Skip to content

Commit eb8ed7c

Browse files
jtlaytonbrauner
authored andcommitted
lockd: 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 9a7eec4 commit eb8ed7c

File tree

12 files changed

+119
-114
lines changed

12 files changed

+119
-114
lines changed

fs/lockd/clnt4xdr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static void encode_nlm4_holder(struct xdr_stream *xdr,
243243
u64 l_offset, l_len;
244244
__be32 *p;
245245

246-
encode_bool(xdr, lock->fl.fl_type == F_RDLCK);
246+
encode_bool(xdr, lock->fl.c.flc_type == F_RDLCK);
247247
encode_int32(xdr, lock->svid);
248248
encode_netobj(xdr, lock->oh.data, lock->oh.len);
249249

@@ -270,7 +270,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
270270
goto out_overflow;
271271
exclusive = be32_to_cpup(p++);
272272
lock->svid = be32_to_cpup(p);
273-
fl->fl_pid = (pid_t)lock->svid;
273+
fl->c.flc_pid = (pid_t)lock->svid;
274274

275275
error = decode_netobj(xdr, &lock->oh);
276276
if (unlikely(error))
@@ -280,8 +280,8 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
280280
if (unlikely(p == NULL))
281281
goto out_overflow;
282282

283-
fl->fl_flags = FL_POSIX;
284-
fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
283+
fl->c.flc_flags = FL_POSIX;
284+
fl->c.flc_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
285285
p = xdr_decode_hyper(p, &l_offset);
286286
xdr_decode_hyper(p, &l_len);
287287
nlm4svc_set_file_lock_range(fl, l_offset, l_len);
@@ -357,7 +357,7 @@ static void nlm4_xdr_enc_testargs(struct rpc_rqst *req,
357357
const struct nlm_lock *lock = &args->lock;
358358

359359
encode_cookie(xdr, &args->cookie);
360-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
360+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
361361
encode_nlm4_lock(xdr, lock);
362362
}
363363

@@ -380,7 +380,7 @@ static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req,
380380

381381
encode_cookie(xdr, &args->cookie);
382382
encode_bool(xdr, args->block);
383-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
383+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
384384
encode_nlm4_lock(xdr, lock);
385385
encode_bool(xdr, args->reclaim);
386386
encode_int32(xdr, args->state);
@@ -403,7 +403,7 @@ static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req,
403403

404404
encode_cookie(xdr, &args->cookie);
405405
encode_bool(xdr, args->block);
406-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
406+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
407407
encode_nlm4_lock(xdr, lock);
408408
}
409409

fs/lockd/clntlock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
185185
continue;
186186
if (!rpc_cmp_addr(nlm_addr(block->b_host), addr))
187187
continue;
188-
if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->fl_file)), fh) != 0)
188+
if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->c.flc_file)), fh) != 0)
189189
continue;
190190
/* Alright, we found a lock. Set the return status
191191
* and wake up the caller

fs/lockd/clntproc.c

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/types.h>
1313
#include <linux/errno.h>
1414
#include <linux/fs.h>
15-
#define _NEED_FILE_LOCK_FIELD_MACROS
1615
#include <linux/filelock.h>
1716
#include <linux/nfs_fs.h>
1817
#include <linux/utsname.h>
@@ -134,7 +133,8 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
134133
char *nodename = req->a_host->h_rpcclnt->cl_nodename;
135134

136135
nlmclnt_next_cookie(&argp->cookie);
137-
memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh));
136+
memcpy(&lock->fh, NFS_FH(file_inode(fl->c.flc_file)),
137+
sizeof(struct nfs_fh));
138138
lock->caller = nodename;
139139
lock->oh.data = req->a_owner;
140140
lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
@@ -143,7 +143,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
143143
lock->svid = fl->fl_u.nfs_fl.owner->pid;
144144
lock->fl.fl_start = fl->fl_start;
145145
lock->fl.fl_end = fl->fl_end;
146-
lock->fl.fl_type = fl->fl_type;
146+
lock->fl.c.flc_type = fl->c.flc_type;
147147
}
148148

149149
static void nlmclnt_release_lockargs(struct nlm_rqst *req)
@@ -183,7 +183,7 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *dat
183183
call->a_callback_data = data;
184184

185185
if (IS_SETLK(cmd) || IS_SETLKW(cmd)) {
186-
if (fl->fl_type != F_UNLCK) {
186+
if (fl->c.flc_type != F_UNLCK) {
187187
call->a_args.block = IS_SETLKW(cmd) ? 1 : 0;
188188
status = nlmclnt_lock(call, fl);
189189
} else
@@ -433,22 +433,23 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl)
433433
{
434434
int status;
435435

436-
status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST);
436+
status = nlmclnt_call(nfs_file_cred(fl->c.flc_file), req,
437+
NLMPROC_TEST);
437438
if (status < 0)
438439
goto out;
439440

440441
switch (req->a_res.status) {
441442
case nlm_granted:
442-
fl->fl_type = F_UNLCK;
443+
fl->c.flc_type = F_UNLCK;
443444
break;
444445
case nlm_lck_denied:
445446
/*
446447
* Report the conflicting lock back to the application.
447448
*/
448449
fl->fl_start = req->a_res.lock.fl.fl_start;
449450
fl->fl_end = req->a_res.lock.fl.fl_end;
450-
fl->fl_type = req->a_res.lock.fl.fl_type;
451-
fl->fl_pid = -req->a_res.lock.fl.fl_pid;
451+
fl->c.flc_type = req->a_res.lock.fl.c.flc_type;
452+
fl->c.flc_pid = -req->a_res.lock.fl.c.flc_pid;
452453
break;
453454
default:
454455
status = nlm_stat_to_errno(req->a_res.status);
@@ -486,14 +487,15 @@ static const struct file_lock_operations nlmclnt_lock_ops = {
486487
static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host)
487488
{
488489
fl->fl_u.nfs_fl.state = 0;
489-
fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, fl->fl_owner);
490+
fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host,
491+
fl->c.flc_owner);
490492
INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list);
491493
fl->fl_ops = &nlmclnt_lock_ops;
492494
}
493495

