[{"id":1766705,"web_url":"http://patchwork.ozlabs.org/comment/1766705/","msgid":"<20170912063838.GA16554@quack2.suse.cz>","list_archive_url":null,"date":"2017-09-12T06:38:38","subject":"Re: [PATCH v2 1/5] ext4: prevent data corruption with inline data +\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:22, Ross Zwisler wrote:\n> If an inode has inline data it is currently prevented from using DAX by a\n> check in ext4_set_inode_flags().  When the inode grows inline data via\n> ext4_create_inline_data() or removes its inline data via\n> ext4_destroy_inline_data_nolock(), the value of S_DAX can change.\n> \n> Currently these changes are unsafe because we don't hold off page faults\n> and I/O, write back dirty radix tree entries and invalidate all mappings.\n> There are also issues with mm-level races when changing the value of S_DAX,\n> as well as issues with the VM_MIXEDMAP flag:\n> \n> https://www.spinics.net/lists/linux-xfs/msg09859.html\n> \n> The unsafe transition of S_DAX can reliably cause data corruption, as shown\n> by the following fstest:\n> \n> https://patchwork.kernel.org/patch/9948381/\n> \n> Fix this issue by preventing the DAX mount option from being used on\n> filesystems that were created to support inline data.  Inline data is an\n> option given to mkfs.ext4.\n> \n> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\n> CC: stable@vger.kernel.org\n\nLooks good. You can add:\n\nReviewed-by: Jan Kara <jack@suse.cz>\n\n\t\t\t\t\t\t\t\tHonza\n\n> ---\n>  fs/ext4/inline.c | 10 ----------\n>  fs/ext4/super.c  |  5 +++++\n>  2 files changed, 5 insertions(+), 10 deletions(-)\n> \n> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c\n> index 28c5c3a..fd95019 100644\n> --- a/fs/ext4/inline.c\n> +++ b/fs/ext4/inline.c\n> @@ -302,11 +302,6 @@ static int ext4_create_inline_data(handle_t *handle,\n>  \tEXT4_I(inode)->i_inline_size = len + EXT4_MIN_INLINE_DATA_SIZE;\n>  \text4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);\n>  \text4_set_inode_flag(inode, EXT4_INODE_INLINE_DATA);\n> -\t/*\n> -\t * Propagate changes to inode->i_flags as well - e.g. S_DAX may\n> -\t * get cleared\n> -\t */\n> -\text4_set_inode_flags(inode);\n>  \tget_bh(is.iloc.bh);\n>  \terror = ext4_mark_iloc_dirty(handle, inode, &is.iloc);\n>  \n> @@ -451,11 +446,6 @@ static int ext4_destroy_inline_data_nolock(handle_t *handle,\n>  \t\t}\n>  \t}\n>  \text4_clear_inode_flag(inode, EXT4_INODE_INLINE_DATA);\n> -\t/*\n> -\t * Propagate changes to inode->i_flags as well - e.g. S_DAX may\n> -\t * get set.\n> -\t */\n> -\text4_set_inode_flags(inode);\n>  \n>  \tget_bh(is.iloc.bh);\n>  \terror = ext4_mark_iloc_dirty(handle, inode, &is.iloc);\n> diff --git a/fs/ext4/super.c b/fs/ext4/super.c\n> index c9e7be5..4251e50 100644\n> --- a/fs/ext4/super.c\n> +++ b/fs/ext4/super.c\n> @@ -3707,6 +3707,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)\n>  \t}\n>  \n>  \tif (sbi->s_mount_opt & EXT4_MOUNT_DAX) {\n> +\t\tif (ext4_has_feature_inline_data(sb)) {\n> +\t\t\text4_msg(sb, KERN_ERR, \"Cannot use DAX on a filesystem\"\n> +\t\t\t\t\t\" that may contain inline data\");\n> +\t\t\tgoto failed_mount;\n> +\t\t}\n>  \t\terr = bdev_dax_supported(sb, blocksize);\n>  \t\tif (err)\n>  \t\t\tgoto failed_mount;\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 3xrw9r2Bwpz9s7g\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 12 Sep 2017 16:38:56 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751141AbdILGil (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 02:38:41 -0400","from mx2.suse.de ([195.135.220.15]:48978 \"EHLO mx1.suse.de\"\n\trhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP\n\tid S1750911AbdILGil (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 12 Sep 2017 02:38:41 -0400","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id 34D24ADB4;\n\tTue, 12 Sep 2017 06:38:39 +0000 (UTC)","by quack2.suse.cz (Postfix, from userid 1000)\n\tid 6080D1E3442; Tue, 12 Sep 2017 08:38:38 +0200 (CEST)"],"X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","Date":"Tue, 12 Sep 2017 08:38:38 +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, stable@vger.kernel.org","Subject":"Re: [PATCH v2 1/5] ext4: prevent data corruption with inline data +\n\tDAX","Message-ID":"<20170912063838.GA16554@quack2.suse.cz>","References":"<20170912050526.7627-1-ross.zwisler@linux.intel.com>\n\t<20170912050526.7627-2-ross.zwisler@linux.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170912050526.7627-2-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":1785597,"web_url":"http://patchwork.ozlabs.org/comment/1785597/","msgid":"<20171012155227.o3dql7teq6gkghfo@thunk.org>","list_archive_url":null,"date":"2017-10-12T15:52:27","subject":"Re: [PATCH v2 1/5] ext4: prevent data corruption with inline data +\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:22PM -0600, Ross Zwisler wrote:\n> If an inode has inline data it is currently prevented from using DAX by a\n> check in ext4_set_inode_flags().  When the inode grows inline data via\n> ext4_create_inline_data() or removes its inline data via\n> ext4_destroy_inline_data_nolock(), the value of S_DAX can change.\n> \n> Currently these changes are unsafe because we don't hold off page faults\n> and I/O, write back dirty radix tree entries and invalidate all mappings.\n> There are also issues with mm-level races when changing the value of S_DAX,\n> as well as issues with the VM_MIXEDMAP flag:\n> \n> https://www.spinics.net/lists/linux-xfs/msg09859.html\n> \n> The unsafe transition of S_DAX can reliably cause data corruption, as shown\n> by the following fstest:\n> \n> https://patchwork.kernel.org/patch/9948381/\n> \n> Fix this issue by preventing the DAX mount option from being used on\n> filesystems that were created to support inline data.  Inline data is an\n> option given to mkfs.ext4.\n> \n> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\n> CC: stable@vger.kernel.org\n\nThanks, applied.\n\n\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=\"mP7W66RV\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yCb3F4F7wz9t2r\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 13 Oct 2017 02:52:57 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752311AbdJLPwn (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 12 Oct 2017 11:52:43 -0400","from imap.thunk.org ([74.207.234.97]:40176 \"EHLO imap.thunk.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751517AbdJLPwm (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tThu, 12 Oct 2017 11:52:42 -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 1e2fmd-0006A2-Ty; Thu, 12 Oct 2017 15:52:27 +0000","by callcc.thunk.org (Postfix, from userid 15806)\n\tid 3750AC0033F; Thu, 12 Oct 2017 11:52:27 -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=2MrbFkDNSu51QLxxPLI5oZPbY8FGKjCWUf6ZVsCgk6Y=;\n\tb=mP7W66RV1v3mPY2ftei4WrSg1f\n\trRVhu5T3HrMeJdalIIlsv0Bj1V1l/Ip2v/t3rDPnLuCIkk46w60Y42KibB37TKwUuzg05o2MuHWKS\n\tt/sRlHFrA4R/ZJmTdV0avmPanTs8UbtxzWIgncp8d8XBMD+VPbVb2xXsSO02boLQ3guo=;","Date":"Thu, 12 Oct 2017 11:52:27 -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, stable@vger.kernel.org","Subject":"Re: [PATCH v2 1/5] ext4: prevent data corruption with inline data +\n\tDAX","Message-ID":"<20171012155227.o3dql7teq6gkghfo@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, stable@vger.kernel.org","References":"<20170912050526.7627-1-ross.zwisler@linux.intel.com>\n\t<20170912050526.7627-2-ross.zwisler@linux.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170912050526.7627-2-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"}}]