Skip to content

Commit dd1fac6

Browse files
jtlaytonbrauner
authored andcommitted
nfs: 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 eb8ed7c commit dd1fac6

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

fs/nfs/delegation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_state
157157
spin_lock(&flctx->flc_lock);
158158
restart:
159159
for_each_file_lock(fl, list) {
160-
if (nfs_file_open_context(fl->fl_file)->state != state)
160+
if (nfs_file_open_context(fl->c.flc_file)->state != state)
161161
continue;
162162
spin_unlock(&flctx->flc_lock);
163163
status = nfs4_lock_delegation_recall(fl, state, stateid);

fs/nfs/file.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <linux/swap.h>
3232

3333
#include <linux/uaccess.h>
34-
#define _NEED_FILE_LOCK_FIELD_MACROS
3534
#include <linux/filelock.h>
3635

3736
#include "delegation.h"
@@ -721,15 +720,15 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
721720
{
722721
struct inode *inode = filp->f_mapping->host;
723722
int status = 0;
724-
unsigned int saved_type = fl->fl_type;
723+
unsigned int saved_type = fl->c.flc_type;
725724

726725
/* Try local locking first */
727726
posix_test_lock(filp, fl);
728-
if (fl->fl_type != F_UNLCK) {
727+
if (fl->c.flc_type != F_UNLCK) {
729728
/* found a conflict */
730729
goto out;
731730
}
732-
fl->fl_type = saved_type;
731+
fl->c.flc_type = saved_type;
733732

734733
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
735734
goto out_noconflict;
@@ -741,7 +740,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
741740
out:
742741
return status;
743742
out_noconflict:
744-
fl->fl_type = F_UNLCK;
743+
fl->c.flc_type = F_UNLCK;
745744
goto out;
746745
}
747746

@@ -766,7 +765,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
766765
* If we're signalled while cleaning up locks on process exit, we
767766
* still need to complete the unlock.
768767
*/
769-
if (status < 0 && !(fl->fl_flags & FL_CLOSE))
768+
if (status < 0 && !(fl->c.flc_flags & FL_CLOSE))
770769
return status;
771770
}
772771

@@ -833,12 +832,12 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
833832
int is_local = 0;
834833

835834
dprintk("NFS: lock(%pD2, t=%x, fl=%x, r=%lld:%lld)\n",
836-
filp, fl->fl_type, fl->fl_flags,
835+
filp, fl->c.flc_type, fl->c.flc_flags,
837836
(long long)fl->fl_start, (long long)fl->fl_end);
838837

839838
nfs_inc_stats(inode, NFSIOS_VFSLOCK);
840839

841-
if (fl->fl_flags & FL_RECLAIM)
840+
if (fl->c.flc_flags & FL_RECLAIM)
842841
return -ENOGRACE;
843842

844843
if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FCNTL)
@@ -870,9 +869,9 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
870869
int is_local = 0;
871870

872871
dprintk("NFS: flock(%pD2, t=%x, fl=%x)\n",
873-
filp, fl->fl_type, fl->fl_flags);
872+
filp, fl->c.flc_type, fl->c.flc_flags);
874873

875-
if (!(fl->fl_flags & FL_FLOCK))
874+
if (!(fl->c.flc_flags & FL_FLOCK))
876875
return -ENOLCK;
877876

878877
if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FLOCK)

fs/nfs/nfs3proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
963963
struct nfs_open_context *ctx = nfs_file_open_context(filp);
964964
int status;
965965

