All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/3] gfs2: bugger off early if O_CREAT open	finds a directory
Date: Wed, 19 Nov 2014 15:46:41 -0500 (EST)	[thread overview]
Message-ID: <1442237591.16635682.1416430001191.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20141119204256.GC7996@ZenIV.linux.org.uk>

----- Original Message -----
> On Wed, Nov 19, 2014 at 03:33:29PM -0500, Bob Peterson wrote:
> > ----- Original Message -----
> > > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> > > ---
> > >  fs/gfs2/inode.c |    5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> > > index c4ed823..310e248 100644
> > > --- a/fs/gfs2/inode.c
> > > +++ b/fs/gfs2/inode.c
> > > @@ -624,6 +624,11 @@ static int gfs2_create_inode(struct inode *dir,
> > > struct
> > > dentry *dentry,
> > >  	inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
> > >  	error = PTR_ERR(inode);
> > >  	if (!IS_ERR(inode)) {
> > > +		if (S_ISDIR(inode->i_mode)) {
> > > +			iput(inode);
> > > +			inode = ERR_PTR(-EISDIR);
> > > +			goto fail_gunlock;
> > > +		}
> > >  		d = d_splice_alias(inode, dentry);
> > >  		error = PTR_ERR(d);
> > >  		if (IS_ERR(d)) {
> 
> > Hm. Seems wrong that it should return 0 if the dirent exists (mkdir of a
> > directory that already exists) but it looks like it already behaves that
> > way.
> > So I guess so. It may warrant further investigation.
> 
> It doesn't.  Note that !S_ISREG(mode) || excl in there - *anything* other
> than ->create() will treat existing entries with the same name as EEXIST.
> The only case when we can possibly get into that if (!IS_ERR(inode)) is
> ->create() hitting an existing file.  And with this change it narrows to
> "->create() hitting an existing non-directory".  That allows the next patch
> to use d_instantiate() instead of d_splice_alias() - for non-directories
> it's the same thing, since dentry is already hashed here and we don't need
> to avoid multiple aliases.  Which kills one of the two places in the
> tree where d_splice_alias() is called for an already hashed dentry (another
> is d_add_ci() and that call also goes down - see vfs.git#for-next for that
> one).
> 
Okay, thanks for clearing that up.

ACK

Bob Peterson
Red Hat File Systems



  reply	other threads:[~2014-11-19 20:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 19:34 [Cluster-devel] [gfs2 patches in vfs.git] Al Viro
2014-11-19 19:34 ` [Cluster-devel] [PATCH 1/3] gfs2: bugger off early if O_CREAT open finds a directory Al Viro
2014-11-19 20:33   ` Bob Peterson
2014-11-19 20:42     ` Al Viro
2014-11-19 20:46       ` Bob Peterson [this message]
2014-11-19 19:35 ` [Cluster-devel] [PATCH 2/3] gfs2_create_inode(): don't bother with d_splice_alias() Al Viro
2014-11-19 19:35 ` [Cluster-devel] [PATCH 3/3] gfs2_atomic_open(): simplify the use of finish_no_open() 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=1442237591.16635682.1416430001191.JavaMail.zimbra@redhat.com \
    --to=rpeterso@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 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.