函数逻辑报告 |
Source Code:mm\swapfile.c |
Create Date:2022-07-27 16:50:24 |
Last Modify:2020-03-17 22:19:49 | Copyright©Brick |
首页 | 函数Tree |
注解内核,赢得工具 | 下载SCCT | English |
函数名称:SYSCALL_DEFINE2
函数原型:SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
返回类型:
参数:无
3121 | unsigned char * swap_map = NULL |
3122 | struct swap_cluster_info * cluster_info = NULL |
3123 | unsigned long * frontswap_map = NULL |
3126 | bool inced_nr_rotate_swap = false |
3128 | 如果swap_flags按位与SWAP_FLAGS_VALID的反则返回:负EINVAL |
3137 | p等于alloc_swap_info() |
3141 | INIT_WORK( & discard worker , swap_discard_work) |
3143 | name等于getname(specialfile) |
3144 | 如果是错误则 |
3149 | swap_file等于file_open_name(name, O_RDWR | O_LARGEFILE, 0) |
3150 | 如果是错误则 |
3156 | seldom referenced 等于swap_file |
3161 | error等于claim_swapfile(p, inode) |
3162 | 如果此条件成立可能性小(为编译器优化)(error)则转到:bad_swap |
3168 | 如果非readpage则 |
3172 | page等于read_mapping_page(mapping, 0, swap_file) |
3173 | 如果是错误则 |
3177 | swap_header等于kmap(page) |
3179 | maxpages等于read_swap_header(p, swap_header, inode) |
3180 | 如果此条件成立可能性小(为编译器优化)(!maxpages)则 |
3187 | 如果非swap_map则 |
3192 | 如果bdi_cap_stable_pages_required(inode_to_bdi(inode))则SWP_USED etc: see above 或等于SWP_STABLE_WRITES |
3210 | cluster_info等于kvcalloc(nr_cluster, cluster_info的长度, GFP_KERNEL) |
3212 | 如果非cluster_info则 |
3217 | 以ci小于nr_cluster循环spin_lock_init( & (Protect swap_cluster_info fields* and swap_info_struct->swap_map* elements correspond to the swap* cluster)) |
3220 | per cpu's swap location 等于alloc_percpu(structpercpu_cluster) |
3221 | 如果非per cpu's swap location 则 |
3227 | cluster等于per_cpu_ptr(per cpu's swap location , cpu) |
3228 | cluster_set_null( & Current cluster index ) |
3230 | 否则 |
3231 | atomic_inc( & nr_rotate_swap) |
3232 | inced_nr_rotate_swap = true |
3239 | nr_extents等于setup_swap_map_and_extents(p, swap_header, swap_map, cluster_info, maxpages, & span) |
3241 | 如果此条件成立可能性小(为编译器优化)(nr_extents < 0)则 |
3242 | error等于nr_extents |
3243 | 转到:bad_swap |
3246 | 如果IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_FRONTSWAP)则frontswap_map等于kvcalloc(BITS_TO_LONGS(maxpages), sizeof(long), GFP_KERNEL) |
3269 | 否则如果swap_flags按位与discard page-clusters after use 则SWP_USED etc: see above 与等于SWP_AREA_DISCARD的反 |
3273 | 如果SWP_USED etc: see above 按位与SWP_AREA_DISCARD则 |
3274 | err等于swapon tell device that all the old swap contents can be discarded,* to allow the swap device to optimize its wear-levelling. |
3275 | 如果此条件成立可能性小(为编译器优化)(err)则打印错误信息("swapon: discard_swap(%p): %d\n", p, err) |
3290 | error等于Flush file data before changing attributes. Caller must hold any locks* required to prevent further writes to this file until we're done setting* flags. |
3291 | 如果error则 |
3292 | i_flags与等于Do not truncate: swapon got its bmaps 的反 |
3293 | 转到:bad_swap |
3296 | mutex_lock( & swapon_mutex) |
3297 | prio等于负1 |
3298 | 如果swap_flags按位与set if swap priority specified 则prio等于swap_flags按位与SWAP_FLAG_PRIO_MASK的值右移SWAP_FLAG_PRIO_SHIFT位 |
3301 | enable_swap_info(p, prio, swap_map, cluster_info, frontswap_map) |
3303 | 打印信息("Adding %uk swap on %s. Priority:%d extents:%d across:%lluk %s%s%s%s%s\n", al of usable pages of swap << (PAGE_SHIFT determines the page size - 10), pointer to actual string , swap priority of this type , nr_extents, (unsignedlonglong)span << (PAGE_SHIFT determines the page size - 10), (SWP_USED etc: see above & SWP_SOLIDSTATE) ? "SS" : "", (SWP_USED etc: see above & SWP_DISCARDABLE) ? "D" : "", (SWP_USED etc: see above & SWP_AREA_DISCARD) ? "s" : "", (SWP_USED etc: see above & SWP_PAGE_DISCARD) ? "c" : "", (frontswap_map) ? "FS" : "") |
3314 | wake_up_interruptible( & proc_poll_wait) |
3316 | error等于0 |
3317 | 转到:out |
3318 | bad_swap : |
3319 | 释放内存 |
3320 | per cpu's swap location = NULL |
3321 | 如果inode且S_ISBLK(i_mode)且swap device or bdev of swap file 则 |
3327 | 加自旋锁 |
3328 | seldom referenced = NULL |
3329 | SWP_USED etc: see above 等于0 |
3330 | 自旋锁解锁 |
3334 | 如果inced_nr_rotate_swap则atomic_dec( & nr_rotate_swap) |
3336 | 如果swap_file则 |
3343 | out : |
3350 | 如果inode则inode_unlock(inode) |
3352 | 如果非error则enable_swap_slots_cache() |
3354 | 返回:error |
源代码转换工具 开放的插件接口 | X |
---|---|
支持:c/c++/esqlc/java Oracle/Informix/Mysql 插件可实现:逻辑报告 代码生成和批量转换代码 |