Lines Matching refs:fl
17 static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl);
18 static void afs_fl_release_private(struct file_lock *fl);
463 static int afs_do_setlk(struct file *file, struct file_lock *fl) in afs_do_setlk() argument
478 fl->fl_start, fl->fl_end, fl->fl_type, mode); in afs_do_setlk()
480 fl->fl_ops = &afs_lock_ops; in afs_do_setlk()
481 INIT_LIST_HEAD(&fl->fl_u.afs.link); in afs_do_setlk()
482 fl->fl_u.afs.state = AFS_LOCK_PENDING; in afs_do_setlk()
484 partial = (fl->fl_start != 0 || fl->fl_end != OFFSET_MAX); in afs_do_setlk()
485 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; in afs_do_setlk()
493 trace_afs_flock_op(vnode, fl, afs_flock_op_set_lock); in afs_do_setlk()
510 list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks); in afs_do_setlk()
524 list_move_tail(&fl->fl_u.afs.link, &vnode->granted_locks); in afs_do_setlk()
525 fl->fl_u.afs.state = AFS_LOCK_GRANTED; in afs_do_setlk()
531 list_move_tail(&fl->fl_u.afs.link, &vnode->granted_locks); in afs_do_setlk()
532 fl->fl_u.afs.state = AFS_LOCK_GRANTED; in afs_do_setlk()
538 !(fl->fl_flags & FL_SLEEP)) { in afs_do_setlk()
561 trace_afs_flock_ev(vnode, fl, afs_flock_try_to_lock, 0); in afs_do_setlk()
576 fl->fl_u.afs.state = ret; in afs_do_setlk()
577 trace_afs_flock_ev(vnode, fl, afs_flock_fail_perm, ret); in afs_do_setlk()
578 list_del_init(&fl->fl_u.afs.link); in afs_do_setlk()
583 fl->fl_u.afs.state = ret; in afs_do_setlk()
584 trace_afs_flock_ev(vnode, fl, afs_flock_fail_other, ret); in afs_do_setlk()
585 list_del_init(&fl->fl_u.afs.link); in afs_do_setlk()
590 fl->fl_u.afs.state = ret; in afs_do_setlk()
591 trace_afs_flock_ev(vnode, fl, afs_flock_fail_other, ret); in afs_do_setlk()
592 list_del_init(&fl->fl_u.afs.link); in afs_do_setlk()
602 ASSERTCMP(vnode->pending_locks.next, ==, &fl->fl_u.afs.link); in afs_do_setlk()
607 trace_afs_flock_ev(vnode, fl, afs_flock_acquired, type); in afs_do_setlk()
616 ASSERTCMP(fl->fl_u.afs.state, ==, AFS_LOCK_GRANTED); in afs_do_setlk()
620 trace_afs_flock_ev(vnode, fl, afs_flock_vfs_locking, 0); in afs_do_setlk()
621 ret = locks_lock_file_wait(file, fl); in afs_do_setlk()
622 trace_afs_flock_ev(vnode, fl, afs_flock_vfs_lock, ret); in afs_do_setlk()
635 if (!(fl->fl_flags & FL_SLEEP)) { in afs_do_setlk()
636 list_del_init(&fl->fl_u.afs.link); in afs_do_setlk()
643 trace_afs_flock_ev(vnode, fl, afs_flock_would_block, ret); in afs_do_setlk()
654 trace_afs_flock_ev(vnode, fl, afs_flock_waiting, 0); in afs_do_setlk()
655 ret = wait_event_interruptible(fl->fl_wait, in afs_do_setlk()
656 fl->fl_u.afs.state != AFS_LOCK_PENDING); in afs_do_setlk()
657 trace_afs_flock_ev(vnode, fl, afs_flock_waited, ret); in afs_do_setlk()
659 if (fl->fl_u.afs.state >= 0 && fl->fl_u.afs.state != AFS_LOCK_GRANTED) { in afs_do_setlk()
662 switch (fl->fl_u.afs.state) { in afs_do_setlk()
664 fl->fl_u.afs.state = AFS_LOCK_PENDING; in afs_do_setlk()
674 fl->fl_u.afs.state = AFS_LOCK_PENDING; in afs_do_setlk()
686 if (fl->fl_u.afs.state == AFS_LOCK_GRANTED) in afs_do_setlk()
688 ret = fl->fl_u.afs.state; in afs_do_setlk()
700 list_del_init(&fl->fl_u.afs.link); in afs_do_setlk()
713 static int afs_do_unlk(struct file *file, struct file_lock *fl) in afs_do_unlk() argument
718 _enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type); in afs_do_unlk()
720 trace_afs_flock_op(vnode, fl, afs_flock_op_unlock); in afs_do_unlk()
725 ret = locks_lock_file_wait(file, fl); in afs_do_unlk()
733 static int afs_do_getlk(struct file *file, struct file_lock *fl) in afs_do_getlk() argument
744 fl->fl_type = F_UNLCK; in afs_do_getlk()
747 posix_test_lock(file, fl); in afs_do_getlk()
748 if (fl->fl_type == F_UNLCK) { in afs_do_getlk()
757 fl->fl_type = F_RDLCK; in afs_do_getlk()
759 fl->fl_type = F_WRLCK; in afs_do_getlk()
760 fl->fl_start = 0; in afs_do_getlk()
761 fl->fl_end = OFFSET_MAX; in afs_do_getlk()
762 fl->fl_pid = 0; in afs_do_getlk()
768 _leave(" = %d [%hd]", ret, fl->fl_type); in afs_do_getlk()
775 int afs_lock(struct file *file, int cmd, struct file_lock *fl) in afs_lock() argument
783 fl->fl_type, fl->fl_flags, in afs_lock()
784 (long long) fl->fl_start, (long long) fl->fl_end); in afs_lock()
787 if (__mandatory_lock(&vnode->vfs_inode) && fl->fl_type != F_UNLCK) in afs_lock()
791 return afs_do_getlk(file, fl); in afs_lock()
793 fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); in afs_lock()
794 trace_afs_flock_op(vnode, fl, afs_flock_op_lock); in afs_lock()
796 if (fl->fl_type == F_UNLCK) in afs_lock()
797 ret = afs_do_unlk(file, fl); in afs_lock()
799 ret = afs_do_setlk(file, fl); in afs_lock()
807 trace_afs_flock_op(vnode, fl, op); in afs_lock()
814 int afs_flock(struct file *file, int cmd, struct file_lock *fl) in afs_flock() argument
822 fl->fl_type, fl->fl_flags); in afs_flock()
831 if (!(fl->fl_flags & FL_FLOCK)) in afs_flock()
834 fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); in afs_flock()
835 trace_afs_flock_op(vnode, fl, afs_flock_op_flock); in afs_flock()
838 if (fl->fl_type == F_UNLCK) in afs_flock()
839 ret = afs_do_unlk(file, fl); in afs_flock()
841 ret = afs_do_setlk(file, fl); in afs_flock()
849 trace_afs_flock_op(vnode, fl, op); in afs_flock()
859 static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) in afs_fl_copy_lock() argument
861 struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file)); in afs_fl_copy_lock()
869 list_add(&new->fl_u.afs.link, &fl->fl_u.afs.link); in afs_fl_copy_lock()
877 static void afs_fl_release_private(struct file_lock *fl) in afs_fl_release_private() argument
879 struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file)); in afs_fl_release_private()
885 trace_afs_flock_op(vnode, fl, afs_flock_op_release_lock); in afs_fl_release_private()
886 list_del_init(&fl->fl_u.afs.link); in afs_fl_release_private()