From: Greg Farnum Date: Tue, 2 Aug 2016 02:08:07 +0000 (-0700) Subject: client: fill in cap renewals with the "best" uid/gid perms X-Git-Tag: v11.0.1~36^2~48 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b05e06ecc4dca2f7a38a8d18108b4c85c24fe241;p=ceph.git client: fill in cap renewals with the "best" uid/gid perms Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index abd01e86ca44..c4c7881eee29 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7865,7 +7865,7 @@ int Client::_renew_caps(Inode *in) req->head.args.open.mask = 0; req->set_inode(in); - UserPerm perms(get_uid(), get_gid()); // FIXME + UserPerm perms(in->get_best_cap_uid(), in->get_best_cap_gid()); int ret = make_request(req, perms); return ret; } diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 454ae9d2c421..de59869e943b 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -288,6 +288,28 @@ int Inode::caps_dirty() return dirty_caps | flushing_caps; } +uid_t Inode::get_best_cap_uid() +{ + uid_t any = -1; + for (const auto ci : caps) { + if (ci.second->latest_uid == uid) + return uid; + any = ci.second->latest_uid; + } + return any; +} + +gid_t Inode::get_best_cap_gid() +{ + gid_t any = -1; + for (const auto ci : caps) { + if (ci.second->latest_gid == uid) + return uid; + any = ci.second->latest_gid; + } + return any; +} + bool Inode::have_valid_size() { // RD+RDCACHE or WR+WRBUFFER => valid size diff --git a/src/client/Inode.h b/src/client/Inode.h index b51b9d86d58e..5115f6a794dd 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -279,6 +279,8 @@ struct Inode { int caps_wanted(); int caps_mds_wanted(); int caps_dirty(); + uid_t get_best_cap_uid(); + gid_t get_best_cap_gid(); bool have_valid_size(); Dir *open_dir();