From patchwork Wed Oct 30 17:38:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Schumaker X-Patchwork-Id: 3115911 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02E8BBF924 for ; Wed, 30 Oct 2013 17:38:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC3DA20375 for ; Wed, 30 Oct 2013 17:38:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CBF5201EC for ; Wed, 30 Oct 2013 17:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752703Ab3J3RiR (ORCPT ); Wed, 30 Oct 2013 13:38:17 -0400 Received: from mx2.netapp.com ([216.240.18.37]:56557 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993Ab3J3RiR (ORCPT ); Wed, 30 Oct 2013 13:38:17 -0400 X-IronPort-AV: E=Sophos;i="4.93,602,1378882800"; d="scan'208";a="53853184" Received: from vmwexceht01-prd.hq.netapp.com ([10.106.76.239]) by mx2-out.netapp.com with ESMTP; 30 Oct 2013 10:38:16 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCEHT01-PRD.hq.netapp.com (10.106.76.239) with Microsoft SMTP Server id 14.3.123.3; Wed, 30 Oct 2013 10:38:16 -0700 Received: from davros.com ([10.63.231.104]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id r9UHcFk0016095; Wed, 30 Oct 2013 10:38:15 -0700 (PDT) From: Anna Schumaker To: , Subject: [PATCH] NFSD: Add support for NFS v4.2 operation checking Date: Wed, 30 Oct 2013 13:38:13 -0400 Message-ID: <1383154693-29741-1-git-send-email-bjschuma@netapp.com> X-Mailer: git-send-email 1.8.4.2 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Anna Schumaker --- fs/nfsd/nfs4xdr.c | 8 +++++--- include/linux/nfs4.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 99bebea..83db5a7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -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; } diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index c56fa8f..9577769 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -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,