| Function report | 
| 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 activity | Download SCCT | Chinese | 
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:
| Type | Parameter | Name | 
|---|---|---|
| struct inode * | inode | |
| struct file_lock * | request | 
| 1041 | error = 0 | 
| 1042 | bool found = false | 
| 1045 | ctx = locks_get_lock_context(inode, fl_type) | 
| 1046 | If Not ctx Then | 
| 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 | 
| 1058 | percpu_down_read( & file_rwsem) | 
| 1060 | If fl_flags & trying to lock, just looking Then Go to find_conflict | 
| 1068 | found = true | 
| 1069 | locks_delete_lock_ctx(fl, & dispose) | 
| 1070 | Break | 
| 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 | 
| 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. | 
| 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 | 
| Name | Describe | 
|---|---|
| flock_lock_inode_wait | lock_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_flock | The i_flctx must be valid when calling into here | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |