svn commit: r258556 - stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Andriy Gapon avg at
Mon Nov 25 15:40:21 UTC 2013

Author: avg
Date: Mon Nov 25 15:40:20 2013
New Revision: 258556

  MFC r258353: zfs page_busy: fix the boundaries of the cleared range
  This is a fix for a regression introduced in r246293.
  vm_page_clear_dirty expects the range to have DEV_BSIZE aligned
  otherwise it extends them.  Thus it can happen that the whole page is
  marked clean while actually having some small dirty region(s).
  This commit makes the range properly aligned and ensures that only
  the clean data is marked as such.
  It would interesting to evaluate how much benefit clearing with
  granularity produces.  Perhaps instead we should clear the whole page
  when it is completely overwritten and don't bother clearing any bits
  if only a portion a page is written.

Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/cddl/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Mon Nov 25 15:39:50 2013	(r258555)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Mon Nov 25 15:40:20 2013	(r258556)
@@ -327,6 +327,20 @@ page_busy(vnode_t *vp, int64_t start, in
 	vm_object_t obj;
 	vm_page_t pp;
+	int64_t end;
+	/*
+	 * At present vm_page_clear_dirty extends the cleared range to DEV_BSIZE
+	 * aligned boundaries, if the range is not aligned.  As a result a
+	 * DEV_BSIZE subrange with partially dirty data may get marked as clean.
+	 * It may happen that all DEV_BSIZE subranges are marked clean and thus
+	 * the whole page would be considred clean despite have some dirty data.
+	 * For this reason we should shrink the range to DEV_BSIZE aligned
+	 * boundaries before calling vm_page_clear_dirty.
+	 */
+	end = rounddown2(off + nbytes, DEV_BSIZE);
+	off = roundup2(off, DEV_BSIZE);
+	nbytes = end - off;
 	obj = vp->v_object;
@@ -348,7 +362,8 @@ page_busy(vnode_t *vp, int64_t start, in
-			vm_page_clear_dirty(pp, off, nbytes);
+			if (nbytes != 0)
+				vm_page_clear_dirty(pp, off, nbytes);

More information about the svn-src-stable-8 mailing list