久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

cephfs kernel client針對dir的file

164次閱讀
沒有評論

共計 3683 個字符,預計需要花費 10 分鐘才能閱讀完成。

這篇文章給大家分享的是有關 cephfs kernel client 針對 dir 的 file_operations 操作代碼的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。

cephfs kernel client 針對 dir 的 file_operations 操作

const struct file_operations ceph_dir_fops = {

        .read = ceph_read_dir,

        .iterate = ceph_readdir,

        .llseek = ceph_dir_llseek,

        .open = ceph_open,

        .release = ceph_release,

        .unlocked_ioctl = ceph_ioctl,

        .fsync = ceph_fsync,

};

ceph_read_dir(struct file *file, char __user *buf, size_t size, loff_t *ppos)    只有在 mount 時帶有參數 -o dirstat 時該函數才有效

|__調用 ceph_test_mount_opt() 函數檢查 mount options 中是否包含 DIRSTAT,若不包含則直接返回

|__若 struct ceph_file_info 中的 dir_info 為空

   |__調用 kmalloc() 函數為 dir_info 分配空間

   |__使用 snprintf() 函數向 dir_info 的內存空間進行格式化輸出

|__調用 copy_to_user() 函數將 dir_info 中的內容復制到用戶態空間 buf 中

ceph_readdir(struct file *file, struct dir_context *ctx)

|__調用 dir_emit() 函數向外發布”.”和”..”信息

|__若 mount options 中包含 DCACHE 則說明應該盡可能的從 dcache 中讀取 dir 的信息

   |__調用__dcache_readdir() 函數從 dcache 中讀取 dir

   |__返回值不等于 EAGAIN

     |__直接返回

|__調用 need_send_readdir() 函數檢查是否應該從集群中讀取 dir 的內容

   |__得到操作碼 op=CEPH_MDS_OP_LSSNAP 或者 CEPH_MDS_OP_READDIR

   |__調用 ceph_mdsc_create_request() 函數創建 mds 請求

   |__調用 ceph_alloc_readdir_reply_buffer() 函數為從集群中讀取到的 dir 內容分配內存空間

   |__調用 ceph_mdsc_do_request() 函數將請求同步發送給 mds 進程

|__遍歷 struct ceph_file_info- last_readdir- r_reply_info- dir_nr

   |__調用 dir_emit() 函數向外發布 dir 信息

ceph_dir_llseek(struct file *file, loff_t offset, int whence)

|__根據 whence 的不同值更新 offset 的值

|__若 offset =0

   |__調用 need_reset_readdir() 函數檢查是否需要 reset readdir

     |__調用 reset_readdir() 函數

   |__調整 file- f_pos 值為 offset 值

ceph_open(struct inode *inode, struct file *file)    該函數在打開文件時被調用

|__調用 prepare_open_request() 函數來創建 ceph_mds_request 請求

|__調用 ceph_mdsc_do_request() 函數將 ceph_mds_request 請求同步的發送給 mds 進程

|__調用 ceph_init_file() 函數創建 ceph_file_info 數據結構且將該數據結構放入到 file- private_data 中

ceph_release(struct inode *inode, struct file *file)    該函數在關閉文件時被調用

|__調用 ceph_put_fmode() 函數減少打開文件的引用次數,若引用次數為 0,則從本地 cache 中刪除該文件

ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

|__根據 cmd 的值做不同的處理

   |__cmd==CEPH_IOC_GET_LAYOUT

     |__ceph_ioctl_get_layout()

       |__ceph_do_getattr(CEPH_STAT_CAP_LAYOUT) 從 mds 集群中讀取 file 對應的 inode 的 layout 信息到 ceph_inode_info 的 i_layout 中

       |__將 i_layout 信息寫入到 struct ceph_ioctl_layout 數據結構中且通過 copy_to_user() 函數將數據返回給用戶態

   |__cmd==CEPH_IOC_SET_LAYOUT

     |__ceph_ioctl_set_layout()

       |__調用 copy_from_user() 函數將新的 layout 信息從用戶態復制到內核態

       |__調用 ceph_do_getattr() 函數從 mds 集群中讀取當前的 layout 信息

       |__調用__validate_layout() 函數檢查新設置的 layout 是否有效

       |__調用 ceph_mdsc_create_request() 函數創建 request 請求

       |__調用 ceph_mdsc_do_request() 函數同步的發送 request 請求到 mds 集群

   |__cmd==CEPH_IOC_SET_LAYOUT_POLICY

     |__ceph_ioctl_set_layout_policy()

       |__調用 copy_from_user() 函數將新的 layout 信息從用戶態復制到內核態

       |__調用__validate_layout() 函數檢查新設置的 layout 是否有效

       |__調用 ceph_mdsc_create_request() 函數創建 request 請求

       |__調用 ceph_mdsc_do_request() 函數同步的發送 request 請求到 mds 集群

   |__cmd==CEPH_IOC_GET_DATALOC          計算 data 所在的 ceph 集群中的位置信息

     |__ceph_ioctl_get_dataloc()

       |__調用 copy_from_user() 函數將 ceph_ioctl_dataloc 信息復制到內核態

       |__調用 ceph_calc_file_object_mapping() 函數計算 ceph_ioctl_dataloc 信息中指定文件所在的 oid 等信息

       |__調用 ceph_object_locator_to_pg() 函數計算出 oid 所在的 pg 信息

       |__調用 ceph_pg_to_acting_primary() 函數計算出 pg 所在的主 osd 信息

       |__調用 copy_to_user() 函數將計算出來的信息發送回給用戶態

   |__cmd==CEPH_IOC_LAZYIO              設置 LAZYIO 標識

     |__ceph_ioctl_lazyio()

       |__ 判斷 struct ceph_file_info 中的 fmode 是否未設置 CEPH_FILE_MODE_LAZY

         |__設置 struct ceph_file_info 中的 fmode 擁有 CEPH_FILE_MODE_LAZY 標識

         |__更新 ceph_inode_info 中的 i_nr_by_mode 數組

         |__調用 ceph_check_caps() 函數更新 caps

   |__cmd==CEPH_IOC_SYNCIO

     |__ceph_ioctl_syncio()

       |__設置 struct ceph_file_info 結構中的 flags 的 CEPH_F_SYNC 位

ceph_fsync(struct file *file, loff_t start , loff_t end, int datasync)

|__調用 ceph_sync_write_wait() 函數等待 inode 上所有未完成的 osd 請求執行完畢

|__調用 try_flush_caps() 函數將所有 dirty 的 caps 刷回到 mds

|__調用 unsafe_request_wait() 函數等待 inode 上所有針對 mds 請求執行完畢

感謝各位的閱讀!關于“cephfs kernel client 針對 dir 的 file_operations 操作代碼”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-16發表,共計3683字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 蓬莱市| 慈溪市| 中阳县| 定陶县| 壶关县| 建阳市| 财经| 楚雄市| 大荔县| 彭山县| 南靖县| 乐昌市| 双鸭山市| 稷山县| 彭州市| 南京市| 登封市| 德钦县| 盘山县| 南康市| 二手房| 五台县| 南通市| 伊春市| 建瓯市| 崇仁县| 广昌县| 抚顺县| 南靖县| 屯留县| 南开区| 河西区| 色达县| 宝鸡市| 大埔县| 广汉市| 容城县| 敦煌市| 新乡市| 渝中区| 札达县|