]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: switch make_request implementation and verify_reply_trace to UserPerm
authorGreg Farnum <gfarnum@redhat.com>
Thu, 28 Jul 2016 23:26:06 +0000 (16:26 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:48 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h

index 335bd7be159e7d3e09d78b7bff8bc7536cea7e2f..1c2311a802dcb6ea8961c7d284434b7f61534890 100644 (file)
@@ -1509,14 +1509,13 @@ void Client::dump_mds_requests(Formatter *f)
 int Client::verify_reply_trace(int r,
                               MetaRequest *request, MClientReply *reply,
                               InodeRef *ptarget, bool *pcreated,
-                              int uid, int gid)
+                              const UserPerm& perms)
 {
   // check whether this request actually did the create, and set created flag
   bufferlist extra_bl;
   inodeno_t created_ino;
   bool got_created_ino = false;
   ceph::unordered_map<vinodeno_t, Inode*>::iterator p;
-  UserPerm perms(uid, gid);
 
   extra_bl.claim(reply->get_extra_bl());
   if (extra_bl.length() >= 8) {
@@ -1594,15 +1593,14 @@ int Client::verify_reply_trace(int r,
  * a request).
  *
  * @param request the MetaRequest to execute
- * @param uid uid to execute as
- * @param gid gid to execute as
+ * @param perms The user uid/gid to execute as (eventually, full group lists?)
  * @param ptarget [optional] address to store a pointer to the target inode we want to create or operate on
  * @param pcreated [optional; required if ptarget] where to store a bool of whether our create atomically created a file
  * @param use_mds [optional] prefer a specific mds (-1 for default)
  * @param pdirbl [optional; disallowed if ptarget] where to pass extra reply payload to the caller
  */
-int Client::make_request(MetaRequest *request, 
-                        int uid, int gid, 
+int Client::make_request(MetaRequest *request,
+                        const UserPerm& perms,
                         InodeRef *ptarget, bool *pcreated,
                         int use_mds,
                         bufferlist *pdirbl)
@@ -1621,13 +1619,8 @@ int Client::make_request(MetaRequest *request,
   if (oldest_tid == 0 && request->get_op() != CEPH_MDS_OP_SETFILELOCK)
     oldest_tid = tid;
 
-  if (uid < 0)
-    uid = get_uid();
-  if (gid < 0)
-    gid = get_gid();
-
-  request->set_caller_uid(uid);
-  request->set_caller_gid(gid);
+  request->set_caller_uid(perms.uid());
+  request->set_caller_gid(perms.gid());
 
   if (cct->_conf->client_inject_fixed_oldest_tid) {
     ldout(cct, 20) << __func__ << " injecting fixed oldest_client_tid(1)" << dendl;
@@ -1731,7 +1724,7 @@ int Client::make_request(MetaRequest *request,
   request->dispatch_cond = 0;
   
   if (r >= 0 && ptarget)
-    r = verify_reply_trace(r, request, reply, ptarget, pcreated, uid, gid);
+    r = verify_reply_trace(r, request, reply, ptarget, pcreated, perms);
 
   if (pdirbl)
     pdirbl->claim(reply->get_extra_bl());
index fd8b0d8e8a55c6749b205d04e57033892fdd3cdf..145bfca48ccb48c6fd051e627ea931526ca84a1d 100644 (file)
@@ -374,22 +374,21 @@ protected:
   void dump_mds_requests(Formatter *f);
   void dump_mds_sessions(Formatter *f);
 
-  int make_request(MetaRequest *req, int uid, int gid,
-                  //MClientRequest *req, int uid, int gid,
+  int make_request(MetaRequest *req, const UserPerm& perms,
                   InodeRef *ptarget = 0, bool *pcreated = 0,
                   int use_mds=-1, bufferlist *pdirbl=0);
-
-  int make_request(MetaRequest *req, const UserPerm& perm,
+  int make_request(MetaRequest *req, int uid, int gid,
                   InodeRef *ptarget = 0, bool *pcreated = 0,
                   int use_mds=-1, bufferlist *pdirbl=0) {
-    return make_request(req, perm.uid(), perm.gid(), ptarget, pcreated,
-                       use_mds, pdirbl);
+    UserPerm perms(uid, gid);
+    return make_request(req, perms, ptarget, pcreated, use_mds, pdirbl);
   }
   void put_request(MetaRequest *request);
   void unregister_request(MetaRequest *request);
 
   int verify_reply_trace(int r, MetaRequest *request, MClientReply *reply,
-                        InodeRef *ptarget, bool *pcreated, int uid, int gid);
+                        InodeRef *ptarget, bool *pcreated,
+                        const UserPerm& perms);
   void encode_cap_releases(MetaRequest *request, mds_rank_t mds);
   int encode_inode_release(Inode *in, MetaRequest *req,
                           mds_rank_t mds, int drop,