Skip to content

Commit 9c2df22

Browse files
brauneridryomov
authored andcommitted
ceph: stash idmapping in mdsc request
When sending a mds request cephfs will send relevant data for the requested operation. For creation requests the caller's fs{g,u}id is used to set the ownership of the newly created filesystem object. For setattr requests the caller can pass in arbitrary {g,u}id values to which the relevant filesystem object is supposed to be changed. If the caller is performing the relevant operation via an idmapped mount cephfs simply needs to take the idmapping into account when it sends the relevant mds request. In order to support idmapped mounts for cephfs we stash the idmapping whenever they are relevant for the operation for the duration of the request. Since mds requests can be queued and performed asynchronously we make sure to keep the idmapping around and release it once the request has finished. In follow-up patches we will use this to send correct ownership information over the wire. This patch just adds the basic infrastructure to keep the idmapping around. The actual conversion patches are all fairly minimal. Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 1b90344 commit 9c2df22

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

fs/ceph/mds_client.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/bits.h>
1313
#include <linux/ktime.h>
1414
#include <linux/bitmap.h>
15+
#include <linux/mnt_idmapping.h>
1516

1617
#include "super.h"
1718
#include "mds_client.h"
@@ -1122,6 +1123,8 @@ void ceph_mdsc_release_request(struct kref *kref)
11221123
kfree(req->r_path1);
11231124
kfree(req->r_path2);
11241125
put_cred(req->r_cred);
1126+
if (req->r_mnt_idmap)
1127+
mnt_idmap_put(req->r_mnt_idmap);
11251128
if (req->r_pagelist)
11261129
ceph_pagelist_release(req->r_pagelist);
11271130
kfree(req->r_fscrypt_auth);
@@ -1181,6 +1184,8 @@ static void __register_request(struct ceph_mds_client *mdsc,
11811184
insert_request(&mdsc->request_tree, req);
11821185

11831186
req->r_cred = get_current_cred();
1187+
if (!req->r_mnt_idmap)
1188+
req->r_mnt_idmap = &nop_mnt_idmap;
11841189

11851190
if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK)
11861191
mdsc->oldest_tid = req->r_tid;

fs/ceph/mds_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ struct ceph_mds_request {
300300
int r_fmode; /* file mode, if expecting cap */
301301
int r_request_release_offset;
302302
const struct cred *r_cred;
303+
struct mnt_idmap *r_mnt_idmap;
303304
struct timespec64 r_stamp;
304305

305306
/* for choosing which mds to send this request to */

0 commit comments

Comments
 (0)