Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cephfs kernel client file_operations operation code for dir

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you the content of cephfs kernel client's file_operations operation code for dir. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Cephfs kernel client's file_operations operation for dir

Const struct file_operations ceph_dir_fops = {

.read = ceph_read_dir

.iterate = ceph_readdir

.llcards = ceph_dir_llseek

.open = ceph_open

.release = ceph_release

.unloaded _ ioctl = ceph_ioctl

.fsync = ceph_fsync

}

Ceph_read_dir (struct file * file, char _ _ user * buf, size_t size, loff_t * ppos) is valid only when mount takes the parameter-o dirstat

| | _ _ call the ceph_test_mount_opt () function to check whether DIRSTAT is included in the mount options, and return directly if it does not include it |

| | _ _ if the dir_info in struct ceph_file_info is empty |

| | _ _ call kmalloc () function to allocate space for dir_info |

| | _ _ use the snprintf () function to format output to the memory space of dir_info |

| | _ _ call the copy_to_user () function to copy the contents of dir_info to the user state space buf |

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

| _ _ call the dir_emit () function to publish "." And ".." information

| | _ _ if DCACHE is included in mount options, you should read dir information from dcache as much as possible. |

| | _ _ call _ _ dcache_readdir () function to read dir from dcache |

| | _ _ returned value is not equal to EAGAIN |

| | _ _ return directly |

| | _ _ call the need_send_readdir () function to check whether the contents of dir should be read from the cluster |

| | _ _ get the opcode op=CEPH_MDS_OP_LSSNAP or CEPH_MDS_OP_READDIR |

| | _ _ call the ceph_mdsc_create_request () function to create a mds request |

| | _ _ call the ceph_alloc_readdir_reply_buffer () function to allocate memory space for the dir content read from the cluster |

| | _ _ call the ceph_mdsc_do_request () function to send the request to the mds process synchronously |

| | _ _ traversal struct ceph_file_info- > last_readdir- > rroomreplyinformation-> dir_nr |

| | _ _ call dir_emit () function to publish dir information |

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

| | _ _ update the value of whence according to the different values of offset |

| | _ if offset > = 0 |

| | _ _ call the need_reset_readdir () function to check whether reset readdir is required |

| | _ _ call reset_readdir () function |

| | _ _ adjust file- > f _ posvalue to offset value |

Ceph_open (struct inode * inode, struct file * file) this function is called when the file is opened

| | _ _ call the prepare_open_request () function to create a ceph_mds_request request |

| | _ _ call ceph_mdsc_do_request () function to send the ceph_mds_request request to the mds process synchronously |

| | _ _ call the ceph_init_file () function to create a ceph_file_info data structure and put the data structure into file- > private_data |

Ceph_release (struct inode * inode, struct file * file) this function is called when the file is closed

| | _ _ call the ceph_put_fmode () function to reduce the number of references to a file. If the number of references is 0, the file will be deleted from the local cache. |

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

| | _ _ do different processing according to the value of cmd |

| | _ cmd==CEPH_IOC_GET_LAYOUT |

| | _ ceph_ioctl_get_layout () |

| | _ _ ceph_do_getattr (CEPH_STAT_CAP_LAYOUT) reads the layout information of the inode corresponding to file from the mds cluster to the i_layout of ceph_inode_info |

| | _ _ write the i_layout information to the struct ceph_ioctl_layout data structure and return the data to the user state through the copy_to_user () function |

| | _ cmd==CEPH_IOC_SET_LAYOUT |

| | _ ceph_ioctl_set_layout () |

| | _ _ call the copy_from_user () function to copy the new layout information from user mode to kernel mode |

| | _ _ call ceph_do_getattr () function to read the current layout information from the mds cluster |

| | _ _ call _ _ validate_layout () function to check whether the newly set layout is valid |

| | _ _ call the ceph_mdsc_create_request () function to create a request request |

| | _ _ call the ceph_mdsc_do_request () function to send a request request to the mds cluster synchronously |

| | _ cmd==CEPH_IOC_SET_LAYOUT_POLICY |

| | _ ceph_ioctl_set_layout_policy () |

| | _ _ call the copy_from_user () function to copy the new layout information from user mode to kernel mode |

| | _ _ call _ _ validate_layout () function to check whether the newly set layout is valid |

| | _ _ call the ceph_mdsc_create_request () function to create a request request |

| | _ _ call the ceph_mdsc_do_request () function to send a request request to the mds cluster synchronously |

| | _ _ cmd==CEPH_IOC_GET_DATALOC calculates the location information in the ceph cluster where the data resides |

| | _ ceph_ioctl_get_dataloc () |

| | _ _ call copy_from_user () function to copy ceph_ioctl_dataloc information to kernel state |

| | _ _ call the ceph_calc_file_object_mapping () function to calculate the oid and other information of the specified file in the ceph_ioctl_dataloc information |

| | _ _ call the ceph_object_locator_to_pg () function to calculate the pg information where the oid is located |

| | _ _ call the ceph_pg_to_acting_primary () function to calculate the information of the main osd where the pg is located |

| | _ _ call the copy_to_user () function to send the calculated information back to the user state |

| | _ _ cmd==CEPH_IOC_LAZYIO sets the LAZYIO ID |

| | _ ceph_ioctl_lazyio () |

| | _ _ determines whether the fmode in struct ceph_file_info does not have CEPH_FILE_MODE_LAZY set |

| | _ _ sets the fmode in struct ceph_file_info to have the CEPH_FILE_MODE_LAZY ID |

| | _ _ update the i_nr_by_mode array in ceph_inode_info |

| | _ _ call ceph_check_caps () function to update caps |

| | _ cmd==CEPH_IOC_SYNCIO |

| | _ ceph_ioctl_syncio () |

| | _ _ sets the CEPH_F_ sync bit of flags in struct ceph_file_info structure |

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

| | _ _ call the ceph_sync_write_wait () function to wait for the execution of all outstanding osd requests on inode. |

| | _ _ call the try_flush_caps () function to brush the caps of all dirty back to mds |

| | _ _ call the unsafe_request_wait () function to wait for the execution of all mds requests on the inode. |

Thank you for reading! This is the end of this article on "cephfs kernel client's file_operations operation code for dir". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report