]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: pass UserPerm to lookup_parent()
authorGreg Farnum <gfarnum@redhat.com>
Mon, 1 Aug 2016 18:12:06 +0000 (11:12 -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/Client.h
src/libcephfs.cc

index 5f441fb4c47b9b99c6a8cc7c6b89afdff615a3b8..700c243f72bde6e9d4836f9136720ed10300d9d7 100644 (file)
@@ -7634,12 +7634,14 @@ int Client::lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode)
  * our cache.  Conditionally also set `parent` to a referenced
  * Inode* if caller provides non-NULL value.
  */
-int Client::lookup_parent(Inode *ino, Inode **parent)
+int Client::lookup_parent(Inode *ino, const UserPerm& perms, Inode **parent)
 {
   Mutex::Locker lock(client_lock);
   ldout(cct, 3) << "lookup_parent enter(" << ino->ino << ") = " << dendl;
 
   if (!ino->dn_set.empty()) {
+    // if we exposed the parent here, we'd need to check permissions,
+    // but right now we just rely on the MDS doing so in make_request
     ldout(cct, 3) << "lookup_parent dentry already present" << dendl;
     return 0;
   }
@@ -7650,7 +7652,6 @@ int Client::lookup_parent(Inode *ino, Inode **parent)
   req->set_inode(ino);
 
   InodeRef target;
-  UserPerm perms(get_uid(), get_gid()); // FIXME
   int r = make_request(req, perms, &target, NULL, rand() % mdsmap->get_num_in_mds());
   // Give caller a reference to the parent ino if they provided a pointer.
   if (parent != NULL) {
index bf0e51cbdf3739f7beb35f17f3b0e098a67d4edb..ab1b867e06252b1e7fb446b83acde2b5a7f5f1bb 100644 (file)
@@ -1124,7 +1124,7 @@ public:
   int lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name,
                  const UserPerm& perms);
   int lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode=NULL);
-  int lookup_parent(Inode *in, Inode **parent=NULL);
+  int lookup_parent(Inode *in, const UserPerm& perms, Inode **parent=NULL);
   int lookup_name(Inode *in, Inode *parent);
   int close(int fd);
   loff_t lseek(int fd, loff_t offset, int whence, const UserPerm& perms);
index 12a5d9ed034129fc6767abc85e19e1e041ccec73..681bc19404aca4899ebee699cf1bf1929af4ef3b 100644 (file)
@@ -1384,7 +1384,7 @@ extern "C" int ceph_ll_lookup_inode(
 
   // Request the parent inode, so that we can look up the name
   Inode *parent;
-  r = (cmount->get_client())->lookup_parent(*inode, &parent);
+  r = (cmount->get_client())->lookup_parent(*inode, perms, &parent);
   if (r && r != -EINVAL) {
     // Unexpected error
     (cmount->get_client())->ll_forget(*inode, 1);
@@ -1394,6 +1394,8 @@ extern "C" int ceph_ll_lookup_inode(
     // and don't try to look up the non-existent dentry.
     return 0;
   }
+  // FIXME: I don't think this works; lookup_parent() returns 0 if the parent
+  // is already in cache
   assert(parent != NULL);
 
   // Finally, get the name (dentry) of the requested inode