From patchwork Sun Sep 1 13:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786433 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 4D6D1183087 for ; Sun, 1 Sep 2024 13:37:22 +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=1725197845; cv=fail; b=US7PFqG5wCCAqRMugxEP9al+IYuX92bwDcbhBAcePj/SbJWje7Zirs9X+91CowfDae2Y+CgZ4CNm2J4eLzV1Lpce7OoYSeqeADOXa9K06s3FA+pP2PzfswptkAxcOJ0nAVwroLm1ku1sBbKsI41M74juIJ9TL4q6yYFI0TXRERw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197845; c=relaxed/simple; bh=TfNQSKeB7F3/+dh+Af4cyQEWuwq5YHJ0xf5InxsLB9g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eI2a/aVnGQiM/vqDkQheaHaFCtMQk+Boi1MU1+YtDnea6eVHVKO4qzAUOg8Am9eCRevoWERHSuYZGUB3pIxN3jhrdwBZEDLDOZ6p87plV2we1hRj/jfeg36Rm+7+TS0gGzWwqG3AvU6rdSvzIWQWEiHU668kKZLdVQIVgwDH+jI= 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=l4n55oB+; 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="l4n55oB+" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by mx-outbound46-102.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q8MIergY8wqEH9REI/q7rbjoZshqXaJWnxks/gQ1ujP4/Sgwc3P4rh+eHWMVS6b/tWjeNrcfxOkI9Qq2sOqs52xurIF5FFnTsd6C3pEcTBogLrUBl+Twud/YJhfKnL+v7jNAFu/JeG6p5FBCU17AcnD5ZPwfZ0a1ILK2fLFqHiuCQ5FHopPZBXNl9xcdVnn+X4XOzyKWCsgKu4db/sUy2Njbd0pQA2BkkBBuYY/27CJrutBuHaNqGYifeIGlCkNJ17nt2jdoqcO67fo9ay/1Obv3WC7bFxiWudXqFT5NJMttACHxdzM9CbelCYchE/9rD3wT+FImw6vunHAb6pRWrw== 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=DT1T7381vULKsMd3buvk6qO6/yqyAwmtdMrJdlOxvsI=; b=J6Zqd2gtqzjMmUAz9S5axHhJxyCY1Ie3aLIVoBVFyk83bIY/m+rh0pIn2qkp/vKh6Cw8CsVVo2DP1tz0u2bUs8vHclC2ZiIqdWF3RyPsP/nBFtMZNe+OoGY31Pd8GRYaXxjbIrKkmtwkSr4n9uEwXAE7aG7u6mxRftgfrzd8IEUvc9+qhAjFwFIngO4YVsBa/GPuIOgLp99BPWM2VCQgNpFRJ2x0ChqTH/sZOodQ2xxAu9QoswYZdezbmwCDt1LHhq2AZwh5KXlnCG1pZmldm6F4K3Q3PeM801jtz4qqxytxQRYGP2puWNoTGYrizDFGZ2oz2nOGZoURJWbZC3Xi4A== 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=DT1T7381vULKsMd3buvk6qO6/yqyAwmtdMrJdlOxvsI=; b=l4n55oB+xEEwH+kngL7Usb/UdFIpZ/Z/fSyWlYNS4T6F6l3El/GvQ4+rxCCT1JYQq2WxstO1G2By9cH1cXsItx8T3DRd9qeXIhKl8OGlNiar05ByVMbuBHhTZpwY2nAfolcdmXKOZ0kpx5dgyxEtZnYmUXQPqRN9OMM0wrbxVOI= Received: from BN7PR06CA0070.namprd06.prod.outlook.com (2603:10b6:408:34::47) by PH0PR19MB7570.namprd19.prod.outlook.com (2603:10b6:510:288::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.22; Sun, 1 Sep 2024 13:37:13 +0000 Received: from MN1PEPF0000F0E3.namprd04.prod.outlook.com (2603:10b6:408:34:cafe::60) by BN7PR06CA0070.outlook.office365.com (2603:10b6:408:34::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23 via Frontend Transport; Sun, 1 Sep 2024 13:37:13 +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 MN1PEPF0000F0E3.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Sun, 1 Sep 2024 13:37:13 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 3BD8972; Sun, 1 Sep 2024 13:37:12 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:09 +0200 Subject: [PATCH RFC v3 15/17] ate: 2024-08-30 15:43:32 +0100 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-15-9207f7391444@ddn.com> References: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-0-9207f7391444@ddn.com> In-Reply-To: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-0-9207f7391444@ddn.com> To: Miklos Szeredi , Jens Axboe , Pavel Begunkov , bernd@fastmail.fm Cc: linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Bernd Schubert X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1725197817; l=1851; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=pxJAJ9fhLRnwTzrQw0INNc/zulJ2qjLgXu6t66nWwDo=; b=tcAZWbgGD+w6Y72Jc4UiG1+upNbxqc2NxiT2vFWjNLqJJuuqOItFYp84ecCwom+0duIoD05mV 4nZg8/6wOAiAY+VI/OYP4p4bTeserhCgRphqb2sKll4SyFQW4jBcLwq X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E3:EE_|PH0PR19MB7570:EE_ X-MS-Office365-Filtering-Correlation-Id: bbe227e4-fb5e-49e3-c820-08dcca8b2fee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WVHIq6kiyOteiz0p68P56aNECNBYjoe?= =?utf-8?q?neQo7GEkKw8VdiDlPGP/m3MjfFF74EyscciIvtxwydciArOBflAiZLClu9QN2BaD3?= =?utf-8?q?V62w6d0Du1vO0WEV6vCL6BqPTbtJF4OsBHSt1mnmDIvfO218FTWczN9JQ6FHkUNAV?= =?utf-8?q?YZoqYlE4F75wNHIv8cnWXw2phs4MzYvjVeS2Rjw9de55EijYpJOXqV04n8WhJfoUW?= =?utf-8?q?LH3Dpg454fdq6bBUSewBfCUgobD0/DFyiloD2S+lzNddmb6/VVtOvTudiSZYm1gu+?= =?utf-8?q?ulJxKiIjIR1qpzxaFKRXuMVqrY7ihZQzoAeVO3ma3TRDynbn5gc1HficP7YXSZfkw?= =?utf-8?q?tNYMZ6c0/n4Z22Z778Myck+auhlfiIydMpzYQy2BFQOM8yr7rpxO9B9CC2jRDRZgU?= =?utf-8?q?fVa9/us3V5CaBK6WizxwUH+o48BmmQ6obqfknYePmHzYnzd6GE0vlI6HwU2iOWNJE?= =?utf-8?q?4DypGaHDwmcOMiMfzGcYTZ88pzPDtu9EgP8pqTOGQKnQhopga7nKThGwf7HdkhF1t?= =?utf-8?q?IAaaeYpSi8vAEhZs0yz3DuRW09ZXUGjBRYGmj7AELjE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ANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XI3b2McSECQtuQHo1CG89xJVbE6kdK5Zbg93/CNReyXQ/npUusmOeccArPjJLAPXum+JPHEnngs0VHhcyRZIr9sygIwhYpr7S0UXpGUUFkc+xbPjDpxIEn+5JVu7kyP6tR500WzJNAs5RXuConZqpptSw42gmPAgPnvKH5Z1aIj9S/LQh9KsncRFygZdoRiUKPQqkrsS+EA8vEZnpVd/MvaGUz2jgS0cgKYbJv/0FBXKYxgey93yfR13LyVEScTLjll6id0dlNfi8XgIoGAB42fsGH3Gz8CRHkVpfLUgNazX48PruuHCMnVCW9KDLXcaZUIwI3XS1Nbfna2o9Re5Xfz59/HUpsR9Ql1dIdd5D7cqN0n/tXmnZJlhcAr64EH8VNcHRGmY6MrRMt8N6QHXG3L+8hkmaeO27W4DbCJ2TpZ1Co5pJTQgc68337zw3gqVJ6SmvEgDtgHPQ2Uv1w6+V1YPnUZJ0BTTHQam0oQPT2UtMuD+FeyXqZkdP1j7qiDdvGC9AbhmpA+EEXMD9R/9pYwc6Tff5N22z1G1DFqWmg+qZvgaQcX1XZhyIgC15iVn4qv3415GXsEkYv/LCUDDtydvNsgboigbsqiOJhdJzK3yfbadulalPotCqcC/mho1lifIKbV38KB7wId4/Wy3pA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:13.1804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbe227e4-fb5e-49e3-c820-08dcca8b2fee 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: MN1PEPF0000F0E3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR19MB7570 X-BESS-ID: 1725197837-111878-3266-33033-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.58.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWpgZAVgZQMDHZwDTFJMXA0j Qp0TjJPMXYLMnEyDLFJDk1LdXSzMJMqTYWAGA88etBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan10-92.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 From: Pavel Begunkov io_uring/cmd: let cmds tw know about dying task When the taks that submitted a request is dying, a task work for that request might get run by a kernel thread or even worse by a half dismantled task. We can't just cancel the task work without running the callback as the cmd might need to do some clean up, so pass a flag instead. If set, it's not safe to access any task resources and the callback is expected to cancel the cmd ASAP. Signed-off-by: Pavel Begunkov --- include/linux/io_uring_types.h | 1 + io_uring/uring_cmd.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h index 7abdc0927124..869a81c63e49 100644 --- a/include/linux/io_uring_types.h +++ b/include/linux/io_uring_types.h @@ -37,6 +37,7 @@ enum io_uring_cmd_flags { /* set when uring wants to cancel a previously issued command */ IO_URING_F_CANCEL = (1 << 11), IO_URING_F_COMPAT = (1 << 12), + IO_URING_F_TASK_DEAD = (1 << 13), }; struct io_wq_work_node { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 21ac5fb2d5f0..e6d22b6fc0f4 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -119,9 +119,13 @@ EXPORT_SYMBOL_GPL(io_uring_cmd_mark_cancelable); static void io_uring_cmd_work(struct io_kiocb *req, struct io_tw_state *ts) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); + unsigned flags = IO_URING_F_COMPLETE_DEFER; + + if (req->task->flags & PF_EXITING) + flags |= IO_URING_F_TASK_DEAD; /* task_work executor checks the deffered list completion */ - ioucmd->task_work_cb(ioucmd, IO_URING_F_COMPLETE_DEFER); + ioucmd->task_work_cb(ioucmd, flags); } void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd,