Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Verify that a swap entry is valid and increment its swap map count.* Returns error code in following case.* - success -> 0* - swp_entry is invalid -> EINVAL* - swp_entry is migration entry -> EINVAL

Proto:static int __swap_duplicate(swp_entry_t entry, unsigned char usage)

Type:int

Parameter:

TypeParameterName
swp_entry_tentry
unsigned charusage
3392  err = -EINVAL
3394  p = Check whether swap entry is valid in the swap device
3395  If Not p Then Go to out
3398  offset = Extract the `offset' field from a swp_entry_t. The swp_entry_t is in* arch-independent format
3399  ci = Determine the locking method in use for this device. Return* swap_cluster_info if SSD-style cluster-based locking is in place.
3401  count = vmalloc'ed array of usage counts [offset]
3407  If Value for the false possibility is greater at compile time(swap_count(count) == Note pageblock is bad, in first swap_map ) Then
3408  err = -ENOENT
3409  Go to unlock_out
3412  has_cache = count & Flag page is cached, in first swap_map
3413  count &= ~Flag page is cached, in first swap_map
3414  err = 0
3416  If usage == Flag page is cached, in first swap_map Then
3419  If Not has_cache && count Then has_cache = Flag page is cached, in first swap_map
3421  Else if has_cache Then err = -EEXIST
3423  Else err = -ENOENT
3426  Else if count || has_cache Then
3428  If (count & ~See swap_map continuation for full count ) < Max duplication count, in first swap_map Then count += usage
3430  Else if (count & ~See swap_map continuation for full count ) > Max duplication count, in first swap_map Then err = -EINVAL
3432  Else if swap_count_continued - when the original swap_map count is incremented* from SWAP_MAP_MAX, check if there is already a continuation page to carry* into, carry if so, or else fail until a new continuation page is allocated;* when the original swap_map Then count = See swap_map continuation for full count
3434  Else err = -ENOMEM
3436  Else err = -ENOENT
3439  vmalloc'ed array of usage counts [offset] = count | has_cache
3441  unlock_out :
3442  unlock_cluster_or_swap_info(p, ci)
3443  out :
3444  If p Then put_swap_device(p)
3446  Return err
Caller
NameDescribe
swap_shmem_allocHelp swapoff by noting that swap entry belongs to shmem/tmpfs* (in which case its reference count is never incremented).
swap_duplicateIncrease reference count of swap entry by 1
swapcache_prepare@entry: swap entry for which we allocate swap cache.* Called when allocating swap cache for existing swap entry,* This can return error codes. Returns 0 at success.* -EBUSY means there is a swap cache.* Note: return code is different from swap_duplicate().