ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
To: xiubli@redhat.com
Cc: brauner@kernel.org, stgraber@ubuntu.com,
	linux-fsdevel@vger.kernel.org,
	Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>,
	Jeff Layton <jlayton@kernel.org>,
	Ilya Dryomov <idryomov@gmail.com>,
	ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 13/15] ceph: pass idmap to ceph_open/ioctl_set_layout/readdir
Date: Fri,  9 Jun 2023 11:31:24 +0200	[thread overview]
Message-ID: <20230609093125.252186-14-aleksandr.mikhalitsyn@canonical.com> (raw)
In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com>

Pass an idmapping to:
- ceph_open
- ceph_ioctl_set_layout
- ceph_readdir

Cc: Xiubo Li <xiubli@redhat.com>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: brauner@kernel.org
Cc: ceph-devel@vger.kernel.org
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
---
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


  parent reply	other threads:[~2023-06-09  9:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  9:31 [PATCH v6 00/15] ceph: support idmapped mounts Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 01/15] fs: export mnt_idmap_get/mnt_idmap_put Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 02/15] ceph: stash idmapping in mdsc request Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 03/15] ceph: handle idmapped mounts in create_request_message() Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 04/15] ceph: pass an idmapping to mknod/symlink/mkdir/rename Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 05/15] ceph: allow idmapped getattr inode op Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 06/15] ceph: allow idmapped permission " Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 07/15] ceph: pass idmap to __ceph_setattr Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 08/15] ceph: allow idmapped setattr inode op Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 09/15] ceph/acl: allow idmapped set_acl " Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 10/15] ceph/file: allow idmapped atomic_open " Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 11/15] ceph: pass idmap to ceph_do_getattr Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 12/15] ceph: pass idmap to __ceph_setxattr Alexander Mikhalitsyn
2023-06-09  9:31 ` Alexander Mikhalitsyn [this message]
2023-06-09  9:31 ` [PATCH v6 14/15] ceph: pass idmap to ceph_netfs_issue_op_inline Alexander Mikhalitsyn
2023-06-09  9:31 ` [PATCH v6 15/15] ceph: allow idmapped mounts Alexander Mikhalitsyn

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=20230609093125.252186-14-aleksandr.mikhalitsyn@canonical.com \
    --to=aleksandr.mikhalitsyn@canonical.com \
    --cc=brauner@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stgraber@ubuntu.com \
    --cc=xiubli@redhat.com \
    /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).