summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2014-03-20 21:19:13 +0000
committerpfg <pfg@FreeBSD.org>2014-03-20 21:19:13 +0000
commit81396b10ba992f9eeb7af2731c0cb390d65a17e8 (patch)
tree748cff57d81d2ae4124709164b4be4d2e36aec38 /sys/fs
parent2babaa36d7395945084bafdde10218682e306b93 (diff)
downloadFreeBSD-src-81396b10ba992f9eeb7af2731c0cb390d65a17e8.zip
FreeBSD-src-81396b10ba992f9eeb7af2731c0cb390d65a17e8.tar.gz
ext2fs: minor update to the dirpref policy.
Bring in a minor change to the dirpref policy based on r248623. This is pretty minimal change to keep the implementation in sync with UFS but other parts from the original change are not directly applicable so don't expect improvements in fsck times. MFC after: 2 weeks
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/ext2fs/ext2_alloc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c
index 106a124..5486c04 100644
--- a/sys/fs/ext2fs/ext2_alloc.c
+++ b/sys/fs/ext2fs/ext2_alloc.c
@@ -510,6 +510,22 @@ ext2_dirpref(struct inode *pip)
* Limit number of dirs in one cg and reserve space for
* regular files, but only if we have no deficit in
* inodes or space.
+ *
+ * We are trying to find a suitable cylinder group nearby
+ * our preferred cylinder group to place a new directory.
+ * We scan from our preferred cylinder group forward looking
+ * for a cylinder group that meets our criterion. If we get
+ * to the final cylinder group and do not find anything,
+ * we start scanning backwards from our preferred cylinder
+ * group. The ideal would be to alternate looking forward
+ * and backward, but that is just too complex to code for
+ * the gain it would get. The most likely place where the
+ * backward scan would take effect is when we start near
+ * the end of the filesystem and do not find anything from
+ * where we are to the end. In that case, scanning backward
+ * will likely find us a suitable cylinder group much closer
+ * to our desired location than if we were to start scanning
+ * forward from the beginning of the filesystem.
*/
prefcg = ino_to_cg(fs, pip->i_number);
for (cg = prefcg; cg < fs->e2fs_gcount; cg++)
@@ -519,7 +535,7 @@ ext2_dirpref(struct inode *pip)
if (fs->e2fs_contigdirs[cg] < maxcontigdirs)
return (cg);
}
- for (cg = 0; cg < prefcg; cg++)
+ for (cg = prefcg - 1; cg >= 0; cg--)
if (fs->e2fs_gd[cg].ext2bgd_ndirs < maxndir &&
fs->e2fs_gd[cg].ext2bgd_nifree >= minifree &&
fs->e2fs_gd[cg].ext2bgd_nbfree >= minbfree) {
@@ -532,7 +548,7 @@ ext2_dirpref(struct inode *pip)
for (cg = prefcg; cg < fs->e2fs_gcount; cg++)
if (fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree)
return (cg);
- for (cg = 0; cg < prefcg; cg++)
+ for (cg = prefcg - 1; cg >= 0; cg--)
if (fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree)
break;
return (cg);
OpenPOWER on IntegriCloud