linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 4/5] e2fsck: Don't rehash directories which can fit in a single directory block
Date: Sun, 29 Nov 2009 15:33:28 -0500	[thread overview]
Message-ID: <1259526809-23697-4-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1259526809-23697-1-git-send-email-tytso@mit.edu>

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 e2fsck/rehash.c         |   12 ++++++++++++
 tests/f_dup_de/expect.1 |   12 ++++++------
 tests/f_dup_de/expect.2 |    2 +-
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 46d04e4..780742e 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 78545cc..e421547 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 e3accc6..4d680af 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
-- 
1.6.5.216.g5288a.dirty


  parent reply	other threads:[~2009-11-29 20:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-29 20:33 [PATCH 1/5] e2fsck: detect holes in extent-mapped directories Theodore Ts'o
2009-11-29 20:33 ` [PATCH 2/5] libext2fs: Fix SET_BMAP bugs in ext2fs_bmap() and ext2fs_bmap2() Theodore Ts'o
2009-11-29 20:33 ` [PATCH 3/5] e2fsck: Fix block allocation for holes in extent-mapped directories Theodore Ts'o
2009-11-29 20:33 ` Theodore Ts'o [this message]
2009-11-29 20:33 ` [PATCH 5/5] e2fsck: Try to update on-disk bitmap in e2fsck_get_alloc_block() callback Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1259526809-23697-4-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).