Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\locks.c Create Date:2022-07-28 20:25:28
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Try to create a FLOCK lock on filp

Proto:static int flock_lock_inode(struct inode *inode, struct file_lock *request)

Type:int

Parameter:

TypeParameterName
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  If Not ctx Then
1047  If fl_type != F_UNLCK Then Return -ENOMEM
1049  Return If fl_flags & when unlocking, test for existence Then -ENOENT Else 0
1052  If Not (fl_flags & trying to lock, just looking ) && fl_type != F_UNLCK Then
1053  new_fl = Allocate an empty lock structure.
1054  If Not new_fl Then Return -ENOMEM
1058  percpu_down_read( & file_rwsem)
1059  spin_lock( & flc_lock)
1060  If fl_flags & trying to lock, just looking Then Go to find_conflict
1064  If fl_file != fl_file Then Continue
1066  If fl_type == fl_type Then Go to out
1068  found = true
1069  locks_delete_lock_ctx(fl, & dispose)
1070  Break
1073  If fl_type == F_UNLCK Then
1074  If fl_flags & when unlocking, test for existence && Not found Then error = -ENOENT
1076  Go to out
1079  find_conflict :
1081  If Not Determine if lock sys_fl blocks lock caller_fl. FLOCK specific* checking before calling the locks_conflict(). Then Continue
1083  error = -EAGAIN
1084  If Not (fl_flags & A blocking lock ) Then Go to 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  Go to out
1090  If fl_flags & trying to lock, just looking Then Go to 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  spin_unlock( & flc_lock)
1100  percpu_up_read( & file_rwsem)
1101  If new_fl Then Free a lock which is not in use.
1103  locks_dispose_list( & dispose)
1104  trace_flock_lock_inode(inode, request, error)
1105  Return error
Caller
NameDescribe
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