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

55次阅读
没有评论

共计 2593 个字符,预计需要花费 7 分钟才能阅读完成。

这篇文章主要介绍 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 的操作代码”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-16发表,共计2593字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)