From: Sage Weil <sage@newdream.net>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, viro@ZenIV.linux.org.uk,
akpm@linux-foundation.org, hch@infradead.org
Subject: Re: [PATCH] vfs: fix vfs_rename_dir for FS_RENAME_DOES_D_MOVE filesystems
Date: Fri, 11 Jul 2008 15:15:34 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0807111513530.16351@cobra.newdream.net> (raw)
In-Reply-To: <E1KHPcH-00076R-UD@pomaz-ex.szeredi.hu>
On Fri, 11 Jul 2008, Miklos Szeredi wrote:
> On Fri, 11 Jul 2008, Sage Weil wrote:
> > However, vfs_rename_dir() doesn't properly account for filesystems with
> > FS_RENAME_DOES_D_MOVE. If new_dentry has a target inode attached, it
> > unhashes the new_dentry prior to the rename() iop and rehashes it after,
> > but doesn't account for the possibility that rename() may have swapped
> > {old,new}_dentry. For FS_RENAME_DOES_D_MOVE filesystems, it rehashes
> > new_dentry (now the old renamed-from name, which d_move() expected to go
> > away), such that a subsequent lookup will find it.
> >
> > To correct this, move vfs_rename_dir()'s call to d_move() _before_ the
> > target inode mutex is dealt with. Since d_move() will have been called
> > for all filesystems at this point, there is no need to rehash new_dentry
> > unless the rename failed. (If the rename succeeded, old_dentry should
> > already be rehashed in the new location.)
>
> I think rehashing the new dentry is bogus, even on error. And it
> looks racy with lookup as well.
>
> I wonder what the original reason for that was? Git history doesn't
> tell...
I assume just to leave the dentry in the same stat we originally found it
in?
> So a better fix would be just to remove the rehashing completely.
> Does the below patch work for you?
This would work as well, yeah. I've no real preference, here...
thanks-
sage
>
> Thanks,
> Miklos
>
> ---
> fs/namei.c | 2 --
> 1 file changed, 2 deletions(-)
>
> Index: linux-2.6/fs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/namei.c 2008-07-11 22:09:32.000000000 +0200
> +++ linux-2.6/fs/namei.c 2008-07-11 22:40:16.000000000 +0200
> @@ -2643,8 +2643,6 @@ static int vfs_rename_dir(struct inode *
> if (!error)
> target->i_flags |= S_DEAD;
> mutex_unlock(&target->i_mutex);
> - if (d_unhashed(new_dentry))
> - d_rehash(new_dentry);
> dput(new_dentry);
> }
> if (!error)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
next prev parent reply other threads:[~2008-07-11 22:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 19:47 [PATCH] vfs: fix vfs_rename_dir for FS_RENAME_DOES_D_MOVE filesystems Sage Weil
2008-07-11 20:53 ` Miklos Szeredi
2008-07-11 22:12 ` Zach Brown
2008-07-18 10:59 ` Miklos Szeredi
2008-07-18 19:44 ` Zach Brown
2008-07-11 22:15 ` Sage Weil [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-07-21 11:41 [patch] " Miklos Szeredi
2008-07-21 19:02 ` Al Viro
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=Pine.LNX.4.64.0807111513530.16351@cobra.newdream.net \
--to=sage@newdream.net \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=viro@ZenIV.linux.org.uk \
/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).