Date: Fri, 13 Apr 2007 17:46:22 GMT From: Ulf Lilleengen <lulf@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 118020 for review Message-ID: <200704131746.l3DHkMYD004382@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=118020 Change 118020 by lulf@lulf_vimes on 2007/04/13 17:45:56 - Update and create new SoC branches. Affected files ... .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum.h#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_drive.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_init.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_list.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_move.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_plex.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_raid5.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_raid5.h#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_rename.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_rm.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_share.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_share.h#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_state.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_subr.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_var.h#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_kernel/geom_vinum_volume.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_user/Makefile#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_user/gvinum.8#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_user/gvinum.c#1 branch .. //depot/projects/soc2007/lulf-gvinum/vinum_user/gvinum.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_drive.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_init.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_list.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_move.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_plex.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_raid5.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_raid5.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_rename.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_rm.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_share.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_share.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_state.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_subr.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_var.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_kernel/geom_vinum_volume.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/Makefile#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_drive.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_init.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_list.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_move.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_plex.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_raid5.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_raid5.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_rename.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_rm.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_share.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_share.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_state.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_subr.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_var.h#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/geom_vinum_volume.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/gvinum.8#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/gvinum.c#1 branch .. //depot/projects/soc2007/lulf/gvinum_fixup/vinum_user/gvinum.h#1 branch .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum.h#2 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_drive.c#2 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_plex.c#2 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_rm.c#3 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_subr.c#4 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_var.h#2 edit .. //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_volume.c#2 edit .. //depot/user/lulf/gvinum_concat/vinum_kernel/geom_vinum_create.c#6 edit .. //depot/user/lulf/gvinum_concat/vinum_kernel/geom_vinum_share.c#2 edit .. //depot/user/lulf/gvinum_concat/vinum_user/gvinum.c#14 edit Differences ... ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum.h#2 (text+ko) ==== @@ -91,5 +91,7 @@ int gv_sd_to_plex(struct gv_plex *, struct gv_sd *, int); void gv_update_plex_config(struct gv_plex *); void gv_update_vol_size(struct gv_volume *, off_t); +off_t gv_vol_size(struct gv_volume *); +off_t gv_plex_size(struct gv_plex *); #endif /* !_GEOM_VINUM_H_ */ ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_drive.c#2 (text+ko) ==== @@ -401,7 +401,7 @@ struct g_geom *gp, *gp2; struct g_consumer *cp; struct gv_drive *d; - struct gv_sd *s; + struct gv_sd *s, *s2; struct gv_softc *sc; struct gv_freelist *fl; struct gv_hdr *vhdr; @@ -463,7 +463,6 @@ * configuration. */ d = gv_find_drive(sc, vhdr->label.name); - /* We already know about this drive. */ if (d != NULL) { /* Check if this drive already has a geom. */ @@ -471,10 +470,22 @@ g_topology_unlock(); break; } - bcopy(vhdr, d->hdr, sizeof(*vhdr)); - + /* If we have a dummy, remove it. */ + if (d->flags & GV_DRIVE_DUMMY) { + LIST_FOREACH_SAFE(s, &d->subdisks, from_drive, + s2) { + s->drive_sc = NULL; + LIST_REMOVE(s, from_drive); + } + LIST_REMOVE(d, drive); + g_free(d); + d = NULL; + } else + bcopy(vhdr, d->hdr, sizeof(*vhdr)); + + } /* This is a new drive. */ - } else { + if (d == NULL) { d = g_malloc(sizeof(*d), M_WAITOK | M_ZERO); /* Initialize all needed variables. */ @@ -526,10 +537,12 @@ * them. */ LIST_FOREACH(s, &sc->subdisks, sd) { - if (!strncmp(s->drive, d->name, GV_MAXDRIVENAME)) + if (!strncmp(s->drive, d->name, GV_MAXDRIVENAME)) { /* XXX: errors ignored */ gv_sd_to_drive(sc, d, s, errstr, sizeof(errstr)); + s->flags ^= GV_SD_AWAITING; + } } /* This drive is now up for sure. */ ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_plex.c#2 (text+ko) ==== @@ -728,6 +728,9 @@ * configuration, we don't check the given value (should we?). * XXX: shouldn't be done here */ + printf("Adding sd %s on drive %s\n", s->name, s->drive); + if (s->flags & GV_SD_AWAITING) + s->state = GV_SD_DOWN; gv_sd_to_plex(p, s, 0); /* Now check if there's already a geom for this plex. */ ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_rm.c#3 (text+ko) ==== @@ -217,9 +217,7 @@ { struct g_geom *gp; struct gv_volume *v; - struct gv_plex *p2; struct gv_sd *s, *s2; - off_t minplexsize; int err; g_topology_assert(); @@ -265,16 +263,8 @@ p->vol_sc->plexcount--; LIST_REMOVE(p, in_volume); p->vol_sc = NULL; - /* Correctly update the volume size. XXX: Do this on subdisk - * removal also? */ - p2 = LIST_FIRST(&v->plexes); - minplexsize = p2->size; - LIST_FOREACH(p2, &v->plexes, plex) { - if (p2->size < minplexsize) { - minplexsize = p2->size; - } - } - gv_update_vol_size(v, minplexsize); + /* Correctly update the volume size. */ + gv_update_vol_size(v, gv_vol_size(v)); } gv_kill_plex_thread(p); @@ -293,14 +283,28 @@ gv_rm_sd(struct gv_softc *sc, struct gctl_req *req, struct gv_sd *s, int flags) { struct g_provider *pp; + struct gv_plex *p; + struct gv_volume *v; KASSERT(s != NULL, ("gv_rm_sd: NULL s")); pp = s->provider; + p = s->plex_sc; + v = NULL; /* Clean up. */ - if (s->plex_sc) + if (p != NULL) { LIST_REMOVE(s, in_plex); + + p->sdcount--; + /* Update the plexsize. */ + p->size = gv_plex_size(p); + v = p->vol_sc; + if (v != NULL) { + /* Update the size of our plex' volume. */ + gv_update_vol_size(v, gv_vol_size(v)); + } + } if (s->drive_sc) LIST_REMOVE(s, from_drive); LIST_REMOVE(s, sd); ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_subr.c#4 (text+ko) ==== @@ -89,6 +89,7 @@ struct gv_volume *v, *v2; struct gv_plex *p, *p2; struct gv_sd *s, *s2; + struct gv_drive *d; int tokens; char *token[GV_MAXARGS]; @@ -164,6 +165,25 @@ } } + /* If drive's not up yet, we create a dummy. */ + d = gv_find_drive(sc, s->drive); + if (d == NULL) { + d = g_malloc(sizeof(*d), + M_WAITOK | M_ZERO); + d->size = s->size; + strlcpy(d->name, s->drive, + GV_MAXDRIVENAME); + d->flags |= GV_DRIVE_DUMMY; + LIST_INSERT_HEAD(&sc->drives, d, + drive); + LIST_INSERT_HEAD(&d->subdisks, s, + from_drive); + s->drive_sc = d; + } + + if ((d->flags & GV_DRIVE_DUMMY) && s->state == GV_SD_UP) + s->flags |= GV_SD_AWAITING; + s->vinumconf = sc; LIST_INSERT_HEAD(&sc->subdisks, s, sd); } @@ -345,6 +365,60 @@ v->size = size; } +/* Calculates the plex size. */ +off_t +gv_plex_size(struct gv_plex *p) +{ + struct gv_sd *s; + off_t size; + + KASSERT(p != NULL, ("gv_plex_size: NULL p")); + + if (p->sdcount == 0) + return (0); + + /* Adjust the size of our plex. */ + size = 0; + switch (p->org) { + case GV_PLEX_CONCAT: + LIST_FOREACH(s, &p->subdisks, in_plex) + size += s->size; + break; + case GV_PLEX_STRIPED: + s = LIST_FIRST(&p->subdisks); + size = p->sdcount * s->size; + break; + case GV_PLEX_RAID5: + s = LIST_FIRST(&p->subdisks); + size = (p->sdcount - 1) * s->size; + break; + } + + return (size); +} + +/* Returns the size of a volume. */ +off_t +gv_vol_size(struct gv_volume *v) +{ + struct gv_plex *p; + off_t minplexsize; + + KASSERT(v != NULL, ("gv_vol_size: NULL v")); + + p = LIST_FIRST(&v->plexes); + if (p == NULL) + return (0); + + minplexsize = p->size; + LIST_FOREACH(p, &v->plexes, plex) { + if (p->size < minplexsize) { + minplexsize = p->size; + } + } + return (minplexsize); +} + void gv_update_plex_config(struct gv_plex *p) { @@ -641,13 +715,11 @@ gv_free_sd(struct gv_sd *s) { struct gv_drive *d; - struct gv_plex *p; struct gv_freelist *fl, *fl2; KASSERT(s != NULL, ("gv_free_sd: NULL s")); d = s->drive_sc; - p = s->plex_sc; if (d == NULL) return; @@ -693,21 +765,8 @@ fl->offset = s->drive_offset; } - printf("Decrementing from %d to %d\n", p->sdcount, p->sdcount - 1); d->avail += s->size; d->sdcount--; - p->sdcount--; - switch(p->org) { - case GV_PLEX_CONCAT: - p->size -= s->size; - break; - case GV_PLEX_STRIPED: - p->size = p->sdcount * s->size; - break; - case GV_PLEX_RAID5: - p->size = (p->sdcount - 1) * s->size; - break; - } } void ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_var.h#2 (text+ko) ==== @@ -190,6 +190,7 @@ #define GV_DRIVE_THREAD_DIE 0x02 /* Signal the worker thread to die. */ #define GV_DRIVE_THREAD_DEAD 0x04 /* The worker thread has died. */ #define GV_DRIVE_NEWBORN 0x08 /* The drive was just created. */ +#define GV_DRIVE_DUMMY 0x10 /* This is a dummy drive. */ struct gv_hdr *hdr; /* The drive header. */ @@ -230,6 +231,7 @@ int flags; #define GV_SD_NEWBORN 0x01 /* Subdisk was just created. */ #define GV_SD_INITCANCEL 0x02 /* Cancel initialization process. */ +#define GV_SD_AWAITING 0x04 /* Awaiting underlying drive. */ char drive[GV_MAXDRIVENAME]; /* Name of underlying drive. */ char plex[GV_MAXPLEXNAME]; /* Name of associated plex. */ ==== //depot/user/lulf/gvinum_bugs/vinum_kernel/geom_vinum_volume.c#2 (text+ko) ==== ==== //depot/user/lulf/gvinum_concat/vinum_kernel/geom_vinum_create.c#6 (text+ko) ==== ==== //depot/user/lulf/gvinum_concat/vinum_kernel/geom_vinum_share.c#2 (text+ko) ==== ==== //depot/user/lulf/gvinum_concat/vinum_user/gvinum.c#14 (text+ko) ==== @@ -170,11 +170,6 @@ if (name == NULL) err(1, "not enough memory"); -/* req = gctl_get_handle(); - gctl_ro_param(req, "class", -1, "VINUM"); - gctl_ro_param(req, "verb", -1, "exists"); - gctl_ro_param(req, "type", sizeof(int), &type);*/ - /* * We loop to find a unique drive name for our object. Jump out of the loop * if we reach 100000, which is a pretty big number never going to be reach @@ -220,12 +215,8 @@ printf("Trying to create drive on %s\n", device); /* Strip away eventual /dev/ in front. */ - if (*device == '/') { - device++; - while (*device != '/') - device++; - device++; - } + if (strncmp(device, "/dev/", 5) == 0) + device += 5; drivename = gvinum_find_name("gvinumdrive", GV_TYPE_DRIVE, GV_MAXDRIVENAME);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704131746.l3DHkMYD004382>