In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the operation code of cephfs linux kernel client for linux page cache, which is very detailed and has certain reference value. Friends who are interested must finish reading it.
The operation on linux page cache is mainly reflected in the struct address_space_operations data structure. The set of functions used by cephfs to process linux page cache is as follows:
Const struct address_space_operations ceph_aops = {
.readpage = ceph_readpage
.readpages = ceph_readpages
.writepage = ceph_writepage
.writepages = ceph_writepages_start
.write _ begin = ceph_write_begin
.write _ end = ceph_write_end
.set _ page_dirty = ceph_set_page_dirty
.invalidatepage = ceph_invalidatepage
.releasers = ceph_releasepage
.direct _ IO = ceph_direct_io
}
Ceph_readpage (struct file * filp, struct page * page)
| | _ _ call readpage_nounlock (filep, page) to read the data of a physical memory page with lock |
| | _ _ make sure that the offset of page does not exceed the total length of inode |
| | _ _ call the ceph_readpage_from_fscache () function to attempt to read the data of a physical memory page from fscache |
| | _ _ if the read is successful, it will be returned directly |
| | _ _ call ceph_osdc_readpages () function to read the data of a physical memory page from the ceph cluster |
| | _ _ call ceph_osdc_new_reqeust () function to create a read request |
| | _ _ call the osd_req_op_extent_osd_data_pages () function to allocate memory space for the returned content of the read request |
| | _ _ call ceph_osdc_start_request () function to send read request to ceph cluster synchronously |
| | _ _ call the flush_dcache_page () function to page into dcache |
| | _ _ call the SetPageUptodate () function to set the status of the physical memory page to update |
| | _ _ call the ceph_readpage_to_fscache () function to update the newly read physical memory page to fscache |
| | _ _ call unlock_page (page) |
| | _ _ call clear_bit_unlock () function to unlock page |
| | _ _ call the wake_up_page () function to wake up the relevant processes waiting for the page |
Ceph_readpages (struct file * file, struct address_space * mapping, struct list_head * page_list, unsigned nr_pages) reads multiple pages
| | _ _ call ceph_readpages_from_fscache () function to attempt to read data from multiple physical memory pages from fscache |
| | _ _ if the read is successful, it will be returned directly |
| | _ _ traverses page_list |
| | _ _ call the start_read () function to read data to the physical memory page contained in page_list |
| | _ _ call ceph_osdc_new_reqeust () function to create a read request |
| | _ _ call the calc_pages_for (0, len) function to get the number of physical memory pages needed to read the data of the specified length len |
| | _ _ remove the specified number of physical memory pages from page_list |
| | _ _ call the osd_req_op_extent_osd_data_pages () function to use the physical memory page removed from page_list as the receive buffer for read requests |
| | _ _ set the callback function after the read request is completed as finish_read () |
| | _ _ call ceph_osdc_start_request () function to send read request to ceph cluster synchronously |
Finish_read (struct ceph_osd_request * req) callback function after reading operation from ceph cluster
| | _ _ traverses all physical memory pages read |
| | _ _ call the flush_dcache_page () function to brush the memory in page to dcache |
| | _ _ call the SetPageUptodate () function to set the status of page to uptodate |
| | _ _ call the ceph_readpage_to_fscache () function to synchronize the read page memory to fscache |
Ceph_writepage (struct page * page, struct writeback_control * wbc)
| | _ _ call the writepage_nounlock (page,wbc) function to synchronize page information to the ceph cluster |
| | _ _ call the page_snap_context () function to get the snap context information of page (page writes the CephSnapContext information to the private of page) |
| | _ _ call the set_page_writeback (page) function to set the page writeback ID |
| | _ _ call the ceph_osdc_writepages () function to write page information synchronously to the ceph cluster |
| | _ _ call ceph_osdc_new_reqeust () function to create a write request |
| | _ _ call the osd_req_op_extent_osd_data_pages () function to set the write content physical memory page for the write request |
| | _ _ call the ceph_osdc_start_request () function to send the write request to the ceph cluster synchronously |
| | _ _ set page- > private=0, that is, delete the CephSnapContext information of page |
| | _ _ call the ClearPagePrivate (page) function to clear the private of page |
| | _ _ call end_page_writeback () function |
| | _ _ call the wake_up_page (page, PG_writeback) function to wake up the process waiting for writeback to complete on page |
Ceph_writepages_start (struct address_space * mapping, struct writeback_control * wbc)
| | _ _ call pagevec_init (& pvec, 0) function to initialize struct pagevec instance pvec |
| | _ _ get start and end from range_start and range_end of wbc |
| | _ _ call pagevec_lookup_tag (& pvec, mapping, PAGECACHE_TAG_DIRTY …) | Function finds all pages of tags==PAGECACHE_TAG_DIRTY from radix tree in mapping and writes all pages to pvec
| | _ _ traverses all pages of PAGECACHE_TAG_DIRTY |
| | _ _ call the page_offset () function to get the offset value where page is located |
| | _ _ call the ceph_calc_file_object_mapping () function to get the number of objects occupied by a file whose length is len starting from offset and its offset in object |
| | _ _ add page to pages array |
| | _ _ get the offset value from the pages array, that is, offset=page_offset (pages [0]) |
| | _ _ call the ceph_osdc_new_request () function to create a write data request |
| | _ _ set the callback function of the write data request to writepages_finish |
| | _ _ call the osd_req_op_extent_osd_data_pages () function to add additional data for the write request |
| | _ _ call the ceph_osdc_start_request () function to send the write request to the ceph cluster synchronously |
Writepages_finish (struct ceph_osd_request * req)
| | _ _ clear all memory generated during the sending of a write request |
Ceph_write_begin (struct file * file, struct address_space * mapping, loff_t pos, unsigned len, unsigend flags, staruct page * pagep, void * fsdata)
| | _ _ get the page location where pos is located, that is, index=pos > > PAGE_SHIFT |
| | _ _ call the grab_cache_page_write_begin (mapping, index, flags) function to index at the specified location in pagecache to get or create a physical memory page page |
| | _ _ call the pagecache_get_page () function to index at the specified location in pagecache to obtain or create a physical memory page page |
| | _ _ call the wait_for_stable_page (page) function and wait for the writeback function on the page to return |
| | _ _ calling the ceph_update_writeable_page (file, pos, len, page) function only allows you to write data to clean page or snap context that has already been dirty |
| | _ _ call the wait_on_page_writeback (page) function to wait for the completion of the writeback of page |
| | _ _ call the page_snap_context (page) function to get the snap context of the page |
| | _ _ if seq > oldest- > seq of snap context |
| | _ _ call the ceph_queue_writeback (inode) function to put the inode into the writeback queue |
| | _ _ call the clear_page_dirty_for_io (page) function to clear the dirty identity on the page |
| | _ _ call the writepage_nounlock (page, NULL) function to write page data synchronously to the ceph cluster |
| | _ _ call PageUptodate (page) to check whether page belongs to uptodate |
| | _ _ Yes, return directly |
| | _ _ if page is full |
| | _ _ return directly |
| | _ _ call the i_size_read (inode) function to get the read data size of inode |
| | _ _ call readpage_nounlock (file, page) function to read data from ceph cluster to page |
Ceph_write_end (struct file * file, struct address_space * mapping, loff_t pos, unsigned len, unsigned copied, struct page * * page, void * fsdata)
| | _ if copied |
< len |__调用zero_user_segment(page, from+copied, len)函数将page中从from+copied一直到from+copied+len的内存空间置0 |__若pos+copied >I_size_read (inode)
| | _ _ call the ceph_inode_set_size () function to set the size of inode to pos+copied |
| | _ _ if Page does not belong to uptodate |
| | _ _ call the SetPageUptodate (page) function to set page to uptodate |
| | _ _ call the set_page_dirty (page) function to set page to dirty |
Ceph_set_page_dirty (struct page * page)
| | _ if PageDirty (page) |
| | _ _ return directly |
| | _ _ to struct ceph_inode_info structure via mapping |
| | _ _ call _ _ ceph_have_pending_cap_snap () function to check whether cephfs has snaps |
| | _ _ get the struct ceph_cap_snap structure from the i_cap_snaps list in the struct ceph_inode_info structure |
| | _ _ get struct ceph_snap_context structure from struct ceph_cap_snap structure |
| | _ _ if cephfs does not have snaps |
| | _ _ call the ceph_get_snap_context () function to get the struct ceph_snap_context structure from the i_head_spapc of struct ceph_inode_info |
| | _ _ set the struct ceph_snap_context structure to the private of page, that is, page- > private=snapc |
| | _ _ call _ _ set_page_dirty_nobuffers () function to set page to dirty in radix tree in address_spaces |
Ceph_invalidatepage (struct page * page, unsigned int offset, unsigned int length)
| | _ _ call the ceph_invalidate_fscache_page () function to invalidate page in fscache |
| | _ _ if page does not have private |
| | _ _ return directly |
| | _ _ set page- > private=0 to clear the snaps of page |
| | _ _ call ClearPagePriavte (page) |
Ceph_releasepage (struct page * page, gfp_t g)
| | _ _ call ceph_release_fscache_page () function to delete page in fscache |
| | _ _ return! PagePrivate (page) |
Ceph_direct_io (struct kiocb * iocb, struct iov_iter * iter)
| | _ return-EINVAL |
The above is all the contents of this article "cephfs linux kernel client's operation code for linux page cache". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.