summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-11-29 01:22:44 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-11-29 01:22:44 -0500
commitf4e14505ed19a1527aa69a0474fe3b15ddf8b188 (patch)
tree8737374dac9b4b62f83dece0fc6feee7cdc5ed52
parent3a6be7bc18f593789728fa9887bc74c9bf9d1930 (diff)
downloade2fsprogs-f4e14505ed19a1527aa69a0474fe3b15ddf8b188.tar.gz
e2fsck: Don't rehash directories which can fit in a single directory block
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/rehash.c12
-rw-r--r--tests/f_dup_de/expect.112
-rw-r--r--tests/f_dup_de/expect.22
3 files changed, 19 insertions, 7 deletions
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 46d04e49..780742e9 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -736,6 +736,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
fd.compress = 1;
fd.parent = 0;
+retry_nohash:
/* Read in the entire directory into memory */
retval = ext2fs_block_iterate2(fs, ino, 0, 0,
fill_dir_block, &fd);
@@ -744,6 +745,17 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
goto errout;
}
+ /*
+ * If the entries read are less than a block, then don't index
+ * the directory
+ */
+ if (!fd.compress && (fd.dir_size < (fs->blocksize - 24))) {
+ fd.compress = 1;
+ fd.dir_size = 0;
+ fd.num_array = 0;
+ goto retry_nohash;
+ }
+
#if 0
printf("%d entries (%d bytes) found in inode %d\n",
fd.num_array, fd.dir_size, ino);
diff --git a/tests/f_dup_de/expect.1 b/tests/f_dup_de/expect.1
index 78545cc1..e4215478 100644
--- a/tests/f_dup_de/expect.1
+++ b/tests/f_dup_de/expect.1
@@ -5,24 +5,24 @@ Duplicate entry 'mailcap.dpkg-old' found.
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
-Duplicate entry 'mailcap.dpkg-old' in /etc (12) found. Clear? yes
-
Duplicate entry 'fstab' in /etc (12) found. Clear? yes
Duplicate entry 'localtime' in /etc (12) found. Clear? yes
-Duplicate entry 'resolv.conf' in /etc (12) found. Clear? yes
-
-Duplicate entry 'usb.permissions' in /etc (12) found. Clear? yes
+Duplicate entry 'mailcap.dpkg-old' in /etc (12) found. Clear? yes
Duplicate entry 'modules.conf.old' in /etc (12) found. Clear? yes
Entry 'modules.conf.old' in /etc (12) has a non-unique filename.
Rename to modules.conf.o~0? yes
+Duplicate entry 'resolv.conf' in /etc (12) found. Clear? yes
+
+Duplicate entry 'usb.permissions' in /etc (12) found. Clear? yes
+
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 18/2048 files (5.6% non-contiguous), 325/330 blocks
+test_filesys: 18/2048 files (5.6% non-contiguous), 324/330 blocks
Exit status is 1
diff --git a/tests/f_dup_de/expect.2 b/tests/f_dup_de/expect.2
index e3accc66..4d680afe 100644
--- a/tests/f_dup_de/expect.2
+++ b/tests/f_dup_de/expect.2
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 18/2048 files (5.6% non-contiguous), 325/330 blocks
+test_filesys: 18/2048 files (5.6% non-contiguous), 324/330 blocks
Exit status is 0