From patchwork Thu Sep 26 18:40:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950151 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 0C4DCBFF0B for ; Thu, 26 Sep 2013 18:40:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EAA8202D1 for ; Thu, 26 Sep 2013 18:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A81820258 for ; Thu, 26 Sep 2013 18:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753217Ab3IZSk1 (ORCPT ); Thu, 26 Sep 2013 14:40:27 -0400 Received: from mail-qe0-f48.google.com ([209.85.128.48]:61372 "EHLO mail-qe0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753047Ab3IZSk1 (ORCPT ); Thu, 26 Sep 2013 14:40:27 -0400 Received: by mail-qe0-f48.google.com with SMTP id nd7so1091391qeb.7 for ; Thu, 26 Sep 2013 11:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LMtZNqh/iRRhb7K/hFRb/i5SDI6xBrrZAKnsIcc0PEk=; b=fMVAq/An2YEIdsvidjR2s/KC3+FfRO046Eqy28Z1fD+ouXk7MKrb/KbA25bciOqpiJ 0LdgnR8gXEQ2gaBFEsU1MbKr3WN++v3HFa8MPeLlOXE0KYYST7KidtOtqOJ6EW7RH/Y9 nuDDa32fP9qf/OvYlyzkl6m5ORED0IciI57/HTr+SUm/cCosrI+4uMEYFvsrnU3p4BlN y6zkRM19UZhZrEKKpHHOilq/2rUF6q7bHjWLzjDjGdqycwvc/9C2HCp1MzjEJFR7I65R lTt5Ole4ZKxgvjKy4BLCrq8qDqcsSjgLZejkOZFbydZ3gyX4YJzVUHHTW5MqUisRtP3G qMqA== X-Received: by 10.224.32.133 with SMTP id c5mr8699457qad.84.1380220826395; Thu, 26 Sep 2013 11:40:26 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com.com (nat-pool-bos-u.redhat.com. [66.187.233.207]) by mx.google.com with ESMTPSA id n9sm10246683qag.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:40:25 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 08/49] pnfsd: layout verify Date: Thu, 26 Sep 2013 14:40:24 -0400 Message-Id: <1380220824-13047-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <52447EA0.7070004@primarydata.com> References: <52447EA0.7070004@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 From: Benny Halevy Verify whether the server and file system support the given layout type. [was pnfsd: Streamline error code checking for non-pnfs filesystems] Signed-off-by: Dean Hildebrand [pnfsd: Add super block to layout_type()] Signed-off-by: Marc Eshel [pnfsd: Fix order of ops in nfsd4_layout_verify] Signed-off-by: Dean Hildebrand [pnfsd: convert generic code to use new pnfs api] [pnfsd: define pnfs_export_operations] [pnfsd: obliterate old vfs api] Signed-off-by: Benny Halevy [pnfsd: layout verify all layout types] Signed-off-by: Andy Adamson [pnfsd: tone nfsd4_layout_verify printk down to dprintk] Signed-off-by: Benny Halevy [pnfsd: check ex_pnfs in nfsd4_verify_layout] Signed-off-by: Andy Adamson [pnfsd: handle s_pnfs_op==NULL] [pnfsd: verify export option only if svc_export is present] Signed-off-by: Benny Halevy Signed-off-by: Benny Halevy --- fs/nfsd/export.c | 6 ++++++ fs/nfsd/nfs4proc.c | 39 +++++++++++++++++++++++++++++++++++++++ fs/nfsd/pnfsd.h | 2 ++ include/linux/nfsd/nfsd4_pnfs.h | 5 ++++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 7730dfd..d803414 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -376,6 +376,12 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid) return -EINVAL; } + if (inode->i_sb->s_pnfs_op && + !inode->i_sb->s_pnfs_op->layout_type) { + dprintk("exp_export: export of invalid fs pnfs export ops.\n"); + return -EINVAL; + } + return 0; } diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 419572f..576b635 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -41,6 +41,7 @@ #include "vfs.h" #include "current_stateid.h" #include "netns.h" +#include "pnfsd.h" #ifdef CONFIG_NFSD_V4_SECURITY_LABEL #include @@ -1109,6 +1110,44 @@ static int fill_in_write_vector(struct kvec *vec, struct nfsd4_write *write) return status == nfserr_same ? nfs_ok : status; } +#if defined(CONFIG_PNFSD) +static __be32 +nfsd4_layout_verify(struct super_block *sb, struct svc_export *exp, + unsigned int layout_type) +{ + int status, type; + + /* check to see if pNFS is supported. */ + status = nfserr_layoutunavailable; + if (exp && exp->ex_pnfs == 0) { + dprintk("%s: Underlying file system " + "is not exported over pNFS\n", __func__); + goto out; + } + if (!sb->s_pnfs_op || !sb->s_pnfs_op->layout_type) { + dprintk("%s: Underlying file system " + "does not support pNFS\n", __func__); + goto out; + } + + type = sb->s_pnfs_op->layout_type(sb); + + /* check to see if requested layout type is supported. */ + status = nfserr_unknown_layouttype; + if (!type) + dprintk("BUG: %s: layout_type 0 is reserved and must not be " + "used by filesystem\n", __func__); + else if (type != layout_type) + dprintk("%s: requested layout type %d " + "does not match supported type %d\n", + __func__, layout_type, type); + else + status = nfs_ok; +out: + return status; +} +#endif /* CONFIG_PNFSD */ + /* * NULL call. */ diff --git a/fs/nfsd/pnfsd.h b/fs/nfsd/pnfsd.h index 65fb57e..7c46791 100644 --- a/fs/nfsd/pnfsd.h +++ b/fs/nfsd/pnfsd.h @@ -34,4 +34,6 @@ #ifndef LINUX_NFSD_PNFSD_H #define LINUX_NFSD_PNFSD_H +#include + #endif /* LINUX_NFSD_PNFSD_H */ diff --git a/include/linux/nfsd/nfsd4_pnfs.h b/include/linux/nfsd/nfsd4_pnfs.h index ff6613e..d44669e 100644 --- a/include/linux/nfsd/nfsd4_pnfs.h +++ b/include/linux/nfsd/nfsd4_pnfs.h @@ -34,6 +34,8 @@ #ifndef _LINUX_NFSD_NFSD4_PNFS_H #define _LINUX_NFSD_NFSD4_PNFS_H +#include + /* * pNFS export operations vector. * @@ -45,7 +47,8 @@ * All other methods are optional and can be set to NULL if not implemented. */ struct pnfs_export_operations { - /* stub */ + /* Returns the supported pnfs_layouttype4. */ + int (*layout_type) (struct super_block *); }; #endif /* _LINUX_NFSD_NFSD4_PNFS_H */