From: Jeff Layton Date: Mon, 1 Feb 2021 15:41:14 +0000 (-0500) Subject: client: make _lookup_ino take a vinodeno_t X-Git-Tag: v14.2.22~35^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=58d22edea51ed9beaa7832bdef4c336c5600be23;p=ceph.git client: make _lookup_ino take a vinodeno_t 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 (cherry picked from commit 0e0bebd22dc1abea3f0132debc0b524a01fadf63) Conflicts: src/client/Client.cc --- diff --git a/src/client/Client.cc b/src/client/Client.cc index cf8f745c7bb43..07fe47940ea87 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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::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, diff --git a/src/client/Client.h b/src/client/Client.h index 434a768f33b28..5914029925ed9 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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);