From patchwork Sat Dec 31 13:18:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9492727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6A1B62ABC for ; Sat, 31 Dec 2016 13:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7761B203C0 for ; Sat, 31 Dec 2016 13:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 561A624B44; Sat, 31 Dec 2016 13:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10050203C0 for ; Sat, 31 Dec 2016 13:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754540AbcLaNSS (ORCPT ); Sat, 31 Dec 2016 08:18:18 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34111 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752703AbcLaNSR (ORCPT ); Sat, 31 Dec 2016 08:18:17 -0500 Received: by mail-pg0-f66.google.com with SMTP id b1so25086859pgc.1 for ; Sat, 31 Dec 2016 05:18:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=pTUZxSadoDT82kauE23VxKgAuuvoBIl5uwa0bNl9MTs=; b=k/YHe1ZUF1LPTpZBErpuUeJwz1ecke8sq7URL6n9CwYGH9TZpQWsFHKYstOk4asJ87 WO97wgfpZ4RuLFvqudwCqwC0cf33Yihd8/4pCmjqIvd5SQnrIn2h+rEPcoJ4z4fuNDK8 OraPaWMg8yXUzk04sqCA0hocRskZv4p5BShHr04Aif3rdjhGGdECUMph9rbhw6p9//1O 1YPLmRrm6VvO+yEP6dXOVW4XUKWgFdOn2Vj90qnrie8G2NQfiO7ossBLa9J6qaO/aTAj Aq8P6nUxPbUD0srxIAFkoEw7G0u/l+IwFZ09FP5PMpqrZpv2rXOWomgvdmOSWqC3URKw v0KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=pTUZxSadoDT82kauE23VxKgAuuvoBIl5uwa0bNl9MTs=; b=JOhdRbvoI+AcKptM+T+20bqFiAr8GH1jIr1wQxnIpXHUkzEF+SnyTSZ1ujMv0VmYPD PFmy6LI/I+M3UE5SWtAgHo/heY9DSoc4tR6xdtqPMszcfDx8MmZsM/uwKHFWkl3lg2e9 U1302M7Jjm0g9m94RE4sFuLPJwndppvMa4tri7G8pWIZaUcskl6PV8MCW3UQ6pLR6TuP 74DSjXpDf3/CyeXm/NzkBZtSN5I//ApPzfkMKoa7Pnad1JZkNagrFrGnvemMIW7+xbIS ClJw2nMtH5E4rCBwKfXha3iwM+aySJ87ZClZqvDq1Il1Ua9I+sp24/ZDwut0OMJW83/o HUPg== X-Gm-Message-State: AIkVDXLXBiZHF8I+DJckf8cDWehZVMWPlVVjX3N8vFvG0BPHk+1BCriTqLixhAQzPEi8QQ== X-Received: by 10.84.211.12 with SMTP id b12mr94970576pli.117.1483190297150; Sat, 31 Dec 2016 05:18:17 -0800 (PST) Received: from [192.168.0.104] ([183.228.30.39]) by smtp.googlemail.com with ESMTPSA id q190sm79939619pfb.51.2016.12.31.05.18.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Dec 2016 05:18:16 -0800 (PST) To: "J. Bruce Fields" , linux-nfs@vger.kernel.org From: Kinglong Mee Subject: [PATCH] NFSD: only support readonly export for !fsync and readonly filesystem Cc: Christoph Hellwig , Steve Dickson , kinglongmee@gmail.com Message-ID: <960d206f-3cb5-b60e-5245-d7282dabf664@gmail.com> Date: Sat, 31 Dec 2016 21:18:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit fae5096ad217 "nfsd: assume writeable exportabled filesystems have f_sync" have remove the checking of f_sync. Christoph Hellwig suggests, "Warn and refuse the writable export." I think just covert to a readonly export for !fsync filesystem, also, for a readonly filesystem is reasonable. Signed-off-by: Kinglong Mee --- fs/nfsd/export.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 43e109c..3ec3b6b 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -358,6 +358,18 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid) if (*flags & NFSEXP_V4ROOT) *flags |= NFSEXP_READONLY; + /* + * Convert to a readonly export for that, + * 1. not supported fsync filesystem, + * 2. readonly filesystem. + */ + if ((!inode->i_fop->fsync || IS_RDONLY(inode)) + && !(*flags & NFSEXP_READONLY)) { + dprintk("exp_export: Only support readonly export " + "for fsync unsupported or readonly filesystem.\n"); + *flags |= NFSEXP_READONLY; + } + /* There are two requirements on a filesystem to be exportable. * 1: We must be able to identify the filesystem from a number. * either a device number (so FS_REQUIRES_DEV needed)