nfsd41: control nfsv4.1 svc via /proc/fs/nfsd/versions
authorBenny Halevy <bhalevy@panasas.com>
Fri, 3 Apr 2009 05:28:59 +0000 (08:28 +0300)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Sat, 4 Apr 2009 00:41:21 +0000 (17:41 -0700)
Support enabling and disabling nfsv4.1 via /proc/fs/nfsd/versions
by writing the strings "+4.1" or "-4.1" correspondingly.

Use user mode nfs-utils (rpc.nfsd option) to enable.
This will allow us to get rid of CONFIG_NFSD_V4_1

[nfsd41: disable support for minorversion by default]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/nfsd/nfs4proc.c
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c
include/linux/nfsd/nfsd.h

index db208dd8fdca0e9fc8e47e24fa1f04473e592236..52bb14debb30a9e809d6f4e1f67cf842fcf990a0 100644 (file)
@@ -921,7 +921,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_MINOR_VERSION)
+       if (args->minorversion > nfsd_supported_minorversion)
                goto out;
 
        if (!nfs41_op_ordering_ok(args)) {
index 4adebb6312c4f80fe866728210bea4c55b6392cb..a9b8c75bf0bff899c92de5ce49fe82907aea00d1 100644 (file)
@@ -792,8 +792,9 @@ out_free:
 static ssize_t __write_versions(struct file *file, char *buf, size_t size)
 {
        char *mesg = buf;
-       char *vers, sign;
+       char *vers, *minorp, sign;
        int len, num;
+       unsigned minor;
        ssize_t tlen = 0;
        char *sep;
 
@@ -814,9 +815,20 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
                do {
                        sign = *vers;
                        if (sign == '+' || sign == '-')
-                               num = simple_strtol((vers+1), NULL, 0);
+                               num = simple_strtol((vers+1), &minorp, 0);
                        else
-                               num = simple_strtol(vers, NULL, 0);
+                               num = simple_strtol(vers, &minorp, 0);
+                       if (*minorp == '.') {
+                               if (num < 4)
+                                       return -EINVAL;
+                               minor = simple_strtoul(minorp+1, NULL, 0);
+                               if (minor == 0)
+                                       return -EINVAL;
+                               if (nfsd_minorversion(minor, sign == '-' ?
+                                                    NFSD_CLEAR : NFSD_SET) < 0)
+                                       return -EINVAL;
+                               goto next;
+                       }
                        switch(num) {
                        case 2:
                        case 3:
@@ -826,6 +838,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
                        default:
                                return -EINVAL;
                        }
+               next:
                        vers += len + 1;
                        tlen += len;
                } while ((len = qword_get(&mesg, vers, size)) > 0);
@@ -844,6 +857,13 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
                                       num);
                        sep = " ";
                }
+       if (nfsd_vers(4, NFSD_AVAIL))
+               for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION; minor++)
+                       len += sprintf(buf+len, " %c4.%u",
+                                       (nfsd_vers(4, NFSD_TEST) &&
+                                        nfsd_minorversion(minor, NFSD_TEST)) ?
+                                               '+' : '-',
+                                       minor);
        len += sprintf(buf+len, "\n");
        return len;
 }
index b53a098e97a4d3b52195dccc5b856c46e3ef1cf5..e9d57734a348b55f132a7d132989e9c54f2d2ddf 100644 (file)
@@ -121,6 +121,8 @@ struct svc_program          nfsd_program = {
 
 };
 
+u32 nfsd_supported_minorversion;
+
 int nfsd_vers(int vers, enum vers_op change)
 {
        if (vers < NFSD_MINVERS || vers >= NFSD_NRVERS)
@@ -147,6 +149,28 @@ int nfsd_vers(int vers, enum vers_op change)
        }
        return 0;
 }
+
+int nfsd_minorversion(u32 minorversion, enum vers_op change)
+{
+       if (minorversion > NFSD_SUPPORTED_MINOR_VERSION)
+               return -1;
+       switch(change) {
+       case NFSD_SET:
+               nfsd_supported_minorversion = minorversion;
+               break;
+       case NFSD_CLEAR:
+               if (minorversion == 0)
+                       return -1;
+               nfsd_supported_minorversion = minorversion - 1;
+               break;
+       case NFSD_TEST:
+               return minorversion <= nfsd_supported_minorversion;
+       case NFSD_AVAIL:
+               return minorversion <= NFSD_SUPPORTED_MINOR_VERSION;
+       }
+       return 0;
+}
+
 /*
  * Maximum number of nfsd processes
  */
index 1f063d495159801d29e587a692ca14d79cc155b3..70339b7b83c04aacbb8a2dfc4e55c45af129c3ce 100644 (file)
@@ -53,6 +53,7 @@ typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
 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 struct svc_serv         *nfsd_serv;
 
@@ -149,6 +150,7 @@ int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
 
 enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
 int nfsd_vers(int vers, enum vers_op change);
+int nfsd_minorversion(u32 minorversion, enum vers_op change);
 void nfsd_reset_versions(void);
 int nfsd_create_serv(void);