函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\locks.c Create Date:2022-07-29 10:59:25
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Try to create a FLOCK lock on filp

函数原型:static int flock_lock_inode(struct inode *inode, struct file_lock *request)

返回类型:int

参数:

类型参数名称
struct inode *inode
struct file_lock *request
1038  struct file_lock * new_fl = NULL
1041  error等于0
1042  bool found = false
1043  LIST_HEAD(dispose)
1045  ctx等于locks_get_lock_context(inode, fl_type)
1046  如果非ctx
1047  如果fl_type不等于F_UNLCK则返回:负ENOMEM
1049  返回:如果fl_flags按位与when unlocking, test for existence 则负ENOENT否则0
1052  如果非fl_flags按位与 trying to lock, just looking 的值且fl_type不等于F_UNLCK
1053  new_fl等于Allocate an empty lock structure.
1054  如果非new_fl则返回:负ENOMEM
1058  percpu_down_read( & file_rwsem)
1059  加自旋锁
1060  如果fl_flags按位与 trying to lock, just looking 则转到:find_conflict
1064  如果fl_file不等于fl_file则继续下一循环
1066  如果fl_type恒等于fl_type则转到:out
1068  found = true
1069  locks_delete_lock_ctx(fl, & dispose)
1070  退出
1073  如果fl_type恒等于F_UNLCK
1074  如果fl_flags按位与when unlocking, test for existence 且非founderror等于负ENOENT
1076  转到:out
1079  find_conflict :
1081  如果非Determine if lock sys_fl blocks lock caller_fl. FLOCK specific* checking before calling the locks_conflict().则继续下一循环
1083  error等于负EAGAIN
1084  如果非fl_flags按位与A blocking lock 的值则转到:out
1086  error等于Special return value from posix_lock_file() and vfs_lock_file() for* asynchronous locking.
1087  Must be called with flc_lock held.
1088  转到:out
1090  如果fl_flags按位与 trying to lock, just looking 则转到:out
1092  locks_copy_lock(new_fl, request)
1093  locks_move_blocks(new_fl, request)
1094  locks_insert_lock_ctx(new_fl, & flc_flock)
1095  new_fl = NULL
1096  error等于0
1098  out :
1099  自旋锁解锁
1100  percpu_up_read( & file_rwsem)
1101  如果new_flFree a lock which is not in use.
1103  locks_dispose_list( & dispose)
1104  trace_flock_lock_inode(inode, request, error)
1105  返回:error
调用者
名称描述
flock_lock_inode_waitlock_lock_inode_wait - Apply a FLOCK-style lock to a file*@inode: inode of the file to apply to*@fl: The lock to be applied* Apply a FLOCK style lock request to an inode.
locks_remove_flockThe i_flctx must be valid when calling into here