494496
static int do_vfs_lock(struct file_lock *fl)
495497
{
496-
return locks_lock_file_wait(fl->fl_file, fl);
498+
return locks_lock_file_wait(fl->c.flc_file, fl);
497499
}
498500

499501
/*
@@ -519,11 +521,11 @@ static int do_vfs_lock(struct file_lock *fl)
519521
static int
520522
nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
521523
{
522-
const struct cred *cred = nfs_file_cred(fl->fl_file);
524+
const struct cred *cred = nfs_file_cred(fl->c.flc_file);
523525
struct nlm_host *host = req->a_host;
524526
struct nlm_res *resp = &req->a_res;
525527
struct nlm_wait block;
526-
unsigned char flags = fl->fl_flags;
528+
unsigned char flags = fl->c.flc_flags;
527529
unsigned char type;
528530
__be32 b_status;
529531
int status = -ENOLCK;
@@ -532,9 +534,9 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
532534
goto out;
533535
req->a_args.state = nsm_local_state;
534536

535-
fl->fl_flags |= FL_ACCESS;
537+
fl->c.flc_flags |= FL_ACCESS;
536538
status = do_vfs_lock(fl);
537-
fl->fl_flags = flags;
539+
fl->c.flc_flags = flags;
538540
if (status < 0)
539541
goto out;
540542

@@ -592,11 +594,11 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
592594
goto again;
593595
}
594596
/* Ensure the resulting lock will get added to granted list */
595-
fl->fl_flags |= FL_SLEEP;
597+
fl->c.flc_flags |= FL_SLEEP;
596598
if (do_vfs_lock(fl) < 0)
597599
printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__);
598600
up_read(&host->h_rwsem);
599-
fl->fl_flags = flags;
601+
fl->c.flc_flags = flags;
600602
status = 0;
601603
}
602604
if (status < 0)
@@ -623,13 +625,13 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
623625
req->a_host->h_addrlen, req->a_res.status);
624626
dprintk("lockd: lock attempt ended in fatal error.\n"
625627
" Attempting to unlock.\n");
626-
type = fl->fl_type;
627-
fl->fl_type = F_UNLCK;
628+
type = fl->c.flc_type;
629+
fl->c.flc_type = F_UNLCK;
628630
down_read(&host->h_rwsem);
629631
do_vfs_lock(fl);
630632
up_read(&host->h_rwsem);
631-
fl->fl_type = type;
632-
fl->fl_flags = flags;
633+
fl->c.flc_type = type;
634+
fl->c.flc_flags = flags;
633635
nlmclnt_async_call(cred, req, NLMPROC_UNLOCK, &nlmclnt_unlock_ops);
634636
return status;
635637
}
@@ -652,12 +654,14 @@ nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl,
652654
nlmclnt_setlockargs(req, fl);
653655
req->a_args.reclaim = 1;
654656

655-
status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_LOCK);
657+
status = nlmclnt_call(nfs_file_cred(fl->c.flc_file), req,
658+
NLMPROC_LOCK);
656659
if (status >= 0 && req->a_res.status == nlm_granted)
657660
return 0;
658661

659662
printk(KERN_WARNING "lockd: failed to reclaim lock for pid %d "
660-
"(errno %d, status %d)\n", fl->fl_pid,
663+
"(errno %d, status %d)\n",
664+
fl->c.flc_pid,
661665
status, ntohl(req->a_res.status));
662666

663667
/*
@@ -684,26 +688,26 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
684688
struct nlm_host *host = req->a_host;
685689
struct nlm_res *resp = &req->a_res;
686690
int status;
687-
unsigned char flags = fl->fl_flags;
691+
unsigned char flags = fl->c.flc_flags;
688692

689693
/*
690694
* Note: the server is supposed to either grant us the unlock
691695
* request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either
692696
* case, we want to unlock.
693697
*/
694-
fl->fl_flags |= FL_EXISTS;
698+
fl->c.flc_flags |= FL_EXISTS;
695699
down_read(&host->h_rwsem);
696700
status = do_vfs_lock(fl);
697701
up_read(&host->h_rwsem);
698-
fl->fl_flags = flags;
702+
fl->c.flc_flags = flags;
699703
if (status == -ENOENT) {
700704
status = 0;
701705
goto out;
702706
}
703707