966-
if (fl->fl_flags & FL_CLOSE) {
966+
if (fl->c.flc_flags & FL_CLOSE) {
967967
l_ctx = nfs_get_lock_context(ctx);
968968
if (IS_ERR(l_ctx))
969969
l_ctx = NULL;

fs/nfs/nfs4_fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#define NFS4_MAX_LOOP_ON_RECOVER (10)
2424

2525
#include <linux/seqlock.h>
26-
#define _NEED_FILE_LOCK_FIELD_MACROS
2726
#include <linux/filelock.h>
2827

2928
struct idmap;

fs/nfs/nfs4proc.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6800,7 +6800,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
68006800
status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
68016801
switch (status) {
68026802
case 0:
6803-
request->fl_type = F_UNLCK;
6803+
request->c.flc_type = F_UNLCK;
68046804
break;
68056805
case -NFS4ERR_DENIED:
68066806
status = 0;
@@ -7018,8 +7018,8 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
70187018
/* Ensure this is an unlock - when canceling a lock, the
70197019
* canceled lock is passed in, and it won't be an unlock.
70207020
*/
7021-
fl->fl_type = F_UNLCK;
7022-
if (fl->fl_flags & FL_CLOSE)
7021+
fl->c.flc_type = F_UNLCK;
7022+
if (fl->c.flc_flags & FL_CLOSE)
70237023
set_bit(NFS_CONTEXT_UNLOCK, &ctx->flags);
70247024

70257025
data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid);
@@ -7045,11 +7045,11 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
70457045
struct rpc_task *task;
70467046
struct nfs_seqid *(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
70477047
int status = 0;
7048-
unsigned char saved_flags = request->fl_flags;
7048+
unsigned char saved_flags = request->c.flc_flags;
70497049

70507050
status = nfs4_set_lock_state(state, request);
70517051
/* Unlock _before_ we do the RPC call */
7052-
request->fl_flags |= FL_EXISTS;
7052+
request->c.flc_flags |= FL_EXISTS;
70537053
/* Exclude nfs_delegation_claim_locks() */
70547054
mutex_lock(&sp->so_delegreturn_mutex);
70557055
/* Exclude nfs4_reclaim_open_stateid() - note nesting! */
@@ -7073,14 +7073,16 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
70737073
status = -ENOMEM;
70747074
if (IS_ERR(seqid))
70757075
goto out;
7076-
task = nfs4_do_unlck(request, nfs_file_open_context(request->fl_file), lsp, seqid);
7076+
task = nfs4_do_unlck(request,
7077+
nfs_file_open_context(request->c.flc_file),
7078+
lsp, seqid);
70777079
status = PTR_ERR(task);
70787080
if (IS_ERR(task))
70797081
goto out;
70807082
status = rpc_wait_for_completion_task(task);
70817083
rpc_put_task(task);
70827084
out:
7083-
request->fl_flags = saved_flags;
7085+
request->c.flc_flags = saved_flags;
70847086
trace_nfs4_unlock(request, state, F_SETLK, status);
70857087
return status;
70867088
}
@@ -7191,7 +7193,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
71917193
renew_lease(NFS_SERVER(d_inode(data->ctx->dentry)),
71927194
data->timestamp);
71937195
if (data->arg.new_lock && !data->cancelled) {
7194-
data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS);
7196+
data->fl.c.flc_flags &= ~(FL_SLEEP | FL_ACCESS);
71957197
if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0)
71967198
goto out_restart;
71977199
}
@@ -7292,7 +7294,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
72927294
if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE))
72937295
task_setup_data.flags |= RPC_TASK_MOVEABLE;
72947296

7295-
data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file),
7297+
data = nfs4_alloc_lockdata(fl,
7298+
nfs_file_open_context(fl->c.flc_file),
72967299
fl->fl_u.nfs4_fl.owner, GFP_KERNEL);
72977300
if (data == NULL)
72987301
return -ENOMEM;
@@ -7398,10 +7401,10 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
73987401
{
73997402
struct nfs_inode *nfsi = NFS_I(state->inode);
74007403
struct nfs4_state_owner *sp = state->owner;
7401-
unsigned char flags = request->fl_flags;
7404+
unsigned char flags = request->c.flc_flags;
74027405
int status;
74037406

7404-
request->fl_flags |= FL_ACCESS;
7407+
request->c.flc_flags |= FL_ACCESS;
74057408
status = locks_lock_inode_wait(state->inode, request);
74067409
if (status < 0)
74077410
goto out;
@@ -7410,7 +7413,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
74107413
if (test_bit(NFS_DELEGATED_STATE, &state->flags)) {
74117414
/* Yes: cache locks! */
74127415
/* ...but avoid races with delegation recall... */
7413-
request->fl_flags = flags & ~FL_SLEEP;
7416+
request->c.flc_flags = flags & ~FL_SLEEP;
74147417
status = locks_lock_inode_wait(state->inode, request);
74157418
up_read(&nfsi->rwsem);
74167419
mutex_unlock(&sp->so_delegreturn_mutex);
@@ -7420,7 +7423,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
74207423
mutex_unlock(&sp->so_delegreturn_mutex);
74217424
status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW);
74227425
out:
7423-
request->fl_flags = flags;
7426+
request->c.flc_flags = flags;
74247427
return status;
74257428
}
74267429

