Lines Matching refs:fl
138 #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) argument
139 #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) argument
140 #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) argument
141 #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) argument
143 static bool lease_breaking(struct file_lock *fl) in lease_breaking() argument
145 return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); in lease_breaking()
148 static int target_leasetype(struct file_lock *fl) in target_leasetype() argument
150 if (fl->fl_flags & FL_UNLOCK_PENDING) in target_leasetype()
152 if (fl->fl_flags & FL_DOWNGRADE_PENDING) in target_leasetype()
154 return fl->fl_type; in target_leasetype()
247 static void locks_init_lock_heads(struct file_lock *fl) in locks_init_lock_heads() argument
249 INIT_HLIST_NODE(&fl->fl_link); in locks_init_lock_heads()
250 INIT_LIST_HEAD(&fl->fl_list); in locks_init_lock_heads()
251 INIT_LIST_HEAD(&fl->fl_block); in locks_init_lock_heads()
252 init_waitqueue_head(&fl->fl_wait); in locks_init_lock_heads()
258 struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL); in locks_alloc_lock() local
260 if (fl) in locks_alloc_lock()
261 locks_init_lock_heads(fl); in locks_alloc_lock()
263 return fl; in locks_alloc_lock()
267 void locks_release_private(struct file_lock *fl) in locks_release_private() argument
269 if (fl->fl_ops) { in locks_release_private()
270 if (fl->fl_ops->fl_release_private) in locks_release_private()
271 fl->fl_ops->fl_release_private(fl); in locks_release_private()
272 fl->fl_ops = NULL; in locks_release_private()
275 if (fl->fl_lmops) { in locks_release_private()
276 if (fl->fl_lmops->lm_put_owner) { in locks_release_private()
277 fl->fl_lmops->lm_put_owner(fl->fl_owner); in locks_release_private()
278 fl->fl_owner = NULL; in locks_release_private()
280 fl->fl_lmops = NULL; in locks_release_private()
286 void locks_free_lock(struct file_lock *fl) in locks_free_lock() argument
288 BUG_ON(waitqueue_active(&fl->fl_wait)); in locks_free_lock()
289 BUG_ON(!list_empty(&fl->fl_list)); in locks_free_lock()
290 BUG_ON(!list_empty(&fl->fl_block)); in locks_free_lock()
291 BUG_ON(!hlist_unhashed(&fl->fl_link)); in locks_free_lock()
293 locks_release_private(fl); in locks_free_lock()
294 kmem_cache_free(filelock_cache, fl); in locks_free_lock()
301 struct file_lock *fl; in locks_dispose_list() local
304 fl = list_first_entry(dispose, struct file_lock, fl_list); in locks_dispose_list()
305 list_del_init(&fl->fl_list); in locks_dispose_list()
306 locks_free_lock(fl); in locks_dispose_list()
310 void locks_init_lock(struct file_lock *fl) in locks_init_lock() argument
312 memset(fl, 0, sizeof(struct file_lock)); in locks_init_lock()
313 locks_init_lock_heads(fl); in locks_init_lock()
321 void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) in locks_copy_conflock() argument
323 new->fl_owner = fl->fl_owner; in locks_copy_conflock()
324 new->fl_pid = fl->fl_pid; in locks_copy_conflock()
326 new->fl_flags = fl->fl_flags; in locks_copy_conflock()
327 new->fl_type = fl->fl_type; in locks_copy_conflock()
328 new->fl_start = fl->fl_start; in locks_copy_conflock()
329 new->fl_end = fl->fl_end; in locks_copy_conflock()
330 new->fl_lmops = fl->fl_lmops; in locks_copy_conflock()
333 if (fl->fl_lmops) { in locks_copy_conflock()
334 if (fl->fl_lmops->lm_get_owner) in locks_copy_conflock()
335 fl->fl_lmops->lm_get_owner(fl->fl_owner); in locks_copy_conflock()
340 void locks_copy_lock(struct file_lock *new, struct file_lock *fl) in locks_copy_lock() argument
345 locks_copy_conflock(new, fl); in locks_copy_lock()
347 new->fl_file = fl->fl_file; in locks_copy_lock()
348 new->fl_ops = fl->fl_ops; in locks_copy_lock()
350 if (fl->fl_ops) { in locks_copy_lock()
351 if (fl->fl_ops->fl_copy_lock) in locks_copy_lock()
352 fl->fl_ops->fl_copy_lock(new, fl); in locks_copy_lock()
376 struct file_lock *fl; in flock_make_lock() local
382 fl = locks_alloc_lock(); in flock_make_lock()
383 if (fl == NULL) in flock_make_lock()
386 fl->fl_file = filp; in flock_make_lock()
387 fl->fl_owner = filp; in flock_make_lock()
388 fl->fl_pid = current->tgid; in flock_make_lock()
389 fl->fl_flags = FL_FLOCK; in flock_make_lock()
390 fl->fl_type = type; in flock_make_lock()
391 fl->fl_end = OFFSET_MAX; in flock_make_lock()
393 return fl; in flock_make_lock()
396 static int assign_type(struct file_lock *fl, long type) in assign_type() argument
402 fl->fl_type = type; in assign_type()
410 static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, in flock64_to_posix_lock() argument
415 fl->fl_start = 0; in flock64_to_posix_lock()
418 fl->fl_start = filp->f_pos; in flock64_to_posix_lock()
421 fl->fl_start = i_size_read(file_inode(filp)); in flock64_to_posix_lock()
426 if (l->l_start > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
428 fl->fl_start += l->l_start; in flock64_to_posix_lock()
429 if (fl->fl_start < 0) in flock64_to_posix_lock()
435 if (l->l_len - 1 > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
437 fl->fl_end = fl->fl_start + l->l_len - 1; in flock64_to_posix_lock()
440 if (fl->fl_start + l->l_len < 0) in flock64_to_posix_lock()
442 fl->fl_end = fl->fl_start - 1; in flock64_to_posix_lock()
443 fl->fl_start += l->l_len; in flock64_to_posix_lock()
445 fl->fl_end = OFFSET_MAX; in flock64_to_posix_lock()
447 fl->fl_owner = current->files; in flock64_to_posix_lock()
448 fl->fl_pid = current->tgid; in flock64_to_posix_lock()
449 fl->fl_file = filp; in flock64_to_posix_lock()
450 fl->fl_flags = FL_POSIX; in flock64_to_posix_lock()
451 fl->fl_ops = NULL; in flock64_to_posix_lock()
452 fl->fl_lmops = NULL; in flock64_to_posix_lock()
454 return assign_type(fl, l->l_type); in flock64_to_posix_lock()
460 static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, in flock_to_posix_lock() argument
470 return flock64_to_posix_lock(filp, fl, &ll); in flock_to_posix_lock()
475 lease_break_callback(struct file_lock *fl) in lease_break_callback() argument
477 kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG); in lease_break_callback()
482 lease_setup(struct file_lock *fl, void **priv) in lease_setup() argument
484 struct file *filp = fl->fl_file; in lease_setup()
492 if (!fasync_insert_entry(fa->fa_fd, filp, &fl->fl_fasync, fa)) in lease_setup()
507 static int lease_init(struct file *filp, long type, struct file_lock *fl) in lease_init() argument
509 if (assign_type(fl, type) != 0) in lease_init()
512 fl->fl_owner = filp; in lease_init()
513 fl->fl_pid = current->tgid; in lease_init()
515 fl->fl_file = filp; in lease_init()
516 fl->fl_flags = FL_LEASE; in lease_init()
517 fl->fl_start = 0; in lease_init()
518 fl->fl_end = OFFSET_MAX; in lease_init()
519 fl->fl_ops = NULL; in lease_init()
520 fl->fl_lmops = &lease_manager_ops; in lease_init()
527 struct file_lock *fl = locks_alloc_lock(); in lease_alloc() local
530 if (fl == NULL) in lease_alloc()
533 error = lease_init(filp, type, fl); in lease_alloc()
535 locks_free_lock(fl); in lease_alloc()
538 return fl; in lease_alloc()
561 static void locks_insert_global_locks(struct file_lock *fl) in locks_insert_global_locks() argument
564 fl->fl_link_cpu = smp_processor_id(); in locks_insert_global_locks()
565 hlist_add_head(&fl->fl_link, this_cpu_ptr(&file_lock_list)); in locks_insert_global_locks()
570 static void locks_delete_global_locks(struct file_lock *fl) in locks_delete_global_locks() argument
577 if (hlist_unhashed(&fl->fl_link)) in locks_delete_global_locks()
579 lg_local_lock_cpu(&file_lock_lglock, fl->fl_link_cpu); in locks_delete_global_locks()
580 hlist_del_init(&fl->fl_link); in locks_delete_global_locks()
581 lg_local_unlock_cpu(&file_lock_lglock, fl->fl_link_cpu); in locks_delete_global_locks()
585 posix_owner_key(struct file_lock *fl) in posix_owner_key() argument
587 if (fl->fl_lmops && fl->fl_lmops->lm_owner_key) in posix_owner_key()
588 return fl->fl_lmops->lm_owner_key(fl); in posix_owner_key()
589 return (unsigned long)fl->fl_owner; in posix_owner_key()
687 locks_insert_lock_ctx(struct file_lock *fl, struct list_head *before) in locks_insert_lock_ctx() argument
689 fl->fl_nspid = get_pid(task_tgid(current)); in locks_insert_lock_ctx()
690 list_add_tail(&fl->fl_list, before); in locks_insert_lock_ctx()
691 locks_insert_global_locks(fl); in locks_insert_lock_ctx()
695 locks_unlink_lock_ctx(struct file_lock *fl) in locks_unlink_lock_ctx() argument
697 locks_delete_global_locks(fl); in locks_unlink_lock_ctx()
698 list_del_init(&fl->fl_list); in locks_unlink_lock_ctx()
699 if (fl->fl_nspid) { in locks_unlink_lock_ctx()
700 put_pid(fl->fl_nspid); in locks_unlink_lock_ctx()
701 fl->fl_nspid = NULL; in locks_unlink_lock_ctx()
703 locks_wake_up_blocks(fl); in locks_unlink_lock_ctx()
707 locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) in locks_delete_lock_ctx() argument
709 locks_unlink_lock_ctx(fl); in locks_delete_lock_ctx()
711 list_add(&fl->fl_list, dispose); in locks_delete_lock_ctx()
713 locks_free_lock(fl); in locks_delete_lock_ctx()
763 posix_test_lock(struct file *filp, struct file_lock *fl) in posix_test_lock() argument
771 fl->fl_type = F_UNLCK; in posix_test_lock()
777 if (posix_locks_conflict(fl, cfl)) { in posix_test_lock()
778 locks_copy_conflock(fl, cfl); in posix_test_lock()
780 fl->fl_pid = pid_vnr(cfl->fl_nspid); in posix_test_lock()
784 fl->fl_type = F_UNLCK; in posix_test_lock()
829 struct file_lock *fl; in what_owner_is_waiting_for() local
831 hash_for_each_possible(blocked_hash, fl, fl_link, posix_owner_key(block_fl)) { in what_owner_is_waiting_for()
832 if (posix_same_owner(fl, block_fl)) in what_owner_is_waiting_for()
833 return fl->fl_next; in what_owner_is_waiting_for()
872 struct file_lock *fl; in flock_lock_inode() local
895 list_for_each_entry(fl, &ctx->flc_flock, fl_list) { in flock_lock_inode()
896 if (request->fl_file != fl->fl_file) in flock_lock_inode()
898 if (request->fl_type == fl->fl_type) in flock_lock_inode()
901 locks_delete_lock_ctx(fl, &dispose); in flock_lock_inode()
912 list_for_each_entry(fl, &ctx->flc_flock, fl_list) { in flock_lock_inode()
913 if (!flock_locks_conflict(request, fl)) in flock_lock_inode()
919 locks_insert_block(fl, request); in flock_lock_inode()
939 struct file_lock *fl, *tmp; in __posix_lock_file() local
973 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in __posix_lock_file()
974 if (!posix_locks_conflict(request, fl)) in __posix_lock_file()
977 locks_copy_conflock(conflock, fl); in __posix_lock_file()
987 if (likely(!posix_locks_deadlock(request, fl))) { in __posix_lock_file()
989 __locks_insert_block(fl, request); in __posix_lock_file()
1002 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in __posix_lock_file()
1003 if (posix_same_owner(request, fl)) in __posix_lock_file()
1008 list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_list) { in __posix_lock_file()
1009 if (!posix_same_owner(request, fl)) in __posix_lock_file()
1013 if (request->fl_type == fl->fl_type) { in __posix_lock_file()
1018 if (fl->fl_end < request->fl_start - 1) in __posix_lock_file()
1023 if (fl->fl_start - 1 > request->fl_end) in __posix_lock_file()
1031 if (fl->fl_start > request->fl_start) in __posix_lock_file()
1032 fl->fl_start = request->fl_start; in __posix_lock_file()
1034 request->fl_start = fl->fl_start; in __posix_lock_file()
1035 if (fl->fl_end < request->fl_end) in __posix_lock_file()
1036 fl->fl_end = request->fl_end; in __posix_lock_file()
1038 request->fl_end = fl->fl_end; in __posix_lock_file()
1040 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1043 request = fl; in __posix_lock_file()
1049 if (fl->fl_end < request->fl_start) in __posix_lock_file()
1051 if (fl->fl_start > request->fl_end) in __posix_lock_file()
1055 if (fl->fl_start < request->fl_start) in __posix_lock_file()
1056 left = fl; in __posix_lock_file()
1060 if (fl->fl_end > request->fl_end) { in __posix_lock_file()
1061 right = fl; in __posix_lock_file()
1064 if (fl->fl_start >= request->fl_start) { in __posix_lock_file()
1069 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1085 locks_insert_lock_ctx(request, &fl->fl_list); in __posix_lock_file()
1086 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1114 locks_insert_lock_ctx(new_fl, &fl->fl_list); in __posix_lock_file()
1115 fl = new_fl; in __posix_lock_file()
1126 locks_insert_lock_ctx(left, &fl->fl_list); in __posix_lock_file()
1162 int posix_lock_file(struct file *filp, struct file_lock *fl, in posix_lock_file() argument
1165 return __posix_lock_file(file_inode(filp), fl, conflock); in posix_lock_file()
1176 static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl) in posix_lock_inode_wait() argument
1181 error = __posix_lock_file(inode, fl, NULL); in posix_lock_inode_wait()
1184 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in posix_lock_inode_wait()
1188 locks_delete_block(fl); in posix_lock_inode_wait()
1206 struct file_lock *fl; in locks_mandatory_locked() local
1217 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in locks_mandatory_locked()
1218 if (fl->fl_owner != current->files && in locks_mandatory_locked()
1219 fl->fl_owner != file) { in locks_mandatory_locked()
1245 struct file_lock fl; in locks_mandatory_area() local
1249 locks_init_lock(&fl); in locks_mandatory_area()
1250 fl.fl_pid = current->tgid; in locks_mandatory_area()
1251 fl.fl_file = filp; in locks_mandatory_area()
1252 fl.fl_flags = FL_POSIX | FL_ACCESS; in locks_mandatory_area()
1255 fl.fl_type = (read_write == FLOCK_VERIFY_WRITE) ? F_WRLCK : F_RDLCK; in locks_mandatory_area()
1256 fl.fl_start = offset; in locks_mandatory_area()
1257 fl.fl_end = offset + count - 1; in locks_mandatory_area()
1261 fl.fl_owner = filp; in locks_mandatory_area()
1262 fl.fl_flags &= ~FL_SLEEP; in locks_mandatory_area()
1263 error = __posix_lock_file(inode, &fl, NULL); in locks_mandatory_area()
1269 fl.fl_flags |= FL_SLEEP; in locks_mandatory_area()
1270 fl.fl_owner = current->files; in locks_mandatory_area()
1271 error = __posix_lock_file(inode, &fl, NULL); in locks_mandatory_area()
1274 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next); in locks_mandatory_area()
1284 locks_delete_block(&fl); in locks_mandatory_area()
1293 static void lease_clear_pending(struct file_lock *fl, int arg) in lease_clear_pending() argument
1297 fl->fl_flags &= ~FL_UNLOCK_PENDING; in lease_clear_pending()
1300 fl->fl_flags &= ~FL_DOWNGRADE_PENDING; in lease_clear_pending()
1305 int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) in lease_modify() argument
1307 int error = assign_type(fl, arg); in lease_modify()
1311 lease_clear_pending(fl, arg); in lease_modify()
1312 locks_wake_up_blocks(fl); in lease_modify()
1314 struct file *filp = fl->fl_file; in lease_modify()
1318 fasync_helper(0, fl->fl_file, 0, &fl->fl_fasync); in lease_modify()
1319 if (fl->fl_fasync != NULL) { in lease_modify()
1320 printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync); in lease_modify()
1321 fl->fl_fasync = NULL; in lease_modify()
1323 locks_delete_lock_ctx(fl, dispose); in lease_modify()
1340 struct file_lock *fl, *tmp; in time_out_leases() local
1344 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { in time_out_leases()
1345 trace_time_out_leases(inode, fl); in time_out_leases()
1346 if (past_time(fl->fl_downgrade_time)) in time_out_leases()
1347 lease_modify(fl, F_RDLCK, dispose); in time_out_leases()
1348 if (past_time(fl->fl_break_time)) in time_out_leases()
1349 lease_modify(fl, F_UNLCK, dispose); in time_out_leases()
1366 struct file_lock *fl; in any_leases_conflict() local
1370 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in any_leases_conflict()
1371 if (leases_conflict(fl, breaker)) in any_leases_conflict()
1394 struct file_lock *new_fl, *fl, *tmp; in __break_lease() local
1425 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { in __break_lease()
1426 if (!leases_conflict(fl, new_fl)) in __break_lease()
1429 if (fl->fl_flags & FL_UNLOCK_PENDING) in __break_lease()
1431 fl->fl_flags |= FL_UNLOCK_PENDING; in __break_lease()
1432 fl->fl_break_time = break_time; in __break_lease()
1434 if (lease_breaking(fl)) in __break_lease()
1436 fl->fl_flags |= FL_DOWNGRADE_PENDING; in __break_lease()
1437 fl->fl_downgrade_time = break_time; in __break_lease()
1439 if (fl->fl_lmops->lm_break(fl)) in __break_lease()
1440 locks_delete_lock_ctx(fl, &dispose); in __break_lease()
1453 fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_list); in __break_lease()
1454 break_time = fl->fl_break_time; in __break_lease()
1459 locks_insert_block(fl, new_fl); in __break_lease()
1501 struct file_lock *fl; in lease_get_mtime() local
1507 fl = list_first_entry(&ctx->flc_lease, in lease_get_mtime()
1509 if (fl->fl_type == F_WRLCK) in lease_get_mtime()
1548 struct file_lock *fl; in fcntl_getlease() local
1558 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in fcntl_getlease()
1559 if (fl->fl_file != filp) in fcntl_getlease()
1561 type = target_leasetype(fl); in fcntl_getlease()
1603 struct file_lock *fl, *my_fl = NULL, *lease; in generic_add_lease() local
1652 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in generic_add_lease()
1653 if (fl->fl_file == filp && in generic_add_lease()
1654 fl->fl_owner == lease->fl_owner) { in generic_add_lease()
1655 my_fl = fl; in generic_add_lease()
1669 if (fl->fl_flags & FL_UNLOCK_PENDING) in generic_add_lease()
1718 struct file_lock *fl, *victim = NULL; in generic_delete_lease() local
1730 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in generic_delete_lease()
1731 if (fl->fl_file == filp && in generic_delete_lease()
1732 fl->fl_owner == owner) { in generic_delete_lease()
1733 victim = fl; in generic_delete_lease()
1739 error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose); in generic_delete_lease()
1816 struct file_lock *fl; in do_fcntl_add_lease() local
1820 fl = lease_alloc(filp, arg); in do_fcntl_add_lease()
1821 if (IS_ERR(fl)) in do_fcntl_add_lease()
1822 return PTR_ERR(fl); in do_fcntl_add_lease()
1826 locks_free_lock(fl); in do_fcntl_add_lease()
1831 error = vfs_setlease(filp, arg, &fl, (void **)&new); in do_fcntl_add_lease()
1832 if (fl) in do_fcntl_add_lease()
1833 locks_free_lock(fl); in do_fcntl_add_lease()
1863 static int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl) in flock_lock_inode_wait() argument
1868 error = flock_lock_inode(inode, fl); in flock_lock_inode_wait()
1871 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in flock_lock_inode_wait()
1875 locks_delete_block(fl); in flock_lock_inode_wait()
1888 int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl) in locks_lock_inode_wait() argument
1891 switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { in locks_lock_inode_wait()
1893 res = posix_lock_inode_wait(inode, fl); in locks_lock_inode_wait()
1896 res = flock_lock_inode_wait(inode, fl); in locks_lock_inode_wait()
1980 int vfs_test_lock(struct file *filp, struct file_lock *fl) in vfs_test_lock() argument
1983 return filp->f_op->lock(filp, F_GETLK, fl); in vfs_test_lock()
1984 posix_test_lock(filp, fl); in vfs_test_lock()
1989 static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) in posix_lock_to_flock() argument
1991 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; in posix_lock_to_flock()
1997 if (fl->fl_start > OFFT_OFFSET_MAX) in posix_lock_to_flock()
1999 if (fl->fl_end != OFFSET_MAX && fl->fl_end > OFFT_OFFSET_MAX) in posix_lock_to_flock()
2002 flock->l_start = fl->fl_start; in posix_lock_to_flock()
2003 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock()
2004 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock()
2006 flock->l_type = fl->fl_type; in posix_lock_to_flock()
2011 static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) in posix_lock_to_flock64() argument
2013 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; in posix_lock_to_flock64()
2014 flock->l_start = fl->fl_start; in posix_lock_to_flock64()
2015 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock64()
2016 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock64()
2018 flock->l_type = fl->fl_type; in posix_lock_to_flock64()
2104 int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) in vfs_lock_file() argument
2107 return filp->f_op->lock(filp, cmd, fl); in vfs_lock_file()
2109 return posix_lock_file(filp, fl, conf); in vfs_lock_file()
2114 struct file_lock *fl) in do_lock_file_wait() argument
2118 error = security_file_lock(filp, fl->fl_type); in do_lock_file_wait()
2123 error = vfs_lock_file(filp, cmd, fl, NULL); in do_lock_file_wait()
2126 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in do_lock_file_wait()
2130 locks_delete_block(fl); in do_lock_file_wait()
2139 check_fmode_for_setlk(struct file_lock *fl) in check_fmode_for_setlk() argument
2141 switch (fl->fl_type) { in check_fmode_for_setlk()
2143 if (!(fl->fl_file->f_mode & FMODE_READ)) in check_fmode_for_setlk()
2147 if (!(fl->fl_file->f_mode & FMODE_WRITE)) in check_fmode_for_setlk()
2431 struct file_lock fl = { in locks_remove_flock() local
2445 filp->f_op->flock(filp, F_SETLKW, &fl); in locks_remove_flock()
2447 flock_lock_inode(inode, &fl); in locks_remove_flock()
2449 if (fl.fl_ops && fl.fl_ops->fl_release_private) in locks_remove_flock()
2450 fl.fl_ops->fl_release_private(&fl); in locks_remove_flock()
2457 struct file_lock *fl, *tmp; in locks_remove_lease() local
2464 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) in locks_remove_lease()
2465 if (filp == fl->fl_file) in locks_remove_lease()
2466 lease_modify(fl, F_UNLCK, &dispose); in locks_remove_lease()
2520 int vfs_cancel_lock(struct file *filp, struct file_lock *fl) in vfs_cancel_lock() argument
2523 return filp->f_op->lock(filp, F_CANCELLK, fl); in vfs_cancel_lock()
2538 static void lock_get_status(struct seq_file *f, struct file_lock *fl, in lock_get_status() argument
2544 if (fl->fl_nspid) in lock_get_status()
2545 fl_pid = pid_vnr(fl->fl_nspid); in lock_get_status()
2547 fl_pid = fl->fl_pid; in lock_get_status()
2549 if (fl->fl_file != NULL) in lock_get_status()
2550 inode = file_inode(fl->fl_file); in lock_get_status()
2553 if (IS_POSIX(fl)) { in lock_get_status()
2554 if (fl->fl_flags & FL_ACCESS) in lock_get_status()
2556 else if (IS_OFDLCK(fl)) in lock_get_status()
2564 } else if (IS_FLOCK(fl)) { in lock_get_status()
2565 if (fl->fl_type & LOCK_MAND) { in lock_get_status()
2570 } else if (IS_LEASE(fl)) { in lock_get_status()
2571 if (fl->fl_flags & FL_DELEG) in lock_get_status()
2576 if (lease_breaking(fl)) in lock_get_status()
2578 else if (fl->fl_file) in lock_get_status()
2585 if (fl->fl_type & LOCK_MAND) { in lock_get_status()
2587 (fl->fl_type & LOCK_READ) in lock_get_status()
2588 ? (fl->fl_type & LOCK_WRITE) ? "RW " : "READ " in lock_get_status()
2589 : (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE "); in lock_get_status()
2592 (lease_breaking(fl)) in lock_get_status()
2593 ? (fl->fl_type == F_UNLCK) ? "UNLCK" : "READ " in lock_get_status()
2594 : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ "); in lock_get_status()
2604 if (IS_POSIX(fl)) { in lock_get_status()
2605 if (fl->fl_end == OFFSET_MAX) in lock_get_status()
2606 seq_printf(f, "%Ld EOF\n", fl->fl_start); in lock_get_status()
2608 seq_printf(f, "%Ld %Ld\n", fl->fl_start, fl->fl_end); in lock_get_status()
2617 struct file_lock *fl, *bfl; in locks_show() local
2619 fl = hlist_entry(v, struct file_lock, fl_link); in locks_show()
2621 lock_get_status(f, fl, iter->li_pos, ""); in locks_show()
2623 list_for_each_entry(bfl, &fl->fl_block, fl_block) in locks_show()
2633 struct file_lock *fl; in __show_fd_locks() local
2635 list_for_each_entry(fl, head, fl_list) { in __show_fd_locks()
2637 if (filp != fl->fl_file) in __show_fd_locks()
2639 if (fl->fl_owner != files && in __show_fd_locks()
2640 fl->fl_owner != filp) in __show_fd_locks()
2645 lock_get_status(f, fl, *id, ""); in __show_fd_locks()