return r;
}
-int Client::ll_lookup_inode(
- struct inodeno_t ino,
+int Client::ll_lookup_vino(
+ vinodeno_t vino,
const UserPerm& perms,
Inode **inode)
{
ceph_assert(inode != NULL);
- std::lock_guard lock(client_lock);
- ldout(cct, 3) << "ll_lookup_inode " << ino << dendl;
-
+
if (unmounting)
return -ENOTCONN;
- // Num1: get inode and *inode
+ std::lock_guard lock(client_lock);
+ ldout(cct, 3) << __func__ << vino << 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;
+ }
+
+ uint64_t snapid = vino.snapid;
+
+ // for snapdir, find the non-snapped dir inode
+ if (snapid == CEPH_SNAPDIR)
+ vino.snapid = CEPH_NOSNAP;
+
+ int r = _lookup_vino(vino, perms, inode);
+ if (r)
+ return r;
+ ceph_assert(*inode != NULL);
+
+ if (snapid == CEPH_SNAPDIR) {
+ Inode *tmp = *inode;
+
+ // open the snapdir and put the inode ref
+ *inode = open_snapdir(tmp);
+ _ll_forget(tmp, 1);
+ _ll_get(*inode);
+ }
+ return 0;
+}
+
+int Client::ll_lookup_inode(
+ struct inodeno_t ino,
+ const UserPerm& perms,
+ Inode **inode)
+{
vinodeno_t vino(ino, CEPH_NOSNAP);
- return _lookup_vino(vino, perms, inode);
+ return ll_lookup_vino(vino, perms, inode);
}
int Client::ll_lookupx(Inode *parent, const char *name, Inode **out,
int ll_lookup(Inode *parent, const char *name, struct stat *attr,
Inode **out, const UserPerm& perms);
int ll_lookup_inode(struct inodeno_t ino, const UserPerm& perms, Inode **inode);
+ int ll_lookup_vino(vinodeno_t vino, const UserPerm& perms, Inode **inode);
int ll_lookupx(Inode *parent, const char *name, Inode **out,
struct ceph_statx *stx, unsigned want, unsigned flags,
const UserPerm& perms);
/* Low Level */
struct Inode *ceph_ll_get_inode(struct ceph_mount_info *cmount,
vinodeno_t vino);
+
+int ceph_ll_lookup_vino(struct ceph_mount_info *cmount, vinodeno_t vino,
+ Inode **inode);
+
int ceph_ll_lookup_inode(
struct ceph_mount_info *cmount,
struct inodeno_t ino,
}
+extern "C" int ceph_ll_lookup_vino(
+ struct ceph_mount_info *cmount,
+ vinodeno_t vino,
+ Inode **inode)
+{
+ return (cmount->get_client())->ll_lookup_vino(vino, cmount->default_perms, inode);
+}
+
/**
* Populates the client cache with the requested inode, and its
* parent dentry.