From: Greg Farnum Date: Mon, 1 Aug 2016 18:12:06 +0000 (-0700) Subject: client: pass UserPerm to lookup_parent() X-Git-Tag: v11.0.1~36^2~51 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4d37088acb58eeebaa89da1b0a484bcd137f870e;p=ceph.git client: pass UserPerm to lookup_parent() Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 5f441fb4c47b..700c243f72bd 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) { diff --git a/src/client/Client.h b/src/client/Client.h index bf0e51cbdf37..ab1b867e0625 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 12a5d9ed0341..681bc19404ac 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -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