Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\ramfs\file-nommu.c Create Date:2022-07-28 20:35:07
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:add a contiguous set of pages into a ramfs inode when it's truncated from* size 0 on the assumption that it's going to be used for an mmap of shared* memory

Proto:int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)

Type:int

Parameter:

TypeParameterName
struct inode *inode
size_tnewsize
69  gfp = mapping_gfp_mask(i_mapping)
72  order = get_order - Determine the allocation order of a memory size*@size: The size for which to get the order* Determine the allocation order of a particular sized block of memory
73  If Value for the false possibility is greater at compile time(order >= Free memory management - zoned buddy allocator. ) Then Return -EFBIG
76  ret = de_newsize_ok - may this inode be truncated to a given size*@inode: the inode to be truncated*@offset: the new size to assign to the inode* inode_newsize_ok must be called with i_mutex held
77  If ret Then Return ret
80  NOTE: unlike i_size_read(), i_size_write() does need locking around it* (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount* can be lost, resulting in subsequent i_size_read() calls spinning forever.
84  pages = alloc_pages(gfp, order)
85  If Not pages Then Return -ENOMEM
89  xpages = 1UL << order
90  npages = newsize + PAGE_SIZE - 1 >> PAGE_SHIFT determines the page size
92  split_page takes a non-compound higher-order page, and splits it into* n (1<
95  When loop < xpages cycle __free_page(pages + loop)
99  newsize = PAGE_SIZE * npages
100  data = page_address(pages)
101  memset(data, 0, newsize)
104  When loop < npages cycle
105  page = pages + loop
107  ret = add_to_page_cache_lru(page, i_mapping, loop, gfp)
109  If ret < 0 Then Go to add_error
113  SetPageDirty(page)
114  SetPageUptodate(page)
116  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.
117  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
120  Return 0
122  add_error :
123  When loop < npages cycle
124  __free_page(pages + loop++)
125  Return ret
Caller
NameDescribe
ramfs_nommu_resize
__shmem_file_setupmmon code