From: NeilBrown <neilb@ownmail.net>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
Jori Koolstra <jkoolstra@xs4all.nl>,
Mateusz Guzik <mjguzik@gmail.com>,
Dorjoy Chowdhury <dorjoychy111@gmail.com>
Cc: Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
Andreas Gruenbacher <agruenba@redhat.com>,
gfs2@lists.linux.dev, Ilya Dryomov <idryomov@gmail.com>,
Alex Markuze <amarkuze@redhat.com>,
Viacheslav Dubeyko <slava@dubeyko.com>,
ceph-devel@vger.kernel.org, Paulo Alcantara <pc@manguebit.org>,
Namjae Jeon <linkinjeon@kernel.org>,
linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-nfs@vger.kernel.org
Subject: [PATCH v2 04/14] ceph: simplify atomic_open to use finish_no_open()
Date: Sat, 19 Sep 2026 12:06:08 +1000 [thread overview]
Message-ID: <20260919022441.3305170-5-neilb@ownmail.net> (raw)
In-Reply-To: <20260919022441.3305170-1-neilb@ownmail.net>
From: NeilBrown <neil@brown.name>
The cephfs protocol does not combine lookup/create and open into a
single request/response. atomic_open() first performs the lookup/create
and then if a positive dentry results, this is passed to
finish_open(..., ceph_open) which simply performs a normal open.
The same effect can be achieved more simply be calling finish_no_open().
VFS code will call file_operations->open which is exactly ceph_open.
This fixes a potential bug where an open with __O_REGULAR but not
O_NOFOLLOW may treat a symlink as an error, and also avoids any
possibility of passing a non-regular file to ceph_open()
in ceph_finish_async_create() if __O_REGULAR were set.
It also ensures correct handling of any alias returned by
d_splice_alias().
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/ceph/file.c | 45 ++++++++++++++++++---------------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index bd3e3f5c269e..83ceb2906f85 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -754,7 +754,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
d_drop(dentry);
discard_new_inode(inode);
} else {
- struct dentry *dn;
+ struct dentry *dn = NULL;
doutc(cl, "d_adding new inode 0x%llx to 0x%llx/%s\n",
vino.ino, ceph_ino(dir), dentry->d_name.name);
@@ -775,10 +775,9 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
if (!d_unhashed(dentry))
d_drop(dentry);
dn = d_splice_alias(inode, dentry);
- WARN_ON_ONCE(dn && dn != dentry);
}
file->f_mode |= FMODE_CREATED;
- ret = finish_open(file, dentry, ceph_open);
+ ret = finish_no_open(file, dn);
}
spin_lock(&dentry->d_lock);
@@ -977,33 +976,25 @@ retry:
}
if (err)
goto out_req;
- if (dn || d_really_is_negative(dentry) || d_is_symlink(dentry)) {
- /* make vfs retry on splice, ENOENT, or symlink */
- doutc(cl, "finish_no_open on dn %p\n", dn);
- err = finish_no_open(file, dn);
- } else {
- if (IS_ENCRYPTED(dir) &&
- !fscrypt_has_permitted_context(dir, d_inode(dentry))) {
- pr_warn_client(cl,
- "Inconsistent encryption context (parent %llx:%llx child %llx:%llx)\n",
- ceph_vinop(dir), ceph_vinop(d_inode(dentry)));
- goto out_req;
- }
- doutc(cl, "finish_open on dn %p\n", dn);
- if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
- struct inode *newino = d_inode(dentry);
+ if (IS_ENCRYPTED(dir) &&
+ !fscrypt_has_permitted_context(dir, d_inode(dentry))) {
+ pr_warn_client(cl,
+ "Inconsistent encryption context (parent %llx:%llx child %llx:%llx)\n",
+ ceph_vinop(dir), ceph_vinop(d_inode(dentry)));
+ goto out_req;
+ }
- cache_file_layout(dir, newino);
- ceph_init_inode_acls(newino, &as_ctx);
- file->f_mode |= FMODE_CREATED;
- }
- if ((flags & __O_REGULAR) && !d_is_reg(dentry)) {
- err = -EFTYPE;
- goto out_req;
- }
- err = finish_open(file, dentry, ceph_open);
+ doutc(cl, "finish_no_open on dn %p\n", dn);
+ if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
+ struct inode *newino = d_inode(dentry);
+
+ cache_file_layout(dir, newino);
+ ceph_init_inode_acls(newino, &as_ctx);
+ file->f_mode |= FMODE_CREATED;
}
+ err = finish_no_open(file, dn);
+
out_req:
ceph_mdsc_put_request(req);
iput(new_inode);
--
2.50.0.107.gf914562f5916.dirty
next prev parent reply other threads:[~2026-09-19 2:25 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 2:06 [PATCH v2 01/14] fixes for vfs_lookup_open, and integration with nfsd NeilBrown
2026-09-19 2:06 ` [PATCH v2 01/14] VFS: revise and expand documentation for atomic_open NeilBrown
2026-09-24 12:25 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 02/14] nfs: correctly handle NFS4ERR_WRONG_TYPE from v4 OPEN request NeilBrown
2026-09-24 12:55 ` Jeff Layton
2026-09-24 13:01 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 03/14] gfs2: simplify atomic_open handling NeilBrown
2026-09-19 16:49 ` Andreas Gruenbacher
2026-09-19 22:22 ` NeilBrown
2026-09-20 16:31 ` Andreas Gruenbacher
2026-09-22 21:16 ` NeilBrown
2026-09-19 2:06 ` NeilBrown [this message]
2026-09-24 13:02 ` [PATCH v2 04/14] ceph: simplify atomic_open to use finish_no_open() Jeff Layton
2026-09-25 21:49 ` NeilBrown
2026-09-26 11:48 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 05/14] cifs: allow -EISDIR precedence over -EFTYPE in __cifs_do_create() NeilBrown
2026-09-23 5:54 ` Namjae Jeon
2026-09-23 6:50 ` NeilBrown
2026-09-23 7:52 ` Namjae Jeon
2026-09-23 8:13 ` Namjae Jeon
2026-09-19 2:06 ` [PATCH v2 06/14] vfs: add some allowed open flags to vfs_lookup_open() NeilBrown
2026-09-24 12:54 ` Jeff Layton
2026-09-29 15:18 ` Jori Koolstra
2026-09-29 22:04 ` NeilBrown
2026-09-19 2:06 ` [PATCH v2 07/14] vfs: O_NONBLOCK|O_CREAT open shouldn't wait for directory delegation NeilBrown
2026-09-24 12:51 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 08/14] vfs: don't return -ENODEV from vfs_lookup_open() NeilBrown
2026-09-24 13:07 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 09/14] vfs: change vfs_lookup_open() to use do_open(), not vfs_open() NeilBrown
2026-09-24 13:13 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 10/14] nfsd: make EEXIST checks in nfsd4_create_file() more consistent NeilBrown
2026-09-24 13:23 ` Jeff Layton
2026-09-25 21:57 ` NeilBrown
2026-09-19 2:06 ` [PATCH v2 11/14] nfsd: check for mountpoints after non-creating open NeilBrown
2026-09-24 13:03 ` Jeff Layton
2026-09-25 22:14 ` NeilBrown
2026-09-19 2:06 ` [PATCH v2 12/14] nfsd: switch NFS4 OPEN to use vfs_lookup_open() NeilBrown
2026-09-20 17:10 ` Chuck Lever
2026-09-22 21:55 ` NeilBrown
2026-09-23 4:07 ` NeilBrown
2026-09-19 2:06 ` [PATCH v2 13/14] nfsd: change nfsd_check_obj_isreg() to use nfs error codes NeilBrown
2026-09-24 13:25 ` Jeff Layton
2026-09-19 2:06 ` [PATCH v2 14/14] nfsd: use vfs_lookup_open() for non-creating open requests too NeilBrown
2026-09-20 17:13 ` Chuck Lever
2026-09-25 22:26 ` NeilBrown
2026-09-25 16:04 ` [PATCH v2 01/14] fixes for vfs_lookup_open, and integration with nfsd Christian Brauner
2026-09-25 16:56 ` Chuck Lever
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=20260919022441.3305170-5-neilb@ownmail.net \
--to=neilb@ownmail.net \
--cc=agruenba@redhat.com \
--cc=amarkuze@redhat.com \
--cc=anna@kernel.org \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=dorjoychy111@gmail.com \
--cc=gfs2@lists.linux.dev \
--cc=idryomov@gmail.com \
--cc=jkoolstra@xs4all.nl \
--cc=jlayton@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=neil@brown.name \
--cc=pc@manguebit.org \
--cc=slava@dubeyko.com \
--cc=trondmy@kernel.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