函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-27 16:50:04
Last Modify:2020-03-17 22:19:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:setup_swap_map_and_extents

函数原型: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)

返回类型:int

参数:

类型参数名称
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 i小于nr_badpages循环
3034  page_nr等于badpages[i]
3035  如果page_nr恒等于0或page_nr大于last_page则返回:负EINVAL
3037  如果page_nr小于maxpages
3039  nr_good_pages自减
3049 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)循环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  如果nr_good_pages
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  如果nr_extents小于0则返回:nr_extents
3064  nr_good_pages等于al of usable pages of swap
3066  如果非nr_good_pages
3067  打印警告信息("Empty swap-file\n")
3068  返回:负EINVAL
3071  如果非cluster_info则返回:nr_extents
3079 k小于SWAP_CLUSTER_COLS循环
3080  j等于kcol的和取模SWAP_CLUSTER_COLS
3082  idx等于iSWAP_CLUSTER_COLSj
3083  如果idx大于等于nr_clusters则继续下一循环
3085  如果cluster_count( & cluster_info[idx])则继续下一循环
3092  返回:nr_extents
调用者
名称描述
SYSCALL_DEFINE2