svn commit: r218052 - projects/graid/head/sys/geom/raid

Warner Losh imp at FreeBSD.org
Sat Jan 29 00:21:40 UTC 2011


Author: imp
Date: Sat Jan 29 00:21:40 2011
New Revision: 218052
URL: http://svn.freebsd.org/changeset/base/218052

Log:
  Stop leaking BIOs on rebuild.  We used to leak 20k of them on a 20GB
  rebuild.  Now we leak none.
  
  Also, if g_clone_bp() fails during a rebuild, just stop rebuilding for
  a while.  Maybe the next step here would be actually reusing the BPs
  since we don't really need to clone them for a rebuild (we do for
  resync however).
  
  # But we do leak them when we do actual I/O to the disk still :(

Modified:
  projects/graid/head/sys/geom/raid/tr_raid1.c

Modified: projects/graid/head/sys/geom/raid/tr_raid1.c
==============================================================================
--- projects/graid/head/sys/geom/raid/tr_raid1.c	Fri Jan 28 23:44:57 2011	(r218051)
+++ projects/graid/head/sys/geom/raid/tr_raid1.c	Sat Jan 29 00:21:40 2011	(r218052)
@@ -179,9 +179,6 @@ g_raid_tr_raid1_rebuild_some(struct g_ra
 		g_raid_tr_raid1_rebuild_abort(tr, sd->sd_volume);
 		return;
 	}
-	trs->trso_flags |= TR_RAID1_F_DOING_SOME;
-	trs->trso_recover_slabs = SD_REBUILD_CLUSTER_IDLE;
-	trs->trso_fair_io = SD_REBUILD_FAIR_IO;
 	bp = &trs->trso_bio;
 	memset(bp, 0, sizeof(*bp));
 	bp->bio_offset = sd->sd_rebuild_pos;
@@ -190,8 +187,13 @@ g_raid_tr_raid1_rebuild_some(struct g_ra
 	bp->bio_data = trs->trso_buffer;
 	bp->bio_cmd = BIO_READ;
 	bp2 = g_clone_bio(bp);
+	if (bp2 == NULL)	/* We'll try again later */
+		return;
 	bp2->bio_cflags = G_RAID_BIO_FLAG_SYNC;
 	bp2->bio_caller1 = good_sd;
+	trs->trso_recover_slabs = SD_REBUILD_CLUSTER_IDLE;
+	trs->trso_fair_io = SD_REBUILD_FAIR_IO;
+	trs->trso_flags |= TR_RAID1_F_DOING_SOME;
 	g_raid_lock_range(sd->sd_volume,	/* Lock callback starts I/O */
 	    bp2->bio_offset, bp2->bio_length, bp2);
 }
@@ -609,11 +611,23 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_
 					return;
 				}
 				cbp = g_clone_bio(pbp);
+				if (cbp == NULL) {
+					/*
+					 * By flagging that we're not doing anything,
+					 * we'll pick up the rebuild at a later point
+					 * either by timeout or when we steal a small
+					 * part of the active I/O.
+					 */
+					g_destroy_bio(bp); /* reuse? */
+					trs->trso_flags &= ~TR_RAID1_F_DOING_SOME;
+					return;
+				}
 				cbp->bio_cmd = BIO_WRITE;
 				cbp->bio_cflags = G_RAID_BIO_FLAG_SYNC;
 				cbp->bio_offset = bp->bio_offset;
 				cbp->bio_length = bp->bio_length;
 				G_RAID_LOGREQ(4, bp, "Queueing reguild write.");
+				g_destroy_bio(bp); /* reuse? */
 				g_raid_subdisk_iostart(trs->trso_failed_sd, cbp);
 			} else {
 				/*
@@ -630,8 +644,10 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_
 				    "rebuild write done. Error %d", bp->bio_error);
 				if (bp->bio_error != 0) {
 					g_raid_tr_raid1_rebuild_abort(tr, vol);
+					g_destroy_bio(bp); /* reuse? */
 					return;
 				}
+				g_destroy_bio(bp); /* reuse? */
 /* XXX A lot of the following is needed when we kick of the work -- refactor */
 				nsd = trs->trso_failed_sd;
 				g_raid_unlock_range(sd->sd_volume,
@@ -657,6 +673,16 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_
 				}
 				pbp->bio_offset = nsd->sd_rebuild_pos;
 				cbp = g_clone_bio(pbp);
+				if (cbp == NULL) {
+					/*
+					 * By flagging that we're not doing anything,
+					 * we'll pick up the rebuild at a later point
+					 * either by timeout or when we steal a small
+					 * part of the active I/O.
+					 */
+					trs->trso_flags &= ~TR_RAID1_F_DOING_SOME;
+					return;
+				}
 				cbp->bio_cmd = BIO_READ;
 				cbp->bio_cflags = G_RAID_BIO_FLAG_SYNC;
 				cbp->bio_offset = nsd->sd_rebuild_pos;


More information about the svn-src-projects mailing list