Skip to contentSkip to conversation

ceph: set pool_ns in new inode layout for async creates

PATCH Superseded Jeff Layton 2 participants 4 messages Jan 25, 2022 – Jan 26, 2022 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: set pool_ns in new inode layout for async creates

Dan reported that he was unable to write to files that had been asynchronously created when the client's OSD caps are restricted to a particular namespace.

The issue is that the layout for the new inode is only partially being filled. Ensure that we populate the pool_ns_data and pool_ns_len in the iinfo before calling ceph_fill_inode.

Fixes 9a8d03ca2e2c ("ceph: attempt to do async create when possible")
---
 fs/ceph/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/file.c +7 -0
index cbe4d5a5cde5..efea321ff643 100644
@@ -599,6 +599,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
 	struct ceph_inode_info *ci = ceph_inode(dir);
 	struct inode *inode;
 	struct timespec64 now;
+	struct ceph_string *pool_ns;
 	struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
 	struct ceph_vino vino = { .ino = req->r_deleg_ino,
 				  .snap = CEPH_NOSNAP };
@@ -648,11 +649,17 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
 	in.max_size = cpu_to_le64(lo->stripe_unit);
 
 	ceph_file_layout_to_legacy(lo, &in.layout);
+	pool_ns = ceph_try_get_string(lo->pool_ns);
+	if (pool_ns) {
+		iinfo.pool_ns_len = pool_ns->len;
+		iinfo.pool_ns_data = pool_ns->str;
+	}
 
 	down_read(&mdsc->snap_rwsem);
 	ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session,
 			      req->r_fmode, NULL);
 	up_read(&mdsc->snap_rwsem);
+	ceph_put_string(pool_ns);
 	if (ret) {
 		dout("%s failed to fill inode: %d\n", __func__, ret);
 		ceph_dir_clear_complete(dir);
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 29 lines · Jeff Layton

Dan reported that he was unable to write to files that had been asynchronously created when the client's OSD caps are restricted to a particular namespace.

The issue is that the layout for the new inode is only partially being filled. Ensure that we populate the pool_ns_data and pool_ns_len in the iinfo before calling ceph_fill_inode.

Fixes 9a8d03ca2e2c ("ceph: attempt to do async create when possible")
---
 fs/ceph/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/file.c +1 -0
index cbe4d5a5cde5..efea321ff643 100644
@@ -599,6 +599,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        struct ceph_inode_info *ci = ceph_inode(dir);
        struct inode *inode;
        struct timespec64 now;
+       struct ceph_string *pool_ns;
        struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_vino vino = { .ino = req->r_deleg_ino,
                                  .snap = CEPH_NOSNAP };

fs/ceph/file.c static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, · line 656

Quoted 8 lines
fs/ceph/file.c +5 -0
@@ -648,11 +649,17 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        in.max_size = cpu_to_le64(lo->stripe_unit);
 
        ceph_file_layout_to_legacy(lo, &in.layout);
+       pool_ns = ceph_try_get_string(lo->pool_ns);
+       if (pool_ns) {
+               iinfo.pool_ns_len = pool_ns->len;
+               iinfo.pool_ns_data = pool_ns->str;
+       }

Considering that we have a reference from try_prep_async_create(), do we actually need to bother with ceph_try_get_string() here?

Thanks,

Ilya

#2 lore raw
Quoted 32 lines · Ilya Dryomov
Quoted 31 lines · Jeff Layton

Dan reported that he was unable to write to files that had been asynchronously created when the client's OSD caps are restricted to a particular namespace.

The issue is that the layout for the new inode is only partially being filled. Ensure that we populate the pool_ns_data and pool_ns_len in the iinfo before calling ceph_fill_inode.

Fixes 9a8d03ca2e2c ("ceph: attempt to do async create when possible")
---
 fs/ceph/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/file.c +1 -0
index cbe4d5a5cde5..efea321ff643 100644
@@ -599,6 +599,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        struct ceph_inode_info *ci = ceph_inode(dir);
        struct inode *inode;
        struct timespec64 now;
+       struct ceph_string *pool_ns;
        struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_vino vino = { .ino = req->r_deleg_ino,
                                  .snap = CEPH_NOSNAP };
@@ -648,11 +649,17 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        in.max_size = cpu_to_le64(lo->stripe_unit);
 
Quoted 10 lines

fs/ceph/file.c static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, · line 656

Quoted 6 lines
fs/ceph/file.c +5 -0
        ceph_file_layout_to_legacy(lo, &in.layout);
+       pool_ns = ceph_try_get_string(lo->pool_ns);
+       if (pool_ns) {
+               iinfo.pool_ns_len = pool_ns->len;
+               iinfo.pool_ns_data = pool_ns->str;
+       }

Considering that we have a reference from try_prep_async_create(), do we actually need to bother with ceph_try_get_string() here?

Technically, no. We could just do a rcu_dereference_protected there since we know that lo is private and can't change. Want me to send a v2?

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#3 lore raw
Quoted 45 lines · Jeff Layton
Quoted 32 lines · Ilya Dryomov
Quoted 31 lines · Jeff Layton

Dan reported that he was unable to write to files that had been asynchronously created when the client's OSD caps are restricted to a particular namespace.

The issue is that the layout for the new inode is only partially being filled. Ensure that we populate the pool_ns_data and pool_ns_len in the iinfo before calling ceph_fill_inode.

Fixes 9a8d03ca2e2c ("ceph: attempt to do async create when possible")
---
 fs/ceph/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/file.c +1 -0
index cbe4d5a5cde5..efea321ff643 100644
@@ -599,6 +599,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        struct ceph_inode_info *ci = ceph_inode(dir);
        struct inode *inode;
        struct timespec64 now;
+       struct ceph_string *pool_ns;
        struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
        struct ceph_vino vino = { .ino = req->r_deleg_ino,
                                  .snap = CEPH_NOSNAP };
@@ -648,11 +649,17 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        in.max_size = cpu_to_le64(lo->stripe_unit);
 
Quoted 10 lines

fs/ceph/file.c static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, · line 656

Quoted 6 lines
fs/ceph/file.c +5 -0
        ceph_file_layout_to_legacy(lo, &in.layout);
+       pool_ns = ceph_try_get_string(lo->pool_ns);
+       if (pool_ns) {
+               iinfo.pool_ns_len = pool_ns->len;
+               iinfo.pool_ns_data = pool_ns->str;
+       }

Considering that we have a reference from try_prep_async_create(), do we actually need to bother with ceph_try_get_string() here?

Quoted 2 lines

Technically, no. We could just do a rcu_dereference_protected there since we know that lo is private and can't change. Want me to send a v2?

Yeah, let's not do the reference dance when it isn't needed.

I'd probably use rcu_dereference_raw() to avoid having to think about omitted READ_ONCE (even if the reasoning is trivial), but up to you.

Thanks,

Ilya