提交 05cb11c1 编写于 作者: E Eric W. Biederman

ceph: Translate between uid and gids in cap messages and kuids and kgids

- Make the uid and gid arguments of send_cap_msg() used to compose
  ceph_mds_caps messages of type kuid_t and kgid_t.

- Pass inode->i_uid and inode->i_gid in __send_cap to send_cap_msg()
  through variables of type kuid_t and kgid_t.

- Modify struct ceph_cap_snap to store uids and gids in types kuid_t
  and kgid_t.  This allows capturing inode->i_uid and inode->i_gid in
  ceph_queue_cap_snap() without loss and pssing them to
  __ceph_flush_snaps() where they are removed from struct
  ceph_cap_snap and passed to send_cap_msg().

- In handle_cap_grant translate uid and gids in the initial user
  namespace stored in struct ceph_mds_cap into kuids and kgids
  before setting inode->i_uid and inode->i_gid.

Cc: Sage Weil <sage@inktank.com>
Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
上级 eea553c2
...@@ -930,7 +930,7 @@ static int send_cap_msg(struct ceph_mds_session *session, ...@@ -930,7 +930,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
u64 size, u64 max_size, u64 size, u64 max_size,
struct timespec *mtime, struct timespec *atime, struct timespec *mtime, struct timespec *atime,
u64 time_warp_seq, u64 time_warp_seq,
uid_t uid, gid_t gid, umode_t mode, kuid_t uid, kgid_t gid, umode_t mode,
u64 xattr_version, u64 xattr_version,
struct ceph_buffer *xattrs_buf, struct ceph_buffer *xattrs_buf,
u64 follows) u64 follows)
...@@ -974,8 +974,8 @@ static int send_cap_msg(struct ceph_mds_session *session, ...@@ -974,8 +974,8 @@ static int send_cap_msg(struct ceph_mds_session *session,
ceph_encode_timespec(&fc->atime, atime); ceph_encode_timespec(&fc->atime, atime);
fc->time_warp_seq = cpu_to_le32(time_warp_seq); fc->time_warp_seq = cpu_to_le32(time_warp_seq);
fc->uid = cpu_to_le32(uid); fc->uid = cpu_to_le32(from_kuid(&init_user_ns, uid));
fc->gid = cpu_to_le32(gid); fc->gid = cpu_to_le32(from_kgid(&init_user_ns, gid));
fc->mode = cpu_to_le32(mode); fc->mode = cpu_to_le32(mode);
fc->xattr_version = cpu_to_le64(xattr_version); fc->xattr_version = cpu_to_le64(xattr_version);
...@@ -1081,8 +1081,8 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, ...@@ -1081,8 +1081,8 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
struct timespec mtime, atime; struct timespec mtime, atime;
int wake = 0; int wake = 0;
umode_t mode; umode_t mode;
uid_t uid; kuid_t uid;
gid_t gid; kgid_t gid;
struct ceph_mds_session *session; struct ceph_mds_session *session;
u64 xattr_version = 0; u64 xattr_version = 0;
struct ceph_buffer *xattr_blob = NULL; struct ceph_buffer *xattr_blob = NULL;
...@@ -2359,8 +2359,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant, ...@@ -2359,8 +2359,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
if ((issued & CEPH_CAP_AUTH_EXCL) == 0) { if ((issued & CEPH_CAP_AUTH_EXCL) == 0) {
inode->i_mode = le32_to_cpu(grant->mode); inode->i_mode = le32_to_cpu(grant->mode);
inode->i_uid = le32_to_cpu(grant->uid); inode->i_uid = make_kuid(&init_user_ns, le32_to_cpu(grant->uid));
inode->i_gid = le32_to_cpu(grant->gid); inode->i_gid = make_kgid(&init_user_ns, le32_to_cpu(grant->gid));
dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode, dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode,
inode->i_uid, inode->i_gid); inode->i_uid, inode->i_gid);
} }
......
...@@ -138,8 +138,8 @@ struct ceph_cap_snap { ...@@ -138,8 +138,8 @@ struct ceph_cap_snap {
struct ceph_snap_context *context; struct ceph_snap_context *context;
umode_t mode; umode_t mode;
uid_t uid; kuid_t uid;
gid_t gid; kgid_t gid;
struct ceph_buffer *xattr_blob; struct ceph_buffer *xattr_blob;
u64 xattr_version; u64 xattr_version;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册