From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] atomic create+open
Date: Fri, 07 Oct 2005 10:47:57 -0400 [thread overview]
Message-ID: <1128696477.8583.17.camel@lade.trondhjem.org> (raw)
In-Reply-To: <E1ENslH-00057W-00@dorka.pomaz.szeredi.hu>
fr den 07.10.2005 Klokka 15:59 (+0200) skreiv Miklos Szeredi:
> So, you are saying OPEN has to do the lookup too. That's OK, but that
> _does not_ mean that you have to do the OPEN operation from the
> ->lookup() or ->d_revalidate() methods. In fact you cannot do the
> later without getting into trouble over mounts.
You cannot do anything else without getting into trouble over dentry
races. Given that choice, I prefer to take my chances with the mounts as
those are rare.
We can add locking in order to exclude the mount races, or we can just
ignore them. AFAICS there are 2 cases:
1) umount races
refcounting of any in-use dentry is supposed to prevent trouble here.
2) mount races. Either
Just ignore if the filesystem has already opened the file.
or
Add locking to prevent races.
> > If you end up opening a different file to the one you looked up, things
> > can get very interesting.
>
> You can replace the inode in ->create_open() if you want to. Or let
> the VFS redo the lookup (as if d_revalidate() returned 0).
...but I cannot do that once I get to dentry_open(). You are ignoring
the case of generic file open without creation.
> > > I know you are thinking of the non-exclusive create case when between
> > > the lookup and the open the file is removed or transmuted on the
> > > server..
> >
> > > Yes, it's tricky to sovle, but by no means impossible without atomic
> > > lookup+open. E.g. consider this pseudo-code (only the atomic
> > > open+create case) in open_namei():
> >
> > Firstly, that pseudo-code doesn't deal at all with the race you describe
> > above. It only deals with lookup + file creation.
>
> It does deal with the race:
>
> __lookup_hash() returns a positive dentry
>
> file is removed on server
>
> "else if (!(flag & O_EXCL) && may_create(dir))" condition is met
>
> __follow_mount() return false
>
> vfs_create_open() calls ->create_open()
>
> NFS does OPEN (O_CREAT), file is opened, dentry replaced (this is not
> ellaborated in the pseudocode).
Which again only deals with the case of open(O_CREAT). My point is that
the race exists for the case of generic open().
If you first lookup the dentry in open_namei(), then end up opening a
completely different file in dentry_open(), then you are fscked.
Cheers,
Trond
next prev parent reply other threads:[~2005-10-07 14:48 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-06 14:38 Miklos Szeredi
2005-10-06 16:41 ` Trond Myklebust
2005-10-06 17:02 ` Miklos Szeredi
2005-10-06 17:06 ` Miklos Szeredi
2005-10-06 17:25 ` Trond Myklebust
2005-10-06 17:30 ` Miklos Szeredi
2005-10-06 17:42 ` Trond Myklebust
2005-10-06 17:51 ` Miklos Szeredi
2005-10-06 18:00 ` Jamie Lokier
2005-10-06 18:48 ` Daniel Jacobowitz
2005-10-06 18:38 ` Trond Myklebust
2005-10-06 18:49 ` Miklos Szeredi
2005-10-06 19:17 ` Trond Myklebust
2005-10-06 20:17 ` Miklos Szeredi
2005-10-06 21:12 ` Trond Myklebust
2005-10-07 6:01 ` Miklos Szeredi
2005-10-07 13:38 ` Trond Myklebust
2005-10-07 13:59 ` Miklos Szeredi
2005-10-07 14:47 ` Trond Myklebust [this message]
2005-10-07 15:18 ` Miklos Szeredi
2005-10-07 16:01 ` Trond Myklebust
2005-10-07 17:20 ` Miklos Szeredi
2005-10-07 15:13 ` Trond Myklebust
2005-10-07 15:28 ` Miklos Szeredi
2005-10-07 16:23 ` Trond Myklebust
2005-10-07 17:27 ` Miklos Szeredi
2005-10-07 17:36 ` Trond Myklebust
[not found] ` <1129061494.11164.38.camel@lade.trondhjem.org>
[not found] ` <E1EPeM4-0000Xz-00@dorka.pomaz.szeredi.hu>
2005-10-12 13:20 ` Trond Myklebust
2005-10-12 13:52 ` Miklos Szeredi
2005-10-12 19:01 ` Trond Myklebust
2005-10-12 19:53 ` Miklos Szeredi
2005-10-12 15:20 ` Miklos Szeredi
2005-10-06 17:07 ` Trond Myklebust
2005-10-06 17:23 ` Miklos Szeredi
2005-10-06 17:36 ` Trond Myklebust
2005-10-06 17:47 ` Miklos Szeredi
2005-10-06 17:59 ` Jamie Lokier
2005-10-06 18:13 ` Miklos Szeredi
2005-10-06 18:42 ` Trond Myklebust
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=1128696477.8583.17.camel@lade.trondhjem.org \
--to=trond.myklebust@fys.uio.no \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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
all inboxes | Powered by JetHome®