溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

cephfs linux kernel client針對export的操作代碼

發(fā)布時間:2021-12-17 10:01:30 來源:億速云 閱讀:242 作者:小新 欄目:云計算

這篇文章主要介紹cephfs linux kernel client針對export的操作代碼,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

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)

|__調(diào)用ceph_snap(inode)函數(shù)檢查inode是否包含snap信息,若包含snap則直接返回

|__輸入?yún)?shù)校驗

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

        |__設(shè)置max_len=sizeof(struct ceph_nfs_confh)/4

        |__直接返回

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

        |__設(shè)置max_len=sizeof(struct ceph_nfs_fh)/4

        |__直接返回

|__若parent_inode不為空

    |__設(shè)置struct ceph_nfs_confh的ino為inode的ino

    |__設(shè)置struct ceph_nfs_confh的parent_ino為parent_inode的ino

    |__設(shè)置max_len為sizeof(struct ceph_nfs_confh)/4

    |__返回FILEID_INO32_GEN_PARENT

|__若parent_inode為空

    |__設(shè)置struct ceph_nfs_fh的ino為inode的ino

    |__設(shè)置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,若不是則直接返回

|__調(diào)用__fh_to_dentry(sb, fh->ino)函數(shù)找到fh->ino對應(yīng)的dentry結(jié)構(gòu)

__fh_to_dentry(struct super_block *sb, u64 ino)

|__通過sb得到struct ceph_mds_client結(jié)構(gòu)

|__調(diào)用ceph_find_inode()函數(shù)得到ino指定的struct inode結(jié)構(gòu)

|__若struct inode結(jié)構(gòu)為空

    |__調(diào)用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPINO)函數(shù)創(chuàng)建查找指定inode的請求

    |__調(diào)用ceph_mdsc_do_reqeust()函數(shù)將請求發(fā)送給mds集群得到指定inode number對應(yīng)的inode結(jié)構(gòu)

|__調(diào)用d_obtain_alias(inode)函數(shù)得到inode對應(yīng)的dentry信息

|__調(diào)用ceph_init_dentry()函數(shù)來初始化dentry數(shù)據(jù)結(jié)構(gòu)

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

|__通過sb得到struct ceph_mds_client結(jié)構(gòu)

|__調(diào)用__get_parent()函數(shù)獲取cfh->ino對應(yīng)的parent的dentry結(jié)構(gòu)

|__若獲取parent的dentry結(jié)構(gòu)失敗

    |__調(diào)用__fh_to_dentry(sb, cfh->parent_ino)函數(shù)獲取parent_ino對應(yīng)的dentry結(jié)構(gòu)

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

|__通過sb得到struct ceph_mds_client結(jié)構(gòu)

|__調(diào)用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPPARENT)函數(shù)創(chuàng)建查找parent inode的請求

|__調(diào)用ceph_mdsc_do_request()函數(shù)將請求發(fā)送給mds集群

|__從請求的r_target_inode字段得到parent inode信息

|__調(diào)用d_obtain_alias(inode)函數(shù)得到inode對應(yīng)的dentry

|__調(diào)用ceph_init_dentry(dentry)函數(shù)初始化dentry數(shù)據(jù)結(jié)構(gòu)

ceph_get_parent(struct dentry *child)

|__調(diào)用ceph_snap()函數(shù)檢查child是否包含snap,若包含snap則直接返回

|__調(diào)用__get_parent()函數(shù)獲取child對應(yīng)parent的dentry結(jié)構(gòu)

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

|__從child得到struct ceph_mds_client數(shù)據(jù)結(jié)構(gòu)

|__調(diào)用ceph_mdsc_create_request(CEPH_MDS_OP_LOOKUPNAME)函數(shù)創(chuàng)建查找inode name的請求

|__調(diào)用ceph_mdsc_do_request()函數(shù)將請求同步發(fā)送給mds集群

|__調(diào)用memcpy()函數(shù)將請求的返回信息中的dname復(fù)制到name中

以上是“cephfs linux kernel client針對export的操作代碼”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI