Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:19:38
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:setup_swap_map_and_extents

Proto:static int setup_swap_map_and_extents(struct swap_info_struct *p, union swap_header *swap_header, unsigned char *swap_map, struct swap_cluster_info *cluster_info, unsigned long maxpages, sector_t *span)

Type:int

Parameter:

TypeParameterName
struct swap_info_struct *p
union swap_header *swap_header
unsigned char *swap_map
struct swap_cluster_info *cluster_info
unsigned longmaxpages
sector_t *span
3024  nr_clusters = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER)
3025  col = likely index for next allocation / SWAPFILE_CLUSTER % SWAP_CLUSTER_COLS
3028  nr_good_pages = maxpages - 1
3030  cluster_list_init( & clusters list )
3031  cluster_list_init( & discard clusters list )
3033  When i < nr_badpages cycle
3034  page_nr = badpages[i]
3035  If page_nr == 0 || page_nr > last_page Then Return -EINVAL
3037  If page_nr < maxpages Then
3039  nr_good_pages--
3049  When i < und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(maxpages, SWAPFILE_CLUSTER) cycle The cluster corresponding to page_nr will be used. The cluster will be* removed from free cluster list and its usage counter will be increased.
3052  If nr_good_pages Then
3053  swap_map[0] = Note pageblock is bad, in first swap_map
3058  The cluster corresponding to page_nr will be used. The cluster will be* removed from free cluster list and its usage counter will be increased.
3059  xtent of the swap_map = maxpages
3060  al of usable pages of swap = nr_good_pages
3061  nr_extents = A `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
3062  If nr_extents < 0 Then Return nr_extents
3064  nr_good_pages = al of usable pages of swap
3066  If Not nr_good_pages Then
3067  pr_warn("Empty swap-file\n")
3068  Return -EINVAL
3071  If Not cluster_info Then Return nr_extents
3079  When k < SWAP_CLUSTER_COLS cycle
3080  j = (k + col) % SWAP_CLUSTER_COLS
3082  idx = i * SWAP_CLUSTER_COLS + j
3083  If idx >= nr_clusters Then Continue
3085  If cluster_count( & cluster_info[idx]) Then Continue
3092  Return nr_extents
Caller
NameDescribe
SYSCALL_DEFINE2