From patchwork Sun Sep 1 13:36:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786484 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 4B9CF14A4FF for ; Sun, 1 Sep 2024 14:10:21 +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=1725199824; cv=fail; b=o/sJAcmBwi7bl8rmiuEgUuomtQCORxpLjmVXAKba+ySW6Gk8sZt0g9kYnlp3hzf8cDFv12QOWiO0y+NgwM40Pa1AQWPpHzSs+DzyZIb/8yXh0BJBd1j3+q7SO9zJSCdJiW3Pl42O0G4HFoGevSed/On4jwoA1cEKedz3tn6Rfuc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725199824; c=relaxed/simple; bh=xGBbWgo2hG/E1txkE9HfWsjbQKcS3FLe2casQepXLZ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l2PXhNRbhpcpF0Ek8KJvkZYkQwmwx2PImosp36zNk+YzI9EBBe6WDCw+q6ecj257Fwxpdxww2GGOPHJs7WHxvZsoB3ymXxIjmkVWnAc4HNZ9hM1LEswwohYXoww0mv9k5EaTzMT366QPMDW0hSigr6jLZmPYxtcNTyEFR5B3VEA= 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=p8isiqkq; 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="p8isiqkq" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by mx-outbound20-213.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 14:10:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dr9jVacMTY0Q915L3iVmnWdc93sf4vENJwm+srspocrcy5XO6AWbQF4Gu1C/kxehYk/Gk0v2JgNMQYqJ/d2giMS0Hr0Tcj4hX5uRpUrxpyDAj0ywpIk7fnMqCeW53l//abb5UCt2rPH1exucPZ7JkCZkTqUya4Mb5QfBF+mfh+wNerIIbe6xURdI2WlXpw2zwGdoJalASUo6fn2oWvb9nmLfLDaBKuDqWY7u853qsFeV9eX+5G3/iQs8q7+PqyB5IRBoFs7Qb1HPFyn5yNB5YHgDrXWXBbQs0Z5Fz36uWkD81GeszRQ/u3y7+0EjLlfaUd5dPfJqv3caREq+x49Srg== 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=EB2+Qa7oMm5M7WYKiLV8TBlwCE4F85ZJ3yzFcpM2wd4=; b=pG6YoiUAeWBuf7HOijLh76aOf7bnA9Q2B8cHxHC5ro+d+6YSMoye1ciWDZz41aGAGlvZ6FSD6nHdInxy/XnvvARxLcbXVtrIz9rqEAz90E7PeTKyXqpxtiV3bgITgjJlw+gNoesfhlKkVr8fODXnWa2xrYv569+oZkD58B4Re/RNOZsUxHW8oCRt2mv6T1XudK/3JE/nKi31Q/y+v6jVrSkZPXD5taz5JdcRXvCxfuQIm7Q+UepKrAgZKAVkP+89dDR4clsBbCJMbK08lBBd2ux36Ni7t0rWFwqIeXyVXiy6DOfj6fkfFqxWS9Tt/mev3l5yTFtdLJXIe2ECEG9JYQ== 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=EB2+Qa7oMm5M7WYKiLV8TBlwCE4F85ZJ3yzFcpM2wd4=; b=p8isiqkqcmUtJzhIDY9RZRw/NTFtR6YSdnxxLrEmr2fw1/sVWHwgjnhvTfEE24bCLCcJaSt82/YL1DXx15nG+VRVSXeqMSBQmnEC20Q34Pm5SaAULpVYRKop/dtwCWvDhyHOIt59sHMFVJCpyAjo2Fjpy74Amzl4BhsxOGX1XfE= Received: from SA9PR13CA0023.namprd13.prod.outlook.com (2603:10b6:806:21::28) by MN0PR19MB5970.namprd19.prod.outlook.com (2603:10b6:208:37e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:36:59 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:21:cafe::31) by SA9PR13CA0023.outlook.office365.com (2603:10b6:806:21::28) 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:36:59 +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 SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) 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:36:59 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id A4236D0; Sun, 1 Sep 2024 13:36:58 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:36:55 +0200 Subject: [PATCH RFC v3 01/17] fuse: rename to fuse_dev_end_requests and make non-static Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-1-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=2071; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=xGBbWgo2hG/E1txkE9HfWsjbQKcS3FLe2casQepXLZ4=; b=mpDC0wEjjky3LWI4I97s9WlGciUPSc8VEiW4BEW7ZxxvWuoyU73TDMeRjo4ANaTwn6sMrjyQu /JS5MHeZHlkDDPq16SQKdZsq/UjCXi4RQ4Wj6FMtVa6//j9isJwi69m X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|MN0PR19MB5970:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ce9707e-d654-4dc0-b470-08dcca8b27aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?L7PqteuyYraiJRcgctJRYt3gM2u25As?= =?utf-8?q?ol1wxkYQesg2Az1weKJskrYuYx1aRByFS4mJnD6NqCzx57U1t4wFXUTO5hJ4CcEEr?= =?utf-8?q?mZXjtfnETorxG8C2+berttdFnv/jEPOdqaVOngEHhMTjGFjz+Dk8Jp55NMTdTnagr?= =?utf-8?q?xNBZwYNROoNxqmL9lFtJPFWcNdaArhRdz+BuJXANqi2k183jtRmnERd7V7cEMR+U+?= =?utf-8?q?mBXWCdD1nRFIKqtSseA2KmrtuGh1M6qAnUnrIj7GQ4ghnO6qyfvRTpqu20qB5Ckbr?= =?utf-8?q?iwtCkkiHIdMT0COT2HTIRCzd/xj1TvpmRfOrNt6kfTAmqjeGCeMBYmf22Y6eKPElV?= =?utf-8?q?h+mcuRhIAiVifwrmmXseJQfFwHXD6FYTkyv98Og4kyP1DkoxiBt1M7iBk9htHBjFr?= =?utf-8?q?B5yw0oDnmvZUxMoN0G+U9azBHWHfKn3XpWZ/1nu8j7QX5WfHW0VVdLncllqshPe9e?= =?utf-8?q?M4riUMOmRPeZzldv3z0pd1DEWMOkPRNXqeSphBNkgMxb44D9FkIEhBi1oc23s4bsd?= =?utf-8?q?bBUnI2vuYrq5Z51aSb6M/fbSSOetmtQMfvNzZcf68mJDuZvlcllo+3PkPlFBAvlci?= =?utf-8?q?LsDD0jj4XnY1b87mZl6kHQUUMU2Us5fZCU7XXUAHaGLASnCuOfBqCEb6NiuhL3yjw?= =?utf-8?q?L4108zHv6M5Y3dRRlpkVrzdiMwMf5Db+5qSe74dwfeVsHWhTGXkE/RHYeBvv2TUGH?= =?utf-8?q?7tKdufzyHs1Ml75tqSqV1qomKTtHZd7asKACdVPc7/3lxs+WYdRJ2oESBs1x9PmiE?= =?utf-8?q?7pz/GBkaKWnvQwEvUwcUPoSBxydG1y+S5u9jyzHIAQDSQqf3EVTlAqCJQp9cJiTW+?= =?utf-8?q?Nh5ultr5tOzIj+l9cVBuveJX3Xpc6yyqUcJ/qt4p5lTnWTYBG6LeYxgGZrjnQrb78?= =?utf-8?q?4EE/TPRnwU4frTNmUw28tM4IhIy2AP9pLfcDO/6hH1J/CvNcdT4Hmn+8tETGh87HN?= =?utf-8?q?tR7R2V/30YXKgun6xtZ4UJ1JDDdE6dLNiXqxasf7LbkF7gYl7WHFL6/aY3zkDMUxz?= =?utf-8?q?7WDgy3ImRfV951qkQpuvoPLa2J1RJl0k/6Ww1Lh0zfa/dII7M+4FDQpdpyajyBp/D?= =?utf-8?q?C7BojEYfeoHH2zOE1vDTxHrDpRCgfcagj1MwCezVWphj9lfzxlKYkn44NwtDa8je6?= =?utf-8?q?1QbU6Ir9Rcfs4amGCRmMQC4aG+Y6undhUhvQCXX3ulwRoYNDCpZedXWLabLWG8Ytv?= =?utf-8?q?40Lit33/jfey3mXTRP3XPXcExa1jtdstucu6mlof+tZcZHxlmVPzSeujQBLis3YhD?= =?utf-8?q?21vLKOM568S+cy+2TC5x+ZiDWFrg2FLtdWfIPD6Rs5LqAru9Bdlx7NuSekDDp5FkQ?= =?utf-8?q?AHgjtxB+WvrNO7xNK/irEjnnX8v0meZPwatLmVGrJB0hoLDAhp6uoMltGw/NZqe+/?= =?utf-8?q?wbpctRhQQyM?= 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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nGtuNHZ4xPxSa7uXAWkQy5o7SHTIT+aqUhvwILPOnCR0T/2MJ0DEYIFDOH4mPqU0UA36lopZNTZ2yArbMlJbsmTGzNEqU1tCXMvkU8MJYze3AwhUIRLVrawqCo+gRSrWUeygZ1Ebqz7g8qys1PZeNMRDRK6VzC1smp5PWyfBGzmpD6BK9+vmnq17BQ5TqtXRwI/p/kwZpA22r439bSIeRdQ6Bc3CfVSh4o0W+rgh2cg9MpFqAl4inVamHq3cjWjCdoeaHL+0Qw6yiZvozbr9JivE+WLZEfzyGGghMss+6jnLjJ5CAwKwngQo20Kj/p+WkbzIYofvlDTyttiIWEiuM+hYUhJz1evBYXME//Zq881UyA6RavluQwsl5W7KM9YpRnLxoiw/3U2Apy0Km47063ce8rhKDJnZeIjYuL5ZD/+7Hr/+N4n9qEtPsRv1agZFlIrO1eWxUO+XGSPJ5M9u/G6mEmg/JiYdg/FazdWNTDcPmD058C4v3lmDGIuONMuPzEtXCUUqdzNwHbIB7pT+WCwA9c484ct3lltUwXfSbbVaz8IYUupOJiI7PctEkOTUOA8hWXBqi9GwVlo55oGaLxf0KMn/C9CimkyhGTqsm3pCIvQ9gRhL/0EMDJwCLeD6+8TgWycnSnIAilmYLS351A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:36:59.3750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce9707e-d654-4dc0-b470-08dcca8b27aa 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: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR19MB5970 X-OriginatorOrg: ddn.com X-BESS-ID: 1725199820-105333-12934-692-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.58.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaWlhZAVgZQMMk0Odk4MdE82S wt2cA4Mc0s2SDZyNwIyEo0TjRKTVWqjQUA2BoRZUEAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258744 [from cloudscan19-239.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_SC0_MISMATCH_TO X-BESS-BRTS-Status: 1 This function is needed by fuse_uring.c to clean ring queues, so make it non static. Especially in non-static mode the function name 'end_requests' should be prefixed with fuse_ Signed-off-by: Bernd Schubert Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 7 ++++--- fs/fuse/fuse_dev_i.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9eb191b5c4de..74cb9ae90052 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -7,6 +7,7 @@ */ #include "fuse_i.h" +#include "fuse_dev_i.h" #include #include @@ -2136,7 +2137,7 @@ static __poll_t fuse_dev_poll(struct file *file, poll_table *wait) } /* Abort all requests on the given list (pending or processing) */ -static void end_requests(struct list_head *head) +void fuse_dev_end_requests(struct list_head *head) { while (!list_empty(head)) { struct fuse_req *req; @@ -2239,7 +2240,7 @@ void fuse_abort_conn(struct fuse_conn *fc) wake_up_all(&fc->blocked_waitq); spin_unlock(&fc->lock); - end_requests(&to_end); + fuse_dev_end_requests(&to_end); } else { spin_unlock(&fc->lock); } @@ -2269,7 +2270,7 @@ int fuse_dev_release(struct inode *inode, struct file *file) list_splice_init(&fpq->processing[i], &to_end); spin_unlock(&fpq->lock); - end_requests(&to_end); + fuse_dev_end_requests(&to_end); /* Are we the last open device? */ if (atomic_dec_and_test(&fc->dev_count)) { diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h new file mode 100644 index 000000000000..5a1b8a2775d8 --- /dev/null +++ b/fs/fuse/fuse_dev_i.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * FUSE: Filesystem in Userspace + * Copyright (C) 2001-2008 Miklos Szeredi + */ +#ifndef _FS_FUSE_DEV_I_H +#define _FS_FUSE_DEV_I_H + +#include + +void fuse_dev_end_requests(struct list_head *head); + +#endif + + From patchwork Sun Sep 1 13:36:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786439 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 029203A29F; Sun, 1 Sep 2024 13:37:14 +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=1725197838; cv=fail; b=bG/bUbXUwxhRtNAEbl5vHSiKRoPp+44DJoSWFaDjnojWUbYdCbFVEYQgLXCFKO1z6DaGMWojUP79eciGIZKGIyqmGatFVI0q+FErZ5PZM64Ph0kr615cuZ+mMir+eKLwOlL/5pkUHZbklpb7KlRUEhLWJAaadm3r9O2P6zdEhv4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197838; c=relaxed/simple; bh=+r7EhP+63h6FqApIsmR73SFRzWpagGrXais2MsTBRxU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Si8IDAoqazuD5zaPU/idKizYoGQlCEcpsbZiNILbheA3wn80Yh+fDkFe0Xhl86NYGiNRM6p8nRDWK6yLLwr070uHD418dMSxZHatbvPEdq6pLibobfrrGnEqCIDMGCvu0E5z9OBOuyJvfYp0aQ3vbn3wyU7Qht2mbtgCisUb3qA= 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=fHUHhr7H; 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="fHUHhr7H" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx-outbound10-30.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XfG8a0N7tBuive/n3gbKUVr3eu5hA72sv/D5k2+WXoYMvcw9G9etqPMGRB0mWWlKYRwkxpAMYdRCyLIf6fMuZoT5yW8vakolD9jtzi1KxcZhKZhS8dDQJQE1sZgL6l7XuKV1kQX/3wq5vhQE/KKOLVB9dqtXySLUuS0TwpAuYtIt2aGyyM1Rek0hlxzilM9P33D++zjjS1DHdtbb5PD4e1OzpEpYePy29k+scgb/7zXmefZAAg0pZHef3l8+kqecJ/OBy/EQO5xT9qrpIExms73C4L8WaEKq2mS6nJKl3CRq+uaslh5X1Pnb9LqZKiN/ulrI62Nx2HzEHrUwW2wO7g== 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=cBsvOGbik58g3TROcZTG127F6qGJ+oALHjFIO1xoQdI=; b=qYrIu95Ep+B+LBnUvsG2x102PfhuxgCl9bE+q4+QY3RkvsCmu4qAirU97GTh3x8QNF6RgNcNQ+cvq+qO6UnJAC8k8tjJjtgtaApbLHDtvFs1Mkzt3NLCdVwgIA6m/RVaW7f8I2a6DsZT4G/8q+DdWdjDxlHrO9TuVvu/N0HjKI8jpVmVf1oiC8NUsrWt/1auWMs3Vab4/At3RYsGU15qMIo21raLA73IlXOKRV2RduQCiI746RzLGI33qL714/kBBaXSXINxPb6ALSaYjuKd4KuI0+h8z0BRj03oYz+GinKTEpLNRo0QsjL+Bq0yTiRBCWHN0L0ZL8atvX/C0t1jfA== 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=cBsvOGbik58g3TROcZTG127F6qGJ+oALHjFIO1xoQdI=; b=fHUHhr7H4/FMeS2ghxPWX7A4THsm0wNccRHpOHpHipnJOAOpOcj/OeQhO4HA58mx+KrSxzoaEauMmDxxMib/YF1qS4ov3DiB7Le9oYIwYSpswTx4T+aRn/zPBsoO3o36WwT34EBb5KbIezf72iQuNMYYIEpXlwzgFr4+KxXots0= Received: from BY3PR05CA0047.namprd05.prod.outlook.com (2603:10b6:a03:39b::22) by SN7PR19MB7089.namprd19.prod.outlook.com (2603:10b6:806:2ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Sun, 1 Sep 2024 13:37:01 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:a03:39b:cafe::52) by BY3PR05CA0047.outlook.office365.com (2603:10b6:a03:39b::22) 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:00 +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 MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) 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:00 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 9D20372; Sun, 1 Sep 2024 13:36:59 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:36:56 +0200 Subject: [PATCH RFC v3 02/17] fuse: Move fuse_get_dev to header file Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-2-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=1467; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=+r7EhP+63h6FqApIsmR73SFRzWpagGrXais2MsTBRxU=; b=Om6SklbavqnyRJbYNJen+joXJ2iqN2sa1zxov9lPdO6iy7BbZchkojkghVBvnzq5539i2qXzi Ns+JnK+j3FiBcZmHgt9NbpCQakXKwPtUqb6rV5x3KrnFd0mx8rRtznM X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|SN7PR19MB7089:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ce755ce-4b76-4cc1-a6ec-08dcca8b283e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Hwx7aU5eRcY9r7Zf//8zmxW3i4rPssY?= =?utf-8?q?bjjdjEI9dDslMABheTxegYexgMUFpyWotrdCJArtbGLNi7Uj6tElOmsQB+9OQfgc7?= =?utf-8?q?YGjRNrdF6xaqo0ri8HZGfNKzLkmcj4OtHNV8nCPlpVHWytoGXm0V9dC4HP4mGOgt9?= =?utf-8?q?X3pOs7tKueWZW+pQmkaNRpNlSoZJsj68YnfrB3dAFQYmMF14ILT0WYWj3afeDtrES?= =?utf-8?q?XrThXQyGK8dltUJDT4AA/KC46g3EkYwrABoCOE5FdZQjPx0NZkBK/QVW7/C7gSlaz?= =?utf-8?q?wtMgsC2wIBEOA6V/VxNiP9dN+AfVRTfxYr8leH/cYJnjIbi1iI7W68ylVBfQioOOz?= =?utf-8?q?4DAT4ZbFzCRuU2Fxy6C9sd7PS7vGHo3QIgExIqnjAkc02Y4CoBz/sAV3GlMSoSdEU?= =?utf-8?q?qVTcvvohaaJDSDghfutRMjrs8pL7eaflw8Uc+fY3mojq1ZewB0SLyrnlfTObU2tE+?= =?utf-8?q?qWeUlJDvOO9HbuyZmfo7J/hzjUrR3TgsO9revzUxm0W78csuVToFOOaq6DiF1LwFy?= =?utf-8?q?UXoKPRGPzxNQTZ4QW1fdPx6K1rarfsVkvgNprKY8M2RR+bJUuQa/pqLmjErU2jlll?= =?utf-8?q?ij9iYmwe2ppnbKUk2VfUA7Zd7Uhk+ZNAp57WxIVpoQb9EAn9nfsHA5FgVyokeEK8z?= =?utf-8?q?hyNPFVkwtpzuxMoog7WBE4UckFYbpHDQ5IsRUH4z3/HIJv8+xj2njSpwsP//IJZu+?= =?utf-8?q?/Rd3Grhi1aCq0YCMg0U7iYUu5Et+oK1QMUNoNy2li9kjTMU/a1FFLNq1MS6FgOcMk?= =?utf-8?q?kwzRrDjwoQf3a8/vD/XzsE/lWPDYT6wkO/QHDb5zPQY+s5XOCSavm8eDnagN47cxr?= =?utf-8?q?x7EueWK+Uo6KjOF3+uaOTWawf1gCwj9QexdrfZ0lfDFBF7tc5o7jrXswR2PzQVX7x?= =?utf-8?q?GREE3i3DZFkY6QRYstXMPeGdnuPgoe2aldbhedVHlNAL8ZPEHM+izZGvt5mz2F4KF?= =?utf-8?q?luY2FJ0GKvjDvR3fYRWx+gZcirZN/K/qNKEzCV/63FCoEJj0zSjLYvN6EnqOTtVlQ?= =?utf-8?q?Jb139s2buPCYV6oxi1COMqpHLKTbstFSlwGMjheqbCFwEfO+nK9mSaB47yWCbjqwg?= =?utf-8?q?tuu3Dj3J0uXwn0kxtwdR0/JzITiqluCiDGOGDga/qcwNUbXKYhItTvvfQWVFYq2AG?= =?utf-8?q?wCo5XaUVtP8Srq5fokuAeOe8Es8hvqj1WwA7PsKXwFzzhKHMn5OKURxx7l7bSzqpa?= =?utf-8?q?h8lblv0AD4U2hxhWV3CC/1DQfXa6yIOgzaG0v1PK+VH1++y9zwH7Y2jeIZA2u1A3W?= =?utf-8?q?3ETxsDo++X3c1n/hqT43Cifu+4ykS0uO3LXdBXUA0rO71YHBps8vS8apPYRsXvB8n?= =?utf-8?q?QlpRrLPX25MZAkX2RdGSGrWC457SDNkArfjBc7ban0FbZb5UuLs090Q=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)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ov0OHFvKuB3ULeCivMcyBKyuW1Nog1gh3wmbJyOi2A12ofUfl3CBztJLKVYkhllnaSeWh9w58ePkgyc1FTMOqLRWKoycsl7RQlmP76alRA3pXyZQhPGB4x+Dbds2dg7W7DGIOlnOMolC8+mJUrZRRbHN/gWo9f5qC9ZhebN2KFVLTopEHYvsScHjz86HjS4SqLLB8cNGdyJkmdvroO0kxUnrWcSSIpyIpuur4RfOxvSMDbhurKkMz3TR9pcDIZro0/Wpto33zO8WmgOiurKpmCCeMF2nMIUoEY8kltH6qt+FJGcczGBpj2G+racfc+QqczFcLktx2rxBMcc2wNvScCSvc2DJkpw2GMmhMGJzsQrobZoGBldeMpPxs51pj7t/zTgMqGPFCYfHA8i59mIVg1shWX8aRbZ/NlxaEtxYADyWNxobyuw/vV5SlQyEuDMWLQd9mqTYortGo1YdRzKM3PbwMy7AOtKuRLypw6W9wF2fgPFB7T9VEDjywKQG+arG9mnx9oiZj8hPgvPys8Y8HYu/IzERYZUKfhBDjTc3jpaFajvDktgruEqZ8+PNrx6EbnbLv7eeS3XinLR2FfqWLd5uWgpdeefcEY3pgofGCHsYsxCvEDcSYmw3OF+l0Q7rNuf4+RelSAgIUbVPsr1xEQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:00.2821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce755ce-4b76-4cc1-a6ec-08dcca8b283e 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: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR19MB7089 X-BESS-ID: 1725197823-102590-12635-7738-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.58.101 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYmhqZAVgZQ0CDFwCzZODHRMj kxJdUyxcDYPM0oydDc1DA1LdXI1CxFqTYWADykb05BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan19-197.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 Another preparation patch, as this function will be needed by fuse/dev.c and fuse/dev_uring.c. Signed-off-by: Bernd Schubert Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 9 --------- fs/fuse/fuse_dev_i.h | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 74cb9ae90052..9ac69fd2cead 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -32,15 +32,6 @@ MODULE_ALIAS("devname:fuse"); static struct kmem_cache *fuse_req_cachep; -static struct fuse_dev *fuse_get_dev(struct file *file) -{ - /* - * Lockless access is OK, because file->private data is set - * once during mount and is valid until the file is released. - */ - return READ_ONCE(file->private_data); -} - static void fuse_request_init(struct fuse_mount *fm, struct fuse_req *req) { INIT_LIST_HEAD(&req->list); diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 5a1b8a2775d8..b38e67b3f889 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -8,6 +8,15 @@ #include +static inline struct fuse_dev *fuse_get_dev(struct file *file) +{ + /* + * Lockless access is OK, because file->private data is set + * once during mount and is valid until the file is released. + */ + return READ_ONCE(file->private_data); +} + void fuse_dev_end_requests(struct list_head *head); #endif From patchwork Sun Sep 1 13:36:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786443 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 6B195158DB2; Sun, 1 Sep 2024 13:37:17 +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=1725197842; cv=fail; b=bPJQGlcg0JeSuhcCj4B2+91ik9OiGfgwDWP/bK8I+lPyHc3k3+KDMXslAGIITBCWqS4vexIOvJJjz4WQzDXkwlKDWxSSYE5SShEeACiOehxXep3031QJVdNNxkIZyiHmbqnNSr3MAv+JXqoSBUwPFUrRkf/dMS5OO4DPqIr9NRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197842; c=relaxed/simple; bh=3mCTEEHA68u9oTnOirv0IWKrlahncnp6c005tOkLWpY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hSSFvMBeZ6T3lb7akl16cl5YE1XiO7i+2oZOWhPURhAkP8NymKtS8SxQTKs06RVnFMESrwk+Y/FVP4maASTb0st8Nr7UmGwbX4F3CR1/6RNho0DDrQdz9ZJ6bVCQoAwqzfWKTHkXle7bLPsbcJG04uGymhl6WZPcbqGCN4w/8F0= 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=e1wAqozu; 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="e1wAqozu" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2048.outbound.protection.outlook.com [104.47.55.48]) by mx-outbound10-30.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Aqyt8GxaMSDceryuJX2ivs606CXGdGbfNH0YEMqeby8MpWBF3l8aO9PLGahYvqLEnl2w8pKcqIbS48S40+x8cW/lrR1tujcDV6iENSnU3CK1AYOLZCn5ubVymz2UumWQNYDCXn+0tag0b9twvkDxFzw8KhYXeovjKevAybUldizrfqYBwfDB2h88jANOjy/zgjE6URJBEBi/lMp92vZY3/0HBlefO3anJDAVOPS3rO6PzR0J/NtMsu6r/3wKiyjjtvmceWNo0BfVlQT+wUvi6sg/pa5FhvLqgoFpJ4+S86UK7O0HIwaxdMzGQGKiPsRK5uIRkV5Y6FUvUnwdbd8Kpw== 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=QqxCiT+OsF5fNZGoDOBZ6cH6vumq+2fSSzT/25hideM=; b=DixlW17VPie83vU6mIWSsGNTgKmWlVH27zPcbM8TdvICvOqsYKbk3bR7cr5WbPIE8dN/fV56b3333PVJmjqVNc9KhAy+0VhGE+EabGrJzjomTZU9mlYG0lulgx8/jvCMX8IWMLgqr8w9GXtSTV/h0/XAnPSCA5Z7+qFsMEn+7UE+Wskct/XA+HHOVSuOHt4qcbiRg7lh3w2L0BKWfAPopCC3ooB/EG6AT5OZJQb874PNTAOJ7eGt5YmGYe9nqeEgdg0JBgNya/5XWC4eYvWjebHjRTc2Owf3lyP9vCbI+biDZhPZFkeWgQE/nbwwS7WHHFq+4DiLaXlnGggzzVkKyA== 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=QqxCiT+OsF5fNZGoDOBZ6cH6vumq+2fSSzT/25hideM=; b=e1wAqozu27myqcrxPXILF92f9BxR944yNouO0Zs0YiDKxo0KGYE70AbR2bgLyFOJ582kb9n+Hq6/Vf2tHUW/9PHAZ+yfotvBd3/uf4um8BZL9lTdMHG0gqqIdyDD206D5z6BcokIqQiRa++8+C6jUKzEssBBC+PQtc/2pGOsfrM= Received: from MW4P221CA0017.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::22) by CO6PR19MB5356.namprd19.prod.outlook.com (2603:10b6:303:147::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Sun, 1 Sep 2024 13:37:01 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:303:8b:cafe::bf) by MW4P221CA0017.outlook.office365.com (2603:10b6:303:8b::22) 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:01 +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 MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) 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:01 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 95951D0; Sun, 1 Sep 2024 13:37:00 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:36:57 +0200 Subject: [PATCH RFC v3 03/17] fuse: Move request bits Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-3-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=1214; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=3mCTEEHA68u9oTnOirv0IWKrlahncnp6c005tOkLWpY=; b=rumk+d/5/shsGZ+z3AwG94byRgiTSP+pfup293w+WYCeKc5Zj6JV8uV6oaeTBkv/JnuWEe+Mh jI4YZ1A6wGnB6CD3JOSTaa+gtaDb4m2zcFH5AmbNzAxeaqGoW1E8707 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|CO6PR19MB5356:EE_ X-MS-Office365-Filtering-Correlation-Id: 1780a3f7-42f4-47ee-c4e9-08dcca8b28d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?e0tpOP+T/rTgyWWZ6dQ26VvlxnjriBk?= =?utf-8?q?a5gj+DlryOGncP6g+DZkc3rukNjkLs5N0lbQul3Eid+qlTuLPfNZibou252qHa0u4?= =?utf-8?q?urNK0NuG59wTS0+IfxVcqmz0G9Ok57/E/tPlYtb+BxHjtnwb6RcBcOgGtH9B+FS4f?= =?utf-8?q?LM3J+OXUVUjwEwPOCo71vDRifyJwWdPaCxDoHsZbFkMya0XSHWMh62NQF6Cx126wH?= =?utf-8?q?FbwCe0dKAKViDb5uV9130cXySD2ZCywDQCmNddrrQ9WFk4hA8pC/pR0F+HHnSX+o7?= =?utf-8?q?CDrCa2/T04Bv7CgvAo/BqaMTT9K7Zbp886MySk8nkVKVqvQ2gG8BlISOm6cwLY9MY?= =?utf-8?q?YIXADZVIZcegdqXU4don/aFFVM1kaWNVNhxosONVYhkXSqG1ErX5JTwF5egFN9Smo?= =?utf-8?q?B0EYdBVXkCtWrGG1EUkzcFnB7Ks3jCx6d5JtuLNmcJS58b6gX1jMN/HBUdY77ImqD?= =?utf-8?q?GUf/Wt7ind9OcdS5nW7oRB0GRbDVGdL9q75yuGLvyQNTV+LKnJuxGOMerEtVvaPHO?= =?utf-8?q?93og/lMu4b7tqZ1Uq9a5PXkVZpy621WJ/ApiSs+TUHnAdfDHaPVmFqvbAzKEWPLgN?= =?utf-8?q?EIlJbY9j84kjxr9DJm3fLKX1/bvW1j9+yUtYVPF6AXD3HwOipRpuwvLPgPJDZJx3j?= =?utf-8?q?19jY/QgE6MfUaEAPxGNNed2vDGfrEWb3Hkov+W6t4lpZKhJZDGaMOiUCI8thvuNVC?= =?utf-8?q?2SjHha/PXos6KBGJI8W4RdPIGyUxpzS7lrpoLzxAxC87CcT+Ld03R8TTWIjUl7WCn?= =?utf-8?q?miq2VAGWWmFqlr3M7VocgBEpw1/KbuIHj9BU+Mqrlb4XCS8pc2Y8ZxisiIq0PCJZs?= =?utf-8?q?da1E00OYxXBBbHhe0CA7teOpmGH+NQURfJ3b9l0twdZAAzbGOjC4OZYytziXrO8g0?= =?utf-8?q?7WZI183NCTeadKUiQ2cX7C7RZpni+XKURTxat7pePFMHkJuK9LD9jODu6DKE/BJS2?= =?utf-8?q?3XhBC7ElsCrqP1YXf7O44WVUn2i14kCkn1SUNPQzikrxv+pPtc1yKhv5rR3np+11i?= =?utf-8?q?b438D0REX60J9eTs+JcmpYxkjzF/3pi57GyDG8H6VhM7m97yv/hJh8JrTF/IBWtaj?= =?utf-8?q?8sSgtxlL8sr7fS+yLaaEX+tmFob6aMcQSqKLtjfriQCIljzXJxuzv07fYuFP75khm?= =?utf-8?q?+zXm0i9o8ePIV81KmmmQc+abk+r5aDmMIlZoONSuNNdabOka/WMGXe513Rodnyj9p?= =?utf-8?q?0R+sQJRZtHZVQHy3kBXI00U9lgPBFJYPMAzAx2IbRKP7paLh6BaV6RDMfvbOS/dcV?= =?utf-8?q?BB5OnFvBaKJQJOnq1G75flCfa+MSIQxZ3NuR8UpxM/nPPC/TFgYJzhAxAKtBXcbiY?= =?utf-8?q?ClcSayBfIr+eNRJEfZar4XYJb+XYhyXpLgFjEzbNzZeQFui23YV8Tt0MkxQ9pzV4N?= =?utf-8?q?TAhkrqAgQbV?= 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)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hycbEm6uUNAiXOuOsrVva1BcEmcp1mpVCkLRe2aNtgCQH2kWQPnzl/n7LF+I69GpjaDaJPT2HvZGmab74MwtFeRdrveCWkfr1GHJVgR5NpvgrSCieANIhkNzad3My5h6EjgkG3c+GCk5lQ65fjWSK8iHg6nOzbzaoooECFIoOabKEudJpyMF2XTTLuC4oNlF1c5ceXQsUcR3UyRAodaZ31BQqX33FN0GOKHf1F/NDPjuWRgNAGuMLU/kzuqcP2izo4Q8fh2Dozfw7jmTZG+jPPdBxiC7wU+EcOBSg9fZglQpYupXE7NT+E6wZQ7Hj9dkXyenutgv9KZaVS3T/CXL13e0cD9iCjk8kqDEwjjzPntwJADMXDQBeeaRxi/8GaUWjc+spwMYxFMT+vukF3juYPb7GeTzo2DjI6ZFQh+r8XYW9iJgTlhXyAW8K0ZFYs3M2m3gFQpfrejNTkC4P4ITHoFQIyqrAsRqrR6sDdC2ggz1ORDd7xbzBjWeQ9q3VbrIYWkYCbBGKdoSYYynBRrvGWG2c1G1MhBkmoqQeNBpoH6/M3TKDuRKAtGmjeMGTdTciQFsH0swWZfrmQg61jWRV6LaPG5CaTaioJLrWkafiXwMCD+A0R3KeMms2ZMWKlHMKqZO9WkdUu2akOeQjCgvXQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:01.2865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1780a3f7-42f4-47ee-c4e9-08dcca8b28d0 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: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR19MB5356 X-BESS-ID: 1725197824-102590-12630-7736-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.55.48 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaG5sZAVgZQ0CTJwtDMwCTZLD XFICnN2MLUKCU1MTXJPCXNIs3SINlCqTYWACZ/iBJBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan10-236.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 These are needed by dev_uring functions as well Signed-off-by: Bernd Schubert Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 4 ---- fs/fuse/fuse_dev_i.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9ac69fd2cead..dbc222f9b0f0 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -26,10 +26,6 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR); MODULE_ALIAS("devname:fuse"); -/* Ordinary requests have even IDs, while interrupts IDs are odd */ -#define FUSE_INT_REQ_BIT (1ULL << 0) -#define FUSE_REQ_ID_STEP (1ULL << 1) - static struct kmem_cache *fuse_req_cachep; static void fuse_request_init(struct fuse_mount *fm, struct fuse_req *req) diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index b38e67b3f889..6c506f040d5f 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -8,6 +8,10 @@ #include +/* Ordinary requests have even IDs, while interrupts IDs are odd */ +#define FUSE_INT_REQ_BIT (1ULL << 0) +#define FUSE_REQ_ID_STEP (1ULL << 1) + static inline struct fuse_dev *fuse_get_dev(struct file *file) { /* From patchwork Sun Sep 1 13:36:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786440 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 4474A14F9F1; Sun, 1 Sep 2024 13:37:15 +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=1725197839; cv=fail; b=GpoCAKabNk2ht85hgt9jGk60WLQs4DJzuMxE67NcLWpOzGhqYBtLTTKbbnhZDgn5AksHqvHJDj7ckrDYfFu7cfYiaR3uoiioursOSzfJU/2VV8HGdv1R5lFUDy3hrsmsf/7FNOV+rOBiWWYfe4l64HDiIPSWqlUUz2THSCwNTew= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197839; c=relaxed/simple; bh=uLVuRbDRdNskIgEn+OHh8ksb7ZOBJ99vCuhAK7xxins=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s7x0X6d4xqUdcbU82qayxJlnobCD0cZ2gsNK1XcLtz0wQhzuL6jWZUCZF66tDbMo8qaZ1UQY5J5uVePsJ/diOyzvFUPTdBJZcSrZvXEEKnITYvRN3Ah4PaIQHeN4Aq3GdUjyHuFbAvOfJFcSGNj/XzBhRVvPVfx7w9krtETb9EM= 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=gKqcM3Cr; 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="gKqcM3Cr" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) 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:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BQiy/MiO2xn+kHLULsbE3OIq9Rp5V8PFusgpxZ9QUlMEhEMqxScgutPsShz4D9BXejdLNYyc6uqMv835qd5EksFnOFdIfEEP3fpphHzPv58gK2orw0vQh3gow4V1HGyo7oxBcPAGgiJsu3/u1xzub+7HnFeYNcY9haVuOYHcXv8rO6o5K9HPUHvBn9BuevzFHF/KLb4g3SVWSdbq9Km78WdCBf6qJI/Z7kxm8l2+FyP/nlzloxeQh8/YqjB64aqKQboETbi1xxzq35HZ4UvmBnuh5FFtF2PwSKcO9FMY9jgcttXtfRJN02EodXlU0LivF5AkJiaYMvSHsOiaGgECDQ== 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=WkCkFVmj73WwUKv/B6JEhehEIp/wAG43uxDCFspdcvE=; b=UFMRAoa6Djh8eey2Lj00Vo9CZ1qY40iD8wZWJuWmEKPoZW5X2gKx88OYk549tz1jVPHPL3SizxszQgjbSUWsXyEmgiEZpUUAklITCv3x/x0dP2vFE1wrLtY/GCiWhVtYDRl6cUOFOIUTF5SDkQNnAN2yKdL7qEunB5bE0A/5PVGmlgD6rdzB0aj3oVzdQ5Cyif+OwCo6dFBhLD17vR/gsJ0XoMyxtMZIy1abrJ/V/Syl4LSczmdasMvPRMe9q07jpwWGCSoBfrz4BBwS5YF5nTbT3t1Ql2R3OzL9Aas9JxUTi/BWwyEiDsxtZk9fJ3U0xRMTAz/J+a4XT9+Ukbbw3g== 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=WkCkFVmj73WwUKv/B6JEhehEIp/wAG43uxDCFspdcvE=; b=gKqcM3CrkYXkYZKj48EInK7nbKyaLvIW81+nnuxUbHTc+v2m1BKAU9jU1/RXuqFSQVgLw6RLgZA8ilddYmB4e8tAOdSDg34CEHBX1lKqOSA2+x4+tS0KzeyytrCzlUc6bc+O/hWntKsW2S1VxjqDK63FH+fqWzYcFEe8hCL6zpo= Received: from SA9PR13CA0012.namprd13.prod.outlook.com (2603:10b6:806:21::17) by PH0PR19MB7426.namprd19.prod.outlook.com (2603:10b6:510:28a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:02 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:21:cafe::51) by SA9PR13CA0012.outlook.office365.com (2603:10b6:806:21::17) 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:02 +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 SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) 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:02 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 8E43C72; Sun, 1 Sep 2024 13:37:01 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:36:58 +0200 Subject: [PATCH RFC v3 04/17] fuse: Add fuse-io-uring design documentation Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-4-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=5011; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=uLVuRbDRdNskIgEn+OHh8ksb7ZOBJ99vCuhAK7xxins=; b=MHP0dubGPSk/WDuH10OFmqwWHyPFvR7vxYkfnOzhHjQy38Xe7ivqY+5ysYgyg7HytV3xdFVJG P6r8A/fG7HbDNKYUR0IUyD3pUMMqJPOGj37c9oBxOURIfIDFnQ7HzIY X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|PH0PR19MB7426:EE_ X-MS-Office365-Filtering-Correlation-Id: 456ce1a7-a28a-4e86-b56b-08dcca8b2950 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?xKJNvKsh7UebjqHtLFM0n4lEbVxXkeH?= =?utf-8?q?o5mmC3czGdEtN9UPj7zcF9Xyhs5gxHFE/9d3xfj+3nf1iKzmD8E07mm7iCifV8izf?= =?utf-8?q?V922gfRourlCLnKN9fr4f9vEsQIg/MxuDr+TtdIOJNDoOzqJ0f0R0vESOzog3Ptgb?= =?utf-8?q?CTCXwtKj7OBfJT19XkSmlngvJGanWHKtg81GrZa743FPdAmt0/1ITzXXIBt0bOrOv?= =?utf-8?q?9181EqXDxrFLcdSYydDtxXyq+X2NvM6tdoB6E6eAARZXEFnvcZSI/K7C7TdfLZP8+?= =?utf-8?q?947DYVtXSpQUGtKc/0WvLagfeoKMR5BVVGmZp7oNg86PVtxJtsOES0xd7CvTAPh6E?= =?utf-8?q?x2JyzyHqkNhfQkdv3adVmv8y0okmPYG1mBzkENR4i/tvcoqufHSWJFasZNOQKf40/?= =?utf-8?q?uvwc9PbqqoH4hYJFnAXf6Og+u5K8UVZsAZOlhlpMFZm5cpJHp+i76c6nyinzrCiSz?= =?utf-8?q?TJd4Xk9FXuQj8ZwA2Z6f7bFlFrIAgAJGCvOESupVTiIswHaEkVNiRlMbGHUhYb8iU?= =?utf-8?q?kwKJDAAWe3j5TopfBuasx+UKKGpyDrmAbFen3Ujcbbzv4nq7L6WJf6/0wuO/ooqGK?= =?utf-8?q?l6TpmtY5IjNG5ca4aLURW6zHzZIcYajNFFSfoutdH5aroveDhklkKHAq3z9wVZ1Gg?= =?utf-8?q?ujJaP1v2HMJ+qXaG2h6LIdmrkL+9XwgpAvnJHHSJvaS9EaI50rNvTUw/GvtwpLPMD?= =?utf-8?q?W792d6zstZDGz1FSceKA0E4b9fw8+RKV3bSWUBiEYWggjfML6AccR4Qq7g34gDxGp?= =?utf-8?q?ZQsuNOKMxFyIo3oV6+hRNyYl3T5UxfGhqY5ipaQ0hpRaAoJQE92MJjLRuWGhT5kSU?= =?utf-8?q?sP6cSvpSmJ6yYsm/CY4OsOmQ4tkMepV1NX1oZu5JFO6z8oJeRAseJLM+ajbQfshZ7?= =?utf-8?q?24exMwahc4iVtqFhUThXmiqEiv9+5a6eEyvHqj2dXBtzPg1yLhYUBrldCIm4RVNSw?= =?utf-8?q?vAg829dVHoKv96KFMwTkEu3WEhFnZp31c7vYMLSrai8E+13vzqmz7epYFr65cTOkW?= =?utf-8?q?pVH4MSAL8RbNFKNsc2LM7ceUdw2gs/PxtedCjHY+4DXjPsYf4UKdGr1+HxrHoI/i+?= =?utf-8?q?ieMIjEA0TsW7V1xtHKaMjQAS4DKYPQ78ziOVApvTEWuFSYZLK6k6arAA7pvxfFCCw?= =?utf-8?q?8jFrXZ4HKrt2trD29ageLx+vFcpzUITooYoZMaAZ4E8WxZVILOYC78mNZLf4x9fpf?= =?utf-8?q?rvsk1sbejdL8fgdQ2SL5/OItLWGXy58C41OJagxWzE8D3XwpwbFiZ41T1ENdFL12l?= =?utf-8?q?VVvanEn0MIj7VBUoifnsiWcZfp6C1giEd1SHLCwYD7lg/e3kXjmLTCYmiwwAsHyHH?= =?utf-8?q?QmSHOMwLRA9px5BwxMnbeA7wcLH9fYMQ+dxkjORLJ344H8TO2K5rdxJoPq5d/jkpW?= =?utf-8?q?HfWaYWsDyeT?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 69oQE6ibkMf4ZE/B/maCfgRnmZtCTTvdlvIHr+LFiobNhSVPuBE2ofk1CTsL71gnGllG2ppl0oPWEApn+ntm68USYHb4atE9JpMLvBq/LL5CuCG0inaxRrPkZl4IiRsM7g4DFQAwtI3pFxdqftV6HonMLwUSDkAo/45RobH2ldVNBP20IYhjcnwFezv+cgXff1YjFUjIyLqBo4aLQ7TMltk69jeiJ4ZXglWjN/nl4HIqoQ4N9B/xz5vg+dC1h0GYmh1DG5PkdiWS0BfRNH1r0YBIJxf1ZDusIeW/9JrO4ZZBaYCsO3RlpaHETS948jMX1UDFTq1NVCd5Z04ZCnH/Z3iTbnST3lMqHh3XmopdC+V8dw6OXcLO38W2ULbUtWJcoczEhl4ZYHPrSkYGKIdK36i1EWbBVcUYf3pXx7IZIxCfnV8Wjo+2Vv+p09DneDIWhULu2LnuwtfQDvhBfzjHZGR7zuymeZb1UNpTjeskRZcMoRTKzPtISRFIUDEtgGk9+LBsbeIjvYcqNn1amoWhryWmN4Mk7kT5tXGzlwWGBRe7B097EbE4/GecO5qbjsAWbesXkWta3dNr0s9qnLz/dXDxNVzPVtWxTDmsZrOfR1/HsJnawwGQ1nJip9XtcFFNvR55VwrwlgOlGBb6Q5ibPw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:02.1250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 456ce1a7-a28a-4e86-b56b-08dcca8b2950 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: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR19MB7426 X-BESS-ID: 1725197825-111878-25435-67287-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.57.171 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYWlgZAVgZQMNHEwNIyMdXIzN g8xdQ00SLFODnJ0ijJ3CItOTHFIslAqTYWAEqm3Q9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan11-219.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 Signed-off-by: Bernd Schubert --- Documentation/filesystems/fuse-io-uring.rst | 108 ++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/Documentation/filesystems/fuse-io-uring.rst b/Documentation/filesystems/fuse-io-uring.rst new file mode 100644 index 000000000000..0f1e8bb7eca6 --- /dev/null +++ b/Documentation/filesystems/fuse-io-uring.rst @@ -0,0 +1,108 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=============================== +FUSE Uring design documentation +============================== + +This documentation covers basic details how the fuse +kernel/userspace communication through uring is configured +and works. For generic details about FUSE see fuse.rst. + +This document also covers the current interface, which is +still in development and might change. + +Limitations +=========== +As of now not all requests types are supported through uring, userspace +is required to also handle requests through /dev/fuse after +uring setup is complete. Specifically notifications (initiated from +the daemon side) and interrupts. + +Fuse uring configuration +======================== + +Fuse kernel requests are queued through the classical /dev/fuse +read/write interface - until uring setup is complete. + +In order to set up fuse-over-io-uring userspace has to send a ring initiation +and configuration ioctl(FUSE_DEV_IOC_URING_CFG) and then per queue +the FUSE_DEV_IOC_URING_QUEUE_CFG. The latter will is mostly indentical +with FUSE_DEV_IOC_CLONE, but also contains the qid. + +Kernel - userspace interface using uring +======================================== + +After queue ioctl setup userspace submits +SQEs (opcode = IORING_OP_URING_CMD) in order to fetch +fuse requests. Initial submit is with the sub command +FUSE_URING_REQ_FETCH, which will just register entries +to be available in the kernel. + +Once all entries for all queues are submitted, kernel starts +to enqueue to ring queues. +Userspace handles the CQE/fuse-request and submits the result as +subcommand FUSE_URING_REQ_COMMIT_AND_FETCH - kernel completes +the requests and also marks the entry available again. If there are +pending requests waiting the request will be immediately submitted +to the daemon again. + +Initial SQE +----------- + + | | FUSE filesystem daemon + | | + | | >io_uring_submit() + | | IORING_OP_URING_CMD / + | | FUSE_URING_REQ_FETCH + | | [wait cqe] + | | >io_uring_wait_cqe() or + | | >io_uring_submit_and_wait() + | | + | >fuse_uring_cmd() | + | >fuse_uring_fetch() | + | >fuse_uring_ent_release() | + + +Sending requests with CQEs +-------------------------- + + | | FUSE filesystem daemon + | | [waiting for CQEs] + | "rm /mnt/fuse/file" | + | | + | >sys_unlink() | + | >fuse_unlink() | + | [allocate request] | + | >__fuse_request_send() | + | ... | + | >fuse_uring_queue_fuse_req | + | [queue request on fg or | + | bg queue] | + | >fuse_uring_assign_ring_entry() | + | >fuse_uring_send_to_ring() | + | >fuse_uring_copy_to_ring() | + | >io_uring_cmd_done() | + | >request_wait_answer() | + | [sleep on req->waitq] | + | | [receives and handles CQE] + | | [submit result and fetch next] + | | >io_uring_submit() + | | IORING_OP_URING_CMD/ + | | FUSE_URING_REQ_COMMIT_AND_FETCH + | >fuse_uring_cmd() | + | >fuse_uring_commit_and_release() | + | >fuse_uring_copy_from_ring() | + | [ copy the result to the fuse req] | + | >fuse_uring_req_end_and_get_next() | + | >fuse_request_end() | + | [wake up req->waitq] | + | >fuse_uring_ent_release_and_fetch()| + | [wait or handle next req] | + | | + | | + | [req->waitq woken up] | + | X-Patchwork-Id: 13786444 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 BA17617E009; Sun, 1 Sep 2024 13:37:18 +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=1725197842; cv=fail; b=tZXwS1T2ZmL3L4fqknp69sE0vNt1MiUEYBp3iFlZJcX4qBtYHjxWyqEAWH2aB64UgF9XCJd83SjB6j6/8qb49e91OLKXlWiazPiRyjG/3nf/jyFPXE3frwioTiAKQC8DLKlBA8pVrMxIjvZdZQ4bWY83O6VUyGHFslpBt7eDdOY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197842; c=relaxed/simple; bh=w3I2I81oijYHRhDrNbBhBfrVu52q84THeahpP/fjLaQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ID8Ehun4RXkDqRJhV5eBYFtLNnAkagLMiKP3l1mCenSLVg9K3dwm0fsK1csbp891Jnc19HknOhiwp0JZ4GgNu5f/J9BHvb5Cgx6J5DNZ4Mu+9ATznVbwOftrMWY44+77y/aWVoDXfC/LOL9juPOq0uApvZeLV/w0xUTDSry1IUU= 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=Bgpmkght; 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="Bgpmkght" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by mx-outbound40-32.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:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=frQBPn/QjogOqGLNPfk8PveN1SJXS+URZDKnl+XlE7UgoPJ6gl3tHloqSe2O95M2MGB0CXI+UI+l+SMWq2yDDg6F5P0uYTW1NhYWhdn3Z36wO2soT9ar++bJ3GeltozNi/nBay4h8nhsYS+chYVSQsRz7xGOf7yJ6V9Bb02LLQ3XhITpjtUpteGRVOiBf2BX3iFnUoqBEkfAY/wlWZv3yEBy8u18q6SJyZMSbiUpKJz9I8gSyiw+lnl+Ac44Ayh8xDUE5iC3re77dtdcPHNd4Ge8h5AFvOlVr5Frgdebu72t8mSF0jbkURkZeNXqenJslXOm/FnVeNXPY6EKwBW0OA== 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=T6q5S1PNJl48cu+U85QaUzCSaX5qozR8G53hTnF9P3g=; b=trVFwdnYM0ezKrMom4Wc8il/dmmmL/L4PaFMAG4nQoS8oXXzSRcQiRb/VKaeg5XTf5M7ZYyrkoBrPW283CyxdHOYAVyVnN83xnbohscnv9CMmWbxTHeh11ggZZTF4EPrfo9SHLDcpC+z+Fl67zOBXNGYtA718v3qo+ML8lHwsTNO7WnXPSbj4dhsCbx3sURVgXI8xSXNFZDwrKLNFdSMfDjDGvQ8KaAHq8c7y+Ae9WPW+mp8OcAdPGO62XuW0nRSGBnZD7oTffqSukcuJzwzYcVwtA4pjm4eRY4WGV0Mw88tefUjPpmlIU8mzD0mQnHBzs4qlrBpCdzgtfAjMrFLCw== 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=T6q5S1PNJl48cu+U85QaUzCSaX5qozR8G53hTnF9P3g=; b=BgpmkghtlUB5ZM5KzImu91OTxYb8tRU2fqHwQO6jSmrk5UDHl5abKmgG0DvBItsDP/Xn09+FAHotYNTXE7t2d5eRZw0zcXWwyIX7MzhiuLy6VpyDCXSUoELPMu27UniO4FaYKU2RN+1/JMIzK2V8u7YCBm3WbDwJYKoBNrPTHUE= Received: from SJ0PR05CA0102.namprd05.prod.outlook.com (2603:10b6:a03:334::17) by SA3PR19MB7745.namprd19.prod.outlook.com (2603:10b6:806:2f9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:05 +0000 Received: from CO1PEPF000075F2.namprd03.prod.outlook.com (2603:10b6:a03:334:cafe::68) by SJ0PR05CA0102.outlook.office365.com (2603:10b6:a03:334::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24 via Frontend Transport; Sun, 1 Sep 2024 13:37:04 +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 CO1PEPF000075F2.mail.protection.outlook.com (10.167.249.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:04 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 867E5D0; Sun, 1 Sep 2024 13:37:02 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:36:59 +0200 Subject: [PATCH RFC v3 05/17] fuse: Add a uring config ioctl Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-5-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=13754; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=w3I2I81oijYHRhDrNbBhBfrVu52q84THeahpP/fjLaQ=; b=/K8gosAsXvI7UaDTjoC9nRznWvvKbvhrobM5fPl3mMhvYllgyItXheW4y97lmXnDf4MiSqD3Z icz4wi0TwXLCoQeveqqBWSBNBx9M4nW1L3T6AQ6bX4KVMcmHaPuCiD0 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F2:EE_|SA3PR19MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: c1eaa820-f106-4d04-af00-08dcca8b2a9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hQ8OpIs2Cc7fza2g3vPbJxDvWWXLD5w?= =?utf-8?q?nOYqc3iivx9IlVPRIMDsBSTAvssqErovK7whmPXEvq0RUpBsOc6HfQE+yXS59TpPq?= =?utf-8?q?DJwv6Kv8/2S/fFK/QBWE/lNCMwzb/Utzh+dcXU93r5ke+ZAcUdlUi0YP58npKNykF?= =?utf-8?q?PZWis0SHuaj7bVHWma/Qu0Lncbgbg/dwySLjWTbBX/hX9EUaE/cow96av/SRlpHaK?= =?utf-8?q?RKOjsfQV1PSmZwvI4ZmNwTbqHCyKjG3/UHT9JzgmElB8EZ0fEUypMrQvejFQtyXmC?= =?utf-8?q?3RAX7hBFYrnkSdweW3LOTsaHHci2p/cEfn7mre4ViHj1ASWUpjbWSXdhiER8N1b32?= =?utf-8?q?5/kY4sR4S8WocBUB+S+mDGCNjO5zHgP5KxI8mQB3DzDalBpeKHsq1K2gEqXBYd8T6?= =?utf-8?q?B6xOgkZmMhgfwVv57FRHKsOj/mdS45Vj0hH8wIItBW7pGS1dsDYn3jV7V7NZWlzql?= =?utf-8?q?4TC6CYjnHWqBb0pg5N+/YnvvPtkVmTbHXK6bSvl4nk0LmlJkr5/VVvtfZEnbEl1+l?= =?utf-8?q?K3ojEGZ7nlbFILSVpWRWT4uA+GItHgtAeoCbDcUy7ayF+XHb90uvN213FiW+jePPx?= =?utf-8?q?/VL2PdrejmpIOianLLRIrHOIfDvpqIGVwmt5wGXFS+iQ1EW6d49wHqJWhv5lO7Ovb?= =?utf-8?q?YGBTmR2nfUuZ3QLU4+V1s5KQQjKJEDlW6VjErEGtFGWO/2ndmYZNViMlkb+htdts3?= =?utf-8?q?e9AP/K6ZMOHiQj/96vkb0xyIevYQKFd2qsGYPIoZKpPmiGBETpKmAZcnqH+dr8ucO?= =?utf-8?q?IzW66P/L9bE9mhzCIOcglWVdpH8L0PxVCDGPD1FQpuaRwYkUZDbTcPn/vEEYRqOdK?= =?utf-8?q?Bqr2Ns8t1wWEOeSO3qayyAqsN7ez7nmrBExISJ10/9hpNi+csW2lnNCzE3DEU6Xm9?= =?utf-8?q?K8JePoEp8iQpICnPXpKhZfk1iDHYlN2AtTzYiKCoP+1RgRs5exQoHMxkReACmfdDs?= =?utf-8?q?j+LHmXKj10F+pw4QnYN+SFwbte3VLMYES46OMSLrkJB/n3LXeUMXvA0gW6Y8T8byF?= =?utf-8?q?Q426ZFbLAqfe+afFX5O0kAW8CXqUWF3xcGKiPR2tFxh+uiGj1kfwvvQcsE+1I1mNv?= =?utf-8?q?UrVYzBDVxN7DpCSrGCvfZRsT3tMamcSrarJHE9/mkDA4brg+FDUpdZjsB5jIeSprc?= =?utf-8?q?UPtdAUCKGktpFjkWEaCFrePevyRdE8x7OHP/MlEt8lxPyg7XDosb2od89Cxj83D9w?= =?utf-8?q?+oOecNQbuW5qcwH+xz/JG7eS8aAttf+fKjpaPawujp3P65iJgGhhUkhFtDVV5iEEc?= =?utf-8?q?lgYvhtaeBHieK2iTUsrbYnCWR4TY8W1jIgDqFqZ7iGcWhYjdkRqhJ/tX+KLp4NBZN?= =?utf-8?q?EMqIWK69dfkog9tdOMGH9hvgVKSxqdezE4aHC0AxxqdoqVdwdQTdp8bEQi0QKAhY6?= =?utf-8?q?TcUx9UnA7fD?= 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)(1800799024)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2i//iVNPFLzMfJWz/EHZ8ZoBeyJS/SUIcjFFPFdSWNBxfIFGR1+zGmOlZaH0uHgKCuhpkKl8VdBYNiYyj+wmXknWFDLolBGyroGW5A94AooDhU57egWQY2tVr+tCA2qDhzUT6790HrJuRuNyc3u6wLf1hREemKH1raAozErnWxF2HWLYFZc9QCiFfYTpQ1sDn40/4I08iO9dYUMtIIZqn9xNrrrkPLCMKqxSX/JapnWRkuEho+xJjQU8rxkzutw7uZJNgdEV2BqYR1RdbgQgwn5V3i5Y1bJ2wkv+p8kTBz945V9tXfXyfq5MOxoqxIy2Z1h4h1i0lq/glsYThAtOY52tfl7ptL89N+U5RfB0jz0GyJmErWBI4nxE4fsPn4NDBr27CmmmN2FV3aR+vxaZYrQfJKFwvJzqaoY7APHwgi95N7nludDqUdz5LR5io52BzdwKEK9dT/n7Hy0Pv0mE+l+Gq9rwrLpAwZqa/I4frOcQBpTadPeo6Po7Pm0B4FMGHLN6hzliOBrl7yL53FqEAc3h06A23ZmOYMcNBqKbRG6fgfXjbg6c2Oykb9WI6lJHGNrJ5yXLD3VnlBWY+SicYw2WXT/2jvH33CgZ7ejXsxg/UcgPblaM+a1h67Jrg/oLxyHXkFGvyCflMQJ0h2THNw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:04.3072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1eaa820-f106-4d04-af00-08dcca8b2a9d 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: CO1PEPF000075F2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR19MB7745 X-BESS-ID: 1725197828-110272-12687-2086-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.55.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGRsYmQGYGUDQ1yTzV2MwkzS I1JdXQ1DLVPMnEyMwkOcnIyNDY1DDNUKk2FgAk3zLWQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan17-160.us-east-2b.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 This only adds the initial ioctl for basic fuse-uring initialization. More ioctl types will be added later to initialize queues. This also adds data structures needed or initialized by the ioctl command and that will be used later. Signed-off-by: Bernd Schubert --- fs/fuse/Kconfig | 12 ++++ fs/fuse/Makefile | 1 + fs/fuse/dev.c | 33 ++++++++--- fs/fuse/dev_uring.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 113 +++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_dev_i.h | 1 + fs/fuse/fuse_i.h | 5 ++ fs/fuse/inode.c | 3 + include/uapi/linux/fuse.h | 47 ++++++++++++++++ 9 files changed, 349 insertions(+), 7 deletions(-) diff --git a/fs/fuse/Kconfig b/fs/fuse/Kconfig index 8674dbfbe59d..11f37cefc94b 100644 --- a/fs/fuse/Kconfig +++ b/fs/fuse/Kconfig @@ -63,3 +63,15 @@ config FUSE_PASSTHROUGH to be performed directly on a backing file. If you want to allow passthrough operations, answer Y. + +config FUSE_IO_URING + bool "FUSE communication over io-uring" + default y + depends on FUSE_FS + depends on IO_URING + help + This allows sending FUSE requests over the IO uring interface and + also adds request core affinity. + + If you want to allow fuse server/client communication through io-uring, + answer Y diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile index 6e0228c6d0cb..7193a14374fd 100644 --- a/fs/fuse/Makefile +++ b/fs/fuse/Makefile @@ -11,5 +11,6 @@ fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o fuse-y += iomode.o fuse-$(CONFIG_FUSE_DAX) += dax.o fuse-$(CONFIG_FUSE_PASSTHROUGH) += passthrough.o +fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o virtiofs-y := virtio_fs.o diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index dbc222f9b0f0..6489179e7260 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -8,6 +8,7 @@ #include "fuse_i.h" #include "fuse_dev_i.h" +#include "dev_uring_i.h" #include #include @@ -26,6 +27,13 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR); MODULE_ALIAS("devname:fuse"); +#ifdef CONFIG_FUSE_IO_URING +static bool __read_mostly enable_uring; +module_param(enable_uring, bool, 0644); +MODULE_PARM_DESC(enable_uring, + "Enable uring userspace communication through uring."); +#endif + static struct kmem_cache *fuse_req_cachep; static void fuse_request_init(struct fuse_mount *fm, struct fuse_req *req) @@ -2298,16 +2306,12 @@ static int fuse_device_clone(struct fuse_conn *fc, struct file *new) return 0; } -static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) +static long _fuse_dev_ioctl_clone(struct file *file, int oldfd) { int res; - int oldfd; struct fuse_dev *fud = NULL; struct fd f; - if (get_user(oldfd, argp)) - return -EFAULT; - f = fdget(oldfd); if (!f.file) return -EINVAL; @@ -2330,6 +2334,16 @@ static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) return res; } +static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) +{ + int oldfd; + + if (get_user(oldfd, argp)) + return -EFAULT; + + return _fuse_dev_ioctl_clone(file, oldfd); +} + static long fuse_dev_ioctl_backing_open(struct file *file, struct fuse_backing_map __user *argp) { @@ -2365,8 +2379,9 @@ static long fuse_dev_ioctl_backing_close(struct file *file, __u32 __user *argp) return fuse_backing_close(fud->fc, backing_id); } -static long fuse_dev_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) +static long +fuse_dev_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { void __user *argp = (void __user *)arg; @@ -2380,6 +2395,10 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, case FUSE_DEV_IOC_BACKING_CLOSE: return fuse_dev_ioctl_backing_close(file, argp); +#ifdef CONFIG_FUSE_IO_URING + case FUSE_DEV_IOC_URING_CFG: + return fuse_uring_conn_cfg(file, argp); +#endif default: return -ENOTTY; } diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c new file mode 100644 index 000000000000..4e7518ef6527 --- /dev/null +++ b/fs/fuse/dev_uring.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FUSE: Filesystem in Userspace + * Copyright (c) 2023-2024 DataDirect Networks. + */ + +#include "fuse_dev_i.h" +#include "fuse_i.h" +#include "dev_uring_i.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, + struct fuse_ring *ring) +{ + int tag; + + queue->qid = qid; + queue->ring = ring; + + for (tag = 0; tag < ring->queue_depth; tag++) { + struct fuse_ring_ent *ent = &queue->ring_ent[tag]; + + ent->queue = queue; + ent->tag = tag; + } +} + +static int _fuse_uring_conn_cfg(struct fuse_ring_config *rcfg, + struct fuse_conn *fc, struct fuse_ring *ring, + size_t queue_sz) +{ + ring->numa_aware = rcfg->numa_aware; + ring->nr_queues = rcfg->nr_queues; + ring->per_core_queue = rcfg->nr_queues > 1; + + ring->max_nr_sync = rcfg->sync_queue_depth; + ring->max_nr_async = rcfg->async_queue_depth; + ring->queue_depth = ring->max_nr_sync + ring->max_nr_async; + + ring->req_buf_sz = rcfg->user_req_buf_sz; + + ring->queue_size = queue_sz; + + fc->ring = ring; + ring->fc = fc; + + return 0; +} + +static int fuse_uring_cfg_sanity(struct fuse_ring_config *rcfg) +{ + if (rcfg->nr_queues == 0) { + pr_info("zero number of queues is invalid.\n"); + return -EINVAL; + } + + if (rcfg->nr_queues > 1 && rcfg->nr_queues != num_present_cpus()) { + pr_info("nr-queues (%d) does not match nr-cores (%d).\n", + rcfg->nr_queues, num_present_cpus()); + return -EINVAL; + } + + return 0; +} + +/* + * Basic ring setup for this connection based on the provided configuration + */ +int fuse_uring_conn_cfg(struct file *file, void __user *argp) +{ + struct fuse_ring_config rcfg; + int res; + struct fuse_dev *fud; + struct fuse_conn *fc; + struct fuse_ring *ring = NULL; + struct fuse_ring_queue *queue; + int qid; + + res = copy_from_user(&rcfg, (void *)argp, sizeof(rcfg)); + if (res != 0) + return -EFAULT; + res = fuse_uring_cfg_sanity(&rcfg); + if (res != 0) + return res; + + fud = fuse_get_dev(file); + if (fud == NULL) + return -ENODEV; + fc = fud->fc; + + if (fc->ring == NULL) { + size_t queue_depth = rcfg.async_queue_depth + + rcfg.sync_queue_depth; + size_t queue_sz = sizeof(struct fuse_ring_queue) + + sizeof(struct fuse_ring_ent) * queue_depth; + + ring = kvzalloc(sizeof(*fc->ring) + queue_sz * rcfg.nr_queues, + GFP_KERNEL_ACCOUNT); + if (ring == NULL) + return -ENOMEM; + + spin_lock(&fc->lock); + if (fc->ring == NULL) + res = _fuse_uring_conn_cfg(&rcfg, fc, ring, queue_sz); + else + res = -EALREADY; + spin_unlock(&fc->lock); + if (res != 0) + goto err; + } + + for (qid = 0; qid < ring->nr_queues; qid++) { + queue = fuse_uring_get_queue(ring, qid); + fuse_uring_queue_cfg(queue, qid, ring); + } + + return 0; +err: + kvfree(ring); + return res; +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h new file mode 100644 index 000000000000..d4eff87bcd1f --- /dev/null +++ b/fs/fuse/dev_uring_i.h @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * FUSE: Filesystem in Userspace + * Copyright (c) 2023-2024 DataDirect Networks. + */ + +#ifndef _FS_FUSE_DEV_URING_I_H +#define _FS_FUSE_DEV_URING_I_H + +#include "fuse_i.h" + +#ifdef CONFIG_FUSE_IO_URING + +/* IORING_MAX_ENTRIES */ +#define FUSE_URING_MAX_QUEUE_DEPTH 32768 + +/* A fuse ring entry, part of the ring queue */ +struct fuse_ring_ent { + /* back pointer */ + struct fuse_ring_queue *queue; + + /* array index in the ring-queue */ + unsigned int tag; +}; + +struct fuse_ring_queue { + /* + * back pointer to the main fuse uring structure that holds this + * queue + */ + struct fuse_ring *ring; + + /* queue id, typically also corresponds to the cpu core */ + unsigned int qid; + + /* size depends on queue depth */ + struct fuse_ring_ent ring_ent[] ____cacheline_aligned_in_smp; +}; + +/** + * Describes if uring is for communication and holds alls the data needed + * for uring communication + */ +struct fuse_ring { + /* back pointer */ + struct fuse_conn *fc; + + /* number of ring queues */ + size_t nr_queues; + + /* number of entries per queue */ + size_t queue_depth; + + /* req_arg_len + sizeof(struct fuse_req) */ + size_t req_buf_sz; + + /* max number of background requests per queue */ + size_t max_nr_async; + + /* max number of foreground requests */ + size_t max_nr_sync; + + /* size of struct fuse_ring_queue + queue-depth * entry-size */ + size_t queue_size; + + /* one queue per core or a single queue only ? */ + unsigned int per_core_queue : 1; + + /* numa aware memory allocation */ + unsigned int numa_aware : 1; + + struct fuse_ring_queue queues[] ____cacheline_aligned_in_smp; +}; + +void fuse_uring_abort_end_requests(struct fuse_ring *ring); +int fuse_uring_conn_cfg(struct file *file, void __user *argp); + +static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) +{ + if (fc->ring == NULL) + return; + + kvfree(fc->ring); + fc->ring = NULL; +} + +static inline struct fuse_ring_queue * +fuse_uring_get_queue(struct fuse_ring *ring, int qid) +{ + char *ptr = (char *)ring->queues; + + if (WARN_ON(qid > ring->nr_queues)) + qid = 0; + + return (struct fuse_ring_queue *)(ptr + qid * ring->queue_size); +} + +#else /* CONFIG_FUSE_IO_URING */ + +struct fuse_ring; + +static inline void fuse_uring_conn_init(struct fuse_ring *ring, + struct fuse_conn *fc) +{ +} + +static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) +{ +} + +#endif /* CONFIG_FUSE_IO_URING */ + +#endif /* _FS_FUSE_DEV_URING_I_H */ diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 6c506f040d5f..e6289bafb788 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -7,6 +7,7 @@ #define _FS_FUSE_DEV_I_H #include +#include /* Ordinary requests have even IDs, while interrupts IDs are odd */ #define FUSE_INT_REQ_BIT (1ULL << 0) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f23919610313..33e81b895fee 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -917,6 +917,11 @@ struct fuse_conn { /** IDR for backing files ids */ struct idr backing_files_map; #endif + +#ifdef CONFIG_FUSE_IO_URING + /** uring connection information*/ + struct fuse_ring *ring; +#endif }; /* diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 99e44ea7d875..33a080b24d65 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -7,6 +7,7 @@ */ #include "fuse_i.h" +#include "dev_uring_i.h" #include #include @@ -947,6 +948,8 @@ static void delayed_release(struct rcu_head *p) { struct fuse_conn *fc = container_of(p, struct fuse_conn, rcu); + fuse_uring_conn_destruct(fc); + put_user_ns(fc->user_ns); fc->release(fc); } diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index d08b99d60f6f..a1c35e0338f0 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1079,12 +1079,53 @@ struct fuse_backing_map { uint64_t padding; }; +enum fuse_uring_ioctl_cmd { + /* not correctly initialized when set */ + FUSE_URING_IOCTL_CMD_INVALID = 0, + + /* Ioctl to prepare communucation with io-uring */ + FUSE_URING_IOCTL_CMD_RING_CFG = 1, + + /* Ring queue configuration ioctl */ + FUSE_URING_IOCTL_CMD_QUEUE_CFG = 2, +}; + +enum fuse_uring_cfg_flags { + /* server/daemon side requests numa awareness */ + FUSE_URING_WANT_NUMA = 1ul << 0, +}; + +struct fuse_ring_config { + /* number of queues */ + uint32_t nr_queues; + + /* number of foreground entries per queue */ + uint32_t sync_queue_depth; + + /* number of background entries per queue */ + uint32_t async_queue_depth; + + /* + * buffer size userspace allocated per request buffer + * from the mmaped queue buffer + */ + uint32_t user_req_buf_sz; + + /* ring config flags */ + uint64_t numa_aware:1; + + /* for future extensions */ + uint8_t padding[64]; +}; + /* Device ioctls: */ #define FUSE_DEV_IOC_MAGIC 229 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) #define FUSE_DEV_IOC_BACKING_OPEN _IOW(FUSE_DEV_IOC_MAGIC, 1, \ struct fuse_backing_map) #define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t) +#define FUSE_DEV_IOC_URING_CFG _IOR(FUSE_DEV_IOC_MAGIC, 3, \ + struct fuse_ring_config) struct fuse_lseek_in { uint64_t fh; @@ -1186,4 +1227,10 @@ struct fuse_supp_groups { uint32_t groups[]; }; +/** + * Size of the ring buffer header + */ +#define FUSE_RING_HEADER_BUF_SIZE 4096 +#define FUSE_RING_MIN_IN_OUT_ARG_SIZE 4096 + #endif /* _LINUX_FUSE_H */ From patchwork Sun Sep 1 13:37:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786447 Received: from outbound-ip191b.ess.barracuda.com (outbound-ip191b.ess.barracuda.com [209.222.82.124]) (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 C6A91183063; Sun, 1 Sep 2024 13:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197845; cv=fail; b=BU7KkJD5ZW5zD9dPHr5gAOP7J7ZMcKeBaBzVjS8n9piSQntLiB0htuS5asa8H890HKh84rHoL9iwX7AfgGi2mRD1RQJVF6IA/8/T1h9sYcsII8dQwZU9DBKPXloPJXPtoABweBV5fHBZX9Ndfy/zeZsHFYD1n30tAlEh302vNWQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197845; c=relaxed/simple; bh=mT02XlyX4gmi4ocpMbkDD+Qv65yCFHgFxbcP2gxZjPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q4cZHw7HKoX2tOexZv0N6foTLOqqmTzGX+0znjWsxUiVuf3eJ9Th3cH09PbIlIKvXF8q+9oY3CtyI5TXHKi3BDoQXBEJVlHztqvSORPgcyOV4wORVM4ebChPH5Ip9PkM4VCu+Plm/KEOIntCxUjOmSw3Zxwq9TvJKq3H3trdG1M= 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=a7faAJEj; arc=fail smtp.client-ip=209.222.82.124 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="a7faAJEj" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx-outbound22-20.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IHltib7UIQxr9AEk+e09La7SGCg1DiLkLhADIhhdjXSSDCaSzRK9TPYdBK7sAytN6fVjAlzwt3FDaM96aj/mQttx6QqtTLobBmRa1BSAVwuwW1wTWXnL0JQwk9JqILCXc/SodQ3nYkivuz5z5JIMIpTlPp2iMfqafFgR3A7KihhCkoo/hvD0Z6Elv8Ki/tk8EPqmtSFtdzOF6hVuSlmFgZ9eCxttG6TeMuU0iReT8M+Ziu/XYPTSfKsZcE31ISu57YRbE+/2GEFVmwpn/19hPvBmj5Mkr0ZBftKmyQ+j8GORL2+F+3qEZRkviQPrmHn6ZwmvGsBGjE6B8KUUzOxCRg== 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=PUQ7YhCmB9FZswPSTwkDTgWzD/Vt8/BQcnaZo0gIQyI=; b=mvL2/vLwgHQ8QA5YaK9qQYCkKr3/eJjBofLRau0kO6P3pyLXdOpgg25eQTb3F4vOPrKHbHEzB08MwoWnpYniYmHGPUUsLB+4D7vPcrsQDHekWlbzLKmHmm4VuYYoFjEnUCEZsjNr9FtePrNzklKnR4y1FtA2jzf7BqP7niHtKMi/FyPr0jAXDY44ha9kyZLrRd4aT0C/2AXfmW/qmXDq4r90CzNgLvpl8gA/BfjciR8O9MZOlQGDp9PTfWcmKI++Lni1w10DAwXTQS5z6l+qb3cOCvN1UyZ+Fi/iTfzadNc5Hb2ITclrQEtwxdqEPbeTacuLYxVXXENrWu5kQSGAhA== 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=PUQ7YhCmB9FZswPSTwkDTgWzD/Vt8/BQcnaZo0gIQyI=; b=a7faAJEjWuMq2BzOIK6lP/Ut+PbnnYLxEXhgJhS1uoubIVesNnxQYUWvX3KRuM0tK6h2Hmb1b3Ci9xU8+1upZAPQsAsiADDeAuytt04WROlhrjDjYWGNtKIc89KzkvE+G/AdHpmwttQ5+DFjGrAIdmgiAC57e7Elff1Cc8lsErI= Received: from BY1P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::10) by CH2PR19MB3878.namprd19.prod.outlook.com (2603:10b6:610:9c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:07 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:a03:59d:cafe::ac) by BY1P220CA0003.outlook.office365.com (2603:10b6:a03:59d::10) 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:07 +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 CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) 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:05 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 7F9BA72; Sun, 1 Sep 2024 13:37:03 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:00 +0200 Subject: [PATCH RFC v3 06/17] fuse: Add the queue configuration ioctl Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-6-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=4637; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=mT02XlyX4gmi4ocpMbkDD+Qv65yCFHgFxbcP2gxZjPQ=; b=+94++RXxVoA7dhYuDirAidazAUjB4HbPchYcB9wY70TX3jONJEueJJDYspKaw7/iSbtH+4eEw fY6GMUUbsCcDIRKwEPVSEYiMj/98xG8znhLyMO5vrRLsYAwlh+ZsN8w X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075ED:EE_|CH2PR19MB3878:EE_ X-MS-Office365-Filtering-Correlation-Id: f818af4b-d5a4-4c92-c78d-08dcca8b2c3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?fKK+dUlVG3DWLrZIwU8E7ENC8GjRy/w?= =?utf-8?q?wum64AqyBppFmpPmC6pkpvcrldBx8ym2M1CKKnKFuUQ2WsMKfGOGH+4+w2DmjctqR?= =?utf-8?q?qyIUqpgjsNR3YeMqRyf3p3MZ+agYNNiBIWnSFjifBurEKDeIxMhvTVe82rauJj1Kr?= =?utf-8?q?tBu0sjXqWvLVS4V72xy8VHH14aC/UBtrFYQAmL4vLyhFc8LeMPl9UObG00/8qCvuU?= =?utf-8?q?U0/iSjPbqwPE4K5LI2quuGLnITKwpVdQH0je5UD+2Xb1EOWW+ug8OWjt0Y+iLwd7m?= =?utf-8?q?mtvchTwlQRBMfOWj8lSmIlR5pqEW2fHj45ZwHWkbcXo8EoSwsmpDddQseUu7dX6W6?= =?utf-8?q?Xqb72Fe7EWdE1cuFks8sW2Pm29kPPIvfSQoqX4PJlRwtnBkirD6OQnpRrutHlwXzK?= =?utf-8?q?+V5JKLA9YpjIg4RUnTkeM2CZiDsoawDcUMYGjuL90jhUDn8m9c3kqdSB/VaccZCJ8?= =?utf-8?q?VfFsqHSImF8Ru3lEZv98bjv0qeuJK2hV4d5Vb09JZAXDLgLbt5SeDPGWEnyQSQiO9?= =?utf-8?q?+CT2j2TZ+3iEw0gwHLtBIVTAtTI+pe4JyhYdZtbBZVT9pilp3T7JVkZF6r3bQW2Lp?= =?utf-8?q?TVxXHl5snJljSk2c1G2QsuIwdTsv6os82a7qlEcbYEMEcIfqceEl3ip2QbEo3DqNB?= =?utf-8?q?DQSGmejihtsfnnGIye5apgoAsPClls8uI3IrecKr5Ib4ErtaxbRvwHm4naj1dug9o?= =?utf-8?q?l4D7OW5ShIVeJ3ijNjvWdjWtEMnfm6u+Xde3e7+yR2X2Z0QjDsAQffkITydT0ehd0?= =?utf-8?q?sXIksgUre4JxFXWDOWyhw8fb23nU7BKBB+PgYe9z692NOJVT4tFhP0xFPCYaDuFsU?= =?utf-8?q?eQC+R7bMYjLO6xFFK1ibjXd8F9bzOk8N0Wl6CW243Vc0p1L8FzJjD/zb7IWdrAVGA?= =?utf-8?q?w/0IWs00W5GqcySTCCXMTHzL5zzySosZ8Mk9150+GUPPHgt6CQ4ep/DMs1h+y1Z7x?= =?utf-8?q?Y+4ukBPJ8jn1L9IYJNWswXwXBYYVSjY6T10czhaFp8iOR7YF06BIftL8VCK+DXsFt?= =?utf-8?q?GDe2tfXYwYOYgvTtT9WzFp3i5fJpKl8NBNEKDvwX3VUqqMmGIl93yyMm0ruQQe7E0?= =?utf-8?q?/Q5J0d4U1s2Ft3/1Y67qWufCGVU+WzGdc4T+QZrdyPgINvsTIgYWX/ZM8L1P46yz7?= =?utf-8?q?Co4XMoelKH5fpEPyCc4qI0s7UeGXsWQNOWUPO6S8JlELZ6PA/ZM5eUNe6oEpzNTdq?= =?utf-8?q?W1+tvR9ITbzHoedNTcUfS55Xsu7R6DVNwKtFDe1q1c+CvE6l8b28KQL6L/io7/9QG?= =?utf-8?q?dCVgGdyer4WtSOkemapPypAmdQ4e4BYsU+1a6197YP7j1RwgN7ubWLY/Yf/01MHBk?= =?utf-8?q?eKGCvm3urhqo8BkUjowEVMobismdy2Z7WG/a+aGWoDF0hc5v6DGviJcoSxXDmnnaz?= =?utf-8?q?8nOAyUduxSk?= 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OZEs84whfJh9qTh3Vq3WwK3ks/tnnpuYnRv5Ko2wm4phtAs1+uYWGV1TTmvKQ9/JDIRhtEeTD73i7a8cF/fkVLa8YEsHRt0zntmZF16ya+er4bPAxyRQQMtq4VltjDf9iCKjvyZ44ayyzuYOrDLytfG4jwZtbh+Qc4UaH5IEbiEVQzpTHwwpmzZNAwt+rVr0rSr5ToNjdQzOAZtDmevIgu8fkmMe8uHggVnJOuFNKkhcBI/P1iwlvfOlJt3gPi289vvOz299ONXbMAAuHECiBvTMRPRI1yekv2Gt6XJVNxdXthYSRacn2PMEGw0IxNivRoNSraevYf1FqiHcSM1QDx4Pr0C48bBRmAnWCzpWmqh18xjV5Jnp7vBda9RxWB3QZtNxEO1b6B8j21HVGuN7PIiNwyOVB51cWgSPmUPZlH7WHMd9mLIYvZQvU/iokuDKGsama8laDrheLqU6wtSlj5/QQEX3qvbsKM4iiSAPtqK/B/3OvrA/iGVWz/0B4zfIxIooLhnetJ+WncsEUqgDxsV6yP/bMzh0z+bevCFaHBJ4/n1VpNTBeuv/drLhh3rv627AEqM+4LkNvYVYbzB+UUCcGpAGTtwnMOxC3MOCzCwCju2xNtKsnNxfB5G3f/6YBPXp51mW7RTzoiJVrL72fw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:05.9116 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f818af4b-d5a4-4c92-c78d-08dcca8b2c3b 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: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR19MB3878 X-BESS-ID: 1725197831-105652-12653-5390-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.66.43 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYmpuZAVgZQ0MjIKDHFPM3SMD nNNCnRLDk52TLJxNjSwCLNODnFPNlcqTYWAKbYgktBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan16-237.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 Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 30 ++++++++++++++++++++++++++++++ fs/fuse/dev_uring.c | 2 ++ fs/fuse/dev_uring_i.h | 13 +++++++++++++ fs/fuse/fuse_i.h | 4 ++++ include/uapi/linux/fuse.h | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 6489179e7260..06ea4dc5ffe1 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2379,6 +2379,33 @@ static long fuse_dev_ioctl_backing_close(struct file *file, __u32 __user *argp) return fuse_backing_close(fud->fc, backing_id); } +#ifdef CONFIG_FUSE_IO_URING +static long fuse_uring_queue_ioc(struct file *file, __u32 __user *argp) +{ + int res = 0; + struct fuse_dev *fud; + struct fuse_conn *fc; + struct fuse_ring_queue_config qcfg; + + res = copy_from_user(&qcfg, (void *)argp, sizeof(qcfg)); + if (res != 0) + return -EFAULT; + + res = _fuse_dev_ioctl_clone(file, qcfg.control_fd); + if (res != 0) + return res; + + fud = fuse_get_dev(file); + if (fud == NULL) + return -ENODEV; + fc = fud->fc; + + fud->ring_q = fuse_uring_get_queue(fc->ring, qcfg.qid); + + return 0; +} +#endif + static long fuse_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -2398,6 +2425,9 @@ fuse_dev_ioctl(struct file *file, unsigned int cmd, #ifdef CONFIG_FUSE_IO_URING case FUSE_DEV_IOC_URING_CFG: return fuse_uring_conn_cfg(file, argp); + + case FUSE_DEV_IOC_URING_QUEUE_CFG: + return fuse_uring_queue_ioc(file, argp); #endif default: return -ENOTTY; diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 4e7518ef6527..4dcb4972242e 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -42,6 +42,8 @@ static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, ent->queue = queue; ent->tag = tag; + + ent->state = FRRS_INIT; } } diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index d4eff87bcd1f..301b37d16506 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -14,6 +14,13 @@ /* IORING_MAX_ENTRIES */ #define FUSE_URING_MAX_QUEUE_DEPTH 32768 +enum fuse_ring_req_state { + + /* request is basially initialized */ + FRRS_INIT = 1, + +}; + /* A fuse ring entry, part of the ring queue */ struct fuse_ring_ent { /* back pointer */ @@ -21,6 +28,12 @@ struct fuse_ring_ent { /* array index in the ring-queue */ unsigned int tag; + + /* + * state the request is currently in + * (enum fuse_ring_req_state) + */ + unsigned long state; }; struct fuse_ring_queue { diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 33e81b895fee..5eb8552d9d7f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -540,6 +540,10 @@ struct fuse_dev { /** list entry on fc->devices */ struct list_head entry; + +#ifdef CONFIG_FUSE_IO_URING + struct fuse_ring_queue *ring_q; +#endif }; enum fuse_dax_mode { diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index a1c35e0338f0..143ed3c1c7b3 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1118,6 +1118,18 @@ struct fuse_ring_config { uint8_t padding[64]; }; +struct fuse_ring_queue_config { + /* qid the command is for */ + uint32_t qid; + + /* /dev/fuse fd that initiated the mount. */ + uint32_t control_fd; + + /* for future extensions */ + uint8_t padding[64]; +}; + + /* Device ioctls: */ #define FUSE_DEV_IOC_MAGIC 229 #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) @@ -1126,6 +1138,8 @@ struct fuse_ring_config { #define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t) #define FUSE_DEV_IOC_URING_CFG _IOR(FUSE_DEV_IOC_MAGIC, 3, \ struct fuse_ring_config) +#define FUSE_DEV_IOC_URING_QUEUE_CFG _IOR(FUSE_DEV_IOC_MAGIC, 3, \ + struct fuse_ring_queue_config) struct fuse_lseek_in { uint64_t fh; @@ -1233,4 +1247,29 @@ struct fuse_supp_groups { #define FUSE_RING_HEADER_BUF_SIZE 4096 #define FUSE_RING_MIN_IN_OUT_ARG_SIZE 4096 +/** + * This structure mapped onto the + */ +struct fuse_ring_req { + union { + /* The first 4K are command data */ + char ring_header[FUSE_RING_HEADER_BUF_SIZE]; + + struct { + uint64_t flags; + + uint32_t in_out_arg_len; + uint32_t padding; + + /* kernel fills in, reads out */ + union { + struct fuse_in_header in; + struct fuse_out_header out; + }; + }; + }; + + char in_out_arg[]; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Sun Sep 1 13:37:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786514 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 F204F446AB for ; Sun, 1 Sep 2024 15:09:31 +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=1725203373; cv=fail; b=FV0q2pl/euQYPugAdoH6Hu9HzPOuP8x+nIYEmkC+XPlRQloAYjc1uhwFwJktIxVwkjLqlaIjDxcpVHQzB/wDi0L6SqpT+JiTlJQSB7pWn9aPgjEc8iMgz0SwqV4/zvqONkshikq8c7QC96xnDwY7jU/KDPLemd7J2RRvZjyvTBQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725203373; c=relaxed/simple; bh=iY2u27Lx75nk/Jbh8FJuFoTqdy1g9U9WNWFnLzjscRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y+0O6yml1fFjzOCIuFLMfCFEpDgv62loV+RDPQiq0FqQVJDEGrRUeZBz+EPcsEGilTL3NGymRb/L5ULvG1o/ln2hFzXNfnioi0CrmscHb8yTRuIdao95nFG7g0rEqk53DQ+t6DQLJSeOODP6AL+9RgmfwfRS4rPqMDkkbEkY8xQ= 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=At9QoBci; 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="At9QoBci" Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2173.outbound.protection.outlook.com [104.47.73.173]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 15:09:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pfnd6xdu4sNs6vigWshcM3jUAUxR4/frwtYVl6zlvXlPeVEsxAeRY9/P1NGvJ5JcdWYHrUWkPYLiuroC6UisHlVMxOt2DANIEdHRvqsmeP98FnSv8ICw+rWAIdxL6wR+U2RCScj1atI0z/5q8ZuwQw1xYHlvU+9UPrT1tG8jjs19rN9ka7zboV9NUlUixLKCRMWZ+TohvqpHJVrQO+FcVjFWs94LpSjJItZsK1x3TVWnz94sL2uDKKrTN8KBTArFLBs2SnloN/hRNxMDoscg6QarCRRoC1njnCupd6JENvKA+slqoTercOem6nK5pEAf9Ekftu00I3ICCDigGmjFIg== 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=H1tBy1zQLOJh/01sA2m8CZ71UkTSo5m8UsZlpi6fGcI=; b=DfdC+R+6uQ4PgkX7sOF6+2xrmrXr/NAM9cd3UKi+tBZLiJyhwR0GOLSTRZM9I2AFO5qz2r4+N/D2uweaIXnHgCShQd01tp4RyoxncYxy7stFSnJxUaD6tej9+cVoczderMDb8VnzXI3SLX/+32Acxm/X5DF2mSU8q7jVHYftYH7ioyJe7RvqIg4L43lKSFG+PwtDjlAysJG4Gq8M96yUEYGAPdLm6nxWiSJhYBlt9RRFYmJwac4deNoUGAAXt8Kh4JCuQSGH5cbr43qSXUa5wpJHO3LOMVhX8w3MRJoDSMpR5glBEfAgRcyotdDiJ0pqzeGbNCGBmCS5vwtLrUGobw== 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=H1tBy1zQLOJh/01sA2m8CZ71UkTSo5m8UsZlpi6fGcI=; b=At9QoBcixCfYgp+cuVaDn8j3Y9UAwMldG/Q73Zk8gbcM+3/7Ql8zLshE8PxICbRCH5XSwib8udwuKrddhdfC2mgqDIH2l7xfm+2mV/LnHAY5VLiDToq/p9vW9d0JyVMUon4cM/ohsls+k2vWtmeCwx0WRSzpQdI2pn81mLb2Ml8= Received: from PH8PR05CA0019.namprd05.prod.outlook.com (2603:10b6:510:2cc::25) by MN0PR19MB6066.namprd19.prod.outlook.com (2603:10b6:208:381::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:05 +0000 Received: from MWH0EPF000A6733.namprd04.prod.outlook.com (2603:10b6:510:2cc:cafe::ce) by PH8PR05CA0019.outlook.office365.com (2603:10b6:510:2cc::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24 via Frontend Transport; Sun, 1 Sep 2024 13:37:05 +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 MWH0EPF000A6733.mail.protection.outlook.com (10.167.249.25) 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:05 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 77C9BD2; Sun, 1 Sep 2024 13:37:04 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:01 +0200 Subject: [PATCH RFC v3 07/17] fuse: {uring} Add a dev_release exception for fuse-over-io-uring Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-7-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=3491; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=iY2u27Lx75nk/Jbh8FJuFoTqdy1g9U9WNWFnLzjscRY=; b=b6FPd+AMFMLVBA0vSwR1/RvE8baeZy+z+vp+wJI0ze+5O6cWrLuD3m7AeXThAqVdMm8hi4Z0V WL1TWe+pvHZCmZihtrp9DY7RZ6E5zKpN8GywLXpvVp18ONT2SN0UI+w X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6733:EE_|MN0PR19MB6066:EE_ X-MS-Office365-Filtering-Correlation-Id: 900c58cc-efbe-442a-1c61-08dcca8b2b22 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?VcyR3CveSvBBdgMISmgog/yJ1VfiaQw?= =?utf-8?q?xLDBWXR+LVQrz3vKQPTo0qaZDVqk8CJv1Wr35TkFI1H7PAhluoqT4MSZacPvbyZkG?= =?utf-8?q?3veoD4vR3J46azJuFhy7l88Y68tN0qQ1ul2Cs0O47ILSuf6VYPRdRRqEmWbpPe7Ee?= =?utf-8?q?9kFs76FcODcV4ZxAHiYyYo0X7Zg8yO1IrGOIKlavLj60J0rh0wMGybUEgAnReLGih?= =?utf-8?q?8F/DZ6ixUTKAKscuAgEraPzBOD2FAM90A1E/8Pyh0CahBbp+AXePVKC/b0K2TVZ9G?= =?utf-8?q?yRhlrfSGdgdkYXsl+rGPpRrBqVrIekKLPMPVIpBrkuX4mwhk40SZgMGVhf8QYyzAB?= =?utf-8?q?lChAxEyK33ZcDNAU7/OhbfvOHtELwxg4D9p4U7xpIcNltdIldg6PhOK9sBOTVpDXG?= =?utf-8?q?j+fPC7GA3pYxYhezZ6Neb5KtMQVd6i6mBAkaCw6j05vGC1OJEsgvk0gTQmQIlizvK?= =?utf-8?q?8StxFJwpItdGD92YeGKafan1ENZuTWLAUsYO76Gr/9qm7Vs/l0zbxwCET3P/Be0kv?= =?utf-8?q?L26fXcnDHMZnCMkppgn3QLtyWmk2w7W0TKjpSZdponQkBQaOCTNQ8W3Xk3dfRW7gu?= =?utf-8?q?YhdJXgYW1KKk1H2f0rudHM5Vs39QMpRkfs85aVFKzK4yjyeLsUMDl/kC6zF2Glbuf?= =?utf-8?q?eMwNjg8tc7UKXtLgIuJceKFJW0RkGprHlR7FAn/ER+UlNMOewvPgR7pYyew5oVpK4?= =?utf-8?q?ZPN8UqqGz9MACiwabsv0EoM8lyK3LIKwNd47nHNf5lJUCQSRYDgxCNSjhomudiNwM?= =?utf-8?q?Zn9JjhoVICgncnuX0sClxkOc2klE2TezGnn4GcA+0QtpRWN7KEnHCljF+KgVqrwYq?= =?utf-8?q?3O2dbpQHqT6otHXKrqZQCprx+vST8KXJMpAlFfuNP8F2e5d6Is2uASne9ULnPO4dT?= =?utf-8?q?8eiksAIsaCnCFejbsKtK/ymnrScrlTdy+H8oevUY+9MJHiSEKQhLA+TPdnxAjAdmt?= =?utf-8?q?w8qCw1+Z3583eICoHDlVrF7FaWnRK+s6wBzTZ20i5PkxMbEVywJLcSERjVJVXWLJD?= =?utf-8?q?F98+2CYa11PNnnnywcA00FOhNvO0G7YgnCByx1nt6fqJUyyHdwgrHFVHdZHpoBshE?= =?utf-8?q?QBv3q7eAmBsVCdK7DQZdx2qc89q7S0goimlfXsabIA4wZsb6Fjsva72IvLGhxmVY+?= =?utf-8?q?x/YEet66Y/6yinDHZ5CoI298StoQdmUkzhZtLuSPiTSS4h9Xp9vFyOSVGbHDo+cyE?= =?utf-8?q?/jEq90Aq6rZdhqfkF6oRjpbigD6tIyiU7b0+6RehcS+wHYLF1xxupenX4JlFH4YIY?= =?utf-8?q?Mdzzd6nmlwVSfyqAVKvCnyaUU1+JlHT+ZeNlXH+eS2W8a8bPC92CzFcqaE4uQwQs1?= =?utf-8?q?JN6x81mg8zBO3ScnS6GqNxVu+7aC26dXnq/C6IO1m1wVfKscIF3vz1R6caSXiSi3L?= =?utf-8?q?uGQhdppQ0N5?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XjehkRUVJa3oL+/LItDSP1Hv+c9WuRfZgOBNxBnZiP3zaj4llPj98+joVy9wcik5cNT3mopOCexQgLHE/Pa6tdQebq3qqTExpIsQD8re1RFVWBXXiXr8XtNmG0g2IXbu7UGC1NJQuyfDUpNtwYYix7pYJ0HMttJS35RME2nKJYbnBhontZz7rFyLplEk0EyH5gv4A/yyU/R+nMdNw7svFm4eCUTT/Le/f4rlHWeWxbFq0feHm11XZCxdSDhSQiWeXmKWtEf2iw3mg9+1ViSxN+sFLmxsD8PBIE2rXH7BtuDy/VuStgXc7WBP2iD+y8fOsI/5ZrJz4nyGuUB42f8LTehVd5oU6J+a+VskaWNn06q+RjNdnrJZJ5ayMM05YGaMhCq1+ePsfHiSBUcXryhPgo/KoM8pj2u1f9YktgiFf2Sn7NgarsqDqnU/01YBufmemjmFzC7a2+k+xxax6RxFxZeS6WgX5l0CGO9GwO5a35EIKdaHVDWcZYW993cvSZCrBlA2p7op5vq/0QQc5RNAulgJ8vCMh/BKaca0jes/BCQow3sGd60eOwFQ8IwaVKnFHgCbrmYC/p/Ohyg9FB2/O1HBXojR9QNA3H1s0IiJJI+mjkuXHXPPIbRMTPQtgLPzfchn90JnOkR6uVBchepi/A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:05.0657 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 900c58cc-efbe-442a-1c61-08dcca8b2b22 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: MWH0EPF000A6733.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR19MB6066 X-OriginatorOrg: ddn.com X-BESS-ID: 1725203370-105647-14397-78717-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.73.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbGZqZAVgZQMDnF2DTJ0MI0NT XZyMjS3MgiNdHE0sI8ycDE3MDY3MRIqTYWAFoRZDlBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258745 [from cloudscan21-205.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 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_SC0_MISMATCH_TO, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 fuse-over-io-uring needs an implicit device clone, which is done per queue to avoid hanging "umount" when daemon side is already terminated. Reason is that fuse_dev_release() is not called when there are queued (waiting) io_uring commands. Solution is the implicit device clone and an exception in fuse_dev_release for uring devices to abort the connection when only uring device are left. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 34 ++++++++++++++++++++++++++++++++-- fs/fuse/dev_uring_i.h | 24 +++++++++++++++++------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 06ea4dc5ffe1..fec995818a9e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2258,6 +2258,8 @@ int fuse_dev_release(struct inode *inode, struct file *file) struct fuse_pqueue *fpq = &fud->pq; LIST_HEAD(to_end); unsigned int i; + int dev_cnt; + bool abort_conn = false; spin_lock(&fpq->lock); WARN_ON(!list_empty(&fpq->io)); @@ -2267,8 +2269,36 @@ int fuse_dev_release(struct inode *inode, struct file *file) fuse_dev_end_requests(&to_end); - /* Are we the last open device? */ - if (atomic_dec_and_test(&fc->dev_count)) { + /* Are we the last open device? */ + dev_cnt = atomic_dec_return(&fc->dev_count); + if (dev_cnt == 0) + abort_conn = true; + +#ifdef CONFIG_FUSE_IO_URING + /* + * Or is this with io_uring and only ring devices left? + * These devices will not receive a ->release() as long as + * there are io_uring_cmd's waiting and not completed + * with io_uring_cmd_done yet + */ + if (fuse_uring_configured(fc)) { + struct fuse_dev *list_dev; + bool all_uring = true; + + spin_lock(&fc->lock); + list_for_each_entry(list_dev, &fc->devices, entry) { + if (list_dev == fud) + continue; + if (!list_dev->ring_q) + all_uring = false; + } + spin_unlock(&fc->lock); + if (all_uring) + abort_conn = true; + } +#endif + + if (abort_conn) { WARN_ON(fc->iq.fasync != NULL); fuse_abort_conn(fc); } diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 301b37d16506..26266f923321 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -15,10 +15,10 @@ #define FUSE_URING_MAX_QUEUE_DEPTH 32768 enum fuse_ring_req_state { + FRRS_INVALID = 0, /* request is basially initialized */ - FRRS_INIT = 1, - + FRRS_INIT, }; /* A fuse ring entry, part of the ring queue */ @@ -29,11 +29,8 @@ struct fuse_ring_ent { /* array index in the ring-queue */ unsigned int tag; - /* - * state the request is currently in - * (enum fuse_ring_req_state) - */ - unsigned long state; + /* state the request is currently in */ + enum fuse_ring_req_state state; }; struct fuse_ring_queue { @@ -108,6 +105,14 @@ fuse_uring_get_queue(struct fuse_ring *ring, int qid) return (struct fuse_ring_queue *)(ptr + qid * ring->queue_size); } +static inline bool fuse_uring_configured(struct fuse_conn *fc) +{ + if (fc->ring != NULL) + return true; + + return false; +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -121,6 +126,11 @@ static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) { } +static inline bool fuse_uring_configured(struct fuse_conn *fc) +{ + return false; +} + #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ From patchwork Sun Sep 1 13:37:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786446 Received: from outbound-ip191b.ess.barracuda.com (outbound-ip191b.ess.barracuda.com [209.222.82.124]) (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 BA86417F389; Sun, 1 Sep 2024 13:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197843; cv=fail; b=snRpOJFcJl7xW1yCDDIBvBPN+sKZLuXpjCKfqbut/g7T3D7WN+Ro3qKYCjizJ/o4F8baiogPLRcR5WhJOMfA7YM94Az+NyjIbW4eOR3XCN52ubQbyNA2iWTY6yhlfBWe4cedGcuzPp3J8Dgxj3aIMpyeaO/jWg3P7XnfW2Xjuts= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197843; c=relaxed/simple; bh=R/YQ5fAgxZSRo5nZQW3oRq/ADQN8D5FW6Yx0yb+KkWI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cbJUsqTRk5mZfY67G4xii2IUZ1Hj4wFcB5jLzjvcXW7zn8uFSXYo0qH4shVvGYN8wJ6TjSMrB+t6sQV7s56t967mWzFZIbzCyPheQP/pcsRJGv2WCALH9K6Xb9iAP9laqUoL+WJD8oRDKDNxrAfyk1O0VsY4exYKzttDhyHr2sc= 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=2BfYJ+f8; arc=fail smtp.client-ip=209.222.82.124 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="2BfYJ+f8" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VuCSfyaBoimPBiiFjaGtVuwdjvYgPkwGbV5RbWHy0GwBxP2wHAFcl4sVvMKkfSe+/UMyAISwVu2gsO19c03YMc4Z4CpekQtlNBGNwnKWSv420o9gfAbv9J3RGzSun+sMD+O7modda3x/UECmpE5AiiCDumOeDIVOYkT1ysCI+7CDLWnreJf8RgFoRgje7E54drmJQ+596svsdg/tYy1kGVk7oD0te72JxElm5kDsLOBTj9jU8NUOC2NQYNk3QY4NlYoT0Brjg4szrHFZucTFHog6a5aQjs872jG6tI7ZumpQLOkSzltYdMnsiNpk6jm4fSAS+ubPQr/o0k+utDLHkw== 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=0+rPJ9zlblzQhoHd87Myu37u7q09ruu0yH0U4YsKFZ4=; b=WD97bjs2DyutZ8mRjLCG8dEboKjPOKz/gViFJ0nOYcpA+/baP1Stf/R9cmfzBVLmRJLkdUO6HBxFkJcb3q5WJZbMs2bBPRqmI9KqmJcbGSv1kZ6bqvZQwlXm/fsxzw44QKQbReyulUjKAHec8gRhqxfZUa9Hs+pjcfk23muQDonnya1NwoVkSXBVEW05tbBpJrrf86AcL0hZcpH3XUciIE+hWQqMrqIkItJKit35VER8ZntszJrZA3bKWRKoMH5xskS45i+sejosdaJZxLJvKT3zzHw3R6Kzl4mvyy3TlOAjFW4QjL+/nUz5qyDvIr9rV0F6PX2HejSSoXw+/qdHYQ== 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=0+rPJ9zlblzQhoHd87Myu37u7q09ruu0yH0U4YsKFZ4=; b=2BfYJ+f8ufp1bEqT97brKBzkcgUBvBTuIJz2jMyznGpb4WeLu4llBrh2CEX9a0Jp/PLf/fl2n+otBbMfQW7yJzERQmQKMZKWAaDxKDVmRjn57pgdZPT+tcB82xXqwtoKnNmPg9SeZbiwG1X6nChXJ0L4dEZNU2pKoj1y5mQOk3E= Received: from SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) by PH7PR19MB7147.namprd19.prod.outlook.com (2603:10b6:510:20e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:06 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:a03:33a:cafe::84) by SJ0PR03CA0003.outlook.office365.com (2603:10b6:a03:33a::8) 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:06 +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 CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) 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:06 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 7056BD3; Sun, 1 Sep 2024 13:37:05 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:02 +0200 Subject: [PATCH RFC v3 08/17] fuse: {uring} Handle SQEs - register commands Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-8-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=12052; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=R/YQ5fAgxZSRo5nZQW3oRq/ADQN8D5FW6Yx0yb+KkWI=; b=8cnCkFt8LnAIiCeW0skvyCus40DnIYARC02x1jKidVeFs4Y3Bz4N8xkltx4ZHCRHvjUyMnHrl eaDGkJGnZSMD3iB/MP5grIwvaC8bges9zO104Q71dtPSHDeZNzqQLZs X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F0:EE_|PH7PR19MB7147:EE_ X-MS-Office365-Filtering-Correlation-Id: acae371d-0755-4cf9-3180-08dcca8b2bb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?DlxlhGzN5hN2TDAfNjuL2+MpaKvKfTO?= =?utf-8?q?znNiaoRLPu9iwkZVjbx2JJS7v/jfJnb51hQBCYll6HtHi6+FTkEkiYyn3exx1x3cP?= =?utf-8?q?RlC1bh+TRFRZgSzE17v8Juv5iiWB3DcNH/xC3msB+/Nim/TLhbao2oev41vZKOeof?= =?utf-8?q?3Er29JAgFYs73Z2+k9tiQIioUgIFgyc9KD3iGXdt4mXE84zZLX8a+jz/ExT+GSN/H?= =?utf-8?q?s+W9Obqk2aleOB6LmqHloSfeQWHpv3EgkrXv0VP+WdsY+xoYBgMRmc4AhIXv5yXQj?= =?utf-8?q?bS4RwrRKn/yrZTEGG/O4Kc2B4xLy2OvCFWaGglKXB3S4YfUW4R6AqGP2ZYPoJlffe?= =?utf-8?q?Cvl5IdkDG2YKqaDd4ZfVCDREAZM7K/OebPSc+K89Ek82C+7LhIryLDjSQhLr5MqXV?= =?utf-8?q?wqROrCzhEzwAd8ZlQXVyRtE8xspuTLVz9HzTnrD8sd7+moH2O3jESUUuO4SgM5GyH?= =?utf-8?q?UBnoyBi9/H19sJR1h+TW+Ke9Z9slgebU3wP4FV1LCuyLuVTOXauz6BDmwNhgRxRgn?= =?utf-8?q?geMhjI4mFUQd1edG/ZGK1pZshUWOQh/8oEZ6RwXUkB1Mi031KUjT5oZ4Umai6z4ja?= =?utf-8?q?iOSoOwM6vY3yBZdqBNP8Fvdd2bNI41O5r6TxgySBk1Czf7eihgaFnSGkPCKTz7MAg?= =?utf-8?q?jckFh593Yv9RJxfW/C9iTQcoBt5/+NajiF23/T+OdKAa6OQvu+rZkmQ9z/P3BhBPu?= =?utf-8?q?e+6peWVd/UL8LCKghhcyLtxzPbiBq88ug81aZ6vkq4JLbGplpa1dW/fK3tFT325Iv?= =?utf-8?q?4wvyYnwxdrnfZS0B9w6u3mewDYQW8l8rttNd04I3RHHCVAiGFZON0t1IKOLpFPMxZ?= =?utf-8?q?SfoFsCOiGVFQeg3Ih235RO7PuVVCKf9C0IT7qfSoIya7JInnQphn4dNGSziKabnCI?= =?utf-8?q?hhScY19TEPUOe+Dn/cZf2uww4mTlqgbw8JbP/ikaTsxw1ZO71NPKbFShxhooAlUhS?= =?utf-8?q?dU90uYRDRl5Xb8clJC7QOa+JSEyFSqA1Ma3nXRip06lejHDGZ4NMWgvKZv280/Cbj?= =?utf-8?q?Ae/u9W0OqzPXIVfgR3pM0q7lhsdUZdKvPjA18BYHV9W0iQUY9qFch5G7e5JiI34lH?= =?utf-8?q?EF0o2mUae24kng5UTqw9CIKoNQlbKA9r1u6eKL9JKQUyTEyT/z7+lLnxz3sBmQpCi?= =?utf-8?q?ico/KwJ0Fqh6b8Xpgp4MOjVkeuyilpP81fIujayd0qhsAqE8nVhVHzA5mdUSAxgiV?= =?utf-8?q?ndnfBGs5dk75fxeeELCHw40bFQSTI3DGDo+butwCFhFhfYJ8mkUii4CPH92Vo6yb8?= =?utf-8?q?BtUbtccveVwn8QnIsJ4qybGj1nooiuH66XeMG2AVLNov3t25rNkEV8tImECJIoENY?= =?utf-8?q?i5Pch0UqsPXp0asgNS1Le5Ts3o3L7+YBkXF5DWJSElUsTy+WgF5Xbxfp7pzNKFCzB?= =?utf-8?q?EO38hWhifE9?= 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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: etnCK1aZauHTt5SqgJ7rgZ+Fi3dUovdQVHLXp6KBSqmBt5INR1FUjE+3x20iA1/T0+ZOjVXRJSblcT44xtm/nhEtUVUwufNvAaqflTVDf1MVxaU9CgSvoSNE0GzMLjjdkJ80e22Sj6A78lY3bW2QMEi91r3v68A1hyVWfC8ViwXJHovZccD3Yh/9Da79X/6uEy0uSuBhvBO70rKWkAZgNIsXGScfTeCSF8kfGhby10R3XB12hjN51QC/GHs47Moc75uTyg3OGMoBfNFv5/M5LKSNdffHEz9qP8Rq9Ai7ya1bkv0lUhpLpaTeGyrvHAVXO7YfWU8lHfSCB0/JIeodP5u3m6+q0pSLs9FFq+n78Yzl8rrUpSXKZWUnWCuuNaoY2/UIBTm2NZEgXWRjZjv6ntmnH9fWJaANvlRa5/TVJ7p98FkjLLW16wBR2GyexPg4rJ33gIRPN/jPqQ8RUtXsp2lcd5kuaA2RdX8RsnTadXb4MEXXk++JiKaSYXDt2hXhkg6iokBsrm8VfR/j1K1t9d+agUYKHcOfxiEICy7t/kKyak9VPEEyC314kNJgcKdV4LhtqNWmnMpp1ZKEQI+8sxm5EEXvulPadaigIGa2/ptfkQHHG6wT+4v4oO/vX9Jh5lXH1ww8jAiBPQgHWf5QYQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:06.1586 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acae371d-0755-4cf9-3180-08dcca8b2bb8 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: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB7147 X-BESS-ID: 1725197829-105647-4468-37174-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.57.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGZgYGQGYGUNQ4LdXcNNXY1D DV3DLN2DDFDEiaGliaAVkpSamWhkq1sQCH/KiwQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan16-251.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 adds basic support for ring SQEs (with opcode=IORING_OP_URING_CMD). For now only FUSE_URING_REQ_FETCH is handled to register queue entries. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 3 + fs/fuse/dev_uring.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 60 ++++++++++++ include/uapi/linux/fuse.h | 38 ++++++++ 4 files changed, 332 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index fec995818a9e..998027825481 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2477,6 +2477,9 @@ const struct file_operations fuse_dev_operations = { .fasync = fuse_dev_fasync, .unlocked_ioctl = fuse_dev_ioctl, .compat_ioctl = compat_ptr_ioctl, +#ifdef CONFIG_FUSE_IO_URING + .uring_cmd = fuse_uring_cmd, +#endif }; EXPORT_SYMBOL_GPL(fuse_dev_operations); diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 4dcb4972242e..46c2274193bf 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -29,6 +29,30 @@ #include #include +static int fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) +{ + if (WARN_ON_ONCE(ent->state != FRRS_USERSPACE)) + return -EIO; + + ent->state = FRRS_COMMIT; + list_del_init(&ent->list); + + return 0; +} + +/* Update conn limits according to ring values */ +static void fuse_uring_conn_cfg_limits(struct fuse_ring *ring) +{ + struct fuse_conn *fc = ring->fc; + + /* + * This not ideal, as multiplication with nr_queue assumes the limit + * gets reached when all queues are used, but even a single queue + * might reach the limit. + */ + WRITE_ONCE(fc->max_background, ring->nr_queues * ring->max_nr_async); +} + static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, struct fuse_ring *ring) { @@ -37,6 +61,11 @@ static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, queue->qid = qid; queue->ring = ring; + spin_lock_init(&queue->lock); + + INIT_LIST_HEAD(&queue->sync_ent_avail_queue); + INIT_LIST_HEAD(&queue->async_ent_avail_queue); + for (tag = 0; tag < ring->queue_depth; tag++) { struct fuse_ring_ent *ent = &queue->ring_ent[tag]; @@ -44,6 +73,8 @@ static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, ent->tag = tag; ent->state = FRRS_INIT; + + INIT_LIST_HEAD(&ent->list); } } @@ -141,3 +172,203 @@ int fuse_uring_conn_cfg(struct file *file, void __user *argp) kvfree(ring); return res; } + +/* + * Put a ring request onto hold, it is no longer used for now. + */ +static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, + struct fuse_ring_queue *queue) + __must_hold(&queue->lock) +{ + struct fuse_ring *ring = queue->ring; + + lockdep_assert_held(&queue->lock); + + /* unsets all previous flags - basically resets */ + pr_devel("%s ring=%p qid=%d tag=%d state=%d async=%d\n", __func__, + ring, ring_ent->queue->qid, ring_ent->tag, ring_ent->state, + ring_ent->async); + + if (WARN_ON(ring_ent->state != FRRS_COMMIT)) { + pr_warn("%s qid=%d tag=%d state=%d async=%d\n", __func__, + ring_ent->queue->qid, ring_ent->tag, ring_ent->state, + ring_ent->async); + return; + } + + WARN_ON_ONCE(!list_empty(&ring_ent->list)); + + if (ring_ent->async) + list_add(&ring_ent->list, &queue->async_ent_avail_queue); + else + list_add(&ring_ent->list, &queue->sync_ent_avail_queue); + + ring_ent->state = FRRS_WAIT; +} + +/* + * fuse_uring_req_fetch command handling + */ +static int _fuse_uring_fetch(struct fuse_ring_ent *ring_ent, + struct io_uring_cmd *cmd, unsigned int issue_flags) +__must_hold(ring_ent->queue->lock) +{ + struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_ring *ring = queue->ring; + int nr_ring_sqe; + + lockdep_assert_held(&queue->lock); + + /* register requests for foreground requests first, then backgrounds */ + if (queue->nr_req_sync >= ring->max_nr_sync) { + queue->nr_req_async++; + ring_ent->async = 1; + } else + queue->nr_req_sync++; + + fuse_uring_ent_avail(ring_ent, queue); + + if (WARN_ON_ONCE(queue->nr_req_sync + + queue->nr_req_async > ring->queue_depth)) { + /* should be caught by ring state before and queue depth + * check before + */ + pr_info("qid=%d tag=%d req cnt (fg=%d async=%d exceeds depth=%zu", + queue->qid, ring_ent->tag, queue->nr_req_sync, + queue->nr_req_async, ring->queue_depth); + return -ERANGE; + } + + WRITE_ONCE(ring_ent->cmd, cmd); + + nr_ring_sqe = ring->queue_depth * ring->nr_queues; + if (atomic_inc_return(&ring->nr_sqe_init) == nr_ring_sqe) { + fuse_uring_conn_cfg_limits(ring); + ring->ready = 1; + } + + return 0; +} + +static int fuse_uring_fetch(struct fuse_ring_ent *ring_ent, + struct io_uring_cmd *cmd, unsigned int issue_flags) + __releases(ring_ent->queue->lock) +{ + struct fuse_ring *ring = ring_ent->queue->ring; + struct fuse_ring_queue *queue = ring_ent->queue; + int ret; + + /* No other bit must be set here */ + ret = -EINVAL; + if (ring_ent->state != FRRS_INIT) + goto err; + + /* + * FUSE_URING_REQ_FETCH is an initialization exception, needs + * state override + */ + ring_ent->state = FRRS_USERSPACE; + ret = fuse_ring_ring_ent_unset_userspace(ring_ent); + if (ret != 0) { + pr_info_ratelimited( + "qid=%d tag=%d register req state %d expected %d", + queue->qid, ring_ent->tag, ring_ent->state, + FRRS_INIT); + goto err; + } + + ret = _fuse_uring_fetch(ring_ent, cmd, issue_flags); + if (ret) + goto err; + + /* + * The ring entry is registered now and needs to be handled + * for shutdown. + */ + atomic_inc(&ring->queue_refs); +err: + spin_unlock(&queue->lock); + return ret; +} + +/** + * Entry function from io_uring to handle the given passthrough command + * (op cocde IORING_OP_URING_CMD) + */ +int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) +{ + const struct fuse_uring_cmd_req *cmd_req = io_uring_sqe_cmd(cmd->sqe); + struct fuse_dev *fud; + struct fuse_conn *fc; + struct fuse_ring *ring; + struct fuse_ring_queue *queue; + struct fuse_ring_ent *ring_ent = NULL; + u32 cmd_op = cmd->cmd_op; + int ret = 0; + + ret = -ENODEV; + fud = fuse_get_dev(cmd->file); + if (!fud) + goto out; + fc = fud->fc; + + ring = fc->ring; + if (!ring) + goto out; + + queue = fud->ring_q; + if (!queue) + goto out; + + ret = -EINVAL; + if (queue->qid != cmd_req->qid) + goto out; + + ret = -ERANGE; + if (cmd_req->tag > ring->queue_depth) + goto out; + + ring_ent = &queue->ring_ent[cmd_req->tag]; + + pr_devel("%s:%d received: cmd op %d qid %d (%p) tag %d (%p)\n", + __func__, __LINE__, cmd_op, cmd_req->qid, queue, cmd_req->tag, + ring_ent); + + spin_lock(&queue->lock); + ret = -ENOTCONN; + if (unlikely(fc->aborted || queue->stopped)) + goto err_unlock; + + switch (cmd_op) { + case FUSE_URING_REQ_FETCH: + ret = fuse_uring_fetch(ring_ent, cmd, issue_flags); + break; + default: + ret = -EINVAL; + pr_devel("Unknown uring command %d", cmd_op); + goto err_unlock; + } +out: + pr_devel("uring cmd op=%d, qid=%d tag=%d ret=%d\n", cmd_op, + cmd_req->qid, cmd_req->tag, ret); + + if (ret < 0) { + if (ring_ent != NULL) { + pr_info_ratelimited("error: uring cmd op=%d, qid=%d tag=%d ret=%d\n", + cmd_op, cmd_req->qid, cmd_req->tag, + ret); + + /* must not change the entry state, as userspace + * might have sent random data, but valid requests + * might be registered already - don't confuse those. + */ + } + io_uring_cmd_done(cmd, ret, 0, issue_flags); + } + + return -EIOCBQUEUED; + +err_unlock: + spin_unlock(&queue->lock); + goto out; +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 26266f923321..6561f4178cac 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -19,6 +19,15 @@ enum fuse_ring_req_state { /* request is basially initialized */ FRRS_INIT, + + /* ring entry received from userspace and it being processed */ + FRRS_COMMIT, + + /* The ring request waits for a new fuse request */ + FRRS_WAIT, + + /* request is in or on the way to user space */ + FRRS_USERSPACE, }; /* A fuse ring entry, part of the ring queue */ @@ -31,6 +40,13 @@ struct fuse_ring_ent { /* state the request is currently in */ enum fuse_ring_req_state state; + + /* is this an async or sync entry */ + unsigned int async : 1; + + struct list_head list; + + struct io_uring_cmd *cmd; }; struct fuse_ring_queue { @@ -43,6 +59,30 @@ struct fuse_ring_queue { /* queue id, typically also corresponds to the cpu core */ unsigned int qid; + /* + * queue lock, taken when any value in the queue changes _and_ also + * a ring entry state changes. + */ + spinlock_t lock; + + /* available ring entries (struct fuse_ring_ent) */ + struct list_head async_ent_avail_queue; + struct list_head sync_ent_avail_queue; + + /* + * available number of sync requests, + * loosely bound to fuse foreground requests + */ + int nr_req_sync; + + /* + * available number of async requests + * loosely bound to fuse background requests + */ + int nr_req_async; + + unsigned int stopped : 1; + /* size depends on queue depth */ struct fuse_ring_ent ring_ent[] ____cacheline_aligned_in_smp; }; @@ -79,11 +119,21 @@ struct fuse_ring { /* numa aware memory allocation */ unsigned int numa_aware : 1; + /* Is the ring read to take requests */ + unsigned int ready : 1; + + /* number of SQEs initialized */ + atomic_t nr_sqe_init; + + /* Used to release the ring on stop */ + atomic_t queue_refs; + struct fuse_ring_queue queues[] ____cacheline_aligned_in_smp; }; void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_conn_cfg(struct file *file, void __user *argp); +int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) { @@ -113,6 +163,11 @@ static inline bool fuse_uring_configured(struct fuse_conn *fc) return false; } +static inline bool fuse_per_core_queue(struct fuse_conn *fc) +{ + return fc->ring && fc->ring->per_core_queue; +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -131,6 +186,11 @@ static inline bool fuse_uring_configured(struct fuse_conn *fc) return false; } +static inline bool fuse_per_core_queue(struct fuse_conn *fc) +{ + return false; +} + #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 143ed3c1c7b3..586358e9992c 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1247,6 +1247,12 @@ struct fuse_supp_groups { #define FUSE_RING_HEADER_BUF_SIZE 4096 #define FUSE_RING_MIN_IN_OUT_ARG_SIZE 4096 +/* + * Request is background type. Daemon side is free to use this information + * to handle foreground/background CQEs with different priorities. + */ +#define FUSE_RING_REQ_FLAG_ASYNC (1ull << 0) + /** * This structure mapped onto the */ @@ -1272,4 +1278,36 @@ struct fuse_ring_req { char in_out_arg[]; }; +/** + * sqe commands to the kernel + */ +enum fuse_uring_cmd { + FUSE_URING_REQ_INVALID = 0, + + /* submit sqe to kernel to get a request */ + FUSE_URING_REQ_FETCH = 1, + + /* commit result and fetch next request */ + FUSE_URING_REQ_COMMIT_AND_FETCH = 2, +}; + +/** + * In the 80B command area of the SQE. + */ +struct fuse_uring_cmd_req { + /* User buffer */ + uint64_t buf_ptr; + + /* length of the user buffer */ + uint32_t buf_len; + + /* queue the command is for (queue index) */ + uint16_t qid; + + /* queue entry (array index) */ + uint16_t tag; + + uint32_t flags; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Sun Sep 1 13:37:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786441 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 4470B143C6C; Sun, 1 Sep 2024 13:37:15 +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=1725197840; cv=fail; b=sMvjtN5+145gOUITIpODfcjORkhgYvaxqMBf/tPTV9V9b2trLaDXmB1dl/JYVEMDioHwpihRHV3P4FRTT7hEUt6BXnuIC3wGT/Ps+dMyj+T9d0yOXapVgjHt19DEZfIzFwxthBSnnKtLNyaXZwFQzad02Z1fARkqEd6DKawbYJs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197840; c=relaxed/simple; bh=XKaocKew3lcYQPHAH8W6P7pyorB0iIVLO/jnXgQCYQo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MutYQlycVidzOzbxek2t7GDmMub/yb88K7+KaNOZGlO33m8tSjJk67oNva8rmKuruMPIeyY4gcj5lQoqKOPe9a8b4XWvIrbHDkg/28YLfvU4OYcQSDo7EdM3ZkWmMqZLwAldBJ5SRMyGD0CYi8r9CDh3TnsaZHKgA18DhVR4rIQ= 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=1PKpnwST; 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="1PKpnwST" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by mx-outbound-ea15-210.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kCX7ByqWB03kmPevpLTmKdt4rlqVTBwDxd2uG1/j1msje/o0zHDCb55stZ6e1xkjonE32SdCtqRV8xfAQSPRUc+VD4AmgaPtUNBDc7j/A9CS0uKWFhpeRJ5iAEHLOaI/lhkNS2uKd5+BivyYhaM+gjcrQ6M4lTfSLWk5/3POu1v3eQKTmN9OwvhoqdcScACgU2KTRH+pZs/uLtngLmWnbO0avp+rquUFyNoB2CizMeX/DilYETEGLImIaTnbEUBvRnIpZvBJMWHUuz0CUe3YGcF6mPiCSYQpn6p/9VPr7TWWuZON6/07A8RgGpZtaRtLQ3Ae4yNeJ4iorzUw/+HDEQ== 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=QmPiQBUvsMtW8+yplJP+3lFYxN3/0veiUZKKkafplYA=; b=WB5ic5qsSDeQNBQuRFUxI5ZZCeepoid4KfJNKFuBi9nQVGx/NcSJuLAp8EDT0BWgcD502R5pEEjx8fRGSavUSsBa7xD1BDdzWNzQb0yjQYHXQvptQvtOz2+OAV0wcgo9QG5d2FpAkYsRyNaxyghrWwUszooOMKZa3z/ExUZduEhJcVfPBM3tyGnC1bh1YnGpFmGBifZo8fjT8n//+mSSOavPZHQC2ekvNWNGLoQWElrrFGmqenyTj6+u4DRrAXJaO3mi7AMgtRIhB7Itr45vfnVk9ePmxfP6ogd4pr3mRshkW+W88aE4xK3XFDamy1g3/CcDsCtsRcVjns+VILEeiA== 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=QmPiQBUvsMtW8+yplJP+3lFYxN3/0veiUZKKkafplYA=; b=1PKpnwSTKvWSo2HDflVE4NkD2y/pXp/PbWIOZhJENhCs4rpXlct6pbp3BQDhUOmxZ5Gb1VQxuOWNQIBcMWcXILF5UkeLGjE90NRGda6YXLe3ZIhrZxpilD3+X9RzuOzNzG4/AyAp6KeQDaBeiyhOZ1hpWXxb6B6Fx4lytPnan4E= Received: from PH0PR07CA0014.namprd07.prod.outlook.com (2603:10b6:510:5::19) by PH7PR19MB7310.namprd19.prod.outlook.com (2603:10b6:510:272::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:08 +0000 Received: from CO1PEPF000075F3.namprd03.prod.outlook.com (2603:10b6:510:5:cafe::13) by PH0PR07CA0014.outlook.office365.com (2603:10b6:510:5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.21 via Frontend Transport; Sun, 1 Sep 2024 13:37:08 +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 CO1PEPF000075F3.mail.protection.outlook.com (10.167.249.42) 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:08 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 68A5BD0; Sun, 1 Sep 2024 13:37:06 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:03 +0200 Subject: [PATCH RFC v3 09/17] fuse: Make fuse_copy non static Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-9-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=3552; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=XKaocKew3lcYQPHAH8W6P7pyorB0iIVLO/jnXgQCYQo=; b=rJl1Jo9v7DfM8AkAuAI3AOmnpMN13ARZGgJIYcM9k0d50f8IQJ8tOZnIGS2TAahVN60wNtus1 Sv1qZ0i8/CJAdwoPMHI+wQge2iJFG3TJWDT+d5uHKMUKvJB6x+gnJgb X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F3:EE_|PH7PR19MB7310:EE_ X-MS-Office365-Filtering-Correlation-Id: ec3696a3-b853-4aa8-3478-08dcca8b2ce3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rzMe+2d6NeYNBxzBZIIsGGSeXNlMQk0?= =?utf-8?q?Zkw3ZSDyK84XfeuHgV+83IVY3AK0OPr/Lo4Jy5XmHt4xte7EhZ2qKh1e0XX3Xlbl4?= =?utf-8?q?RDhNFHjVKZUEH+gL5UCBPN8Z+EJ+xMHVpjXObOtTU0h8bwmelWFlROefoqnW99acp?= =?utf-8?q?CLbvnUJzvZi9M05zkldSsKfsL/zwXntIDmWDVqtH1bKuQQ7NTr3qidgpmlm021a4e?= =?utf-8?q?Ohd2Xp/1998n6z/2Nb5HBiGmNqlt6k4zsmUFByHGCsvsumuQ76TkKqdwjO1LjR1XA?= =?utf-8?q?6WwJtthd9QVYcHmzWqEc0VTeODoqGySLDW74/L0HO1y6a9baOfUc5E4ewzADIO51N?= =?utf-8?q?Elmkxfrum2hCo/LwgZVAZQ49qr+Chg4U4JqlTfLCAFtx5fnpHm9u6uztwZHh0Dcf4?= =?utf-8?q?oLYfTSjCg6wrhJbuY1vUxylXVd+mkr2pT2hRY/euyWsafGbOyVTw+T/2Soxig9Vfz?= =?utf-8?q?uYc34hER/MyJSKY3gJitfCtMo5nJBQWor1jJ7kKia8ZCfAxRF9YvWnLOHl0oTZ4Cu?= =?utf-8?q?62CZrC3uV4sN0z6iiPcBpvtz5FNS06tJOZhP5sjL4kfX8fAB1LpoETCl4Btu7FIXR?= =?utf-8?q?oc98nGpqURiPMSqx7n4UKNSzjEzUj4G/jRuynDjo6F9ew8jmHWuNIUKymxGx+MQ8h?= =?utf-8?q?cmdAyXf8QBihMQMWQeYbJ7EPaeubBRpflqD2fTUnb8jeI6bcVahdti+a5w/m4rNbV?= =?utf-8?q?Om5SqqWut/PfNTv0JtCYYxbIl+gmJyxyw9kc5jfskD2oXaJI9aA3scvcqk22v57gn?= =?utf-8?q?8qofM/RS5ZGycB17hKLPTa61WWCpFbRZjK8cjnMnA4sYU5i/du6PPT86jKrvBxlT+?= =?utf-8?q?4KOj/3/ot61enz+xaZtycE3trn7RpyE84M9Hn5c9SiXA3RMSEIOWs6Yr25MoiU6MG?= =?utf-8?q?85rQJBk8Fk1YbJvpo3x/F3IKEiRj8aQsPPbL3H4EZvShz79jE9mFy+/47o+5ftH1A?= =?utf-8?q?tehPltOL1rtRcP7OGAByHzKOKwZG4u38gl6TR4IxaYbah7u5NiMUCs+s3fMLAmkzF?= =?utf-8?q?lRTCFxu2Rs4MamxN4cfsEBvjgQFKqmSyZ+LeobBtnKwboiVJXroqhlNQhcUt4HFma?= =?utf-8?q?66DClYVhazfCSf7XgGzAd9gauGFx0OAaJQ0FsaLdcYfee8ZLGksWS8BRIli9amGPM?= =?utf-8?q?3KVDq87fa0t5faBPkgEiOvTV1jIkeIBhxZOeUq8hjUUTxmL0HtIKp5pzxNQ1mIPxN?= =?utf-8?q?ylzArHpQx0u6DefdBcqlHhf3ziRSVqOlG/D5vWSDp/MomVgXOGMwNyqHjWdVd6VxU?= =?utf-8?q?1XQPsBAA3g8Q/kyGZ98ILsMq5XKy5bnX5NlkSr3dAG5GhlMPYoC1OIDpwThGrzHmg?= =?utf-8?q?NipZsmt0/SB76kJ1Cnke19CLapeFGn9iL9+eAmtMwBgXMpQjZ6iq3tmjllcSMa4WF?= =?utf-8?q?3sK1jcuco8T?= 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)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: euwJ9ved8mXt9VcAImGHr9Uq+PtIUndxMvtC3k4xdV6sBBTAFsNO3XP+kMXefAGdPcpOJZA2J+PuHdkdZOGlFc22ALRLnqm2INtSx5+xZT6DZ0zMJ8AoTOUpTIHPFxvxvroYJRJlRFMtesm5D0KoUscUBYj+ivGfsR8Af36s+EJqrxYcIoY4dslX15ZQ2691pni3NonU7RRHBB/4AmiXT8ee0cLWGBKy2rVuWDMwfIgLZVtQTwMROuVUlREGWbA1YtFijL12Ye4/nGbQc6M49I5VK/9Orfj4IjfwI29w/FW0K9ANT6CBeQAQJlcpmWOlulCSKELTxYEznVAvzm/lsaoOc74EbBtOtisrZQ48c/bt4ckrnhnynkbiZ1OrL8IjsHAdqRxTPg9+6g2S8C5CvHk6MOBaqjbY+7fb3CfCNSt8CSamIYfU+TP52ZqZhCf5Guam/i7btQqbgiBgRnW/IuySymHKI/Nh0NoaY8pH1odZZYGe6NXeEpWnln0RFtLojuOlVPrDhjgRGLn3l9ASKfzjyh7j8nHssNZW9MQ8kJQ+H+aiWqVq+TF/xdHt7opPduzYNr+Qw+dwM5TQK9m6xVOaq4O14akxrwWaXgMFxYfYouog7fsI9xmVXdzWJZjy9MLSAdoX1pP8ZIFhJY8e9A== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:08.0714 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec3696a3-b853-4aa8-3478-08dcca8b2ce3 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: CO1PEPF000075F3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB7310 X-BESS-ID: 1725197831-104050-6777-5849-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.58.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsYmxqZAVgZQ0NLQNMkoLSUl2T TV2MgkMS0pyTTJ1DTN3MLEItE0OclUqTYWAJClDLtBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan23-79.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 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_RULE_7582B, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Move 'struct fuse_copy_state' and fuse_copy_* functions to fuse_dev_i.h to make it available for fuse-uring. 'copy_out_args()' is renamed to 'fuse_copy_out_args'. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 30 ++++++++---------------------- fs/fuse/fuse_dev_i.h | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 998027825481..9e012c902df2 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -637,22 +637,8 @@ static int unlock_request(struct fuse_req *req) return err; } -struct fuse_copy_state { - int write; - struct fuse_req *req; - struct iov_iter *iter; - struct pipe_buffer *pipebufs; - struct pipe_buffer *currbuf; - struct pipe_inode_info *pipe; - unsigned long nr_segs; - struct page *pg; - unsigned len; - unsigned offset; - unsigned move_pages:1; -}; - -static void fuse_copy_init(struct fuse_copy_state *cs, int write, - struct iov_iter *iter) +void fuse_copy_init(struct fuse_copy_state *cs, int write, + struct iov_iter *iter) { memset(cs, 0, sizeof(*cs)); cs->write = write; @@ -1006,9 +992,9 @@ static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) } /* Copy request arguments to/from userspace buffer */ -static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, - unsigned argpages, struct fuse_arg *args, - int zeroing) +int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, + unsigned argpages, struct fuse_arg *args, + int zeroing) { int err = 0; unsigned i; @@ -1874,8 +1860,8 @@ static struct fuse_req *request_find(struct fuse_pqueue *fpq, u64 unique) return NULL; } -static int copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, - unsigned nbytes) +int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, + unsigned nbytes) { unsigned reqsize = sizeof(struct fuse_out_header); @@ -1977,7 +1963,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, if (oh.error) err = nbytes != sizeof(oh) ? -EINVAL : 0; else - err = copy_out_args(cs, req->args, nbytes); + err = fuse_copy_out_args(cs, req->args, nbytes); fuse_copy_finish(cs); spin_lock(&fpq->lock); diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index e6289bafb788..0fc7a0ff7b1c 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -13,6 +13,23 @@ #define FUSE_INT_REQ_BIT (1ULL << 0) #define FUSE_REQ_ID_STEP (1ULL << 1) +struct fuse_arg; +struct fuse_args; + +struct fuse_copy_state { + int write; + struct fuse_req *req; + struct iov_iter *iter; + struct pipe_buffer *pipebufs; + struct pipe_buffer *currbuf; + struct pipe_inode_info *pipe; + unsigned long nr_segs; + struct page *pg; + unsigned int len; + unsigned int offset; + unsigned int move_pages:1; +}; + static inline struct fuse_dev *fuse_get_dev(struct file *file) { /* @@ -24,6 +41,14 @@ static inline struct fuse_dev *fuse_get_dev(struct file *file) void fuse_dev_end_requests(struct list_head *head); +void fuse_copy_init(struct fuse_copy_state *cs, int write, + struct iov_iter *iter); +int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs, + unsigned int argpages, struct fuse_arg *args, + int zeroing); +int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, + unsigned int nbytes); + #endif From patchwork Sun Sep 1 13:37:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786448 Received: from outbound-ip191b.ess.barracuda.com (outbound-ip191b.ess.barracuda.com [209.222.82.124]) (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 21C4D18306E; Sun, 1 Sep 2024 13:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197846; cv=fail; b=UHeHpQ0Q1/+sQZWBpkoaovYmM6MR1vJQN7FFOJp83dmaookG3j17IYxHGvjuA6V8vrvDU3E74FVn6dk9IXGCjMctfx1XEm4BsYwac+lCGlHEeIGTW2RMNRp61tprFdQbA2KlYLKwj+umaIMtkVgBvz8VcsUY7VHwyHUcCb4OgQ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197846; c=relaxed/simple; bh=pHDJTeiI/wATKGBye8CuRLq1KZTYS4o1p+0q2EJuG/o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pMmcGM28GeogypKyuwC3EEXtFtS3gOF+YJs4p57EXxVfFAayAMbJ5nInSpWdKJh/YPs0BXSsXZ6QnlIhdWBzr7bMv1x3PQUjZ056hdsgEbmyFwHzXnXWPmkolh1ykFgz1CWubR0Em/1SRJgwYDGPE+fndlC6UvT8ZLXAXy/cBpo= 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=Ug/gHyoK; arc=fail smtp.client-ip=209.222.82.124 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="Ug/gHyoK" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o6NWtIRXFPH3yeuhu6oEOJVX2V5UALyoyXXPI6leFGjA4i24wvH9slgy8aAmI5WALxS8vYgUpymFRFqL5VcuG76pyOKoBoZ70FZebtIaZ722sEogVoRJbsOfNPAWCoY1A8/w1uIrJM2M7Oe5wbjZBNbHqRh/+uNNFExbAJ8mqdHdur8m54a5dCmRRYON6YlKHFqFoLlx34wKs2LCzdZCK7S7XcP/Omk7Ol4DBQ+QqntmuDwNxu8V2yCd2uA5MpAhmNOoT5MB1L9txKlOgHlH4dd8VZiJnrbtmAafX3/CoahYhQmQsHAumnTRAtiO63VekQIhnLCFVC6dtfVxf+HmLQ== 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=GNAPuSxJyn5kGTojJW8+xT4Kscme4HWuBlvVW+TyX+c=; b=mbqZt/fCa8GKVtWUD6ztYcfD560s0n+EqfxAAjhjqgR2aNuDISL73c5yHbVIKcQafySFzODwf6qm510AUBnN/Mny6Qd9qwWg127TWBIJbNfUpshU9xTDdtJvzmQ69c+RLUsWreBmJ4KfxrGS6WSWvQnjRhWRThpVYBWQW/CjdZ3BnenjrE9eg65zjDODH03g+cXlwddWNqu0XYaFudxxT/UNvGVTiwlH3lAaQ1oujPdBMhPQASjFiKudD5KanozRj2Q2Dg6erkAGm9a8o4y3ZUnkHHcYtkBMayQ8Ry5i/3ujD5A6sAByTCsO45ip6sa1wKd9pft7dxhXyDxVTGtOag== 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=GNAPuSxJyn5kGTojJW8+xT4Kscme4HWuBlvVW+TyX+c=; b=Ug/gHyoKc8mRf6Q9S+Tq56S7sXDWd0XbjMwjQVKv3BZmcXvjkpIbtlCb4Emgw117kWSwd0aXGX/rqKyqfcAJAEAuhyU/1DEHWKvQ0PShn/wcHoFFT0HCt0dDEysm1dI1J9T5eCj8oAJiOBN/XIlkD0mhvjGiKrNT21q1dpN3wm8= Received: from PH7P222CA0030.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::13) by MW4PR19MB7150.namprd19.prod.outlook.com (2603:10b6:303:219::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:09 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:510:33a:cafe::20) by PH7P222CA0030.outlook.office365.com (2603:10b6:510:33a::13) 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:08 +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 MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) 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:08 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 61A96D2; Sun, 1 Sep 2024 13:37:07 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:04 +0200 Subject: [PATCH RFC v3 10/17] fuse: Add buffer offset for uring into fuse_copy_state Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-10-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=1631; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=pHDJTeiI/wATKGBye8CuRLq1KZTYS4o1p+0q2EJuG/o=; b=uU2ftzmp17X8OcPLRfclSU1nV4S9TfavdkuFAoG+cMX9F4qfdJYR+YpfPi3KJXwPgpc0An2AH RsygxXPiz8hBEA8wu+Gv7svXKmT2/gRnEZqseJNpntP4loeWLq+cA0Q X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|MW4PR19MB7150:EE_ X-MS-Office365-Filtering-Correlation-Id: f1a0c551-9662-4f6a-d3f3-08dcca8b2cf6 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?HJ0BRceYxrzM7RR+/YyEBkwoDRrPyer?= =?utf-8?q?evTCkIb/KLnPZzMQRcgrG992wqnttYrZyc6scBhN9soFT6T9ApDpMwIdN9Atbmvxr?= =?utf-8?q?IoRcNcYvk2pfN4hWjoKNExy6LQqrx7ARltv5eVtIELTiZbBlkq3DFKFz4eO8PvUOd?= =?utf-8?q?Jl4nphi6XLCzf/R8X05ma2JCL+DocDjtrQyBCSfaeqDDTppYteM7hsPvasWp61GVQ?= =?utf-8?q?3dCxBQINrPL1b2QNZfmeWpzJ5r4dEJJtnLPRaOTAgFGw8g6CcSK9Ca4SPmS8wl7K7?= =?utf-8?q?kXslWi/5GKRRzcJxve0pzVWSuhEo8eG51E1/lyvsfL4nKKxEH0jK66KYu5k6A+iAv?= =?utf-8?q?CH2PPLNpvb8XMowaBzU/QWDiTreyT/U6kzuDwUeX31I8DSjviDM+Jc+PiET7q16eI?= =?utf-8?q?EFXFZDPy9M927cro/OLgWec34rLVdIe7MqEAQToFGqHyVTjWZ8ys+nvwQrd52slY1?= =?utf-8?q?BLFjT8CU90WyrEwiqFZhIdrzSqA6DUTUpUKEMflAMrJbTV/7YXUH+mCc3KHVu5/vE?= =?utf-8?q?xYzbuODM3OkdU8nmoXO+QKRkPgeI4OLDx4vD0GYDI09mNET1dHezcbzDTEZWvAj6q?= =?utf-8?q?PHRVJSPwHK4sUbJPlznhld61NWe1f81ECpE75MVgsiLAz9y/64KrGufH/rj9nSpE5?= =?utf-8?q?pJx7Aht1cXGYpg30ozivcfZkyK2hC2DMxPaOUkpV6DN6vwKw5gZcyXK28NsmtQrmM?= =?utf-8?q?yE/x4bHzLm4aPWri6tPcDyRG7KZzcVf8+WyZ8+4vKuw/4Tt/azUZ/NVz9T8AqChCM?= =?utf-8?q?XCZ36YnvaHhzjuhHl8JZdJxiQQDVRwKDQ0UJfxSU6FuoOHoZubRKahbZ6XfVat6km?= =?utf-8?q?vmdmYkxoutrP8AOEe/BjkDEaClwEs9I15xw6m9O9VCeZ9pgSvbxFBkS9RI/19YFPM?= =?utf-8?q?XAlCDbb2o2BgsyFGkNuW5uUqTN5xBwPb5pIov6iJ/FZwuaBlpcfPrbZWOP/+qEyzM?= =?utf-8?q?1hI4vtWcKvqZ2rt1bn60GvCI6rqjsd2Kn8n858ZnQYWUVZOTJ1nKxo6BMybhxRxU7?= =?utf-8?q?bvYGFn0vdAVb4g1gvCdTUrt+TrpMusBBC2lbN+OvBVYn30/fP6vU8HzIf9HcHnga6?= =?utf-8?q?HI506euhm9I8jG9UlEV00n0GnGiuHN2dezjV6azwwZdkqnfTnyzPl1F668CQHby1B?= =?utf-8?q?fHMSyoo+CNvjN59XLqB4TFJVlJVPeQLLnLna+DtnDzg+ND9OJRhxMCSLbY2pB+GrR?= =?utf-8?q?Bmbcy0zaZuc6H4xzSN/olOGPDncYEfqIbrGXbdDLtnWEUCop6mImoSAjp38GCY1MH?= =?utf-8?q?9NcYMikPZuiLH62Sb8+Qv350w5q1CTU0lwj/HXPpImhnvZbibOCIHWOwROywUTxyB?= =?utf-8?q?DZhU68Tkushh8oBhttiH/HA5CHfyP/bFMxsL9Hy2mQeIOTYRyHnbws0fByCtbAQCu?= =?utf-8?q?mATHDwXGrgZ?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Gm9GtNIjp3MneZCgSWB8lj8MNAb5cF0LVBt2ASNv6q6l8al+uvKWvwOWiwhcbv5II5A2c71krJZlDTj2UUBL9vxXLIc1KqFkhSOmhS+s6cyHlioFhycTBIXqHbRrfzkKNNcbtElEcZuUfgJj2ieMRIG9GUOWIv6Ot6wBcnA+uCKyL2iTXZy1AmeyRF4rSNy811UQpIR8GJefLTX+G83DnxPZP6BOHGFuEh1QVSLm8uXVCwrp1dxWKuq/uRV8DkNInDl7e2fb7msTHvtjm8Ib59+FYuh/7lOI80nQHv/MoU7p60sLq4ybfCOwAs9AI+aNlWMBjDPZkSSOeaMfu1BI01aVt71PO1lMj1XsW+g1mG9/P5b15acYuHVUtoyCaoKYGndjCElZAPG3qDhQMyfq0WGsy3eXoa830AAChEQ+++wS+JHqNxvS7ATqzqpURpyS+lFnlwfBTM9F2bEAwEY5wlzJ8AML5G+tzXA2hwqu+gUZK+Y8AmFR2Q63yowH0DXiNEgAN7S+8mRL78s80OKxJgFIKVs33upVHruON/kz44OFXOSd8A8OZp10rYDZiCFnm1RzIt84CNXylrbgIfQ71LNlc/i5i2tli4t2FlYwUJz8l29hsAbh2J6dAC1N6kmpkSdpJAjWTXHUDqKKlyctcQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:08.1375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1a0c551-9662-4f6a-d3f3-08dcca8b2cf6 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: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR19MB7150 X-BESS-ID: 1725197831-105647-20973-54398-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.56.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoam5iZAVgZQMCkpycjEyCjNKD HRLNEoKc3CLM3EzMAsOdEkKTXFIMVUqTYWAIkwLMJBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan17-123.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.50 BSF_RULE_7582B META: Custom Rule 7582B X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_RULE_7582B X-BESS-BRTS-Status: 1 This is to know the size of the overall copy. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 13 ++++++++++++- fs/fuse/fuse_dev_i.h | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9e012c902df2..71443a93f1d4 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -745,6 +745,9 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) *size -= ncpy; cs->len -= ncpy; cs->offset += ncpy; + if (cs->is_uring) + cs->ring.offset += ncpy; + return ncpy; } @@ -1863,7 +1866,15 @@ static struct fuse_req *request_find(struct fuse_pqueue *fpq, u64 unique) int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, unsigned nbytes) { - unsigned reqsize = sizeof(struct fuse_out_header); + + unsigned int reqsize = 0; + + /* + * Uring has the out header outside of args + * XXX: This uring exception will probably change + */ + if (!cs->is_uring) + reqsize = sizeof(struct fuse_out_header); reqsize += fuse_len_args(args->out_numargs, args->out_args); diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 0fc7a0ff7b1c..0fbb4f28261c 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -28,6 +28,11 @@ struct fuse_copy_state { unsigned int len; unsigned int offset; unsigned int move_pages:1; + unsigned int is_uring:1; + struct { + /* overall offset with the user buffer */ + unsigned int offset; + } ring; }; static inline struct fuse_dev *fuse_get_dev(struct file *file) From patchwork Sun Sep 1 13:37:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786445 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 765B9178389; Sun, 1 Sep 2024 13:37:18 +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=1725197843; cv=fail; b=QHct1c+G83tL7ZtpmUjgkE559r3ZHyil6uWOiRD5CO09BIS/CGW2wZfnyZFgeXj+eU1B/dks34JcJP988cKegtEgYX9KJqj7qHTYSPIExQor4FmnK8/3j0iWOCz1FES/guW61eFoRZodlNOsc1bN3qA/sYcpASHTOp5YDX525hc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197843; c=relaxed/simple; bh=w0NJq/l16y0S+J6XuJP4C9FZbMOgQfXOGxgt3ADtXEw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r9R59fKZRpwyrENUujH7BE6vcuomwFkQZZ/PoSWtvNRY677mT5rSM2wqSYY2uRiaF0/zvHOPu7au+ncAngnquhhlWYsPy4InXqQ9y7FrL4jaDzDSjSVacDYdjx9vXrh30qFZk+hgxxjGG07SqPfhJeJE2SyS+OzX68G99srtaK8= 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=ZpQn4BRM; 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="ZpQn4BRM" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by mx-outbound10-30.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h0DFG3MiWF0Yx+Fi0xSQk237Ku7tXq2o2IVHvTOpmK65J9r8pVo22bemWPF9ew0PZ6XHuACo4unVx1/Su3bQ3aoVlkSE2ZphGY5/jxG0HNBrTdA1GUZz3+np8k/6LSu9DXHSu3Oqa5/8zG7bmiSbuOnOTR5WRwNg0RaFmFZfpFnd9lqlYQvsX0U9IuLZiZZWWi1+r19/QwW19xNH/6Hwd14iJCoxwlRxQbbPLolAgAgrc6Ggk6J9CWNUZ9ThS+7AIaWsmgqdVfIIMhBfaaXeccHIagULfX2PF6lMvtAaN5LKFPC8/Mqdz2cLMsyq72d9lsYWqVImjxsPFedM5EZD1A== 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=q2WC8bx3EVBfO5DeBhJ0BHqJRiE4M/E88qGR0Ivt+ac=; b=OWvRW0Txqm8ZtNcP+YRyyJPT+TQPZDTUknLl2Rqef2P7/CGLjlODS8OCmgI4InZbRnHLZM1nqUg7vh5/6jWQD3CjSRQ8p98B2l0UCQMDP/38227+kivH0YWScnFAzRNoFFByvga6mHUfiJl6wLlzeArTa42ADP9Md3rAWb7v8NhZwEeZY5HrySzs2rrnWLtfIWRX4+WXukhrbQnZvTbD+S9iHNPCX4r43yE7KhP+ConO4hFf0AYX9tDGBBxgsBgGwWBSa+nXXOW+c9e8dlvS9qwcalZ2rFXa7bkuZlRRF74woNGkwfkk6HXJE9835vIEvjzv1yvGu9Hybqj0BHIttA== 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=q2WC8bx3EVBfO5DeBhJ0BHqJRiE4M/E88qGR0Ivt+ac=; b=ZpQn4BRMfQHoaLKAVmFW1ut2KiS6/zc7B7Y+2rXOLHOpQCQw8XEgMopelAMxASnRI7jxAfp02F95Qw07NUp+fGJyU+Jy3A3SwvYMne9YB5kt0prxQzTvnSlGY1UrTj37pMl44PzrMW9mNWPILwYvjzILGI7FMNi7e5VHXe43mzs= Received: from SA9PR13CA0101.namprd13.prod.outlook.com (2603:10b6:806:24::16) by DM4PR19MB7972.namprd19.prod.outlook.com (2603:10b6:8:186::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:09 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:24:cafe::f) by SA9PR13CA0101.outlook.office365.com (2603:10b6:806:24::16) 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:09 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) 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:08 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 59FC972; Sun, 1 Sep 2024 13:37:08 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:05 +0200 Subject: [PATCH RFC v3 11/17] fuse: {uring} Add uring sqe commit and fetch support Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-11-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=15001; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=w0NJq/l16y0S+J6XuJP4C9FZbMOgQfXOGxgt3ADtXEw=; b=MeknDXt2v16jma3yhcyhslsJ6GPMmnnIMZFpkhgzOqPfekrv6j4XzDd1667Wt2OJ5niqOiHuF rDf3n3qkEUdCEcqU1pdEyaBKdtYhKPF1m6YQHL0s/KqIHVXo/YmtdP4 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|DM4PR19MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 08e4490e-8a5a-449f-d3fd-08dcca8b2d66 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?a5pNDPBOB3+tZtGhQSkZ+6ZveuJbuC5?= =?utf-8?q?kzlNV6j0tAURcZNao2UHhLpHldncj9g4MbRvQuuBbzduFQriyldzAgGmmhbeLo3Ym?= =?utf-8?q?cVODs6PWokZ1qOOCR6oYiDvKO3iihvj51YquNst7gVS3gvYdhF/12hRDe6vvS4QF2?= =?utf-8?q?5nlMqm6J9m/0ceO9qrAYH5WewT8QkzUqUfFJCNx2U8c1uO6QbBB0Jzp4Hu/3g6d4V?= =?utf-8?q?F53FvW4R3cb7HmBS26RnXs8vHIeuVjICnOQyw0A+7luPBmyteVvn4Q5woixEmh7jr?= =?utf-8?q?gRHq7rsNYaBhPPp0iVFrDgM7LZp1WOfvgQ00PaxKqpZK8rs+gD1As6/hlT9vP8ZAx?= =?utf-8?q?Qgadx3PYb8D7qm/BhROlsItLxIj9ZBrfGm+T0/RE0l4jlojiWRvctu17BFnGszFHO?= =?utf-8?q?+AN+rXxrfnDdeMGvbfHjYmLDEsxV7vRLwh5kiD943jA1gdcyaHqvUIYH+z8biSjol?= =?utf-8?q?xDk0WsiG344TBnsjZdDnXM0RBFq8ppNgUpIJE7LMmJq7YGJUwfwkMBlRQbtBVRCkh?= =?utf-8?q?pnAwmMJQ3sgBxT6UAV4rOQsYlKt7kyY7DF7HcAiunD5Q7mml+7DqjFgyXb7V4FYJl?= =?utf-8?q?tChjzpDVN0l+CulM4ZXF3s/opq6/mRlifkrhlIa+AkD9hikwVRfrAGID/xCgt6o6s?= =?utf-8?q?fgo7CmWYp8ixadYWcO1bzTmszxt6p1+te9RHW4KhJ/VQy7aJEGXvXzyIYlnMZOXRO?= =?utf-8?q?zeQp/AwwB2vLkPQ4AlRdR2EFDp1ubgD9DghSZQAh1NZR3fk7wpo2FS1n+T4ft0Vbs?= =?utf-8?q?A0AwR3+ncGdzFkh0eKMNdDt4y5UIUJD4cZcwABN5LThhPxN7If4FDHFsAoSt5wgBr?= =?utf-8?q?p5FcJufitcEq/crw1nitBVeMcLtHuObR8AUB9XzB3lLW8qLBJetF8XSu0AB3Ir1SS?= =?utf-8?q?YWDqhrUwOOFtI0dp4z5C9+LNQ3ypHsoaqkEnYI9MusLlQQVMYvF1Uw4WUmEJNFU1Q?= =?utf-8?q?h3gSGnwD66x5sfDXGqvCnoC87h8q6P31TPsHDquZwdT0+7cMmZQX2FtWt9i5ZYThT?= =?utf-8?q?ryz+JR3rT1zH4RKe5oApMDE8/6cD6LUsdys8NYWtDT5KvwL+HCLudFrY5wDGHHjCg?= =?utf-8?q?sUsDSDkWFe4yHs7F1hS0EYVMqw0VQqqh+FLNTX7PdLj6+yB541JG4qkI44xnes5fr?= =?utf-8?q?AGjeGLBdc/5NtOXQ8ZVPiFPMR+vQgYW2wXV7sD+fbW7z0Ix1LeVujfB7pgvq3VDI/?= =?utf-8?q?fTNRQcXBLVgVeu3WTZMWyzK0FOxw491LAx8iVoFv/yh9S3jALZOj8w+hccv2cB3wa?= =?utf-8?q?BrCKZw4QUzdv/HGUD00Yru6VwaIPtFm5WjfMC3u/FqFqvIHMsYZsvwT2OUJPxjJ5W?= =?utf-8?q?gMW5q1HYAw3JVrlJmAfnN8imwtBn9H0DVXOXcKMOXk72S0Hbkwdqk62rpZRVh4n6M?= =?utf-8?q?H/2efrrId+c?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: on6GYrdyO+/Rz6dXFNBAmR91jrmY7TfipeCyaAiSz1zWRuUhkwEJNfY+9gFrlZCttBcfsFbtz+szWAHK8DOmTJKp3tBxpkCcmC2eWKfATUeXOOjDVE/ImB4JPTw5JzTgN2000zbrSSRBGOHifrwo9REpLwimdhD907ujrGzB1erVRs0nRXNRNWRT/xJFJrHlYdO32vbPJMGTkDClz/G6GW7X5akf71QoKKZD13Oesmjc2krWGvt+ZV8eKxcVH05gCIRmeqQnvyKAW3L/gDlZVu92Zpb7lzn78p5O3gW7jMEDduoDtNKaLEXL/lv4l8nlSm/trpVgPJ4YaL3H0cgcZw6/at9mEY4MUzqr+X/94c1ELfyQr2wyZ8j7q328/qq2G1qLzlx6OK60sWGJP44NE8XWD2vahjRtKiNcENaH9GteZRUCP4PhkQwUJvMvSjhqhbaTs6jyAszKz3EPYZ15usa/sclWvbH2JnYmfHs/CbYmJGnd/R6SA0cITaAZw2qOVxhs7e45+IbzD5bxPGoRO+TxDm1zcYjqloC8aBKpZvuI5XwpWhySey3GStZ6gg55OGcARZ271lBciEaxAwzpZQxsMZoV6bk368LkEEDjzM4CSpahPht+GTy47oXT03LcMo6evw28ionMnjHSm/+jFQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:08.9964 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08e4490e-8a5a-449f-d3fd-08dcca8b2d66 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB7972 X-BESS-ID: 1725197830-102590-12632-7784-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.55.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYmJuYmQGYGUNTA1DTF3MzM0D TV2MAiOTHVxNQ82cAw0dLS0NQi0cjUTKk2FgAlzCdEQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan23-211.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 adds support for fuse request completion through ring SQEs (FUSE_URING_REQ_COMMIT_AND_FETCH handling). After committing the ring entry it becomes available for new fuse requests. Handling of requests through the ring (SQE/CQE handling) is complete now. Fuse request data are copied through the mmaped ring buffer, there is no support for any zero copy yet. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 407 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 21 +++ 2 files changed, 428 insertions(+) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 46c2274193bf..96347751668e 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -29,6 +29,26 @@ #include #include +struct fuse_uring_cmd_pdu { + struct fuse_ring_ent *ring_ent; +}; + +/* + * Finalize a fuse request, then fetch and send the next entry, if available + */ +static void fuse_uring_req_end(struct fuse_ring_ent *ring_ent, + bool set_err, int error) +{ + struct fuse_req *req = ring_ent->fuse_req; + + if (set_err) + req->out.h.error = error; + + clear_bit(FR_SENT, &req->flags); + fuse_request_end(ring_ent->fuse_req); + ring_ent->fuse_req = NULL; +} + static int fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) { if (WARN_ON_ONCE(ent->state != FRRS_USERSPACE)) @@ -40,6 +60,13 @@ static int fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) return 0; } +static void +fuse_uring_async_send_to_ring(struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + io_uring_cmd_done(cmd, 0, 0, issue_flags); +} + /* Update conn limits according to ring values */ static void fuse_uring_conn_cfg_limits(struct fuse_ring *ring) { @@ -65,6 +92,9 @@ static void fuse_uring_queue_cfg(struct fuse_ring_queue *queue, int qid, INIT_LIST_HEAD(&queue->sync_ent_avail_queue); INIT_LIST_HEAD(&queue->async_ent_avail_queue); + INIT_LIST_HEAD(&queue->ent_in_userspace); + INIT_LIST_HEAD(&queue->sync_fuse_req_queue); + INIT_LIST_HEAD(&queue->async_fuse_req_queue); for (tag = 0; tag < ring->queue_depth; tag++) { struct fuse_ring_ent *ent = &queue->ring_ent[tag]; @@ -173,6 +203,200 @@ int fuse_uring_conn_cfg(struct file *file, void __user *argp) return res; } +/* + * Checks for errors and stores it into the request + */ +static int fuse_uring_out_header_has_err(struct fuse_out_header *oh, + struct fuse_req *req, + struct fuse_conn *fc) +{ + int err; + + if (oh->unique == 0) { + /* Not supportd through request based uring, this needs another + * ring from user space to kernel + */ + pr_warn("Unsupported fuse-notify\n"); + err = -EINVAL; + goto seterr; + } + + if (oh->error <= -512 || oh->error > 0) { + err = -EINVAL; + goto seterr; + } + + if (oh->error) { + err = oh->error; + pr_devel("%s:%d err=%d op=%d req-ret=%d", __func__, __LINE__, + err, req->args->opcode, req->out.h.error); + goto err; /* error already set */ + } + + if ((oh->unique & ~FUSE_INT_REQ_BIT) != req->in.h.unique) { + pr_warn("Unpexted seqno mismatch, expected: %llu got %llu\n", + req->in.h.unique, oh->unique & ~FUSE_INT_REQ_BIT); + err = -ENOENT; + goto seterr; + } + + /* Is it an interrupt reply ID? */ + if (oh->unique & FUSE_INT_REQ_BIT) { + err = 0; + if (oh->error == -ENOSYS) + fc->no_interrupt = 1; + else if (oh->error == -EAGAIN) { + /* XXX Interrupts not handled yet */ + /* err = queue_interrupt(req); */ + pr_warn("Intrerupt EAGAIN not supported yet"); + err = -EINVAL; + } + + goto seterr; + } + + return 0; + +seterr: + pr_devel("%s:%d err=%d op=%d req-ret=%d", __func__, __LINE__, err, + req->args->opcode, req->out.h.error); + oh->error = err; +err: + pr_devel("%s:%d err=%d op=%d req-ret=%d", __func__, __LINE__, err, + req->args->opcode, req->out.h.error); + return err; +} + +static int fuse_uring_copy_from_ring(struct fuse_ring *ring, + struct fuse_req *req, + struct fuse_ring_ent *ent) +{ + struct fuse_ring_req __user *rreq = ent->rreq; + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + struct iov_iter iter; + int err; + int res_arg_len; + + err = copy_from_user(&res_arg_len, &rreq->in_out_arg_len, + sizeof(res_arg_len)); + if (err) + return err; + + err = import_ubuf(ITER_SOURCE, (void __user *)&rreq->in_out_arg, + ent->max_arg_len, &iter); + if (err) + return err; + + fuse_copy_init(&cs, 0, &iter); + cs.is_uring = 1; + cs.req = req; + + return fuse_copy_out_args(&cs, args, res_arg_len); +} + + /* + * Copy data from the req to the ring buffer + */ +static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, + struct fuse_ring_ent *ent) +{ + struct fuse_ring_req __user *rreq = ent->rreq; + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + int err, res; + struct iov_iter iter; + + err = import_ubuf(ITER_DEST, (void __user *)&rreq->in_out_arg, + ent->max_arg_len, &iter); + if (err) { + pr_info("Import user buffer failed\n"); + return err; + } + + fuse_copy_init(&cs, 1, &iter); + cs.is_uring = 1; + cs.req = req; + err = fuse_copy_args(&cs, args->in_numargs, args->in_pages, + (struct fuse_arg *)args->in_args, 0); + if (err) { + pr_info("%s fuse_copy_args failed\n", __func__); + return err; + } + + BUILD_BUG_ON((sizeof(rreq->in_out_arg_len) != sizeof(cs.ring.offset))); + res = copy_to_user(&rreq->in_out_arg_len, &cs.ring.offset, + sizeof(rreq->in_out_arg_len)); + err = res > 0 ? -EFAULT : res; + + return err; +} + +static int +fuse_uring_prepare_send(struct fuse_ring_ent *ring_ent) +{ + struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_ring *ring = queue->ring; + struct fuse_req *req = ring_ent->fuse_req; + int err = 0, res; + + if (WARN_ON(ring_ent->state != FRRS_FUSE_REQ)) { + pr_err("qid=%d tag=%d ring-req=%p buf_req=%p invalid state %d on send\n", + queue->qid, ring_ent->tag, ring_ent, rreq, + ring_ent->state); + err = -EIO; + } + + if (err) + return err; + + pr_devel("%s qid=%d tag=%d state=%d cmd-done op=%d unique=%llu\n", + __func__, queue->qid, ring_ent->tag, ring_ent->state, + req->in.h.opcode, req->in.h.unique); + + /* copy the request */ + err = fuse_uring_copy_to_ring(ring, req, ring_ent); + if (unlikely(err)) { + pr_info("Copy to ring failed: %d\n", err); + goto err; + } + + /* copy fuse_in_header */ + res = copy_to_user(&rreq->in, &req->in.h, sizeof(rreq->in)); + err = res > 0 ? -EFAULT : res; + if (err) + goto err; + + set_bit(FR_SENT, &req->flags); + return 0; + +err: + fuse_uring_req_end(ring_ent, true, err); + return err; +} + +/* + * Write data to the ring buffer and send the request to userspace, + * userspace will read it + * This is comparable with classical read(/dev/fuse) + */ +static int fuse_uring_send_next_to_ring(struct fuse_ring_ent *ring_ent) +{ + int err = 0; + + err = fuse_uring_prepare_send(ring_ent); + if (err) + goto err; + + io_uring_cmd_complete_in_task(ring_ent->cmd, + fuse_uring_async_send_to_ring); + return 0; + +err: + return err; +} + /* * Put a ring request onto hold, it is no longer used for now. */ @@ -206,6 +430,166 @@ static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, ring_ent->state = FRRS_WAIT; } +/* + * Assign a fuse queue entry to the given entry + */ +static void fuse_uring_add_req_to_ring_ent(struct fuse_ring_ent *ring_ent, + struct fuse_req *req) +{ + lockdep_assert_held(&ring_ent->queue->lock); + + if (WARN_ON_ONCE(ring_ent->state != FRRS_WAIT && + ring_ent->state != FRRS_COMMIT)) { + pr_warn("%s qid=%d tag=%d state=%d async=%d\n", __func__, + ring_ent->queue->qid, ring_ent->tag, ring_ent->state, + ring_ent->async); + } + list_del_init(&req->list); + clear_bit(FR_PENDING, &req->flags); + ring_ent->fuse_req = req; + ring_ent->state = FRRS_FUSE_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 *ring_ent) + __must_hold(&queue->lock) +{ + struct fuse_req *req = NULL; + struct fuse_ring_queue *queue = ring_ent->queue; + struct list_head *req_queue = ring_ent->async ? + &queue->async_fuse_req_queue : + &queue->sync_fuse_req_queue; + + lockdep_assert_held(&queue->lock); + + /* get and assign the next entry while it is still holding the lock */ + if (!list_empty(req_queue)) { + req = list_first_entry(req_queue, struct fuse_req, list); + fuse_uring_add_req_to_ring_ent(ring_ent, req); + list_del_init(&ring_ent->list); + } + + return req ? true : false; +} + +/* + * Read data from the ring buffer, which user space has written to + * 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 *ring_ent, + unsigned int issue_flags) +{ + struct fuse_ring *ring = ring_ent->queue->ring; + struct fuse_conn *fc = ring->fc; + struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_req *req = ring_ent->fuse_req; + ssize_t err = 0; + bool set_err = false; + + err = copy_from_user(&req->out.h, &rreq->out, sizeof(req->out.h)); + if (err) { + req->out.h.error = err; + goto out; + } + + err = fuse_uring_out_header_has_err(&req->out.h, req, fc); + if (err) { + /* req->out.h.error already set */ + pr_devel("%s:%d err=%zd oh->err=%d\n", __func__, __LINE__, err, + req->out.h.error); + goto out; + } + + err = fuse_uring_copy_from_ring(ring, req, ring_ent); + if (err) + set_err = true; + +out: + pr_devel("%s:%d ret=%zd op=%d req-ret=%d\n", __func__, __LINE__, err, + req->args->opcode, req->out.h.error); + fuse_uring_req_end(ring_ent, set_err, err); +} + +/* + * Get the next fuse req and send it + */ +static void fuse_uring_next_fuse_req(struct fuse_ring_ent *ring_ent, + struct fuse_ring_queue *queue) +{ + int has_next, err; + int prev_state = ring_ent->state; + + WARN_ON_ONCE(!list_empty(&ring_ent->list)); + + do { + spin_lock(&queue->lock); + has_next = fuse_uring_ent_assign_req(ring_ent); + if (!has_next) { + fuse_uring_ent_avail(ring_ent, queue); + spin_unlock(&queue->lock); + break; /* no request left */ + } + spin_unlock(&queue->lock); + + err = fuse_uring_send_next_to_ring(ring_ent); + if (err) { + ring_ent->state = prev_state; + continue; + } + + err = 0; + spin_lock(&queue->lock); + ring_ent->state = FRRS_USERSPACE; + list_add(&ring_ent->list, &queue->ent_in_userspace); + spin_unlock(&queue->lock); + } while (err); +} + +/* FUSE_URING_REQ_COMMIT_AND_FETCH handler */ +static int fuse_uring_commit_fetch(struct fuse_ring_ent *ring_ent, + struct io_uring_cmd *cmd, int issue_flags) +__releases(ring_ent->queue->lock) +{ + int err; + struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_ring *ring = queue->ring; + + err = -ENOTCONN; + if (unlikely(!ring->ready)) { + pr_info("commit and fetch, but fuse-uring is not ready."); + return err; + } + + err = -EALREADY; + if (ring_ent->state != FRRS_USERSPACE) { + pr_info("qid=%d tag=%d state %d SQE already handled\n", + queue->qid, ring_ent->tag, ring_ent->state); + return err; + } + + fuse_ring_ring_ent_unset_userspace(ring_ent); + + ring_ent->cmd = cmd; + spin_unlock(&queue->lock); + + /* without the queue lock, as other locks are taken */ + fuse_uring_commit(ring_ent, issue_flags); + + /* + * Fetching the next request is absolutely required as queued + * fuse requests would otherwise not get processed - committing + * and fetching is done in one step vs legacy fuse, which has separated + * read (fetch request) and write (commit result). + */ + fuse_uring_next_fuse_req(ring_ent, queue); + return 0; +} + /* * fuse_uring_req_fetch command handling */ @@ -250,6 +634,7 @@ __must_hold(ring_ent->queue->lock) return 0; } +/* FUSE_URING_REQ_FETCH handler */ static int fuse_uring_fetch(struct fuse_ring_ent *ring_ent, struct io_uring_cmd *cmd, unsigned int issue_flags) __releases(ring_ent->queue->lock) @@ -339,10 +724,32 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) if (unlikely(fc->aborted || queue->stopped)) goto err_unlock; + ring_ent->rreq = (void __user *)cmd_req->buf_ptr; + ring_ent->max_arg_len = cmd_req->buf_len - + offsetof(struct fuse_ring_req, in_out_arg); + ret = -EINVAL; + if (cmd_req->buf_len < ring->req_buf_sz) { + pr_info("Invalid req buf len, expected: %zd got %d\n", + ring->req_buf_sz, cmd_req->buf_len); + goto err_unlock; + } + + ring_ent->rreq = (void __user *)cmd_req->buf_ptr; + ring_ent->max_arg_len = cmd_req->buf_len - + offsetof(struct fuse_ring_req, in_out_arg); + if (cmd_req->buf_len < ring->req_buf_sz) { + pr_info("Invalid req buf len, expected: %zd got %d\n", + ring->req_buf_sz, cmd_req->buf_len); + goto err_unlock; + } + switch (cmd_op) { case FUSE_URING_REQ_FETCH: ret = fuse_uring_fetch(ring_ent, cmd, issue_flags); break; + case FUSE_URING_REQ_COMMIT_AND_FETCH: + ret = fuse_uring_commit_fetch(ring_ent, cmd, issue_flags); + break; default: ret = -EINVAL; pr_devel("Unknown uring command %d", cmd_op); diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 6561f4178cac..697963e5d524 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -26,6 +26,9 @@ enum fuse_ring_req_state { /* The ring request waits for a new fuse request */ FRRS_WAIT, + /* The ring req got assigned a fuse req */ + FRRS_FUSE_REQ, + /* request is in or on the way to user space */ FRRS_USERSPACE, }; @@ -47,6 +50,17 @@ struct fuse_ring_ent { struct list_head list; struct io_uring_cmd *cmd; + + /* fuse_req assigned to the ring entry */ + struct fuse_req *fuse_req; + + /* + * buffer provided by fuse server + */ + struct fuse_ring_req __user *rreq; + + /* struct fuse_ring_req::in_out_arg size*/ + size_t max_arg_len; }; struct fuse_ring_queue { @@ -69,6 +83,13 @@ struct fuse_ring_queue { struct list_head async_ent_avail_queue; struct list_head sync_ent_avail_queue; + /* fuse fg/bg request types */ + struct list_head async_fuse_req_queue; + struct list_head sync_fuse_req_queue; + + /* entries sent to userspace */ + struct list_head ent_in_userspace; + /* * available number of sync requests, * loosely bound to fuse foreground requests From patchwork Sun Sep 1 13:37:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786442 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 CD96913D606; Sun, 1 Sep 2024 13:37:16 +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=1725197840; cv=fail; b=DLAks0yZQtmClZARJ20onttYEXECcT8YyLBz8cnLElvhn6zPt8ArrYMo47tWxK25MbSgq8gG96Q83Fc0oDWABSsqjBIXqvgd4xPSNnzm0WKrQhITKJscqXn6MHY5F+CrcJ1jL63Wgbvco4CY1APl/fRvLnXVqDSQpQeo+K7R45Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725197840; c=relaxed/simple; bh=95qTbUW97WWpiVcnaY/Q8JPMTXK+qrrYxhYEPAZAO2U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PDHqkTVkbi7LojpG2T9Hhif5PAFziuKpPV3EPNtIu/rFtG9U3BcQm0N0338BidANmLyu9pywEkw1uGKbelB86vnUSsLRhHMFP6TQoMzrZ9A7svCy/f++5yWuxq9oOvX6EtHCRkGJzD+ow1oeJwdMvdDLtHPXxEzsE2LICkZYZTo= 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=yyqigBaV; 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="yyqigBaV" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 13:37:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wxIYnDBusKz9jigMxmLDs+AOxRngHtOhQU/ja53/9JiEOK1ArW9tC4tIxAxAJA4XeYmaEshQVz2HrgehOCeqEgrjM9UQTujwir4+rVn2VDiiOiCsdaLRdetExBCM3GB/wn5CWbtjRRBDsREVk+wTpHFsTBU2hAvG/FE0JlabJI0ydUInWew6WSgzo8lBvqgV64335EJmoLT4gF+3Yo+R7/XGnE7Yo0cJ6r01aWT4bpikUopp9hq1FfmpZJU9kZCNmf0+EaOA+dOT1vHEVIFguD69fftRVzc2Mu7FgwmQZuSnZz/LFfAJCluUN5VVHK5Jn71fsIgH8Oo9tZg8HXz8Jg== 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=IsH4lX8Q+W42yKJAe4yrQfi0tMPwtu+oohQy45fNVj0=; b=ZscJJtv5AO2FE7rUTwOijmTmtm7gURkGivjH3ifI4hJPjqAj7v91Hlx1pbRqoP4H+IumhXlXzo2eaVrlIzXDRmyl/64sNCabzzb8DI/4zyfINfAKeAgDfsJh4I8OB7pPeavVWmdYco3xjYVtHSg+YIhYsJvsDiDQitNeIIDqiy/bIkq6zsoRgwpITKhgsP2E2iceSRpEqGy+1SK25c9/AkOOuXyaeefVKjwV5XDyyYLIDrSITtAztAvuK35nzxzqK2oGLPFggMBMyG3ZfgXSGS/dqzT6Iqpns9sRjea7lXUEgf00yFhTSNRP9GpIrXmVhqX01U1OgMA5QqK4uE7WRA== 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=IsH4lX8Q+W42yKJAe4yrQfi0tMPwtu+oohQy45fNVj0=; b=yyqigBaVtjnydXCYXSL0Zu2D+Q2/FurH8RgwqX4dX9WXWHWgacPSxyB2ZJ5rOWQ23L4cHmZRFZGK1I0A1WAMJhiCxJav3oP/0Fzg6WTGsv3lRM/iXziDaoh+NBiuFNcQq+J2D3g5/K1J9GkFKjifdoKEP6I0tFhPG007a0wTIDU= Received: from BN1PR14CA0021.namprd14.prod.outlook.com (2603:10b6:408:e3::26) by SN7PR19MB7355.namprd19.prod.outlook.com (2603:10b6:806:34d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:10 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:408:e3:cafe::95) by BN1PR14CA0021.outlook.office365.com (2603:10b6:408:e3::26) 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:10 +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 MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) 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:10 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 5285ED0; Sun, 1 Sep 2024 13:37:09 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:06 +0200 Subject: [PATCH RFC v3 12/17] fuse: {uring} Handle teardown of ring entries Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-12-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=12273; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=95qTbUW97WWpiVcnaY/Q8JPMTXK+qrrYxhYEPAZAO2U=; b=p4ys6hnZIiEaJw7zE1De8tWhnCsFDucYErm1uN4RiS+ceqNxbK+BLsAattwPpp49YjYjC1zmp Dn+dtWEZpHbBdk6hZfBYa0rnT27s0xq0QZBg0GvBtSCOa3MrSe6tYDn X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|SN7PR19MB7355:EE_ X-MS-Office365-Filtering-Correlation-Id: bb5aeda8-84fa-4e8a-554b-08dcca8b2e28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?IvuS20iORpslqt+d1gwbnIm70GUdNpE?= =?utf-8?q?OozCjCk9AE9Yij2Cio/v446MsY2uJUV32G+9bnZ4pyjVzjweEhUePHsoutK/5qIsl?= =?utf-8?q?ud9tYxUOrxURSas9aYbrJplNYctrvXWB/AWxtQ2AN5pHJ+/FKsGk+27fr5NFvrdPz?= =?utf-8?q?B5pjt6XHnpF/aGlxBhzYIfmIHo4EpU0PcTCvS4M+6GL0ahfsFQsKSfC9u4veW4u26?= =?utf-8?q?l6/k4MrhSeSXZl+Cfbs3UrMP6iD/ykINJuB25WrBkOInswE+qrYv0izPR51WI2iRV?= =?utf-8?q?Cx+wme3vHDBPjPFLRyFHYtgBvqfqDP2LQINlkvkrDDbth2+ywB+KzVjlvlznS4Pfi?= =?utf-8?q?5pZcPlOU3NowVjxIythciVMpaUImdPp/3hTH1VxPtYaHqMqAPsfqlKuaUNa8X5PrL?= =?utf-8?q?WBYdb/Ha2BaE0OQf3j8DK4XNjxUouFZq/2Ub7ilsOI5lbxxb3nR6AEEV231PV9LoB?= =?utf-8?q?FGPQh9YZg/9I7mJKqjkmsxO6ZzJXJwo6vCIGitc6rqkiRhbSxsuG/CoNTrgc2/fHy?= =?utf-8?q?Vf451Gu3r/tKytxIf655IRYArSXQ9iJJkOMPrc9IEOWFvQ3/GoDQQkLhFTOAejwNZ?= =?utf-8?q?aKm6boPOuYZ1LWuac48V74U577WhrBbdZVTQMfyNfizvZr+yquSIOlTbIBalvq0J6?= =?utf-8?q?jTQ00y33W7b//WsBcVc79fEPZ31w7N/opG/zaniQALc2MTUTcVFIH7OJt+Gda5TXM?= =?utf-8?q?qbtLImCTo40L1pnOZpQ7TwWA8voVrIaVmkeCEc1QJPeKJK73xRzdg2c4hS6uJITB+?= =?utf-8?q?sFj13SrdsFT11yZ1mu9DigKLcuY/sOaYdkYpuGYC0/RPRySslDzTa37AmK/0JIGoF?= =?utf-8?q?vquGDONYbe8AWhosyWbw3NJ/HXC+zV74k0XLjeGHxe4UXH/nBS/87EMJPvxHqmtBz?= =?utf-8?q?OwxDx7e+aQDJDmSP2xAto8K/TZvZ2cDVZ3oCPzDcOR/0A2nQ6u4v8SvZhX3geZ2jx?= =?utf-8?q?f8y6zMVvGBviZEeYMpReMT8NIeRgz4Dm7wzDx//F3QwXVD1ppLn8NHDkSTAy1AXoC?= =?utf-8?q?Rw7H4gjnLi320I/au3Rhmnl0xZ780kUJ5Q7EqfaO6lu8Z4ddkMkmZ5sueny8/ezax?= =?utf-8?q?QlNcNgO8WpygMxTMhQFc8iih2OMUyDbBM/7Vv8vT1/xjVwGEsfBRN0oq+bu7pX5g8?= =?utf-8?q?fjYjEkAd02mVBykANynMzKCyKOyj74Xv9JbIurThUG+iWi5ZmlbrWXNaE7uvBL5m1?= =?utf-8?q?VGxyXKW0RmV2O8k1hHyIfybm6PiuM/XyjT85zPm39pm8bG0/6KB9bQKP+xZmv+Xau?= =?utf-8?q?7pUzGocCA4uZXHBPvA3zx3x272uQDHzfzi+td8s94kzPkkjQr0IpTyU/RER4fMFwQ?= =?utf-8?q?eDqwoj7zbL+ClpDLp2GJxhH2K8qYxIPCLVGlbjEJLUsf2zXn0j7HCedAuP4S4F3Ku?= =?utf-8?q?X8sCdZA5HsY?= 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)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kBOqrXnqbsP4ct3Y8wAUfr7qCSOJDwYDtKXObwGPHEbw1Tq9eS+NdXcoC2woL5NQ/rAX2skCOjPPK4+ws5YiGCaDRJSaR6UTCDOJuXPkUB6BR5d83gqkOP/B0otKKqTJ8nhox7SjjWUmLgaW/5GmhML3mKFcGJzsK3vdWNPftjU5imhrpUGoUiXBxf8Z+g0wopYOehROAgETfNgw5z35xyFslz02Oze42eZrT/t8h83puI0/xHJn/yj4ogJJ+V1qO/cUBrwZOYY2I7wiVeMKsnFMJ1fvIHAqMOthnbr/cwcrBVkb5uKFyX1nVUZZ8G/IkHlib+rR/HOvwKkh2vfsvUWtg63xQNQXWh0rxoZu8YUgp9l251ja1khBFFS/B0SSUtaFgteFuybD1EaNM2PUUuuLxgNtSJz59kQw2VZVH2KHQlfUxdf4l/2FwSmylmFuiLTDFyyHjDy9z7Yt5iqrApZMLHjF9txEqTD1Iob4QEGDszXTCSJZwM9ALJ16XxY+fwt8+O2ML7YtibtPHODfzuarSrjhllAvyNxAwEPTUJ5nIO+X+MOiq/I4iZnTCS+dnRchEe3XmF4F10qBaHrs0lzNRCIU4bvxCxxRevrao03KbBsx8kP0MWs2EWD4yWrDDalbPM7Uhu7Wjx8XgzmiFw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:10.2021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb5aeda8-84fa-4e8a-554b-08dcca8b2e28 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: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR19MB7355 X-BESS-ID: 1725197832-105647-21816-50042-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.58.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGFiYmQGYGUDQ50dg4xTTRxD wpzSTRONnIwNQiySItydgoJS0lJSnJSKk2FgD9VheCQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258743 [from cloudscan9-142.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 On teardown struct file_operations::uring_cmd requests need to be completed by calling io_uring_cmd_done(). Not completing all ring entries would result in busy io-uring tasks giving warning messages in intervals and unreleased struct file. Additionally the fuse connection and with that the ring can only get released when all io-uring commands are completed. Completion is done with ring entries that are a) in waiting state for new fuse requests - io_uring_cmd_done is needed b) already in userspace - io_uring_cmd_done through teardown is not needed, the request can just get released. If fuse server is still active and commits such a ring entry, fuse_uring_cmd() already checks if the connection is active and then complete the io-uring itself with -ENOTCONN. I.e. special handling is not needed. This scheme is basically represented by the ring entry state FRRS_WAIT and FRRS_USERSPACE. Entries in state: - FRRS_INIT: No action needed, do not contribute to ring->queue_refs yet - All other states: Are currently processed by other tasks, async teardown is needed and it has to wait for the two states above. It could be also solved without an async teardown task, but would require additional if conditions in hot code paths. Also in my personal opinion the code looks cleaner with async teardown. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 10 +++ fs/fuse/dev_uring.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 81 +++++++++++++++++++++ 3 files changed, 287 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 71443a93f1d4..3485752e25aa 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2190,6 +2190,8 @@ void fuse_abort_conn(struct fuse_conn *fc) fc->connected = 0; spin_unlock(&fc->bg_lock); + fuse_uring_set_stopped(fc); + fuse_set_initialized(fc); list_for_each_entry(fud, &fc->devices, entry) { struct fuse_pqueue *fpq = &fud->pq; @@ -2233,6 +2235,12 @@ void fuse_abort_conn(struct fuse_conn *fc) spin_unlock(&fc->lock); fuse_dev_end_requests(&to_end); + + /* + * fc->lock must not be taken to avoid conflicts with io-uring + * locks + */ + fuse_uring_abort(fc); } else { spin_unlock(&fc->lock); } @@ -2244,6 +2252,8 @@ void fuse_wait_aborted(struct fuse_conn *fc) /* matches implicit memory barrier in fuse_drop_waiting() */ smp_mb(); wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); + + fuse_uring_wait_stopped_queues(fc); } int fuse_dev_release(struct inode *inode, struct file *file) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 96347751668e..52e2323cc258 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -67,6 +67,41 @@ fuse_uring_async_send_to_ring(struct io_uring_cmd *cmd, io_uring_cmd_done(cmd, 0, 0, issue_flags); } +/* Abort all list queued request on the given ring queue */ +static void fuse_uring_abort_end_queue_requests(struct fuse_ring_queue *queue) +{ + struct fuse_req *req; + LIST_HEAD(sync_list); + LIST_HEAD(async_list); + + spin_lock(&queue->lock); + + list_for_each_entry(req, &queue->sync_fuse_req_queue, list) + clear_bit(FR_PENDING, &req->flags); + list_for_each_entry(req, &queue->async_fuse_req_queue, list) + clear_bit(FR_PENDING, &req->flags); + + list_splice_init(&queue->async_fuse_req_queue, &sync_list); + list_splice_init(&queue->sync_fuse_req_queue, &async_list); + + spin_unlock(&queue->lock); + + /* must not hold queue lock to avoid order issues with fi->lock */ + fuse_dev_end_requests(&sync_list); + fuse_dev_end_requests(&async_list); +} + +void fuse_uring_abort_end_requests(struct fuse_ring *ring) +{ + int qid; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + fuse_uring_abort_end_queue_requests(queue); + } +} + /* Update conn limits according to ring values */ static void fuse_uring_conn_cfg_limits(struct fuse_ring *ring) { @@ -124,6 +159,8 @@ static int _fuse_uring_conn_cfg(struct fuse_ring_config *rcfg, ring->queue_size = queue_sz; + init_waitqueue_head(&ring->stop_waitq); + fc->ring = ring; ring->fc = fc; @@ -203,6 +240,165 @@ int fuse_uring_conn_cfg(struct file *file, void __user *argp) return res; } +static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) +{ + struct fuse_req *req = ent->fuse_req; + + ent->fuse_req = NULL; + clear_bit(FR_SENT, &req->flags); + req->out.h.error = -ECONNABORTED; + fuse_request_end(req); +} + +/* + * Release a request/entry on connection tear down + */ +static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, + bool need_cmd_done) +{ + struct fuse_ring_queue *queue = ent->queue; + + /* + * fuse_request_end() might take other locks like fi->lock and + * can lead to lock ordering issues + */ + lockdep_assert_not_held(&ent->queue->lock); + + if (need_cmd_done) { + pr_devel("qid=%d tag=%d sending cmd_done\n", queue->qid, + ent->tag); + + io_uring_cmd_done(ent->cmd, -ENOTCONN, 0, + IO_URING_F_UNLOCKED); + } + + if (ent->fuse_req) + fuse_uring_stop_fuse_req_end(ent); + + ent->state = FRRS_FREED; +} + +static void fuse_uring_stop_list_entries(struct list_head *head, + struct fuse_ring_queue *queue, + enum fuse_ring_req_state exp_state) +{ + struct fuse_ring *ring = queue->ring; + struct fuse_ring_ent *ent, *next; + ssize_t queue_refs = SSIZE_MAX; + LIST_HEAD(to_teardown); + + spin_lock(&queue->lock); + list_for_each_entry_safe(ent, next, head, list) { + if (ent->state != exp_state) { + pr_warn("entry teardown qid=%d tag=%d state=%d expected=%d", + queue->qid, ent->tag, ent->state, exp_state); + continue; + } + + list_move(&ent->list, &to_teardown); + } + spin_unlock(&queue->lock); + + /* no queue lock to avoid lock order issues */ + list_for_each_entry_safe(ent, next, &to_teardown, list) { + bool need_cmd_done = ent->state != FRRS_USERSPACE; + + fuse_uring_entry_teardown(ent, need_cmd_done); + queue_refs = atomic_dec_return(&ring->queue_refs); + + if (WARN_ON_ONCE(queue_refs < 0)) + pr_warn("qid=%d queue_refs=%zd", queue->qid, + queue_refs); + } +} + +static void fuse_uring_stop_queue(struct fuse_ring_queue *queue) +{ + fuse_uring_stop_list_entries(&queue->ent_in_userspace, queue, + FRRS_USERSPACE); + fuse_uring_stop_list_entries(&queue->async_ent_avail_queue, queue, + FRRS_WAIT); + fuse_uring_stop_list_entries(&queue->sync_ent_avail_queue, queue, + FRRS_WAIT); +} + +/* + * Log state debug info + */ +static void fuse_uring_log_ent_state(struct fuse_ring *ring) +{ + int qid, tag; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + for (tag = 0; tag < ring->queue_depth; tag++) { + struct fuse_ring_ent *ent = &queue->ring_ent[tag]; + + if (ent->state != FRRS_FREED && ent->state != FRRS_INIT) + pr_info("ring=%p qid=%d tag=%d state=%d\n", + ring, qid, tag, ent->state); + } + } + ring->stop_debug_log = 1; +} + +static void fuse_uring_async_stop_queues(struct work_struct *work) +{ + int qid; + struct fuse_ring *ring = + container_of(work, struct fuse_ring, async_teardown_work.work); + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + fuse_uring_stop_queue(queue); + } + + /* + * Some ring entries are might be in the middle of IO operations, + * i.e. in process to get handled by file_operations::uring_cmd + * or on the way to userspace - we could handle that with conditions in + * run time code, but easier/cleaner to have an async tear down handler + * If there are still queue references left + */ + if (atomic_read(&ring->queue_refs) > 0) { + if (time_after(jiffies, + ring->teardown_time + FUSE_URING_TEARDOWN_TIMEOUT)) + fuse_uring_log_ent_state(ring); + + schedule_delayed_work(&ring->async_teardown_work, + FUSE_URING_TEARDOWN_INTERVAL); + } else { + wake_up_all(&ring->stop_waitq); + } +} + +/* + * Stop the ring queues + */ +void fuse_uring_stop_queues(struct fuse_ring *ring) +{ + int qid; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + fuse_uring_stop_queue(queue); + } + + if (atomic_read(&ring->queue_refs) > 0) { + pr_info("ring=%p scheduling async queue stop\n", ring); + ring->teardown_time = jiffies; + INIT_DELAYED_WORK(&ring->async_teardown_work, + fuse_uring_async_stop_queues); + schedule_delayed_work(&ring->async_teardown_work, + FUSE_URING_TEARDOWN_INTERVAL); + } else { + wake_up_all(&ring->stop_waitq); + } +} + /* * Checks for errors and stores it into the request */ diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 697963e5d524..432465d4bfce 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -14,6 +14,9 @@ /* IORING_MAX_ENTRIES */ #define FUSE_URING_MAX_QUEUE_DEPTH 32768 +#define FUSE_URING_TEARDOWN_TIMEOUT (5 * HZ) +#define FUSE_URING_TEARDOWN_INTERVAL (HZ/20) + enum fuse_ring_req_state { FRRS_INVALID = 0, @@ -31,6 +34,9 @@ enum fuse_ring_req_state { /* request is in or on the way to user space */ FRRS_USERSPACE, + + /* request is released */ + FRRS_FREED, }; /* A fuse ring entry, part of the ring queue */ @@ -143,17 +149,32 @@ struct fuse_ring { /* Is the ring read to take requests */ unsigned int ready : 1; + /* + * Log ring entry states onces on stop when entries cannot be + * released + */ + unsigned int stop_debug_log : 1; + /* number of SQEs initialized */ atomic_t nr_sqe_init; /* Used to release the ring on stop */ atomic_t queue_refs; + wait_queue_head_t stop_waitq; + + /* async tear down */ + struct delayed_work async_teardown_work; + + /* log */ + unsigned long teardown_time; + struct fuse_ring_queue queues[] ____cacheline_aligned_in_smp; }; void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_conn_cfg(struct file *file, void __user *argp); +void fuse_uring_stop_queues(struct fuse_ring *ring); int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) @@ -189,6 +210,55 @@ static inline bool fuse_per_core_queue(struct fuse_conn *fc) return fc->ring && fc->ring->per_core_queue; } +static inline void fuse_uring_set_stopped_queues(struct fuse_ring *ring) +{ + int qid; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + spin_lock(&queue->lock); + queue->stopped = 1; + spin_unlock(&queue->lock); + } +} + +/* + * Set per queue aborted flag + */ +static inline void fuse_uring_set_stopped(struct fuse_conn *fc) + __must_hold(fc->lock) +{ + if (fc->ring == NULL) + return; + + fc->ring->ready = false; + + fuse_uring_set_stopped_queues(fc->ring); +} + +static inline void fuse_uring_abort(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + + if (ring == NULL) + return; + + if (atomic_read(&ring->queue_refs) > 0) { + fuse_uring_abort_end_requests(ring); + fuse_uring_stop_queues(ring); + } +} + +static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + + if (ring) + wait_event(ring->stop_waitq, + atomic_read(&ring->queue_refs) == 0); +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -212,6 +282,17 @@ static inline bool fuse_per_core_queue(struct fuse_conn *fc) return false; } +static inline void fuse_uring_set_stopped(struct fuse_conn *fc) +{ +} + +static inline void fuse_uring_abort(struct fuse_conn *fc) +{ +} + +static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) +{ +} #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ From patchwork Sun Sep 1 13:37:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786486 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 3075014A4FF for ; Sun, 1 Sep 2024 14:11:59 +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=1725199922; cv=fail; b=ksknuTgSpkns4zjtrKwfw/lGqBYB4wQ+ojgGpqAMr3b86HVoobbXj3fhHIrgfnfE6/nEh0VZNemgEAUlCa0XMKrTNOFiuY0MIy4ZZoCRAzBgbu1FLNi+qK+Su1BXToXDHjOjF44gyF8/Or5S29yP2y5dNycU+UjEDD6NCqHuvnI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725199922; c=relaxed/simple; bh=48GPYOKOv8QstAokuDa8NlonP/TjSLahD8Y3o5cLiWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i83ezMBwGVSMuTedjkJJo8SWgTWnzgCetlMbeGQryMbiP3mhIgv1l5AwVDOsaFhdVD32s24OFBfUzFRO02KmrAShHQof6pGMQcqG74KQ5ylbiSn1e2eh1TNhIzuk7qPEEB7an50thCUyd4n/h3+CqAFgniABf1C0oB706+2L3NA= 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=1k0DCccb; 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="1k0DCccb" Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by mx-outbound45-16.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 14:11:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LGldjW+pdnw382ICfhaKojonegL6xgGsl5HOIfTR7XJVyhH9NmYZOMlG4xdMF1GSMs1CIq+9OoM5pPIBGvnClNPU0iuC/TVg2xXDll8ZuQuzUTLn/ofXg4mh00Ei6XlI3z8yp3EqR/29FsKicvIhRmJqnKM30l9g98Pm9Q/LDcw/wqR9UzmVtMlmKrjWwDaKy+xxHmvLqaaej+PEH+7MHY62Vqe2hqnupS2QMWiyWJyr2Xyj4MKpQ4B24ZRQN1/WPvVaWNXAvcGCdcqoeC4WV6MRlm729RsWQIBVy7jkfV8EjG5kkSELMM4KPjcPWs8+v5qdBhnGHNlTd6jXHKLG5g== 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=HQOtdUiFVUeg27JJdVwU6S2ZUaMwoGj91RAVXoW+FYo=; b=ig0pHTD2DAeGozWCnV8QM5ewQGfQRB7Uf+aO67YIwxD4qD8x4rYzX2DC9zu6HyNk5zMT9ek+QgOUpFTV2vZxuzfegncjrkn/VcHgqrRQa0rIvWWeCroyskuZbcKIN6stlzGBq3MymGk1vWxZFdAisqEPaypuPhJ4ORKlZP3KH/D5u9F39WOnP97ZARYYwo/A7JHqHJDGz6k5j/Pt10BCbqDYh5gDCyUL6RBCDPh4Bga3txstC7N8G61E9pD7D4C/waJ5lwSvVbKH4c1j+uohqDhWW6p/R0E4EJBN0iDVy56kG+yyguebFb3ZgO7FbjeVdiXsN8b4GUODmLf8twaI9w== 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=HQOtdUiFVUeg27JJdVwU6S2ZUaMwoGj91RAVXoW+FYo=; b=1k0DCccbhRsrIs88UJmI0oQmqGpZjxw88FiMcUawoV4fgK1kUmF8VM/J7pFPaUEYlc3MeQ19VAcx0vfUUtGelled/QCByfyHcWx2qE8BHhK+q6vzGKLrjvqsLIXENVaAT5jVk9rDEQmmg3wxcig64jI9YiZT8YaLbiRBFXdUPNA= Received: from SJ0PR05CA0081.namprd05.prod.outlook.com (2603:10b6:a03:332::26) by PH7PR19MB5750.namprd19.prod.outlook.com (2603:10b6:510:1d1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:11 +0000 Received: from SJ5PEPF000001CA.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::b4) by SJ0PR05CA0081.outlook.office365.com (2603:10b6:a03:332::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24 via Frontend Transport; Sun, 1 Sep 2024 13:37:11 +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 SJ5PEPF000001CA.mail.protection.outlook.com (10.167.242.39) 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:10 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 4B26372; Sun, 1 Sep 2024 13:37:10 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:07 +0200 Subject: [PATCH RFC v3 13/17] fuse: {uring} Add a ring queue and send method Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-13-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=4710; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=48GPYOKOv8QstAokuDa8NlonP/TjSLahD8Y3o5cLiWU=; b=UScpLiDFoG2eYQJr7xRap+gaF572Z5o5JdLBVXHRhwA0nNLk6nQcaPDaFp6Z2C6+SUNNKCA5F /WvOtmURGw8DbDogm7V/S+NYAVTsELyHp8rnOFa0dy+KhUeW6wgBiCE X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CA:EE_|PH7PR19MB5750:EE_ X-MS-Office365-Filtering-Correlation-Id: c1acfc8e-f83d-40df-0479-08dcca8b2e9b 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?WkPuJsYbDTXOKimlgGAAtOFKaiJh7oQ?= =?utf-8?q?OZddEx1hyiqDxVK9yk6ZmwAFabqGzu8+YJlH8crEsQytpWhq85ahIkVJOYx7V2gbk?= =?utf-8?q?7tzhygVmQhQjORPCnIjKL/hhUyMDm/SkOLWtpDjeza8XiVti8ybExe1ywVSZkWIRu?= =?utf-8?q?x3iZ4/bOpMmySzATFgWl33r76RKo12m3AvIxCOJuATyy8DpT2VpQKgdn1NVG74GJj?= =?utf-8?q?IbICj1a/Hbw3IE6+Cd6KTeDU+cvfC5gmzRk+8J/JSnm80nr3TAiUXL/nhy2v2Xf9m?= =?utf-8?q?617hK7GWLvh40gADjgl/3olYFtckOTW9RHykf2HtM5D/95X9xDbrrhB0bzVGK2hN1?= =?utf-8?q?am5g4jYq21Aor6rdF6DtR1XP0O1JriIHIb3jJDU0kT8vcUecBJCjkO2RAmg7Up7vZ?= =?utf-8?q?u4tZJsv0C6n09jrPXdBKGrOSAA18jJJLPmlWmJCjMAN5MSB6YKJYbhncwNhq7srVH?= =?utf-8?q?fWU2VNH4s9CeoZM5JZEgdfq/hjJV/OwKg9boQnslofQBxl8Ny8PXRGXvCla0KikMa?= =?utf-8?q?p6QBOkJs5T1/18XQAD2+dI01CdJEhFTBp/AFkMqysbb85VEoxYt9kwLfadcd54UP6?= =?utf-8?q?USYT1Do27o73BIYNq80zcf6A0B4yG4LvBzptFc+Xc4dzZDFEFNLj6+zgf5pOzJrsc?= =?utf-8?q?mChluS3woKweYDETc8YMiKfvX/1HG5kYe4fEDYa8Q9iThd40PhtiVFqAjA5ma1Fgs?= =?utf-8?q?a5HUnLf6AioyQ7bHvQtl8ufTMX0kB13UbpyeSItKw8U0hjcqPxPASHjV3sxd3agNg?= =?utf-8?q?hDpD1xOsszJONubtX+bnpfR57cv4zEYG1qxdFOPu00fqCIqe9BepjdK0mm9oYh0lY?= =?utf-8?q?wzQdgAU42TpYB9R+N19frEvYMSPt1f2Mz9sYjSeItDk/heo3sVYngAVi0GMbOVIaf?= =?utf-8?q?nlUQPYjS0YrhPRNw4REDbf1zhsiWWsxMb7pijTbB5F7DS6kEUFtVd+h7ljqVjVkg5?= =?utf-8?q?rWvFkkJ3flw9Fe01uXXYewzRDRItE7/AuPCeHMsA/PE9aBJMsoFQY61jeKd2KldYu?= =?utf-8?q?LmjRL7Ybl0NCsYvA1NL+xOM27lUD6r/13n1xkeB6l7xaBiFQi/IsET+pjFzEV0C6I?= =?utf-8?q?RaDyZavels0XrvRBSbpF0x/lPQI3OiPl5K6FUi6DG2Xf4bZmoCHbhHv+h0I8XtqVT?= =?utf-8?q?si5uoidpHJtKjwvR5Xwdobhxt6ZhCGCKH0PM3nvji1hbwA4TtaMzLGqDHtSPJpl52?= =?utf-8?q?sFsqYlwRkO01I5uNi23E0+7iZBvcprHJSdz74DvsHlT9gOPN8ZPbJOZae3fTvVy0x?= =?utf-8?q?7NdyZxESGPWiN46YFaG8EyKjkBlo/iEXGHMhctMyGBFYZMK9nONnSv7h2sXRZbUFu?= =?utf-8?q?4qnXzbOaiPMQVMvaMy8kNhboenq0RVO2iqxTv/vXrAtVWUJQHVgnB+GuGFKO4uTn7?= =?utf-8?q?sQbPF5rYXzk?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: e4SAmlVj6P7sIvaXZB8jUcRLri4pjT8QGz8rqP+4hMoldIsHoRN3X56vRlMPJUM13E18uKi4b9a7yeW3ybMut+Gy5oO4tvXWOrecA60HayEwTniVpBo1qumD+U/Kw2QE78oo9O4uDd/yjt4wx7MmfR+NuumsQRTl8AC31PcC+fwSe9Xt51+GxU09sNAJ9tB+ZpKJ/X9fVlFNwPywcfjAKDE+6o40XaBbrkON0gNe0h6TuAi0SlG6D1ZQAQjDHZx6q5J5+0fQE0Yi/beWLB/Qxz7Jtgnz62ERHeWd9Soce0yGGw04qtyT8u+NUSxARaitoQDgSqA9gePkg3GXc1CPOsB037nsw/hkwkKWBTrGJaLzUcG7uqqrW0lS5ex1JFS38yY5k9rKL+QlL1h0hJ85zqBQvx51irTjCh0OsJ1y7iId7twDvXpWX+jNF0a6ItXm2p3LuYZISafWkj4XmkFZyodVqczr1UJIRNCNXqYvzJT0HmGM6ou+OysH25KIaAwGvr42UA0yXvEhlR+VcmRZ9E3RRf+HyC7pFoygo+9X/u+XzNsmUPnEOiMzkQ/5JJdhbRttymssisKdFuDeEDsERVFUSOw6dWWf6YV6W4u3kjotQtixR0LfM9boP0KnDP0pSzjrB/SJggykFylySaPRcg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:10.9850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1acfc8e-f83d-40df-0479-08dcca8b2e9b 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: SJ5PEPF000001CA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB5750 X-OriginatorOrg: ddn.com X-BESS-ID: 1725199918-111536-13527-71134-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.51.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViamZsZAVgZQ0CzNwjjJNNHSwN IiMTkxxcLSLC0xzTLFwNzAIs0wNclSqTYWALB0aLpBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258744 [from cloudscan22-227.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_SC0_MISMATCH_TO X-BESS-BRTS-Status: 1 This prepares queueing and sending through io-uring. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 7 ++++ 2 files changed, 111 insertions(+) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 52e2323cc258..43e7486d9f93 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -975,3 +975,107 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) spin_unlock(&queue->lock); goto out; } + +/* + * This prepares and sends the ring request in fuse-uring task context. + * User buffers are not mapped yet - the application does not have permission + * to write to it - this has to be executed in ring task context. + * XXX: Map and pin user paged and avoid this function. + */ +static void +fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + struct fuse_uring_cmd_pdu *pdu = (struct fuse_uring_cmd_pdu *)cmd->pdu; + struct fuse_ring_ent *ring_ent = pdu->ring_ent; + struct fuse_ring_queue *queue = ring_ent->queue; + int err; + + BUILD_BUG_ON(sizeof(pdu) > sizeof(cmd->pdu)); + + err = fuse_uring_prepare_send(ring_ent); + if (err) + goto err; + + io_uring_cmd_done(cmd, 0, 0, issue_flags); + + spin_lock(&queue->lock); + ring_ent->state = FRRS_USERSPACE; + list_add(&ring_ent->list, &queue->ent_in_userspace); + spin_unlock(&queue->lock); + + return; +err: + fuse_uring_next_fuse_req(ring_ent, queue); +} + +/* queue a fuse request and send it if a ring entry is available */ +int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) +{ + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + int qid = 0; + struct fuse_ring_ent *ring_ent = NULL; + int res; + bool async = test_bit(FR_BACKGROUND, &req->flags); + struct list_head *req_queue, *ent_queue; + + if (ring->per_core_queue) { + /* + * async requests are best handled on another core, the current + * core can do application/page handling, while the async request + * is handled on another core in userspace. + * For sync request the application has to wait - no processing, so + * the request should continue on the current core and avoid context + * switches. + * XXX This should be on the same numa node and not busy - is there + * a scheduler function available that could make this decision? + * It should also not persistently switch between cores - makes + * it hard for the scheduler. + */ + qid = task_cpu(current); + + if (WARN_ONCE(qid >= ring->nr_queues, + "Core number (%u) exceeds nr ueues (%zu)\n", + qid, ring->nr_queues)) + qid = 0; + } + + queue = fuse_uring_get_queue(ring, qid); + req_queue = async ? &queue->async_fuse_req_queue : + &queue->sync_fuse_req_queue; + ent_queue = async ? &queue->async_ent_avail_queue : + &queue->sync_ent_avail_queue; + + spin_lock(&queue->lock); + + if (unlikely(queue->stopped)) { + res = -ENOTCONN; + goto err_unlock; + } + + list_add_tail(&req->list, req_queue); + + if (!list_empty(ent_queue)) { + ring_ent = + list_first_entry(ent_queue, struct fuse_ring_ent, list); + list_del_init(&ring_ent->list); + fuse_uring_add_req_to_ring_ent(ring_ent, req); + } + spin_unlock(&queue->lock); + + if (ring_ent != NULL) { + struct io_uring_cmd *cmd = ring_ent->cmd; + struct fuse_uring_cmd_pdu *pdu = + (struct fuse_uring_cmd_pdu *)cmd->pdu; + + pdu->ring_ent = ring_ent; + io_uring_cmd_complete_in_task(cmd, fuse_uring_send_req_in_task); + } + + return 0; + +err_unlock: + spin_unlock(&queue->lock); + return res; +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 432465d4bfce..d9988d4beeed 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -176,6 +176,7 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_conn_cfg(struct file *file, void __user *argp); void fuse_uring_stop_queues(struct fuse_ring *ring); int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); +int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req); static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) { @@ -293,6 +294,12 @@ static inline void fuse_uring_abort(struct fuse_conn *fc) static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) { } + +static inline int +fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) +{ + return -EPFNOSUPPORT; +} #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ From patchwork Sun Sep 1 13:37:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786512 Received: from outbound-ip191b.ess.barracuda.com (outbound-ip191b.ess.barracuda.com [209.222.82.124]) (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 A46AB3CF7E for ; Sun, 1 Sep 2024 15:08:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725203320; cv=fail; b=GGXcA1E+4Rf1o9OCvF3MS4/mS1+uxPUD240pqwr5+izCV3H8EfRR9QEvri/hGBPZFaSwlWaSSSSrDt9ttzyGi2ny48iVSoW0QDblcmbXUDgk+AnY9NfpWTSPiWbK8HKX64Z9qi3Y/wEw+7JD98wUTVAT8PKuL1CEFPkhDf/ifQI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725203320; c=relaxed/simple; bh=WO9U9Vi16OvjSCHwWmwvrGaz8Wfi1w9JwEePyqVl2RM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YWb7Z0mKP9fxXsMbXCgOcSgZWsmpM+kBVzgGbcvjsO2YkkKSlNcUpFhmt+JNmHELPD5OrTSjB9qlJwIbbmPUDzuHEVNRk4ekhHKGiTTaD+eus5wpafLhxcYPO3NbeucIYeXEO9VzFvTKVX8CWT5uz6a4mBFlZJdOUqCFeMuGK0g= 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=JDUR1uE5; arc=fail smtp.client-ip=209.222.82.124 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="JDUR1uE5" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 15:08:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XPWtx0VrLiuPirkA5+dpxK4vwjVdGbAXlUnimWwc8UhQD6GJERLp+EF7oECGO8eE1p0wsw84M4u3hIxklyOeaDxnHudVKXpJkxOFDNwTKBQgrs/RaZnQ5m/+1d55yV33NM/3LDOWkKPWMnm/8MCwferPaL/Tor2aMzILBKs5YhPpPjGXAlfugwQS9wGDz5IHOaJevUH1L4RQoZ6LWK4zAmze0lLGTSMAomiK82Hurk7I0+lENRSz3zof8qDM8Kjh29npHsC5gsTKCsFDehH6UF/cbvOtE73YlKGA3OQMkCbYLtVobb4X/KucbsmKHtTSJRxcy+CviwWOPExf+xOttA== 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=OIjNG6O4yUAaaqOK6KfuqMs34g2ZILTtn10ODN8wnrs=; b=Igbxq10XmsVtgerYH/acdmqLM11R++tHxTeYgGzzBGtEBuj5TqQ3c/GkDqEI/WWFqEizfkKq41TvB1CsuL0+HtYAY8m1pX7a943BdtUrQkysr5IYSvyAHQaJJCm3+v4C2gF20N7F/MNPHEVm0rz3T2hVphVgXyW3MryN29uLCpIUc1JbNVzt5rH3wBMheGpkoKIZBJ6abWRbIND01WrJowPDrH8OI8zcFFAzpm8bvdMuNwvY1d3LIZcJLWTzQmDSTbl7NtQXdCnnXxMBHaFJZ8iMXEkvO/rp0MVSPvc1ECkiXRFDT0eykYLvv5uZ4qhwJJLssJzH3+MDtYgnCqfi2w== 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=OIjNG6O4yUAaaqOK6KfuqMs34g2ZILTtn10ODN8wnrs=; b=JDUR1uE5gvFESm2k4jvmSSLoVHWLiMU+ULSE0sCsiNip+6PGHPcpuWkyoBE/y7jRUZx78BT4wjM4BrxpZVTBuypp/QZ+fMBiY9qghzp27lCVXeJwEiWlX4urYQXiTxp62WB9+McKq+hQF7y+h3I8DlHlXihOmrnxwvNpT3UL6s8= Received: from BN9PR03CA0718.namprd03.prod.outlook.com (2603:10b6:408:ef::33) by CYYPR19MB8118.namprd19.prod.outlook.com (2603:10b6:930:ba::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:12 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:408:ef:cafe::8) by BN9PR03CA0718.outlook.office365.com (2603:10b6:408:ef::33) 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:12 +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 BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) 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:12 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 43430D0; Sun, 1 Sep 2024 13:37:11 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:08 +0200 Subject: [PATCH RFC v3 14/17] fuse: {uring} Allow to queue to the ring Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-14-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=6166; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=WO9U9Vi16OvjSCHwWmwvrGaz8Wfi1w9JwEePyqVl2RM=; b=MppN/AaMBx4+/71Sx6awxzbkOjqZrbPK5/XFhLto0Dh6mNAvKY3Bwxx41CaFDG13F2TH6rOeT QhNo8hYDDh4BAiEeUAswXM2QP1a78Iks7FhTAGiRLG7NUctT+q+vgtT X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|CYYPR19MB8118:EE_ X-MS-Office365-Filtering-Correlation-Id: ea8ecd73-19df-4c3f-8cac-08dcca8b2f4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?fC8eW/S2xdfZk7Ci9ZBCMWNPsLbrmkd?= =?utf-8?q?5ohyPsuh+VBP/e20T55FmCIhKEtAAbJO7S1PPJttLVD3mnWdym5pohNZus/dH+Bp/?= =?utf-8?q?BakrloeeM+D01t6LXgAI2Bc7dMs3wJFyQpqjAkWxWYqiXxgfc7kio/kwRgVt6NWyI?= =?utf-8?q?P7qyHsHa5T2vQILqlOJiS6uBCbbAFrt9tK0c8V77fagxJ8GXfA47tM0QAxdW/oBZx?= =?utf-8?q?7V8v5KmmkxoMx7ZJqfjn8WdOgpWGVdsgsEn3Ky4f5E1NoyzNp5bapxV5dDbfcxn3p?= =?utf-8?q?w1jmJPITxBJCC212rNbWIUsVcXHI89R0sGecJfj3DM2tkjVbMyGM8HIRPm8F3oGnR?= =?utf-8?q?xcgejtUbnGkDY/XYYDFBNtFAwFTHBTZYMKfvK2vX1tkljg8WKd42T+TjLkW0dsw2f?= =?utf-8?q?v2nwPSyYJJzGYdB2MwLEm67EjWyXjAbJenBoohWdBEWn+uTQVQ/ZJF7gN4GUCjpAR?= =?utf-8?q?tTt3aTheZWm2B4TM7NxlsFW3FZ5ugCSW9mUqU/8YhfQ3RpTORpU9HbbFQmwaSFZkX?= =?utf-8?q?iAX2B1eOjV3uVQcWRxdwk20aECoEMaNRgiIbeZk/5WsFRctd1PBei0yWYSibvU9uy?= =?utf-8?q?uNrGnsL2sXBko6B3wQmltzt+JFcKPEWXDuZRzgrRKASbiKJii1qw5E6Ku+urItPRh?= =?utf-8?q?08SyGeVku0dP+ciQF70WchKZd9ao76LkXh5cX87OWLl7dZgfGRfY6ODVE1mVXhfwG?= =?utf-8?q?c3lpuMSsU03vm2PiEEZOm1TEfeuZW23pj2rGbx7EHRk4XvmPPCHO/W7oHZ/ukETMg?= =?utf-8?q?6+3BElRYniS5L+4ujrQKGXwGm8QmGafaCT58WTCgQ1DwoTQOpyhjrkEvXyVcyyqyH?= =?utf-8?q?tFlnLQ6hMTrUif7kHxzUBT+Ww4cdtt/M1MgBI+1RISMSi6q65M505pbjf+hWGD/g0?= =?utf-8?q?32bVJfrhRcoitBMfKf2x891sizUXzBtodINQmTkvfAWGjHYp2ss30qPRsXJKvAl/6?= =?utf-8?q?gSr+ew7XJeorJZ0N+lClSF4lZMCirKM/Up4puuMcFypgn4E8lWBfn0poTL/ueSHHG?= =?utf-8?q?drr+IENWhUQ71K5OOPW3Z5hVRocgS+/hEfwUCPyZffeqOF2SxyQPqK5FEQ8uPU3nF?= =?utf-8?q?gUkdo7BfM3bVtQUBScKTSSsaviNrr/xBO0mLVgveSdXQ/gLXHhhzT90uv3Myd5eRC?= =?utf-8?q?aAdTQ4YwefPoZBFI3SKOaP+DBfzC3nCwsJoGaAnyv/iGYC3+0GJkuW6osWnMCKzOp?= =?utf-8?q?cYmlIcFjvdG8h24AsAQDhv30ZQKfcZUYv03Q5Uqb0CnvkPITJAS8auaeMZZfZv8M+?= =?utf-8?q?A0QLbGqsFFZbbCpYcIjtxRc8WhYzPITMqDLStU/2xtpHsCliAiMBgg1aLXiVq8W1T?= =?utf-8?q?nRYsJVlM/B/rzzRg8QSDfH25hlP8PejG+08sGmjtdZgZgNODxvlNyTSWc+xB/rsaw?= =?utf-8?q?iuQVUDDrOW1?= 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)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AjuGvfZ20iz6E99QspcBFEfqYllqFSgpM8LCB66LkS4bT8Kg1KXb9FJtxc2+igPN9y3E/cL4rADHAXGYguu/GMEsQXKJOttd/kWeMI5DlL+NH5gUkifGqToj8acRgXHlh4OIUSaeHbPeIlB6BzSGBMsPDUQT2rKKzeNnUMcOEIYPHCMrmWn3a8OlcsX4A5N57JjdYcSVxlq/97ltncmYs4w4eEo4BrARwaNhcLIpL1qC/U4NjXsQ0K3Vw7O1tNTvBcN9J4OAvan6ElAhP4jjo90c3ibsqxdUth0+OfG752QdbkX2mOcc6BJJ26XASvOTJ2oD6wQ+7cxqE4uJG8H7GRmSLy6aVGu0B8xGmlcUDWrpHth2kZ9d9DE7asZMJricMJhQaOBPEHjgWZ2WYn4T8A7l8d5L5OH4hXX+tKwybTSJjbYFVyDaQzj40U/1NDgQfbopWZoIDMM12itpMDB3jNPenojaB5EVMwhVap7hAv/KXAot8j2DqWXUMSxU5F+QvZttuLrA6rw6csh6d4w4L5T2wJmJ0KD74HDNVQowDGdwNiu4lyWyw3n8AJSD+eLzsv/3MnS5wob450mmhgiiGz2DOyUhcnRQxXV7Jc+7STogwfK/waD4FYewEh1poBeHiTgUU4S3VxlfhVzund+D9w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:12.1237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea8ecd73-19df-4c3f-8cac-08dcca8b2f4d 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR19MB8118 X-OriginatorOrg: ddn.com X-BESS-ID: 1725203316-105647-24686-26161-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.56.176 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqaWZqZAVgZQMC3NxDIpLTXRLC 0lxdLU3NA0LSktJTEt0cLS3DApMdFAqTYWAO1YKwBBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258745 [from cloudscan10-26.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 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_SC0_MISMATCH_TO, BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This enables enqueuing requests through fuse uring queues. For initial simplicity requests are always allocated the normal way then added to ring queues lists and only then copied to ring queue entries. Later on the allocation and adding the requests to a list can be avoided, by directly using a ring entry. This introduces some code complexity and is therefore not done for now. FIXME: Needs update with new function pointers in fuse-next. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 74 +++++++++++++++++++++++++++++++++++++++++++++------ fs/fuse/dev_uring_i.h | 10 +++++++ 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 3485752e25aa..9f0f2120b1fa 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -218,13 +218,24 @@ const struct fuse_iqueue_ops fuse_dev_fiq_ops = { }; EXPORT_SYMBOL_GPL(fuse_dev_fiq_ops); -static void queue_request_and_unlock(struct fuse_iqueue *fiq, - struct fuse_req *req) + +static void queue_request_and_unlock(struct fuse_conn *fc, + struct fuse_req *req, bool allow_uring) __releases(fiq->lock) { + struct fuse_iqueue *fiq = &fc->iq; + req->in.h.len = sizeof(struct fuse_in_header) + fuse_len_args(req->args->in_numargs, (struct fuse_arg *) req->args->in_args); + + if (allow_uring && fuse_uring_ready(fc)) { + /* this lock is not needed at all for ring req handling */ + spin_unlock(&fiq->lock); + fuse_uring_queue_fuse_req(fc, req); + return; + } + list_add_tail(&req->list, &fiq->pending); fiq->ops->wake_pending_and_unlock(fiq); } @@ -261,7 +272,7 @@ static void flush_bg_queue(struct fuse_conn *fc) fc->active_background++; spin_lock(&fiq->lock); req->in.h.unique = fuse_get_unique(fiq); - queue_request_and_unlock(fiq, req); + queue_request_and_unlock(fc, req, true); } } @@ -405,7 +416,8 @@ static void request_wait_answer(struct fuse_req *req) static void __fuse_request_send(struct fuse_req *req) { - struct fuse_iqueue *fiq = &req->fm->fc->iq; + struct fuse_conn *fc = req->fm->fc; + struct fuse_iqueue *fiq = &fc->iq; BUG_ON(test_bit(FR_BACKGROUND, &req->flags)); spin_lock(&fiq->lock); @@ -417,7 +429,7 @@ static void __fuse_request_send(struct fuse_req *req) /* acquire extra reference, since request is still needed after fuse_request_end() */ __fuse_get_request(req); - queue_request_and_unlock(fiq, req); + queue_request_and_unlock(fc, req, true); request_wait_answer(req); /* Pairs with smp_wmb() in fuse_request_end() */ @@ -487,6 +499,10 @@ ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) if (args->force) { atomic_inc(&fc->num_waiting); req = fuse_request_alloc(fm, GFP_KERNEL | __GFP_NOFAIL); + if (unlikely(!req)) { + ret = -ENOTCONN; + goto err; + } if (!args->nocreds) fuse_force_creds(req); @@ -514,16 +530,55 @@ ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) } fuse_put_request(req); +err: return ret; } -static bool fuse_request_queue_background(struct fuse_req *req) +static bool fuse_request_queue_background_uring(struct fuse_conn *fc, + struct fuse_req *req) +{ + struct fuse_iqueue *fiq = &fc->iq; + int err; + + req->in.h.unique = fuse_get_unique(fiq); + req->in.h.len = sizeof(struct fuse_in_header) + + fuse_len_args(req->args->in_numargs, + (struct fuse_arg *) req->args->in_args); + + err = fuse_uring_queue_fuse_req(fc, req); + if (!err) { + /* XXX remove and lets the users of that use per queue values - + * avoid the shared spin lock... + * Is this needed at all? + */ + spin_lock(&fc->bg_lock); + fc->num_background++; + fc->active_background++; + + + /* XXX block when per ring queues get occupied */ + if (fc->num_background == fc->max_background) + fc->blocked = 1; + spin_unlock(&fc->bg_lock); + } + + return err ? false : true; +} + +/* + * @return true if queued + */ +static int fuse_request_queue_background(struct fuse_req *req) { struct fuse_mount *fm = req->fm; struct fuse_conn *fc = fm->fc; bool queued = false; WARN_ON(!test_bit(FR_BACKGROUND, &req->flags)); + + if (fuse_uring_ready(fc)) + return fuse_request_queue_background_uring(fc, req); + if (!test_bit(FR_WAITING, &req->flags)) { __set_bit(FR_WAITING, &req->flags); atomic_inc(&fc->num_waiting); @@ -576,7 +631,8 @@ static int fuse_simple_notify_reply(struct fuse_mount *fm, struct fuse_args *args, u64 unique) { struct fuse_req *req; - struct fuse_iqueue *fiq = &fm->fc->iq; + struct fuse_conn *fc = fm->fc; + struct fuse_iqueue *fiq = &fc->iq; int err = 0; req = fuse_get_req(fm, false); @@ -590,7 +646,8 @@ static int fuse_simple_notify_reply(struct fuse_mount *fm, spin_lock(&fiq->lock); if (fiq->connected) { - queue_request_and_unlock(fiq, req); + /* uring for notify not supported yet */ + queue_request_and_unlock(fc, req, false); } else { err = -ENODEV; spin_unlock(&fiq->lock); @@ -2193,6 +2250,7 @@ void fuse_abort_conn(struct fuse_conn *fc) fuse_uring_set_stopped(fc); fuse_set_initialized(fc); + list_for_each_entry(fud, &fc->devices, entry) { struct fuse_pqueue *fpq = &fud->pq; diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index d9988d4beeed..f1247ee57dc4 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -260,6 +260,11 @@ static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) atomic_read(&ring->queue_refs) == 0); } +static inline bool fuse_uring_ready(struct fuse_conn *fc) +{ + return fc->ring && fc->ring->ready; +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -295,6 +300,11 @@ static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) { } +static inline bool fuse_uring_ready(struct fuse_conn *fc) +{ + return false; +} + static inline int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) { 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: 13786485 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 3630C17F394 for ; Sun, 1 Sep 2024 14:11: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=1725199894; cv=fail; b=lCoSr6Ghx2svvmPmkWsGGAS67wr2DHzoAfkWWezQjMtkGz+RKdLGR4rh9cvQHQA21vE4nq38t1fOgPV+w5nVc5UYsXwVgYXuM27RE4YzFwS6QAc5kk7X3sEs54e/lfLw2AMhVmw+INqOIrmN4bxUeI05XYbJ4emPGERAiohXmh4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725199894; c=relaxed/simple; bh=TfNQSKeB7F3/+dh+Af4cyQEWuwq5YHJ0xf5InxsLB9g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pad1e8wprbKxtzb9TrorYNodFzo1byDogUd3GS7xu1Ce7udZa8xU1VsFb3jlL2cwdMDjXFcyDuYoZI9vtjbhY8q6IucBqoEvHAMAIwtReaZHDBHViCj1lt81fZuFamTfi1vvnXKLvGfxbz1IdxXnB9v3uGx9TYsYp9jAJfL9Htw= 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 NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx-outbound47-8.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 14:11:31 +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: io-uring@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?IAaaeYpSi8vAEhZs0yz3DuRW09ZXUGjBRYGmj7AELjEE4xvBijorfEU3shZ+K6+6k?= =?utf-8?q?/cjwcRzTNIEMLgHTNqgrRS07c//RF9XRqHV8fDsnKFXz4yQScbjwF8ClZ1x4pPubP?= =?utf-8?q?ek797RRZwlSDgk4MCmmVqBwL+YYlHQpXARifWjhdDIFD1KjbCtvdhJkb/cQ5Vz8vE?= =?utf-8?q?B6fx6XceTSb0OoAmLRTFg/AUsAkAmOl0h8Z6Yi56anAIEqto1r8a3+b71CY6XBVTT?= =?utf-8?q?wCc347ue6wscimcx+WAbEa3iUZ9VOaKUAdXDRhQxyOKcRJUP2xZIt3qWLOljSpFFl?= =?utf-8?q?JlJnVeHV1ebyX2ZmwOYVSj7pCfb/w+0zpUzRPpIIOtPw7FXjp3qhBkwwVb+WQNO6U?= =?utf-8?q?AhOKC+moVh88nKKt/7+oqqyA5IB/uUFxBAx9jJ6Oc6vYa+hZGTIh/u5sqdLcgzmre?= =?utf-8?q?HmqGFlDsoQuLPrO7dR9SLpioQzzyboazcCiv8pmD/iZj/mPFYod1yGqPwgFkiNjLf?= =?utf-8?q?c0En0sig1wwefoASy0hv7N2YosWeES2mto8gYFeexTNA5kdz5YqE3D8PeNzddJf5H?= =?utf-8?q?K9vB1UOndbzVE4wLABVA0YKqKj9cqMPjbbxWzJnIU7cQkYLOC+cq93t1LchjhfoaK?= =?utf-8?q?n0bwtZYq1FZBLaY3+vEJRuA3yorQgPq69jJnbwWJ0f5NXxuh+b+PItoMoePAwySWH?= =?utf-8?q?m/bC2KVfHobBRy06LHHqK769za8TKHVjH6BszatYw9VUTSsJdbdYmEyeJq8iC1EIH?= =?utf-8?q?5Hj9Sw7kyCmltf8phVuTjIWtr1fbF1Ig4sBbu5eVdw9IELKPjkM2ThXDoVqrnyzNL?= =?utf-8?q?KxKnA0LbnZG9j2ELtvRJY2uBwXs50aYf6QzanAs/tVc8pD+j8lbA7WhmpIozqEt9V?= =?utf-8?q?i3fGZi5qXSF?= 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)(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-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-OriginatorOrg: ddn.com X-BESS-ID: 1725199891-112040-12656-1465-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.58.100 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.258744 [from cloudscan8-19.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.50 BSF_RULE7568M META: Custom Rule 7568M X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_SC0_MISMATCH_TO, BSF_BESS_OUTBOUND, BSF_RULE7568M 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, From patchwork Sun Sep 1 13:37:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786513 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 C91793CF7E for ; Sun, 1 Sep 2024 15:09:13 +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=1725203355; cv=fail; b=G9vC37Moe5/8puHra/8k+p5NSXS6m2AkWgd+jp10kYxCVYqX8UjjHUlg1av5VaHCA1ywhzH4ClGd8ToAoVwhCdhtthxHOFxdpGz4OHxBuScoZ4pvNpjDjTN627Tzc4krZGYXIkNjtdrWlYCOyUBkpienU3N/0PRASFwVt8kXeL8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725203355; c=relaxed/simple; bh=8dhkqhFwHO1uc2gQUMpZEDKo8OQGVPegTAACyzpk3Xc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eIr5gkxF1pvT87WLyBcCWATJTF81lSajCIzlGQh3HFDsSCC22m4hYzB7rAiVH5zpqRqV1IhFMqX6jLHm3m4xID40DPToCOuxFweETp68PHUhLsvTWevLU3Y7yILrFccMdXoufvvZbWxLQRnIFXYh4c7iR4XygnRFmE7Te8uiKdk= 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=kTzLJIMX; 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="kTzLJIMX" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2045.outbound.protection.outlook.com [104.47.55.45]) by mx-outbound46-229.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 15:09:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ef7oE2nGH4RBI1GtaRyKm+1FXEiW6xBt70BkkCqRK4XQpBnHEQ9YYX0maH7tEVQr4CALgztmHbwly03fH+lqWMt0d+kGObaN6GaWNZAImNcDb3h1cMa89IgYcHyrOdAXwEFr8N6202ryAWHmLw+0R+Gk1PP59Ntra2jrqnfpk75t/4IqhYSjN94FqD4r4xOaGYjyhLTca2gqyFdM6MgoU5vIptDfkhYxn3/FDVJ6KKc8yeWIo3FFXChZrxFcuJyIMgSQ6LVTmTBFZcJLPcgN09N21MAsWCvIGTDQ2oy5HXnsdzRxHJ6Ym7OlGWwMh/+qUT2z3FmpUW71wzssfeaZuA== 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=pgMtCDsoXOyo/QPcdUDSpQJhzlP9ifRQC1shbPtI6Bo=; b=J9N33ICax4UZ7MEG7UZK5Qz1P28/fUeZT7waDv4mbON1p67qzgeqjIKiG2p54YKRVyRnrhdDFHTv59TNSPCpkk1Cxjk8sm6tS/PUuff+QGCf66JYccMXJokMROkTPQi+ShH/nvxduRu0oYXvfa8+BxIbQJDguYYJ/hcjjbEm+EaQamAMRIr+cZJIpntjULlDqr798qra6MHJdeGpcWQGe61ReHfl8iLV+tTR9hWfNTH8yfpibtU2uqyasmwlKg0iThXx6s73+nQOkVqu5I5XwFAS9sbMT9LhvH+QSIL4MJYCSNaivKu9aaYJRWw3IofBw7Yq/4GpK+ZRsFxk7RJtfQ== 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=pgMtCDsoXOyo/QPcdUDSpQJhzlP9ifRQC1shbPtI6Bo=; b=kTzLJIMXC2rUOq7z5gV9BecSC7g2iI64/yBWn0z7hCfsJ9iZDe7Zy6Cd5PKnH6RG5mXYCDmm9BdwPy/4WHqfaVrzqrsSCbs+Z1PNCZF34PRsmFccj7em6Hw1aMpU2fmejUcFydFWsm9xy0KpMpaV2xjXjyBG8KZosgkw+42nEA8= Received: from BN8PR15CA0043.namprd15.prod.outlook.com (2603:10b6:408:80::20) by BLAPR19MB4244.namprd19.prod.outlook.com (2603:10b6:208:276::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Sun, 1 Sep 2024 13:37:14 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:408:80:cafe::63) by BN8PR15CA0043.outlook.office365.com (2603:10b6:408:80::20) 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: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 MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) 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:14 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 34174D0; Sun, 1 Sep 2024 13:37:13 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:10 +0200 Subject: [PATCH RFC v3 16/17] fuse: {uring} Handle IO_URING_F_TASK_DEAD Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-16-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=1048; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=8dhkqhFwHO1uc2gQUMpZEDKo8OQGVPegTAACyzpk3Xc=; b=eyrkXfca8xjIyuTMNoR2ImJakYrTiEZVmR0snVkBZJcHwDUfU1JDpD2sC4dEjPAEgSZ/5S0Pb iDnX/5kB43NByHkzoRjZ6kLrYvMtLCQwKg3/0KJcddn7FU24ID0uw8m X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E2:EE_|BLAPR19MB4244:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d8d3189-d8ef-49ab-b5e9-08dcca8b3086 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Kh3gcvIcIw2vQ2umbuzbCq8VCmAyDVd?= =?utf-8?q?KTL7It6kIOR+N5XeSeFN1VWulgWNfZOmVAXb1JFfvydR/fd7+akTg8zkhF+pQwdmD?= =?utf-8?q?wkQ5lQ4HfwqfFAnZ2ZLGPM6NEkjoAZfmN3VKkVQ15PN16AcljMRYAEyStTS/WWsZv?= =?utf-8?q?kByRL/g0eEjMD9OGNPvhGPk0IJT+Fhc8dgKgPnBDOGLEIFPOrYFPmaz2hBlRpXBKy?= =?utf-8?q?NuaQy10m1DMrkHHmhEGQe8gybwQPBaB9kphssI3KmJbA9L5Ax6AF6G+pymbeWVk/b?= =?utf-8?q?phl95HnYci/m3vfLJl6ynltbljb9motnGgKLpnQjghV5S+YLYHytVFyqu5Rq5U/8c?= =?utf-8?q?eXlmR5PnAOB6bfZi4yyTxAyG4jgVVnF87TY7kdQLvslq+bRB0IBc7/gw8nG3bIEzU?= =?utf-8?q?wPaNSp2O5lhST48A49/9am48c/AR55uQyf15Wl8OsLPRxh/nBv/QelGspgYBxFRh0?= =?utf-8?q?cyEisGIgVOhiNkWrSGiCcvUq3D2z6BPIxf0ctmM8QIIIDN8mGo18KSI/XvD/ARtK4?= =?utf-8?q?nCP865Ga/mku8tPh9Y2bLGQiY3FjWe7kKPQZ3WbO4MxiTAGhE6Na677q9jVluo+CI?= =?utf-8?q?kHVaEr8lT3GosnUjHLf31D/3yr0+oeHrOJFyYVTglnIP+YEeCCOIrAkJdeI+nfiNW?= =?utf-8?q?1I+4JiVXI1YRB+SVN8LHHNhIV44niAXZ0RJaBXvXTLKKJuqIgpUzILEoPr15K9qdg?= =?utf-8?q?6d7+3iKjBd4uQVtjKXuQFVgDWtXSV66hmrG7YVvyGO0yVr6bessBumo8FvBfYZpIY?= =?utf-8?q?ST0qZMScHox2AF/F/Pno65HJrXAVfZ7pkQSl1UtsvibUVAzvFD3KSgTsosaHhqMde?= =?utf-8?q?1BvY7H5b2NVtZIAyjZ0ac/FQ09KcnkydeK20YTUCJDINQaNNOM3DRaUDYTca+4ijt?= =?utf-8?q?Fnn69IWn7jLBPeI0b+g6akJOYzf4tSzQaqdFD2GFXqgmhZMbTt+FhhYa1Xv+T8xI5?= =?utf-8?q?GRUD2G7Owb/jA5cU+Gn9wzh+w6Sq+4jiahFFV97enwJWCGAzVXlSL4NbH3HfohpvB?= =?utf-8?q?9qd/RRh5A9cRwfTEn9KfXbJ2uuA1htBW+t2m7rSrYR0I8KjLR8ggJKaTKvVh3EQRy?= =?utf-8?q?XnUiy2ZsYvoF3DhWyJFT12wFM8OvOA4c3HW+HMbvZTpuVRsSHVgUER6q/RgIRwXuk?= =?utf-8?q?8sV89rSQ3tXGAoa04hYuvauq58J1yt5EVqmc5208v1eolHo7usMOl4k2P14Zb/OSo?= =?utf-8?q?A7kWFcK+y67Y4KKr0kYW259FpXzE1kPocrP+RW5HZ3fBrPaS79S/zt6gL5Zq4+255?= =?utf-8?q?YcS1FiUGrFJHea1sBT3RxYHn+uImi+6xueVFRd3UKX9zLcJ5ZMFQeaxb1yaScOBqK?= =?utf-8?q?fg6BQyj3fsZQCHjiSq4PLNl9q8uJP8s6bjtTu9kuO5sC+At5B4LuiaLyfBMwXVgTE?= =?utf-8?q?2OvrWsH0L78?= 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kcYNadwZd6OcT7bg24HnbP2JQK/SXrf51IW34HuOZGwn4IBeoUgrLj5O5CQSiLfzV48JrsjgwKxJ4vsLPcIyh9i50w1hkaQJ+17JpnFBXpI5OVsD14pwFksnYtDXOqjfU2e8QqUjngmXF5XViFovWqlEO1xRM5T6MFCKzwaWZTDOPydP9HlOp37SFoY0xSoAwCLIyWsu4YOBAtvu8qyMCk7H5GLmPHjnlp3wRQKYlRjlkLyJzIJkdjK/2obOdqhMkUeMoQzkzQBlzGce7YjY9/5icbzSVG6iYp8lTtdt3/U5WnVgkSussznC5jW8i4CDF88V4JKk8Uel7W8RtIobyUulnmKYPmuY692VyVAzQG3fJYvzHSofSjojGgrV9/pzrHgbc3FTfM7Kw5s2UTfXxuS5uv0dxJKUy+1XpAf2JsM1kxSb+JVCUx/Muo08t2c6Qzf9Y3MR4dUJmi8Khaaj81dDCARhqSC5fMsm2H3h2IDy4cd1DPqJRtrylNwwKyZJyP95yW0WbH9/NGnJrn8BqB+zEGS1tjnNuE0AE98PQMlBq2mNJohCNwvdvevZ211gS7Rnbvrxg2Eoa3lRAZJggxB59GNq+BuLFKVeBlpHPoZ9O0Qxd2XLCG7RZKF+g2AhPsLUFWGw6xcD0Opb8nBF+g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:14.1761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d8d3189-d8ef-49ab-b5e9-08dcca8b3086 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: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR19MB4244 X-OriginatorOrg: ddn.com X-BESS-ID: 1725203351-112005-12689-916-1 X-BESS-VER: 2019.1_20240829.0001 X-BESS-Apparent-Source-IP: 104.47.55.45 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGhsZAVgZQMC3RMNHYyDwp1d gyydjYNNUkLdE41dIs2SjJ0jTFyMRMqTYWABcshV9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258745 [from cloudscan12-95.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 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_SC0_MISMATCH_TO, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 The ring task is terminating, it not safe to still access its resources. Also no need for further actions. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 43e7486d9f93..a65c5d08fce1 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -993,6 +993,9 @@ fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, BUILD_BUG_ON(sizeof(pdu) > sizeof(cmd->pdu)); + if (unlikely(issue_flags & IO_URING_F_TASK_DEAD)) + goto terminating; + err = fuse_uring_prepare_send(ring_ent); if (err) goto err; @@ -1007,6 +1010,10 @@ fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, return; err: fuse_uring_next_fuse_req(ring_ent, queue); + +terminating: + /* Avoid all actions as the task that issues the ring is terminating */ + io_uring_cmd_done(cmd, -ECANCELED, 0, issue_flags); } /* queue a fuse request and send it if a ring entry is available */ From patchwork Sun Sep 1 13:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13786515 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 9046744C97 for ; Sun, 1 Sep 2024 15:09:49 +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=1725203391; cv=fail; b=s25gDIzjxmVBS/jmq7LcMQzEeaKgHR/EYgZep2Ou+bpuUiWIbsXWdm+dERzllTbXVVwf31CmhK9pDExQQrxQ3cTBY0ryA/3xJpQW43zbIQKD0xptHZFu/fNPW6SDmVR/q7d/we80/msb9oK5AooMVps+Lwv358qNLXhxTYLlQX0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725203391; c=relaxed/simple; bh=fuliOyC1lcweNpXS+AQqKEdtF9y9TtcVKajjb9Lh/Lw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lnfEn6Zb3uEQLNo7yX8shdzqtcZDCAXbRTShSWRqOUbzm3EmfgP+zD7/YD1atDxuNigaGIHIPvZnz61MZC+Zld6+WpoGBtCu+/hXvLXNwlEvo8Mp/zYca28QlaN8MkhsE9qvZGRe83ia7ysb4mfPjiQswXA7eQyFtmEYps5YiO4= 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=P8dv02mC; 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="P8dv02mC" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2040.outbound.protection.outlook.com [104.47.70.40]) by mx-outbound-ea15-210.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 01 Sep 2024 15:09:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IHftSqIRMePAeedB1ucXsNociIyhBgvprkXjQxaOXaqipd48WNmJdMST+7jXbuhFXBqRyU6UD5sFdUMTaymr8wnvqqKrCytXBLE2e0IfseFX34RrG+1/3Q/z2x9d+BVCdVWs16SxF77bvUZuVhV6qd63O7s38wVNNi/FjO3OCHsdNtt1VE+Er5yIzT36xBzNr0W0wua1Wmn6pizFWHETs2tYvdIh3sDiWjuGd48JSSM1FYI5tk8X889Xw6Q+M4eM4GhZaxCcwPdH/+6hjrMhmlwXYwt5Bq6j4OcZfkgHs8+HLP0RJpUxIQ1fonISNECYLhC3TnIcF0Qk27+xIUyVKg== 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=7LLShqviQXhEKujvXEobFQRhi6pw9v0mOs5fr/Dw9Mk=; b=v243etDb45LZvWXJRIQbxwqz2E4NJ4gQoqCWsN0/7O7+K0fLWrj77n19bxIc3KMxo4BtB4zNIBPTbh4lp3IfE+ovzbIO+IPvgdXDIjWDQmUZKG5fWTNR+H69pHjTRH8AOyZXCJDVDtvxsYCBT5PfVmBWl2ejqlbZgcfQWyU+F2hgamyER7K/hv8amK4XpczCjCoY0mbW31kiZJDJQYvg1msswk6FLVFRy3O2cV7aRP91t9o+tW8cvvN/R+uB+vSruVbmQExigG7kpihA0MgOeAqFSqTqSYtZg6tJdKZqEETk57O1IoiU8t8t7z30+Nr/a+os+Xmbbe0WqOvQCjD9HA== 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=7LLShqviQXhEKujvXEobFQRhi6pw9v0mOs5fr/Dw9Mk=; b=P8dv02mCnc5FHMmSEy2MQZKPTo21VrcXj2bSodRDtzEBOAO0uYcuQ6glxQ0ttYKEMr7KsoQ7W5zY8q+4Z0aZvfFwi5fagN91ekrSiSEJB/JBZM6wg5CcYj1kRhkQH+b6PqXU9YVhw0jM1jz8M/t1Gs+qn4YzNgEI4qVjy4nVzWE= Received: from BN0PR04CA0158.namprd04.prod.outlook.com (2603:10b6:408:eb::13) by MN2PR19MB3871.namprd19.prod.outlook.com (2603:10b6:208:1e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 13:37:15 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:408:eb:cafe::b1) by BN0PR04CA0158.outlook.office365.com (2603:10b6:408:eb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24 via Frontend Transport; Sun, 1 Sep 2024 13:37: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7962.2 via Frontend Transport; Sun, 1 Sep 2024 13:37:14 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 2DAC8D2; Sun, 1 Sep 2024 13:37:14 +0000 (UTC) From: Bernd Schubert Date: Sun, 01 Sep 2024 15:37:11 +0200 Subject: [PATCH RFC v3 17/17] fuse: {uring} Pin the user buffer Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240901-b4-fuse-uring-rfcv3-without-mmap-v3-17-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=14839; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=fuliOyC1lcweNpXS+AQqKEdtF9y9TtcVKajjb9Lh/Lw=; b=Q8z+lAIf+jbe9nQjluggxgiC9SytD+gmu9E9HXTwLswknJUjzcZPqgg60/PcYyY8TAjJ3WrBN 4kFdWBQQrswAv4OuOANc8Tu67WxdGh0bJOu/V9r8HeDYMVBllqtv4fw X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DF:EE_|MN2PR19MB3871:EE_ X-MS-Office365-Filtering-Correlation-Id: 55f49997-62d6-4d33-143b-08dcca8b3101 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pz2TxACIP37oL/75HtTFB9D6ZaNG7mO?= =?utf-8?q?NR+PVjd7fvx4QUiBHSPSFnuJf5H92vGlOv8vH56KgVv2aK/fZfpTqtiRfVPqbkf2R?= =?utf-8?q?sKy+htEZsy02OFJCPZnrC3/PepQfTYd6VN/UruI20WnJI60BTpFajulnQES3PnhIS?= =?utf-8?q?u9AI6okLU3igtGoWRArFHCyvDBBCP1KUxGoDFKuH+Na4OIf4zBwUIdyITvlACStnZ?= =?utf-8?q?GPIYuCjrsdzf/RmDADCeFLJLNCE+7o3egqN7bfTzNJdIcGZE2X45f7j5BwAyoCbO3?= =?utf-8?q?FjxA5S8BbpDL1Tr0ZLapbQ6wrIQXPAAY4ZyfYYkrrceDDxKJ7GiWeBziwLvaY86tI?= =?utf-8?q?4Y/N5SZ28IohHXwpI+hqGj53uXPQ1yfJfMpQEn0oZEvEqIXmXwQH68xe/GhUZD/ZN?= =?utf-8?q?a+lJWmn1+gxbxFyHgq4w0R+GzVgToSymXpTTOtQBlzqGUkAuAevR6Hh4lyZsKxSDc?= =?utf-8?q?Yro2qhdu4hJpAARBwWruPpLRHLNHj3/pKp4TsvWNJf7aCTlhLRwItY+y4ew5GvUaJ?= =?utf-8?q?Pa18h3uPw33vxn0We65NN6RI/mtxjq4tnN9jUl4uRPqbkI92oPWxjas2YBYtuBW4e?= =?utf-8?q?fMTtQlXlPyuXYbTdrRA1d6K8FACXQy+/g3N6QlswxUb3b0g4huV+Ti0PV75AHDse6?= =?utf-8?q?ECfHxaSA68Dfqce3OirVsqA0j3mD3Udh+SGUABtLL937pyljNR+dfcgZCQ86C4qGe?= =?utf-8?q?3ZUQetzWnBRkMiLZXBgkrirWFr4t0aubcLmXGBxyDtefMLb5LweneTMv5C2JHWc8L?= =?utf-8?q?Dwr/yZg/gOfv5Z+RRO9BG47VY9evIBn+mVLbObEoWMhrNJQaqAb6HrMnDFLLPkVdC?= =?utf-8?q?/p0eNXgqe4u9+b4cfpL3V8bAo+OcFRL6kOqUC8Ob0d2SB7JqyEEws/0LpkoI9mz6X?= =?utf-8?q?SoOpXe866PBZT9PQQJI6F/7ryTEhdQ1VTrEQBqoR5QUuCyx2Mxp0GCoDtCkI/qy5h?= =?utf-8?q?cYAPRUE9WtClKoEl0LUD80kK6poJQmaY/d7XZsYDQisuyziTMFooPBs3Z0dCK8/n+?= =?utf-8?q?+1ly1sou4xqVUdly+EN39Vg+kIaRRsdV9Foa4zC1VbFtLz0y0mJV8bYXbuGZwI/hT?= =?utf-8?q?asmcB1hhY9MFCw1imQziC/vNQZ9WfWfN0ltIQML6R4X6jjGPxTiCRvzx17gdkJC6a?= =?utf-8?q?YKFJcWwXL6SeI1Yq9i1EpJUJo5B5wcGFVuSf1DYPfYypQ46YSyZtio79/WsbfMvEg?= =?utf-8?q?avKTjlR1cVqxZrRF80JIwMT4tWN6atvHOzOM6G3FUPIpcIgzb6L+dIW0wkHrG/W9E?= =?utf-8?q?4Cpi2mKzwZdWiwRHTcGdLx6tlm4wGvTNb25XS6X6GXLVzdl49cMtmSkDg1HiFJy4e?= =?utf-8?q?D9e57DbMrGmaQBkxoDIb+cbx4v5+m6vDl+vOk8PJUBPQC7C5vZhtYExvId77ew5ad?= =?utf-8?q?rUWXXsJJgB1?= 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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +TJICCPMfNBUw9gMaVZal1ZcafMpmEyOSb2vKnUdsL0mmC+0A7GQa/Ds1uVu5xl1bbLGzCUqqnWErVuU4bZ+SZesv4yqZUD7PVmndgtiqaol/8qLCi1QcqV4Uk4c6mW02AsM4LKChjYuIu3bQPloWM5dpfY5PUKD6mAL6ypMWOYY1vyGlZOyUl9+FaIpX+utbPty8Owr0s7u4kKNSGd1DbTG16++GTQaK9i5mhh1wZWfdumDi26rQ5/+nTnnnKJIz/Go7dxbfgx7gWUp3W/Tw543AxQschsIk8b4E9z1FyVVgkC22VF5xUvkUDnkkZc6BpC8188chzgyuUkRvQiuA9C9oPZIFSDrezMPHiziqioW+qqTqN5tJpO1RiLbtw4A9IcCGg/2tA18l/x1/wBY7/fQ6Wr0/IWQjbKvXbun0+RngrRMcau+f7oVGgqex+HENy5OETY5drglVxyEqMEALipRpoV92V0H/lJk5p8yZXEI8MRDU51zgD69d6BCUCmr5ml08pxxWWusVYjk+MYvMvJB3TeAvps4QdSLplNdHZqXhjikT0Ivj7DZiVpre65Hi/Qov0SXTS06nQNC61ec9wlmP9/TudZQZ3ggm9w1s0ziFVKyDLMJhdrE/3PQpmhtSWDme1vTBV2pqiB8x76gYg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 13:37:14.9624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55f49997-62d6-4d33-143b-08dcca8b3101 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR19MB3871 X-OriginatorOrg: ddn.com X-BESS-ID: 1725203387-104050-14418-8297-1 X-BESS-VER: 2019.3_20240829.2013 X-BESS-Apparent-Source-IP: 104.47.70.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYmxmYWQGYGUNTc1CQ5zcTCJC 3J1Mg8NSXJ2MTI1MzSwMDS0iTNwDTNUqk2FgAL0xEmQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.258745 [from cloudscan13-175.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 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_SC0_MISMATCH_TO, BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This is to allow copying into the buffer from the application without the need to copy in ring context (and with that, the need that the ring task is active in kernel space). Also absolutely needed for now to avoid this teardown issue 1525.905504] KASAN: null-ptr-deref in range [0x00000000000001a0-0x00000000000001a7] [ 1525.910431] CPU: 15 PID: 183 Comm: kworker/15:1 Tainted: G O 6.10.0+ #48 [ 1525.916449] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 1525.922470] Workqueue: events io_fallback_req_func [ 1525.925840] RIP: 0010:__lock_acquire+0x74/0x7b80 [ 1525.929010] Code: 89 bc 24 80 00 00 00 0f 85 1c 5f 00 00 83 3d 6e 80 b0 02 00 0f 84 1d 12 00 00 83 3d 65 c7 67 02 00 74 27 48 89 f8 48 c1 e8 03 <42> 80 3c 30 00 74 0d e8 50 44 42 00 48 8b bc 24 80 00 00 00 48 c7 [ 1525.942211] RSP: 0018:ffff88810b2af490 EFLAGS: 00010002 [ 1525.945672] RAX: 0000000000000034 RBX: 0000000000000000 RCX: 0000000000000001 [ 1525.950421] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000000001a0 [ 1525.955200] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 [ 1525.959979] R10: dffffc0000000000 R11: fffffbfff07b1cbe R12: 0000000000000000 [ 1525.964252] R13: 0000000000000001 R14: dffffc0000000000 R15: 0000000000000001 [ 1525.968225] FS: 0000000000000000(0000) GS:ffff88875b200000(0000) knlGS:0000000000000000 [ 1525.973932] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1525.976694] CR2: 00005555b6a381f0 CR3: 000000012f5f1000 CR4: 00000000000006f0 [ 1525.980030] Call Trace: [ 1525.981371] [ 1525.982567] ? __die_body+0x66/0xb0 [ 1525.984376] ? die_addr+0xc1/0x100 [ 1525.986111] ? exc_general_protection+0x1c6/0x330 [ 1525.988401] ? asm_exc_general_protection+0x22/0x30 [ 1525.990864] ? __lock_acquire+0x74/0x7b80 [ 1525.992901] ? mark_lock+0x9f/0x360 [ 1525.994635] ? __lock_acquire+0x1420/0x7b80 [ 1525.996629] ? attach_entity_load_avg+0x47d/0x550 [ 1525.998765] ? hlock_conflict+0x5a/0x1f0 [ 1526.000515] ? __bfs+0x2dc/0x5a0 [ 1526.001993] lock_acquire+0x1fb/0x3d0 [ 1526.004727] ? gup_fast_fallback+0x13f/0x1d80 [ 1526.006586] ? gup_fast_fallback+0x13f/0x1d80 [ 1526.008412] gup_fast_fallback+0x158/0x1d80 [ 1526.010170] ? gup_fast_fallback+0x13f/0x1d80 [ 1526.011999] ? __lock_acquire+0x2b07/0x7b80 [ 1526.013793] __iov_iter_get_pages_alloc+0x36e/0x980 [ 1526.015876] ? do_raw_spin_unlock+0x5a/0x8a0 [ 1526.017734] iov_iter_get_pages2+0x56/0x70 [ 1526.019491] fuse_copy_fill+0x48e/0x980 [fuse] [ 1526.021400] fuse_copy_args+0x174/0x6a0 [fuse] [ 1526.023199] fuse_uring_prepare_send+0x319/0x6c0 [fuse] [ 1526.025178] fuse_uring_send_req_in_task+0x42/0x100 [fuse] [ 1526.027163] io_fallback_req_func+0xb4/0x170 [ 1526.028737] ? process_scheduled_works+0x75b/0x1160 [ 1526.030445] process_scheduled_works+0x85c/0x1160 [ 1526.032073] worker_thread+0x8ba/0xce0 [ 1526.033388] kthread+0x23e/0x2b0 [ 1526.035404] ? pr_cont_work_flush+0x290/0x290 [ 1526.036958] ? kthread_blkcg+0xa0/0xa0 [ 1526.038321] ret_from_fork+0x30/0x60 [ 1526.039600] ? kthread_blkcg+0xa0/0xa0 [ 1526.040942] ret_from_fork_asm+0x11/0x20 [ 1526.042353] Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 9 +++ fs/fuse/dev_uring.c | 186 ++++++++++++++++++++++++++++++++------------------ fs/fuse/dev_uring_i.h | 15 ++-- fs/fuse/fuse_dev_i.h | 2 + 4 files changed, 143 insertions(+), 69 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9f0f2120b1fa..492bb95fde4e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -769,6 +769,15 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) cs->pipebufs++; cs->nr_segs++; } + } else if (cs->is_uring) { + cs->pg = cs->ring.pages[cs->ring.page_idx++]; + /* + * non stricly needed, just to avoid a uring exception in + * fuse_copy_finish + */ + get_page(cs->pg); + cs->len = PAGE_SIZE; + cs->offset = 0; } else { size_t off; err = iov_iter_get_pages2(cs->iter, &page, PAGE_SIZE, 1, &off); diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index a65c5d08fce1..4cc0facaaae3 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -29,6 +29,9 @@ #include #include +#define FUSE_RING_HEADER_PG 0 +#define FUSE_RING_PAYLOAD_PG 1 + struct fuse_uring_cmd_pdu { struct fuse_ring_ent *ring_ent; }; @@ -250,6 +253,21 @@ static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) fuse_request_end(req); } +/* + * Copy from memmap.c, should be exported + */ +static void io_pages_free(struct page ***pages, int npages) +{ + struct page **page_array = *pages; + + if (!page_array) + return; + + unpin_user_pages(page_array, npages); + kvfree(page_array); + *pages = NULL; +} + /* * Release a request/entry on connection tear down */ @@ -275,6 +293,8 @@ static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, if (ent->fuse_req) fuse_uring_stop_fuse_req_end(ent); + io_pages_free(&ent->user_pages, ent->nr_user_pages); + ent->state = FRRS_FREED; } @@ -417,6 +437,7 @@ static int fuse_uring_out_header_has_err(struct fuse_out_header *oh, goto seterr; } + /* FIXME copied from dev.c, check what 512 means */ if (oh->error <= -512 || oh->error > 0) { err = -EINVAL; goto seterr; @@ -465,53 +486,41 @@ static int fuse_uring_out_header_has_err(struct fuse_out_header *oh, static int fuse_uring_copy_from_ring(struct fuse_ring *ring, struct fuse_req *req, - struct fuse_ring_ent *ent) + struct fuse_ring_ent *ent, + struct fuse_ring_req *rreq) { - struct fuse_ring_req __user *rreq = ent->rreq; struct fuse_copy_state cs; struct fuse_args *args = req->args; struct iov_iter iter; - int err; - int res_arg_len; + int res_arg_len, err; - err = copy_from_user(&res_arg_len, &rreq->in_out_arg_len, - sizeof(res_arg_len)); - if (err) - return err; - - err = import_ubuf(ITER_SOURCE, (void __user *)&rreq->in_out_arg, - ent->max_arg_len, &iter); - if (err) - return err; + res_arg_len = rreq->in_out_arg_len; fuse_copy_init(&cs, 0, &iter); cs.is_uring = 1; + cs.ring.pages = &ent->user_pages[FUSE_RING_PAYLOAD_PG]; cs.req = req; - return fuse_copy_out_args(&cs, args, res_arg_len); + err = fuse_copy_out_args(&cs, args, res_arg_len); + + return err; } - /* - * Copy data from the req to the ring buffer - */ +/* + * Copy data from the req to the ring buffer + */ static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, - struct fuse_ring_ent *ent) + struct fuse_ring_ent *ent, + struct fuse_ring_req *rreq) { - struct fuse_ring_req __user *rreq = ent->rreq; struct fuse_copy_state cs; struct fuse_args *args = req->args; - int err, res; + int err; struct iov_iter iter; - err = import_ubuf(ITER_DEST, (void __user *)&rreq->in_out_arg, - ent->max_arg_len, &iter); - if (err) { - pr_info("Import user buffer failed\n"); - return err; - } - fuse_copy_init(&cs, 1, &iter); cs.is_uring = 1; + cs.ring.pages = &ent->user_pages[FUSE_RING_PAYLOAD_PG]; cs.req = req; err = fuse_copy_args(&cs, args->in_numargs, args->in_pages, (struct fuse_arg *)args->in_args, 0); @@ -520,10 +529,7 @@ static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, return err; } - BUILD_BUG_ON((sizeof(rreq->in_out_arg_len) != sizeof(cs.ring.offset))); - res = copy_to_user(&rreq->in_out_arg_len, &cs.ring.offset, - sizeof(rreq->in_out_arg_len)); - err = res > 0 ? -EFAULT : res; + rreq->in_out_arg_len = cs.ring.offset; return err; } @@ -531,11 +537,11 @@ static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, static int fuse_uring_prepare_send(struct fuse_ring_ent *ring_ent) { - struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_ring_req *rreq = NULL; struct fuse_ring_queue *queue = ring_ent->queue; struct fuse_ring *ring = queue->ring; struct fuse_req *req = ring_ent->fuse_req; - int err = 0, res; + int err = 0; if (WARN_ON(ring_ent->state != FRRS_FUSE_REQ)) { pr_err("qid=%d tag=%d ring-req=%p buf_req=%p invalid state %d on send\n", @@ -551,25 +557,27 @@ fuse_uring_prepare_send(struct fuse_ring_ent *ring_ent) __func__, queue->qid, ring_ent->tag, ring_ent->state, req->in.h.opcode, req->in.h.unique); + rreq = kmap_local_page(ring_ent->user_pages[FUSE_RING_HEADER_PG]); + /* copy the request */ - err = fuse_uring_copy_to_ring(ring, req, ring_ent); + err = fuse_uring_copy_to_ring(ring, req, ring_ent, rreq); if (unlikely(err)) { pr_info("Copy to ring failed: %d\n", err); goto err; } /* copy fuse_in_header */ - res = copy_to_user(&rreq->in, &req->in.h, sizeof(rreq->in)); - err = res > 0 ? -EFAULT : res; - if (err) - goto err; + rreq->in = req->in.h; + err = 0; set_bit(FR_SENT, &req->flags); - return 0; - +out: + if (rreq) + kunmap_local(rreq); + return err; err: fuse_uring_req_end(ring_ent, true, err); - return err; + goto out; } /* @@ -682,16 +690,13 @@ static void fuse_uring_commit(struct fuse_ring_ent *ring_ent, { struct fuse_ring *ring = ring_ent->queue->ring; struct fuse_conn *fc = ring->fc; - struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_ring_req *rreq; struct fuse_req *req = ring_ent->fuse_req; ssize_t err = 0; bool set_err = false; - err = copy_from_user(&req->out.h, &rreq->out, sizeof(req->out.h)); - if (err) { - req->out.h.error = err; - goto out; - } + rreq = kmap_local_page(ring_ent->user_pages[FUSE_RING_HEADER_PG]); + req->out.h = rreq->out; err = fuse_uring_out_header_has_err(&req->out.h, req, fc); if (err) { @@ -701,7 +706,8 @@ static void fuse_uring_commit(struct fuse_ring_ent *ring_ent, goto out; } - err = fuse_uring_copy_from_ring(ring, req, ring_ent); + err = fuse_uring_copy_from_ring(ring, req, ring_ent, rreq); + kunmap_local(rreq); if (err) set_err = true; @@ -830,6 +836,46 @@ __must_hold(ring_ent->queue->lock) return 0; } +/* + * Copy from memmap.c, should be exported there + */ +static struct page **io_pin_pages(unsigned long uaddr, unsigned long len, + int *npages) +{ + unsigned long start, end, nr_pages; + struct page **pages; + int ret; + + end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; + start = uaddr >> PAGE_SHIFT; + nr_pages = end - start; + if (WARN_ON_ONCE(!nr_pages)) + return ERR_PTR(-EINVAL); + + pages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); + if (!pages) + return ERR_PTR(-ENOMEM); + + ret = pin_user_pages_fast(uaddr, nr_pages, FOLL_WRITE | FOLL_LONGTERM, + pages); + /* success, mapped all pages */ + if (ret == nr_pages) { + *npages = nr_pages; + return pages; + } + + /* partial map, or didn't map anything */ + if (ret >= 0) { + /* if we did partial map, release any pages we did get */ + if (ret) + unpin_user_pages(pages, ret); + ret = -EFAULT; + } + kvfree(pages); + return ERR_PTR(ret); +} + + /* FUSE_URING_REQ_FETCH handler */ static int fuse_uring_fetch(struct fuse_ring_ent *ring_ent, struct io_uring_cmd *cmd, unsigned int issue_flags) @@ -837,39 +883,48 @@ static int fuse_uring_fetch(struct fuse_ring_ent *ring_ent, { struct fuse_ring *ring = ring_ent->queue->ring; struct fuse_ring_queue *queue = ring_ent->queue; - int ret; + int err; /* No other bit must be set here */ - ret = -EINVAL; + err = -EINVAL; if (ring_ent->state != FRRS_INIT) - goto err; + goto err_unlock; /* * FUSE_URING_REQ_FETCH is an initialization exception, needs * state override */ ring_ent->state = FRRS_USERSPACE; - ret = fuse_ring_ring_ent_unset_userspace(ring_ent); - if (ret != 0) { - pr_info_ratelimited( - "qid=%d tag=%d register req state %d expected %d", - queue->qid, ring_ent->tag, ring_ent->state, - FRRS_INIT); + fuse_ring_ring_ent_unset_userspace(ring_ent); + + err = _fuse_uring_fetch(ring_ent, cmd, issue_flags); + if (err) + goto err_unlock; + + spin_unlock(&queue->lock); + + /* must not hold the queue->lock */ + ring_ent->user_pages = io_pin_pages(ring_ent->user_buf, + ring_ent->user_buf_len, + &ring_ent->nr_user_pages); + if (IS_ERR(ring_ent->user_pages)) { + err = PTR_ERR(ring_ent->user_pages); + pr_info("qid=%d ent=%d pin-res=%d\n", + queue->qid, ring_ent->tag, err); goto err; } - ret = _fuse_uring_fetch(ring_ent, cmd, issue_flags); - if (ret) - goto err; - /* * The ring entry is registered now and needs to be handled * for shutdown. */ atomic_inc(&ring->queue_refs); -err: + return 0; + +err_unlock: spin_unlock(&queue->lock); - return ret; +err: + return err; } /** @@ -920,7 +975,9 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) if (unlikely(fc->aborted || queue->stopped)) goto err_unlock; - ring_ent->rreq = (void __user *)cmd_req->buf_ptr; + ring_ent->user_buf = cmd_req->buf_ptr; + ring_ent->user_buf_len = cmd_req->buf_len; + ring_ent->max_arg_len = cmd_req->buf_len - offsetof(struct fuse_ring_req, in_out_arg); ret = -EINVAL; @@ -930,7 +987,6 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) goto err_unlock; } - ring_ent->rreq = (void __user *)cmd_req->buf_ptr; ring_ent->max_arg_len = cmd_req->buf_len - offsetof(struct fuse_ring_req, in_out_arg); if (cmd_req->buf_len < ring->req_buf_sz) { diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index f1247ee57dc4..2e43b2e9bcf2 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -60,10 +60,17 @@ struct fuse_ring_ent { /* fuse_req assigned to the ring entry */ struct fuse_req *fuse_req; - /* - * buffer provided by fuse server - */ - struct fuse_ring_req __user *rreq; + /* buffer provided by fuse server */ + unsigned long __user user_buf; + + /* length of user_buf */ + size_t user_buf_len; + + /* mapped user_buf pages */ + struct page **user_pages; + + /* number of user pages */ + int nr_user_pages; /* struct fuse_ring_req::in_out_arg size*/ size_t max_arg_len; diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 0fbb4f28261c..63e0e5dcb9f4 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -32,6 +32,8 @@ struct fuse_copy_state { struct { /* overall offset with the user buffer */ unsigned int offset; + struct page **pages; + int page_idx; } ring; };