From patchwork Fri Jan 24 16:46:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13949731 Received: from outbound-ip191a.ess.barracuda.com (outbound-ip191a.ess.barracuda.com [209.222.82.58]) (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 CEAC11459E0 for ; Fri, 24 Jan 2025 16:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737257; cv=fail; b=spyYZ0nY3T5Sov6DjA21KsgvDFiLDeyuuzt1doK5fZjVVMUwiI4+9wmxUOv/4HVL/R4sU0uJTr2xhNd0dVB1ArVJVCAyqWyMTVwdE9KdNgbfhZTmNGewnwPdKI7UqRRHvppkmmlGTR09e3fLhUwFp8J0r8YhIslFoZK17V7L76c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737257; c=relaxed/simple; bh=TXMZt2stBIZhV5QMsvTgD1jJCgtZKXxeYmcD90vE+uw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lFDlksvCJ3hKkhPYnMgFihUhoSc1ckRRIzBfMOeVJQ6o66g53tSECZGkWKF9yVmnjR31ik4LIy98XlqqgunemlQlyT0UZpJ71gM56ThT26xfk5yHe/YENvYwqI3avcS+3AZQ7yxk/PMnIZsV3a9NCNY4hwiIkTNqOcUL3X12SxA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=hjHeKkzZ; arc=fail smtp.client-ip=209.222.82.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="hjHeKkzZ" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by mx-outbound12-186.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Jan 2025 16:47:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oSIR5GNKBeM64spCTwp4MpY0sH5+loDJN+U5qfxCSzVyycuNgN1JjYDzFxQxHjDKIR3HqcLW8USwvei2XPs8oJ50PhtauaoHDEbegI75Yz+iN8mjBNlfECCF0E2F4aOPv943JJLYmvRfe3Ajakn4dWPKakm5QD8HzW/1brkLkaxcPywiGMArdopfr1GaKDHL6McUbVuECnTJEMg85eHvlOBY2ilOWkDgxs429KKPshWlv6RcbZ6aMxkSVYCYK2MiFCbogQxWV1SxXoTfoOxHnABtfdCNeEZ7y/jPZ1coRgjrNTDOrRCWIAmfH36Mpck4DVaP7hplacebFoDiYQfi8w== 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=4uoQ9ZZI7NMtPOY5SExtUUjVHiMg9a4I2CRP7tHtJv4=; b=LpvMeAGwCS0/2HOwcXUbRsFcs8xRmAJW3fztdhR9t0DUOmtB26E8NwjIwrl0Pw1lwBfb1vZIFptDXJam5gEed7eZWnTN/18kQBhjliPKTtsswZm4sEyE6CL1aBUz87BwVTtCCIwmbzdgqCyPh7hmdREGwFLrHE7lxjNoWtynldq7JXqsDrHUZ1IvG2aefBcNB2YyY7ubuhDJxx0fOru9PGxD2oY47KI6HWHEbJLUEBPiC9yinhw+zJ8cUvCPVmob/KUVaMf18u5+Cn6lm4tnhdpAbx0S0GK2laLk6ZHtpzv416vv0mODDPr2ezJOyMUSzK7WWCfpkpGt4MKcSqWxgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4uoQ9ZZI7NMtPOY5SExtUUjVHiMg9a4I2CRP7tHtJv4=; b=hjHeKkzZ7Hb6wjMX7ppmd2zUbAD7BrzaHnlbZkG/h9T2iFc1B/wgsJys6iPhdqV6MuHaHDSvBsLAJ4eStwT2bWHLkZaTCuLr2MU6zdNqIm1aDRTh6abqb+9lTQVODfzNL9OE/exGBqZTdNcn0l2ipzUtZ/xcMmjIq/zuiJZB52A= Received: from DM6PR06CA0041.namprd06.prod.outlook.com (2603:10b6:5:54::18) by DS0PR19MB7960.namprd19.prod.outlook.com (2603:10b6:8:165::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.16; Fri, 24 Jan 2025 16:47:15 +0000 Received: from CY4PEPF0000E9CE.namprd03.prod.outlook.com (2603:10b6:5:54:cafe::7b) by DM6PR06CA0041.outlook.office365.com (2603:10b6:5:54::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.18 via Frontend Transport; Fri, 24 Jan 2025 16:47:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by CY4PEPF0000E9CE.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.8 via Frontend Transport; Fri, 24 Jan 2025 16:47:13 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 0467E80; Fri, 24 Jan 2025 16:47:12 +0000 (UTC) From: Bernd Schubert Date: Fri, 24 Jan 2025 17:46:51 +0100 Subject: [PATCH 1/4] fuse: {io-uring} Use READ_ONCE in fuse_uring_send_in_task Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-optimize-fuse-uring-req-timeouts-v1-1-b834b5f32e85@ddn.com> References: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> In-Reply-To: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> To: Miklos Szeredi , Pavel Begunkov , Luis Henriques Cc: linux-fsdevel@vger.kernel.org, Joanne Koong , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737737231; l=1108; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=TXMZt2stBIZhV5QMsvTgD1jJCgtZKXxeYmcD90vE+uw=; b=otFRD663HbwZK63yBHHiojxYXL4rCAKf2MBbT5OWuCas6uQEW8IOpqgRNeL6fYmT22mxHoalH VRqXZv2Y8ubD392HwuTy0H3sttoJMeM04+5ikoeXX8nLCMXgi2xj36f X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CE:EE_|DS0PR19MB7960:EE_ X-MS-Office365-Filtering-Correlation-Id: 724bcd9e-c7d2-4b0c-ec59-08dd3c96c105 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?d7YAH0E7o6OE9yZNDhXFnmCw2l6sZsJ?= =?utf-8?q?FYjxQ9jaOp+wJ57Gcnh+GISd80jfCOSOBeWuM/1XkGfDiwY/ZnRDJCj0V+CQtaF/a?= =?utf-8?q?WJc9B7Q2WU0nIzkcTdNdoq0dxFvkTDTz7YQMuTyW7gIGzHEWZDkcWIZ+sCdoI8pSK?= =?utf-8?q?QG/6jb33WIXz/tcWFPxDwTNIMEyUH4qlo9UH+lCU7BhRc/aAkiFSpnRq9XIYA7E5u?= =?utf-8?q?WHIoDi8MXxcP4ZqqGtD5shkaMUT1BsnvHjlJePcILuGGM4hOTSCtb9o8InraPjKww?= =?utf-8?q?/wThMCT1jDuPQ1JI2mA7rD6TgYESf1Hhp02x1CprbtXDAOD5EECGXhBxVbUbAFZkl?= =?utf-8?q?DjS1dp7WWs2rhWD+eeRLbjn76x3Ej5f/zbNVZleczMjrVP6DZroqSjWqXQncRPMRa?= =?utf-8?q?vURveXoPpfBagB+dLfdytJewExWfa3ggYTl94KCINap772IbqwLy4m/gp+swzkJ4e?= =?utf-8?q?ZXNYbXl40+U5hQSLkpeYImM3K9BpiI0ws5xexsrUf40VBnWun+6mcNR5Us0e1BiIi?= =?utf-8?q?3lcGntxclKJxEMOr4rpi6CN6Ud6ELinEZFDMILvaVkydBU8SSwVeWxp22gZ65/JdR?= =?utf-8?q?bsqdc5H9Z8sywRykwCO6D51Q4nXQThFlkkGc9aKduwDbEWV7qVf6l1pQyFGp3ezXm?= =?utf-8?q?3Uf0une3gm6gaQbGeLVaY/hlbeOebyetDyoQQcVA7WpESh1ZJ2bKfo3brX1xUuI8N?= =?utf-8?q?UvhFCr6WxC/G4jWHY1QRx1MQHiKx4CHI+ZO7wBholPm/4zSbVk9uqOjsTlQ1Z3k1q?= =?utf-8?q?3poY+h4Fsvc9WCfxKue393RDPptR/zAwYUUpC76r4bOAMRYzVxvskurOpW1YOeGj/?= =?utf-8?q?UwrXVWpldVkEC5Vd1GQU9kGGI2axYjT68wtXInLKIs3jW3YRAXtA4AbzjNcne6jrw?= =?utf-8?q?2snQ2FUXNDM/C27LSGaUwRf1N2M2sGz1uSvN/jWF4Iij7lxQ+zKnmRxI40n9koTn/?= =?utf-8?q?hV5jKkU1XfczmsnjcI00PbCeUts8o3gIa2YhD/75KUrreFyhv+aU18KxiMDzXIFMr?= =?utf-8?q?B3+w/rfa7CYZO+zOL+FoRVPlllsDDTdzWLMQwGaOPknmSV31mE9Y/K4HHZ/VeFckk?= =?utf-8?q?aX8/9KbypMJamCfXHMTwqIt3TXLnRHktFdWcWSXyOwsvoEjp0JvaMdeNbxaxeR3Rc?= =?utf-8?q?4BFDnayMEaGHv4WFigNf8YQKPotKEEt+SJR6hJKG1EMms3udyi8YKjOg4dq2pv3a9?= =?utf-8?q?gdX3gVJ8AvxY9pRJb3NMu0oTnXY60/B6SmeFriQ3xpMY4YOIOnHb0UDEsBaysJ2sr?= =?utf-8?q?csrUj9NNVETgpWsCmjtk9sK3Ah+93fHNBdjl1QEYFqwWusKoCRRSBmgzCUJLd6iOZ?= =?utf-8?q?SrBT3S9v0b7EcExEjLdT/GVTT3mmqWRXd6uCi1YRXMrMAW6cJrEupv+scbna1T2Ux?= =?utf-8?q?9IzGekxCbHJtyu0fE4iw2+dxPzShDWbPPY7vmFkVyOlL5rzui4WxVs=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Aa4Knfn0AS1ERhgS38w/rgC47L4tVTBsmUcB6iKbZsDtoalWZhQW91DrygM7/zmK7wv8ZuYNS8eUai4kSrUdtSMMCuQETWv0q8MwLacP4bZRCNEutT9/ETlVoPoEl7/vBoQxe0/G+mVaeWXNNHiokRR9l90adE4ApfIMIwmIvFvIEerE9i4NdjK4EHWZiNrySWh6SeqdvQPY1eEMJpNR7jEtJ9ujcNqxhtUXbwUSugHzRHNj01glf5+9QZNY050DTnvp2vM8E2cX3PYBTvKBa01KEJhiDWBY8hJuM0DM2UETDh/6peB158JjPOPwfJg1CAoat2eZDOLINq7OYqP5A9KFwAs23LXDH0/ZP6vEQr5wDrGN7LMeKOQDci7bo0NJffWTmGchAvhEmm+kXw0ZwGRoCoPbQUfsvfytR/n267Vzro8W5Lvk0RyMZOzmYfgtjUZYBQoxmCtCQja1vYqV5L7O2WX94QhYXHhqZ+EvlP79qjs3L5ksTJ7sL4yYCXq9o5SXVJHMfxlS4Nd5AiN9SltbQk3hjZWFr+cw0ghKEs38JSpShbEP+P1yaumPln4Z98whl+c13XkEKJgJ68fPNDSZs7p/jBQcAt6L3/HaRwRj9BJ5ny6yFQbThqHQ+zxDbOyTUM2sZxOrtMT3Mqsi+Q== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 16:47:13.7005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 724bcd9e-c7d2-4b0c-ec59-08dd3c96c105 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR19MB7960 X-BESS-ID: 1737737236-103258-13472-20903-1 X-BESS-VER: 2019.1_20250123.1616 X-BESS-Apparent-Source-IP: 104.47.58.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYG5hZAVgZQ0CQ5zdjEODUlxc LQPNXMONXA1MggCShoapGcaGxkZKJUGwsA9guvE0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.262028 [from cloudscan19-21.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 The value is read from another task without, while the task that had set the value was holding queue->lock. Better use READ_ONCE to ensure the compiler cannot optimize the read. Fixes: 284985711dc5 ("fuse: Allow to queue fg requests through io-uring") Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 5c9b5a5fb7f7539149840378e224eb640cf8ef08..1834c1933d2bbab0342257fde4b030f06506c55d 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -1202,10 +1202,12 @@ static void fuse_uring_send_in_task(struct io_uring_cmd *cmd, { struct fuse_ring_ent *ent = uring_cmd_to_ring_ent(cmd); struct fuse_ring_queue *queue = ent->queue; + struct fuse_req *req; int err; if (!(issue_flags & IO_URING_F_TASK_DEAD)) { - err = fuse_uring_prepare_send(ent); + req = READ_ONCE(ent->fuse_req); + err = fuse_uring_prepare_send(ent, req); if (err) { fuse_uring_next_fuse_req(ent, queue, issue_flags); return; From patchwork Fri Jan 24 16:46:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13949735 Received: from outbound-ip168b.ess.barracuda.com (outbound-ip168b.ess.barracuda.com [209.222.82.102]) (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 2C134194A64 for ; Fri, 24 Jan 2025 16:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.102 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737272; cv=fail; b=E1TedRJ6KSL7PDzcqNEOqMS1pdbUAI7GxC4Heyfr2m0iRMIUkWjxrVqG1ZODcgSNHwaHh/URBvMfOSCeeSMirjCO5D1DLQqZEd/FGFp23k+nCYZ0GdylPLo/BbcMprKQjhUlx/6Xt4jg6vJlrz9WK/IraAqQv2tZGs7L1z9+GGY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737272; c=relaxed/simple; bh=A4PFhntJG8uOQDXbGbGG2z6CiMSrQ04K3JN7lMyteYI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pzz6EWSSGU7waL0OMD/d0/U2VA+ps+uRqUhwkRz7C1zDUpWV8OB3iwf7VWcuBk6csWknahB+ESJmiz70IhPwG66U3uRKaZNtB0+z6g0qBJyk2I+bMrpPP7S8KdZATqQ3AoZBTi582sZXgpFqhqxL5n5/4UyquHchZaa+aNoIQY4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=MAMBMTU1; arc=fail smtp.client-ip=209.222.82.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="MAMBMTU1" Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2047.outbound.protection.outlook.com [104.47.73.47]) by mx-outbound41-29.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Jan 2025 16:47:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UcHJSFEid+6v3OoZsgLHu13Uo1+L9TuK8C+VmG13sx55rhe5nz6Y85W2txtK83DYmQVPFYs1vdHPgapzMBy2xwFqxs+ChiXWGcuwuAW7Y9YHP95707FY9939RmiTbR2Z7IotWVOdBBX6BXSxHyIwifwZCfMruedq8w/sR/uSbxlBwICaA1++gLhcjWegyq7Pz/11D1VGSCrNM4hOHvqg3S/R+pcwm23nohpVlgRpEo3oYLWhgNrWtHTFtQGNCi9lgERoUmWmW+Gnf/4jf4kssaV8ve7JWPPBKzY3sjTt/jodwU8lHOFfC9EoEItRfzLbuYj/qFh3dSA6OfEf7Udorg== 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=K774j8oyKpgyBrhTSxUGdweMSUZ7fRhDIIYcc+L8rzc=; b=srExYae2vJCcnwy7g59bZ/vQ10rmwihTSC8i42lcw4iqSQ48p0I8P2xX5k/1CETWSYbXU22uaryS92NXkCJT8rKgBbkNjS3MffY0vDj9HTOJ4Dso1TGeHAe7O0G4cJu4rgPJpGWb4vQEUi4taCgGmPZjer/y+eWa77JNgb4JHJlWuMYJIMUXFQb4RyUNan6stYrOM404aS5KMJ5JJtngXgzbT6WcsXTeeXXM41yqCBcsDUbKhw3kUjEAgP6VP2zIE1gF9xbIUtj8zEH09Z53l1IVBxkhhlruf7BMjdfUG5+S+wrzN7fcxtQdG2sOUBwqEoWGK3dCqVpFVcovT5qk9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K774j8oyKpgyBrhTSxUGdweMSUZ7fRhDIIYcc+L8rzc=; b=MAMBMTU1U09fIPqJuGGrdhZXoJUNWnJZK5S4jc7jt6gYtqDutsSRPupn+7x3fIqokbw7SJejeMnTclUVkr5GrdvPoeDMeT2LTxPzgDHn9ZTeAu0AbDRNx2WagVFYMRBcJWkifKAZpJ7UJQR9YhXOr/LA+UBQvDEjPUjRTDcSlPg= Received: from BN0PR04CA0090.namprd04.prod.outlook.com (2603:10b6:408:ea::35) by SA1PR19MB8072.namprd19.prod.outlook.com (2603:10b6:806:38c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.18; Fri, 24 Jan 2025 16:47:15 +0000 Received: from BL02EPF0001A0FC.namprd03.prod.outlook.com (2603:10b6:408:ea:cafe::8) by BN0PR04CA0090.outlook.office365.com (2603:10b6:408:ea::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.20 via Frontend Transport; Fri, 24 Jan 2025 16:47:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by BL02EPF0001A0FC.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.8 via Frontend Transport; Fri, 24 Jan 2025 16:47:15 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 016F4E1; Fri, 24 Jan 2025 16:47:13 +0000 (UTC) From: Bernd Schubert Date: Fri, 24 Jan 2025 17:46:52 +0100 Subject: [PATCH 2/4] fuse: {io-uring} Access entries with queue lock in fuse_uring_entry_teardown Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-optimize-fuse-uring-req-timeouts-v1-2-b834b5f32e85@ddn.com> References: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> In-Reply-To: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> To: Miklos Szeredi , Pavel Begunkov , Luis Henriques Cc: linux-fsdevel@vger.kernel.org, Joanne Koong , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737737231; l=1883; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=A4PFhntJG8uOQDXbGbGG2z6CiMSrQ04K3JN7lMyteYI=; b=+uSHKtz9SKX/naCOJ6SuQwLwj5TNQ5GLMkfUSDl3FTClAS1hCFAoEji/IDe7z5QNSNdPdcIE0 XZCSWLeo52jA0BCRFnaRf/PsxBKEtHSUh9t9l34O1u9FUtCspIr3wUt X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FC:EE_|SA1PR19MB8072:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b1023ec-42cc-4b78-6b26-08dd3c96c1e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?dEihFd1OIvFsPnqJSJw/tM4wQNyr0TJ?= =?utf-8?q?A7H0SNWLrE7nyIAcGnKb2fmBKFtlQGuXzOLzPw7l/E55nWcgXJB1v0d8Pu4QM6Mjs?= =?utf-8?q?G/pRup20nmJ7s0Q1zgdrRDCrCckEYUMH7RjsWumCUC7v1OoKVNZwucvjrl8RUp4nh?= =?utf-8?q?ZcDerLVl/bYShYK85aT0hsmkzqghWWSgdwfUAt4T82zidHmmDj4dx8/2h069s8MKw?= =?utf-8?q?aq2kdf5NU+XmMi74JknWOPuyvGQxmYvix/cK0Xy3Wuf5EgY3/Bqbm1ZKUqzpHcJvt?= =?utf-8?q?O/Ffmpymt9ZPY+dvcL5njX5WGXEzHiaivKvp6i8Yo7u825f5bGvCXRHTSOy2NbOA+?= =?utf-8?q?lvB+j4CZhqcuGJ8Vi+p0vYjBNYhwYxFMRDyOP0naJ/QVCuGbVA1kCpPcBN2MK8QnW?= =?utf-8?q?4KMPqiyYeryImWwHn0e7G/QvV+WxC75eSNGsvWThOrUpY2bgA/ou63c3u1qfDMXyV?= =?utf-8?q?RqC4CPs9ihvx4/bvQ6fNIQL9cKigeyRhIhLsTYREBz5Xv2QBqnz4TybTPknTcWSTV?= =?utf-8?q?+e9Re+AGh2OHBNBvQcoYz/9bCkVazydm/mSLXY00tBvkpTIoj6y+jLpkdVE3sOBio?= =?utf-8?q?wvHb9M8RL6tEPjVcrgVm7Qmc3mplQTVH3+SozTmIWEBsqROoHaiuQy0e/jhMVNJVl?= =?utf-8?q?JAV9yoa3KKapI46gx9408wBrhsudzyY7rxvXBCmJaGw1/XhT/2p35xHksJ+UGP6Ni?= =?utf-8?q?SAWiDXNDWKIT9ndjPGIVrLyxzz+tPDoHPNQr3ISb9ADhdSJYaYAWDLXJgq1cb7j0C?= =?utf-8?q?NEpTvxCHyX2+dS5HSzhElSeVoV4non1o4BKP8blw/apJql34ryu7M2BezfZE/nN6J?= =?utf-8?q?QBkx2PY6WOgNy4VEQSsbD9t+gANlCuy6rU0LlgNtQORqEmw5obPySgidWlbAjUPN6?= =?utf-8?q?ZJPXKHYbIRlXlYBwnz9y+e/wRzT+f99TZb+q3bvbUdC+kdi6Sb4IUQRuSFVUiNaJa?= =?utf-8?q?G5le0SqCg7mfI322N4ehmaykyMdBOAnhQ4qrl3rJ1aBqX2p0PN+28SF0yCbWFEEBI?= =?utf-8?q?K+4An6kdS8Xi4kCJKI1nsqfZpD86LC8svhp5/D8lS1hwWzX6EPcckp7lbJi1F1EPC?= =?utf-8?q?KpWHVJf4o+Kprlpaf0W2nCqOXzlfRre4p6lwYWL4yGVC0u4igDVZ/pVrBrdZFZz/I?= =?utf-8?q?d+VcGilavKzHFX6w+duRpmA7yoBbKEhT7DlYqJGS1xO8erfzqzhEwNt/WMaDGaMkA?= =?utf-8?q?wtpV8nGwaMRR2l+1arJsi9PYCC5X/yeTly775IyjXLNQJAH3JFjecjs+pAGhK2v/g?= =?utf-8?q?UxbGo5R31GVfzzE4kBaZJvFX4W9YDbkLm8mteJ12eQQFB3A1HMD3G1+ax8xy0DAeT?= =?utf-8?q?JDQlc1Q0guu75u7QMr7OdXDSLL4gOgAKRnOAv82akbRisjrgCgSoRPA6YymvDajkm?= =?utf-8?q?ECOwE885+paDEkVicqpWCxSsk3AmRXkhUZEFTzKoTLl+XiHV2gMi9E=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: em0Dw2hPcnA8cC+iq7kIc7DHszhVBbmWE4lL6d+5zVdZJpWce8Qtl4CKmtkm6Q4NVHyZ0SgGhoWiWGJjCvtIKQhQFumkbYwiI4LAsd8D5bZ1t+N8Rfyr0yHTmWM8spe/1FPfh8reLYXxPRCXPmCenDpHGNC5eqGI4UoPbZ2J+JR90C30Eby2LFNq8Zpy9X1336S684nbGpwfa+jDjhR+wrksmxFTB7RvdvfAF0+bLmPx7xKJ/FosrB/VYoTig9CIHyC6f001j3u/QnUJe4M2XH5a1KhXIns7TzQJ6z/GjtXTqW86EAT+maRWQjGW8td7y89DB/WqPxRnIqo27yEuKF1C3E6H9xC69Lc2UggvKZknUh7XsRuCwN+C9Nla00pund2rRO7xONchAfHp/IHS6ruoS0ne6zzKP5sjGfJkQzh6E8Oh1XnuI6FZsIQbKooWB897oFvIMTfIX9tG/0Uc7mjdP7NPd8Ut3ttmXSCxn93fKyqIYx8AI5F6hJVC9DddwUHiIGOr8OA3UckuRhudKxzu82zS39Niq3tJKZsdq+goBb6YDHDQ5y9tNdNT9GeRFi1cHkLAqRObWOUwqs7+y+OHZNSSXiw03OGaU7yjY6RmkDbjcdbXJBjAH3fEOUdxWCv7/GNu1vObRMcnaMBIlQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 16:47:15.0674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b1023ec-42cc-4b78-6b26-08dd3c96c1e2 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR19MB8072 X-BESS-ID: 1737737238-110525-13388-117-1 X-BESS-VER: 2019.1_20250123.1616 X-BESS-Apparent-Source-IP: 104.47.73.47 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWRsZAVgZQ0DLR0jLZPNnCyC DRwszAJMnQ2DTFxDDVxNjAMjXN1CBRqTYWAENfEmxBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.262028 [from cloudscan20-157.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This ensures that ent->cmd and ent->fuse_req are accessed in fuse_uring_entry_teardown while holding the queue lock. Fixes: a4bdb3d786c0 ("fuse: enable fuse-over-io-uring") Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 1834c1933d2bbab0342257fde4b030f06506c55d..87bb89994c311f435c370f78984be060fcb8036f 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -315,14 +315,20 @@ static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) */ static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent) { - struct fuse_ring_queue *queue = ent->queue; - if (ent->cmd) { - io_uring_cmd_done(ent->cmd, -ENOTCONN, 0, IO_URING_F_UNLOCKED); - ent->cmd = NULL; - } + struct fuse_req *req; + struct io_uring_cmd *cmd; - if (ent->fuse_req) - fuse_uring_stop_fuse_req_end(ent); + struct fuse_ring_queue *queue = ent->queue; + + spin_lock(&queue->lock); + ent->fuse_req = NULL; + + req = ent->fuse_req; + if (req) + list_del_init(&req->list); + + cmd = ent->cmd; + ent->cmd = NULL; /* * The entry must not be freed immediately, due to access of direct @@ -330,10 +336,15 @@ static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent) * of race between daemon termination (which triggers IO_URING_F_CANCEL * and accesses entries without checking the list state first */ - spin_lock(&queue->lock); list_move(&ent->list, &queue->ent_released); ent->state = FRRS_RELEASED; spin_unlock(&queue->lock); + + if (cmd) + io_uring_cmd_done(cmd, -ENOTCONN, 0, IO_URING_F_UNLOCKED); + + if (req) + fuse_uring_stop_fuse_req_end(req); } static void fuse_uring_stop_list_entries(struct list_head *head, From patchwork Fri Jan 24 16:46:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13949733 Received: from outbound-ip168a.ess.barracuda.com (outbound-ip168a.ess.barracuda.com [209.222.82.36]) (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 24EAF15CD79 for ; Fri, 24 Jan 2025 16:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737264; cv=fail; b=c0WFKrJsWCyhV9jEf26Ul5eGLaxueMqk0Q0ZA1FrlDPm9YY6i3JwMSKkbO52DQ8iVLZbX+O2mRP3Bp9m+ZkC8wM/8Sl9Mpak7Xr1iCPyd2zSO1Ot3ySefrB/Ir5ETzn/OUq22jcUtQusoENT7RWoKTH9UJ8npEu999QBfzO4xs4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737264; c=relaxed/simple; bh=mmYQgr4xT0s+tpERMuxN/3+z3AOf/vKjTEggk2uOsE0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BouNR8VW4oUccoZJUvSw+LrbK42JZPjW8QE2eqqSFi/Uzo5Dzt4egHnuCwEyOGpGaWp3bh9Wp2oCEUWNvcuQdIR55IcTWWMmyRPygzcW1UFK5hrKM33m9xn4VpIECJSf1+2QfhEnBiPLaHPhVCIBNa7gC4cdRsrr6RUL6IVje8Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=Xt4thC0r; arc=fail smtp.client-ip=209.222.82.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="Xt4thC0r" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by mx-outbound11-174.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Jan 2025 16:47:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y7lQQKFRMQuHrvsKO3wOL46bHKpcKBE9LBPd8Cu2Yrm90+5WoG/s/ciuKkSuwGC5KijdZSdJO2cAW8/vYmQEzH8hT91Pt4KFk8fFivmGlylwFD1U9htJ0qVAD51/e+JNkUdJ+PVp0bjf5Z+f6Gy5+uM2/3GBGLP7X0xDz4ENNoA1KpxyB8tUzJeqWWHlEblYePmKQ0vzMdaxN/pcvK/8e/pcptow5d0HZV49bHEsZjvcdudaKBCuIpfzqwVzpnsJbbYXfSsz7gGcrZZE9YVBQzxvGks6Cf6e7fdxtikkLDtQB8Hp3qb5mj2hPSAsK266i1xP+JiBD/G0ZOFq0kVZrw== 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=19OfjP+cJyZoJzu+CZ/6sw5/92wMTTylOf2yltTPsWw=; b=UAmkwxDUy0A/2YPRxZntUeTaei3Sz8+VHrSoWn2km3SoG46vb1RsbmvtctsMFHLTBFWJqhs5ldYeq4D4ixNYFY+zu5RRjzbAhDBAc6yDrZWOFZ9S7exJCYGqf5eEbvL5dGc8fjqCGsyY0+NkhVMN4jGrmlswhOi725FUk55etXbW+DOtWIfjV5nfLJ7Y0x4QkLEmk8iLMI1GEf9zA2Z/Oa/s9lCn9UvN+gHZlsLBtJTuG6UnmdPd2/RYzbEM/x/tuzXLSx1zNIw9n1lwDGMPS+mPAP74bWMs3Pw8bmc7Z2//GOBegUZlgeHvUi3qGNlnCi91Sl26Z3l0nC4xgfttJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=19OfjP+cJyZoJzu+CZ/6sw5/92wMTTylOf2yltTPsWw=; b=Xt4thC0rCj1m30iWZ42XwsbFXpDfoSJXdyBZrezgIZnklGRd/Q2Na/C+sFqSIPADwUSZQ6kcOLplWOOly8S+imWfv7LZYps/GVIPzWd6ZyWkm/5sX4XBsXphl/PgqEyyVX95zVgOHv8OguMR1D8OxqFbg+dckH8PNc/H964SVcE= Received: from BN8PR04CA0001.namprd04.prod.outlook.com (2603:10b6:408:70::14) by IA1PR19MB7637.namprd19.prod.outlook.com (2603:10b6:208:3f7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Fri, 24 Jan 2025 16:47:16 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:408:70:cafe::d8) by BN8PR04CA0001.outlook.office365.com (2603:10b6:408:70::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.20 via Frontend Transport; Fri, 24 Jan 2025 16:47:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.8 via Frontend Transport; Fri, 24 Jan 2025 16:47:16 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id F1D2934; Fri, 24 Jan 2025 16:47:14 +0000 (UTC) From: Bernd Schubert Date: Fri, 24 Jan 2025 17:46:53 +0100 Subject: [PATCH 3/4] fuse: {io-uring} set/read ent->fuse_req while holding a lock Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-optimize-fuse-uring-req-timeouts-v1-3-b834b5f32e85@ddn.com> References: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> In-Reply-To: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> To: Miklos Szeredi , Pavel Begunkov , Luis Henriques Cc: linux-fsdevel@vger.kernel.org, Joanne Koong , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737737231; l=6303; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=mmYQgr4xT0s+tpERMuxN/3+z3AOf/vKjTEggk2uOsE0=; b=oYxbAHpmlYhxNE1i87BXGUj9QaidBu7mkie8SRig9Ju+K1SrCaTwpxyfPsv4QfbWMxQlIuLzS Lrb0Azdd4CQA0tHMpYrGShG4o7n8oX3vDRA/CSRsBmJuqpVt4KCdE0t X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449D:EE_|IA1PR19MB7637:EE_ X-MS-Office365-Filtering-Correlation-Id: 18ca1c92-67ad-4af5-0e86-08dd3c96c275 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?TEYGlIw+lhb+08x94Esg1vCt53eTA9A?= =?utf-8?q?aFXOOrHiauo/JJ6xyQ2F6un3qgdM5hCMe1YPEwXc9Rliu9qRi/ALWaaylZP0dnrUG?= =?utf-8?q?6fQQ4mjaZrhN3to48swleQJa644lmabR24270IQqx8QceiC+kFrfHhjjy8ixt2iDC?= =?utf-8?q?rqDWRU6NTQz91ib7dx3tXtS2eqe1kfKPJ7IX2NDh5V5LDGAQM85GIhCJhDkVOcTLC?= =?utf-8?q?xslwGjhR8fqO1jjtm7NbOGt3zmBc/KJILeL7Q1ihZjMt/WxDij/n5otf7ZKZ0iaQJ?= =?utf-8?q?tDd7dg1LPzwhfqGshOc5KdfQRgzGBR568pg5qDDkjsDulzbE3PMJu2Ay/nDbIskkf?= =?utf-8?q?7KlVGy1E7Ts1Ou3Qyeej6cuBrcufubenMBAwG7P0nrP3TUJtVlI0neF4oDgVXuPLO?= =?utf-8?q?ve71HtNf9umTrdMyK9tZfdPYqmd51177AZ4pbhYOgK0p5Tolckc1pThXbs5dZY6j5?= =?utf-8?q?5dC67WcScQQpyJK5ygmrpFluYZy9IinMThlCDzJ4SFL21m3XcXkUCFjQRNsrXt7Rb?= =?utf-8?q?l3ekuAc7lBoGEILLBVTNV8Sh6NjEx+6/0Iv/zy04yWfpLl2nDjBCQ1PbbVSLoteRX?= =?utf-8?q?5VTAgeJfEMR+N4jcctEtx50qdjHh+pumjvafgg/LzcHMCS2RM/r9NMHr3nIHI185X?= =?utf-8?q?dLXMaHnO9RknL81uXxF0CkC1rZWsx9lxgFDlLEcFExjcYWc+3vl6RRqvLdvTYKUED?= =?utf-8?q?ixOngw/riEOzzRS/088cwQPuUhyQ8fnyG/evWLBtlo5uwreBkqVxMl15ws2lw+ahe?= =?utf-8?q?8F6wqgMA/X0ANHqEBRwVf3QAsAfAw5qPvZd/BZ2yt+X/e0CcXxgX2q2G0mNmrmJl3?= =?utf-8?q?67VDcGk5pzEkDCVd3MFslZaXVbph53PQSDOwYc5FSl5+hbA9cY/OjDaMWdttK70T5?= =?utf-8?q?oz0lh5BPcBQdPd7G63lWK8HGncx8+d6RvFNEjeyb5D4Nmqc7w2HHDdf0+JAYOTyY3?= =?utf-8?q?YXexx0Jb2uYMv4DEtTPd3eV2S/MsG9F4x9/t30Yz7GDU5eKd9vIcPTF2hrEtiW+H3?= =?utf-8?q?U3dHsIc4qR9gHWyqduSuspnaDGNj1r8dcHkg9kpNcW/9L0lRWuOozsM3g35x0j3uL?= =?utf-8?q?uOIvfIJiI5DBXBBt6rICb4CIeVjpKSVfXM/thcpVG9S3oImZnx347ILxPnbIyGtr2?= =?utf-8?q?ndB5F7rGLSa8WaeuH96r3wuni9CW5LKbMuHC4V5teVlHwTJ3SwUCYos3Pw5CHsF8F?= =?utf-8?q?hrr2772/KlteV3GdHUn7uEQO/M5gA0My+QWrSFqVwdz9ymNR4YzpqulttSUam/Jlp?= =?utf-8?q?TRs9iAIGmx4Lcu1Xyu8jZBiDL3TpiEioi62spCIw4CiQoxJ+SJ1sj5OcTI56rV57Y?= =?utf-8?q?9vicvvTI1kR348gJthbpc16m4NEiCx1h+rfQtRb2mysk+wqfsr14MxnqWovMlx8/S?= =?utf-8?q?sacGNnD+yOwoI/OFG7bAZ49d4Pg2DTMpQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mkBlJbUiH2djE33wsOf2Bfa3wE/f33X/xav4EwhAreTtjKGKzkxYpGwr5r+sRtNvR8T8UwH65/b2t0a9zYS1G84scOJJd2kLwtfKWVpWa12/YUDKtyseSB18LGBq7EJWlIUGGqt9CS/xrVSvxXTbcwso37tjW4DwJ66cdehnXr0K7qIpaXBirAbO51mKLtV1MnVoq1gGMq195Uz+KLyukv3YIYENwSDHPzPt54LPAshRlxOkWWZHZaHsLz8jHx3SHwUDQrrcdov9amhA/hP1wevML7UL7vyo/mPnX5vONgqOb5ZABq+TRAx5xvBg5uLhD2rzy5Duw8NRlD0A72RtF9+VFTwyeuiAIbC+zPBcBOC6Vj7LVJ/kGYLq/xuAZT6blRyv6YYdkK1I42zYZkIQpXQend3fqkKQBP0mP1SNjmgjAt8W8VDsFNqF1FXycrj3V7SuP0SlXtvrkp+9FYgNrJFAtgFurxedrXJveCb3KxBzanAHM8PRTbGilphnuNNsaHa8n8x/Mn9z17pWp9xfSEtcroBlO4qPlfhGplUTbGwhN/D7A5+1K/imZyOqTx1IvcpYEKGxzy0ZwSNGEQXS41d5iIJcPNUZNUTsSrklIyeHCpMeThLpxdKxDRXbEpMoopUkeu5M8RE+az0+AnImDg== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 16:47:16.0284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18ca1c92-67ad-4af5-0e86-08dd3c96c275 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB7637 X-BESS-ID: 1737737239-102990-13434-20870-1 X-BESS-VER: 2019.1_20250123.1616 X-BESS-Apparent-Source-IP: 104.47.56.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaGhoZAVgZQ0MLIItnY3CDF1C TJwtzC0DjJwNw0zdIyLdXM3Dg5ydhAqTYWALZdbUpBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.262028 [from cloudscan21-255.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This was noticed by Joanne, we better set ent->fuse_req while holding the queue lock and also read it with that lock. Issue in current code was mostly fuse_uring_entry_teardown(), which could be done from an async thread. This also changes fuse_uring_next_fuse_req() and subfunctions to use req obtained with a lock to avoid possible issues by compiler induced re-ordering. The only function that doesn't use ent->req without a lock is fuse_uring_send_in_task() and that was changed to use READ_ONCE() to ensure memory access. Fixes: a4bdb3d786c0 ("fuse: enable fuse-over-io-uring") Cc: Joanne Koong Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 54 ++++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 87bb89994c311f435c370f78984be060fcb8036f..c958701d4343705015abe2812e5030a9816346c3 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -75,15 +75,16 @@ static void fuse_uring_flush_bg(struct fuse_ring_queue *queue) } } -static void fuse_uring_req_end(struct fuse_ring_ent *ent, int error) +static void fuse_uring_req_end(struct fuse_ring_ent *ent, struct fuse_req *req, + int error) { struct fuse_ring_queue *queue = ent->queue; - struct fuse_req *req = ent->fuse_req; struct fuse_ring *ring = queue->ring; struct fuse_conn *fc = ring->fc; lockdep_assert_not_held(&queue->lock); spin_lock(&queue->lock); + ent->fuse_req = NULL; if (test_bit(FR_BACKGROUND, &req->flags)) { queue->active_background--; spin_lock(&fc->bg_lock); @@ -97,8 +98,7 @@ static void fuse_uring_req_end(struct fuse_ring_ent *ent, int error) req->out.h.error = error; clear_bit(FR_SENT, &req->flags); - fuse_request_end(ent->fuse_req); - ent->fuse_req = NULL; + fuse_request_end(req); } /* Abort all list queued request on the given ring queue */ @@ -298,13 +298,9 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, return queue; } -static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) +static void fuse_uring_stop_fuse_req_end(struct fuse_req *req) { - struct fuse_req *req = ent->fuse_req; - /* remove entry from fuse_pqueue->processing */ - list_del_init(&req->list); - ent->fuse_req = NULL; clear_bit(FR_SENT, &req->flags); req->out.h.error = -ECONNABORTED; fuse_request_end(req); @@ -685,16 +681,16 @@ static int fuse_uring_copy_to_ring(struct fuse_ring_ent *ent, return 0; } -static int fuse_uring_prepare_send(struct fuse_ring_ent *ent) +static int fuse_uring_prepare_send(struct fuse_ring_ent *ent, + struct fuse_req *req) { - struct fuse_req *req = ent->fuse_req; int err; err = fuse_uring_copy_to_ring(ent, req); if (!err) set_bit(FR_SENT, &req->flags); else - fuse_uring_req_end(ent, err); + fuse_uring_req_end(ent, req, err); return err; } @@ -705,13 +701,14 @@ static int fuse_uring_prepare_send(struct fuse_ring_ent *ent) * This is comparable with classical read(/dev/fuse) */ static int fuse_uring_send_next_to_ring(struct fuse_ring_ent *ent, + struct fuse_req *req, unsigned int issue_flags) { struct fuse_ring_queue *queue = ent->queue; int err; struct io_uring_cmd *cmd; - err = fuse_uring_prepare_send(ent); + err = fuse_uring_prepare_send(ent, req); if (err) return err; @@ -777,28 +774,22 @@ static void fuse_uring_add_req_to_ring_ent(struct fuse_ring_ent *ent, fuse_uring_add_to_pq(ent, req); } -/* - * Release the ring entry and fetch the next fuse request if available - * - * @return true if a new request has been fetched - */ -static bool fuse_uring_ent_assign_req(struct fuse_ring_ent *ent) +/* Fetch the next fuse request if available */ +static struct fuse_req *fuse_uring_ent_assign_req(struct fuse_ring_ent *ent) __must_hold(&queue->lock) { - struct fuse_req *req; struct fuse_ring_queue *queue = ent->queue; struct list_head *req_queue = &queue->fuse_req_queue; + struct fuse_req *req; lockdep_assert_held(&queue->lock); /* get and assign the next entry while it is still holding the lock */ req = list_first_entry_or_null(req_queue, struct fuse_req, list); - if (req) { + if (req) fuse_uring_add_req_to_ring_ent(ent, req); - return true; - } - return false; + return req; } /* @@ -806,12 +797,11 @@ static bool fuse_uring_ent_assign_req(struct fuse_ring_ent *ent) * This is comparible with handling of classical write(/dev/fuse). * Also make the ring request available again for new fuse requests. */ -static void fuse_uring_commit(struct fuse_ring_ent *ent, +static void fuse_uring_commit(struct fuse_ring_ent *ent, struct fuse_req *req, unsigned int issue_flags) { struct fuse_ring *ring = ent->queue->ring; struct fuse_conn *fc = ring->fc; - struct fuse_req *req = ent->fuse_req; ssize_t err = 0; err = copy_from_user(&req->out.h, &ent->headers->in_out, @@ -829,7 +819,7 @@ static void fuse_uring_commit(struct fuse_ring_ent *ent, err = fuse_uring_copy_from_ring(ring, req, ent); out: - fuse_uring_req_end(ent, err); + fuse_uring_req_end(ent, req, err); } /* @@ -840,16 +830,16 @@ static void fuse_uring_next_fuse_req(struct fuse_ring_ent *ent, unsigned int issue_flags) { int err; - bool has_next; + struct fuse_req *req; retry: spin_lock(&queue->lock); fuse_uring_ent_avail(ent, queue); - has_next = fuse_uring_ent_assign_req(ent); + req = fuse_uring_ent_assign_req(ent); spin_unlock(&queue->lock); - if (has_next) { - err = fuse_uring_send_next_to_ring(ent, issue_flags); + if (req) { + err = fuse_uring_send_next_to_ring(ent, req, issue_flags); if (err) goto retry; } @@ -933,7 +923,7 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags, /* without the queue lock, as other locks are taken */ fuse_uring_prepare_cancel(cmd, issue_flags, ent); - fuse_uring_commit(ent, issue_flags); + fuse_uring_commit(ent, req, issue_flags); /* * Fetching the next request is absolutely required as queued From patchwork Fri Jan 24 16:46:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13949732 Received: from outbound-ip168a.ess.barracuda.com (outbound-ip168a.ess.barracuda.com [209.222.82.36]) (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 DA12415958A for ; Fri, 24 Jan 2025 16:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737260; cv=fail; b=i3X6+9fHmGIOvhpGnvuMOnQT4pplfCevrD0DHnBFKnTe53wcUD9uul5oM/fdFjfdyguKwKSyn6fGoBzzwUTTlNHVYRqbFwBuZOvfXFWZfSeSTUzY3Yd9IUmt7HtOrJsH8dblXHUyjuOLZstKTpRnc1GmidcXWWc0zAhujpTEBrw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737737260; c=relaxed/simple; bh=QC5g3Y9Ki2CLVy0xdoc9tKQIgIoRon/XUhR1K6un1dM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CcRv5jaJt65bxDyBhN50iXqW4SmB0VrUEteu7nPWehxd189KPb3PmCH8COWfQrho+zyOeyS7OcLb2RJ1SdqfLf9PPPwkxHOtTLqW4/ACGDxwo6qFrmJnxfBHmaiaiGOIVVmxyxP1t3LVA1RQ06zGHiE0HDgsnbUoj61FDZVexa0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=xFjMIWst; arc=fail smtp.client-ip=209.222.82.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="xFjMIWst" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by mx-outbound11-34.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Jan 2025 16:47:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uz16huy02GKXApe4NxS84/augjhS5FjgbaODQXTLFM70OgTk0wRIg5XWXlJpXQc9ar7bywLySjXh7NdhIAS/JdfqmtS8tTn8/lUIhCu08MLLUJSTvCSkt5Gy7IsX1Zjsjj425YD7KXEc4lYe/xamOItqCZq5fwi9c/2p23ZT6qw51IQr4sp6J4rU/4NZPTSbnbblCebPW7htbcDx/y8eYsoYk25RjEG7EM5i+M1lcJS6Q9YAfl1MhdQ4jHv/xse0lco3VWcS5aOawZKYHzyvD59rlBUpBZ3xm6QdsbUlhd6aPLK1jN6O7rrPB22ulxy2c5ynlStSBjrLSZk7gxjtkw== 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=wc+mea3tcKX4gCh/B2wgNuSW2iW4H3fMvrsJto8Hx8o=; b=Si+NogawDz4Ypcen/QPZ81vOUK+Tk7DEVHtijYt+5P9Kv7XoLkL+YhgrO/GQ+Sn4sZ/hqn0mnSaphBzFlZ4WmuePCHYnun4/k11KRiHqFzlDZD3rF4zfOuWbwdIJz8oba2FEssH8uxfvg5U+VSWtLFn0K7B/Rg45geTeaOpNLolsGKBS8bgamW4yVDrxhtritU83v7hdJRpNSzaXs9yKD2sdz6uXumEeXLZaxKy3pAfyffgtfW/VifRxi8BJD+iSkYXlyoqew/HZww8FcXVQgEMSTZg54dXgb1/Tow+mNoI+SNsiS6alUJKqWbeCHBBGxWqbWfbMXZay56fFZwPVag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wc+mea3tcKX4gCh/B2wgNuSW2iW4H3fMvrsJto8Hx8o=; b=xFjMIWstKid8hC9c1ATzgXZP+8JX+FmQilRSzrCnpewFuEKZ198Op4KoqUhJtWGLkfR4X+oKrvfNf0SJSIzk7SZq1AKHOv7fxgLDJ6x3KReJIuW5w3zbynYkvtZwV+VF8dsLAjKEiUb+3uz775tVF50hjYFbI8ykesZBGK+1KD8= Received: from BN9PR03CA0570.namprd03.prod.outlook.com (2603:10b6:408:138::35) by MW4PR19MB6846.namprd19.prod.outlook.com (2603:10b6:303:20a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.20; Fri, 24 Jan 2025 16:47:18 +0000 Received: from BL02EPF0001A0FD.namprd03.prod.outlook.com (2603:10b6:408:138:cafe::be) by BN9PR03CA0570.outlook.office365.com (2603:10b6:408:138::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.19 via Frontend Transport; Fri, 24 Jan 2025 16:47:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by BL02EPF0001A0FD.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.8 via Frontend Transport; Fri, 24 Jan 2025 16:47:17 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id EBFA458; Fri, 24 Jan 2025 16:47:15 +0000 (UTC) From: Bernd Schubert Date: Fri, 24 Jan 2025 17:46:54 +0100 Subject: [PATCH 4/4] fuse: {io-uring} Use {WRITE,READ}_ONCE for pdu->ent Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-optimize-fuse-uring-req-timeouts-v1-4-b834b5f32e85@ddn.com> References: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> In-Reply-To: <20250124-optimize-fuse-uring-req-timeouts-v1-0-b834b5f32e85@ddn.com> To: Miklos Szeredi , Pavel Begunkov , Luis Henriques Cc: linux-fsdevel@vger.kernel.org, Joanne Koong , Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737737231; l=1124; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=QC5g3Y9Ki2CLVy0xdoc9tKQIgIoRon/XUhR1K6un1dM=; b=kZwSqlW75fuBLIUcVKUiHGlRjIDsqOqW+uKZK50jlSoFpK/0KlcTvJgN3duJX9My7uDkceKCv KTvTfwbu1yhDfIGpDenkg7+DEZdbZEKOpXx/Wwner+PPoseUS58/Xbp X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FD:EE_|MW4PR19MB6846:EE_ X-MS-Office365-Filtering-Correlation-Id: e880a360-6e0e-438d-be3e-08dd3c96c315 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?IGPPB5JwyLwO+1bFmJIkaApNKW5E6PP?= =?utf-8?q?oXxO4Mvmf5Wi4MkQHxhztbMdh1cJqZ0zj68gq/dBwChfd6biZS6R+GO/APQ9fahtg?= =?utf-8?q?+Q42Sux+WWu8no/CpqJ0b2681FHUKtFDVf4p4rSCQRJlMmMmZfDTjtmJeunPNIGSc?= =?utf-8?q?9Qui6M4ACaFzna/xcfdf7oH7/MH2ekbEsJHSYC8nKfBY7vDKVnpIkf+cFouduUwad?= =?utf-8?q?PMbr4/PLzhXtSmXxx/+RbNpT8EmirSWldPntVBjhP/YXCR4c+8I2pvpj3993yY7f0?= =?utf-8?q?GEN9DF4zo6sgPqtstEbTEO22HFbtEpSTwd09ieHPUg1gUqhsYqhH/bhOdLuXc1/43?= =?utf-8?q?A6ODDk49BiO8qPP9/U9Ie1bEVnD0a2x+pGgBm49n7UvqjvnqPuvJbFE3cxcajXNTy?= =?utf-8?q?X84lmDk99wdccJ5uEjvpCQALSFceed7/bDzDXXokvNU8Oaotr3KPnY8lTyaCI4RjA?= =?utf-8?q?D/a42Alu95FRkmGsZhgjRj0z7IegP7KmF5iV2CzJJ37yMCQvRharRydgXgkI3DBZN?= =?utf-8?q?NzGQccXeVNhsmz7WE1PtOPqtYUCKwNJVLpfO1FwTqJ4QNcH7y3CsdRriCHNaPBueC?= =?utf-8?q?0ypXZGa0sERLaYuCX6I+fqr34REMnlupLq02AypDvGDdFL/+4QKWZIySvHUFHIsbt?= =?utf-8?q?t6Xt8To0KHOY3XrjsmZp21z6XOxgSA2iI9EAU5QnQMEN8y+3mUgHzFERJmUVxKnP7?= =?utf-8?q?qgf2i18XzakHHPJdtsvDqTymo7Dh07lL8Om9Ozyd7pMoxXbAawWff6RSDLWSR6T6l?= =?utf-8?q?VlvY6xCLsVs6RqdTTsvHAe2sZ9yw5Ns4NpqYECjqH2aeSgq553/AlSfUfoa0Hn30f?= =?utf-8?q?VSVMakfzN9qotCVHhTzNEp2Qb862UVJHQ7SL8oWxicRP8D+PKROZql/P91KobV2YC?= =?utf-8?q?YdEQILOF1rMhW2DjZvMH136HZCXHk0oPTr9lEfO+hqARGMyI+ZC16dy9C4izQVTyS?= =?utf-8?q?I0Kr24+WCQdYDvUZYwt1DpMYZi/s7QN2oa1S/IqO88z/Pme6DOdu3Q0fYIRT/o2tp?= =?utf-8?q?WYDdQIOuTgmQeI0Q7Rn7elj5a/e+QFv7v/Akx6FmijZ0IVrsZwKXfdf9o7EzkIiUr?= =?utf-8?q?kKvx+0x9RzF1p04z75LDToKA34FaL0JuAxvQf+z85EHIHzXJQ8sFXQRsmooveMD9k?= =?utf-8?q?c4GjL1TiAnsb5MrABvf47BTmDOAXSWJyqyCof/DES3EhwqW7kslOno2H2d9roZvc2?= =?utf-8?q?zdxl2vg6A30C4FvaRJH3o1TFdnc4iEGwlljVYIWDHHRAhZD1e/IlQYVPABfEUzNBe?= =?utf-8?q?ommI4/vd3cu36xi+dtZrofs7wtvoTVDmubUpAebBrUfGMBLV7I+E7hJc50w3jV4WH?= =?utf-8?q?Blg/kHnPuy5xM2C3I8tElBWB/zk1B+mxku8cLkbn1FVMR5ZtQpXyvzeLVM4hzDS+l?= =?utf-8?q?LYp9hhYj6bUzcH2rd8RHcUGPXSPnTHreP9g8PhSAtKsqj0w/EK1vz4=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pEdyID6MiUXqXzJVFxA7xtwBHoGHWeinRqZny063Fh0F0fMce1hTiwRuy77NqNr+7U7a2zwM+VZL8AmYouRCBFAtfpupPmYQvvUS7qTDai8ds1h6bQ3w4jcjoQBzK8CDPkGR3B35rlpyAlOv94Z5g1VtS7GlAvs8ZSHBYuSAasnvRS7FSzZHLPbXW9pO6zIyfZn8031LoJ8djTbqBqkPUSxTmkBXah01zKu2ZUL3di5qTrrdu/gdnSTI00UZmGBJKXYuDJfGPXPPOAtryoe1qDby2KbzB9j8k1ih+6YDG5tvsJCjbk134hYK9GduFCRggeG1EN/zOSS7qfmsPNx8EQJlWydEzuUyX6rujwXuxNZfsFM2qaoXijbTlo32zjuLprSFqO7yXXwDwHSHpgAgy0Iuu27iLeAa6RO6Bclku1Xvo/ze1bbEzMjGZzWsP9zfqo6aveyQxFuIyVGVwJk45iTErmanDGGO+onO9B2q0Ow6Goftxevmu0sikxHi4XTEcV13lSjYei8jVZ4uG4ijkTd84UqpnqAsbNA4UiPr+6SnINl2kUy49m/YWWZUEzvXqe6cqbnBkWRZyfENOh7YxgDU6oX8YJEkRPyatrMf3lwsGQQJ0yFanh1uODl+ml61nPy+y0UIKL3zaFSkuVQtLw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 16:47:17.0658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e880a360-6e0e-438d-be3e-08dd3c96c315 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR19MB6846 X-BESS-ID: 1737737243-102850-13353-20190-1 X-BESS-VER: 2019.1_20250123.1616 X-BESS-Apparent-Source-IP: 104.47.56.176 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGloZAVgZQMMnM0Nw0ySTFwM Qo1SQ10TzF0NjEwMDSLNkkNcXMKM1cqTYWAFaaBBBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.262028 [from cloudscan10-31.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This is set and read by different threads, we better use _ONCE. Fixes: 284985711dc5 ("fuse: Allow to queue fg requests through io-uring") Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index c958701d4343705015abe2812e5030a9816346c3..c4453352a0c1c0aef387caf45bae21eaae0918ef 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -36,7 +36,7 @@ static void uring_cmd_set_ring_ent(struct io_uring_cmd *cmd, struct fuse_uring_pdu *pdu = io_uring_cmd_to_pdu(cmd, struct fuse_uring_pdu); - pdu->ent = ring_ent; + WRITE_ONCE(pdu->ent, ring_ent); } static struct fuse_ring_ent *uring_cmd_to_ring_ent(struct io_uring_cmd *cmd) @@ -44,7 +44,7 @@ static struct fuse_ring_ent *uring_cmd_to_ring_ent(struct io_uring_cmd *cmd) struct fuse_uring_pdu *pdu = io_uring_cmd_to_pdu(cmd, struct fuse_uring_pdu); - return pdu->ent; + return READ_ONCE(pdu->ent); } static void fuse_uring_flush_bg(struct fuse_ring_queue *queue)