Skip to content

Commit 800a938

Browse files
NeilBrownJ. Bruce Fields
authored andcommitted
NFSD: fix nfsd_reset_versions for NFSv4.
If you write "-2 -3 -4" to the "versions" file, it will notice that no versions are enabled, and nfsd_reset_versions() is called. This enables all major versions, not no minor versions. So we lose the invariant that NFSv4 is only advertised when at least one minor is enabled. Fix the code to explicitly enable minor versions for v4, change it to use nfsd_vers() to test and set, and simplify the code. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 928c6fb commit 800a938

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

fs/nfsd/nfssvc.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -416,23 +416,20 @@ static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
416416

417417
void nfsd_reset_versions(void)
418418
{
419-
int found_one = 0;
420419
int i;
421420

422-
for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) {
423-
if (nfsd_program.pg_vers[i])
424-
found_one = 1;
425-
}
421+
for (i = 0; i < NFSD_NRVERS; i++)
422+
if (nfsd_vers(i, NFSD_TEST))
423+
return;
426424

427-
if (!found_one) {
428-
for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++)
429-
nfsd_program.pg_vers[i] = nfsd_version[i];
430-
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
431-
for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++)
432-
nfsd_acl_program.pg_vers[i] =
433-
nfsd_acl_version[i];
434-
#endif
435-
}
425+
for (i = 0; i < NFSD_NRVERS; i++)
426+
if (i != 4)
427+
nfsd_vers(i, NFSD_SET);
428+
else {
429+
int minor = 0;
430+
while (nfsd_minorversion(minor, NFSD_SET) >= 0)
431+
minor++;
432+
}
436433
}
437434

438435
/*

0 commit comments

Comments
 (0)