From owner-p4-projects@FreeBSD.ORG Tue Jul 17 21:16:36 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 0229B16A406; Tue, 17 Jul 2007 21:16:36 +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 7757416A404 for ; Tue, 17 Jul 2007 21:16:35 +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 66FD313C441 for ; Tue, 17 Jul 2007 21:16:35 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6HLGZUq079311 for ; Tue, 17 Jul 2007 21:16:35 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6HLGYhS079308 for perforce@freebsd.org; Tue, 17 Jul 2007 21:16:34 GMT (envelope-from lulf@FreeBSD.org) Date: Tue, 17 Jul 2007 21:16:34 GMT Message-Id: <200707172116.l6HLGYhS079308@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 123664 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: Tue, 17 Jul 2007 21:16:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=123664 Change 123664 by lulf@lulf_carrot on 2007/07/17 21:15:51 - Remove gv_raid5_offset_read and add a flag to the normal offset command to tell it if it needs to handle subdisks in the GROW state. Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_raid5.c#10 edit Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_raid5.c#10 (text+ko) ==== @@ -44,9 +44,7 @@ #include static int gv_raid5_offset(struct gv_plex *, off_t, off_t, - off_t *, off_t *, int *, int *); -static int gv_raid5_offset_read(struct gv_plex *, off_t, off_t, - off_t *, off_t *, int *, int *); + off_t *, off_t *, int *, int *, int); static struct bio * gv_raid5_clone_bio(struct bio *, struct gv_sd *, struct gv_raid5_packet *, caddr_t, int); static int gv_raid5_request(struct gv_plex *, struct gv_raid5_packet *, @@ -172,7 +170,7 @@ if (p == NULL || LIST_EMPTY(&p->subdisks)) return (ENXIO); - gv_raid5_offset(p, boff, bcount, &real_off, &real_len, NULL, &psdno); + gv_raid5_offset(p, boff, bcount, &real_off, &real_len, NULL, &psdno, 0); /* Find the right subdisk. */ parity = NULL; @@ -246,7 +244,7 @@ if (p == NULL || LIST_EMPTY(&p->subdisks)) return (ENXIO); - gv_raid5_offset(p, boff, bcount, &real_off, &real_len, NULL, NULL); + gv_raid5_offset(p, boff, bcount, &real_off, &real_len, NULL, NULL, 0); /* Find the right subdisk. */ broken = NULL; @@ -345,11 +343,11 @@ /* Reads must take into account the growing plexes. */ if (bp->bio_cmd == BIO_READ) - gv_raid5_offset_read(p, boff, bcount, &real_off, &real_len, - &sdno, &psdno); + gv_raid5_offset(p, boff, bcount, &real_off, &real_len, &sdno, + &psdno, 1); else gv_raid5_offset(p, boff, bcount, &real_off, &real_len, &sdno, - &psdno); + &psdno, 0); printf("Got sdno %d and psdno %d\n", sdno, psdno); /* Find the right subdisks. */ @@ -543,8 +541,8 @@ * plexlist before, we get problems. */ static int -gv_raid5_offset_read(struct gv_plex *p, off_t boff, off_t bcount, - off_t *real_off, off_t *real_len, int *sdno, int *psdno) +gv_raid5_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off, + off_t *real_len, int *sdno, int *psdno, int growing) { struct gv_sd *s; int sd, psd, sdcount; @@ -552,68 +550,20 @@ printf("In read we take into account new subdisks.\n"); sdcount = p->sdcount; - LIST_FOREACH(s, &p->subdisks, in_plex) { - if (s->flags & GV_SD_GROW) { - printf("Decrease\n"); - sdcount--; + if (growing) { + LIST_FOREACH(s, &p->subdisks, in_plex) { + if (s->flags & GV_SD_GROW) + sdcount--; } } /* The number of the subdisk containing the parity stripe. */ psd = sdcount - 1 - ( boff / (p->stripesize * (sdcount - 1))) % sdcount; - KASSERT(psdno >= 0, ("gv_raid5_offset_read: psdno < 0")); + KASSERT(psdno >= 0, ("gv_raid5_offset: psdno < 0")); /* Offset of the start address from the start of the stripe. */ stripeoff = boff % (p->stripesize * (sdcount - 1)); - KASSERT(stripeoff >= 0, ("gv_raid5_offset_read: stripeoff < 0")); - - /* The number of the subdisk where the stripe resides. */ - sd = stripeoff / p->stripesize; - KASSERT(sdno >= 0, ("gv_raid5_offset_read: sdno < 0")); - - /* At or past parity subdisk. */ - if (sd >= psd) - sd++; - - /* The offset of the stripe on this subdisk. */ - stripestart = (boff - stripeoff) / (sdcount - 1); - KASSERT(stripestart >= 0, ("gv_raid5_offset_read: stripestart < 0")); - - stripeoff %= p->stripesize; - - /* The offset of the request on this subdisk. */ - *real_off = stripestart + stripeoff; - - stripeend = stripestart + p->stripesize; - len_left = stripeend - *real_off; - KASSERT(len_left >= 0, ("gv_raid5_offset_read: len_left < 0")); - - *real_len = (bcount <= len_left) ? bcount : len_left; - - if (sdno != NULL) - *sdno = sd; - if (psdno != NULL) - *psdno = psd; - - return (0); -} - -/* Calculate the offsets in the various subdisks for a RAID5 request. */ -static int -gv_raid5_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off, - off_t *real_len, int *sdno, int *psdno) -{ - int sd, psd; - off_t len_left, stripeend, stripeoff, stripestart; - - /* The number of the subdisk containing the parity stripe. */ - psd = p->sdcount - 1 - ( boff / (p->stripesize * (p->sdcount - 1))) % - p->sdcount; - KASSERT(psdno >= 0, ("gv_raid5_offset: psdno < 0")); - - /* Offset of the start address from the start of the stripe. */ - stripeoff = boff % (p->stripesize * (p->sdcount - 1)); KASSERT(stripeoff >= 0, ("gv_raid5_offset: stripeoff < 0")); /* The number of the subdisk where the stripe resides. */ @@ -625,7 +575,7 @@ sd++; /* The offset of the stripe on this subdisk. */ - stripestart = (boff - stripeoff) / (p->sdcount - 1); + stripestart = (boff - stripeoff) / (sdcount - 1); KASSERT(stripestart >= 0, ("gv_raid5_offset: stripestart < 0")); stripeoff %= p->stripesize;