Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:lemap_fault - read in file data for page fault handling*@vmf: struct vm_fault containing details of the fault* filemap_fault() is invoked via the vma operations vector for a* mapped memory region to read in file data during a page fault

Proto:vm_fault_t filemap_fault(struct vm_fault *vmf)

Type:vm_fault_t

Parameter:

TypeParameterName
struct vm_fault *vmf
2479  file = File we map to (can be NULL).
2480  struct file * fpin = NULL
2481  mapping = f_mapping
2482  ra = f_ra
2483  inode = host
2484  offset = Logical page offset based on vma
2487  ret = 0
2489  max_off = DIV_ROUND_UP(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 , PAGE_SIZE)
2490  If Value for the false possibility is greater at compile time(offset >= max_off) Then Return VM_FAULT_SIGBUS
2496  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.
2497  If Value is more likely to compile time(page) && Not (FAULT_FLAG_xxx flags & Second try ) Then
2502  fpin = Asynchronous readahead happens when we find the page and PG_readahead,* so we want to possibly extend the readahead further. We return the file that* was pinned if we have to drop the mmap_sem in order to do IO.
2503  Else if Not page Then
2505  Disable counters
2506  count_memcg_event_mm(The address space we belong to. , PGMAJFAULT)
2507  ret = VM_FAULT_MAJOR
2508  fpin = Synchronous readahead happens when we don't even find a page in the page* cache at all. We don't want to perform IO under the mmap sem, so if we have* to drop the mmap sem we return the file that was pinned in order for us to do* that
2509  retry_find :
2510  page = pagecache_get_page - find and get a page reference*@mapping: the address_space to search*@offset: the page index*@fgp_flags: PCG flags*@gfp_mask: gfp mask to use for the page cache data page allocation* Looks up the page cache slot at @mapping & @offset.
2513  If Not page Then
2514  If fpin Then Go to out_retry
2516  Return vmf_error( - ENOMEM)
2520  If Not lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_sem*@vmf - the vm_fault for this fault.*@page - the page to lock.*@fpin - the pointer to the file we may pin (or is already pinned). Then Go to out_retry
2524  If Value for the false possibility is greater at compile time( See page-flags.h for PAGE_MAPPING_FLAGS != mapping) Then
2525  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
2526  put_page(page)
2527  Go to retry_find
2529  VM_BUG_ON_PAGE(Get the offset in PAGE_SIZE.* (TODO: hugepage should have ->index in PAGE_SIZE) != offset, page)
2535  If Value for the false possibility is greater at compile time(!PageUptodate(page)) Then Go to page_not_uptodate
2543  If fpin Then
2544  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
2545  Go to out_retry
2552  max_off = DIV_ROUND_UP(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 , PAGE_SIZE)
2553  If Value for the false possibility is greater at compile time(offset >= max_off) Then
2554  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
2555  put_page(page)
2556  Return VM_FAULT_SIGBUS
2559  ->fault handlers should return a* page here, unless VM_FAULT_NOPAGE* is set (which is also implied by* VM_FAULT_ERROR). = page
2560  Return ret | VM_FAULT_LOCKED
2562  page_not_uptodate :
2569  ClearPageError(page)
2570  fpin = maybe_unlock_mmap_for_io(vmf, fpin)
2571  error = readpage(file, page)
2572  If Not error Then
2573  Wait for a page to be unlocked.* This must be called with the caller "holding" the page,* ie with increased "page->count" so that the page won't* go away during the wait..
2574  If Not PageUptodate(page) Then error = -EIO
2577  If fpin Then Go to out_retry
2579  put_page(page)
2581  If Not error || error == AOP_TRUNCATED_PAGE Then Go to retry_find
2585  CD/DVDs are error prone. When a medium error occurs, the driver may fail* a _large_ part of the i/o request. Imagine the worst scenario:* ---R__________________________________________B__________* ^ reading here ^ bad block(assume 4k)
2586  Return VM_FAULT_SIGBUS
2588  out_retry :
2594  If page Then put_page(page)
2596  If fpin Then fput(fpin)
2598  Return ret | VM_FAULT_RETRY