Skip to contentSkip to conversation

NFSD: Add support for NFS v4.2 operation checking

PATCH In review Anna Schumaker 2 participants 2 messages Oct 30, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: Add support for NFS v4.2 operation checking

The server does allow NFS over v4.2, even if it doesn't add any new operations yet.

I also switch to using constants to represent the last operation for each minor version since this makes the code cleaner and easier to understand at a quick glance.

---
 fs/nfsd/nfs4xdr.c    | 8 +++++---
 include/linux/nfs4.h | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)
fs/nfsd/nfs4xdr.c +5 -3
index 99bebea..83db5a7 100644
@@ -1585,11 +1585,13 @@ static nfsd4_dec nfsd4_dec_ops[] = {
 static inline bool
 nfsd4_opnum_in_range(struct nfsd4_compoundargs *argp, struct nfsd4_op *op)
 {
-	if (op->opnum < FIRST_NFS4_OP || op->opnum > LAST_NFS4_OP)
+	if (op->opnum < FIRST_NFS4_OP)
 		return false;
-	else if (argp->minorversion == 0 && op->opnum > OP_RELEASE_LOCKOWNER)
+	else if (argp->minorversion == 0 && op->opnum > LAST_NFS40_OP)
 		return false;
-	else if (argp->minorversion == 1 && op->opnum > OP_RECLAIM_COMPLETE)
+	else if (argp->minorversion == 1 && op->opnum > LAST_NFS41_OP)
+		return false;
+	else if (argp->minorversion == 2 && op->opnum > LAST_NFS42_OP)
 		return false;
 	return true;
 }
include/linux/nfs4.h +3 -0
index c56fa8f..9577769 100644
@@ -118,6 +118,9 @@ Needs to be updated if more operations are defined in future.*/
 
 #define FIRST_NFS4_OP	OP_ACCESS
 #define LAST_NFS4_OP 	OP_RECLAIM_COMPLETE
+#define LAST_NFS40_OP	OP_RELEASE_LOCKOWNER
+#define LAST_NFS41_OP	OP_RECLAIM_COMPLETE
+#define LAST_NFS42_OP	OP_RECLAIM_COMPLETE
 
 enum nfsstat4 {
 	NFS4_OK = 0,
Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 6 lines · Anna Schumaker

The server does allow NFS over v4.2, even if it doesn't add any new operations yet.

I also switch to using constants to represent the last operation for each minor version since this makes the code cleaner and easier to understand at a quick glance.

Looks good to me. Thanks!

--b.

Quoted 45 lines
---
 fs/nfsd/nfs4xdr.c    | 8 +++++---
 include/linux/nfs4.h | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)
fs/nfsd/nfs4xdr.c +5 -3
index 99bebea..83db5a7 100644
@@ -1585,11 +1585,13 @@ static nfsd4_dec nfsd4_dec_ops[] = {
 static inline bool
 nfsd4_opnum_in_range(struct nfsd4_compoundargs *argp, struct nfsd4_op *op)
 {
-	if (op->opnum < FIRST_NFS4_OP || op->opnum > LAST_NFS4_OP)
+	if (op->opnum < FIRST_NFS4_OP)
 		return false;
-	else if (argp->minorversion == 0 && op->opnum > OP_RELEASE_LOCKOWNER)
+	else if (argp->minorversion == 0 && op->opnum > LAST_NFS40_OP)
 		return false;
-	else if (argp->minorversion == 1 && op->opnum > OP_RECLAIM_COMPLETE)
+	else if (argp->minorversion == 1 && op->opnum > LAST_NFS41_OP)
+		return false;
+	else if (argp->minorversion == 2 && op->opnum > LAST_NFS42_OP)
 		return false;
 	return true;
 }
include/linux/nfs4.h +3 -0
index c56fa8f..9577769 100644
@@ -118,6 +118,9 @@ Needs to be updated if more operations are defined in future.*/
 
 #define FIRST_NFS4_OP	OP_ACCESS
 #define LAST_NFS4_OP 	OP_RECLAIM_COMPLETE
+#define LAST_NFS40_OP	OP_RELEASE_LOCKOWNER
+#define LAST_NFS41_OP	OP_RECLAIM_COMPLETE
+#define LAST_NFS42_OP	OP_RECLAIM_COMPLETE
 
 enum nfsstat4 {
 	NFS4_OK = 0,
Signature · 1 line
1.8.4.2