Skip to content

Commit 82a8cb9

Browse files
jtlaytonbrauner
authored andcommitted
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>
1 parent 459c814 commit 82a8cb9

3 files changed

Lines changed: 21 additions & 22 deletions

File tree

fs/afs/flock.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,15 @@ static void afs_next_locker(struct afs_vnode *vnode, int error)
121121

122122
list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) {
123123
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) {
126126
list_del_init(&p->fl_u.afs.link);
127127
p->fl_u.afs.state = error;
128128
locks_wake_up(p);
129129
}
130130

131131
/* 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)))
134133
continue;
135134
next = p;
136135
}
@@ -464,7 +463,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
464463

465464
_enter("{%llx:%llu},%llu-%llu,%u,%u",
466465
vnode->fid.vid, vnode->fid.vnode,
467-
fl->fl_start, fl->fl_end, fl->fl_type, mode);
466+
fl->fl_start, fl->fl_end, fl->c.flc_type, mode);
468467

469468
fl->fl_ops = &afs_lock_ops;
470469
INIT_LIST_HEAD(&fl->fl_u.afs.link);
@@ -524,7 +523,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
524523
}
525524

526525
if (vnode->lock_state == AFS_VNODE_LOCK_NONE &&
527-
!(fl->fl_flags & FL_SLEEP)) {
526+
!(fl->c.flc_flags & FL_SLEEP)) {
528527
ret = -EAGAIN;
529528
if (type == AFS_LOCK_READ) {
530529
if (vnode->status.lock_count == -1)
@@ -621,7 +620,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
621620
return 0;
622621

623622
lock_is_contended:
624-
if (!(fl->fl_flags & FL_SLEEP)) {
623+
if (!(fl->c.flc_flags & FL_SLEEP)) {
625624
list_del_init(&fl->fl_u.afs.link);
626625
afs_next_locker(vnode, 0);
627626
ret = -EAGAIN;
@@ -641,7 +640,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
641640
spin_unlock(&vnode->lock);
642641

643642
trace_afs_flock_ev(vnode, fl, afs_flock_waiting, 0);
644-
ret = wait_event_interruptible(fl->fl_wait,
643+
ret = wait_event_interruptible(fl->c.flc_wait,
645644
fl->fl_u.afs.state != AFS_LOCK_PENDING);
646645
trace_afs_flock_ev(vnode, fl, afs_flock_waited, ret);
647646

@@ -704,7 +703,8 @@ static int afs_do_unlk(struct file *file, struct file_lock *fl)
704703
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
705704
int ret;
706705

707-
_enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type);
706+
_enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode,
707+
fl->c.flc_type);
708708

709709
trace_afs_flock_op(vnode, fl, afs_flock_op_unlock);
710710

@@ -730,7 +730,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
730730
if (vnode->lock_state == AFS_VNODE_LOCK_DELETED)
731731
return -ENOENT;
732732

733-
fl->fl_type = F_UNLCK;
733+
fl->c.flc_type = F_UNLCK;
734734

735735
/* check local lock records first */
736736
posix_test_lock(file, fl);
@@ -743,18 +743,18 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
743743
lock_count = READ_ONCE(vnode->status.lock_count);
744744
if (lock_count != 0) {
745745
if (lock_count > 0)
746-
fl->fl_type = F_RDLCK;
746+
fl->c.flc_type = F_RDLCK;
747747
else
748-
fl->fl_type = F_WRLCK;
748+
fl->c.flc_type = F_WRLCK;
749749
fl->fl_start = 0;
750750
fl->fl_end = OFFSET_MAX;
751-
fl->fl_pid = 0;
751+
fl->c.flc_pid = 0;
752752
}
753753
}
754754

755755
ret = 0;
756756
error:
757-
_leave(" = %d [%hd]", ret, fl->fl_type);
757+
_leave(" = %d [%hd]", ret, fl->c.flc_type);
758758
return ret;
759759
}
760760

@@ -769,7 +769,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl)
769769

770770
_enter("{%llx:%llu},%d,{t=%x,fl=%x,r=%Ld:%Ld}",
771771
vnode->fid.vid, vnode->fid.vnode, cmd,
772-
fl->fl_type, fl->fl_flags,
772+
fl->c.flc_type, fl->c.flc_flags,
773773
(long long) fl->fl_start, (long long) fl->fl_end);
774774

775775
if (IS_GETLK(cmd))
@@ -804,7 +804,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl)
804804

805805
_enter("{%llx:%llu},%d,{t=%x,fl=%x}",
806806
vnode->fid.vid, vnode->fid.vnode, cmd,
807-
fl->fl_type, fl->fl_flags);
807+
fl->c.flc_type, fl->c.flc_flags);
808808

809809
/*
810810
* No BSD flocks over NFS allowed.
@@ -813,7 +813,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl)
813813
* Not sure whether that would be unique, though, or whether
814814
* that would break in other places.
815815
*/
816-
if (!(fl->fl_flags & FL_FLOCK))
816+
if (!(fl->c.flc_flags & FL_FLOCK))
817817
return -ENOLCK;
818818

819819
fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id);
@@ -843,7 +843,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl)
843843
*/
844844
static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl)
845845
{
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));
847847

848848
_enter("");
849849

@@ -861,7 +861,7 @@ static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl)
861861
*/
862862
static void afs_fl_release_private(struct file_lock *fl)
863863
{
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));
865865

866866
_enter("");
867867

fs/afs/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <linux/kernel.h>
1010
#include <linux/ktime.h>
1111
#include <linux/fs.h>
12-
#define _NEED_FILE_LOCK_FIELD_MACROS
1312
#include <linux/filelock.h>
1413
#include <linux/pagemap.h>
1514
#include <linux/rxrpc.h>

include/trace/events/afs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,8 @@ TRACE_EVENT(afs_flock_op,
11641164
__entry->from = fl->fl_start;
11651165
__entry->len = fl->fl_end - fl->fl_start + 1;
11661166
__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;
11691169
__entry->debug_id = fl->fl_u.afs.debug_id;
11701170
),
11711171

0 commit comments

Comments
 (0)