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.
Unified · Split
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <linux/bits.h> | 12 | #include <linux/bits.h> |
| 13 | #include <linux/ktime.h> | 13 | #include <linux/ktime.h> |
| 14 | #include <linux/bitmap.h> | 14 | #include <linux/bitmap.h> |
| 15 | #include <linux/mnt_idmapping.h> | ||
| 15 | 16 | ||
| 16 | #include "super.h" | 17 | #include "super.h" |
| 17 | #include "mds_client.h" | 18 | #include "mds_client.h" |
| @@ -1122,6 +1123,8 @@ void ceph_mdsc_release_request(struct kref *kref) · 1104 unmodified lines | |||
| 1122 | kfree(req->r_path1); | 1123 | kfree(req->r_path1); |
| 1123 | kfree(req->r_path2); | 1124 | kfree(req->r_path2); |
| 1124 | put_cred(req->r_cred); | 1125 | put_cred(req->r_cred); |
| 1126 | if (req->r_mnt_idmap) | ||
| 1127 | mnt_idmap_put(req->r_mnt_idmap); | ||
| 1125 | if (req->r_pagelist) | 1128 | if (req->r_pagelist) |
| 1126 | ceph_pagelist_release(req->r_pagelist); | 1129 | ceph_pagelist_release(req->r_pagelist); |
| 1127 | kfree(req->r_fscrypt_auth); | 1130 | kfree(req->r_fscrypt_auth); |
| @@ -1181,6 +1184,8 @@ static void __register_request(struct ceph_mds_client *mdsc, · 53 unmodified lines | |||
| 1181 | insert_request(&mdsc->request_tree, req); | 1184 | insert_request(&mdsc->request_tree, req); |
| 1182 | 1185 | ||
| 1183 | req->r_cred = get_current_cred(); | 1186 | req->r_cred = get_current_cred(); |
| 1187 | if (!req->r_mnt_idmap) | ||
| 1188 | req->r_mnt_idmap = &nop_mnt_idmap; | ||
| 1184 | 1189 | ||
| 1185 | if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK) | 1190 | if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK) |
| 1186 | mdsc->oldest_tid = req->r_tid; | 1191 | mdsc->oldest_tid = req->r_tid; |
| @@ -300,6 +300,7 @@ struct ceph_mds_request { · 299 unmodified lines | |||
| 300 | int r_fmode; /* file mode, if expecting cap */ | 300 | int r_fmode; /* file mode, if expecting cap */ |
| 301 | int r_request_release_offset; | 301 | int r_request_release_offset; |
| 302 | const struct cred *r_cred; | 302 | const struct cred *r_cred; |
| 303 | struct mnt_idmap *r_mnt_idmap; | ||
| 303 | struct timespec64 r_stamp; | 304 | struct timespec64 r_stamp; |
| 304 | 305 | ||
| 305 | /* for choosing which mds to send this request to */ | 306 | /* for choosing which mds to send this request to */ |