From: "Theodore Ts'o" <tytso@mit.edu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Markus Trippelsdorf <markus@trippelsdorf.de>,
linux-kernel@vger.kernel.org, eugene@ibrix.com,
msnitzer@ibrix.com, akpm@linux-foundation.org,
"Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH 2/2] ext4: Fix duplicate entries returned from getdents() system call
Date: Sat, 25 Oct 2008 22:42:13 -0400 [thread overview]
Message-ID: <1224988933-13343-2-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1224988933-13343-1-git-send-email-tytso@mit.edu>
Fix a regression caused by commit d0156417, "ext4: fix ext4_dx_readdir
hash collision handling", where deleting files in a large directory
(requiring more than one getdents system call), results in some
filenames being returned twice. This was caused by a failure to
update info->curr_hash and info->curr_minor_hash, so that if the
directory had gotten modified since the last getdents() system call
(as would be the case if the user is running "rm -r" or "git clean"),
a directory entry would get returned twice to the userspace.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This patch fixes the bug reported by Markus Trippelsdorf at:
http://bugzilla.kernel.org/show_bug.cgi?id=11844
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
---
fs/ext4/dir.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 3ca6a2b..fed5b61 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -459,17 +459,8 @@ static int ext4_dx_readdir(struct file *filp,
if (info->extra_fname) {
if (call_filldir(filp, dirent, filldir, info->extra_fname))
goto finished;
-
info->extra_fname = NULL;
- info->curr_node = rb_next(info->curr_node);
- if (!info->curr_node) {
- if (info->next_hash == ~0) {
- filp->f_pos = EXT4_HTREE_EOF;
- goto finished;
- }
- info->curr_hash = info->next_hash;
- info->curr_minor_hash = 0;
- }
+ goto next_node;
} else if (!info->curr_node)
info->curr_node = rb_first(&info->root);
@@ -501,9 +492,14 @@ static int ext4_dx_readdir(struct file *filp,
info->curr_minor_hash = fname->minor_hash;
if (call_filldir(filp, dirent, filldir, fname))
break;
-
+ next_node:
info->curr_node = rb_next(info->curr_node);
- if (!info->curr_node) {
+ if (info->curr_node) {
+ fname = rb_entry(info->curr_node, struct fname,
+ rb_hash);
+ info->curr_hash = fname->hash;
+ info->curr_minor_hash = fname->minor_hash;
+ } else {
if (info->next_hash == ~0) {
filp->f_pos = EXT4_HTREE_EOF;
break;
--
1.5.6.1.205.ge2c7.dirty
prev parent reply other threads:[~2008-10-26 2:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-22 9:32 ext3: fix ext3_dx_readdir hash collision handling - Regression Markus Trippelsdorf
2008-10-23 3:28 ` Theodore Tso
2008-10-23 6:37 ` Markus Trippelsdorf
2008-10-24 0:01 ` Theodore Tso
[not found] ` <20081024042851.GA2360@gentoox2.trippelsdorf.de>
2008-10-24 10:41 ` Theodore Tso
2008-10-24 16:08 ` Linus Torvalds
2008-10-24 20:44 ` Theodore Tso
2008-10-24 22:00 ` Re* " Junio C Hamano
2008-10-24 22:26 ` Linus Torvalds
2008-10-24 22:35 ` Junio C Hamano
2008-10-25 11:56 ` [PATCH] " Theodore Tso
2008-10-25 12:25 ` Markus Trippelsdorf
2008-10-25 21:15 ` Linus Torvalds
2008-10-26 2:39 ` [GIT PULL] " Theodore Tso
2008-10-26 2:42 ` [PATCH 1/2] ext3: Fix duplicate entries returned from getdents() system call Theodore Ts'o
2008-10-26 2:42 ` Theodore Ts'o [this message]
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=1224988933-13343-2-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=akpm@linux-foundation.org \
--cc=eugene@ibrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus@trippelsdorf.de \
--cc=msnitzer@ibrix.com \
--cc=torvalds@linux-foundation.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 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.