public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>, r6144 <rainy6144@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"ext2-devel@lists.sourceforge.net"
	<ext2-devel@lists.sourceforge.net>,
	phillips@istop.com, Alex Tomas <alex@clusterfs.com>,
	Christopher Li <chrisl@vmware.com>,
	Christopher Li <ext2-devel@chrisli.org>
Subject: Re: Fw: [POSSIBLE-BUG] telldir() broken on ext3 dir_index'd directories just after the first entry.
Date: Wed, 17 Nov 2004 23:53:36 -0500	[thread overview]
Message-ID: <20041118045336.GA5236@thunk.org> (raw)
In-Reply-To: <1100736003.11047.14.camel@sisko.sctweedie.blueyonder.co.uk>

On Thu, Nov 18, 2004 at 12:00:05AM +0000, Stephen C. Tweedie wrote:
> 
> Doesn't this make things worse?  
> don't we end up silently ignoring all dirents with a major hash <= 1,
> even for unbroken getdents() with no intervening seekdir?  

Oops, yes, I screwed up.

> If we're going to do this, I think we need to stuff . and .. into the
> rbtree with the right hashes, but without ignoring other existing
> dirents with colliding hashes.

We can't just do that, because there are programs that's assume '.'
and '..' are the first and second entries in the directory.  Yes, they
are broken and non-portable, but so are programs that depend on
d_off....

So instead what we need to do is wire '.' and '..' to have hash values
of (0,0) and (2,0), respectively, without ignoring other existing
dirents with colliding hashes.  (In those cases the programs will
break, but they are statistically rare, and there's not much we can do
in those cases anyway.)

This patch should do this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

--- 1.59/fs/ext3/namei.c	2004-10-19 05:40:30 -04:00
+++ edited/fs/ext3/namei.c	2004-11-17 23:05:35 -05:00
@@ -610,10 +610,14 @@ int ext3_htree_fill_tree(struct file *di
 		de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
 		if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
 			goto errout;
+		count++;
+	}
+	if (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {
+		de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
 		de = ext3_next_entry(de);
-		if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
+		if ((err = ext3_htree_store_dirent(dir_file, 2, 0, de)) != 0)
 			goto errout;
-		count += 2;
+		count++;
 	}
 
 	while (1) {

  reply	other threads:[~2004-11-18  4:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041116183813.11cbf280.akpm@osdl.org>
2004-11-17 22:34 ` Fw: [POSSIBLE-BUG] telldir() broken on ext3 dir_index'd directories just after the first entry Theodore Ts'o
2004-11-18  0:00   ` Stephen C. Tweedie
2004-11-18  4:53     ` Theodore Ts'o [this message]
2004-11-18 11:22       ` Jan Engelhardt
2004-11-18 14:06         ` Theodore Ts'o
2004-11-18 15:40           ` Jan Engelhardt
2004-11-18 15:37       ` Stephen C. Tweedie

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=20041118045336.GA5236@thunk.org \
    --to=tytso@mit.edu \
    --cc=akpm@osdl.org \
    --cc=alex@clusterfs.com \
    --cc=chrisl@vmware.com \
    --cc=ext2-devel@chrisli.org \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillips@istop.com \
    --cc=rainy6144@gmail.com \
    --cc=sct@redhat.com \
    /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