Skip to content

Commit 8bda955

Browse files
committed
Merge tag 'nfsd-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd updates from Chuck Lever: "New features: - Support for server-side disconnect injection via debugfs - Protocol definitions for new RPC_AUTH_TLS authentication flavor Performance improvements: - Reduce page allocator traffic in the NFSD splice read actor - Reduce CPU utilization in svcrdma's Send completion handler Notable bug fixes: - Stabilize lockd operation when re-exporting NFS mounts - Fix the use of %.*s in NFSD tracepoints - Fix /proc/sys/fs/nfs/nsm_use_hostnames" * tag 'nfsd-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (31 commits) nfsd: fix crash on LOCKT on reexported NFSv3 nfs: don't allow reexport reclaims lockd: don't attempt blocking locks on nfs reexports nfs: don't atempt blocking locks on nfs reexports Keep read and write fds with each nlm_file lockd: update nlm_lookup_file reexport comment nlm: minor refactoring nlm: minor nlm_lookup_file argument change lockd: lockd server-side shouldn't set fl_ops SUNRPC: Add documentation for the fail_sunrpc/ directory SUNRPC: Server-side disconnect injection SUNRPC: Move client-side disconnect injection SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory svcrdma: xpt_bc_xprt is already clear in __svc_rdma_free() nfsd4: Fix forced-expiry locking rpc: fix gss_svc_init cleanup on failure SUNRPC: Add RPC_AUTH_TLS protocol numbers lockd: change the proc_handler for nsm_use_hostnames sysctl: introduce new proc handler proc_dobool SUNRPC: Fix a NULL pointer deref in trace_svc_stats_latency() ...
2 parents 4529fb1 + 0bcc7ca commit 8bda955

39 files changed

+489
-240
lines changed

Documentation/fault-injection/fault-injection.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Available fault injection capabilities
2424

2525
injects futex deadlock and uaddr fault errors.
2626

27+
- fail_sunrpc
28+
29+
injects kernel RPC client and server failures.
30+
2731
- fail_make_request
2832

2933
injects disk IO errors on devices permitted by setting
@@ -151,6 +155,20 @@ configuration of fault-injection capabilities.
151155
default is 'N', setting it to 'Y' will disable failure injections
152156
when dealing with private (address space) futexes.
153157

158+
- /sys/kernel/debug/fail_sunrpc/ignore-client-disconnect:
159+
160+
Format: { 'Y' | 'N' }
161+
162+
default is 'N', setting it to 'Y' will disable disconnect
163+
injection on the RPC client.
164+
165+
- /sys/kernel/debug/fail_sunrpc/ignore-server-disconnect:
166+
167+
Format: { 'Y' | 'N' }
168+
169+
default is 'N', setting it to 'Y' will disable disconnect
170+
injection on the RPC server.
171+
154172
- /sys/kernel/debug/fail_function/inject:
155173

156174
Format: { 'function-name' | '!function-name' | '' }

fs/lockd/svc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static struct ctl_table nlm_sysctls[] = {
584584
.data = &nsm_use_hostnames,
585585
.maxlen = sizeof(int),
586586
.mode = 0644,
587-
.proc_handler = proc_dointvec,
587+
.proc_handler = proc_dobool,
588588
},
589589
{
590590
.procname = "nsm_local_state",

fs/lockd/svc4proc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
4040

4141
/* Obtain file pointer. Not used by FREE_ALL call. */
4242
if (filp != NULL) {
43-
if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0)
43+
int mode = lock_to_openmode(&lock->fl);
44+
45+
error = nlm_lookup_file(rqstp, &file, lock);
46+
if (error)
4447
goto no_locks;
4548
*filp = file;
4649

4750
/* Set up the missing parts of the file_lock structure */
48-
lock->fl.fl_file = file->f_file;
51+
lock->fl.fl_file = file->f_file[mode];
4952
lock->fl.fl_pid = current->tgid;
5053
lock->fl.fl_lmops = &nlmsvc_lock_operations;
5154
nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);

fs/lockd/svclock.c

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/lockd/nlm.h>
3232
#include <linux/lockd/lockd.h>
3333
#include <linux/kthread.h>
34+
#include <linux/exportfs.h>
3435

3536
#define NLMDBG_FACILITY NLMDBG_SVCLOCK
3637

@@ -395,28 +396,10 @@ nlmsvc_release_lockowner(struct nlm_lock *lock)
395396
nlmsvc_put_lockowner(lock->fl.fl_owner);
396397
}
397398

