Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/810308/?format=api
{ "id": 810308, "url": "http://patchwork.ozlabs.org/api/patches/810308/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20170905223541.20594-8-ross.zwisler@linux.intel.com/", "project": { "id": 8, "url": "http://patchwork.ozlabs.org/api/projects/8/?format=api", "name": "Linux ext4 filesystem development", "link_name": "linux-ext4", "list_id": "linux-ext4.vger.kernel.org", "list_email": "linux-ext4@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170905223541.20594-8-ross.zwisler@linux.intel.com>", "list_archive_url": null, "date": "2017-09-05T22:35:39", "name": "[7/9] ext4: prevent data corruption with inline data + DAX", "commit_ref": null, "pull_url": null, "state": "new", "archived": true, "hash": "d276ed1bb5d7a26a826647fc831e939ed3d449be", "submitter": { "id": 46514, "url": "http://patchwork.ozlabs.org/api/people/46514/?format=api", "name": "Ross Zwisler", "email": "ross.zwisler@linux.intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20170905223541.20594-8-ross.zwisler@linux.intel.com/mbox/", "series": [ { "id": 1660, "url": "http://patchwork.ozlabs.org/api/series/1660/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=1660", "date": "2017-09-05T22:35:36", "name": "add ext4 per-inode DAX flag", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1660/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810308/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810308/checks/", "tags": {}, "related": [], "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 3xn1p13hwwz9sP3\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 6 Sep 2017 08:38:17 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754485AbdIEWhr (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 5 Sep 2017 18:37:47 -0400", "from mga01.intel.com ([192.55.52.88]:31464 \"EHLO mga01.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1754017AbdIEWgU (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 5 Sep 2017 18:36:20 -0400", "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Sep 2017 15:36:18 -0700", "from theros.lm.intel.com ([10.232.112.77])\n\tby fmsmga004.fm.intel.com with ESMTP; 05 Sep 2017 15:36:17 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.41,481,1498546800\"; d=\"scan'208\";a=\"308314888\"", "From": "Ross Zwisler <ross.zwisler@linux.intel.com>", "To": "Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org", "Cc": "Ross Zwisler <ross.zwisler@linux.intel.com>,\n\t\"Darrick J. Wong\" <darrick.wong@oracle.com>,\n\t\"Theodore Ts'o\" <tytso@mit.edu>,\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>, Jan Kara <jack@suse.cz>,\n\tlinux-ext4@vger.kernel.org, linux-nvdimm@lists.01.org,\n\tlinux-xfs@vger.kernel.org, stable@vger.kernel.org", "Subject": "[PATCH 7/9] ext4: prevent data corruption with inline data + DAX", "Date": "Tue, 5 Sep 2017 16:35:39 -0600", "Message-Id": "<20170905223541.20594-8-ross.zwisler@linux.intel.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20170905223541.20594-1-ross.zwisler@linux.intel.com>", "References": "<20170905223541.20594-1-ross.zwisler@linux.intel.com>", "Sender": "linux-ext4-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-ext4.vger.kernel.org>", "X-Mailing-List": "linux-ext4@vger.kernel.org" }, "content": "If an inode has inline data it is currently prevented from using DAX by a\ncheck in ext4_should_use_dax(). When the inode grows inline data via\next4_create_inline_data() or removes its inline data via\next4_destroy_inline_data_nolock(), the value of S_DAX can change.\n\nCurrently these changes are unsafe because we don't hold off page faults\nand I/O, write back dirty radix tree entries and invalidate all mappings.\nThis work is done in XFS via xfs_ioctl_setattr_dax_invalidate(), for\nexample. This unsafe transitioning of S_DAX could potentially lead to data\ncorruption.\n\nFix this issue by preventing the DAX mount option from being used on\nfilesystems that were created to support inline data. Inline data is an\noption given to mkfs.ext4.\n\nWe prevent DAX from being used with inline data as opposed to trying to\nsafely manage the transition of S_DAX because of the locking complexities:\n\n1) filemap_write_and_wait() eventually calls ext4_writepages(), which\nacquires the sbi->s_journal_flag_rwsem. This lock ranks above the\njbdw_handle which is eventually taken by ext4_journal_start(). This\nessentially means that the writeback has to happen outside of the context\nof an active journal handle (outside of ext4_journal_start() to\next4_journal_stop().)\n\n2) To lock out page faults we take a write lock on the ei->i_mmap_sem, and\nthis lock again ranks above the jbd2_handle taken by ext4_journal_start().\nSo, as with the writeback code in 1) above we have to take ei->i_mmap_sem\noutside of the context of an active journal handle.\n\nWe are able to work around both of these restrictions and safely transition\nS_DAX when we change the journaling mode, but for inline data it's much\nharder because each of ext4_create_inline_data() and\next4_destroy_inline_data_nolock() are passed in journal handles that have\nalready been started.\n\nTo be able to safely writeback and invalidate our dirty inode data we'd\neither need to uplevel the locking, writeback and invalidate into all the\ncallers of those two functions, or we'd need to stop our current journal\nhandle, do the appropriate locking, writeback and invalidate, unlock and\nrestart the journal handle.\n\nThese both seem too complex, and I don't know if we have a valid use case\nwhere we need to combine a filesystem with inline data and DAX, so just\nprevent them from being used together.\n\nSigned-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\nCC: stable@vger.kernel.org\n---\n fs/ext4/inline.c | 10 ----------\n fs/ext4/super.c | 5 +++++\n 2 files changed, 5 insertions(+), 10 deletions(-)", "diff": "diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c\nindex 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);\ndiff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex d61a70e2..d549dfb 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -3686,6 +3686,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", "prefixes": [ "7/9" ] }