Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2007 21:16:34 GMT
From:      Ulf Lilleengen <lulf@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123664 for review
Message-ID:  <200707172116.l6HLGYhS079308@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <geom/vinum/geom_vinum.h>
 
 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707172116.l6HLGYhS079308>