[{"id":1766707,"web_url":"http://patchwork.ozlabs.org/comment/1766707/","msgid":"<20170912064144.GB16554@quack2.suse.cz>","list_archive_url":null,"date":"2017-09-12T06:41:44","subject":"Re: [PATCH v2 2/5] ext4: prevent data corruption with journaling +\n\tDAX","submitter":{"id":363,"url":"http://patchwork.ozlabs.org/api/people/363/","name":"Jan Kara","email":"jack@suse.cz"},"content":"On Mon 11-09-17 23:05:23, Ross Zwisler wrote:\n> The current code has the potential for data corruption when changing an\n> inode's journaling mode, as that can result in a subsequent unsafe change\n> in S_DAX.\n> \n> I've captured an instance of this data corruption in the following fstest:\n> \n> https://patchwork.kernel.org/patch/9948377/\n> \n> Prevent this data corruption from happening by disallowing changes to the\n> journaling mode if the '-o dax' mount option was used.  This means that for\n> a given filesystem we could have a mix of inodes using either DAX or\n> data journaling, but whatever state the inodes are in will be held for the\n> duration of the mount.\n> \n> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\n> Suggested-by: Jan Kara <jack@suse.cz>\n\nI guess this is fine for now to stop corrupting data so:\n\nReviewed-by: Jan Kara <jack@suse.cz>\n\nBut I think we should work on more user friendly (i.e., permissive)\nversion.\n\n\t\t\t\t\t\t\t\tHonza\n\n> ---\n>  fs/ext4/inode.c |  5 -----\n>  fs/ext4/ioctl.c | 16 +++++++++++++---\n>  2 files changed, 13 insertions(+), 8 deletions(-)\n> \n> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\n> index e963508..3207333 100644\n> --- a/fs/ext4/inode.c\n> +++ b/fs/ext4/inode.c\n> @@ -5971,11 +5971,6 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)\n>  \t\text4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);\n>  \t}\n>  \text4_set_aops(inode);\n> -\t/*\n> -\t * Update inode->i_flags after EXT4_INODE_JOURNAL_DATA was updated.\n> -\t * E.g. S_DAX may get cleared / set.\n> -\t */\n> -\text4_set_inode_flags(inode);\n>  \n>  \tjbd2_journal_unlock_updates(journal);\n>  \tpercpu_up_write(&sbi->s_journal_flag_rwsem);\n> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c\n> index afb66d4..b0b754b 100644\n> --- a/fs/ext4/ioctl.c\n> +++ b/fs/ext4/ioctl.c\n> @@ -290,10 +290,20 @@ static int ext4_ioctl_setflags(struct inode *inode,\n>  \tif (err)\n>  \t\tgoto flags_out;\n>  \n> -\tif ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))\n> +\tif ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {\n> +\t\t/*\n> +\t\t * Changes to the journaling mode can cause unsafe changes to\n> +\t\t * S_DAX if we are using the DAX mount option.\n> +\t\t */\n> +\t\tif (test_opt(inode->i_sb, DAX)) {\n> +\t\t\terr = -EBUSY;\n> +\t\t\tgoto flags_out;\n> +\t\t}\n> +\n>  \t\terr = ext4_change_inode_journal_flag(inode, jflag);\n> -\tif (err)\n> -\t\tgoto flags_out;\n> +\t\tif (err)\n> +\t\t\tgoto flags_out;\n> +\t}\n>  \tif (migrate) {\n>  \t\tif (flags & EXT4_EXTENTS_FL)\n>  \t\t\terr = ext4_ext_migrate(inode);\n> -- \n> 2.9.5\n>","headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xrwFN73tvz9sBZ\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 12 Sep 2017 16:42:00 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751028AbdILGlq (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 02:41:46 -0400","from mx2.suse.de ([195.135.220.15]:49134 \"EHLO mx1.suse.de\"\n\trhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP\n\tid S1750911AbdILGlq (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 12 Sep 2017 02:41:46 -0400","from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id EC073ADB4;\n\tTue, 12 Sep 2017 06:41:44 +0000 (UTC)","by quack2.suse.cz (Postfix, from userid 1000)\n\tid 7666C1E3442; Tue, 12 Sep 2017 08:41:44 +0200 (CEST)"],"X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","Date":"Tue, 12 Sep 2017 08:41:44 +0200","From":"Jan Kara <jack@suse.cz>","To":"Ross Zwisler <ross.zwisler@linux.intel.com>","Cc":"Theodore Ts'o <tytso@mit.edu>, Jan Kara <jack@suse.cz>,\n\tlinux-kernel@vger.kernel.org, Andreas Dilger <adilger.kernel@dilger.ca>,\n\tChristoph Hellwig <hch@lst.de>, Dan Williams <dan.j.williams@intel.com>,\n\tDave Chinner <david@fromorbit.com>, linux-ext4@vger.kernel.org,\n\tlinux-nvdimm@lists.01.org","Subject":"Re: [PATCH v2 2/5] ext4: prevent data corruption with journaling +\n\tDAX","Message-ID":"<20170912064144.GB16554@quack2.suse.cz>","References":"<20170912050526.7627-1-ross.zwisler@linux.intel.com>\n\t<20170912050526.7627-3-ross.zwisler@linux.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170912050526.7627-3-ross.zwisler@linux.intel.com>","User-Agent":"Mutt/1.5.24 (2015-08-30)","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"}},{"id":1785600,"web_url":"http://patchwork.ozlabs.org/comment/1785600/","msgid":"<20171012155522.nqnvemlarbxxnrcw@thunk.org>","list_archive_url":null,"date":"2017-10-12T15:55:22","subject":"Re: [PATCH v2 2/5] ext4: prevent data corruption with journaling +\n\tDAX","submitter":{"id":350,"url":"http://patchwork.ozlabs.org/api/people/350/","name":"Theodore Tso","email":"tytso@mit.edu"},"content":"On Mon, Sep 11, 2017 at 11:05:23PM -0600, Ross Zwisler wrote:\n> The current code has the potential for data corruption when changing an\n> inode's journaling mode, as that can result in a subsequent unsafe change\n> in S_DAX.\n> \n> I've captured an instance of this data corruption in the following fstest:\n> \n> https://patchwork.kernel.org/patch/9948377/\n> \n> Prevent this data corruption from happening by disallowing changes to the\n> journaling mode if the '-o dax' mount option was used.  This means that for\n> a given filesystem we could have a mix of inodes using either DAX or\n> data journaling, but whatever state the inodes are in will be held for the\n> duration of the mount.\n> \n> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\n> Suggested-by: Jan Kara <jack@suse.cz>\n\nThanks, applied.\n\n\t\t\t\t\t\t- Ted","headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=thunk.org header.i=@thunk.org\n\theader.b=\"GEOFvwCU\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yCb6R564lz9t2r\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 13 Oct 2017 02:55:43 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752779AbdJLPza (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 12 Oct 2017 11:55:30 -0400","from imap.thunk.org ([74.207.234.97]:40210 \"EHLO imap.thunk.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752691AbdJLPz2 (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tThu, 12 Oct 2017 11:55:28 -0400","from root (helo=callcc.thunk.org)\n\tby imap.thunk.org with local-esmtp (Exim 4.89)\n\t(envelope-from <tytso@thunk.org>)\n\tid 1e2fpT-0006BC-D4; Thu, 12 Oct 2017 15:55:23 +0000","by callcc.thunk.org (Postfix, from userid 15806)\n\tid A3965C0033F; Thu, 12 Oct 2017 11:55:22 -0400 (EDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org;\n\ts=ef5046eb;\n\th=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:\n\tSubject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=mZAix/q+uJO3MX0n3W7m+hzmGhodONNa7yYhfHCDF/I=;\n\tb=GEOFvwCUfPNtPBhwSBnDRReCz3\n\tHV+kApHSSE+mJoKSaJlgC2eC3CGu4MpIDb+EjsNCbFQUTzCT8QeQQoxDQ4lG3fGOGpYlNSspHGuZF\n\tE6pR9awwac5WCLhfhtuO64xEYPMj6Ph22ZN9kjOaeN+nnxyoTmozX2H59rvL6KhBW8m8=;","Date":"Thu, 12 Oct 2017 11:55:22 -0400","From":"Theodore Ts'o <tytso@mit.edu>","To":"Ross Zwisler <ross.zwisler@linux.intel.com>","Cc":"Jan Kara <jack@suse.cz>, linux-kernel@vger.kernel.org,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tChristoph Hellwig <hch@lst.de>, Dan Williams <dan.j.williams@intel.com>,\n\tDave Chinner <david@fromorbit.com>, linux-ext4@vger.kernel.org,\n\tlinux-nvdimm@lists.01.org","Subject":"Re: [PATCH v2 2/5] ext4: prevent data corruption with journaling +\n\tDAX","Message-ID":"<20171012155522.nqnvemlarbxxnrcw@thunk.org>","Mail-Followup-To":"Theodore Ts'o <tytso@mit.edu>,\n\tRoss Zwisler <ross.zwisler@linux.intel.com>,\n\tJan Kara <jack@suse.cz>, linux-kernel@vger.kernel.org,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tChristoph Hellwig <hch@lst.de>,\n\tDan Williams <dan.j.williams@intel.com>,\n\tDave Chinner <david@fromorbit.com>, linux-ext4@vger.kernel.org,\n\tlinux-nvdimm@lists.01.org","References":"<20170912050526.7627-1-ross.zwisler@linux.intel.com>\n\t<20170912050526.7627-3-ross.zwisler@linux.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170912050526.7627-3-ross.zwisler@linux.intel.com>","User-Agent":"NeoMutt/20170609 (1.8.3)","X-SA-Exim-Connect-IP":"<locally generated>","X-SA-Exim-Mail-From":"tytso@thunk.org","X-SA-Exim-Scanned":"No (on imap.thunk.org); SAEximRunCond expanded to false","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"}}]