svn commit: r304232 - head/sys/ufs/ffs

Konstantin Belousov kib at FreeBSD.org
Tue Aug 16 17:31:00 UTC 2016


Author: kib
Date: Tue Aug 16 17:30:58 2016
New Revision: 304232
URL: https://svnweb.freebsd.org/changeset/base/304232

Log:
  In UFS_BALLOC(), invalidate pages of indirect buffers on failed block
  allocation unwinding.
  
  Dandling buffers are released on UFS_BALLOC() failure to ensure that
  later attempt to allocate blocks in close range do not find the blocks
  with invalid content, since possible partial block allocations are
  unwound.  As such, it is not enough to just release the buffers, the
  pages must also invalidated and removed from the vnode vm_object
  queue.  Otherwise the pages might be found later and used to
  reconstruct indirect buffers when doing allocations at offset close to
  the failure point, and their stale content compromise the filesystem
  integrity.
  
  Note that just marking the buffer as B_INVAL is not enough, B_NOCACHE
  is required.  To be sure, clear the B_CACHE flag as well.  This
  complements the r174973, which started releasing buffers.
  
  Reported and tested by:	pho
  Reviewed by:	mckusick
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

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

Modified: head/sys/ufs/ffs/ffs_balloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_balloc.c	Tue Aug 16 17:18:38 2016	(r304231)
+++ head/sys/ufs/ffs/ffs_balloc.c	Tue Aug 16 17:30:58 2016	(r304232)
@@ -492,8 +492,8 @@ fail:
 			    (intmax_t)bp->b_lblkno, (uintmax_t)*lbns_remfree,
 			    (uintmax_t)bp->b_blkno,
 			    (uintmax_t)fsbtodb(fs, *blkp)));
-			bp->b_flags |= (B_INVAL | B_RELBUF);
-			bp->b_flags &= ~B_ASYNC;
+			bp->b_flags |= B_INVAL | B_RELBUF | B_NOCACHE;
+			bp->b_flags &= ~(B_ASYNC | B_CACHE);
 			brelse(bp);
 		}
 		deallocated += fs->fs_bsize;
@@ -1087,8 +1087,8 @@ fail:
 			    (intmax_t)bp->b_lblkno, (uintmax_t)*lbns_remfree,
 			    (uintmax_t)bp->b_blkno,
 			    (uintmax_t)fsbtodb(fs, *blkp)));
-			bp->b_flags |= (B_INVAL | B_RELBUF);
-			bp->b_flags &= ~B_ASYNC;
+			bp->b_flags |= B_INVAL | B_RELBUF | B_NOCACHE;
+			bp->b_flags &= ~(B_ASYNC | B_CACHE);
 			brelse(bp);
 		}
 		deallocated += fs->fs_bsize;


More information about the svn-src-head mailing list