Skip to content

Commit 449bf8d

Browse files
committed
Merge branch 'nfsd-next' of git://linux-nfs.org/~bfields/linux
Pull nfsd changes from Bruce Fields: "This includes miscellaneous bugfixes and cleanup and a performance fix for write-heavy NFSv4 workloads. (The most significant nfsd-relevant change this time is actually in the delegation patches that went through Viro, fixing a long-standing bug that can cause NFSv4 clients to miss updates made by non-nfs users of the filesystem. Those enable some followup nfsd patches which I have queued locally, but those can wait till 3.14)" * 'nfsd-next' of git://linux-nfs.org/~bfields/linux: (24 commits) nfsd: export proper maximum file size to the client nfsd4: improve write performance with better sendspace reservations svcrpc: remove an unnecessary assignment sunrpc: comment typo fix Revert "nfsd: remove_stid can be incorporated into nfs4_put_delegation" nfsd4: fix discarded security labels on setattr NFSD: Add support for NFS v4.2 operation checking nfsd4: nfsd_shutdown_net needs state lock NFSD: Combine decode operations for v4 and v4.1 nfsd: -EINVAL on invalid anonuid/gid instead of silent failure nfsd: return better errors to exportfs nfsd: fh_update should error out in unexpected cases nfsd4: need to destroy revoked delegations in destroy_client nfsd: no need to unhash_stid before free nfsd: remove_stid can be incorporated into nfs4_put_delegation nfsd: nfs4_open_delegation needs to remove_stid rather than unhash_stid nfsd: nfs4_free_stid nfsd: fix Kconfig syntax sunrpc: trim off EC bytes in GSSAPI v2 unwrap gss_krb5: document that we ignore sequence number ...
2 parents ffd3c02 + aea240f commit 449bf8d

12 files changed

Lines changed: 146 additions & 105 deletions

File tree

‎fs/nfsd/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ config NFSD_V4_SECURITY_LABEL
9595
Smack policies on NFSv4 files, say N.
9696

9797
WARNING: there is still a chance of backwards-incompatible protocol changes.
98-
For now we recommend "Y" only for developers and testers."
98+
For now we recommend "Y" only for developers and testers.
9999

100100
config NFSD_FAULT_INJECTION
101101
bool "NFS server manual fault injection"

‎fs/nfsd/export.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,16 +536,12 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
536536
if (err)
537537
goto out3;
538538
exp.ex_anon_uid= make_kuid(&init_user_ns, an_int);
539-
if (!uid_valid(exp.ex_anon_uid))
540-
goto out3;
541539

542540
/* anon gid */
543541
err = get_int(&mesg, &an_int);
544542
if (err)
545543
goto out3;
546544
exp.ex_anon_gid= make_kgid(&init_user_ns, an_int);
547-
if (!gid_valid(exp.ex_anon_gid))
548-
goto out3;
549545

550546
/* fsid */
551547
err = get_int(&mesg, &an_int);
@@ -583,6 +579,26 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
583579
exp.ex_uuid);
584580
if (err)
585581
goto out4;
582+
/*
583+
* No point caching this if it would immediately expire.
584+
* Also, this protects exportfs's dummy export from the
585+
* anon_uid/anon_gid checks:
586+
*/
587+
if (exp.h.expiry_time < seconds_since_boot())
588+
goto out4;
589+
/*
590+
* For some reason exportfs has been passing down an
591+
* invalid (-1) uid & gid on the "dummy" export which it
592+
* uses to test export support. To make sure exportfs
593+
* sees errors from check_export we therefore need to
594+
* delay these checks till after check_export:
595+
*/
596+
err = -EINVAL;
597+
if (!uid_valid(exp.ex_anon_uid))
598+
goto out4;
599+
if (!gid_valid(exp.ex_anon_gid))
600+
goto out4;
601+
err = 0;
586602
}
587603

588604
expp = svc_export_lookup(&exp);

‎fs/nfsd/nfs4state.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,16 @@ static void remove_stid(struct nfs4_stid *s)
402402
idr_remove(stateids, s->sc_stateid.si_opaque.so_id);
403403
}
404404

