From 69fc473ab3b7ad17d88abf0626e21c10d697f1aa Mon Sep 17 00:00:00 2001 From: le Date: Tue, 15 Jun 2004 20:56:25 +0000 Subject: Fix several bugs related to subdisk drive_offset calculation. --- sys/geom/vinum/geom_vinum_subr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/geom/vinum/geom_vinum_subr.c b/sys/geom/vinum/geom_vinum_subr.c index 55cf583..9c7d713 100644 --- a/sys/geom/vinum/geom_vinum_subr.c +++ b/sys/geom/vinum/geom_vinum_subr.c @@ -467,7 +467,7 @@ gv_sd_to_drive(struct gv_softc *sc, struct gv_drive *d, struct gv_sd *s, if (s->size == -1) { /* Find the largest available slot. */ LIST_FOREACH(fl, &d->freelist, freelist) { - if (fl->size > s->size) { + if (fl->size >= s->size) { s->size = fl->size; s->drive_offset = fl->offset; fl2 = fl; @@ -490,8 +490,9 @@ gv_sd_to_drive(struct gv_softc *sc, struct gv_drive *d, struct gv_sd *s, /* Yes, this subdisk fits. */ if (fl->size >= s->size) { i++; - /* Override drive_offset, if given. */ - s->drive_offset = fl->offset; + /* Assign drive offset, if not given. */ + if (s->drive_offset == -1) + s->drive_offset = fl->offset; fl2 = fl; break; } @@ -517,7 +518,7 @@ gv_sd_to_drive(struct gv_softc *sc, struct gv_drive *d, struct gv_sd *s, * If there are no other subdisks yet, then set the default * offset to GV_DATA_START. */ - if (s->drive_offset == 0) + if (s->drive_offset == -1) s->drive_offset = GV_DATA_START; /* Check if we have a free slot at the given drive offset. */ -- cgit v1.1