Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\filemap.c Create Date:2022-07-28 14:02:19
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:generic_file_buffered_read - generic file read routine*@iocb: the iocb to read*@iter: data destination*@written: already copied* This is a generic file read routine, and uses the* mapping->a_ops->readpage() function for the actual low-level stuff.

Proto:static ssize_t generic_file_buffered_read(struct kiocb *iocb, struct iov_iter *iter, ssize_t written)

Type:ssize_t

Parameter:

TypeParameterName
struct kiocb *iocb
struct iov_iter *iter
ssize_twritten
2012  filp = ki_filp
2013  mapping = f_mapping
2014  inode = host
2015  ra = f_ra
2016  ppos = The 'ki_filp' pointer is shared in a union for aio
2022  error = 0
2024  If Value for the false possibility is greater at compile time( * ppos >= s_maxbytes) Then Return 0
2026  Cap the iov_iter by given limit; note that the second argument is* *not* the new size - it's upper limit for such. Passing it a value* greater than the amount of data in iov_iter is fine - it'll just do* nothing in that case.
2028  index = ppos >> PAGE_SHIFT determines the page size
2029  prev_index = Cache last read() position >> PAGE_SHIFT determines the page size
2030  prev_offset = Cache last read() position & PAGE_SIZE - 1
2031  last_index = ppos + count + PAGE_SIZE - 1 >> PAGE_SHIFT determines the page size
2032  offset = ppos & ~PAGE_MASK
2034  cycle
2040  cond_resched()
2041  find_page :
2043  error = -EINTR
2044  Go to out
2047  page = d_get_page - find and get a page reference*@mapping: the address_space to search*@offset: the page index* Looks up the page cache slot at @mapping & @offset. If there is a* page cache page, it is returned with an increased refcount.
2048  If Not page Then
2049  If ki_flags & IOCB_NOWAIT Then Go to would_block
2058  If PageReadahead(page) Then
2063  If Not PageUptodate(page) Then
2064  If ki_flags & IOCB_NOWAIT Then
2065  put_page(page)
2066  Go to would_block
2077  If PageUptodate(page) Then Go to page_ok
2096  page_ok :
2106  isize = NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they
2107  end_index = isize - 1 >> PAGE_SHIFT determines the page size
2109  put_page(page)
2110  Go to out
2114  nr = PAGE_SIZE
2115  If index == end_index Then
2116  nr = ( isize - 1 & ~PAGE_MASK) + 1
2117  If nr <= offset Then
2118  put_page(page)
2119  Go to out
2122  nr = nr - offset
2128  If Might pages of this file have been modified in userspace?* Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff* marks vma as VM_SHARED if it is shared, and the file was opened for* writing i Then flush_dcache_page(page)
2135  If prev_index != index || offset != prev_offset Then mark_page_accessed(page)
2137  prev_index = index
2144  ret = copy_page_to_iter(page, offset, nr, iter)
2145  offset += ret
2146  index += offset >> PAGE_SHIFT determines the page size
2147  offset &= ~PAGE_MASK
2148  prev_offset = offset
2150  put_page(page)
2151  written += ret
2152  If Not iov_iter_count(iter) Then Go to out
2154  If ret < nr Then
2155  error = -EFAULT
2156  Go to out
2158  Continue
2160  page_not_up_to_date :
2162  error = lock_page_killable is like lock_page but can be interrupted by fatal* signals. It returns 0 if it locked the page and -EINTR if it was* killed while waiting.
2163  If Value for the false possibility is greater at compile time(error) Then Go to readpage_error
2166  page_not_up_to_date_locked :
2170  put_page(page)
2171  Continue
2175  If PageUptodate(page) Then
2177  Go to page_ok
2180  readpage :
2186  ClearPageError(page)
2188  error = readpage(filp, page)
2191  If error == AOP_TRUNCATED_PAGE Then
2192  put_page(page)
2193  error = 0
2194  Go to find_page
2196  Go to readpage_error
2199  If Not PageUptodate(page) Then
2203  If Not PageUptodate(page) Then
2220  Go to page_ok
2222  readpage_error :
2224  put_page(page)
2225  Go to out
2227  no_cached_page :
2232  page = page_cache_alloc(mapping)
2233  If Not page Then
2234  error = -ENOMEM
2235  Go to out
2237  error = add_to_page_cache_lru(page, mapping, index, Restricts the given gfp_mask to what the mapping allows. )
2239  If error Then
2240  put_page(page)
2241  If error == -EEXIST Then
2242  error = 0
2243  Go to find_page
2245  Go to out
2247  Go to readpage
2250  would_block :
2251  error = -EAGAIN
2252  out :
2253  Cache last read() position = prev_index
2254  Cache last read() position <<= PAGE_SHIFT determines the page size
2255  Cache last read() position |= prev_offset
2257  ppos = (index << PAGE_SHIFT determines the page size ) + offset
2258  file_accessed(filp)
2259  Return If written Then written Else error
Caller
NameDescribe
generic_file_read_itergeneric_file_read_iter - generic filesystem read routine*@iocb: kernel I/O control block*@iter: destination for the data read* This is the "read_iter()" routine for all filesystems* that can use the page cache directly