Lines Matching refs:fl
82 static bool lease_breaking(struct file_lease *fl) in lease_breaking() argument
84 return fl->c.flc_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); in lease_breaking()
87 static int target_leasetype(struct file_lease *fl) in target_leasetype() argument
89 if (fl->c.flc_flags & FL_UNLOCK_PENDING) in target_leasetype()
91 if (fl->c.flc_flags & FL_DOWNGRADE_PENDING) in target_leasetype()
93 return fl->c.flc_type; in target_leasetype()
275 struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL); in locks_alloc_lock() local
277 if (fl) in locks_alloc_lock()
278 locks_init_lock_heads(&fl->c); in locks_alloc_lock()
280 return fl; in locks_alloc_lock()
287 struct file_lease *fl = kmem_cache_zalloc(filelease_cache, GFP_KERNEL); in locks_alloc_lease() local
289 if (fl) in locks_alloc_lease()
290 locks_init_lock_heads(&fl->c); in locks_alloc_lease()
292 return fl; in locks_alloc_lease()
296 void locks_release_private(struct file_lock *fl) in locks_release_private() argument
298 struct file_lock_core *flc = &fl->c; in locks_release_private()
306 if (fl->fl_ops) { in locks_release_private()
307 if (fl->fl_ops->fl_release_private) in locks_release_private()
308 fl->fl_ops->fl_release_private(fl); in locks_release_private()
309 fl->fl_ops = NULL; in locks_release_private()
312 if (fl->fl_lmops) { in locks_release_private()
313 if (fl->fl_lmops->lm_put_owner) { in locks_release_private()
314 fl->fl_lmops->lm_put_owner(flc->flc_owner); in locks_release_private()
317 fl->fl_lmops = NULL; in locks_release_private()
350 void locks_free_lock(struct file_lock *fl) in locks_free_lock() argument
352 locks_release_private(fl); in locks_free_lock()
353 kmem_cache_free(filelock_cache, fl); in locks_free_lock()
358 void locks_free_lease(struct file_lease *fl) in locks_free_lease() argument
360 kmem_cache_free(filelease_cache, fl); in locks_free_lease()
379 void locks_init_lock(struct file_lock *fl) in locks_init_lock() argument
381 memset(fl, 0, sizeof(struct file_lock)); in locks_init_lock()
382 locks_init_lock_heads(&fl->c); in locks_init_lock()
386 void locks_init_lease(struct file_lease *fl) in locks_init_lease() argument
388 memset(fl, 0, sizeof(*fl)); in locks_init_lease()
389 locks_init_lock_heads(&fl->c); in locks_init_lease()
396 void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) in locks_copy_conflock() argument
398 new->c.flc_owner = fl->c.flc_owner; in locks_copy_conflock()
399 new->c.flc_pid = fl->c.flc_pid; in locks_copy_conflock()
401 new->c.flc_flags = fl->c.flc_flags; in locks_copy_conflock()
402 new->c.flc_type = fl->c.flc_type; in locks_copy_conflock()
403 new->fl_start = fl->fl_start; in locks_copy_conflock()
404 new->fl_end = fl->fl_end; in locks_copy_conflock()
405 new->fl_lmops = fl->fl_lmops; in locks_copy_conflock()
408 if (fl->fl_lmops) { in locks_copy_conflock()
409 if (fl->fl_lmops->lm_get_owner) in locks_copy_conflock()
410 fl->fl_lmops->lm_get_owner(fl->c.flc_owner); in locks_copy_conflock()
415 void locks_copy_lock(struct file_lock *new, struct file_lock *fl) in locks_copy_lock() argument
420 locks_copy_conflock(new, fl); in locks_copy_lock()
422 new->c.flc_file = fl->c.flc_file; in locks_copy_lock()
423 new->fl_ops = fl->fl_ops; in locks_copy_lock()
425 if (fl->fl_ops) { in locks_copy_lock()
426 if (fl->fl_ops->fl_copy_lock) in locks_copy_lock()
427 fl->fl_ops->fl_copy_lock(new, fl); in locks_copy_lock()
432 static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) in locks_move_blocks() argument
441 if (list_empty(&fl->c.flc_blocked_requests)) in locks_move_blocks()
444 list_splice_init(&fl->c.flc_blocked_requests, in locks_move_blocks()
465 static void flock_make_lock(struct file *filp, struct file_lock *fl, int type) in flock_make_lock() argument
467 locks_init_lock(fl); in flock_make_lock()
469 fl->c.flc_file = filp; in flock_make_lock()
470 fl->c.flc_owner = filp; in flock_make_lock()
471 fl->c.flc_pid = current->tgid; in flock_make_lock()
472 fl->c.flc_flags = FL_FLOCK; in flock_make_lock()
473 fl->c.flc_type = type; in flock_make_lock()
474 fl->fl_end = OFFSET_MAX; in flock_make_lock()
491 static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, in flock64_to_posix_lock() argument
496 fl->fl_start = 0; in flock64_to_posix_lock()
499 fl->fl_start = filp->f_pos; in flock64_to_posix_lock()
502 fl->fl_start = i_size_read(file_inode(filp)); in flock64_to_posix_lock()
507 if (l->l_start > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
509 fl->fl_start += l->l_start; in flock64_to_posix_lock()
510 if (fl->fl_start < 0) in flock64_to_posix_lock()
516 if (l->l_len - 1 > OFFSET_MAX - fl->fl_start) in flock64_to_posix_lock()
518 fl->fl_end = fl->fl_start + (l->l_len - 1); in flock64_to_posix_lock()
521 if (fl->fl_start + l->l_len < 0) in flock64_to_posix_lock()
523 fl->fl_end = fl->fl_start - 1; in flock64_to_posix_lock()
524 fl->fl_start += l->l_len; in flock64_to_posix_lock()
526 fl->fl_end = OFFSET_MAX; in flock64_to_posix_lock()
528 fl->c.flc_owner = current->files; in flock64_to_posix_lock()
529 fl->c.flc_pid = current->tgid; in flock64_to_posix_lock()
530 fl->c.flc_file = filp; in flock64_to_posix_lock()
531 fl->c.flc_flags = FL_POSIX; in flock64_to_posix_lock()
532 fl->fl_ops = NULL; in flock64_to_posix_lock()
533 fl->fl_lmops = NULL; in flock64_to_posix_lock()
535 return assign_type(&fl->c, l->l_type); in flock64_to_posix_lock()
541 static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, in flock_to_posix_lock() argument
551 return flock64_to_posix_lock(filp, fl, &ll); in flock_to_posix_lock()
556 lease_break_callback(struct file_lease *fl) in lease_break_callback() argument
558 kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG); in lease_break_callback()
563 lease_setup(struct file_lease *fl, void **priv) in lease_setup() argument
565 struct file *filp = fl->c.flc_file; in lease_setup()
573 if (!fasync_insert_entry(fa->fa_fd, filp, &fl->fl_fasync, fa)) in lease_setup()
588 static int lease_init(struct file *filp, int type, struct file_lease *fl) in lease_init() argument
590 if (assign_type(&fl->c, type) != 0) in lease_init()
593 fl->c.flc_owner = filp; in lease_init()
594 fl->c.flc_pid = current->tgid; in lease_init()
596 fl->c.flc_file = filp; in lease_init()
597 fl->c.flc_flags = FL_LEASE; in lease_init()
598 fl->fl_lmops = &lease_manager_ops; in lease_init()
605 struct file_lease *fl = locks_alloc_lease(); in lease_alloc() local
608 if (fl == NULL) in lease_alloc()
611 error = lease_init(filp, type, fl); in lease_alloc()
613 locks_free_lease(fl); in lease_alloc()
616 return fl; in lease_alloc()
704 struct file_lock *fl; in __locks_wake_up_blocks() local
709 fl = file_lock(waiter); in __locks_wake_up_blocks()
712 fl->fl_lmops && fl->fl_lmops->lm_notify) in __locks_wake_up_blocks()
713 fl->fl_lmops->lm_notify(fl); in __locks_wake_up_blocks()
859 locks_insert_lock_ctx(struct file_lock_core *fl, struct list_head *before) in locks_insert_lock_ctx() argument
861 list_add_tail(&fl->flc_list, before); in locks_insert_lock_ctx()
862 locks_insert_global_locks(fl); in locks_insert_lock_ctx()
866 locks_unlink_lock_ctx(struct file_lock_core *fl) in locks_unlink_lock_ctx() argument
868 locks_delete_global_locks(fl); in locks_unlink_lock_ctx()
869 list_del_init(&fl->flc_list); in locks_unlink_lock_ctx()
870 locks_wake_up_blocks(fl); in locks_unlink_lock_ctx()
874 locks_delete_lock_ctx(struct file_lock_core *fl, struct list_head *dispose) in locks_delete_lock_ctx() argument
876 locks_unlink_lock_ctx(fl); in locks_delete_lock_ctx()
878 list_add(&fl->flc_list, dispose); in locks_delete_lock_ctx()
880 locks_free_lock(file_lock(fl)); in locks_delete_lock_ctx()
952 posix_test_lock(struct file *filp, struct file_lock *fl) in posix_test_lock() argument
962 fl->c.flc_type = F_UNLCK; in posix_test_lock()
969 if (!posix_test_locks_conflict(fl, cfl)) in posix_test_lock()
981 locks_copy_conflock(fl, cfl); in posix_test_lock()
984 fl->c.flc_type = F_UNLCK; in posix_test_lock()
1077 struct file_lock *fl; in flock_lock_inode() local
1101 list_for_each_entry(fl, &ctx->flc_flock, c.flc_list) { in flock_lock_inode()
1102 if (request->c.flc_file != fl->c.flc_file) in flock_lock_inode()
1104 if (request->c.flc_type == fl->c.flc_type) in flock_lock_inode()
1107 locks_delete_lock_ctx(&fl->c, &dispose); in flock_lock_inode()
1118 list_for_each_entry(fl, &ctx->flc_flock, c.flc_list) { in flock_lock_inode()
1119 if (!flock_locks_conflict(&request->c, &fl->c)) in flock_lock_inode()
1125 locks_insert_block(&fl->c, &request->c, flock_locks_conflict); in flock_lock_inode()
1149 struct file_lock *fl, *tmp; in posix_lock_inode() local
1187 list_for_each_entry(fl, &ctx->flc_posix, c.flc_list) { in posix_lock_inode()
1188 if (!posix_locks_conflict(&request->c, &fl->c)) in posix_lock_inode()
1190 if (fl->fl_lmops && fl->fl_lmops->lm_lock_expirable in posix_lock_inode()
1191 && (*fl->fl_lmops->lm_lock_expirable)(fl)) { in posix_lock_inode()
1192 owner = fl->fl_lmops->lm_mod_owner; in posix_lock_inode()
1193 func = fl->fl_lmops->lm_expire_lock; in posix_lock_inode()
1202 locks_copy_conflock(conflock, fl); in posix_lock_inode()
1217 if (likely(!posix_locks_deadlock(request, fl))) { in posix_lock_inode()
1219 __locks_insert_block(&fl->c, &request->c, in posix_lock_inode()
1233 list_for_each_entry(fl, &ctx->flc_posix, c.flc_list) { in posix_lock_inode()
1234 if (posix_same_owner(&request->c, &fl->c)) in posix_lock_inode()
1239 list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, c.flc_list) { in posix_lock_inode()
1240 if (!posix_same_owner(&request->c, &fl->c)) in posix_lock_inode()
1244 if (request->c.flc_type == fl->c.flc_type) { in posix_lock_inode()
1249 if (fl->fl_end < request->fl_start - 1) in posix_lock_inode()
1254 if (fl->fl_start - 1 > request->fl_end) in posix_lock_inode()
1262 if (fl->fl_start > request->fl_start) in posix_lock_inode()
1263 fl->fl_start = request->fl_start; in posix_lock_inode()
1265 request->fl_start = fl->fl_start; in posix_lock_inode()
1266 if (fl->fl_end < request->fl_end) in posix_lock_inode()
1267 fl->fl_end = request->fl_end; in posix_lock_inode()
1269 request->fl_end = fl->fl_end; in posix_lock_inode()
1271 locks_delete_lock_ctx(&fl->c, &dispose); in posix_lock_inode()
1274 request = fl; in posix_lock_inode()
1280 if (fl->fl_end < request->fl_start) in posix_lock_inode()
1282 if (fl->fl_start > request->fl_end) in posix_lock_inode()
1286 if (fl->fl_start < request->fl_start) in posix_lock_inode()
1287 left = fl; in posix_lock_inode()
1291 if (fl->fl_end > request->fl_end) { in posix_lock_inode()
1292 right = fl; in posix_lock_inode()
1295 if (fl->fl_start >= request->fl_start) { in posix_lock_inode()
1300 locks_delete_lock_ctx(&fl->c, &dispose); in posix_lock_inode()
1318 &fl->c.flc_list); in posix_lock_inode()
1319 locks_delete_lock_ctx(&fl->c, &dispose); in posix_lock_inode()
1348 locks_insert_lock_ctx(&new_fl->c, &fl->c.flc_list); in posix_lock_inode()
1349 fl = new_fl; in posix_lock_inode()
1360 locks_insert_lock_ctx(&left->c, &fl->c.flc_list); in posix_lock_inode()
1399 int posix_lock_file(struct file *filp, struct file_lock *fl, in posix_lock_file() argument
1402 return posix_lock_inode(file_inode(filp), fl, conflock); in posix_lock_file()
1413 static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl) in posix_lock_inode_wait() argument
1418 error = posix_lock_inode(inode, fl, NULL); in posix_lock_inode_wait()
1421 error = wait_event_interruptible(fl->c.flc_wait, in posix_lock_inode_wait()
1422 list_empty(&fl->c.flc_blocked_member)); in posix_lock_inode_wait()
1426 locks_delete_block(fl); in posix_lock_inode_wait()
1430 static void lease_clear_pending(struct file_lease *fl, int arg) in lease_clear_pending() argument
1434 fl->c.flc_flags &= ~FL_UNLOCK_PENDING; in lease_clear_pending()
1437 fl->c.flc_flags &= ~FL_DOWNGRADE_PENDING; in lease_clear_pending()
1442 int lease_modify(struct file_lease *fl, int arg, struct list_head *dispose) in lease_modify() argument
1444 int error = assign_type(&fl->c, arg); in lease_modify()
1448 lease_clear_pending(fl, arg); in lease_modify()
1449 locks_wake_up_blocks(&fl->c); in lease_modify()
1451 struct file *filp = fl->c.flc_file; in lease_modify()
1455 fasync_helper(0, fl->c.flc_file, 0, &fl->fl_fasync); in lease_modify()
1456 if (fl->fl_fasync != NULL) { in lease_modify()
1457 printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync); in lease_modify()
1458 fl->fl_fasync = NULL; in lease_modify()
1460 locks_delete_lock_ctx(&fl->c, dispose); in lease_modify()
1477 struct file_lease *fl, *tmp; in time_out_leases() local
1481 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, c.flc_list) { in time_out_leases()
1482 trace_time_out_leases(inode, fl); in time_out_leases()
1483 if (past_time(fl->fl_downgrade_time)) in time_out_leases()
1484 lease_modify(fl, F_RDLCK, dispose); in time_out_leases()
1485 if (past_time(fl->fl_break_time)) in time_out_leases()
1486 lease_modify(fl, F_UNLCK, dispose); in time_out_leases()
1546 struct file_lease *new_fl, *fl, *tmp; in __break_lease() local
1578 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, c.flc_list) { in __break_lease()
1579 if (!leases_conflict(&fl->c, &new_fl->c)) in __break_lease()
1582 if (fl->c.flc_flags & FL_UNLOCK_PENDING) in __break_lease()
1584 fl->c.flc_flags |= FL_UNLOCK_PENDING; in __break_lease()
1585 fl->fl_break_time = break_time; in __break_lease()
1587 if (lease_breaking(fl)) in __break_lease()
1589 fl->c.flc_flags |= FL_DOWNGRADE_PENDING; in __break_lease()
1590 fl->fl_downgrade_time = break_time; in __break_lease()
1592 if (fl->fl_lmops->lm_break(fl)) in __break_lease()
1593 locks_delete_lock_ctx(&fl->c, &dispose); in __break_lease()
1606 fl = list_first_entry(&ctx->flc_lease, struct file_lease, c.flc_list); in __break_lease()
1607 break_time = fl->fl_break_time; in __break_lease()
1612 locks_insert_block(&fl->c, &new_fl->c, leases_conflict); in __break_lease()
1702 struct file_lease *fl; in fcntl_getlease() local
1713 list_for_each_entry(fl, &ctx->flc_lease, c.flc_list) { in fcntl_getlease()
1714 if (fl->c.flc_file != filp) in fcntl_getlease()
1716 type = target_leasetype(fl); in fcntl_getlease()
1776 struct file_lease *fl, *my_fl = NULL, *lease; in generic_add_lease() local
1822 list_for_each_entry(fl, &ctx->flc_lease, c.flc_list) { in generic_add_lease()
1823 if (fl->c.flc_file == filp && in generic_add_lease()
1824 fl->c.flc_owner == lease->c.flc_owner) { in generic_add_lease()
1825 my_fl = fl; in generic_add_lease()
1839 if (fl->c.flc_flags & FL_UNLOCK_PENDING) in generic_add_lease()
1889 struct file_lease *fl, *victim = NULL; in generic_delete_lease() local
1902 list_for_each_entry(fl, &ctx->flc_lease, c.flc_list) { in generic_delete_lease()
1903 if (fl->c.flc_file == filp && in generic_delete_lease()
1904 fl->c.flc_owner == owner) { in generic_delete_lease()
1905 victim = fl; in generic_delete_lease()
1911 error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose); in generic_delete_lease()
2032 struct file_lease *fl; in do_fcntl_add_lease() local
2036 fl = lease_alloc(filp, arg); in do_fcntl_add_lease()
2037 if (IS_ERR(fl)) in do_fcntl_add_lease()
2038 return PTR_ERR(fl); in do_fcntl_add_lease()
2042 locks_free_lease(fl); in do_fcntl_add_lease()
2047 error = vfs_setlease(filp, arg, &fl, (void **)&new); in do_fcntl_add_lease()
2048 if (fl) in do_fcntl_add_lease()
2049 locks_free_lease(fl); in do_fcntl_add_lease()
2079 static int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl) in flock_lock_inode_wait() argument
2084 error = flock_lock_inode(inode, fl); in flock_lock_inode_wait()
2087 error = wait_event_interruptible(fl->c.flc_wait, in flock_lock_inode_wait()
2088 list_empty(&fl->c.flc_blocked_member)); in flock_lock_inode_wait()
2092 locks_delete_block(fl); in flock_lock_inode_wait()
2103 int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl) in locks_lock_inode_wait() argument
2106 switch (fl->c.flc_flags & (FL_POSIX|FL_FLOCK)) { in locks_lock_inode_wait()
2108 res = posix_lock_inode_wait(inode, fl); in locks_lock_inode_wait()
2111 res = flock_lock_inode_wait(inode, fl); in locks_lock_inode_wait()
2138 struct file_lock fl; in SYSCALL_DEFINE2() local
2164 flock_make_lock(fd_file(f), &fl, type); in SYSCALL_DEFINE2()
2166 error = security_file_lock(fd_file(f), fl.c.flc_type); in SYSCALL_DEFINE2()
2172 fl.c.flc_flags |= FL_SLEEP; in SYSCALL_DEFINE2()
2177 &fl); in SYSCALL_DEFINE2()
2179 error = locks_lock_file_wait(fd_file(f), &fl); in SYSCALL_DEFINE2()
2181 locks_release_private(&fl); in SYSCALL_DEFINE2()
2193 int vfs_test_lock(struct file *filp, struct file_lock *fl) in vfs_test_lock() argument
2195 WARN_ON_ONCE(filp != fl->c.flc_file); in vfs_test_lock()
2197 return filp->f_op->lock(filp, F_GETLK, fl); in vfs_test_lock()
2198 posix_test_lock(filp, fl); in vfs_test_lock()
2210 static pid_t locks_translate_pid(struct file_lock_core *fl, struct pid_namespace *ns) in locks_translate_pid() argument
2215 if (fl->flc_flags & FL_OFDLCK) in locks_translate_pid()
2219 if (fl->flc_pid <= 0) in locks_translate_pid()
2220 return fl->flc_pid; in locks_translate_pid()
2228 return (pid_t) fl->flc_pid; in locks_translate_pid()
2231 pid = find_pid_ns(fl->flc_pid, &init_pid_ns); in locks_translate_pid()
2237 static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) in posix_lock_to_flock() argument
2239 flock->l_pid = locks_translate_pid(&fl->c, task_active_pid_ns(current)); in posix_lock_to_flock()
2245 if (fl->fl_start > OFFT_OFFSET_MAX) in posix_lock_to_flock()
2247 if (fl->fl_end != OFFSET_MAX && fl->fl_end > OFFT_OFFSET_MAX) in posix_lock_to_flock()
2250 flock->l_start = fl->fl_start; in posix_lock_to_flock()
2251 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock()
2252 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock()
2254 flock->l_type = fl->c.flc_type; in posix_lock_to_flock()
2259 static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) in posix_lock_to_flock64() argument
2261 flock->l_pid = locks_translate_pid(&fl->c, task_active_pid_ns(current)); in posix_lock_to_flock64()
2262 flock->l_start = fl->fl_start; in posix_lock_to_flock64()
2263 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : in posix_lock_to_flock64()
2264 fl->fl_end - fl->fl_start + 1; in posix_lock_to_flock64()
2266 flock->l_type = fl->c.flc_type; in posix_lock_to_flock64()
2275 struct file_lock *fl; in fcntl_getlk() local
2278 fl = locks_alloc_lock(); in fcntl_getlk()
2279 if (fl == NULL) in fcntl_getlk()
2286 error = flock_to_posix_lock(filp, fl, flock); in fcntl_getlk()
2295 fl->c.flc_flags |= FL_OFDLCK; in fcntl_getlk()
2296 fl->c.flc_owner = filp; in fcntl_getlk()
2299 error = vfs_test_lock(filp, fl); in fcntl_getlk()
2303 flock->l_type = fl->c.flc_type; in fcntl_getlk()
2304 if (fl->c.flc_type != F_UNLCK) { in fcntl_getlk()
2305 error = posix_lock_to_flock(flock, fl); in fcntl_getlk()
2310 locks_free_lock(fl); in fcntl_getlk()
2349 int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) in vfs_lock_file() argument
2351 WARN_ON_ONCE(filp != fl->c.flc_file); in vfs_lock_file()
2353 return filp->f_op->lock(filp, cmd, fl); in vfs_lock_file()
2355 return posix_lock_file(filp, fl, conf); in vfs_lock_file()
2360 struct file_lock *fl) in do_lock_file_wait() argument
2364 error = security_file_lock(filp, fl->c.flc_type); in do_lock_file_wait()
2369 error = vfs_lock_file(filp, cmd, fl, NULL); in do_lock_file_wait()
2372 error = wait_event_interruptible(fl->c.flc_wait, in do_lock_file_wait()
2373 list_empty(&fl->c.flc_blocked_member)); in do_lock_file_wait()
2377 locks_delete_block(fl); in do_lock_file_wait()
2384 check_fmode_for_setlk(struct file_lock *fl) in check_fmode_for_setlk() argument
2386 switch (fl->c.flc_type) { in check_fmode_for_setlk()
2388 if (!(fl->c.flc_file->f_mode & FMODE_READ)) in check_fmode_for_setlk()
2392 if (!(fl->c.flc_file->f_mode & FMODE_WRITE)) in check_fmode_for_setlk()
2483 struct file_lock *fl; in fcntl_getlk64() local
2486 fl = locks_alloc_lock(); in fcntl_getlk64()
2487 if (fl == NULL) in fcntl_getlk64()
2495 error = flock64_to_posix_lock(filp, fl, flock); in fcntl_getlk64()
2504 fl->c.flc_flags |= FL_OFDLCK; in fcntl_getlk64()
2505 fl->c.flc_owner = filp; in fcntl_getlk64()
2508 error = vfs_test_lock(filp, fl); in fcntl_getlk64()
2512 flock->l_type = fl->c.flc_type; in fcntl_getlk64()
2513 if (fl->c.flc_type != F_UNLCK) in fcntl_getlk64()
2514 posix_lock_to_flock64(flock, fl); in fcntl_getlk64()
2517 locks_free_lock(fl); in fcntl_getlk64()
2643 struct file_lock fl; in locks_remove_flock() local
2649 flock_make_lock(filp, &fl, F_UNLCK); in locks_remove_flock()
2650 fl.c.flc_flags |= FL_CLOSE; in locks_remove_flock()
2653 filp->f_op->flock(filp, F_SETLKW, &fl); in locks_remove_flock()
2655 flock_lock_inode(inode, &fl); in locks_remove_flock()
2657 if (fl.fl_ops && fl.fl_ops->fl_release_private) in locks_remove_flock()
2658 fl.fl_ops->fl_release_private(&fl); in locks_remove_flock()
2665 struct file_lease *fl, *tmp; in locks_remove_lease() local
2673 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, c.flc_list) in locks_remove_lease()
2674 if (filp == fl->c.flc_file) in locks_remove_lease()
2675 lease_modify(fl, F_UNLCK, &dispose); in locks_remove_lease()
2716 int vfs_cancel_lock(struct file *filp, struct file_lock *fl) in vfs_cancel_lock() argument
2718 WARN_ON_ONCE(filp != fl->c.flc_file); in vfs_cancel_lock()
2720 return filp->f_op->lock(filp, F_CANCELLK, fl); in vfs_cancel_lock()
2764 struct file_lock *fl = file_lock(flc); in lock_get_status() local
2824 if (fl->fl_end == OFFSET_MAX) in lock_get_status()
2825 seq_printf(f, "%Ld EOF\n", fl->fl_start); in lock_get_status()
2827 seq_printf(f, "%Ld %Ld\n", fl->fl_start, fl->fl_end); in lock_get_status()
2901 struct file_lock_core *fl; in __show_fd_locks() local
2903 list_for_each_entry(fl, head, flc_list) { in __show_fd_locks()
2905 if (filp != fl->flc_file) in __show_fd_locks()
2907 if (fl->flc_owner != files && fl->flc_owner != filp) in __show_fd_locks()
2912 lock_get_status(f, fl, *id, "", 0); in __show_fd_locks()