* [PATCH v2] reiserfs: fix race in readdir
@ 2014-04-02 18:40 Jeff Mahoney
2014-04-02 22:19 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Mahoney @ 2014-04-02 18:40 UTC (permalink / raw)
To: reiserfs-devel; +Cc: Jan Kara
jdm-20004 reiserfs_delete_xattrs: Couldn't delete all xattrs (-2)
The -ENOENT is due to readdir calling dir_emit on the same entry twice.
If the dir_emit callback sleeps and the tree is changed underneath us,
we won't be able to trust deh_offset(deh) anymore. We need to save
next_pos before we might sleep so we can find the next entry.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/dir.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -125,6 +125,7 @@ int reiserfs_readdir_inode(struct inode
int d_reclen;
char *d_name;
ino_t d_ino;
+ loff_t cur_pos = deh_offset(deh);
if (!de_visible(deh))
/* it is hidden entry */
@@ -196,8 +197,9 @@ int reiserfs_readdir_inode(struct inode
if (local_buf != small_buf) {
kfree(local_buf);
}
- // next entry should be looked for with such offset
- next_pos = deh_offset(deh) + 1;
+
+ /* deh_offset(deh) may be invalid now. */
+ next_pos = cur_pos + 1;
if (item_moved(&tmp_ih, &path_to_entry)) {
set_cpu_key_k_offset(&pos_key,
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] reiserfs: fix race in readdir
2014-04-02 18:40 [PATCH v2] reiserfs: fix race in readdir Jeff Mahoney
@ 2014-04-02 22:19 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2014-04-02 22:19 UTC (permalink / raw)
To: Jeff Mahoney; +Cc: reiserfs-devel, Jan Kara
On Wed 02-04-14 14:40:26, Jeff Mahoney wrote:
> jdm-20004 reiserfs_delete_xattrs: Couldn't delete all xattrs (-2)
>
> The -ENOENT is due to readdir calling dir_emit on the same entry twice.
>
> If the dir_emit callback sleeps and the tree is changed underneath us,
> we won't be able to trust deh_offset(deh) anymore. We need to save
> next_pos before we might sleep so we can find the next entry.
>
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Thanks for a quick fix. I've merged the patch to my tree.
Honza
> ---
> fs/reiserfs/dir.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> --- a/fs/reiserfs/dir.c
> +++ b/fs/reiserfs/dir.c
> @@ -125,6 +125,7 @@ int reiserfs_readdir_inode(struct inode
> int d_reclen;
> char *d_name;
> ino_t d_ino;
> + loff_t cur_pos = deh_offset(deh);
>
> if (!de_visible(deh))
> /* it is hidden entry */
> @@ -196,8 +197,9 @@ int reiserfs_readdir_inode(struct inode
> if (local_buf != small_buf) {
> kfree(local_buf);
> }
> - // next entry should be looked for with such offset
> - next_pos = deh_offset(deh) + 1;
> +
> + /* deh_offset(deh) may be invalid now. */
> + next_pos = cur_pos + 1;
>
> if (item_moved(&tmp_ih, &path_to_entry)) {
> set_cpu_key_k_offset(&pos_key,
>
> --
> Jeff Mahoney
> SUSE Labs
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-02 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 18:40 [PATCH v2] reiserfs: fix race in readdir Jeff Mahoney
2014-04-02 22:19 ` Jan Kara
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.