[PATCH v6 13/15] ceph: pass idmap to ceph_open/ioctl_set_layout/readdir

From: Alexander Mikhalitsyn
Date: Fri Jun 09 2023 - 05:52:00 EST


Pass an idmapping to:
- ceph_open
- ceph_ioctl_set_layout
- ceph_readdir

Cc: Xiubo Li <xiubli@xxxxxxxxxx>
Cc: Jeff Layton <jlayton@xxxxxxxxxx>
Cc: Ilya Dryomov <idryomov@xxxxxxxxx>
Cc: brauner@xxxxxxxxxx
Cc: ceph-devel@xxxxxxxxxxxxxxx
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@xxxxxxxxxxxxx>
---
v6:
- pass idmap to ceph_readdir
---
fs/ceph/caps.c | 2 +-
fs/ceph/dir.c | 2 ++
fs/ceph/file.c | 9 +++++++--
fs/ceph/ioctl.c | 3 +++
fs/ceph/super.h | 2 +-
5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index b432f29e80dd..13c231258153 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3042,7 +3042,7 @@ int __ceph_get_caps(struct mnt_idmap *idmap, struct inode *inode,
}
if (ret == -EUCLEAN) {
/* session was killed, try renew caps */
- ret = ceph_renew_caps(inode, flags);
+ ret = ceph_renew_caps(idmap, inode, flags);
if (ret == 0)
continue;
}
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 2c0c2c98085b..26335c025f50 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -308,6 +308,7 @@ static bool need_send_readdir(struct ceph_dir_file_info *dfi, loff_t pos)
static int ceph_readdir(struct file *file, struct dir_context *ctx)
{
struct ceph_dir_file_info *dfi = file->private_data;
+ struct mnt_idmap *idmap = file_mnt_idmap(file);
struct inode *inode = file_inode(file);
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
@@ -440,6 +441,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
req->r_inode = inode;
ihold(inode);
req->r_dentry = dget(file->f_path.dentry);
+ req->r_mnt_idmap = mnt_idmap_get(idmap);
err = ceph_mdsc_do_request(mdsc, NULL, req);
if (err < 0) {
ceph_mdsc_put_request(req);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index c2bb8f5fd345..9671b0e77faf 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -175,7 +175,8 @@ static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty)
* inopportune ENOMEM later.
*/
static struct ceph_mds_request *
-prepare_open_request(struct super_block *sb, int flags, int create_mode)
+prepare_open_request(struct super_block *sb,
+ int flags, int create_mode)
{
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb);
struct ceph_mds_request *req;
@@ -293,7 +294,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
/*
* try renew caps after session gets killed.
*/
-int ceph_renew_caps(struct inode *inode, int fmode)
+int ceph_renew_caps(struct mnt_idmap *idmap, struct inode *inode, int fmode)
{
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb);
struct ceph_inode_info *ci = ceph_inode(inode);
@@ -336,6 +337,8 @@ int ceph_renew_caps(struct inode *inode, int fmode)
ihold(inode);
req->r_num_caps = 1;

+ req->r_mnt_idmap = mnt_idmap_get(idmap);
+
err = ceph_mdsc_do_request(mdsc, NULL, req);
ceph_mdsc_put_request(req);
out:
@@ -356,6 +359,7 @@ int ceph_open(struct inode *inode, struct file *file)
struct ceph_mds_client *mdsc = fsc->mdsc;
struct ceph_mds_request *req;
struct ceph_file_info *fi = file->private_data;
+ struct mnt_idmap *idmap = file_mnt_idmap(file);
int err;
int flags, fmode, wanted;

@@ -431,6 +435,7 @@ int ceph_open(struct inode *inode, struct file *file)
ihold(inode);

req->r_num_caps = 1;
+ req->r_mnt_idmap = mnt_idmap_get(idmap);
err = ceph_mdsc_do_request(mdsc, NULL, req);
if (!err)
err = ceph_init_file(inode, file, req->r_fmode);
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 6fa021b973e5..69efd446a9e1 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -114,6 +114,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
req->r_inode = inode;
ihold(inode);
req->r_num_caps = 1;
+ req->r_mnt_idmap = mnt_idmap_get(idmap);

req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL;

@@ -139,6 +140,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
{
struct inode *inode = file_inode(file);
+ struct mnt_idmap *idmap = file_mnt_idmap(file);
struct ceph_mds_request *req;
struct ceph_ioctl_layout l;
int err;
@@ -160,6 +162,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
req->r_inode = inode;
ihold(inode);
req->r_num_caps = 1;
+ req->r_mnt_idmap = mnt_idmap_get(idmap);

req->r_args.setlayout.layout.fl_stripe_unit =
cpu_to_le32(l.stripe_unit);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 05dbae76087c..d89e7b99ac5f 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1308,7 +1308,7 @@ static inline bool ceph_has_inline_data(struct ceph_inode_info *ci)
/* file.c */
extern const struct file_operations ceph_file_fops;

-extern int ceph_renew_caps(struct inode *inode, int fmode);
+extern int ceph_renew_caps(struct mnt_idmap *idmap, struct inode *inode, int fmode);
extern int ceph_open(struct inode *inode, struct file *file);
extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct file *file, unsigned flags, umode_t mode);
--
2.34.1