Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2011 23:56:58 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r222334 - head/sys/ufs/ffs
Message-ID:  <201105262356.p4QNuwbd086354@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Thu May 26 23:56:58 2011
New Revision: 222334
URL: http://svn.freebsd.org/changeset/base/222334

Log:
  The check for whether a block is going to be claimed by a snapshot
  needs to happen before we notify the underlying layer that it is
  being freed.

Modified:
  head/sys/ufs/ffs/ffs_alloc.c

Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c	Thu May 26 23:30:28 2011	(r222333)
+++ head/sys/ufs/ffs/ffs_alloc.c	Thu May 26 23:56:58 2011	(r222334)
@@ -1873,10 +1873,7 @@ ffs_blkfree_cg(ump, fs, devvp, bno, size
 		/* devvp is a normal disk device */
 		dev = devvp->v_rdev;
 		cgblkno = fsbtodb(fs, cgtod(fs, cg));
-		ASSERT_VOP_LOCKED(devvp, "ffs_blkfree");
-		if ((devvp->v_vflag & VV_COPYONWRITE) &&
-		    ffs_snapblkfree(fs, devvp, bno, size, inum))
-			return;
+		ASSERT_VOP_LOCKED(devvp, "ffs_blkfree_cg");
 	}
 #ifdef INVARIANTS
 	if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 ||
@@ -2030,6 +2027,17 @@ ffs_blkfree(ump, fs, devvp, bno, size, i
 	struct bio *bip;
 	struct ffs_blkfree_trim_params *tp;
 
+	/*
+	 * Check to see if a snapshot wants to claim the block.
+	 * Check that devvp is a normal disk device, not a snapshot,
+	 * it has a snapshot(s) associated with it, and one of the
+	 * snapshots wants to claim the block.
+	 */
+	if (devvp->v_type != VREG &&
+	    (devvp->v_vflag & VV_COPYONWRITE) &&
+	    ffs_snapblkfree(fs, devvp, bno, size, inum)) {
+		return;
+	}
 	if (!ump->um_candelete) {
 		ffs_blkfree_cg(ump, fs, devvp, bno, size, inum, dephd);
 		return;



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