nfsd4: fix minorversion support interface
authorJ. Bruce Fields <bfields@redhat.com>
Mon, 8 Jul 2013 23:51:44 +0000 (19:51 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 12 Jul 2013 20:48:52 +0000 (16:48 -0400)
You can turn on or off support for minorversions using e.g.

echo "-4.2" >/proc/fs/nfsd/versions

However, the current implementation is a little wonky.  For example, the
above will turn off 4.2 support, but it will also turn *on* 4.1 support.

This didn't matter as long as we only had 2 minorversions, which was
true till very recently.

And do a little cleanup here.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfsd.h
fs/nfsd/nfssvc.c

index a7cee864e7b245e5ead7c8f04b509a5cfe9c59a8..0d4c410e45893c2ae00064c5a8ae3384e00848b4 100644 (file)
@@ -1293,7 +1293,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
         * According to RFC3010, this takes precedence over all other errors.
         */
        status = nfserr_minor_vers_mismatch;
-       if (args->minorversion > nfsd_supported_minorversion)
+       if (nfsd_minorversion(args->minorversion, NFSD_TEST) <= 0)
                goto out;
 
        status = nfs41_check_op_ordering(args);
index 2bbd94e51efc7dcc8bcba377e2e8373290b3a189..30f34ab02137f8e41aa95bcbf7c51967e694f3c1 100644 (file)
@@ -53,7 +53,6 @@ struct readdir_cd {
 extern struct svc_program      nfsd_program;
 extern struct svc_version      nfsd_version2, nfsd_version3,
                                nfsd_version4;
-extern u32                     nfsd_supported_minorversion;
 extern struct mutex            nfsd_mutex;
 extern spinlock_t              nfsd_drc_lock;
 extern unsigned long           nfsd_drc_max_mem;
index 6b9f48ca4c25183abab7759a588a8ec5d4da4257..760c85a6f534a45b0eb396a62acc305484163109 100644 (file)
@@ -116,7 +116,10 @@ struct svc_program         nfsd_program = {
 
 };
 
-u32 nfsd_supported_minorversion = 1;
+static bool nfsd_supported_minorversions[NFSD_SUPPORTED_MINOR_VERSION + 1] = {
+       [0] = 1,
+       [1] = 1,
+};
 
 int nfsd_vers(int vers, enum vers_op change)
 {
@@ -151,15 +154,13 @@ int nfsd_minorversion(u32 minorversion, enum vers_op change)
                return -1;
        switch(change) {
        case NFSD_SET:
-               nfsd_supported_minorversion = minorversion;
+               nfsd_supported_minorversions[minorversion] = true;
                break;
        case NFSD_CLEAR:
-               if (minorversion == 0)
-                       return -1;
-               nfsd_supported_minorversion = minorversion - 1;
+               nfsd_supported_minorversions[minorversion] = false;
                break;
        case NFSD_TEST:
-               return minorversion <= nfsd_supported_minorversion;
+               return nfsd_supported_minorversions[minorversion];
        case NFSD_AVAIL:
                return minorversion <= NFSD_SUPPORTED_MINOR_VERSION;
        }