温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

cephfs linux kernel client针对export的操作代码

发布时间:2021-12-17 10:01:30 来源:亿速云 阅读:231 作者:小新 栏目:云计算

这篇文章主要介绍cephfs linux kernel client针对export的操作代码,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

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,

};

ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len, struct inode *parent_inode)

|__调用ceph_snap(inode)函数检查inode是否包含snap信息,若包含snap则直接返回

|__输入参数校验

    |__若parent_inode不为空且max_len小于sizeof(struct ceph_nfs_confh)/4

        |__设置max_len=sizeof(struct ceph_nfs_confh)/4

        |__直接返回

    |__若parent_inode为空且max_len小于sizeof(struct ceph_nfs_fh)/4

        |__设置max_len=sizeof(struct ceph_nfs_fh)/4

        |__直接返回

|__若parent_inode不为空

    |__设置struct ceph_nfs_confh的ino为inode的ino

    |__设置struct ceph_nfs_confh的parent_ino为parent_inode的ino

    |__设置max_len为sizeof(struct ceph_nfs_confh)/4

    |__返回FILEID_INO32_GEN_PARENT

|__若parent_inode为空

    |__设置struct ceph_nfs_fh的ino为inode的ino

    |__设置max_len为sizeof(struct ceph_nfs_fh)/4

    |__返回FILEID_INO32_GEN

ceph_fs_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type)

|__通过fid得到struct ceph_nfs_fh对象

|__检查fh_type是否是FILEID_INO32_GEN或FILEID_INO32_GEN_PARENT,若不是则直接返回

|__调用__fh_to_dentry(sb, fh->ino)函数找到fh->ino对应的dentry结构

__fh_to_dentry(struct super_block *sb, u64 ino)

|__通过sb得到struct ceph_mds_client结构

|__调用ceph_find_inode()函数得到ino指定的struct inode结构

|__若struct inode结构为空

    |__调用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPINO)函数创建查找指定inode的请求

    |__调用ceph_mdsc_do_reqeust()函数将请求发送给mds集群得到指定inode number对应的inode结构

|__调用d_obtain_alias(inode)函数得到inode对应的dentry信息

|__调用ceph_init_dentry()函数来初始化dentry数据结构

ceph_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type)

|__通过sb得到struct ceph_mds_client结构

|__调用__get_parent()函数获取cfh->ino对应的parent的dentry结构

|__若获取parent的dentry结构失败

    |__调用__fh_to_dentry(sb, cfh->parent_ino)函数获取parent_ino对应的dentry结构

__get_parent(struct super_block *sb, struct dentry *child, u64 ino)

|__通过sb得到struct ceph_mds_client结构

|__调用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPPARENT)函数创建查找parent inode的请求

|__调用ceph_mdsc_do_request()函数将请求发送给mds集群

|__从请求的r_target_inode字段得到parent inode信息

|__调用d_obtain_alias(inode)函数得到inode对应的dentry

|__调用ceph_init_dentry(dentry)函数初始化dentry数据结构

ceph_get_parent(struct dentry *child)

|__调用ceph_snap()函数检查child是否包含snap,若包含snap则直接返回

|__调用__get_parent()函数获取child对应parent的dentry结构

ceph_get_name(struct dentry *parent, char *name, struct dentry *child)

|__从child得到struct ceph_mds_client数据结构

|__调用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPNAME)函数创建查找inode name的请求

|__调用ceph_mdsc_do_request()函数将请求同步发送给mds集群

|__调用memcpy()函数将请求的返回信息中的dname复制到name中

以上是“cephfs linux kernel client针对export的操作代码”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI