]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fill in cap renewals with the "best" uid/gid perms
authorGreg Farnum <gfarnum@redhat.com>
Tue, 2 Aug 2016 02:08:07 +0000 (19:08 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:51 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Inode.cc
src/client/Inode.h

index abd01e86ca446f98dd28a042f81b4ebdf39a724d..c4c7881eee2956e3fb1e19bceb0548bf03a53c5d 100644 (file)
@@ -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;
 }
index 454ae9d2c4210fc03eb90b22a48b498f2be9bc92..de59869e943b988d8bd1a909c79e50afc004a177 100644 (file)
@@ -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
index b51b9d86d58ea0260f5bfd801aa3e98a3ea1e9b8..5115f6a794ddb165e29398a5cb2936f0dea985b5 100644 (file)
@@ -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();