函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\readahead.c Create Date:2022-07-27 15:35:54
Last Modify:2020-03-17 21:13:07 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:A minimal readahead algorithm for trivial sequential/random reads.

函数原型:static unsigned long ondemand_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, bool hit_readahead_marker, unsigned long offset, unsigned long req_size)

返回类型:unsigned long

参数:

类型参数名称
struct address_space *mapping
struct file_ra_state *ra
struct file *filp
boolhit_readahead_marker
unsigned longoffset
unsigned longreq_size
387  bdi等于inode_to_bdi(host)
388  max_pages等于Maximum readahead window
396  如果req_size大于max_pages max allowed IO size 大于max_pagesmax_pages等于两数取小(req_size, max allowed IO size )
402  如果非offset则转到:initial_readahead
409  如果offset恒等于where readahead started # of readahead pages do asynchronous readahead whenthere are only # of pages ahead offset恒等于where readahead started # of readahead pages
411  where readahead started 加等于# of readahead pages
412  # of readahead pages 等于Get the previous window size, ramp it up, and* return it as the new window size.
413  do asynchronous readahead whenthere are only # of pages ahead 等于# of readahead pages
414  转到:readit
423  如果hit_readahead_marker
426  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
427  start等于page_cache_next_miss() - Find the next gap in the page cache.*@mapping: Mapping.*@index: Index.*@max_scan: Maximum range to search.* Search the range [index, min(index + max_scan - 1, ULONG_MAX)] for the* gap with the lowest index.
428  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
430  如果非startstartoffset大于max_pages则返回:0
433  where readahead started 等于start
434  # of readahead pages 等于startoffset
435  # of readahead pages 加等于req_size
436  # of readahead pages 等于Get the previous window size, ramp it up, and* return it as the new window size.
437  do asynchronous readahead whenthere are only # of pages ahead 等于# of readahead pages
438  转到:readit
444  如果req_size大于max_pages则转到:initial_readahead
452  prev_offset等于Cache last read() position 右移PAGE_SHIFT determines the page size
453  如果offsetprev_offset小于等于1UL则转到:initial_readahead
460  如果page cache context based read-ahead则转到:readit
467  返回:__do_page_cache_readahead() actually reads a chunk of disk. It allocates* the pages first, then submits them for I/O. This avoids the very bad* behaviour which would occur if page allocations are causing VM writeback.
469  initial_readahead :
470  where readahead started 等于offset
471  # of readahead pages 等于Set the initial window size, round to next power of 2 and square* for small size, x 4 for medium, and x 2 for large* for 128k (32 page) max ra* 1-8 page = 32k initial, > 8 page = 128k initial
472  do asynchronous readahead whenthere are only # of pages ahead 等于如果# of readahead pages 大于req_size# of readahead pages req_size否则# of readahead pages
474  readit :
481  如果offset恒等于where readahead started # of readahead pages 恒等于do asynchronous readahead whenthere are only # of pages ahead
482  add_pages等于Get the previous window size, ramp it up, and* return it as the new window size.
483  如果# of readahead pages add_pages小于等于max_pages
486  否则
492  返回:Submit IO for the read-ahead request in file_ra_state.
调用者
名称描述
page_cache_sync_readaheadpage_cache_sync_readahead - generic file readahead*@mapping: address_space which holds the pagecache and I/O vectors*@ra: file_ra_state which holds the readahead state*@filp: passed on to ->readpage() and ->readpages()*@offset: start offset into @mapping,
page_cache_async_readaheadpage_cache_async_readahead - file readahead for marked pages*@mapping: address_space which holds the pagecache and I/O vectors*@ra: file_ra_state which holds the readahead state*@filp: passed on to ->readpage() and ->readpages()*@page: the page at @offset