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()
243 static void locks_init_lock_heads(struct file_lock *fl) in locks_init_lock_heads() argument
245 INIT_HLIST_NODE(&fl->fl_link); in locks_init_lock_heads()
246 INIT_LIST_HEAD(&fl->fl_list); in locks_init_lock_heads()
247 INIT_LIST_HEAD(&fl->fl_block); in locks_init_lock_heads()
248 init_waitqueue_head(&fl->fl_wait); in locks_init_lock_heads()
254 struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL); in locks_alloc_lock() local
256 if (fl) in locks_alloc_lock()
257 locks_init_lock_heads(fl); in locks_alloc_lock()
259 return fl; in locks_alloc_lock()
263 void locks_release_private(struct file_lock *fl) in locks_release_private() argument
265 if (fl->fl_ops) { in locks_release_private()
266 if (fl->fl_ops->fl_release_private) in locks_release_private()
267 fl->fl_ops->fl_release_private(fl); in locks_release_private()
268 fl->fl_ops = NULL; in locks_release_private()
271 if (fl->fl_lmops) { in locks_release_private()
272 if (fl->fl_lmops->lm_put_owner) { in locks_release_private()
273 fl->fl_lmops->lm_put_owner(fl->fl_owner); in locks_release_private()
274 fl->fl_owner = NULL; in locks_release_private()
276 fl->fl_lmops = NULL; in locks_release_private()
282 void locks_free_lock(struct file_lock *fl) in locks_free_lock() argument
284 BUG_ON(waitqueue_active(&fl->fl_wait)); in locks_free_lock()
285 BUG_ON(!list_empty(&fl->fl_list)); in locks_free_lock()
286 BUG_ON(!list_empty(&fl->fl_block)); in locks_free_lock()
287 BUG_ON(!hlist_unhashed(&fl->fl_link)); in locks_free_lock()
289 locks_release_private(fl); in locks_free_lock()
290 kmem_cache_free(filelock_cache, fl); in locks_free_lock()
297 struct file_lock *fl; in locks_dispose_list() local
300 fl = list_first_entry(dispose, struct file_lock, fl_list); in locks_dispose_list()
301 list_del_init(&fl->fl_list); in locks_dispose_list()
302 locks_free_lock(fl); in locks_dispose_list()
306 void locks_init_lock(struct file_lock *fl) in locks_init_lock() argument
308 memset(fl, 0, sizeof(struct file_lock)); in locks_init_lock()
309 locks_init_lock_heads(fl); in locks_init_lock()
317 void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) in locks_copy_conflock() argument
319 new->fl_owner = fl->fl_owner; in locks_copy_conflock()
320 new->fl_pid = fl->fl_pid; in locks_copy_conflock()
322 new->fl_flags = fl->fl_flags; in locks_copy_conflock()
323 new->fl_type = fl->fl_type; in locks_copy_conflock()
324 new->fl_start = fl->fl_start; in locks_copy_conflock()
325 new->fl_end = fl->fl_end; in locks_copy_conflock()
326 new->fl_lmops = fl->fl_lmops; in locks_copy_conflock()
329 if (fl->fl_lmops) { in locks_copy_conflock()
330 if (fl->fl_lmops->lm_get_owner) in locks_copy_conflock()
331 fl->fl_lmops->lm_get_owner(fl->fl_owner); in locks_copy_conflock()
336 void locks_copy_lock(struct file_lock *new, struct file_lock *fl) in locks_copy_lock() argument
341 locks_copy_conflock(new, fl); in locks_copy_lock()
343 new->fl_file = fl->fl_file; in locks_copy_lock()
344 new->fl_ops = fl->fl_ops; in locks_copy_lock()
346 if (fl->fl_ops) { in locks_copy_lock()
347 if (fl->fl_ops->fl_copy_lock) in locks_copy_lock()
348 fl->fl_ops->fl_copy_lock(new, fl); in locks_copy_lock()
372 struct file_lock *fl; in flock_make_lock() local
378 fl = locks_alloc_lock(); in flock_make_lock()
379 if (fl == NULL) in flock_make_lock()
382 fl->fl_file = filp; in flock_make_lock()
383 fl->fl_owner = filp; in flock_make_lock()
384 fl->fl_pid = current->tgid; in flock_make_lock()
385 fl->fl_flags = FL_FLOCK; in flock_make_lock()
386 fl->fl_type = type; in flock_make_lock()
387 fl->fl_end = OFFSET_MAX; in flock_make_lock()
389 return fl; in flock_make_lock()
392 static int assign_type(struct file_lock *fl, long type) in assign_type() argument
398 fl->fl_type = type; in assign_type()
406 static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, in flock64_to_posix_lock() argument
411 fl->fl_start = 0; in flock64_to_posix_lock()
414 fl->fl_start = filp->f_pos; in flock64_to_posix_lock()
417 fl->fl_start = i_size_read(file_inode(filp)); in flock64_to_posix_lock()
422 if (l->l_start > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
424 fl->fl_start += l->l_start; in flock64_to_posix_lock()
425 if (fl->fl_start < 0) in flock64_to_posix_lock()
431 if (l->l_len - 1 > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
433 fl->fl_end = fl->fl_start + l->l_len - 1; in flock64_to_posix_lock()
436 if (fl->fl_start + l->l_len < 0) in flock64_to_posix_lock()
438 fl->fl_end = fl->fl_start - 1; in flock64_to_posix_lock()
439 fl->fl_start += l->l_len; in flock64_to_posix_lock()
441 fl->fl_end = OFFSET_MAX; in flock64_to_posix_lock()
443 fl->fl_owner = current->files; in flock64_to_posix_lock()
444 fl->fl_pid = current->tgid; in flock64_to_posix_lock()
445 fl->fl_file = filp; in flock64_to_posix_lock()
446 fl->fl_flags = FL_POSIX; in flock64_to_posix_lock()
447 fl->fl_ops = NULL; in flock64_to_posix_lock()
448 fl->fl_lmops = NULL; in flock64_to_posix_lock()
450 return assign_type(fl, l->l_type); in flock64_to_posix_lock()
456 static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, in flock_to_posix_lock() argument
466 return flock64_to_posix_lock(filp, fl, &ll); in flock_to_posix_lock()
471 lease_break_callback(struct file_lock *fl) in lease_break_callback() argument
473 kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG); in lease_break_callback()
478 lease_setup(struct file_lock *fl, void **priv) in lease_setup() argument
480 struct file *filp = fl->fl_file; in lease_setup()
488 if (!fasync_insert_entry(fa->fa_fd, filp, &fl->fl_fasync, fa)) in lease_setup()
503 static int lease_init(struct file *filp, long type, struct file_lock *fl) in lease_init() argument
505 if (assign_type(fl, type) != 0) in lease_init()
508 fl->fl_owner = filp; in lease_init()
509 fl->fl_pid = current->tgid; in lease_init()
511 fl->fl_file = filp; in lease_init()
512 fl->fl_flags = FL_LEASE; in lease_init()
513 fl->fl_start = 0; in lease_init()
514 fl->fl_end = OFFSET_MAX; in lease_init()
515 fl->fl_ops = NULL; in lease_init()
516 fl->fl_lmops = &lease_manager_ops; in lease_init()
523 struct file_lock *fl = locks_alloc_lock(); in lease_alloc() local
526 if (fl == NULL) in lease_alloc()
529 error = lease_init(filp, type, fl); in lease_alloc()
531 locks_free_lock(fl); in lease_alloc()
534 return fl; in lease_alloc()
557 static void locks_insert_global_locks(struct file_lock *fl) in locks_insert_global_locks() argument
560 fl->fl_link_cpu = smp_processor_id(); in locks_insert_global_locks()
561 hlist_add_head(&fl->fl_link, this_cpu_ptr(&file_lock_list)); in locks_insert_global_locks()
566 static void locks_delete_global_locks(struct file_lock *fl) in locks_delete_global_locks() argument
573 if (hlist_unhashed(&fl->fl_link)) in locks_delete_global_locks()
575 lg_local_lock_cpu(&file_lock_lglock, fl->fl_link_cpu); in locks_delete_global_locks()
576 hlist_del_init(&fl->fl_link); in locks_delete_global_locks()
577 lg_local_unlock_cpu(&file_lock_lglock, fl->fl_link_cpu); in locks_delete_global_locks()
581 posix_owner_key(struct file_lock *fl) in posix_owner_key() argument
583 if (fl->fl_lmops && fl->fl_lmops->lm_owner_key) in posix_owner_key()
584 return fl->fl_lmops->lm_owner_key(fl); in posix_owner_key()
585 return (unsigned long)fl->fl_owner; in posix_owner_key()
683 locks_insert_lock_ctx(struct file_lock *fl, struct list_head *before) in locks_insert_lock_ctx() argument
685 fl->fl_nspid = get_pid(task_tgid(current)); in locks_insert_lock_ctx()
686 list_add_tail(&fl->fl_list, before); in locks_insert_lock_ctx()
687 locks_insert_global_locks(fl); in locks_insert_lock_ctx()
691 locks_unlink_lock_ctx(struct file_lock *fl) in locks_unlink_lock_ctx() argument
693 locks_delete_global_locks(fl); in locks_unlink_lock_ctx()
694 list_del_init(&fl->fl_list); in locks_unlink_lock_ctx()
695 if (fl->fl_nspid) { in locks_unlink_lock_ctx()
696 put_pid(fl->fl_nspid); in locks_unlink_lock_ctx()
697 fl->fl_nspid = NULL; in locks_unlink_lock_ctx()
699 locks_wake_up_blocks(fl); in locks_unlink_lock_ctx()
703 locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) in locks_delete_lock_ctx() argument
705 locks_unlink_lock_ctx(fl); in locks_delete_lock_ctx()
707 list_add(&fl->fl_list, dispose); in locks_delete_lock_ctx()
709 locks_free_lock(fl); in locks_delete_lock_ctx()
759 posix_test_lock(struct file *filp, struct file_lock *fl) in posix_test_lock() argument
767 fl->fl_type = F_UNLCK; in posix_test_lock()
773 if (posix_locks_conflict(fl, cfl)) { in posix_test_lock()
774 locks_copy_conflock(fl, cfl); in posix_test_lock()
776 fl->fl_pid = pid_vnr(cfl->fl_nspid); in posix_test_lock()
780 fl->fl_type = F_UNLCK; in posix_test_lock()
825 struct file_lock *fl; in what_owner_is_waiting_for() local
827 hash_for_each_possible(blocked_hash, fl, fl_link, posix_owner_key(block_fl)) { in what_owner_is_waiting_for()
828 if (posix_same_owner(fl, block_fl)) in what_owner_is_waiting_for()
829 return fl->fl_next; in what_owner_is_waiting_for()
868 struct file_lock *fl; in flock_lock_inode() local
891 list_for_each_entry(fl, &ctx->flc_flock, fl_list) { in flock_lock_inode()
892 if (request->fl_file != fl->fl_file) in flock_lock_inode()
894 if (request->fl_type == fl->fl_type) in flock_lock_inode()
897 locks_delete_lock_ctx(fl, &dispose); in flock_lock_inode()
908 list_for_each_entry(fl, &ctx->flc_flock, fl_list) { in flock_lock_inode()
909 if (!flock_locks_conflict(request, fl)) in flock_lock_inode()
915 locks_insert_block(fl, request); in flock_lock_inode()
935 struct file_lock *fl, *tmp; in __posix_lock_file() local
969 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in __posix_lock_file()
970 if (!posix_locks_conflict(request, fl)) in __posix_lock_file()
973 locks_copy_conflock(conflock, fl); in __posix_lock_file()
983 if (likely(!posix_locks_deadlock(request, fl))) { in __posix_lock_file()
985 __locks_insert_block(fl, request); in __posix_lock_file()
998 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in __posix_lock_file()
999 if (posix_same_owner(request, fl)) in __posix_lock_file()
1004 list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_list) { in __posix_lock_file()
1005 if (!posix_same_owner(request, fl)) in __posix_lock_file()
1009 if (request->fl_type == fl->fl_type) { in __posix_lock_file()
1014 if (fl->fl_end < request->fl_start - 1) in __posix_lock_file()
1019 if (fl->fl_start - 1 > request->fl_end) in __posix_lock_file()
1027 if (fl->fl_start > request->fl_start) in __posix_lock_file()
1028 fl->fl_start = request->fl_start; in __posix_lock_file()
1030 request->fl_start = fl->fl_start; in __posix_lock_file()
1031 if (fl->fl_end < request->fl_end) in __posix_lock_file()
1032 fl->fl_end = request->fl_end; in __posix_lock_file()
1034 request->fl_end = fl->fl_end; in __posix_lock_file()
1036 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1039 request = fl; in __posix_lock_file()
1045 if (fl->fl_end < request->fl_start) in __posix_lock_file()
1047 if (fl->fl_start > request->fl_end) in __posix_lock_file()
1051 if (fl->fl_start < request->fl_start) in __posix_lock_file()
1052 left = fl; in __posix_lock_file()
1056 if (fl->fl_end > request->fl_end) { in __posix_lock_file()
1057 right = fl; in __posix_lock_file()
1060 if (fl->fl_start >= request->fl_start) { in __posix_lock_file()
1065 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1081 locks_insert_lock_ctx(request, &fl->fl_list); in __posix_lock_file()
1082 locks_delete_lock_ctx(fl, &dispose); in __posix_lock_file()
1110 locks_insert_lock_ctx(new_fl, &fl->fl_list); in __posix_lock_file()
1111 fl = new_fl; in __posix_lock_file()
1122 locks_insert_lock_ctx(left, &fl->fl_list); in __posix_lock_file()
1158 int posix_lock_file(struct file *filp, struct file_lock *fl, in posix_lock_file() argument
1161 return __posix_lock_file(file_inode(filp), fl, conflock); in posix_lock_file()
1173 int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl) in posix_lock_inode_wait() argument
1178 error = __posix_lock_file(inode, fl, NULL); in posix_lock_inode_wait()
1181 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in posix_lock_inode_wait()
1185 locks_delete_block(fl); in posix_lock_inode_wait()
1204 struct file_lock *fl; in locks_mandatory_locked() local
1215 list_for_each_entry(fl, &ctx->flc_posix, fl_list) { in locks_mandatory_locked()
1216 if (fl->fl_owner != current->files && in locks_mandatory_locked()
1217 fl->fl_owner != file) { in locks_mandatory_locked()
1243 struct file_lock fl; in locks_mandatory_area() local
1247 locks_init_lock(&fl); in locks_mandatory_area()
1248 fl.fl_pid = current->tgid; in locks_mandatory_area()
1249 fl.fl_file = filp; in locks_mandatory_area()
1250 fl.fl_flags = FL_POSIX | FL_ACCESS; in locks_mandatory_area()
1253 fl.fl_type = (read_write == FLOCK_VERIFY_WRITE) ? F_WRLCK : F_RDLCK; in locks_mandatory_area()
1254 fl.fl_start = offset; in locks_mandatory_area()
1255 fl.fl_end = offset + count - 1; in locks_mandatory_area()
1259 fl.fl_owner = filp; in locks_mandatory_area()
1260 fl.fl_flags &= ~FL_SLEEP; in locks_mandatory_area()
1261 error = __posix_lock_file(inode, &fl, NULL); in locks_mandatory_area()
1267 fl.fl_flags |= FL_SLEEP; in locks_mandatory_area()
1268 fl.fl_owner = current->files; in locks_mandatory_area()
1269 error = __posix_lock_file(inode, &fl, NULL); in locks_mandatory_area()
1272 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next); in locks_mandatory_area()
1282 locks_delete_block(&fl); in locks_mandatory_area()
1291 static void lease_clear_pending(struct file_lock *fl, int arg) in lease_clear_pending() argument
1295 fl->fl_flags &= ~FL_UNLOCK_PENDING; in lease_clear_pending()
1298 fl->fl_flags &= ~FL_DOWNGRADE_PENDING; in lease_clear_pending()
1303 int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) in lease_modify() argument
1305 int error = assign_type(fl, arg); in lease_modify()
1309 lease_clear_pending(fl, arg); in lease_modify()
1310 locks_wake_up_blocks(fl); in lease_modify()
1312 struct file *filp = fl->fl_file; in lease_modify()
1316 fasync_helper(0, fl->fl_file, 0, &fl->fl_fasync); in lease_modify()
1317 if (fl->fl_fasync != NULL) { in lease_modify()
1318 printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync); in lease_modify()
1319 fl->fl_fasync = NULL; in lease_modify()
1321 locks_delete_lock_ctx(fl, dispose); in lease_modify()
1338 struct file_lock *fl, *tmp; in time_out_leases() local
1342 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { in time_out_leases()
1343 trace_time_out_leases(inode, fl); in time_out_leases()
1344 if (past_time(fl->fl_downgrade_time)) in time_out_leases()
1345 lease_modify(fl, F_RDLCK, dispose); in time_out_leases()
1346 if (past_time(fl->fl_break_time)) in time_out_leases()
1347 lease_modify(fl, F_UNLCK, dispose); in time_out_leases()
1364 struct file_lock *fl; in any_leases_conflict() local
1368 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in any_leases_conflict()
1369 if (leases_conflict(fl, breaker)) in any_leases_conflict()
1392 struct file_lock *new_fl, *fl, *tmp; in __break_lease() local
1422 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { in __break_lease()
1423 if (!leases_conflict(fl, new_fl)) in __break_lease()
1426 if (fl->fl_flags & FL_UNLOCK_PENDING) in __break_lease()
1428 fl->fl_flags |= FL_UNLOCK_PENDING; in __break_lease()
1429 fl->fl_break_time = break_time; in __break_lease()
1431 if (lease_breaking(fl)) in __break_lease()
1433 fl->fl_flags |= FL_DOWNGRADE_PENDING; in __break_lease()
1434 fl->fl_downgrade_time = break_time; in __break_lease()
1436 if (fl->fl_lmops->lm_break(fl)) in __break_lease()
1437 locks_delete_lock_ctx(fl, &dispose); in __break_lease()
1450 fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_list); in __break_lease()
1451 break_time = fl->fl_break_time; in __break_lease()
1456 locks_insert_block(fl, new_fl); in __break_lease()
1498 struct file_lock *fl; in lease_get_mtime() local
1503 fl = list_first_entry(&ctx->flc_lease, in lease_get_mtime()
1505 if (fl->fl_type == F_WRLCK) in lease_get_mtime()
1544 struct file_lock *fl; in fcntl_getlease() local
1553 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in fcntl_getlease()
1554 if (fl->fl_file != filp) in fcntl_getlease()
1556 type = target_leasetype(fl); in fcntl_getlease()
1597 struct file_lock *fl, *my_fl = NULL, *lease; in generic_add_lease() local
1646 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in generic_add_lease()
1647 if (fl->fl_file == filp && in generic_add_lease()
1648 fl->fl_owner == lease->fl_owner) { in generic_add_lease()
1649 my_fl = fl; in generic_add_lease()
1663 if (fl->fl_flags & FL_UNLOCK_PENDING) in generic_add_lease()
1712 struct file_lock *fl, *victim = NULL; in generic_delete_lease() local
1724 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { in generic_delete_lease()
1725 if (fl->fl_file == filp && in generic_delete_lease()
1726 fl->fl_owner == owner) { in generic_delete_lease()
1727 victim = fl; in generic_delete_lease()
1733 error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose); in generic_delete_lease()
1811 struct file_lock *fl; in do_fcntl_add_lease() local
1815 fl = lease_alloc(filp, arg); in do_fcntl_add_lease()
1816 if (IS_ERR(fl)) in do_fcntl_add_lease()
1817 return PTR_ERR(fl); in do_fcntl_add_lease()
1821 locks_free_lock(fl); in do_fcntl_add_lease()
1826 error = vfs_setlease(filp, arg, &fl, (void **)&new); in do_fcntl_add_lease()
1827 if (fl) in do_fcntl_add_lease()
1828 locks_free_lock(fl); in do_fcntl_add_lease()
1858 int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl) in flock_lock_inode_wait() argument
1863 error = flock_lock_inode(inode, fl); in flock_lock_inode_wait()
1866 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in flock_lock_inode_wait()
1870 locks_delete_block(fl); in flock_lock_inode_wait()
1952 int vfs_test_lock(struct file *filp, struct file_lock *fl) in vfs_test_lock() argument
1955 return filp->f_op->lock(filp, F_GETLK, fl); in vfs_test_lock()
1956 posix_test_lock(filp, fl); in vfs_test_lock()
1961 static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) in posix_lock_to_flock() argument
1963 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; in posix_lock_to_flock()
1969 if (fl->fl_start > OFFT_OFFSET_MAX) in posix_lock_to_flock()
1971 if (fl->fl_end != OFFSET_MAX && fl->fl_end > OFFT_OFFSET_MAX) in posix_lock_to_flock()
1974 flock->l_start = fl->fl_start; in posix_lock_to_flock()
1975 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock()
1976 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock()
1978 flock->l_type = fl->fl_type; in posix_lock_to_flock()
1983 static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) in posix_lock_to_flock64() argument
1985 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; in posix_lock_to_flock64()
1986 flock->l_start = fl->fl_start; in posix_lock_to_flock64()
1987 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock64()
1988 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock64()
1990 flock->l_type = fl->fl_type; in posix_lock_to_flock64()
2076 int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) in vfs_lock_file() argument
2079 return filp->f_op->lock(filp, cmd, fl); in vfs_lock_file()
2081 return posix_lock_file(filp, fl, conf); in vfs_lock_file()
2086 struct file_lock *fl) in do_lock_file_wait() argument
2090 error = security_file_lock(filp, fl->fl_type); in do_lock_file_wait()
2095 error = vfs_lock_file(filp, cmd, fl, NULL); in do_lock_file_wait()
2098 error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); in do_lock_file_wait()
2102 locks_delete_block(fl); in do_lock_file_wait()
2111 check_fmode_for_setlk(struct file_lock *fl) in check_fmode_for_setlk() argument
2113 switch (fl->fl_type) { in check_fmode_for_setlk()
2115 if (!(fl->fl_file->f_mode & FMODE_READ)) in check_fmode_for_setlk()
2119 if (!(fl->fl_file->f_mode & FMODE_WRITE)) in check_fmode_for_setlk()
2402 struct file_lock fl = { in locks_remove_flock() local
2417 filp->f_op->flock(filp, F_SETLKW, &fl); in locks_remove_flock()
2419 flock_lock_inode(inode, &fl); in locks_remove_flock()
2421 if (fl.fl_ops && fl.fl_ops->fl_release_private) in locks_remove_flock()
2422 fl.fl_ops->fl_release_private(&fl); in locks_remove_flock()
2431 struct file_lock *fl, *tmp; in locks_remove_lease() local
2438 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) in locks_remove_lease()
2439 if (filp == fl->fl_file) in locks_remove_lease()
2440 lease_modify(fl, F_UNLCK, &dispose); in locks_remove_lease()
2491 int vfs_cancel_lock(struct file *filp, struct file_lock *fl) in vfs_cancel_lock() argument
2494 return filp->f_op->lock(filp, F_CANCELLK, fl); in vfs_cancel_lock()
2509 static void lock_get_status(struct seq_file *f, struct file_lock *fl, in lock_get_status() argument
2515 if (fl->fl_nspid) in lock_get_status()
2516 fl_pid = pid_vnr(fl->fl_nspid); in lock_get_status()
2518 fl_pid = fl->fl_pid; in lock_get_status()
2520 if (fl->fl_file != NULL) in lock_get_status()
2521 inode = file_inode(fl->fl_file); in lock_get_status()
2524 if (IS_POSIX(fl)) { in lock_get_status()
2525 if (fl->fl_flags & FL_ACCESS) in lock_get_status()
2527 else if (IS_OFDLCK(fl)) in lock_get_status()
2535 } else if (IS_FLOCK(fl)) { in lock_get_status()
2536 if (fl->fl_type & LOCK_MAND) { in lock_get_status()
2541 } else if (IS_LEASE(fl)) { in lock_get_status()
2542 if (fl->fl_flags & FL_DELEG) in lock_get_status()
2547 if (lease_breaking(fl)) in lock_get_status()
2549 else if (fl->fl_file) in lock_get_status()
2556 if (fl->fl_type & LOCK_MAND) { in lock_get_status()
2558 (fl->fl_type & LOCK_READ) in lock_get_status()
2559 ? (fl->fl_type & LOCK_WRITE) ? "RW " : "READ " in lock_get_status()
2560 : (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE "); in lock_get_status()
2563 (lease_breaking(fl)) in lock_get_status()
2564 ? (fl->fl_type == F_UNLCK) ? "UNLCK" : "READ " in lock_get_status()
2565 : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ "); in lock_get_status()
2575 if (IS_POSIX(fl)) { in lock_get_status()
2576 if (fl->fl_end == OFFSET_MAX) in lock_get_status()
2577 seq_printf(f, "%Ld EOF\n", fl->fl_start); in lock_get_status()
2579 seq_printf(f, "%Ld %Ld\n", fl->fl_start, fl->fl_end); in lock_get_status()
2588 struct file_lock *fl, *bfl; in locks_show() local
2590 fl = hlist_entry(v, struct file_lock, fl_link); in locks_show()
2592 lock_get_status(f, fl, iter->li_pos, ""); in locks_show()
2594 list_for_each_entry(bfl, &fl->fl_block, fl_block) in locks_show()
2604 struct file_lock *fl; in __show_fd_locks() local
2606 list_for_each_entry(fl, head, fl_list) { in __show_fd_locks()
2608 if (filp != fl->fl_file) in __show_fd_locks()
2610 if (fl->fl_owner != files && in __show_fd_locks()
2611 fl->fl_owner != filp) in __show_fd_locks()
2616 lock_get_status(f, fl, *id, ""); in __show_fd_locks()