398-
static void nlmsvc_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
399-
{
400-
struct nlm_lockowner *nlm_lo = (struct nlm_lockowner *)fl->fl_owner;
401-
new->fl_owner = nlmsvc_get_lockowner(nlm_lo);
402-
}
403-
404-
static void nlmsvc_locks_release_private(struct file_lock *fl)
405-
{
406-
nlmsvc_put_lockowner((struct nlm_lockowner *)fl->fl_owner);
407-
}
408-
409-
static const struct file_lock_operations nlmsvc_lock_ops = {
410-
.fl_copy_lock = nlmsvc_locks_copy_lock,
411-
.fl_release_private = nlmsvc_locks_release_private,
412-
};
413-
414399
void nlmsvc_locks_init_private(struct file_lock *fl, struct nlm_host *host,
415400
pid_t pid)
416401
{
417402
fl->fl_owner = nlmsvc_find_lockowner(host, pid);
418-
if (fl->fl_owner != NULL)
419-
fl->fl_ops = &nlmsvc_lock_ops;
420403
}
421404

422405
/*
@@ -488,17 +471,24 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
488471
struct nlm_cookie *cookie, int reclaim)
489472
{
490473
struct nlm_block *block = NULL;
474+
struct inode *inode = nlmsvc_file_inode(file);
491475
int error;
476+
int mode;
477+
int async_block = 0;
492478
__be32 ret;
493479

494480
dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
495-
locks_inode(file->f_file)->i_sb->s_id,
496-
locks_inode(file->f_file)->i_ino,
481+
inode->i_sb->s_id, inode->i_ino,
497482
lock->fl.fl_type, lock->fl.fl_pid,
498483
(long long)lock->fl.fl_start,
499484
(long long)lock->fl.fl_end,
500485
wait);
501486

487+
if (inode->i_sb->s_export_op->flags & EXPORT_OP_SYNC_LOCKS) {
488+
async_block = wait;
489+
wait = 0;
490+
}
491+
502492
/* Lock file against concurrent access */
503493
mutex_lock(&file->f_mutex);
504494
/* Get existing block (in case client is busy-waiting)
@@ -542,7 +532,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
542532

543533
if (!wait)
544534
lock->fl.fl_flags &= ~FL_SLEEP;
545-
error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL);
535+
mode = lock_to_openmode(&lock->fl);
536+
error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL);
546537
lock->fl.fl_flags &= ~FL_SLEEP;
547538

548539
dprintk("lockd: vfs_lock_file returned %d\n", error);
@@ -558,7 +549,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
558549
*/
559550
if (wait)
560551
break;
561-
ret = nlm_lck_denied;
552+
ret = async_block ? nlm_lck_blocked : nlm_lck_denied;
562553
goto out;
563554
case FILE_LOCK_DEFERRED:
564555
if (wait)
@@ -595,12 +586,13 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
595586
struct nlm_lock *conflock, struct nlm_cookie *cookie)
596587
{
597588
int error;
589+
int mode;
598590
__be32 ret;
599591
struct nlm_lockowner *test_owner;
600592

601593
dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
602-
locks_inode(file->f_file)->i_sb->s_id,
603-
locks_inode(file->f_file)->i_ino,
594+
nlmsvc_file_inode(file)->i_sb->s_id,
595+
nlmsvc_file_inode(file)->i_ino,
604596
lock->fl.fl_type,
605597
(long long)lock->fl.fl_start,
606598
(long long)lock->fl.fl_end);
@@ -613,7 +605,8 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
613605
/* If there's a conflicting lock, remember to clean up the test lock */
614606
test_owner = (struct nlm_lockowner *)lock->fl.fl_owner;
615607

616-
error = vfs_test_lock(file->f_file, &lock->fl);
608+
mode = lock_to_openmode(&lock->fl);
609+
error = vfs_test_lock(file->f_file[mode], &lock->fl);
617610
if (error) {
618611
/* We can't currently deal with deferred test requests */
619612
if (error == FILE_LOCK_DEFERRED)
@@ -634,7 +627,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
634627
conflock->caller = "somehost"; /* FIXME */
635628
conflock->len = strlen(conflock->caller);
636629
conflock->oh.len = 0; /* don't return OH info */
637-
conflock->svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid;
630+
conflock->svid = lock->fl.fl_pid;
638631
conflock->fl.fl_type = lock->fl.fl_type;
639632
conflock->fl.fl_start = lock->fl.fl_start;
640633
conflock->fl.fl_end = lock->fl.fl_end;
@@ -659,11 +652,11 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
659652
__be32
660653
nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock)
661654
{
662-
int error;
655+
int error = 0;
663656

664657
dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
665-
locks_inode(file->f_file)->i_sb->s_id,
666-
locks_inode(file->f_file)->i_ino,
658+
nlmsvc_file_inode(file)->i_sb->s_id,
659+
nlmsvc_file_inode(file)->i_ino,
667660
lock->fl.fl_pid,
668661
(long long)lock->fl.fl_start,
669662
(long long)lock->fl.fl_end);
@@ -672,7 +665,12 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock)
672665
nlmsvc_cancel_blocked(net, file, lock);
673666

