Create a dedicated structure for holding hotspot information rather than

using slice structures for it.
This commit is contained in:
Poul-Henning Kamp 2003-04-19 10:00:22 +00:00
parent cd3b264dfd
commit 183a45f65e
2 changed files with 24 additions and 18 deletions

@ -152,7 +152,8 @@ g_slice_start(struct bio *bp)
struct g_geom *gp; struct g_geom *gp;
struct g_consumer *cp; struct g_consumer *cp;
struct g_slicer *gsp; struct g_slicer *gsp;
struct g_slice *gsl, *gmp; struct g_slice *gsl;
struct g_slice_hot *gmp;
int idx, error; int idx, error;
u_int m_index; u_int m_index;
off_t t; off_t t;
@ -181,8 +182,8 @@ g_slice_start(struct bio *bp)
g_io_deliver(bp, EINVAL); g_io_deliver(bp, EINVAL);
return; return;
} }
for (m_index = 0; m_index < gsp->nhot; m_index++) { for (m_index = 0; m_index < gsp->nhotspot; m_index++) {
gmp = &gsp->hot[m_index]; gmp = &gsp->hotspot[m_index];
if (t >= gmp->offset + gmp->length) if (t >= gmp->offset + gmp->length)
continue; continue;
if (t + bp->bio_length <= gmp->offset) if (t + bp->bio_length <= gmp->offset)
@ -341,21 +342,21 @@ int
g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length) g_slice_conf_hot(struct g_geom *gp, u_int idx, off_t offset, off_t length)
{ {
struct g_slicer *gsp; struct g_slicer *gsp;
struct g_slice *gsl, *gsl2; struct g_slice_hot *gsl, *gsl2;
g_trace(G_T_TOPOLOGY, "g_slice_conf_hot()"); g_trace(G_T_TOPOLOGY, "g_slice_conf_hot()");
g_topology_assert(); g_topology_assert();
gsp = gp->softc; gsp = gp->softc;
gsl = gsp->hot; gsl = gsp->hotspot;
if(idx >= gsp->nhot) { if(idx >= gsp->nhotspot) {
gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO); gsl2 = g_malloc((idx + 1) * sizeof *gsl2, M_WAITOK | M_ZERO);
if (gsp->hot != NULL) if (gsp->hotspot != NULL)
bcopy(gsp->hot, gsl2, gsp->nhot * sizeof *gsl2); bcopy(gsp->hotspot, gsl2, gsp->nhotspot * sizeof *gsl2);
gsp->hot = gsl2; gsp->hotspot = gsl2;
if (gsp->hot != NULL) if (gsp->hotspot != NULL)
g_free(gsl); g_free(gsl);
gsl = gsl2; gsl = gsl2;
gsp->nhot = idx + 1; gsp->nhotspot = idx + 1;
} }
if (bootverbose) if (bootverbose)
printf("GEOM: Add %s hot[%d] start %jd length %jd end %jd\n", printf("GEOM: Add %s hot[%d] start %jd length %jd end %jd\n",

@ -45,16 +45,21 @@ struct g_slice {
struct g_provider *provider; struct g_provider *provider;
}; };
struct g_slice_hot {
off_t offset;
off_t length;
};
typedef int g_slice_start_t (struct bio *bp); typedef int g_slice_start_t (struct bio *bp);
struct g_slicer { struct g_slicer {
u_int nslice; u_int nslice;
u_int nprovider; u_int nprovider;
u_int nhot; struct g_slice *slices;
struct g_slice *slices; u_int nhotspot;
struct g_slice *hot; struct g_slice_hot *hotspot;
void *softc; void *softc;
g_slice_start_t *start; g_slice_start_t *start;
}; };
g_dumpconf_t g_slice_dumpconf; g_dumpconf_t g_slice_dumpconf;