ceph: fix ceph_fh_to_parent()
ceph_fh_to_parent() returns dentry that corresponds to the 'ino' field of struct ceph_nfs_confh. This is wrong, it should return dentry that corresponds to the 'parent_ino' field. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
9017c2ec78
commit
8996f4f23d
|
@ -181,48 +181,24 @@ struct dentry *ceph_get_parent(struct dentry *child)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get parent, if possible.
|
* convert regular fh to parent
|
||||||
*
|
|
||||||
* FIXME: we could do better by querying the mds to discover the
|
|
||||||
* parent.
|
|
||||||
*/
|
*/
|
||||||
static struct dentry *ceph_fh_to_parent(struct super_block *sb,
|
static struct dentry *ceph_fh_to_parent(struct super_block *sb,
|
||||||
struct fid *fid,
|
struct fid *fid,
|
||||||
int fh_len, int fh_type)
|
int fh_len, int fh_type)
|
||||||
{
|
{
|
||||||
struct ceph_nfs_confh *cfh = (void *)fid->raw;
|
struct ceph_nfs_confh *cfh = (void *)fid->raw;
|
||||||
struct ceph_vino vino;
|
|
||||||
struct inode *inode;
|
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
int err;
|
|
||||||
|
|
||||||
if (fh_type == 1)
|
if (fh_type != FILEID_INO32_GEN_PARENT)
|
||||||
return ERR_PTR(-ESTALE);
|
return NULL;
|
||||||
if (fh_len < sizeof(*cfh) / 4)
|
if (fh_len < sizeof(*cfh) / 4)
|
||||||
return ERR_PTR(-ESTALE);
|
return NULL;
|
||||||
|
|
||||||
pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino,
|
dout("fh_to_parent %llx\n", cfh->parent_ino);
|
||||||
cfh->parent_name_hash);
|
dentry = __get_parent(sb, NULL, cfh->ino);
|
||||||
|
if (IS_ERR(dentry) && PTR_ERR(dentry) == -ENOENT)
|
||||||
vino.ino = cfh->ino;
|
dentry = __fh_to_dentry(sb, cfh->parent_ino);
|
||||||
vino.snap = CEPH_NOSNAP;
|
|
||||||
inode = ceph_find_inode(sb, vino);
|
|
||||||
if (!inode)
|
|
||||||
return ERR_PTR(-ESTALE);
|
|
||||||
|
|
||||||
dentry = d_obtain_alias(inode);
|
|
||||||
if (IS_ERR(dentry)) {
|
|
||||||
pr_err("fh_to_parent %llx -- inode %p but ENOMEM\n",
|
|
||||||
cfh->ino, inode);
|
|
||||||
iput(inode);
|
|
||||||
return dentry;
|
|
||||||
}
|
|
||||||
err = ceph_init_dentry(dentry);
|
|
||||||
if (err < 0) {
|
|
||||||
iput(inode);
|
|
||||||
return ERR_PTR(err);
|
|
||||||
}
|
|
||||||
dout("fh_to_parent %llx %p dentry %p\n", cfh->ino, inode, dentry);
|
|
||||||
return dentry;
|
return dentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue