Release 4.11 fs/ceph/export.c
#include <linux/ceph/ceph_debug.h>
#include <linux/exportfs.h>
#include <linux/slab.h>
#include <asm/unaligned.h>
#include "super.h"
#include "mds_client.h"
/*
* Basic fh
*/
struct ceph_nfs_fh {
u64 ino;
} __attribute__ ((packed));
/*
* Larger fh that includes parent ino.
*/
struct ceph_nfs_confh {
u64 ino, parent_ino;
} __attribute__ ((packed));
static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
struct inode *parent_inode)
{
int type;
struct ceph_nfs_fh *fh = (void *)rawfh;
struct ceph_nfs_confh *cfh = (void *)rawfh;
int connected_handle_length = sizeof(*cfh)/4;
int handle_length = sizeof(*fh)/4;
/* don't re-export snaps */
if (ceph_snap(inode) != CEPH_NOSNAP)
return -EINVAL;
if (parent_inode && (*max_len < connected_handle_length)) {
*max_len = connected_handle_length;
return FILEID_INVALID;
} else if (*max_len < handle_length) {
*max_len = handle_length;
return FILEID_INVALID;
}
if (parent_inode) {
dout("encode_fh %llx with parent %llx\n",
ceph_ino(inode), ceph_ino(parent_inode));
cfh->ino = ceph_ino(inode);
cfh->parent_ino = ceph_ino(parent_inode);
*max_len = connected_handle_length;
type = FILEID_INO32_GEN_PARENT;
} else {
dout("encode_fh %llx\n", ceph_ino(inode));
fh->ino = ceph_ino(inode);
*max_len = handle_length;
type = FILEID_INO32_GEN;
}
return type;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sage Weil | 122 | 59.22% | 3 | 42.86% |
Zheng Yan | 52 | 25.24% | 1 | 14.29% |
Aneesh Kumar K.V | 30 | 14.56% | 2 | 28.57% |
Cyril Roelandt | 2 | 0.97% | 1 | 14.29% |
Total | 206 | 100.00% | 7 | 100.00% |
static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
{
struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
struct inode *inode;
struct ceph_vino vino;
int err;
vino.ino = ino;
vino.snap = CEPH_NOSNAP;
inode = ceph_find_inode(sb, vino);
if (!inode) {
struct ceph_mds_request *req;
int mask;
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPINO,
USE_ANY_MDS);
if (IS_ERR(req))
return ERR_CAST(req);
mask = CEPH_STAT_CAP_INODE;
if (ceph_security_xattr_wanted(d_inode(sb->s_root)))
mask |= CEPH_CAP_XATTR_SHARED;
req->r_args.getattr.mask = cpu_to_le32(mask);
req->r_ino1 = vino;
req->r_num_caps = 1;
err = ceph_mdsc_do_request(mdsc, NULL, req);
inode = req->r_target_inode;
if (inode)
ihold(inode);
ceph_mdsc_put_request(req);
if (!inode)
return ERR_PTR(-ESTALE);
}
return d_obtain_alias(inode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sage Weil | 155 | 79.90% | 4 | 57.14% |
Yan, Zheng | 36 | 18.56% | 1 | 14.29% |
Zheng Yan | 2 | 1.03% | 1 | 14.29% |
Al Viro | 1 | 0.52% | 1 | 14.29% |
Total | 194 | 100.00% | 7 | 100.00% |
/*
* convert regular fh to dentry
*/
static struct dentry *ceph_fh_to_dentry(struct super_block *sb,
struct fid *fid,
int fh_len, int fh_type)
{
struct ceph_nfs_fh *fh = (void *)fid->raw;
if (fh_type != FILEID_INO32_GEN &&
fh_type != FILEID_INO32_GEN_PARENT)
return NULL;
if (fh_len < sizeof(*fh) / 4)
return NULL;
dout("fh_to_dentry %llx\n", fh->ino);
return __fh_to_dentry(sb, fh->ino);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sage Weil | 35 | 41.67% | 1 | 33.33% |
Zheng Yan | 33 | 39.29% | 1 | 33.33% |
Hugh Dickins | 16 | 19.05% | 1 | 33.33% |
Total | 84 | 100.00% | 3 | 100.00% |
static struct dentry *__get_parent(struct super_block *sb,
struct dentry *child, u64 ino)
{
struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
struct ceph_mds_request *req;
struct inode *inode;
int mask;
int err;
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPPARENT,
USE_ANY_MDS);
if (IS_ERR(req))
return ERR_CAST(req);
if (child) {
req->r_inode = d_inode(child);
ihold(d_inode(child));
} else {
req->r_ino1 = (struct ceph_vino) {
.ino = ino,
.snap = CEPH_NOSNAP,
};
}
mask = CEPH_STAT_CAP_INODE;
if (ceph_security_xattr_wanted(d_inode(sb->s_root)))
mask |= CEPH_CAP_XATTR_SHARED;
req->r_args.getattr.mask = cpu_to_le32(mask);
req->r_num_caps = 1;
err = ceph_mdsc_do_request(mdsc, NULL, req);
inode = req->r_target_inode;
if (inode)
ihold(inode);
ceph_mdsc_put_request(req);
if (!inode)
return ERR_PTR(-ENOENT);
return d_obtain_alias(inode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Zheng Yan | 164 | 79.23% | 1 | 25.00% |
Yan, Zheng | 36 | 17.39% | 1 | 25.00% |
David Howells | 6 | 2.90% | 1 | 25.00% |
Al Viro | 1 | 0.48% | 1 | 25.00% |
Total | 207 | 100.00% | 4 | 100.00% |
static struct dentry *ceph_get_parent(struct dentry *child)
{
/* don't re-export snaps */
if (ceph_snap(d_inode(child)) != CEPH_NOSNAP)
return ERR_PTR(-EINVAL);
dout("get_parent %p ino %llx.%llx\n",
child, ceph_vinop(d_inode(child)));
return __get_parent(child->d_sb, child, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Zheng Yan | 53 | 88.33% | 1 | 33.33% |
David Howells | 6 | 10.00% | 1 | 33.33% |
Fengguang Wu | 1 | 1.67% | 1 | 33.33% |
Total | 60 | 100.00% | 3 | 100.00% |
/*
* convert regular fh to parent
*/
static struct dentry *ceph_fh_to_parent(struct super_block *sb,
struct fid *fid,
int fh_len, int fh_type)
{
struct ceph_nfs_confh *cfh = (void *)fid->raw;
struct dentry *dentry;
if (fh_type != FILEID_INO32_GEN_PARENT)
return NULL;
if (fh_len < sizeof(*cfh) / 4)
return NULL;
dout("fh_to_parent %llx\n", cfh->parent_ino);
dentry = __get_parent(sb, NULL, cfh->ino);
if (unlikely(dentry == ERR_PTR(-ENOENT)))
dentry = __fh_to_dentry(sb, cfh->parent_ino);
return dentry;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sage Weil | 75 | 65.22% | 1 | 20.00% |
Zheng Yan | 19 | 16.52% | 1 | 20.00% |
Hugh Dickins | 14 | 12.17% | 1 | 20.00% |
Al Viro | 5 | 4.35% | 1 | 20.00% |
Dan Carpenter | 2 | 1.74% | 1 | 20.00% |
Total | 115 | 100.00% | 5 | 100.00% |
static int ceph_get_name(struct dentry *parent, char *name,
struct dentry *child)
{
struct ceph_mds_client *mdsc;
struct ceph_mds_request *req;
int err;
mdsc = ceph_inode_to_client(d_inode(child))->mdsc;
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPNAME,
USE_ANY_MDS);
if (IS_ERR(req))
return PTR_ERR(req);
inode_lock(d_inode(parent));
req->r_inode = d_inode(child);
ihold(d_inode(child));
req->r_ino2 = ceph_vino(d_inode(parent));
req->r_parent = d_inode(parent);
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
req->r_num_caps = 2;
err = ceph_mdsc_do_request(mdsc, NULL, req);
inode_unlock(d_inode(parent));
if (!err) {
struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
memcpy(name, rinfo->dname, rinfo->dname_len);
name[rinfo->dname_len] = 0;
dout("get_name %p ino %llx.%llx name %s\n",
child, ceph_vinop(d_inode(child)), name);
} else {
dout("get_name %p ino %llx.%llx err %d\n",
child, ceph_vinop(d_inode(child)), err);
}
ceph_mdsc_put_request(req);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Zheng Yan | 194 | 82.91% | 1 | 25.00% |
David Howells | 27 | 11.54% | 1 | 25.00% |
Jeff Layton | 11 | 4.70% | 1 | 25.00% |
Al Viro | 2 | 0.85% | 1 | 25.00% |
Total | 234 | 100.00% | 4 | 100.00% |
const struct export_operations ceph_export_ops = {
.encode_fh = ceph_encode_fh,
.fh_to_dentry = ceph_fh_to_dentry,
.fh_to_parent = ceph_fh_to_parent,
.get_parent = ceph_get_parent,
.get_name = ceph_get_name,
};
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Zheng Yan | 530 | 44.76% | 4 | 16.67% |
Sage Weil | 451 | 38.09% | 6 | 25.00% |
Yan, Zheng | 72 | 6.08% | 1 | 4.17% |
David Howells | 39 | 3.29% | 1 | 4.17% |
Hugh Dickins | 30 | 2.53% | 1 | 4.17% |
Aneesh Kumar K.V | 30 | 2.53% | 2 | 8.33% |
Jeff Layton | 11 | 0.93% | 1 | 4.17% |
Al Viro | 9 | 0.76% | 3 | 12.50% |
Yehuda Sadeh Weinraub | 4 | 0.34% | 1 | 4.17% |
Tejun Heo | 3 | 0.25% | 1 | 4.17% |
Dan Carpenter | 2 | 0.17% | 1 | 4.17% |
Cyril Roelandt | 2 | 0.17% | 1 | 4.17% |
Fengguang Wu | 1 | 0.08% | 1 | 4.17% |
Total | 1184 | 100.00% | 24 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.