From patchwork Fri May 10 15:32:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 10939055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B796F76 for ; Fri, 10 May 2019 15:33:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A418D28A3C for ; Fri, 10 May 2019 15:33:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97F1528B06; Fri, 10 May 2019 15:33:32 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CCD0828AAA for ; Fri, 10 May 2019 15:33:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A310621268FB3; Fri, 10 May 2019 08:33:30 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:41d0:602:dbe::8; helo=tartarus.angband.pl; envelope-from=kilobyte@angband.pl; receiver=linux-nvdimm@lists.01.org Received: from tartarus.angband.pl (tartarus.angband.pl [IPv6:2001:41d0:602:dbe::8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0DF342122CA87 for ; Fri, 10 May 2019 08:33:27 -0700 (PDT) Received: from [2a02:a31c:853f:a300::4] (helo=valinor.angband.pl) by tartarus.angband.pl with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hP7WH-0000MM-Hp; Fri, 10 May 2019 17:33:11 +0200 Received: from kilobyte by valinor.angband.pl with local (Exim 4.92) (envelope-from ) id 1hP7Vh-0006Qk-Qj; Fri, 10 May 2019 17:32:33 +0200 From: Adam Borowski To: linux-btrfs@vger.kernel.org, Goldwyn Rodrigues , linux-fsdevel@vger.kernel.org, jack@suse.cz, david@fromorbit.com, willy@infradead.org, hch@lst.de, darrick.wong@oracle.com, dsterba@suse.cz, nborisov@suse.com, linux-nvdimm@lists.01.org Date: Fri, 10 May 2019 17:32:22 +0200 Message-Id: <20190510153222.24665-1-kilobyte@angband.pl> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429172649.8288-13-rgoldwyn@suse.de> References: <20190429172649.8288-13-rgoldwyn@suse.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:a31c:853f:a300::4 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH for-goldwyn] btrfs: disallow MAP_SYNC outside of DAX mounts X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Adam Borowski Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Even if allocation is done synchronously, data would be lost except on actual pmem. Explicit msync()s don't need MAP_SYNC, and don't require a sync per page. Signed-off-by: Adam Borowski --- MAP_SYNC can't be allowed unconditionally, as cacheline flushes don't help guarantee persistency in page cache. This fixes an error in my earlier patch "btrfs: allow MAP_SYNC mmap" -- you'd probably want to amend that. fs/btrfs/file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 362a9cf9dcb2..0bc5428037ba 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2233,6 +2233,13 @@ static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma) if (!IS_DAX(inode) && !mapping->a_ops->readpage) return -ENOEXEC; + /* + * Normal operation of btrfs is pretty much an antithesis of MAP_SYNC; + * supporting it outside DAX is pointless. + */ + if (!IS_DAX(inode) && (vma->vm_flags & VM_SYNC)) + return -EOPNOTSUPP; + file_accessed(filp); if (IS_DAX(inode)) vma->vm_ops = &btrfs_dax_vm_ops;