Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:posix_lock_inode

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

Type:int

Parameter:

TypeParameterName
struct inode *inode
struct file_lock *request
struct file_lock *conflock
1112  struct file_lock * new_fl = NULL
1113  struct file_lock * new_fl2 = NULL
1114  struct file_lock * left = NULL
1115  struct file_lock * right = NULL
1118  bool added = false
1119  LIST_HEAD(dispose)
1121  ctx = locks_get_lock_context(inode, fl_type)
1122  If Not ctx Then Return If fl_type == F_UNLCK Then 0 Else -ENOMEM
1131  If Not (fl_flags & trying to lock, just looking ) && ( fl_type != F_UNLCK || fl_start != 0 || fl_end != OFFSET_MAX ) Then
1134  new_fl = Allocate an empty lock structure.
1135  new_fl2 = Allocate an empty lock structure.
1138  percpu_down_read( & file_rwsem)
1139  spin_lock( & flc_lock)
1145  If fl_type != F_UNLCK Then
1147  If Not Determine if lock sys_fl blocks lock caller_fl. POSIX specific* checking before calling the locks_conflict(). Then Continue
1149  If conflock Then Initialize a new lock from an existing file_lock structure.
1151  error = -EAGAIN
1152  If Not (fl_flags & A blocking lock ) Then Go to out
1158  error = -EDEADLK
1159  spin_lock( & This lock protects the blocked_hash. Generally, if you're accessing it, you* want to be holding this lock.* In addition, it also protects the fl->fl_blocked_requests list, and the* fl->fl_blocker pointer for file_lock structures that are acting as lock)
1164  __locks_wake_up_blocks(request)
1170  spin_unlock( & This lock protects the blocked_hash. Generally, if you're accessing it, you* want to be holding this lock.* In addition, it also protects the fl->fl_blocked_requests list, and the* fl->fl_blocker pointer for file_lock structures that are acting as lock)
1171  Go to out
1176  error = 0
1177  If fl_flags & trying to lock, just looking Then Go to out
1182  If Check whether two locks have the same owner. Then Break
1188  If Not Check whether two locks have the same owner. Then Break
1192  If fl_type == fl_type Then
1197  If fl_end < fl_start - 1 Then Continue
1202  If fl_start - 1 > fl_end Then Break
1210  If fl_start > fl_start Then fl_start = fl_start
1212  Else fl_start = fl_start
1214  If fl_end < fl_end Then fl_end = fl_end
1216  Else fl_end = fl_end
1218  If added Then
1220  Continue
1222  request = fl
1223  added = true
1224  Else
1228  If fl_end < fl_start Then Continue
1230  If fl_start > fl_end Then Break
1232  If fl_type == F_UNLCK Then added = true
1234  If fl_start < fl_start Then left = fl
1239  If fl_end > fl_end Then
1240  right = fl
1241  Break
1243  If fl_start >= fl_start Then
1247  If added Then
1249  Continue
1258  error = -ENOLCK
1259  If Not new_fl Then Go to out
1262  request = new_fl
1263  new_fl = NULL
1266  added = true
1276  error = -ENOLCK
1277  If right && left == right && Not new_fl2 Then Go to out
1280  error = 0
1281  If Not added Then
1282  If fl_type == F_UNLCK Then
1285  Go to out
1288  If Not new_fl Then
1289  error = -ENOLCK
1290  Go to out
1292  locks_copy_lock(new_fl, request)
1293  locks_move_blocks(new_fl, request)
1294  locks_insert_lock_ctx(new_fl, & link into file_lock_context )
1295  fl = new_fl
1296  new_fl = NULL
1298  If right Then
1299  If left == right Then
1303  left = new_fl2
1304  new_fl2 = NULL
1308  fl_start = fl_end + 1
1309  Wake up processes blocked waiting for blocker.* Must be called with the inode->flc_lock held!
1311  If left Then
1312  fl_end = fl_start - 1
1313  Wake up processes blocked waiting for blocker.* Must be called with the inode->flc_lock held!
1315  out :
1316  spin_unlock( & flc_lock)
1317  percpu_up_read( & file_rwsem)
1321  If new_fl Then Free a lock which is not in use.
1323  If new_fl2 Then Free a lock which is not in use.
1325  locks_dispose_list( & dispose)
1326  trace_posix_lock_inode(inode, request, error)
1328  Return error
Caller
NameDescribe
posix_lock_fileApply a POSIX-style lock to a file
posix_lock_inode_waitposix_lock_inode_wait - Apply a POSIX-style lock to a file*@inode: inode of file to which lock request should be applied*@fl: The lock to be applied* Apply a POSIX style lock request to an inode.