函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:posix_lock_inode

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

返回类型:int

参数:

类型参数名称
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  如果非ctx则返回:如果fl_type恒等于F_UNLCK则0否则负ENOMEM
1131  如果非fl_flags按位与 trying to lock, just looking 的值且fl_type不等于F_UNLCKfl_start不等于0或fl_end不等于OFFSET_MAX的值则
1134  new_fl等于Allocate an empty lock structure.
1135  new_fl2等于Allocate an empty lock structure.
1138  percpu_down_read( & file_rwsem)
1139  加自旋锁
1145  如果fl_type不等于F_UNLCK
1147  如果非Determine if lock sys_fl blocks lock caller_fl. POSIX specific* checking before calling the locks_conflict().则继续下一循环
1149  如果conflockInitialize a new lock from an existing file_lock structure.
1151  error等于负EAGAIN
1152  如果非fl_flags按位与A blocking lock 的值则转到:out
1158  error等于负EDEADLK
1159  加自旋锁
1164  __locks_wake_up_blocks(request)
1170  自旋锁解锁
1171  转到:out
1176  error等于0
1177  如果fl_flags按位与 trying to lock, just looking 则转到:out
1182  如果Check whether two locks have the same owner.退出
1188  如果非Check whether two locks have the same owner.退出
1192  如果fl_type恒等于fl_type
1197  如果fl_end小于fl_start减1则继续下一循环
1202  如果fl_start减1大于fl_end退出
1210  如果fl_start大于fl_startfl_start等于fl_start
1212  否则fl_start等于fl_start
1214  如果fl_end小于fl_endfl_end等于fl_end
1216  否则fl_end等于fl_end
1218  如果added
1220  继续下一循环
1222  request等于fl
1223  added = true
1224  否则
1228  如果fl_end小于fl_start则继续下一循环
1230  如果fl_start大于fl_end退出
1232  如果fl_type恒等于F_UNLCKadded = true
1234  如果fl_start小于fl_startleft等于fl
1239  如果fl_end大于fl_end
1240  right等于fl
1241  退出
1243  如果fl_start大于等于fl_start
1247  如果added
1249  继续下一循环
1258  error等于负ENOLCK
1259  如果非new_fl则转到:out
1262  request等于new_fl
1263  new_fl = NULL
1266  added = true
1276  error等于负ENOLCK
1277  如果rightleft恒等于right且非new_fl2则转到:out
1280  error等于0
1281  如果非added
1282  如果fl_type恒等于F_UNLCK
1283  如果fl_flags按位与when unlocking, test for existence error等于负ENOENT
1285  转到:out
1288  如果非new_fl
1289  error等于负ENOLCK
1290  转到: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  如果right
1299  如果left恒等于right
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  如果left
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  自旋锁解锁
1317  percpu_up_read( & file_rwsem)
1321  如果new_flFree a lock which is not in use.
1323  如果new_fl2Free a lock which is not in use.
1325  locks_dispose_list( & dispose)
1326  trace_posix_lock_inode(inode, request, error)
1328  返回:error
调用者
名称描述
posix_lock_file文件加POSIX锁
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.