405+
static void nfs4_free_stid(struct kmem_cache *slab, struct nfs4_stid *s)
406+
{
407+
kmem_cache_free(slab, s);
408+
}
409+
405410
void
406411
nfs4_put_delegation(struct nfs4_delegation *dp)
407412
{
408413
if (atomic_dec_and_test(&dp->dl_count)) {
409-
kmem_cache_free(deleg_slab, dp);
414+
nfs4_free_stid(deleg_slab, &dp->dl_stid);
410415
num_delegations--;
411416
}
412417
}
@@ -610,7 +615,7 @@ static void close_generic_stateid(struct nfs4_ol_stateid *stp)
610615
static void free_generic_stateid(struct nfs4_ol_stateid *stp)
611616
{
612617
remove_stid(&stp->st_stid);
613-
kmem_cache_free(stateid_slab, stp);
618+
nfs4_free_stid(stateid_slab, &stp->st_stid);
614619
}
615620

616621
static void release_lock_stateid(struct nfs4_ol_stateid *stp)
@@ -668,7 +673,6 @@ static void unhash_open_stateid(struct nfs4_ol_stateid *stp)
668673
static void release_open_stateid(struct nfs4_ol_stateid *stp)
669674
{
670675
unhash_open_stateid(stp);
671-
unhash_stid(&stp->st_stid);
672676
free_generic_stateid(stp);
673677
}
674678

@@ -690,7 +694,6 @@ static void release_last_closed_stateid(struct nfs4_openowner *oo)
690694
struct nfs4_ol_stateid *s = oo->oo_last_closed_stid;
691695

692696
if (s) {
693-
unhash_stid(&s->st_stid);
694697
free_generic_stateid(s);
695698
oo->oo_last_closed_stid = NULL;
696699
}
@@ -1127,6 +1130,11 @@ destroy_client(struct nfs4_client *clp)
11271130
dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
11281131
destroy_delegation(dp);
11291132
}
1133+
list_splice_init(&clp->cl_revoked, &reaplist);
1134+
while (!list_empty(&reaplist)) {
1135+
dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
1136+
destroy_revoked_delegation(dp);
1137+
}
11301138
while (!list_empty(&clp->cl_openowners)) {
11311139
oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient);
11321140
release_openowner(oo);
@@ -3154,7 +3162,7 @@ nfs4_open_delegation(struct net *net, struct svc_fh *fh,
31543162
open->op_delegate_type = NFS4_OPEN_DELEGATE_READ;
31553163
return;
31563164
out_free:
3157-
unhash_stid(&dp->dl_stid);
3165+
remove_stid(&dp->dl_stid);
31583166
nfs4_put_delegation(dp);
31593167
out_no_deleg:
31603168
open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
@@ -3995,10 +4003,9 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
39954003

39964004
nfsd4_close_open_stateid(stp);
39974005

3998-
if (cstate->minorversion) {
3999-
unhash_stid(&stp->st_stid);
4006+
if (cstate->minorversion)
40004007
free_generic_stateid(stp);
4001-
} else
4008+
else
40024009
oo->oo_last_closed_stid = stp;
40034010

40044011
if (list_empty(&oo->oo_owner.so_stateids)) {
@@ -5119,7 +5126,6 @@ nfs4_state_start(void)
51195126
return ret;
51205127
}
51215128

5122-
/* should be called with the state lock held */
51235129
void
51245130
nfs4_state_shutdown_net(struct net *net)
51255131
{
@@ -5130,6 +5136,7 @@ nfs4_state_shutdown_net(struct net *net)
51305136
cancel_delayed_work_sync(&nn->laundromat_work);
51315137
locks_end_grace(&nn->nfsd4_manager);
51325138

5139+
nfs4_lock_state();
51335140
INIT_LIST_HEAD(&reaplist);
51345141
spin_lock(&recall_lock);
51355142
list_for_each_safe(pos, next, &nn->del_recall_lru) {
@@ -5144,6 +5151,7 @@ nfs4_state_shutdown_net(struct net *net)
51445151

51455152
nfsd4_client_tracking_exit(net);
51465153
nfs4_state_destroy_net(net);
5154+
nfs4_unlock_state();
51475155
}
51485156

51495157
void

0 commit comments

Comments
 (0)