From owner-svn-src-projects@FreeBSD.ORG Sat Jan 29 00:21:40 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9D65106564A; Sat, 29 Jan 2011 00:21:40 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 998CF8FC0C; Sat, 29 Jan 2011 00:21:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0T0LeZa006314; Sat, 29 Jan 2011 00:21:40 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0T0Le4G006312; Sat, 29 Jan 2011 00:21:40 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201101290021.p0T0Le4G006312@svn.freebsd.org> From: Warner Losh Date: Sat, 29 Jan 2011 00:21:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218052 - projects/graid/head/sys/geom/raid X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Jan 2011 00:21:40 -0000 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;