MCPcopy Create free account
hub / github.com/ceph/ceph / _lookup

Method _lookup

src/client/Client.cc:7730–7875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7728}
7729
7730int Client::_lookup(const InodeRef& dir, const std::string& name, std::string& alternate_name, int mask, InodeRef *target, const UserPerm& perms, bool is_rename)
7731{
7732 int r = 0;
7733 Dentry *dn = NULL;
7734 bool did_lookup_request = false;
7735 // can only request shared caps
7736 mask &= CEPH_CAP_ANY_SHARED | CEPH_STAT_RSTAT;
7737 std::string dname = name;
7738
7739 if (!dir->is_dir()) {
7740 r = -ENOTDIR;
7741 goto done;
7742 }
7743
7744 if (dname == ".."sv) {
7745 if (dir->dentries.empty()) {
7746 MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPPARENT);
7747 filepath path(dir->ino);
7748 req->set_filepath(path);
7749
7750 InodeRef tmptarget;
7751 int r = make_request(req, perms, &tmptarget, NULL, rand() % mdsmap->get_num_in_mds());
7752
7753 if (r == 0) {
7754 *target = std::move(tmptarget);
7755 ldout(cct, 8) << __func__ << " found target " << (*target)->ino << dendl;
7756 } else {
7757 *target = dir;
7758 }
7759 }
7760 else
7761 *target = dir->get_first_parent()->dir->parent_inode; //dirs can't be hard-linked
7762 goto done;
7763 }
7764
7765 if (dname == "."sv) {
7766 *target = dir;
7767 goto done;
7768 }
7769
7770 if (dname.size() > NAME_MAX) {
7771 r = -ENAMETOOLONG;
7772 goto done;
7773 }
7774
7775 if (dname == cct->_conf->client_snapdir &&
7776 dir->snapid == CEPH_NOSNAP) {
7777 if (respect_subvolume_snapshot_visibility &&
7778 !dir->snaprealm->is_snapdir_visible) {
7779 r = -EPERM;
7780 goto done;
7781 }
7782 *target = open_snapdir(dir);
7783 goto done;
7784 }
7785
7786relookup:
7787

Callers

nothing calls this directly

Calls 12

get_num_in_mdsMethod · 0.80
get_first_parentMethod · 0.80
caps_issued_maskMethod · 0.80
try_touch_capMethod · 0.80
make_requestFunction · 0.50
is_dirMethod · 0.45
emptyMethod · 0.45
set_filepathMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
vinoMethod · 0.45

Tested by

no test coverage detected