Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

afs: adapt to breakup of struct file_lock

Most of the existing APIs have remained the same, but subsystems that
access file_lock fields directly need to reach into struct
file_lock_core now.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-35-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jeff Layton and committed by
Christian Brauner
82a8cb96 459c814a

+21 -22
+19 -19
fs/afs/flock.c
··· 121 121 122 122 list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) { 123 123 if (error && 124 - p->fl_type == type && 125 - afs_file_key(p->fl_file) == key) { 124 + p->c.flc_type == type && 125 + afs_file_key(p->c.flc_file) == key) { 126 126 list_del_init(&p->fl_u.afs.link); 127 127 p->fl_u.afs.state = error; 128 128 locks_wake_up(p); 129 129 } 130 130 131 131 /* Select the next locker to hand off to. */ 132 - if (next && 133 - (lock_is_write(next) || lock_is_read(p))) 132 + if (next && (lock_is_write(next) || lock_is_read(p))) 134 133 continue; 135 134 next = p; 136 135 } ··· 463 464 464 465 _enter("{%llx:%llu},%llu-%llu,%u,%u", 465 466 vnode->fid.vid, vnode->fid.vnode, 466 - fl->fl_start, fl->fl_end, fl->fl_type, mode); 467 + fl->fl_start, fl->fl_end, fl->c.flc_type, mode); 467 468 468 469 fl->fl_ops = &afs_lock_ops; 469 470 INIT_LIST_HEAD(&fl->fl_u.afs.link); ··· 523 524 } 524 525 525 526 if (vnode->lock_state == AFS_VNODE_LOCK_NONE && 526 - !(fl->fl_flags & FL_SLEEP)) { 527 + !(fl->c.flc_flags & FL_SLEEP)) { 527 528 ret = -EAGAIN; 528 529 if (type == AFS_LOCK_READ) { 529 530 if (vnode->status.lock_count == -1) ··· 620 621 return 0; 621 622 622 623 lock_is_contended: 623 - if (!(fl->fl_flags & FL_SLEEP)) { 624 + if (!(fl->c.flc_flags & FL_SLEEP)) { 624 625 list_del_init(&fl->fl_u.afs.link); 625 626 afs_next_locker(vnode, 0); 626 627 ret = -EAGAIN; ··· 640 641 spin_unlock(&vnode->lock); 641 642 642 643 trace_afs_flock_ev(vnode, fl, afs_flock_waiting, 0); 643 - ret = wait_event_interruptible(fl->fl_wait, 644 + ret = wait_event_interruptible(fl->c.flc_wait, 644 645 fl->fl_u.afs.state != AFS_LOCK_PENDING); 645 646 trace_afs_flock_ev(vnode, fl, afs_flock_waited, ret); 646 647 ··· 703 704 struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); 704 705 int ret; 705 706 706 - _enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type); 707 + _enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, 708 + fl->c.flc_type); 707 709 708 710 trace_afs_flock_op(vnode, fl, afs_flock_op_unlock); 709 711 ··· 730 730 if (vnode->lock_state == AFS_VNODE_LOCK_DELETED) 731 731 return -ENOENT; 732 732 733 - fl->fl_type = F_UNLCK; 733 + fl->c.flc_type = F_UNLCK; 734 734 735 735 /* check local lock records first */ 736 736 posix_test_lock(file, fl); ··· 743 743 lock_count = READ_ONCE(vnode->status.lock_count); 744 744 if (lock_count != 0) { 745 745 if (lock_count > 0) 746 - fl->fl_type = F_RDLCK; 746 + fl->c.flc_type = F_RDLCK; 747 747 else 748 - fl->fl_type = F_WRLCK; 748 + fl->c.flc_type = F_WRLCK; 749 749 fl->fl_start = 0; 750 750 fl->fl_end = OFFSET_MAX; 751 - fl->fl_pid = 0; 751 + fl->c.flc_pid = 0; 752 752 } 753 753 } 754 754 755 755 ret = 0; 756 756 error: 757 - _leave(" = %d [%hd]", ret, fl->fl_type); 757 + _leave(" = %d [%hd]", ret, fl->c.flc_type); 758 758 return ret; 759 759 } 760 760 ··· 769 769 770 770 _enter("{%llx:%llu},%d,{t=%x,fl=%x,r=%Ld:%Ld}", 771 771 vnode->fid.vid, vnode->fid.vnode, cmd, 772 - fl->fl_type, fl->fl_flags, 772 + fl->c.flc_type, fl->c.flc_flags, 773 773 (long long) fl->fl_start, (long long) fl->fl_end); 774 774 775 775 if (IS_GETLK(cmd)) ··· 804 804 805 805 _enter("{%llx:%llu},%d,{t=%x,fl=%x}", 806 806 vnode->fid.vid, vnode->fid.vnode, cmd, 807 - fl->fl_type, fl->fl_flags); 807 + fl->c.flc_type, fl->c.flc_flags); 808 808 809 809 /* 810 810 * No BSD flocks over NFS allowed. ··· 813 813 * Not sure whether that would be unique, though, or whether 814 814 * that would break in other places. 815 815 */ 816 - if (!(fl->fl_flags & FL_FLOCK)) 816 + if (!(fl->c.flc_flags & FL_FLOCK)) 817 817 return -ENOLCK; 818 818 819 819 fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); ··· 843 843 */ 844 844 static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) 845 845 { 846 - struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file)); 846 + struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->c.flc_file)); 847 847 848 848 _enter(""); 849 849 ··· 861 861 */ 862 862 static void afs_fl_release_private(struct file_lock *fl) 863 863 { 864 - struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file)); 864 + struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->c.flc_file)); 865 865 866 866 _enter(""); 867 867
-1
fs/afs/internal.h
··· 9 9 #include <linux/kernel.h> 10 10 #include <linux/ktime.h> 11 11 #include <linux/fs.h> 12 - #define _NEED_FILE_LOCK_FIELD_MACROS 13 12 #include <linux/filelock.h> 14 13 #include <linux/pagemap.h> 15 14 #include <linux/rxrpc.h>
+2 -2
include/trace/events/afs.h
··· 1164 1164 __entry->from = fl->fl_start; 1165 1165 __entry->len = fl->fl_end - fl->fl_start + 1; 1166 1166 __entry->op = op; 1167 - __entry->type = fl->fl_type; 1168 - __entry->flags = fl->fl_flags; 1167 + __entry->type = fl->c.flc_type; 1168 + __entry->flags = fl->c.flc_flags; 1169 1169 __entry->debug_id = fl->fl_u.afs.debug_id; 1170 1170 ), 1171 1171