Skip to content

Commit 16f9ce8

Browse files
jtlaytonbrauner
authored andcommitted
smb/server: 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 84e286c commit 16f9ce8

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/ethtool.h>
1313
#include <linux/falloc.h>
1414
#include <linux/mount.h>
15-
#define _NEED_FILE_LOCK_FIELD_MACROS
1615
#include <linux/filelock.h>
1716

1817
#include "glob.h"
@@ -6761,10 +6760,10 @@ struct file_lock *smb_flock_init(struct file *f)
67616760

67626761
locks_init_lock(fl);
67636762

6764-
fl->fl_owner = f;
6765-
fl->fl_pid = current->tgid;
6766-
fl->fl_file = f;
6767-
fl->fl_flags = FL_POSIX;
6763+
fl->c.flc_owner = f;
6764+
fl->c.flc_pid = current->tgid;
6765+
fl->c.flc_file = f;
6766+
fl->c.flc_flags = FL_POSIX;
67686767
fl->fl_ops = NULL;
67696768
fl->fl_lmops = NULL;
67706769

@@ -6781,30 +6780,30 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags)
67816780
case SMB2_LOCKFLAG_SHARED:
67826781
ksmbd_debug(SMB, "received shared request\n");
67836782
cmd = F_SETLKW;
6784-
flock->fl_type = F_RDLCK;
6785-
flock->fl_flags |= FL_SLEEP;
6783+
flock->c.flc_type = F_RDLCK;
6784+
flock->c.flc_flags |= FL_SLEEP;
67866785
break;
67876786
case SMB2_LOCKFLAG_EXCLUSIVE:
67886787
ksmbd_debug(SMB, "received exclusive request\n");
67896788
cmd = F_SETLKW;
6790-
flock->fl_type = F_WRLCK;
6791-
flock->fl_flags |= FL_SLEEP;
6789+
flock->c.flc_type = F_WRLCK;
6790+
flock->c.flc_flags |= FL_SLEEP;
67926791
break;
67936792
case SMB2_LOCKFLAG_SHARED | SMB2_LOCKFLAG_FAIL_IMMEDIATELY:
67946793
ksmbd_debug(SMB,
67956794
"received shared & fail immediately request\n");
67966795
cmd = F_SETLK;
6797-
flock->fl_type = F_RDLCK;
6796+
flock->c.flc_type = F_RDLCK;
67986797
break;
67996798
case SMB2_LOCKFLAG_EXCLUSIVE | SMB2_LOCKFLAG_FAIL_IMMEDIATELY:
68006799
ksmbd_debug(SMB,
68016800
"received exclusive & fail immediately request\n");
68026801
cmd = F_SETLK;
6803-
flock->fl_type = F_WRLCK;
6802+
flock->c.flc_type = F_WRLCK;
68046803
break;
68056804
case SMB2_LOCKFLAG_UNLOCK:
68066805
ksmbd_debug(SMB, "received unlock request\n");
6807-
flock->fl_type = F_UNLCK;
6806+
flock->c.flc_type = F_UNLCK;
68086807
cmd = F_SETLK;
68096808
break;
68106809
}
@@ -6848,7 +6847,7 @@ static void smb2_remove_blocked_lock(void **argv)
68486847
static inline bool lock_defer_pending(struct file_lock *fl)
68496848
{
68506849
/* check pending lock waiters */
6851-
return waitqueue_active(&fl->fl_wait);
6850+
return waitqueue_active(&fl->c.flc_wait);
68526851
}
68536852

68546853
/**
@@ -6939,8 +6938,8 @@ int smb2_lock(struct ksmbd_work *work)
69396938
list_for_each_entry(cmp_lock, &lock_list, llist) {
69406939
if (cmp_lock->fl->fl_start <= flock->fl_start &&
69416940
cmp_lock->fl->fl_end >= flock->fl_end) {
6942-
if (cmp_lock->fl->fl_type != F_UNLCK &&
6943-
flock->fl_type != F_UNLCK) {
6941+
if (cmp_lock->fl->c.flc_type != F_UNLCK &&
6942+
flock->c.flc_type != F_UNLCK) {
69446943
pr_err("conflict two locks in one request\n");
69456944
err = -EINVAL;
69466945
locks_free_lock(flock);
@@ -6988,12 +6987,12 @@ int smb2_lock(struct ksmbd_work *work)
69886987
list_for_each_entry(conn, &conn_list, conns_list) {
69896988
spin_lock(&conn->llist_lock);
69906989
list_for_each_entry_safe(cmp_lock, tmp2, &conn->lock_list, clist) {
6991-
if (file_inode(cmp_lock->fl->fl_file) !=
6992-
file_inode(smb_lock->fl->fl_file))
6990+
if (file_inode(cmp_lock->fl->c.flc_file) !=
6991+
file_inode(smb_lock->fl->c.flc_file))
69936992
continue;
69946993

69956994
if (lock_is_unlock(smb_lock->fl)) {
6996-
if (cmp_lock->fl->fl_file == smb_lock->fl->fl_file &&
6995+
if (cmp_lock->fl->c.flc_file == smb_lock->fl->c.flc_file &&
69976996
cmp_lock->start == smb_lock->start &&
69986997
cmp_lock->end == smb_lock->end &&
69996998
!lock_defer_pending(cmp_lock->fl)) {
@@ -7010,7 +7009,7 @@ int smb2_lock(struct ksmbd_work *work)
70107009
continue;
70117010
}
70127011

7013-
if (cmp_lock->fl->fl_file == smb_lock->fl->fl_file) {
7012+
if (cmp_lock->fl->c.flc_file == smb_lock->fl->c.flc_file) {
70147013
if (smb_lock->flags & SMB2_LOCKFLAG_SHARED)
70157014
continue;
70167015
} else {
@@ -7176,7 +7175,7 @@ int smb2_lock(struct ksmbd_work *work)
71767175
struct file_lock *rlock = NULL;
71777176

71787177
rlock = smb_flock_init(filp);
7179-
rlock->fl_type = F_UNLCK;
7178+
rlock->c.flc_type = F_UNLCK;
71807179
rlock->fl_start = smb_lock->start;
71817180
rlock->fl_end = smb_lock->end;
71827181

fs/smb/server/vfs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <linux/kernel.h>
88
#include <linux/fs.h>
9-
#define _NEED_FILE_LOCK_FIELD_MACROS
109
#include <linux/filelock.h>
1110
#include <linux/uaccess.h>
1211
#include <linux/backing-dev.h>
@@ -349,7 +348,7 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end,
349348
}
350349
} else if (lock_is_write(flock)) {
351350
/* check owner in lock */
352-
if (flock->fl_file != filp) {
351+
if (flock->c.flc_file != filp) {
353352
error = 1;
354353
pr_err("not allow rw access by exclusive lock from other opens\n");
355354
goto out;
@@ -1838,13 +1837,13 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
18381837

18391838
void ksmbd_vfs_posix_lock_wait(struct file_lock *flock)
18401839
{
1841-
wait_event(flock->fl_wait, !flock->fl_blocker);
1840+
wait_event(flock->c.flc_wait, !flock->c.flc_blocker);
18421841
}
18431842

18441843
int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout)
18451844
{
1846-
return wait_event_interruptible_timeout(flock->fl_wait,
1847-
!flock->fl_blocker,
1845+
return wait_event_interruptible_timeout(flock->c.flc_wait,
1846+
!flock->c.flc_blocker,
18481847
timeout);
18491848
}
18501849

0 commit comments

Comments
 (0)