From patchwork Tue Jan 7 03:42:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13928055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A8CE77199 for ; Tue, 7 Jan 2025 03:43:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9BE16B009F; Mon, 6 Jan 2025 22:43:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D23A56B00A0; Mon, 6 Jan 2025 22:43:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B29356B00A1; Mon, 6 Jan 2025 22:43:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8BE6F6B009F for ; Mon, 6 Jan 2025 22:43:39 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 434A143D5F for ; Tue, 7 Jan 2025 03:43:39 +0000 (UTC) X-FDA: 82979261358.06.E5E2C05 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by imf19.hostedemail.com (Postfix) with ESMTP id 7DA4D1A0006 for ; Tue, 7 Jan 2025 03:43:36 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=riZWvP+E; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf19.hostedemail.com: domain of apopple@nvidia.com designates 40.107.223.59 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1736221416; a=rsa-sha256; cv=pass; b=k/oIf2/HT7wWr9RSUlDtzN8m4qtru/0twEnZb0oa6oXYk+MLAFdKvGjGo+hJWFTd4WU77F er0IshFmo4qBzjvPEh6VdB7gbLzf8uQFRNXZ0Ma1TYS8sGdejhE13G65KtC+7cOusr1Fiy 6Kdtkl3DrCMB5tLvKdVugHRRXZKUFjg= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=riZWvP+E; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf19.hostedemail.com: domain of apopple@nvidia.com designates 40.107.223.59 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736221416; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mA6IK/Y2KuCTn5DEQhgF4VkZcX2IeUmqIqn2SXK5C70=; b=cS9igqxGlMoCwk7SiGFogoHpUKj1VuXX9QpLJvqiUe6lrKrF5O5tSOQubrHbBJJvcmQ4vf BojV0GuA1mtBM/0XRchXyGEUl+NMwg/+Ot1YKfKXRZB+IdajNFCZwaFpD2FNYToP9VP6wA rTKQpV6vxhQOjs6cq6nUwaTUaB16ng0= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PFVigdnyIX9L5fo+Hsq/QhQu4W7puYLOE+yiImA0k5JSSZj12awuoTzHLYdNKkcCyh1F8aPFRw+Snylyo8QGKCfcizCyC8kOH9mM2NQekKOjQpcZr7oap6W2P8114pNjmC5fGaQeMZNSWMAI2qtFI4e8cGjZBRLDEL/LS3Gc0zyArB8/btUBWKa2l/02sKVcKhz/sBitDC/ZvkDu4j4TxW+ca4zmYIh/lKmqDzMzt413mwHy3oZ+8trwxyvqjhqwOaKWO8XzuQKEpCwoJVuZ2mLOTOkBj+jDlGICnxCrUM9YVoPlX7+SSomndm2qppGOP1LxTzYhz+b40RQ+x7lfGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mA6IK/Y2KuCTn5DEQhgF4VkZcX2IeUmqIqn2SXK5C70=; b=rVlfBO63MstjnqUEhroa0DRHlGVsflOWMj6Yb5C4VDAuTSponLfIFTqjS2j0q0h1np4+e6pI0JP1MsX23JEfian4f17cxe5PDh1JGC7x83C3Qy6lfFnHJ2F4HBBjPLeddk8xlOq/eWbcnNWyI3a3fuNBrvYYc4Fu+hpn1JcNRhzJ/B0bJ1yM/CwwBpvFubapBFueiyXCYLaAe+EQTP0lB41Roj6OACh14ydXEMswn9KpiScNt1lo2Hg447asUgXYHi+Ymzf+2KqKThMRMOOEGBol9WF7x5kasEX5tAiAG7uuWmfYwShI42Uhjnjaj8aWkSdKqptlt2u/zeSAZlkDlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mA6IK/Y2KuCTn5DEQhgF4VkZcX2IeUmqIqn2SXK5C70=; b=riZWvP+EugTc6rJRGdNjp0WuNgtsR4y2D2ueLZAmwfY9xmTz9ktax1PcyhwtsZoipxgHplwIX1VQVEh/+4wkgyTIh55M+XMz8BS9E45EvkRWJG0zWLgyc1NqY2ZQdDDH9nEMHICSkw9587O0k8fjCwJ8YdtAjdaSv1yYDIDbOijTVkOju4JKNYUb5lP8Z2S2o8FEZh7g0i5A6jKbxbcWyHITUTA0PNL5ZTTroROrdUaW03llZ0wh0izig/LAVMa5SkUwDne77zKJ3l0FsWk2ggqISvaxyLN90r9W5937FD2KVxTN8JOGqoEtnOFrmjA0hb/cadG7z8pexYrqSiwcKQ== Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CY5PR12MB6129.namprd12.prod.outlook.com (2603:10b6:930:27::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.15; Tue, 7 Jan 2025 03:43:30 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%6]) with mapi id 15.20.8314.015; Tue, 7 Jan 2025 03:43:30 +0000 From: Alistair Popple To: akpm@linux-foundation.org, dan.j.williams@intel.com, linux-mm@kvack.org Cc: Alistair Popple , lina@asahilina.net, zhang.lyra@gmail.com, gerald.schaefer@linux.ibm.com, vishal.l.verma@intel.com, dave.jiang@intel.com, logang@deltatee.com, bhelgaas@google.com, jack@suse.cz, jgg@ziepe.ca, catalin.marinas@arm.com, will@kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, dave.hansen@linux.intel.com, ira.weiny@intel.com, willy@infradead.org, djwong@kernel.org, tytso@mit.edu, linmiaohe@huawei.com, david@redhat.com, peterx@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jhubbard@nvidia.com, hch@lst.de, david@fromorbit.com Subject: [PATCH v5 07/25] fs/dax: Ensure all pages are idle prior to filesystem unmount Date: Tue, 7 Jan 2025 14:42:23 +1100 Message-ID: <5eadb9096a42f993273cdd755124955665dcea26.1736221254.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: X-ClientProxiedBy: SYBPR01CA0164.ausprd01.prod.outlook.com (2603:10c6:10:d::32) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CY5PR12MB6129:EE_ X-MS-Office365-Filtering-Correlation-Id: 8181a272-27e5-4f39-09ec-08dd2ecd73b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: kMIxnItGqEUiTrFQH/PLNeGA8a0Ab+idc8fNPBifgYLaddvBX0VUjdeGLDH2x5SRAk2TJGjWMKHzPDrf6g33Nm0k1gdUA1R6LB5H9QeZwtMF8ufi/b4oO288p8sh5rX6FV7aQPtNX6Lu/s2eSW+ieiFzLi3+dSTMlgC/qDOa88MpkzFgo7suSrtbxC6BPwCd7zSQ2+riOVpretXezQYSPNYCWn1snRh7f2hzBSmEkfQ+AvDY2vnwKPKTg27nN136mFdvvTyKEuCo2gwCqHhF6RU6pcCRCQlJHmzApz27xjdRypjkTehvy0vlQDB4ZMcWJXYUR+kcIRBSbC5GsBku2MuadwsO65amQZD8e46R6lDO8OLZOUE21JiG+gEAJTPBMnQlO5pY0y57ba3nEjstc2QYi5/UvfX30pHK+wFUYXszetktpHWQRkqhp8vGz13+6BlKkomlhhzo+oHANTiYuX50CQOc+yRsSrWa9XZ5P01UDODLTxgiP2rxuCqfEgBM0oOHj5kK2D9C5AFAwGsTyvmrLZwQ+aop0uD2KlmctY4GsR1ESIKsxQd55nt8ymX4vzrLG6nkbK6KDP/hqmlGhW3kn+odqy3wLtE5OcD5V845X+2CKJoNETAYGetvvQu1ecy4ehP2hSsZkE6mmuAr4u56dmCHzfUzJwwbOwfHGM+i2SgHOO4FBjZ3ZbY/WC3L9+MAOh5zBc6lpaUacRmvZ9hngw9xYn1gb639QKRV8d+AazR62aUc6L0A5zMN6XVKDjWB6AZ8vzvpxM9D4yfafIw2jsfyGNXsavF5et1TTNKjuNd9jJix23lpkFjifPBBw2siwbRceKcCZuwBq3g4/+/bVIRl4T4VjrD+dpHMZtUheBwHWmljNcFEQXx76Vv8iFcpX5gfnNFcfSQDXjiA+UhAkgnmJgXC2rz9bhgVisbm21GschAlpZ25ItH3hnqDIY1jyREHy0VsVpeitQNr5kahoj6naujoC6ptxMVcSpQuYiBSdPl8kpuyw7W8/pNukj7NwCr+jkN1Vn6jXBfgqhSrsck4cY/QLsa0YT/UpaWgr/8ezHl5pqDM6z1dsHLj5BhsALmtJ5uETszRDmiRIud3DcwuZUsWP2WOKv714dDep5pw+13jPh3RnQ1v6IBNjwMs9wrE4/J31B7QwOmStD4imPVRUIYsW6lv580DPUI9UFF8kuuvIdjaAMUhZQYc2kTB9IkJNVcdu3zIILhKfh0JCwM5/TD1x+MmwUl1PrMk27tkVtwK5PIPTfHQj/YHyP+py7Mks36aJHNZCuNcURw6s/9OT+yYmdSbERswFMK1VYfG5asDpKaIyI+UDzq9hUc7dH6EiKRwDwAQjiWSkdvGBvDNGE5V0RL8NHxMBxegTbwwzBLmUVxdt8wsQGAy X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k4PBzmYvr4CjoeQdetj83yZAI54DA0cILOA3GBXofhU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fTfpCa02SOPXqFk5cQcZjx0ie6gBHqhsWP4+j3RD0a881cdNfuGKFfLszl4yE5+7K1ll2Ygb4OmIgWkw4fZUmbIvfiCPTA67mXPyjD8UXoo/YsoYLrpoqnhjlMzzymcs/THLTwV2EX9VAhFXmbfVL1tYuel/Byxmz20nCe4nNScuo/lup34mFpy66v1ZWP0IurC2+ZIiw3WJjs5sKl50+zVR4DavgnojFrL9QrOfIvGP/qgJQlLyOlpfIa/QYmX9gSlT93CX/ZLg4fQhLQw6d10J533sxrD9VcRUcCsIebGuqMcxTUmnF2QUzJiqb/8zpPvJghOmY6QbpPEH2aeDgD4zcwgEHcY/tZ8gwjtLlu9ePPBFI4g6NgtO0Mi3fcYukfkVWwTI0CyHAj8Ye4v4o6V3q/JlgS7XFpbfwjy/c+Nfxbsl0PEm5Q8BP67VVH11IohSNLR5te+8GkxzkN6/WnJ4+kaHgI2IpnhfLY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8181a272-27e5-4f39-09ec-08dd2ecd73b4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 03:43:30.4150 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tZUUcMMgXWSpZvFo+SNizVhxlUYntUuJuYJPi4R0cgeSCi8B1ihUt+zb/nm9vSZNM7MGkJrpqc1F/zCOBB1qrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6129 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7DA4D1A0006 X-Stat-Signature: 6frwodqcrx989smsnpugywthy4sayjex X-Rspam-User: X-HE-Tag: 1736221416-51511 X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ia644oxr1IYsy6zxXqBA/xwWVf2s9JUjYpzK6e4T0SLxog0VL0HQfPjm8+zgA0ujrw6O4BIEqeXef+PqUjTMSMW5SNwlleuELfbfQMALeq+KhNtFEvmLE5AdCe9PIMNTKH9sXt9qEsgSumiADouXTLaP/A0CX8hAVVf52MdBhPal2ibKzf9v5lfsss4PZmYQ28PWf1C0La1RVoNlvJZKbOXHsV6//hZd8Qnb3WyROvvTV+ZcBCbDc9LeasCfOxzWt2e5C84EsXRp3WWucfo0umqSTL3Imp1XZ0bPHfShGlmheXxoxdU0aaM7ynpX2OPZLN9bJhzCteRtn2Nluqzs8x X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: File systems call dax_break_mapping() prior to reallocating file system blocks to ensure the page is not undergoing any DMA or other accesses. Generally this is needed when a file is truncated to ensure that if a block is reallocated nothing is writing to it. However filesystems currently don't call this when an FS DAX inode is evicted. This can cause problems when the file system is unmounted as a page can continue to be under going DMA or other remote access after unmount. This means if the file system is remounted any truncate or other operation which requires the underlying file system block to be freed will not wait for the remote access to complete. Therefore a busy block may be reallocated to a new file leading to corruption. Signed-off-by: Alistair Popple --- Changes for v5: - Don't wait for pages to be idle in non-DAX mappings --- fs/dax.c | 29 +++++++++++++++++++++++++++++ fs/ext4/inode.c | 32 ++++++++++++++------------------ fs/xfs/xfs_inode.c | 9 +++++++++ fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_super.c | 18 ++++++++++++++++++ include/linux/dax.h | 2 ++ 6 files changed, 73 insertions(+), 18 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 7008a73..4e49cc4 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -883,6 +883,14 @@ static int wait_page_idle(struct page *page, TASK_INTERRUPTIBLE, 0, 0, cb(inode)); } +static void wait_page_idle_uninterruptible(struct page *page, + void (cb)(struct inode *), + struct inode *inode) +{ + ___wait_var_event(page, page_ref_count(page) == 1, + TASK_UNINTERRUPTIBLE, 0, 0, cb(inode)); +} + /* * Unmaps the inode and waits for any DMA to complete prior to deleting the * DAX mapping entries for the range. @@ -911,6 +919,27 @@ int dax_break_mapping(struct inode *inode, loff_t start, loff_t end, } EXPORT_SYMBOL_GPL(dax_break_mapping); +void dax_break_mapping_uninterruptible(struct inode *inode, + void (cb)(struct inode *)) +{ + struct page *page; + + if (!dax_mapping(inode->i_mapping)) + return; + + do { + page = dax_layout_busy_page_range(inode->i_mapping, 0, + LLONG_MAX); + if (!page) + break; + + wait_page_idle_uninterruptible(page, cb, inode); + } while (true); + + dax_delete_mapping_range(inode->i_mapping, 0, LLONG_MAX); +} +EXPORT_SYMBOL_GPL(dax_break_mapping_uninterruptible); + /* * Invalidate DAX entry if it is clean. */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ee8e83f..fa35161 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -163,6 +163,18 @@ int ext4_inode_is_fast_symlink(struct inode *inode) (inode->i_size < EXT4_N_BLOCKS * 4); } +static void ext4_wait_dax_page(struct inode *inode) +{ + filemap_invalidate_unlock(inode->i_mapping); + schedule(); + filemap_invalidate_lock(inode->i_mapping); +} + +int ext4_break_layouts(struct inode *inode) +{ + return dax_break_mapping_inode(inode, ext4_wait_dax_page); +} + /* * Called at the last iput() if i_nlink is zero. */ @@ -181,6 +193,8 @@ void ext4_evict_inode(struct inode *inode) trace_ext4_evict_inode(inode); + dax_break_mapping_uninterruptible(inode, ext4_wait_dax_page); + if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL) ext4_evict_ea_inode(inode); if (inode->i_nlink) { @@ -3902,24 +3916,6 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset, return ret; } -static void ext4_wait_dax_page(struct inode *inode) -{ - filemap_invalidate_unlock(inode->i_mapping); - schedule(); - filemap_invalidate_lock(inode->i_mapping); -} - -int ext4_break_layouts(struct inode *inode) -{ - struct page *page; - int error; - - if (WARN_ON_ONCE(!rwsem_is_locked(&inode->i_mapping->invalidate_lock))) - return -EINVAL; - - return dax_break_mapping_inode(inode, ext4_wait_dax_page); -} - /* * ext4_punch_hole: punches a hole in a file by releasing the blocks * associated with the given offset and length diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 4410b42..c7ec5ab 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2997,6 +2997,15 @@ xfs_break_dax_layouts( return dax_break_mapping_inode(inode, xfs_wait_dax_page); } +void +xfs_break_dax_layouts_uninterruptible( + struct inode *inode) +{ + xfs_assert_ilocked(XFS_I(inode), XFS_MMAPLOCK_EXCL); + + dax_break_mapping_uninterruptible(inode, xfs_wait_dax_page); +} + int xfs_break_layouts( struct inode *inode, diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index c4f03f6..613797a 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -594,6 +594,7 @@ xfs_itruncate_extents( } int xfs_break_dax_layouts(struct inode *inode); +void xfs_break_dax_layouts_uninterruptible(struct inode *inode); int xfs_break_layouts(struct inode *inode, uint *iolock, enum layout_break_reason reason); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 8524b9d..73ec060 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -751,6 +751,23 @@ xfs_fs_drop_inode( return generic_drop_inode(inode); } +STATIC void +xfs_fs_evict_inode( + struct inode *inode) +{ + struct xfs_inode *ip = XFS_I(inode); + uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL; + + if (IS_DAX(inode)) { + xfs_ilock(ip, iolock); + xfs_break_dax_layouts_uninterruptible(inode); + xfs_iunlock(ip, iolock); + } + + truncate_inode_pages_final(&inode->i_data); + clear_inode(inode); +} + static void xfs_mount_free( struct xfs_mount *mp) @@ -1189,6 +1206,7 @@ static const struct super_operations xfs_super_operations = { .destroy_inode = xfs_fs_destroy_inode, .dirty_inode = xfs_fs_dirty_inode, .drop_inode = xfs_fs_drop_inode, + .evict_inode = xfs_fs_evict_inode, .put_super = xfs_fs_put_super, .sync_fs = xfs_fs_sync_fs, .freeze_fs = xfs_fs_freeze, diff --git a/include/linux/dax.h b/include/linux/dax.h index ef9e02c..7c3773f 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -274,6 +274,8 @@ static inline int __must_check dax_break_mapping_inode(struct inode *inode, { return dax_break_mapping(inode, 0, LLONG_MAX, cb); } +void dax_break_mapping_uninterruptible(struct inode *inode, + void (cb)(struct inode *)); int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same,