Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Nov 2012 00:36:40 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243641 - head/sys/fs/ext2fs
Message-ID:  <201211280036.qAS0aeSO094520@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Wed Nov 28 00:36:40 2012
New Revision: 243641
URL: http://svnweb.freebsd.org/changeset/base/243641

Log:
  Partially bring r242520 to ext2fs.
  
  When a file is first being written, the dynamic block reallocation
  (implemented by ext2_reallocblks) relocates the file's blocks
  so as to cluster them together into a contiguous set of blocks on
  the disk.
  
  When the cluster crosses the boundary into the first indirect block,
  the first indirect block is initially allocated in a position
  immediately following the last direct block.  Block reallocation
  would usually destroy locality by moving the indirect block out of
  the way to keep the data blocks contiguous.
  
  The issue was diagnosed long ago by Bruce Evans on ffs and surfaced
  on ext2fs when block reallocaton was ported. This is only a partial
  solution based on the similarities with FFS. We still require more
  review of the allocation details that vary in ext2fs.
  
  Reported by:	bde
  MFC after:	1 week

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_alloc.c	Wed Nov 28 00:02:17 2012	(r243640)
+++ head/sys/fs/ext2fs/ext2_alloc.c	Wed Nov 28 00:36:40 2012	(r243641)
@@ -197,6 +197,18 @@ ext2_reallocblks(ap)
 			panic("ext2_reallocblks: non-cluster");
 #endif
 	/*
+	 * If the cluster crosses the boundary for the first indirect
+	 * block, leave space for the indirect block. Indirect blocks
+	 * are initially laid out in a position after the last direct
+	 * block. Block reallocation would usually destroy locality by
+	 * moving the indirect block out of the way to make room for
+	 * data blocks if we didn't compensate here. We should also do
+	 * this for other indirect block boundaries, but it is only
+	 * important for the first one.
+	 */
+	if (start_lbn < NDADDR && end_lbn >= NDADDR)
+		return (ENOSPC);
+	/*
 	 * If the latest allocation is in a new cylinder group, assume that
 	 * the filesystem has decided to move and do not force it back to
 	 * the previous cylinder group.



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