From: NeilBrown <neilb@ownmail.net>
To: "Al Viro" <viro@zeniv.linux.org.uk>
Cc: torvalds@linux-foundation.org, linux-fsdevel@vger.kernel.org,
brauner@kernel.org, jack@suse.cz, miklos@szeredi.hu
Subject: Re: [PATCH 1/9] allow finish_no_open(file, ERR_PTR(-E...))
Date: Sat, 13 Sep 2025 13:34:37 +1000 [thread overview]
Message-ID: <175773447741.1696783.10506741669018237734@noble.neil.brown.name> (raw)
In-Reply-To: <20250912185916.400113-1-viro@zeniv.linux.org.uk>
On Sat, 13 Sep 2025, Al Viro wrote:
> ... allowing any ->lookup() return value to be passed to it.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> fs/open.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index 9655158c3885..4890b13461c7 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -1059,18 +1059,20 @@ EXPORT_SYMBOL(finish_open);
> * finish_no_open - finish ->atomic_open() without opening the file
> *
> * @file: file pointer
> - * @dentry: dentry or NULL (as returned from ->lookup())
> + * @dentry: dentry, ERR_PTR(-E...) or NULL (as returned from ->lookup())
> *
> - * This can be used to set the result of a successful lookup in ->atomic_open().
> + * This can be used to set the result of a lookup in ->atomic_open().
This is my favourite part of the series - removing the word
"successful". It makes the API more general.
My only other thought is that
if (d_in_lookup(dentry)) {
struct dentry *res = dir->i_op->lookup(dir, dentry, 0);
if (res || d_really_is_positive(dentry))
return finish_no_open(file, res);
}
is a common pattern. It would be nice if we could factor it out into a
help but I cannot think of a clean way to do that.
You can add
Reviewed-by: NeilBrown <neil@brown.name>
if you like.
Thanks,
NeilBrown
> *
> * NB: unlike finish_open() this function does consume the dentry reference and
> * the caller need not dput() it.
> *
> - * Returns "0" which must be the return value of ->atomic_open() after having
> - * called this function.
> + * Returns 0 or -E..., which must be the return value of ->atomic_open() after
> + * having called this function.
> */
> int finish_no_open(struct file *file, struct dentry *dentry)
> {
> + if (IS_ERR(dentry))
> + return PTR_ERR(dentry);
> file->f_path.dentry = dentry;
> return 0;
> }
> --
> 2.47.2
>
>
next prev parent reply other threads:[~2025-09-13 3:34 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 20:32 [RFC] a possible way of reducing the PITA of ->d_name audits Al Viro
2025-09-07 21:51 ` Linus Torvalds
2025-09-08 0:06 ` Al Viro
2025-09-08 0:47 ` Linus Torvalds
2025-09-08 2:51 ` Al Viro
2025-09-08 3:57 ` Al Viro
2025-09-08 4:50 ` NeilBrown
2025-09-08 5:19 ` Al Viro
2025-09-08 6:25 ` NeilBrown
2025-09-08 9:05 ` Al Viro
2025-09-10 2:45 ` NeilBrown
2025-09-10 7:24 ` Al Viro
2025-09-10 22:52 ` NeilBrown
2025-09-12 5:49 ` ->atomic_open() fun (was Re: [RFC] a possible way of reducing the PITA of ->d_name audits) Al Viro
2025-09-12 8:23 ` Miklos Szeredi
2025-09-12 18:29 ` Al Viro
2025-09-12 19:22 ` Miklos Szeredi
2025-09-12 20:36 ` Al Viro
2025-09-12 20:50 ` Al Viro
2025-09-13 3:36 ` NeilBrown
2025-09-13 5:07 ` Al Viro
2025-09-13 5:50 ` NeilBrown
2025-09-14 19:01 ` Miklos Szeredi
2025-09-14 19:50 ` Al Viro
2025-09-14 20:05 ` Miklos Szeredi
2025-09-15 8:54 ` Bernd Schubert
2025-09-12 18:55 ` Al Viro
2025-09-12 18:59 ` [PATCH 1/9] allow finish_no_open(file, ERR_PTR(-E...)) Al Viro
2025-09-12 18:59 ` [PATCH 2/9] 9p: simplify v9fs_vfs_atomic_open() Al Viro
2025-09-12 18:59 ` [PATCH 3/9] 9p: simplify v9fs_vfs_atomic_open_dotl() Al Viro
2025-09-12 18:59 ` [PATCH 4/9] simplify cifs_atomic_open() Al Viro
2025-09-12 18:59 ` [PATCH 5/9] simplify vboxsf_dir_atomic_open() Al Viro
2025-09-12 18:59 ` [PATCH 6/9] simplify nfs_atomic_open_v23() Al Viro
2025-09-12 18:59 ` [PATCH 7/9] simplify fuse_atomic_open() Al Viro
2025-09-12 18:59 ` [PATCH 8/9] simplify gfs2_atomic_open() Al Viro
2025-09-12 18:59 ` [PATCH 9/9] slightly simplify nfs_atomic_open() Al Viro
2025-09-12 22:23 ` [PATCH 1/9] allow finish_no_open(file, ERR_PTR(-E...)) Linus Torvalds
2025-09-13 3:34 ` NeilBrown [this message]
2025-09-13 21:28 ` [RFC] a possible way of reducing the PITA of ->d_name audits Al Viro
2025-09-14 1:05 ` NeilBrown
2025-09-14 1:37 ` Al Viro
2025-09-14 5:56 ` Al Viro
2025-09-14 23:07 ` NeilBrown
-- strict thread matches above, loose matches on Subject: below --
2025-09-17 23:24 [PATCHES] finish_no_open() calling conventions change Al Viro
2025-09-17 23:27 ` [PATCH 1/9] allow finish_no_open(file, ERR_PTR(-E...)) 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=175773447741.1696783.10506741669018237734@noble.neil.brown.name \
--to=neilb@ownmail.net \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neil@brown.name \
--cc=torvalds@linux-foundation.org \
--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).