温馨提示×

温馨提示×

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

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

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

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

这篇文章主要为大家展示了“cephfs linux kernel client针对fscache的操作代码”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“cephfs linux kernel client针对fscache的操作代码”这篇文章吧。

针对inode在fscache中操作主要集中在数据结构struct fscache_cookie_def中,具体的数据结构及其操作如下:

static const struct fscache_cookie_def ceph_fscache_inode_object_def = {

        .name           = "CEPH.inode",

        .type           = FSCACHE_COOKIE_TYPE_DATAFILE,

        .get_key        = ceph_fscache_inode_get_key,

        .get_attr       = ceph_fscache_inode_get_attr,

        .get_aux        = ceph_fscache_inode_get_aux,

        .check_aux      = ceph_fscache_inode_check_aux,

        .now_uncached   = ceph_fscache_inode_now_uncached,

};

ceph_fscache_inode_get_key(void *cookie_netfs_data, void *buffer, uint16_t maxbuf)    读取struct ceph_inode_info中的i_vino信息到buffer

|__从参数cookie_netfs_data的到struct ceph_inode_info数据结构

|__调用memcpy()将struct ceph_inode_info中的i_vino内容复制到buffer中

ceph_fscache_inode_get_attr(void *cookie_netfs_data, uint64_t *size)    读取struct ceph_inode_info中vfs_inode的大小

|__从参数cookie_netfs_data的到struct ceph_inode_info数据结构

|__调用i_size_read()函数读取struct ceph_inode_info中vfs_inode的大小且保存到size中

ceph_fscache_inode_get_aux(void *cookie_netfs_data, void *buffer, uint16_t bufmax)

|__从参数cookie_netfs_data的到struct ceph_inode_info数据结构

|__初始化struct ceph_aux_inode信息

|__从struct ceph_inode_info结构中初始化struct ceph_aux_inode信息

|__将struct ceph_aux_inode信息复制到buffer中

ceph_fscache_inode_check_aux(void *cookie_netfs_data, void *data, uint16_t dlen)

|__从参数cookie_netfs_data的到struct ceph_inode_info数据结构

|__从struct ceph_inode_info结构中初始化struct ceph_aux_inode信息

|__比较参数中的data和初始化后的struct ceph_aux_inode信息

ceph_fscache_inode_now_uncached(void *cookie_netfs_data)

|__从参数cookie_netfs_data的到struct ceph_inode_info数据结构

|__调用pagevec_init()函数初始化pvec

|__调用pagevec_lookup()函数查找struct ceph_inode_info里vfs_inode.i_mapping里所有映射的物理内存页

|__调用ClearPageFsCache()函数清除物理内存页的fscache

|__调用pagevec_release()函数释放pvec

ceph_fscache_register_inode_cookie(struct inode *inode)

|__从参数inode中得到struct ceph_inode_info以及struct ceph_fs_client信息

|__调用fscache_acquire_cookie()函数得到访问ceph fscache的cookie值且将该cookie值保存到struct ceph_inode_info的fscache中

ceph_fscache_unregister_inode_cookie(struct ceph_inode_info *ci)

|__调用fscache_uncache_all_inode_pages()函数从cache中删除所有inode占用的物理内存页

|__调用fscache_relinquish_cookie()函数删除cookie

ceph_fscache_can_enable(void *data)

|__从参数data中得到struct inode数据结构

|__调用inode_is_open_for_write(inode)函数且返回该函数返回值的非

ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)

|__从参数inode得到struct ceph_inode_info数据结构

|__调用fscache_cookie_valid()函数检查struct ceph_inode_info中的fscache是否有效,若无效则直接返回

|__调用inode_is_open_for_write()函数检查inode是打开并可写

    |__调用fscache_disable_cookie()函数禁用cookie

    |__调用fscache_uncache_all_inode_pages()函数删除掉cache中inode的所有物理内存页

|__调用inode_is_open_for_write()函数检查inode是未打开且不可写

    |__调用fscache_enable_cookie()函数启用cookie

ceph_fscache_register()

|__调用fscache_register_netfs()函数注册ceph的fscache

ceph_fscache_unregister()

|__调用fscache_unregister_netfs()函数注销ceph的fscache

ceph_fscache_register_fs(struct ceph_fs_client *fs)

|__调用fscache_acquire_cookie()函数得到访问ceph fscache的cookie值且将该cookie值保存到struct ceph_fs_client的fscache中

ceph_fscache_unregister_fs(struct ceph_fs_client *fsc)

|__调用fscache_relinquish_cookie()函数释放fsc->fscache数据结构

ceph_fscache_session_get_key(void *cookie_netfs_data, void *buffer, uint16_t maxbuf)

|__从参数cookie_netfs_data的到struct ceph_fs_client数据结构

|__调用memcpy()函数将struct ceph_fs_client数据结构中的client->fsid值复制到buffer中

ceph_readpage_from_fscache(struct inode *inode, struct page *page)

|__从参数inode得到struct ceph_inode_info数据结构

|__调用fscache_read_or_alloc_page()函数从fscache中读取inode的内容并写到page中

ceph_readpages_from_fscache(struct inode *inode, struct address_space *mapping, struct list_head *pages, unsigned *nr_pages)

|__从参数inode得到struct ceph_inode_info数据结构

|__调用fscache_read_or_alloc_pages()函数从fscahe中读取mapping中的数据并写入到pages中

ceph_readpage_to_fscache(struct inode *inode, struct page *page)

|__从参数inode得到struct ceph_inode_info数据结构

|__调用fscache_write_page()函数将物理内存页page中的数据同步到fscache中

ceph_invalidate_fscache_page(struct inode *inode, struct page *page)

|__从参数inode得到struct ceph_inode_info数据结构

|__调用fscache_wait_on_page_write()函数等待page写入完成

|__调用fscache_uncache_page()函数将page中的内容从struct ceph_inode_info中的fscache中删除

ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci)

|__调用cache_valid()函数检查ci指定的fscache是否有效,若无效

    |__调用fscache_check_consistency()函数校验ci->fscache的一致性,若不一致

        |__调用fscache_invalidate()函数设置ci->fscache无效

    |__设置ci->i_fscache_gen=ci->i_rdcache_gen

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

向AI问一下细节

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

AI