温馨提示×

温馨提示×

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

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

cephfs linux kernel client针对superblock操作流程的示例分析

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

这篇文章给大家分享的是有关cephfs linux kernel client针对superblock操作流程的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

init_caches()
  初始化如下几个cache:
    ceph_inode_cachep
    ceph_cap_cachep
    ceph_cap_flush_cachep
    ceph_dentry_cachep
    ceph_file_cachep
    cephfs cache 

ceph_mount()
|__解析mount options
|__创建fs client,即:struct ceph_fs_client
|__创建mds client且设置fs client和mds client之间的对应关系
|__得到superblock且使用ceph_set_super()函数初始化
|__调用ceph_real_mount()函数来执行实际的mount操作

ceph_real_mount()
|__若superblock中对应的s_boot为空
  |__调用__ceph_open_session()函数创建client到mds的session信息
  |__调用open_root_dentry()函数得到cephfs的root dentry信息
  |__将root dentry写入到superblock中的s_boot中
|__若mount options中没有server path内容
  |__设置当前root为supberblock对应的s_root
  |__调用dget(root)函数得到root的dentry信息
|__若mount options中有server path内容
  |__调用open_root_dentry()得到server path指定的root dentry信息
|__设置mount state为CEPH_MOUNT_MOUNTED

使用ceph_set_super()函数初始化superblock时通过设置如下内容来设置对superblock的操作:
s->s_xattr = ceph_xattr_handlers    处理扩展属性的
s->s_op = ceph_super_ops        处理针对superblock正常操作的
s->s_export_op = ceph_export_ops    处理针对superblock的export操作的

ceph_super_ops的类型是struct super_operations,其中包含了对superblock操作的所有回调函数集合。
ceph_alloc_inode()    该函数用于分配inode
|__从内核cache中得到ceph inode信息,即:struct ceph_inode_info 
|__初始化struct ceph_inode_info
  |__设置了针对inode的writeback的内核线程ceph_writeback_work
  |__设置了针对inode的invalidate的内核线程ceph_invalidate_work
  |__设置了针对inode的vmtruncate的内核线程ceph_vmtruncate_work
|__返回struct inode信息

ceph_destroy_inode(struct inode *inode)
|__调用ceph_fscache_unregister_inode_cookie()函数将inode从fscache中清除掉
|__调用ceph_queue_caps_release()函数将ceph_inode_info中所有caps删除掉
|__若ceph_inode_info中包含snap realm信息
  |__调用ceph_put_snap_realm()释放snap realm 
|__释放ceph_inode_info中的fragtree信息
|__调用__ceph_destroy_xattrs()函数释放ceph_inode_info中所有的xattrs信息
|__调用ceph_put_string()函数释放ceph_inode_info中layout的pool_ns信息

ceph_write_inode(struct inode *inode, struct writeback_control *wbc)
|__调用try_flush_caps()函数将ceph_inode_info中所有dirty caps刷回到mds集群中

ceph_evict_inode(struct inode *inode)
|__调用ceph_sync_write_wait()函数将ceph_inode_info中所有i_unsafe_writes链表上的请求同步到ceph集群
|__调用truncate_inode_pages_final()函数将inode所占用的pages都释放掉
|__调用clear_inode()清除inode信息

ceph_sync_fs(struct super_block *sb, int wait)
|__从superblock中得到struct ceph_fs_client信息
|__调用ceph_osdc_sync()函数将所有osdc连接的osds上的所有struct ceph_osd_request请求同步到ceph集群
|__调用ceph_mdsc_sync()函数将ceph_inode_info中所有dirty caps刷回到mds集群中

ceph_put_super(struct super_block *s)
|__调用ceph_mdsc_close_sessions()函数来关闭所有的mds sessions 
  
ceph_show_options(struct seq_file *m, struct dentry *root)
|__显示所有的mount options在/proc/mounts下

ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
|__根据参数dentry得到struct ceph_fs_client信息,即:fsc=ceph_inode_to_client()
|__通过struct ceph_fs_client得到struct ceph_monmap信息
|__通过调用ceph_monc_do_statfs()从monitor处得到所有的stats信息
|__将从monitor处得到的stats信息格式化输出到buf中

ceph_umount_begin(struct super_block *sb)
|__通过superblock得到struct ceph_fs_client信息
|__调用ceph_mdsc_force_umount()函数执行强制umount操作
  |__查询到所有的mds sessions并且调用__close_session()函数来关闭session
  |__调用tick_requests()函数将未发送出去的request发送到其他mds进程
|__调用__wake_requests()函数将mdsc->waiting_for_map上的请求发送到其他mds进程上


ceph_xattr_handlers的类型是struct xattr_handler,其中包含了所有对inode的xattr的操作。
ceph_get_xattr_handler(struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, char *name, void *value, size_t size)
|__调用ceph_is_valid_xattr()函数检查name是否是有效的属性名
|__调用__ceph_getxattr()函数得到属性名name对应的属性值value以及属性值value的大小size
  |__检查name是否是vxattr,若是则直接从vxattr处获取name对应的value值
  |__调用ceph_do_getattr()函数从mds集群中获取inode对应的xattrs值
  |__调用__build_xattrs()函数创建xattrs数据结构
  |__调用__get_xattr()函数从xattrs中得到name对应的value
  
ceph_set_xattr_handler(struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, char *name, void *value, size_t size, int flags)
|__调用ceph_is_valid_xattr()函数检查name是否是有效的属性名
|__调用__ceph_setxattr()函数设置属性名name和属性值value并同步到mds集群中
  |__调用__build_xattrs()函数得到xattrs数据结构
  |__调用__set_xattr()函数将属性名name和属性值value写入到ceph_inode_info的xattrs对应的红黑树里
  |__调用__ceph_mark_dirty_caps()函数设置caps dirty
|__调用ceph_sync_setxattr()函数将inode对应的属性名name和属性值value同步到mds集群
 

感谢各位的阅读!关于“cephfs linux kernel client针对superblock操作流程的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

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

AI