704708
refcount_inc(&req->a_count);
705-
status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
706-
NLMPROC_UNLOCK, &nlmclnt_unlock_ops);
709+
status = nlmclnt_async_call(nfs_file_cred(fl->c.flc_file), req,
710+
NLMPROC_UNLOCK, &nlmclnt_unlock_ops);
707711
if (status < 0)
708712
goto out;
709713

@@ -796,8 +800,8 @@ static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl
796800
req->a_args.block = block;
797801

798802
refcount_inc(&req->a_count);
799-
status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
800-
NLMPROC_CANCEL, &nlmclnt_cancel_ops);
803+
status = nlmclnt_async_call(nfs_file_cred(fl->c.flc_file), req,
804+
NLMPROC_CANCEL, &nlmclnt_cancel_ops);
801805
if (status == 0 && req->a_res.status == nlm_lck_denied)
802806
status = -ENOLCK;
803807
nlmclnt_release_call(req);

fs/lockd/clntxdr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static void encode_nlm_holder(struct xdr_stream *xdr,
238238
u32 l_offset, l_len;
239239
__be32 *p;
240240

241-
encode_bool(xdr, lock->fl.fl_type == F_RDLCK);
241+
encode_bool(xdr, lock->fl.c.flc_type == F_RDLCK);
242242
encode_int32(xdr, lock->svid);
243243
encode_netobj(xdr, lock->oh.data, lock->oh.len);
244244

@@ -265,7 +265,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result)
265265
goto out_overflow;
266266
exclusive = be32_to_cpup(p++);
267267
lock->svid = be32_to_cpup(p);
268-
fl->fl_pid = (pid_t)lock->svid;
268+
fl->c.flc_pid = (pid_t)lock->svid;
269269

270270
error = decode_netobj(xdr, &lock->oh);
271271
if (unlikely(error))
@@ -275,8 +275,8 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result)
275275
if (unlikely(p == NULL))
276276
goto out_overflow;
277277

278-
fl->fl_flags = FL_POSIX;
279-
fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
278+
fl->c.flc_flags = FL_POSIX;
279+
fl->c.flc_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
280280
l_offset = be32_to_cpup(p++);
281281
l_len = be32_to_cpup(p);
282282
end = l_offset + l_len - 1;
@@ -357,7 +357,7 @@ static void nlm_xdr_enc_testargs(struct rpc_rqst *req,
357357
const struct nlm_lock *lock = &args->lock;
358358

359359
encode_cookie(xdr, &args->cookie);
360-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
360+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
361361
encode_nlm_lock(xdr, lock);
362362
}
363363

@@ -380,7 +380,7 @@ static void nlm_xdr_enc_lockargs(struct rpc_rqst *req,
380380

381381
encode_cookie(xdr, &args->cookie);
382382
encode_bool(xdr, args->block);
383-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
383+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
384384
encode_nlm_lock(xdr, lock);
385385
encode_bool(xdr, args->reclaim);
386386
encode_int32(xdr, args->state);
@@ -403,7 +403,7 @@ static void nlm_xdr_enc_cancargs(struct rpc_rqst *req,
403403

404404
encode_cookie(xdr, &args->cookie);
405405
encode_bool(xdr, args->block);
406-
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
406+
encode_bool(xdr, lock->fl.c.flc_type == F_WRLCK);
407407
encode_nlm_lock(xdr, lock);
408408
}
409409

fs/lockd/svc4proc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
5252
*filp = file;
5353

5454
/* Set up the missing parts of the file_lock structure */
55-
lock->fl.fl_flags = FL_POSIX;
56-
lock->fl.fl_file = file->f_file[mode];
57-
lock->fl.fl_pid = current->tgid;
55+
lock->fl.c.flc_flags = FL_POSIX;
56+
lock->fl.c.flc_file = file->f_file[mode];
57+
lock->fl.c.flc_pid = current->tgid;
5858
lock->fl.fl_start = (loff_t)lock->lock_start;
5959
lock->fl.fl_end = lock->lock_len ?
6060
(loff_t)(lock->lock_start + lock->lock_len - 1) :
6161
OFFSET_MAX;
6262
lock->fl.fl_lmops = &nlmsvc_lock_operations;
6363
nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
64-
if (!lock->fl.fl_owner) {
64+
if (!lock->fl.c.flc_owner) {
6565
/* lockowner allocation has failed */
6666
nlmsvc_release_host(host);
6767
return nlm_lck_denied_nolocks;
@@ -106,7 +106,7 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
106106
if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
107107
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
108108

109-
test_owner = argp->lock.fl.fl_owner;
109+
test_owner = argp->lock.fl.c.flc_owner;
110110
/* Now check for conflicting locks */
111111
resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie);
112112
if (resp->status == nlm_drop_reply)

0 commit comments

Comments
 (0)