674667
lock->fl.fl_type = F_UNLCK;
675-
error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL);
668+
if (file->f_file[O_RDONLY])
669+
error = vfs_lock_file(file->f_file[O_RDONLY], F_SETLK,
670+
&lock->fl, NULL);
671+
if (file->f_file[O_WRONLY])
672+
error = vfs_lock_file(file->f_file[O_WRONLY], F_SETLK,
673+
&lock->fl, NULL);
676674

677675
return (error < 0)? nlm_lck_denied_nolocks : nlm_granted;
678676
}
@@ -689,10 +687,11 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l
689687
{
690688
struct nlm_block *block;
691689
int status = 0;
690+
int mode;
692691

693692
dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
694-
locks_inode(file->f_file)->i_sb->s_id,
695-
locks_inode(file->f_file)->i_ino,
693+
nlmsvc_file_inode(file)->i_sb->s_id,
694+
nlmsvc_file_inode(file)->i_ino,
696695
lock->fl.fl_pid,
697696
(long long)lock->fl.fl_start,
698697
(long long)lock->fl.fl_end);
@@ -704,7 +703,8 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l
704703
block = nlmsvc_lookup_block(file, lock);
705704
mutex_unlock(&file->f_mutex);
706705
if (block != NULL) {
707-
vfs_cancel_lock(block->b_file->f_file,
706+
mode = lock_to_openmode(&lock->fl);
707+
vfs_cancel_lock(block->b_file->f_file[mode],
708708
&block->b_call->a_args.lock.fl);
709709
status = nlmsvc_unlink_block(block);
710710
nlmsvc_release_block(block);
@@ -788,9 +788,21 @@ nlmsvc_notify_blocked(struct file_lock *fl)
788788
printk(KERN_WARNING "lockd: notification for unknown block!\n");
789789
}
790790

791+
static fl_owner_t nlmsvc_get_owner(fl_owner_t owner)
792+
{
793+
return nlmsvc_get_lockowner(owner);
794+
}
795+
796+
static void nlmsvc_put_owner(fl_owner_t owner)
797+
{
798+
nlmsvc_put_lockowner(owner);
799+
}
800+
791801
const struct lock_manager_operations nlmsvc_lock_operations = {
792802
.lm_notify = nlmsvc_notify_blocked,
793803
.lm_grant = nlmsvc_grant_deferred,
804+
.lm_get_owner = nlmsvc_get_owner,
805+
.lm_put_owner = nlmsvc_put_owner,
794806
};
795807

796808
/*
@@ -809,6 +821,7 @@ nlmsvc_grant_blocked(struct nlm_block *block)
809821
{
810822
struct nlm_file *file = block->b_file;
811823
struct nlm_lock *lock = &block->b_call->a_args.lock;
824+
int mode;
812825
int error;
813826
loff_t fl_start, fl_end;
814827

@@ -834,7 +847,8 @@ nlmsvc_grant_blocked(struct nlm_block *block)
834847
lock->fl.fl_flags |= FL_SLEEP;
835848
fl_start = lock->fl.fl_start;
836849
fl_end = lock->fl.fl_end;
837-
error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL);
850+
mode = lock_to_openmode(&lock->fl);
851+
error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL);
838852
lock->fl.fl_flags &= ~FL_SLEEP;
839853
lock->fl.fl_start = fl_start;
840854
lock->fl.fl_end = fl_end;

fs/lockd/svcproc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
5555
struct nlm_host *host = NULL;
5656
struct nlm_file *file = NULL;
5757
struct nlm_lock *lock = &argp->lock;
58+
int mode;
5859
__be32 error = 0;
5960

6061
/* nfsd callbacks must have been installed for this procedure */
@@ -69,13 +70,14 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
6970

7071
/* Obtain file pointer. Not used by FREE_ALL call. */
7172
if (filp != NULL) {
72-
error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh));
73+
error = cast_status(nlm_lookup_file(rqstp, &file, lock));
7374
if (error != 0)
7475
goto no_locks;
7576
*filp = file;
7677

7778
/* Set up the missing parts of the file_lock structure */
78-
lock->fl.fl_file = file->f_file;
79+
mode = lock_to_openmode(&lock->fl);
80+
lock->fl.fl_file = file->f_file[mode];
7981
lock->fl.fl_pid = current->tgid;
8082
lock->fl.fl_lmops = &nlmsvc_lock_operations;
8183
nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);

0 commit comments

Comments
 (0)