]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: store "actor" UserPerm in Fh, use for requesting file locks and things
authorGreg Farnum <gfarnum@redhat.com>
Tue, 2 Aug 2016 02:15:51 +0000 (19:15 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:52 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/Fh.h

index c4c7881eee2956e3fb1e19bceb0548bf03a53c5d..3820093384b9e264345f66a2fd015b56b23bccdc 100644 (file)
@@ -7708,7 +7708,7 @@ int Client::lookup_name(Inode *ino, Inode *parent, const UserPerm& perms)
 }
 
 
-Fh *Client::_create_fh(Inode *in, int flags, int cmode)
+ Fh *Client::_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms)
 {
   // yay
   Fh *f = new Fh;
@@ -7718,6 +7718,7 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode)
   // inode
   assert(in);
   f->inode = in;
+  f->actor_perms = perms;
 
   ldout(cct, 10) << "_create_fh " << in->ino << " mode " << cmode << dendl;
 
@@ -7826,7 +7827,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp,
   // success?
   if (result >= 0) {
     if (fhp)
-      *fhp = _create_fh(in, flags, cmode);
+      *fhp = _create_fh(in, flags, cmode, perms);
   } else {
     in->put_open_ref(cmode);
   }
@@ -9009,7 +9010,7 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
   int ret;
   bufferlist bl;
 
-  UserPerm perms(get_uid(), get_gid()); // FIXME
+  UserPerm perms(fh->actor_uid, fh->actor_gid);
   if (sleep && switch_interrupt_cb) {
     // enable interrupt
     switch_interrupt_cb(callback_handle, req->get());
@@ -10639,7 +10640,7 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode,
   /* If the caller passed a value in fhp, do the open */
   if(fhp) {
     (*inp)->get_open_ref(cmode);
-    *fhp = _create_fh(inp->get(), flags, cmode);
+    *fhp = _create_fh(inp->get(), flags, cmode, perms);
   }
 
  reply_error:
index cc4970f89aa3c03249c8e17bd178230cab8b7641..2f55fcd96c63b88867c690df1b7b0cc251faa822 100644 (file)
@@ -759,7 +759,7 @@ private:
   int _ll_put(Inode *in, int num);
   void _ll_drop_pins();
 
-  Fh *_create_fh(Inode *in, int flags, int cmode);
+  Fh *_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms);
   int _release_fh(Fh *fh);
   void _put_fh(Fh *fh);
 
index db3a28c47a8feeb38f01773efc96d7f7e281757a..170d0e703018927cb73a14715b4ec21292d5f82c 100644 (file)
@@ -21,14 +21,16 @@ struct Fh {
   bool pos_locked;           // pos is currently in use
   list<Cond*> pos_waiters;   // waiters for pos
 
+  UserPerm actor_perms; // perms I opened the file with
+
   Readahead readahead;
 
   // file lock
   ceph_lock_state_t *fcntl_locks;
   ceph_lock_state_t *flock_locks;
-
+  
   Fh() : _ref(1), pos(0), mds(0), mode(0), flags(0), pos_locked(false),
-      readahead(), fcntl_locks(NULL), flock_locks(NULL) {}
+    actor_perms(), readahead(), fcntl_locks(NULL), flock_locks(NULL) {}
   void get() { ++_ref; }
   int put() { return --_ref; }
 };