From patchwork Tue Dec 17 05:12:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13911109 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2810DE7716A for ; Tue, 17 Dec 2024 05:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8p0f5STc3jZ7dypfmVkR93SWOiB4Au8VequleXzSvOU=; b=1rSStzM+tBE+dmjYiLQH76vg2u 7QG8dnX263oLcGFssgdDXqUjc7p1PeCX32YvZusFc1jvOsffNkO1VqwAF+mQcedbMxvjkSg0ClYTI 9yohZKAuGiDAWY9j5NxVf96qgfThlUduFrboQf9qpHMknWOl/KSpnomzr4tRKR94fHFKYjMuXEvGm 6TDeAg3InRZB3oEPx4edEkpx4wbnAAoDZ69LAwv+cZM8+xTnBkxON41rkPR2RtH1+FCN9XfRkpGGx pjzKLF6G9fvifOH2QasV+shmFY1vSIejgZGml466ZR9yZkmuy0539VDORHBmhb+dQduC5tDNVgQz1 Rjpr4xEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tNQ0B-0000000CFaT-3og0; Tue, 17 Dec 2024 05:20:11 +0000 Received: from mail-dm6nam11on20608.outbound.protection.outlook.com ([2a01:111:f403:2415::608] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tNPuB-0000000CD6V-08WY for linux-arm-kernel@lists.infradead.org; Tue, 17 Dec 2024 05:14:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dZeDZTeS+TQgSebGS+9n5lswdsEgyXAH1KEVxk6X6a0z9vnaOknOLGTJrQtDKONakTTRYkyvb4MFb+SY95cUKK2Pd/n981hVZfvC2JcHP9AiFPnRBtFacaG1lwxb6bh6JueZL1kGhfVkFj6WP/rlNdTBptEdrKHZySCORXzhIf1p0MTbx18520MQFhuCsGqjcd8QeDKpDE2o9xmmido1Ram20i1zTZL5sx3qqZq5z21bGHZGcrnvp5h8BJdwffTWVgc8NscEFKQtj0rYsve6y/Zlmxs1SR1Po1hDaclrEwepJ4/WRBjIh4/V+9x6uoWaS6gTnrXbHRLVRss4gHIIVQ== 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=8p0f5STc3jZ7dypfmVkR93SWOiB4Au8VequleXzSvOU=; b=Z1JV//oYA56VWqeOAObWm5/01TuUpsLG1sEp6NQdrNR5xuuKW1NGqDqdsotuGpB5EKxMcODSJi0EnrUrlLtmr33gaGwQtABvhbJQ4COaasyJJq0HBbJTGZWbuBzYM1KHYQZ3IpbiJipWMUWS881jaSKCBfsPRV2ANOqWKSJJyy3B3lvXDNQpN7xLZixEKuDfR50fzLQd3mdcIR7LrLpgfjTeFGg9NxgsJ+vacdT4BAR1tEdfbd5q4FMqcg8XiaSBrR7JRmkm+mQUm9G6IDfHhaj66HCsIjh+cdDlTNYU1yI5FktH5p4sU2iNG8wi5PdLIY28xPhPDgjzbT231hugTg== 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=8p0f5STc3jZ7dypfmVkR93SWOiB4Au8VequleXzSvOU=; b=JKHNlyXKgo4YHc/Fs21PhnRUfoZ9iR9i1iXj1XcmWLNKhM0/SicRohXpSEqBN247dlU32ofSmLd3KGCwLd1VVRrZ79ixfGmYqsnvXF2Df2jLXtuCbhRFaqw/aa6MWUwfDF38ZJ/jP62irVouqW12jeoSySYTAVNjt617W4cxItLsAuw6amRFbwIQnRdPPS4oCPnOStZJoAFa1pvH9Kxsavx6z0n3cMXJE1aQ96o4RCBFDJ7ENqe6j3FcACbYLAMt4OlgsjB/EDbYg9yaAIh1ViPtnq4eX0Gagk3twSdHr+SnqBWLTBPjGAkI55Gay6EbDalEsDySjKiCDHlSAtGP5Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH3PR12MB8936.namprd12.prod.outlook.com (2603:10b6:610:179::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Tue, 17 Dec 2024 05:13:53 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.8251.015; Tue, 17 Dec 2024 05:13:53 +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 v4 05/25] fs/dax: Create a common implementation to break DAX layouts Date: Tue, 17 Dec 2024 16:12:48 +1100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: X-ClientProxiedBy: SY5PR01CA0051.ausprd01.prod.outlook.com (2603:10c6:10:1fc::11) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH3PR12MB8936:EE_ X-MS-Office365-Filtering-Correlation-Id: 1609b788-e811-48b8-d423-08dd1e599990 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|366016; X-Microsoft-Antispam-Message-Info: 6uAGNTVtzvJ9GKkP1DgOY/DqIfX9RK/oAWPMjmX1xkKWZPxOr2e78NrGV7yt4rig3GfT6ang1ABW4RxAXMk1K9mKpN6J/lgNpR1kEyL2vqn5Lc7n7lvmh7xAnnwZ+9pyh5HkCha9iFCFyh02a/DvwWWQrw3eDxN9B/pXgGG8zQ9lcyJILjtB9uA4UxRxZP8lEo2MgVYi3w9bg97WyOmuEaBOVpanOIWzd/vfXZocDIEjPHKMKCYZ4VHmgu1jLyabJ9mWCfCmAYNVh7+YzEuiqZv+zza8IgJI+S9x3gSBB8Xqfc+TGcfNo1rLs7YbsGeDFMH2D3luJv/uPbeoY7wDfWbeX5zMLQxUTsUDVofs8e65wWEA2TzZcQ7OW0W3Fd6Qm7OefkyHjRxA5y3xaC4SSUnjNLZ8L/OasB6GPvLRB6FA4kDyGhsXVkqFcUqY4a7TrqKfr4a7J+iG9JqCx/LG4sP/y47QhVUcMnr+1kO2/ZMB79qQ9I2dhP2X7AH6eNxNhxn4YM69xvoe/iXzX2UmmQmCnKvmayNQ4LCyHv509SsNfO+joBdQ47O6wpRk5acTJNAoqWHK7u2XbDCWxMfAvZ35YfE0S7Jn+R/yHGUAOpjafzv95Suy9ky7ErO1CHAL6ZQjtanTpjB2swATW7Qcej4eXz7D4IcqJ93pfN2e5g8WuKw8rml07m1RAbS775/3o0+cinHWruP7sO1NhCmfFMMVFN+EwpIWwHomC3WtnFRlGXDisyNCKAY4baml12wfrIsXdaKg/m88whEnsyZaS2iKcqw3W6wNRmCAyyPYRD5OEjKeGsF+h2KJLUA9y8X0Dbke/V1I0Eq/Y/hqW5VAdCCotBIutE8Uck8ZaFybMnBBMxcUKhtR1qARRGdWtLKEccQm/IuN2fk9EZpyqn/jF7NS/CfisSdEHDpOBoEtCmDTMc7yVORw2UCtXbB6WAxZTie5PW9R8Mdfm9eALJzdjMe0W4TE/oSK/xb0R+gMiQlICB/gzlUt4DEd7O5b/PNNw+uWTTBNDaK5jXXbkZ9Y7AItiWCiFzKxoQl1SkHWTs9puX9C6015Gs07WZCZ84ynWQ1j2V/bXZjZT/VGV3vXREqHsUxWpwEuaJk8VDOwn2O6+qUjzYvCqbIlRbW9i7S2B7vSj9VpwzhtqDBU7x6HL9oRY8su9iHOGU/m/TZXQhufxk3U9uBEIgRAZVB99jJyFuqThLApbZIyWu8nfNXh2z8hQXwe0akOXKU6Oc4IulBIqi3AYb/27qhw9ZpnyAHhj+a7GBbzFLsAVTuC8RGk8aVAn3L5a0o0OWH6V0SvRk1PkFrMTJCdl7w/U1Qjq3jL4M17Zgr6Y94gh4xqZTdaoC983GkPfM811tbAUNUc7kKIeIyMHzZOR0v8dEX9P/dD 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)(376014)(1800799024)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AGHpvSwsBn20BERcghLsY/9mt3Kqc9mST4PmYU28St7rqzgjn79qSZaOZNQ9HbiRpe7Qp3embFgsANj6R3sZA7jcQPTlhh0J3LVppsC9oluyhERrxiC7Def7f75kMFVEWHA7JAateP3zxdZs951fVwAJ0r7oB0Tbr7V0DMn50C7+Z7OLik3evuhce/3xl97hQ8o/UTzsXlLuYxPKrZu0DUWCTYizgMdK0sM8L9JtPwco2usGE3c/CAEKtzEMGsZyDKaHWl9tXsFJGiVkBOFN+5YaWfYHTAmo3sJQOp0QBX1kemqlN8pEyr2UTN6/PgbA8+USZ/n7mbGIyLagfM5DHfoY/Rt6aFRHAu2zNAlZmNpW1MGTMRdDVEcUK8mNrZjFzMhgCvmCPvpyYblybxDDPt/yk4e0XD6iefJp6UTVSS3QEKczWSa1EvaPu8kKwOCmb2Xe9vvddTUpRxasljxYz6h+uUiKkQViW852B8n9GXFYtcM83pYK1V9eSMnt3D4iARI1LVpL9zjJRDDqdnb4d2mh3+EDM0SFLGJAa2Kxx8auQKN+D4fUyNj+2KyDBeMEorPCMLchWn1B05hXUZgLgwhDfrEYmwE5vG2GumFF6V4vuo+4NrwrdPqxZ9xWKp6pTUCIkK/2R7uUbP1SEw/mOcknOaIsnr2NGW0Q/jrEGCdkiWNDDD5s9qZI0AhgPf91FTGKRgju3L8DzPJAKC/jDuAA3DV1YN+E7jdn4ML4LJ3hQkzofnamoZb2E5BFGMA2Ab+zEP3KJDZOF/aYldPM0PfhUxbWo9+qw4vX1iDJixVkl5nhTPL5b3RxFpnCmvHBjzL8RrECd+Fdu0uaeQ5oOADCeucaaR9bLOseSbKwEkd64nLmB+OUPtM3ZwGEYE9HP/nSwAd5sbF8nXC2R1QM59k7/dgKAygGte3fTj00/yWsNOWM5MkNyS8z+dGpKHwxcvd/rOvpWlWZuJO9k6JkCZbrBqXNh2SvC3eeweSkHJ8EisK8Kp1JGoK2W0gsPbgGb9XMjI5IlaTVXNfLen5bE/ja3AlZPlnoSFht4mNPbYAZN7Do7ja2lsXz9VgN+vSHL26gUMhv0YOVNkbPG8c2oh3hppEYP3l6ka6U2qQToqYnFzYQrk1G2Z/Hzl5UvFsKfvw32eaYrc8Z99bNwDWQHptPwJQxyHqzbitcL18kdM3VxX88uZ/TmBtYIEBNk348lzXfeZoO09KVoWwp+OSyH7xJyx/wxnOpVOO4XYQ3tHiVP9OxGZBp679ne9jKdVKisEWW3Jj19hQztRr8zM1TPamT88ZRO3+TAgIymcwv5KHj1DXi6Bv2FGBX7I2tRKa0176Na5lbxTKZ2A+F+WH2kHVbAcMNB7fPUnkQyDzuOEgbVfbE9dGyMJ3zNAETEPe0PLhWVF2ERHIEMV1TL58ZywfslVGsweCsvot3KNmOgagTTT3Qvh320/4F3dZ42yNp51AraXq6+CjADOksPx2Vui6W+ySOzcIhuo/URm0sJkzssuLu7MdPY3fBb3lJB4fWySXAY9ajU+xJTD7XG5gzxoYMFG3lQUEav79hhuxlBo1OtojpLd+hLDM2UVTZpI/G X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1609b788-e811-48b8-d423-08dd1e599990 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 05:13:53.6819 (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: JU0QvJClRJgWGDY/N1ErJEU7VXQWpqrtattWz3zgC3vSAz8Y0o5KM35dV/f+3zRH6MRdypKWGGarZvUH9dwvYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8936 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241216_211359_209933_F85EF810 X-CRM114-Status: GOOD ( 19.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prior to freeing a block file systems supporting FS DAX must check that the associated pages are both unmapped from user-space and not undergoing DMA or other access from eg. get_user_pages(). This is achieved by unmapping the file range and scanning the FS DAX page-cache to see if any pages within the mapping have an elevated refcount. This is done using two functions - dax_layout_busy_page_range() which returns a page to wait for the refcount to become idle on. Rather than open-code this introduce a common implementation to both unmap and wait for the page to become idle. Signed-off-by: Alistair Popple --- Changes for v4: - Fixed some build breakage due to missing symbol exports reported by John Hubbard (thanks!). --- fs/dax.c | 30 ++++++++++++++++++++++++++++++ fs/ext4/inode.c | 10 +--------- fs/fuse/dax.c | 29 +++++------------------------ fs/xfs/xfs_inode.c | 23 +++++------------------ fs/xfs/xfs_inode.h | 2 +- include/linux/dax.h | 21 +++++++++++++++++++++ mm/madvise.c | 8 ++++---- 7 files changed, 67 insertions(+), 56 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index d010c10..5462d9d 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -845,6 +845,36 @@ int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index) return ret; } +static int wait_page_idle(struct page *page, + void (cb)(struct inode *), + struct inode *inode) +{ + return ___wait_var_event(page, page_ref_count(page) == 1, + TASK_INTERRUPTIBLE, 0, 0, cb(inode)); +} + +/* + * Unmaps the inode and waits for any DMA to complete prior to deleting the + * DAX mapping entries for the range. + */ +int dax_break_mapping(struct inode *inode, loff_t start, loff_t end, + void (cb)(struct inode *)) +{ + struct page *page; + int error; + + do { + page = dax_layout_busy_page_range(inode->i_mapping, start, end); + if (!page) + break; + + error = wait_page_idle(page, cb, inode); + } while (error == 0); + + return error; +} +EXPORT_SYMBOL_GPL(dax_break_mapping); + /* * Invalidate DAX entry if it is clean. */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index cc1acb1..ee8e83f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3917,15 +3917,7 @@ int ext4_break_layouts(struct inode *inode) if (WARN_ON_ONCE(!rwsem_is_locked(&inode->i_mapping->invalidate_lock))) return -EINVAL; - do { - page = dax_layout_busy_page(inode->i_mapping); - if (!page) - return 0; - - error = dax_wait_page_idle(page, ext4_wait_dax_page, inode); - } while (error == 0); - - return error; + return dax_break_mapping_inode(inode, ext4_wait_dax_page); } /* diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index d156c55..48d0652 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -665,38 +665,19 @@ static void fuse_wait_dax_page(struct inode *inode) filemap_invalidate_lock(inode->i_mapping); } -/* Should be called with mapping->invalidate_lock held exclusively */ -static int __fuse_dax_break_layouts(struct inode *inode, bool *retry, - loff_t start, loff_t end) -{ - struct page *page; - - page = dax_layout_busy_page_range(inode->i_mapping, start, end); - if (!page) - return 0; - - *retry = true; - return dax_wait_page_idle(page, fuse_wait_dax_page, inode); -} - -/* dmap_end == 0 leads to unmapping of whole file */ +/* Should be called with mapping->invalidate_lock held exclusively. + * dmap_end == 0 leads to unmapping of whole file. + */ int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end) { - bool retry; - int ret; - - do { - retry = false; - ret = __fuse_dax_break_layouts(inode, &retry, dmap_start, - dmap_end); - } while (ret == 0 && retry); if (!dmap_end) { dmap_start = 0; dmap_end = LLONG_MAX; } - return ret; + return dax_break_mapping(inode, dmap_start, dmap_end, + fuse_wait_dax_page); } ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 42ea203..295730a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2715,21 +2715,17 @@ xfs_mmaplock_two_inodes_and_break_dax_layout( struct xfs_inode *ip2) { int error; - bool retry; struct page *page; if (ip1->i_ino > ip2->i_ino) swap(ip1, ip2); again: - retry = false; /* Lock the first inode */ xfs_ilock(ip1, XFS_MMAPLOCK_EXCL); - error = xfs_break_dax_layouts(VFS_I(ip1), &retry); - if (error || retry) { + error = xfs_break_dax_layouts(VFS_I(ip1)); + if (error) { xfs_iunlock(ip1, XFS_MMAPLOCK_EXCL); - if (error == 0 && retry) - goto again; return error; } @@ -2988,19 +2984,11 @@ xfs_wait_dax_page( int xfs_break_dax_layouts( - struct inode *inode, - bool *retry) + struct inode *inode) { - struct page *page; - xfs_assert_ilocked(XFS_I(inode), XFS_MMAPLOCK_EXCL); - page = dax_layout_busy_page(inode->i_mapping); - if (!page) - return 0; - - *retry = true; - return dax_wait_page_idle(page, xfs_wait_dax_page, inode); + return dax_break_mapping_inode(inode, xfs_wait_dax_page); } int @@ -3018,8 +3006,7 @@ xfs_break_layouts( retry = false; switch (reason) { case BREAK_UNMAP: - error = xfs_break_dax_layouts(inode, &retry); - if (error || retry) + if (xfs_break_dax_layouts(inode)) break; fallthrough; case BREAK_WRITE: diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1648dc5..c4f03f6 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -593,7 +593,7 @@ xfs_itruncate_extents( return xfs_itruncate_extents_flags(tpp, ip, whichfork, new_size, 0); } -int xfs_break_dax_layouts(struct inode *inode, bool *retry); +int xfs_break_dax_layouts(struct inode *inode); int xfs_break_layouts(struct inode *inode, uint *iolock, enum layout_break_reason reason); diff --git a/include/linux/dax.h b/include/linux/dax.h index 9b1ce98..f6583d3 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -228,6 +228,20 @@ static inline void dax_read_unlock(int id) { } #endif /* CONFIG_DAX */ + +#if !IS_ENABLED(CONFIG_FS_DAX) +static inline int __must_check dax_break_mapping(struct inode *inode, + loff_t start, loff_t end, void (cb)(struct inode *)) +{ + return 0; +} + +static inline void dax_break_mapping_uninterruptible(struct inode *inode, + void (cb)(struct inode *)) +{ +} +#endif + bool dax_alive(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, @@ -251,6 +265,13 @@ vm_fault_t dax_finish_sync_fault(struct vm_fault *vmf, int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index); int dax_invalidate_mapping_entry_sync(struct address_space *mapping, pgoff_t index); +int __must_check dax_break_mapping(struct inode *inode, loff_t start, + loff_t end, void (cb)(struct inode *)); +static inline int __must_check dax_break_mapping_inode(struct inode *inode, + void (cb)(struct inode *)) +{ + return dax_break_mapping(inode, 0, LLONG_MAX, cb); +} int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same, diff --git a/mm/madvise.c b/mm/madvise.c index 49f3a75..1f4c99e 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1063,7 +1063,7 @@ static int guard_install_pud_entry(pud_t *pud, unsigned long addr, pud_t pudval = pudp_get(pud); /* If huge return >0 so we abort the operation + zap. */ - return pud_trans_huge(pudval) || pud_devmap(pudval); + return pud_trans_huge(pudval); } static int guard_install_pmd_entry(pmd_t *pmd, unsigned long addr, @@ -1072,7 +1072,7 @@ static int guard_install_pmd_entry(pmd_t *pmd, unsigned long addr, pmd_t pmdval = pmdp_get(pmd); /* If huge return >0 so we abort the operation + zap. */ - return pmd_trans_huge(pmdval) || pmd_devmap(pmdval); + return pmd_trans_huge(pmdval); } static int guard_install_pte_entry(pte_t *pte, unsigned long addr, @@ -1183,7 +1183,7 @@ static int guard_remove_pud_entry(pud_t *pud, unsigned long addr, pud_t pudval = pudp_get(pud); /* If huge, cannot have guard pages present, so no-op - skip. */ - if (pud_trans_huge(pudval) || pud_devmap(pudval)) + if (pud_trans_huge(pudval)) walk->action = ACTION_CONTINUE; return 0; @@ -1195,7 +1195,7 @@ static int guard_remove_pmd_entry(pmd_t *pmd, unsigned long addr, pmd_t pmdval = pmdp_get(pmd); /* If huge, cannot have guard pages present, so no-op - skip. */ - if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) + if (pmd_trans_huge(pmdval)) walk->action = ACTION_CONTINUE; return 0;