From patchwork Tue Dec 17 05:12:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13910987 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2041.outbound.protection.outlook.com [40.107.220.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F69145A09 for ; Tue, 17 Dec 2024 05:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734412413; cv=fail; b=gG1aPWB/TloM6hjWQTmfOz1gvUI2xb7dMS7O7MlVLt2m/va7udodHCTmjEYChfrcnio6F9sVcWaOTos7Lh2j8rbfKjQsylRWtXPnewl4VqL59WltplROgpQLYpKRVjqZA3g5ig0qZaakchJwseVqSTZ1Rbe5paMyN/TKlcVg9YU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734412413; c=relaxed/simple; bh=RCD8Ee77RTWPZ32uiu8qRsmltvIkR4jhZjhzmdQfZIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=h0K3nBmplXOtT5ZxHcdEHtU5iop7+7hkrurQswnvMWBJqcgQIv4WxgVubaIhJyQ/vPltxF6O7wAWOKrmeXYyh1v90Esle7sqDPkfgh8zMqfu+N4EBBI4J+cjjSIQWw5FZKmILU+8L2qC/08w/GXnnGz52ue3R55z3uOVAkeKa+Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YXGFkIJE; arc=fail smtp.client-ip=40.107.220.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YXGFkIJE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SYZqns5NcLI6aid/1gPIi1xHgBQrCx43yJxfgAsi2MtVzA5+uwjQ5xRtgtiRZCSO8ZopzY4hSQH1nxoQ07l//zV+Zt+hiaKjnuDrvPmeV9obrT3YNHussUbowxAtC9K4nzmZB//01OEj2GZfkXJdMbMWpHHSs5ypP5LSlHoNxyOYkSVImMoi9l/LWG1ssPoGw1ms3SFbUVtrmLb1/tt/53Qtz7mhB+HCSLldFgBZGGwk1Oox8iMxmNGVkfu27snFT4nmTN4SFES65tj7M0XQmp2L2yE0Njlk2C1NZVN78vvUfdgiG7SWP1gvRdd2i9AHVW8szJ1yAUzUwQusAeb+uw== 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=oPuDXC5YQtWSoYXGVf7XL4nw5iM/h23dC62Mmqkkwdo=; b=DxT5rXIg5o6M8lMfgpyneUdD4UBzx5SB8UOs7UtrL6fcfq7qCDSejq5P1mPIaSTEe/Qp+4w+Y8c8uPUGTNltHxgqsZdn5DAjB0HbVAJUndm4S/ULjiwzEzwZhhdCYsUiLa6Iy/uzRZUsECcx7eJI3cG6gNDeTKsjRBQ5DkztwzP9WZ3hguJzDUY0ozGZ7Bt3QYxHc07RYt2FRMFmdcOsVy06y/IlujOForD5vsyTUZlalClxZ5ICEyy+ZnX1CuThu9+cOPaQktcvs0JXd2wBAEhYsouixAXxg6hYOPmoCniQFaM3kizPJA6/cLzB2OLS+7VM1kqekm/gp4yuZFoNbw== 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=oPuDXC5YQtWSoYXGVf7XL4nw5iM/h23dC62Mmqkkwdo=; b=YXGFkIJESXxZwN+1AyoIhsVGZiRsJNE199S410Fgp0qXQ1v8xgXkV3VTtJTNE9fdAbglkO5HDULovWVAGuX5sSLkOKDZ7p5xA9nm7AQoVNPW3Fi8CF0X9qGp4slWyysXxoJsz7W5ER0OHk7E+ipaTT6vGtxO1rFvPLrazrexNpyLUhFxEDhay0Hs9zJHM+0oWXjR640XjdRaNhd3xbYp+yxR9GgiRuR7yj8rDYjlv/4OrtCByZCpd59LUnq8FVxc8KQ0sb92Gw2qz3Kjyn7CIteK56wwTLv7PsdWxr4NlDWjbClRp8V0Uo4/GRzBFou7utlA6c6Azq0391sCuD+Iww== 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: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%4]) with mapi id 15.20.8251.015; Tue, 17 Dec 2024 05:13: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, Vivek Goyal Subject: [PATCH v4 01/25] fuse: Fix dax truncate/punch_hole fault path Date: Tue, 17 Dec 2024 16:12:44 +1100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: X-ClientProxiedBy: SY5P300CA0057.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:1fe::7) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH3PR12MB8936:EE_ X-MS-Office365-Filtering-Correlation-Id: 92efd73d-9cd5-4aa4-7343-08dd1e598bd0 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: vGTit7PiNrb0Kc02yU2MWw4C3jILeoV+mXw2ry3NVJuk/BbjuXvFIuBsMC4Yub4reJ729kU/54YZ+XowR2tHnxZ48P/WotD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ZCdo0CQJderzPDwUoYpOVpusJ5YXDKq1PA3S5W1Aho5ZY6ytn5ygVE2uyAKkKTyvA03UE2msXai5KkAiV6Bac24JkaTpZK9q86tRRR+Bm1SRQFqMdKGERlnoqcQvvMd72MlQr3BHcfbIi7HCIIfFIWgTGVF2INMnRH6hMwYYUt4ioMosm36Hb3zrEEN5g6x56ItrUyKylpWkm92 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: PndvQFX0pYbvOfGKuy6VeEyX9wLw9Kjk7HmcCj6GNBkTSlRXN8Ny3oZ6D+kKuvPKFVjUaIa12QUgNPo+YClJMMSzBCCsy3Sg67hJVQ5bX9Y0VN9ov24/EK+IUebXSlAeLSUJGXgCB0g04yy/1naFvjd38jJ8vjkGM+JFXTQWR3WW92ys+qVITkgE6LBkAZtDrCYrD5G/TBMEj1gbbgbZduHoEfQ0YLGbYCIH1x6t7DSJpQplpgTZWbIG4XUZgCs35hz/aZ1UNZ6lrncPx/wV7jFB4Xt7TRiFSTj6LOiof4iPZYaxPDfL/SEek/BEPPVd6CL6ExSNI0MgZSOvvW7INdI8wLcu0CcBQbczSS9Dcs+z5nlozJFo464PcYXgIOQxIxFRq8y8n8Oa3J9WRCjyzZ/ZWmS1QoY0nZlik2DS+TL9JCPL5Z8bUtl5dwCVGJQM0C23fZ1vp7We8oMVkzHIBru4C8Uq5m2KjOr84NVOFNs/1WUlvEuOWrAGgJ4UoN/XHfijEeLtl9/roIi8ziJKjKu7WQPRD7l5hYpCqi6op0ha0ddc56QgDLgLkX916btMRUjsJwyIiS9ybiR3Q7ijI1Q7jz9GRLh0P2fY126d7ygTx8+e26+TemEZ4XBUV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MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 05:13:30.4259 (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: gfxgxB4Owg7WFQjB2fzDNZFbOOy7Uwopd4MAYD06xcMVeiDrQGLE1QWVP/rvXLezZhGjJhjr8qn3Zk3KBCQmSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8936 FS DAX requires file systems to call into the DAX layout prior to unlinking inodes to ensure there is no ongoing DMA or other remote access to the direct mapped page. The fuse file system implements fuse_dax_break_layouts() to do this which includes a comment indicating that passing dmap_end == 0 leads to unmapping of the whole file. However this is not true - passing dmap_end == 0 will not unmap anything before dmap_start, and further more dax_layout_busy_page_range() will not scan any of the range to see if there maybe ongoing DMA access to the range. Fix this by checking for dmap_end == 0 in fuse_dax_break_layouts() and pass the entire file range to dax_layout_busy_page_range(). Signed-off-by: Alistair Popple Fixes: 6ae330cad6ef ("virtiofs: serialize truncate/punch_hole and dax fault path") Cc: Vivek Goyal --- I am not at all familiar with the fuse file system driver so I have no idea if the comment is relevant or not and whether the documented behaviour for dmap_end == 0 is ever relied upon. However this seemed like the safest fix unless someone more familiar with fuse can confirm that dmap_end == 0 is never used. --- fs/fuse/dax.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 9abbc2f..c5d1fea 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -693,6 +693,10 @@ int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, 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; }