From patchwork Thu Sep 26 18:40:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950221 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 61EFA9F288 for ; Thu, 26 Sep 2013 18:41:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55BCD20258 for ; Thu, 26 Sep 2013 18:41:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C9CD20164 for ; Thu, 26 Sep 2013 18:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047Ab3IZSk4 (ORCPT ); Thu, 26 Sep 2013 14:40:56 -0400 Received: from mail-qa0-f49.google.com ([209.85.216.49]:34984 "EHLO mail-qa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752597Ab3IZSk4 (ORCPT ); Thu, 26 Sep 2013 14:40:56 -0400 Received: by mail-qa0-f49.google.com with SMTP id k15so1104567qaq.1 for ; Thu, 26 Sep 2013 11:40:55 -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=jWgl0l1cYVfm34I/qmE1+Mvn4oyuwGy2LkOnBsx6eEc=; b=DPkshndcO3YLF7CfLTcDqeQd5uPo6RKn49sgTqWl3NwabwAP9bhWSM4bOCy9n34UHj t8ve0Y8A9qutFz0aVZD3nKw8d89JdPnkk8bAu6QLMd5sbeP4rja2XEYojgyulYtTKKdD MyfcWGW9nbbaUkIIllrfNLPtrhXLXtamrXsuZc5dIX93d9/TzTx3yX4BZ2DupDdcjlZG 0ly/UVBz7SC5L+2QIjEr5+8/5huf8Hdgy9TdrLHpBLvCaAHoA++fZFqyg31YY1Ivbp8M CNY+jP8aMuHErOrcsZYgs3YVGIEMfuXC8syAdIiMVDaFZiVr4RcSQSY8MQPKkp6aNCw7 f7sQ== X-Received: by 10.49.107.105 with SMTP id hb9mr3654353qeb.74.1380220855759; Thu, 26 Sep 2013 11:40:55 -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 a2sm5110457qek.7.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:40:54 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 15/49] pnfsd: add helper functions for identifying DS filehandles Date: Thu, 26 Sep 2013 14:40:53 -0400 Message-Id: <1380220853-13371-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 [pnfsd: define and use FSID_MAX in enum nfsd_fsid] Signed-off-by: Benny Halevy [pnfsd: add helper functions for identifying DS stateids.] Signed-off-by: David M. Richter [define a no-op version of pnfs_fh_is_ds for !CONFIG_PNFSD] Signed-off-by: Benny Halevy Signed-off-by: Benny Halevy --- fs/nfsd/nfsfh.c | 7 +++++-- fs/nfsd/nfsfh.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 814afaa..71f9470 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -10,6 +10,7 @@ #include #include +#include #include "nfsd.h" #include "vfs.h" #include "auth.h" @@ -136,6 +137,7 @@ static inline __be32 check_pseudo_root(struct svc_rqst *rqstp, static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) { struct knfsd_fh *fh = &fhp->fh_handle; + int fsid_type; struct fid *fid = NULL, sfid; struct svc_export *exp; struct dentry *dentry; @@ -156,7 +158,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) return error; if (fh->fh_auth_type != 0) return error; - len = key_len(fh->fh_fsid_type) / 4; + fsid_type = pnfs_fh_fsid_type(fh); + len = key_len(fsid_type) / 4; if (len == 0) return error; if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { @@ -169,7 +172,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) data_left -= len; if (data_left < 0) return error; - exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_auth); + exp = rqst_exp_find(rqstp, fsid_type, fh->fh_auth); fid = (struct fid *)(fh->fh_auth + len); } else { __u32 tfh[2]; diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index e5e6707..2563e88 100644 --- a/fs/nfsd/nfsfh.h +++ b/fs/nfsd/nfsfh.h @@ -14,6 +14,7 @@ enum nfsd_fsid { FSID_UUID8, FSID_UUID16, FSID_UUID16_INUM, + FSID_MAX }; enum fsid_source { @@ -203,4 +204,42 @@ static inline int key_len(int type) } } +#if defined(CONFIG_PNFSD) + +/* + * fh_fsid_type is overloaded to indicate whether a filehandle was one supplied + * to a DS by LAYOUTGET. nfs4_preprocess_stateid_op() uses this to decide how + * to handle a given stateid. + */ +static inline int pnfs_fh_is_ds(struct knfsd_fh *fh) +{ + return fh->fh_fsid_type >= FSID_MAX; +} + +static inline void pnfs_fh_mark_ds(struct knfsd_fh *fh) +{ + BUG_ON(fh->fh_version != 1); + BUG_ON(pnfs_fh_is_ds(fh)); + fh->fh_fsid_type += FSID_MAX; +} + +#else /* CONFIG_PNFSD */ + +static inline int pnfs_fh_is_ds(struct knfsd_fh *fh) +{ + return 0; +} + +#endif /* CONFIG_PNFSD */ + +/* allows fh_verify() to check the real fsid_type (i.e., not overloaded). */ +static inline int pnfs_fh_fsid_type(struct knfsd_fh *fh) +{ + int fsid_type = fh->fh_fsid_type; + + if (pnfs_fh_is_ds(fh)) + return fsid_type - FSID_MAX; + return fsid_type; +} + #endif /* _LINUX_NFSD_FH_INT_H */