Skip to content

Commit 4dd3c2e

Browse files
committed
Merge tag 'nfsd-4.15' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "Lots of good bugfixes, including: - fix a number of races in the NFSv4+ state code - fix some shutdown crashes in multiple-network-namespace cases - relax our 4.1 session limits; if you've an artificially low limit to the number of 4.1 clients that can mount simultaneously, try upgrading" * tag 'nfsd-4.15' of git://linux-nfs.org/~bfields/linux: (22 commits) SUNRPC: Improve ordering of transport processing nfsd: deal with revoked delegations appropriately svcrdma: Enqueue after setting XPT_CLOSE in completion handlers nfsd: use nfs->ns.inum as net ID rpc: remove some BUG()s svcrdma: Preserve CB send buffer across retransmits nfds: avoid gettimeofday for nfssvc_boot time fs, nfsd: convert nfs4_file.fi_ref from atomic_t to refcount_t fs, nfsd: convert nfs4_cntl_odstate.co_odcount from atomic_t to refcount_t fs, nfsd: convert nfs4_stid.sc_count from atomic_t to refcount_t lockd: double unregister of inetaddr notifiers nfsd4: catch some false session retries nfsd4: fix cached replies to solo SEQUENCE compounds sunrcp: make function _svc_create_xprt static SUNRPC: Fix tracepoint storage issues with svc_recv and svc_rqst_status nfsd: use ARRAY_SIZE nfsd: give out fewer session slots as limit approaches nfsd: increase DRC cache limit nfsd: remove unnecessary nofilehandle checks nfs_common: convert int to bool ...
2 parents 07c455e + 22700f3 commit 4dd3c2e

File tree

18 files changed

+225
-173
lines changed

18 files changed

+225
-173
lines changed

fs/lockd/svc.c

+9-11
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ static int lockd_start_svc(struct svc_serv *serv)
369369
printk(KERN_WARNING
370370
"lockd_up: svc_rqst allocation failed, error=%d\n",
371371
error);
372+
lockd_unregister_notifiers();
372373
goto out_rqst;
373374
}
374375

@@ -459,13 +460,16 @@ int lockd_up(struct net *net)
459460
}
460461

461462
error = lockd_up_net(serv, net);
462-
if (error < 0)
463-
goto err_net;
463+
if (error < 0) {
464+
lockd_unregister_notifiers();
465+
goto err_put;
466+
}
464467

465468
error = lockd_start_svc(serv);
466-
if (error < 0)
467-
goto err_start;
468-
469+
if (error < 0) {
470+
lockd_down_net(serv, net);
471+
goto err_put;
472+
}
469473
nlmsvc_users++;
470474
/*
471475
* Note: svc_serv structures have an initial use count of 1,
@@ -476,12 +480,6 @@ int lockd_up(struct net *net)
476480
err_create:
477481
mutex_unlock(&nlmsvc_mutex);
478482
return error;
479-
480-
err_start:
481-
lockd_down_net(serv, net);
482-
err_net:
483-
lockd_unregister_notifiers();
484-
goto err_put;
485483
}
486484
EXPORT_SYMBOL_GPL(lockd_up);
487485

fs/nfs_common/grace.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ locks_end_grace(struct lock_manager *lm)
5555
}
5656
EXPORT_SYMBOL_GPL(locks_end_grace);
5757

58-
/**
59-
* locks_in_grace
60-
*
61-
* Lock managers call this function to determine when it is OK for them
62-
* to answer ordinary lock requests, and when they should accept only
63-
* lock reclaims.
64-
*/
65-
int
58+
static bool
6659
__state_in_grace(struct net *net, bool open)
6760
{
6861
struct list_head *grace_list = net_generic(net, grace_net_id);
@@ -78,15 +71,22 @@ __state_in_grace(struct net *net, bool open)
7871
return false;
7972
}
8073

81-
int locks_in_grace(struct net *net)
74+
/**
75+
* locks_in_grace
76+
*
77+
* Lock managers call this function to determine when it is OK for them
78+
* to answer ordinary lock requests, and when they should accept only
79+
* lock reclaims.
80+
*/
81+
bool locks_in_grace(struct net *net)
8282
{
83-
return __state_in_grace(net, 0);
83+
return __state_in_grace(net, false);
8484
}
8585
EXPORT_SYMBOL_GPL(locks_in_grace);
8686

87-
int opens_in_grace(struct net *net)
87+
bool opens_in_grace(struct net *net)
8888
{
89-
return __state_in_grace(net, 1);
89+
return __state_in_grace(net, true);
9090
}
9191
EXPORT_SYMBOL_GPL(opens_in_grace);
9292

fs/nfsd/fault_inject.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/nsproxy.h>
1313
#include <linux/sunrpc/addr.h>
1414
#include <linux/uaccess.h>
15+
#include <linux/kernel.h>
1516

1617
#include "state.h"
1718
#include "netns.h"
@@ -126,8 +127,6 @@ static struct nfsd_fault_inject_op inject_ops[] = {
126127
},
127128
};
128129

