From owner-p4-projects@FreeBSD.ORG Thu May 24 19:27:54 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A074316A4D6; Thu, 24 May 2007 19:27:54 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51D8316A4D1 for ; Thu, 24 May 2007 19:27:54 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 406F013C483 for ; Thu, 24 May 2007 19:27:54 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l4OJRsut088127 for ; Thu, 24 May 2007 19:27:54 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l4OJRrSd088118 for perforce@freebsd.org; Thu, 24 May 2007 19:27:53 GMT (envelope-from lulf@FreeBSD.org) Date: Thu, 24 May 2007 19:27:53 GMT Message-Id: <200705241927.l4OJRrSd088118@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to lulf@FreeBSD.org using -f From: Ulf Lilleengen To: Perforce Change Reviews Cc: Subject: PERFORCE change 120331 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2007 19:27:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=120331 Change 120331 by lulf@lulf_carrot on 2007/05/24 19:27:25 - Add paritycheck as well. - Change name of gv_rebuild_parity to gv_parityop. - Replace old parityop with this one. - Change userland utility to include rebuild flag. Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sbin/gvinum/gvinum.c#4 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#10 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#8 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_plex.c#5 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#9 edit Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sbin/gvinum/gvinum.c#4 (text+ko) ==== @@ -594,6 +594,7 @@ req = gctl_get_handle(); gctl_ro_param(req, "class", -1, "VINUM"); gctl_ro_param(req, "verb", -1, op); + gctl_ro_param(req, "rebuild", sizeof(int), &rebuild); gctl_ro_param(req, "flags", sizeof(int), &flags); gctl_ro_param(req, "plex", -1, argv[0]); ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#10 (text+ko) ==== @@ -335,8 +335,9 @@ gv_move(gp, req); #endif - } else if (!strcmp(verb, "rebuildparity")) { - gv_rebuild_parity(sc, req); + } else if (!strcmp(verb, "rebuildparity") || + !strcmp(verb, "checkparity")) { + gv_parityop(sc, req); } else if (!strcmp(verb, "remove")) { gv_remove(gp, req); @@ -568,7 +569,14 @@ "%d\n", err); break; - case GV_EVENT_REBUILD: + case GV_EVENT_PARITY_REBUILD: + /* Start parity check. */ + p = ev->arg1; + p->synced = 0; + gv_issue_next_parity_bio(p, 0); + break; + + case GV_EVENT_PARITY_CHECK: printf("VINUM: event 'rebuild'\n"); /* * Start the rebuild. The gv_plex_done will @@ -578,7 +586,7 @@ /* XXX: Should check plex state here. */ p = ev->arg1; p->synced = 0; - gv_issue_next_parity_bio(p); + gv_issue_next_parity_bio(p, 1); break; case GV_EVENT_THREAD_EXIT: ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#8 (text+ko) ==== @@ -33,7 +33,7 @@ void gv_save_config(struct gv_softc *); /* geom_vinum_init.c */ -void gv_parityop(struct g_geom *, struct gctl_req *); +/*void gv_parityop(struct g_geom *, struct gctl_req *);*/ void gv_start_obj(struct g_geom *, struct gctl_req *); /* geom_vinum_list.c */ @@ -111,7 +111,7 @@ int gv_stripe_active(struct gv_plex *, struct bio *); -void gv_issue_next_parity_bio(struct gv_plex *); -void gv_rebuild_parity(struct gv_softc *, struct gctl_req *); +void gv_issue_next_parity_bio(struct gv_plex *, int); +void gv_parityop(struct gv_softc *, struct gctl_req *); #endif /* !_GEOM_VINUM_H_ */ ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_plex.c#5 (text+ko) ==== @@ -474,7 +474,7 @@ * XXX: Should perhaps be another place. */ void -gv_issue_next_parity_bio(struct gv_plex *p) +gv_issue_next_parity_bio(struct gv_plex *p, int rebuild) { struct bio *bp; @@ -493,7 +493,8 @@ bp->bio_data = g_malloc(p->stripesize, M_WAITOK | M_ZERO); /* bp->bio_cflags |= GV_BIO_REBUILD;*/ bp->bio_cflags |= GV_BIO_CHECK; - bp->bio_cflags |= GV_BIO_PARITY; + if (rebuild) + bp->bio_cflags |= GV_BIO_PARITY; bp->bio_cflags |= GV_BIO_MALLOC; bp->bio_length = p->stripesize; @@ -502,6 +503,7 @@ printf("VINUM: rebuild of %s finished\n", p->name); g_free(bp->bio_data); g_destroy_bio(bp); + p->synced = 0; return; } @@ -520,9 +522,10 @@ static void gv_parity_completed(struct gv_plex *p, struct bio *bp) { - int error; + int error, rebuild; error = bp->bio_error; + rebuild = bp->bio_cflags & GV_BIO_PARITY; if (bp->bio_cflags & GV_BIO_MALLOC) g_free(bp->bio_data); g_destroy_bio(bp); @@ -530,21 +533,21 @@ /* Clean up what we allocated. */ /* XXX: Check for error type. */ if (error) { - printf("VINUM: Error rebuilding %s at %lld\n", p->name, + printf("VINUM: Parity operation error on %s at %lld\n", p->name, p->synced); return; } - printf("VINUM: Finished parity write at %lld\n", p->synced); + printf("VINUM: Parity operation at %lld finished\n", p->synced); /* Send down next. It will determine if we need to itself. */ - gv_issue_next_parity_bio(p); + gv_issue_next_parity_bio(p, rebuild); } void -gv_rebuild_parity(struct gv_softc *sc, struct gctl_req *req) +gv_parityop(struct gv_softc *sc, struct gctl_req *req) { struct gv_plex *p; - int *flags, type; + int *flags, *rebuild, type; char *plex; plex = gctl_get_param(req, "plex", NULL); @@ -559,6 +562,12 @@ return; } + rebuild = gctl_get_paraml(req, "rebuild", sizeof(*rebuild)); + if (rebuild == NULL) { + gctl_error(req, "no operation given"); + return; + } + type = gv_object_type(sc, plex); if (type != GV_TYPE_PLEX) { gctl_error(req, "'%s' is not a plex", plex); @@ -580,5 +589,8 @@ /* Put it in the event queue. */ /* XXX: The state of the plex might have changed when this event is * picked up ... We should really check this afterwards. */ - gv_post_event(sc, GV_EVENT_REBUILD, p, NULL, NULL); + if (*rebuild) + gv_post_event(sc, GV_EVENT_PARITY_REBUILD, p, NULL, NULL); + else + gv_post_event(sc, GV_EVENT_PARITY_CHECK, p, NULL, NULL); } ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#9 (text+ko) ==== @@ -190,7 +190,8 @@ #define GV_EVENT_SET_VOL_STATE 15 #define GV_EVENT_SET_PLEX_STATE 16 #define GV_EVENT_RESET_CONFIG 17 -#define GV_EVENT_REBUILD 18 +#define GV_EVENT_PARITY_REBUILD 18 +#define GV_EVENT_PARITY_CHECK 19 struct gv_event { int type;