From: Yuri Weinstein Date: Tue, 23 Mar 2021 14:55:51 +0000 (-0700) Subject: Merge pull request #40092 from batrick/i49512 X-Git-Tag: v16.2.0~62 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebf209cf2fe8a0deb1c6291d99124a034442777e;p=ceph.git Merge pull request #40092 from batrick/i49512 pacific: client: allow looking up snapped inodes by inode number+snapid tuple Reviewed-by: Patrick Donnelly --- ebf209cf2fe8a0deb1c6291d99124a034442777e diff --cc src/client/Client.cc index 331068ad500b,48791b741152..3a3554c62595 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@@ -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::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::iterator p = inode_map.find(vino); + if (p != inode_map.end()) { + *inode = p->second; + _ll_get(*inode); return 0; }