All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <yjwei@cn.fujitsu.com>
To: linux-ext4@vger.kernel.org, Theodore Tso <tytso@mit.edu>
Subject: [PATCH] ext4: Fix to read empty directory blocks correctly in 64k blocksize filesystems
Date: Tue, 10 Feb 2009 11:56:20 +0800	[thread overview]
Message-ID: <4990FAE4.1080009@cn.fujitsu.com> (raw)

The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.

But if empty directory block is read, error message will be output
by current kernel. You can do the following commands to reproduct it.

> mkfs.ext4 -b $(( 64 * 1024 )) /dev/sda1
> mount -t ext4 /dev/sda1 /mnt
> cd /mnt/lost+found
> ll
> tail /var/log/messages
EXT4-fs error (device sdc1): ext4_readdir: bad entry in \
directory #11: rec_len is smaller than minimal - offset=0, \
inode=0, rec_len=0, name_len=0

This patch fix to treat rec_len of 0 as 65536, like what e2fsprogs do.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
 fs/ext4/ext4.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index aafc9eb..b0c87dc 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -868,7 +868,7 @@ static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
 {
 	unsigned len = le16_to_cpu(dlen);
 
-	if (len == EXT4_MAX_REC_LEN)
+	if (len == EXT4_MAX_REC_LEN || len == 0)
 		return 1 << 16;
 	return len;
 }
-- 
1.5.3.8




             reply	other threads:[~2009-02-10  3:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10  3:56 Wei Yongjun [this message]
2009-02-10  8:26 ` [PATCHv2] ext4: Fix support for empty directory blocks in 64k blocksize filesystems Wei Yongjun
2009-02-10 15:20 ` [PATCH] ext4: Fix to read empty directory blocks correctly " Theodore Tso
2009-02-11  5:48   ` Andreas Dilger
2009-02-11 15:15     ` Theodore Tso
2009-02-12  6:42       ` Wei Yongjun
2009-02-15  4:07         ` Theodore Tso
2009-02-16 23:32       ` Andreas Dilger
2009-02-17  0:05         ` Theodore Tso

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=4990FAE4.1080009@cn.fujitsu.com \
    --to=yjwei@cn.fujitsu.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.