]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #40092 from batrick/i49512
authorYuri Weinstein <yweinste@redhat.com>
Tue, 23 Mar 2021 14:55:51 +0000 (07:55 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Mar 2021 14:55:51 +0000 (07:55 -0700)
pacific: client: allow looking up snapped inodes by inode number+snapid tuple

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
1  2 
src/client/Client.cc
src/client/Client.h

index 331068ad500b8201481037064677610422d6ea16,48791b741152129bc7cc9d4a133b6057ae966e2f..3a3554c62595c0278202aa20feb2c575bdb09b67
@@@ -9087,15 -9087,22 +9087,22 @@@ int Client::_lookup_vino(vinodeno_t vin
  
    RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
    if (!mref_reader.is_state_satisfied())
 -    return -ENOTCONN;
 +    return -CEPHFS_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;
@@@ -11328,20 -11336,16 +11336,16 @@@ int Client::ll_lookup_vino
    ceph_assert(inode != NULL);
    RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
    if (!mref_reader.is_state_satisfied())
 -    return -ENOTCONN;
 +    return -CEPHFS_ENOTCONN;
  
    std::scoped_lock lock(client_lock);
-   ldout(cct, 3) << "ll_lookup_inode " << ino  << dendl;
+   ldout(cct, 3) << __func__ << " " << vino << dendl;
  
-   // Num1: get inode and *inode
-   int r = _lookup_ino(ino, perms, inode);
-   if (r)
-     return r;
-   ceph_assert(*inode != NULL);
-   if (!(*inode)->dentries.empty()) {
-     ldout(cct, 8) << __func__ << " dentry already present" << dendl;
+   // Check the cache first
+   unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
+   if (p != inode_map.end()) {
+     *inode = p->second;
+     _ll_get(*inode);
      return 0;
    }
  
Simple merge