]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: make _lookup_ino take a vinodeno_t
authorJeff Layton <jlayton@redhat.com>
Mon, 1 Feb 2021 15:41:14 +0000 (10:41 -0500)
committerNathan Cutler <ncutler@suse.com>
Wed, 26 May 2021 12:20:20 +0000 (14:20 +0200)
Currently, it always leaves the snapid as 0. Rename it to
_lookup_vino and make it fill the snapid from the vinodeno_t
instead, but only when it's a "real" snapid.

Change the existing callers to pass in a vinodeno_t with the
snapid set to CEPH_NOSNAP.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
(cherry picked from commit 0e0bebd22dc1abea3f0132debc0b524a01fadf63)

Conflicts:
src/client/Client.cc

src/client/Client.cc
src/client/Client.h

index 04f3a3d0547a3bb64378e7ffe80fa3fb36166f5e..0b5d386e14ebef137b61450ecc402d90236ff11d 100755 (executable)
@@ -8708,33 +8708,41 @@ int Client::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name,
  * the resulting Inode object in one operation, so that caller
  * can safely assume inode will still be there after return.
  */
-int Client::_lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode)
+int Client::_lookup_vino(vinodeno_t vino, const UserPerm& perms, Inode **inode)
 {
-  ldout(cct, 8) << __func__ << " enter(" << ino << ")" << dendl;
+  ldout(cct, 8) << __func__ << " enter(" << vino << ")" << dendl;
 
   if (unmounting)
     return -ENOTCONN;
 
   MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPINO);
-  filepath path(ino);
+  filepath path(vino.ino);
   req->set_filepath(path);
 
+  /*
+   * The MDS expects either a "real" snapid here or 0. The special value
+   * carveouts for the snapid are all at the end of the range so we can
+   * just look for any snapid below this value.
+   */
+  if (vino.snapid < CEPH_NOSNAP)
+    req->head.args.lookupino.snapid = vino.snapid;
+
   int r = make_request(req, perms, NULL, NULL, rand() % mdsmap->get_num_in_mds());
   if (r == 0 && inode != NULL) {
-    vinodeno_t vino(ino, CEPH_NOSNAP);
     unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
     ceph_assert(p != inode_map.end());
     *inode = p->second;
     _ll_get(*inode);
   }
-  ldout(cct, 8) << __func__ << " exit(" << ino << ") = " << r << dendl;
+  ldout(cct, 8) << __func__ << " exit(" << vino << ") = " << r << dendl;
   return r;
 }
 
 int Client::lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode)
 {
+  vinodeno_t vino(ino, CEPH_NOSNAP);
   std::lock_guard lock(client_lock);
-  return _lookup_ino(ino, perms, inode);
+  return _lookup_vino(vino, perms, inode);
 }
 
 /**
@@ -10903,13 +10911,14 @@ int Client::ll_lookup_inode(
 {
   ceph_assert(inode != NULL);
   std::lock_guard lock(client_lock);
-  ldout(cct, 3) << "ll_lookup_inode " << ino  << dendl;
+  ldout(cct, 3) << "ll_lookup_inode " << ino << dendl;
    
   if (unmounting)
     return -ENOTCONN;
 
   // Num1: get inode and *inode
-  return _lookup_ino(ino, perms, inode);
+  vinodeno_t vino(ino, CEPH_NOSNAP);
+  return _lookup_vino(vino, perms, inode);
 }
 
 int Client::ll_lookupx(Inode *parent, const char *name, Inode **out,
index 95cb2fcfb94599f072fd0f16c458739c312b00c0..fdd250e197e186205ca21edecac56a584ed62703 100644 (file)
@@ -1183,7 +1183,7 @@ private:
   int _ll_getattr(Inode *in, int caps, const UserPerm& perms);
   int _lookup_parent(Inode *in, const UserPerm& perms, Inode **parent=NULL);
   int _lookup_name(Inode *in, Inode *parent, const UserPerm& perms);
-  int _lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode=NULL);
+  int _lookup_vino(vinodeno_t ino, const UserPerm& perms, Inode **inode=NULL);
   bool _ll_forget(Inode *in, uint64_t count);