@@ -7571,15 +7574,15 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
75717574
if (state == NULL)
75727575
return -ENOLCK;
75737576

7574-
if ((request->fl_flags & FL_POSIX) &&
7577+
if ((request->c.flc_flags & FL_POSIX) &&
75757578
!test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
75767579
return -ENOLCK;
75777580

75787581
/*
75797582
* Don't rely on the VFS having checked the file open mode,
75807583
* since it won't do this for flock() locks.
75817584
*/
7582-
switch (request->fl_type) {
7585+
switch (request->c.flc_type) {
75837586
case F_RDLCK:
75847587
if (!(filp->f_mode & FMODE_READ))
75857588
return -EBADF;

fs/nfs/nfs4state.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl)
980980

981981
if (fl->fl_ops != NULL)
982982
return 0;
983-
lsp = nfs4_get_lock_state(state, fl->fl_owner);
983+
lsp = nfs4_get_lock_state(state, fl->c.flc_owner);
984984
if (lsp == NULL)
985985
return -ENOMEM;
986986
fl->fl_u.nfs4_fl.owner = lsp;
@@ -1530,7 +1530,7 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
15301530
spin_lock(&flctx->flc_lock);
15311531
restart:
15321532
for_each_file_lock(fl, list) {
1533-
if (nfs_file_open_context(fl->fl_file)->state != state)
1533+
if (nfs_file_open_context(fl->c.flc_file)->state != state)
15341534
continue;
15351535
spin_unlock(&flctx->flc_lock);
15361536
status = ops->recover_lock(state, fl);

fs/nfs/nfs4trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ DECLARE_EVENT_CLASS(nfs4_lock_event,
699699

700700
__entry->error = error < 0 ? -error : 0;
701701
__entry->cmd = cmd;
702-
__entry->type = request->fl_type;
702+
__entry->type = request->c.flc_type;
703703
__entry->start = request->fl_start;
704704
__entry->end = request->fl_end;
705705
__entry->dev = inode->i_sb->s_dev;
@@ -771,7 +771,7 @@ TRACE_EVENT(nfs4_set_lock,
771771

772772
__entry->error = error < 0 ? -error : 0;
773773
__entry->cmd = cmd;
774-
__entry->type = request->fl_type;
774+
__entry->type = request->c.flc_type;
775775
__entry->start = request->fl_start;
776776
__entry->end = request->fl_end;
777777
__entry->dev = inode->i_sb->s_dev;

fs/nfs/nfs4xdr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5052,10 +5052,10 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
50525052
fl->fl_end = fl->fl_start + (loff_t)length - 1;
50535053
if (length == ~(uint64_t)0)
50545054
fl->fl_end = OFFSET_MAX;
5055-
fl->fl_type = F_WRLCK;
5055+
fl->c.flc_type = F_WRLCK;
50565056
if (type & 1)
5057-
fl->fl_type = F_RDLCK;
5058-
fl->fl_pid = 0;
5057+
fl->c.flc_type = F_RDLCK;
5058+
fl->c.flc_pid = 0;
50595059
}
50605060
p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
50615061
namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */

fs/nfs/write.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/freezer.h>
2626
#include <linux/wait.h>
2727
#include <linux/iversion.h>
28-
#define _NEED_FILE_LOCK_FIELD_MACROS
2928
#include <linux/filelock.h>
3029

3130
#include <linux/uaccess.h>
@@ -1336,12 +1335,12 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio,
13361335
spin_lock(&flctx->flc_lock);
13371336
if (!list_empty(&flctx->flc_posix)) {
13381337
fl = list_first_entry(&flctx->flc_posix, struct file_lock,
1339-
fl_list);
1338+
c.flc_list);
13401339
if (is_whole_file_wrlock(fl))
13411340
ret = 1;
13421341
} else if (!list_empty(&flctx->flc_flock)) {
13431342
fl = list_first_entry(&flctx->flc_flock, struct file_lock,
1344-
fl_list);
1343+
c.flc_list);
13451344
if (lock_is_write(fl))
13461345
ret = 1;
13471346
}

0 commit comments

Comments
 (0)