From patchwork Tue Nov 17 11:52:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7636381 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 21D19C05CA for ; Tue, 17 Nov 2015 11:54:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FEFE204FC for ; Tue, 17 Nov 2015 11:54:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FBF4204EC for ; Tue, 17 Nov 2015 11:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753543AbbKQLyc (ORCPT ); Tue, 17 Nov 2015 06:54:32 -0500 Received: from mail-qk0-f170.google.com ([209.85.220.170]:35860 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753544AbbKQLxq (ORCPT ); Tue, 17 Nov 2015 06:53:46 -0500 Received: by qkda6 with SMTP id a6so1676853qkd.3 for ; Tue, 17 Nov 2015 03:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds_net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YES0hKp7mFFf9t8+05AuRjjHRmIyJ/x02a7tS7BNPcg=; b=ym7jowF0jKUqWxSjh09ClN9jna1PGZC+0Wi+f2R1utBkmasaI/8t1hsjQ3KQM7NfEN Qf9OHwAzrCeHmdcyx3dEj+UjGGYH+N8ul14P0YZQxJXRymdvG41HL3ZVh+RiJSxFuFgF 4zcQoGbQnSp2vgjnMJ5Uheg6AwT6Z3c1Kvc39Eu3+co8egaefJXxtXLfojjAKXNUmLyv Wq8tamcvacAGTxeSNxWMkNmW2qvJBYbr+2TIdpflQNGWXTOVWf3lvNxyfeXNoGFUiGEb NE/Yu0BmuthYUhK61LqezRxV9oXivykkQJLsk5hT9YpyoIz+g9LMHEr3mU2C2a4ZVX5s 7tcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YES0hKp7mFFf9t8+05AuRjjHRmIyJ/x02a7tS7BNPcg=; b=ZwQhtAU8rT2oKp4RHgRXdSaQQ+TEjX2BY/zBjzMt/BK0m8tnJudZy2WI1THm2TIk3c EJeYXJPdLLe/bqLs+uTPzCFLSVaQ4cV/RdOgZXFjoPAQm2+dEsq7xz9pXTu86u11H6gG jqsm5RarTNCZInvP9G+V/xGHgWL2G2IA2LyiGSsV0Z+zYJdvBH3FJhVyfL9FCQHuVoPP MkdF9fe5RaEaTYWydik4xCGgNY4izRgh4F75mOPILnJQuwIQDCc2i2co+/l7T0i1wVAb AW2p3NcHDhITS1rl7d9hfHA3G9JVEbKdLZLGvrR/jaJPEbhafMD/aURLGWgQGfjih8iC Jwbw== X-Gm-Message-State: ALoCoQmVvnwcXU/uxItqDG4t108KWfAPjasJxqdFRQtYUQCpAW7e/lKdH5/GNB9dcBohLoP+h9Ne X-Received: by 10.55.54.19 with SMTP id d19mr41362871qka.52.1447761225575; Tue, 17 Nov 2015 03:53:45 -0800 (PST) Received: from tlielax.poochiereds.net ([2606:a000:1125:4075::d5a]) by smtp.googlemail.com with ESMTPSA id w10sm1583910qhc.16.2015.11.17.03.53.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Nov 2015 03:53:45 -0800 (PST) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org, trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Eric Paris , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v1 27/38] nfsd: allow filesystems to opt out of subtree checking Date: Tue, 17 Nov 2015 06:52:49 -0500 Message-Id: <1447761180-4250-28-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1447761180-4250-1-git-send-email-jeff.layton@primarydata.com> References: <1447761180-4250-1-git-send-email-jeff.layton@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=-7.4 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 When we start allowing NFS to be reexported, then we have some problems when it comes to subtree checking. In principle, we could allow it, but it would mean encoding parent info in the filehandles and there may not be enough space for that in a NFSv3 filehandle. To enforce this at export upcall time, we add a new export_ops flag that declares the filesystem ineligible for subtree checking. Signed-off-by: Jeff Layton --- Documentation/filesystems/nfs/Exporting | 14 +++++++++++++- fs/nfsd/export.c | 6 ++++++ include/linux/exportfs.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/nfs/Exporting b/Documentation/filesystems/nfs/Exporting index fa636cde3907..a89b5be22703 100644 --- a/Documentation/filesystems/nfs/Exporting +++ b/Documentation/filesystems/nfs/Exporting @@ -160,7 +160,7 @@ contains a "flags" field that allows the filesystem to communicate to nfsd that it may want to do things differently when dealing with it. The following flags are defined: - EXPORT_OP_NOWCC + EXPORT_OP_NOWCC - disable NFSv3 WCC attributes on this filesystem RFC 1813 recommends that servers always send weak cache consistency (WCC) data to the client after each operation. The server should atomically collect attributes about the inode, do an operation on it, @@ -174,3 +174,15 @@ following flags are defined: this on filesystems that have an expensive ->getattr inode operation, or when atomicity between pre and post operation attribute collection is impossible to guarantee. + + EXPORT_OP_NOSUBTREECHK - disallow subtree checking on this fs + Many NFS operations deal with filehandles, which the server must then + vet to ensure that they live inside of an exported tree. When the + export consists of an entire filesystem, this is trivial. nfsd can just + ensure that the filehandle live on the filesystem. When only part of a + filesystem is exported however, then nfsd must walk the ancestors of the + inode to ensure that it's within an exported subtree. This is an + expensive operation and not all filesystems can support it properly. + This flag exempts the filesystem from subtree checking and causes + exportfs to get back an error if it tries to enable subtree checking + on it. diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 4b504edff121..295d22e8fdad 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -392,6 +392,12 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid) return -EINVAL; } + if (inode->i_sb->s_export_op->flags & EXPORT_OP_NOSUBTREECHK && + *flags & NFSEXP_NOSUBTREECHECK) { + dprintk("%s: %s does not support subtree checking!\n", + __func__, inode->i_sb->s_type->name); + return -EINVAL; + } return 0; } diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index 600c3fccc999..5f9b5345f717 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -215,6 +215,7 @@ struct export_operations { int (*commit_blocks)(struct inode *inode, struct iomap *iomaps, int nr_iomaps, struct iattr *iattr); #define EXPORT_OP_NOWCC (0x1) /* Don't collect wcc data for NFSv3 replies */ +#define EXPORT_OP_NOSUBTREECHK (0x2) /* Subtree checking is not supported! */ unsigned long flags; };