From patchwork Thu Sep 26 18:41:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950361 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 23B1B9F288 for ; Thu, 26 Sep 2013 18:42:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30447202DD for ; Thu, 26 Sep 2013 18:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7475B20164 for ; Thu, 26 Sep 2013 18:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055Ab3IZSlx (ORCPT ); Thu, 26 Sep 2013 14:41:53 -0400 Received: from mail-qe0-f53.google.com ([209.85.128.53]:39026 "EHLO mail-qe0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553Ab3IZSlw (ORCPT ); Thu, 26 Sep 2013 14:41:52 -0400 Received: by mail-qe0-f53.google.com with SMTP id jy17so1106331qeb.26 for ; Thu, 26 Sep 2013 11:41:52 -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=BX+Fbj+jkboSgqSGG1OfLmZ1C3PWI5YXefNdAfOMvTk=; b=QnlFVLp/btdmFE5BA3p5nTi2F9qWNM5BvoILMWl0KdgSZnN/0MYymPq0GRuJNj7fU1 ATz4AmXH7xL8kPU4J37OUuEx0aT9hHOAtFd+zvlWjKHsFqd61YB5r1Ok35RkFr6x3V83 FL3nLt2sjKoGfe1ff8UqyFd4b79JkFebKzIIEJDvQoXQN0qGaDrvX66xZUGspTmtMc33 EnK78EHhWWtgzNcFNbowfnPHQQlPiOkxwdGM/O+QvkBLqauMZg9dwpwiGDqUxVCOzbgH EQKKCdUclkLJbKyZ9oVwwcoMOlIxJjbFCcxU+4vj3gYFq+BKLxy7Marnoa6Yn3wjmroI 69Lg== X-Received: by 10.224.151.82 with SMTP id b18mr3763973qaw.125.1380220912192; Thu, 26 Sep 2013 11:41:52 -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 y9sm10251168qaj.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:41:51 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 29/49] pnfsd: support layout_type attribute Date: Thu, 26 Sep 2013 14:41:48 -0400 Message-Id: <1380220908-14009-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 Provide for getting the (read-only) layout_type attribute [extraced from pnfsd: Initial pNFS server implementation.] Signed-off-by: Benny Halevy [pnfsd: Add super block to layout_type()] Signed-off-by: Marc Eshel [pnfsd: convert generic code to use new pnfs api] Signed-off-by: Benny Halevy [Remove the use of struct pnfs_export_operations.] [pnfsd: support layout_type attribute all layout types] [pnfsd: check ex_pnfs in nfsd4_verify_layout] Signed-off-by: Andy Adamson [pnfsd: handle s_pnfs_op==NULL] [pnfsd: test layout_type method in nfsd4_encode_fattr] Signed-off-by: Benny Halevy Signed-off-by: Benny Halevy --- fs/nfsd/nfs4xdr.c | 24 ++++++++++++++++++++++++ fs/nfsd/nfsd.h | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b9c4417..83f7147 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2560,6 +2560,30 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat) get_parent_attributes(exp, &stat); WRITE64(stat.ino); } +#if defined(CONFIG_PNFSD) + if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { + struct super_block *sb = dentry->d_inode->i_sb; + int type = 0; + + /* Query the filesystem for supported pNFS layout types. + * Currently, we only support one layout type per file system. + * The export_ops->layout_type() returns the pnfs_layouttype4. + */ + buflen -= 4; + if (buflen < 0) /* length */ + goto out_resource; + + if (sb && sb->s_pnfs_op && sb->s_pnfs_op->layout_type) + type = sb->s_pnfs_op->layout_type(sb); + if (type) { + if ((buflen -= 4) < 0) /* type */ + goto out_resource; + WRITE32(1); /* length */ + WRITE32(type); /* type */ + } else + WRITE32(0); /* length */ + } +#endif /* CONFIG_PNFSD */ if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { status = nfsd4_encode_security_label(rqstp, context, contextlen, &p, &buflen); diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 30f34ab..f49fb0b 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -321,8 +321,13 @@ static inline void nfs4_reset_lease(time_t leasetime) { } #define NFSD4_1_SUPPORTED_ATTRS_WORD0 \ NFSD4_SUPPORTED_ATTRS_WORD0 +#if defined(CONFIG_PNFSD) +#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \ + (NFSD4_SUPPORTED_ATTRS_WORD1 | FATTR4_WORD1_FS_LAYOUT_TYPES) +#else /* CONFIG_PNFSD */ #define NFSD4_1_SUPPORTED_ATTRS_WORD1 \ NFSD4_SUPPORTED_ATTRS_WORD1 +#endif /* CONFIG_PNFSD */ #define NFSD4_1_SUPPORTED_ATTRS_WORD2 \ (NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT)