Skip to content

Commit 8a051b4

Browse files
brauneridryomov
authored andcommitted
ceph: allow idmapped atomic_open inode op
Enable ceph_atomic_open() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. [ aleksandr.mikhalitsyn: adapted to 5fadbd9 ("ceph: rely on vfs for setgid stripping") ] Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Alexander Mikhalitsyn <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 2cce72d commit 8a051b4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/ceph/file.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,15 +668,19 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
668668
in.truncate_seq = cpu_to_le32(1);
669669
in.truncate_size = cpu_to_le64(-1ULL);
670670
in.xattr_version = cpu_to_le64(1);
671-
in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid()));
671+
in.uid = cpu_to_le32(from_kuid(&init_user_ns,
672+
mapped_fsuid(req->r_mnt_idmap,
673+
&init_user_ns)));
672674
if (dir->i_mode & S_ISGID) {
673675
in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid));
674676

675677
/* Directories always inherit the setgid bit. */
676678
if (S_ISDIR(mode))
677679
mode |= S_ISGID;
678680
} else {
679-
in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid()));
681+
in.gid = cpu_to_le32(from_kgid(&init_user_ns,
682+
mapped_fsgid(req->r_mnt_idmap,
683+
&init_user_ns)));
680684
}
681685
in.mode = cpu_to_le32((u32)mode);
682686

@@ -743,6 +747,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
743747
int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
744748
struct file *file, unsigned flags, umode_t mode)
745749
{
750+
struct mnt_idmap *idmap = file_mnt_idmap(file);
746751
struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb);
747752
struct ceph_client *cl = fsc->client;
748753
struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -802,6 +807,8 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
802807
mask |= CEPH_CAP_XATTR_SHARED;
803808
req->r_args.open.mask = cpu_to_le32(mask);
804809
req->r_parent = dir;
810+
if (req->r_op == CEPH_MDS_OP_CREATE)
811+
req->r_mnt_idmap = mnt_idmap_get(idmap);
805812
ihold(dir);
806813
if (IS_ENCRYPTED(dir)) {
807814
set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags);

0 commit comments

Comments
 (0)