Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:generic_swapfile_activate

Proto:int generic_swapfile_activate(struct swap_info_struct *sis, struct file *swap_file, sector_t *span)

Type:int

Parameter:

TypeParameterName
struct swap_info_struct *sis
struct file *swap_file
sector_t *span
151  mapping = f_mapping
152  inode = host
158  lowest_block = -1
159  highest_block = 0
160  nr_extents = 0
163  blkbits = i_blkbits
164  blocks_per_page = PAGE_SIZE >> blkbits
170  probe_block = 0
171  page_no = 0
172  last_block = 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 >> blkbits
173  When probe_block + blocks_per_page <= last_block && page_no < xtent of the swap_map cycle
178  cond_resched()
180  first_block = find a block number in a file
181  If first_block == 0 Then Go to bad_bmap
187  If first_block & blocks_per_page - 1 Then
188  probe_block++
189  Go to reprobe
197  If block == 0 Then Go to bad_bmap
199  If block != first_block + block_in_page Then
201  probe_block++
202  Go to reprobe
206  first_block >>= PAGE_SHIFT determines the page size - blkbits
207  If page_no Then
217  ret = Add a block range (and the corresponding page range) into this swapdev's* extent tree.* This function rather assumes that it is called in ascending page order.
218  If ret < 0 Then Go to out
220  nr_extents += ret
221  page_no++
222  probe_block += blocks_per_page
223  reprobe :
224  Continue
226  ret = nr_extents
227  span = 1 + highest_block - lowest_block
228  If page_no == 0 Then page_no = 1
230  xtent of the swap_map = page_no
231  al of usable pages of swap = page_no - 1
232  dex of last free in swap_map = page_no - 1
233  out :
234  Return ret
235  bad_bmap :
236  pr_err("swapon: swapfile has holes\n")
237  ret = -EINVAL
238  Go to out
Caller
NameDescribe
setup_swap_extentsA `swap extent' is a simple thing which maps a contiguous range of pages* onto a contiguous range of disk blocks. An ordered list of swap extents* is built at swapon time and is then used at swap_writepage/swap_readpage