Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:read_swap_header

Proto:static unsigned long read_swap_header(struct swap_info_struct *p, union swap_header *swap_header, struct inode *inode)

Type:unsigned long

Parameter:

TypeParameterName
struct swap_info_struct *p
union swap_header *swap_header
struct inode *inode
2947  If memcmp("SWAPSPACE2", magic, 10) Then
2948  pr_err("Unable to find swap-space signature\n")
2949  Return 0
2953  If swab32(version) == 1 Then
2954  swab32s( & version)
2955  swab32s( & last_page)
2956  swab32s( & nr_badpages)
2957  If nr_badpages > Max bad pages in the new format.. Then Return 0
2959  When i < nr_badpages cycle swab32s( & badpages[i])
2963  If version != 1 Then
2964  pr_warn("Unable to handle swap header version %d\n", version)
2966  Return 0
2969  dex of first free in swap_map = 1
2970  likely index for next allocation = 1
2971  countdown to next cluster search = 0
2973  maxpages = Can be overridden by an architecture for additional checks.
2974  last_page = last_page
2975  If Not last_page Then
2976  pr_warn("Empty swap-file\n")
2977  Return 0
2979  If last_page > maxpages Then
2980  pr_warn("Truncating oversized swap area, only using %luk out of %luk\n", maxpages << (PAGE_SHIFT determines the page size - 10), last_page << (PAGE_SHIFT determines the page size - 10))
2984  If maxpages > last_page Then
2985  maxpages = last_page + 1
2987  If maxpages == 0 Then maxpages = UINT_MAX
2990  dex of last free in swap_map = maxpages - 1
2992  If Not maxpages Then Return 0
2994  swapfilepages = 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_SHIFT determines the page size
2995  If swapfilepages && maxpages > swapfilepages Then
2996  pr_warn("Swap area shorter than signature indicates\n")
2997  Return 0
2999  If nr_badpages && S_ISREG(i_mode) Then Return 0
3001  If nr_badpages > Max bad pages in the new format.. Then Return 0
3004  Return maxpages
Caller
NameDescribe
SYSCALL_DEFINE2