]> 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, 12 May 2021 09:03:53 +0000 (11:03 +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 cf8f745c7bb43a1b0b8c3c45f1691db5cfba6d43..07fe47940ea87460aa4061afcb33a9fd45fe37bb 100755 (executable)
@@ -8647,33 +8647,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);
 }
 
 /**
@@ -10800,13 +10808,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 434a768f33b28e13c5afbfb1c94ea30425d55a13..5914029925ed97fcf6e5cb5c7daa594d012519d5 100644 (file)
@@ -1181,7 +1181,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);