函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称: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

函数原型:static int __swap_duplicate(swp_entry_t entry, unsigned char usage)

返回类型:int

参数:

类型参数名称
swp_entry_tentry
unsigned charusage
3392  err等于负EINVAL
3394  p等于Check whether swap entry is valid in the swap device
3395  如果非p则转到: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  如果此条件成立可能性小(为编译器优化)(swap_count(count) == Note pageblock is bad, in first swap_map )则
3408  err等于负ENOENT
3409  转到: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  如果usage恒等于Flag page is cached, in first swap_map
3419  如果非has_cachecounthas_cache等于Flag page is cached, in first swap_map
3421  否则如果has_cacheerr等于负EEXIST
3423  否则err等于负ENOENT
3426  否则如果counthas_cache
3428  如果count按位与See swap_map continuation for full count 的反的值小于Max duplication count, in first swap_map count加等于usage
3430  否则如果count按位与See swap_map continuation for full count 的反的值大于Max duplication count, in first swap_map err等于负EINVAL
3432  否则如果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 count等于See swap_map continuation for full count
3434  否则err等于负ENOMEM
3436  否则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  如果pput_swap_device(p)
3446  返回:err
调用者
名称描述
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().