129-
#define NUM_INJECT_OPS (sizeof(inject_ops)/sizeof(struct nfsd_fault_inject_op))
130-
131130
int nfsd_fault_inject_init(void)
132131
{
133132
unsigned int i;
@@ -138,7 +137,7 @@ int nfsd_fault_inject_init(void)
138137
if (!debug_dir)
139138
goto fail;
140139

141-
for (i = 0; i < NUM_INJECT_OPS; i++) {
140+
for (i = 0; i < ARRAY_SIZE(inject_ops); i++) {
142141
op = &inject_ops[i];
143142
if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
144143
goto fail;

fs/nfsd/netns.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct nfsd_net {
107107
bool lockd_up;
108108

109109
/* Time of server startup */
110-
struct timeval nfssvc_boot;
110+
struct timespec64 nfssvc_boot;
111111

112112
/*
113113
* Max number of connections this nfsd container will allow. Defaults

fs/nfsd/nfs3xdr.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,9 @@ nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
748748
if (resp->status == 0) {
749749
*p++ = htonl(resp->count);
750750
*p++ = htonl(resp->committed);
751-
*p++ = htonl(nn->nfssvc_boot.tv_sec);
752-
*p++ = htonl(nn->nfssvc_boot.tv_usec);
751+
/* unique identifier, y2038 overflow can be ignored */
752+
*p++ = htonl((u32)nn->nfssvc_boot.tv_sec);
753+
*p++ = htonl(nn->nfssvc_boot.tv_nsec);
753754
}
754755
return xdr_ressize_check(rqstp, p);
755756
}
@@ -1119,8 +1120,9 @@ nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p)
11191120
p = encode_wcc_data(rqstp, p, &resp->fh);
11201121
/* Write verifier */
11211122
if (resp->status == 0) {
1122-
*p++ = htonl(nn->nfssvc_boot.tv_sec);
1123-
*p++ = htonl(nn->nfssvc_boot.tv_usec);
1123+
/* unique identifier, y2038 overflow can be ignored */
1124+
*p++ = htonl((u32)nn->nfssvc_boot.tv_sec);
1125+
*p++ = htonl(nn->nfssvc_boot.tv_nsec);
11241126
}
11251127
return xdr_ressize_check(rqstp, p);
11261128
}

fs/nfsd/nfs4layouts.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ nfsd4_recall_file_layout(struct nfs4_layout_stateid *ls)
336336

337337
trace_layout_recall(&ls->ls_stid.sc_stateid);
338338

339-
atomic_inc(&ls->ls_stid.sc_count);
339+
refcount_inc(&ls->ls_stid.sc_count);
340340
nfsd4_run_cb(&ls->ls_recall);
341341

342342
out_unlock:
@@ -441,7 +441,7 @@ nfsd4_insert_layout(struct nfsd4_layoutget *lgp, struct nfs4_layout_stateid *ls)
441441
goto done;
442442
}
443443

444-
atomic_inc(&ls->ls_stid.sc_count);
444+
refcount_inc(&ls->ls_stid.sc_count);
445445
list_add_tail(&new->lo_perstate, &ls->ls_layouts);
446446
new = NULL;
447447
done:

fs/nfsd/nfs4proc.c

+5-14
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,6 @@ static __be32
485485
nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
486486
union nfsd4_op_u *u)
487487
{
488-
if (!cstate->current_fh.fh_dentry)
489-
return nfserr_nofilehandle;
490-
491488
u->getfh = &cstate->current_fh;
492489
return nfs_ok;
493490
}
@@ -535,9 +532,6 @@ static __be32
535532
nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
536533
union nfsd4_op_u *u)
537534
{
538-
if (!cstate->current_fh.fh_dentry)
539-
return nfserr_nofilehandle;
540-
541535
fh_dup2(&cstate->save_fh, &cstate->current_fh);
542536
if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG)) {
543537
memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t));
@@ -570,10 +564,11 @@ static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net)
570564

571565
/*
572566
* This is opaque to client, so no need to byte-swap. Use
573-
* __force to keep sparse happy
567+
* __force to keep sparse happy. y2038 time_t overflow is
568+
* irrelevant in this usage.
574569
*/
575570
verf[0] = (__force __be32)nn->nfssvc_boot.tv_sec;
576-
verf[1] = (__force __be32)nn->nfssvc_boot.tv_usec;
571+
verf[1] = (__force __be32)nn->nfssvc_boot.tv_nsec;
577572
memcpy(verifier->data, verf, sizeof(verifier->data));
578573
}
579574

@@ -703,10 +698,8 @@ nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
703698
union nfsd4_op_u *u)
704699
{
705700
struct nfsd4_link *link = &u->link;
706-
__be32 status = nfserr_nofilehandle;
701+
__be32 status;
707702

708-
if (!cstate->save_fh.fh_dentry)
709-
return status;
710703
status = nfsd_link(rqstp, &cstate->current_fh,
711704
link->li_name, link->li_namelen, &cstate->save_fh);
712705
if (!status)
@@ -850,10 +843,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
850843
union nfsd4_op_u *u)
851844
{
852845
struct nfsd4_rename *rename = &u->rename;
853-
__be32 status = nfserr_nofilehandle;
846+
__be32 status;
854847

855-
if (!cstate->save_fh.fh_dentry)
856-
return status;
857848
if (opens_in_grace(SVC_NET(rqstp)) &&
858849
!(cstate->save_fh.fh_export->ex_flags & NFSEXP_NOSUBTREECHECK))
859850
return nfserr_grace;

0 commit comments

Comments
 (0)