From: Al Viro <viro@zeniv.linux.org.uk>
To: NeilBrown <neil@brown.name>
Cc: Christian Brauner <brauner@kernel.org>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Jeff Layton <jlayton@kernel.org>,
Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 2/2] VFS: don't call ->atomic_open on cached negative without O_CREAT
Date: Wed, 17 Sep 2025 05:23:48 +0100 [thread overview]
Message-ID: <20250917042348.GS39973@ZenIV> (raw)
In-Reply-To: <20250915031134.2671907-3-neilb@ownmail.net>
On Mon, Sep 15, 2025 at 01:01:08PM +1000, NeilBrown wrote:
> All filesystems with ->atomic_open() currently handle the case of a
> negative dentry without O_CREAT either by returning -ENOENT or by
> calling finish_no_open(), either with NULL or with the negative dentry.
Wait a sec... Just who is passing finish_no_open() a negative dentry?
Any such is very likely to be a bug...
> All of these have the same effect.
>
> For filesystems without ->atomic_open(), lookup_open() will, in this
> case, also call finish_no_open().
>
> So this patch removes the burden from filesystems by calling
> finish_no_open() early on a negative cached dentry when O_CREAT isn't
> requested.
Re "removing the burden" - it still can be called with negative cached without
O_CREAT.
O_CREAT in open(2) arguments might not survive to the call of atomic_open() -
in case when you don't have write permissions on parent. In that case
we strip O_CREAT and call into atomic_open() (if the method is there).
In that case -ENOENT from atomic_open() is translated into -EACCES or -EROFS:
dentry = atomic_open(nd, dentry, file, open_flag, mode);
if (unlikely(create_error) && dentry == ERR_PTR(-ENOENT))
dentry = ERR_PTR(create_error);
return dentry;
In case when no ->atomic_open() is there the same logics is
if (unlikely(create_error) && !dentry->d_inode) {
error = create_error;
goto out_dput;
}
in the very end of lookup_open(). The point is, you might have had a call
of ->d_revalidate() with LOOKUP_CREATE|LOOKUP_OPEN and then have the damn
thing passed to ->atomic_open() with no O_CREAT in flags.
next prev parent reply other threads:[~2025-09-17 4:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 3:01 VFS: change ->atomic_open() calling to always have exclusive access NeilBrown
2025-09-15 3:01 ` [PATCH 1/2] NFS: remove d_drop()/d_alloc_paralle() from nfs_atomic_open() NeilBrown
2025-09-15 3:01 ` [PATCH 2/2] VFS: don't call ->atomic_open on cached negative without O_CREAT NeilBrown
2025-09-17 4:23 ` Al Viro [this message]
2025-09-17 7:36 ` NeilBrown
2025-09-17 4:34 ` VFS: change ->atomic_open() calling to always have exclusive access Al Viro
2025-09-17 7:25 ` NeilBrown
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=20250917042348.GS39973@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=amir73il@gmail.com \
--cc=anna@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=trondmy@kernel.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.