From patchwork Wed May 29 18:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679445 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 098B542045 for ; Wed, 29 May 2024 19:36:09 +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=1717011372; cv=fail; b=em6bJh08+jx9AHHt1fbMBVx1xUEs7bC+5z1fzmtwj2pDZS3L0mGc2p0CMiRHT6ZwNgU6yyeFmLuebK27zsB/P/Mjfg4ppwLMgK6sjKs1c3ETt037T+miWet5n6XorJjhkGDMIxfbZWSHVUMT7BWMmRDoOjbqBUZbYi0pvfmOLPY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011372; c=relaxed/simple; bh=JBYJJyOhONGEWcMQZtn6PSf+1+tV6dhuuXcUy7sQHqY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=fFNiQbTchW+7r5BrdnDo2QFcuB3efrQ+OcKeLHv4U3VIq6qt+gEGfz8XVcI6IkKNLNMwQPRKxjUi9SkP5QFjKCJxP0r0oX5s7ryyDpR9IBozlpeiiwYxIm543S4qClcrObgwnNQLqS5XFRRsaSQVfU7nvt37paBjBAlPpHg6QEs= 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=JzS+eElv; 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="JzS+eElv" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by mx-outbound47-163.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:36:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQ0r4VFn3IjiFLm/qXdSHbvEWOa2Un4rYczajourxFv+2GZGWKP1LviDLW1BM0XPJzLNrKNrrHTUfFbt9+fgpfHJiJ4qHba8WdmGNXpw+zaleKMBNlUq4lUxt6a9D36RW7tho1JmYDmQG1rPVszyhSykOk8NwYvVOOmijp3m2NXW/htXKFPSA/v2AfGbnKR0fLv7V7bUQ3VL30V5dpgCIADZh66I0FAKIOIpPzUqtANCwbysO99Yjnuv1m+p70UEbBqyU7yFpj4XlKETk1297bgc7F4y3EmiwH6fsLlm8IYzIR5/3jRXiH/rI/P0Vwy6cXL81YjEv/52lBW0owRYEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=tusvV1Y5IqVEMp+mGAs5Gmb2Tg/Ka4zR4RuLpMxZp8s=; b=Cu9u5Tklr1ZJi7B7tixa8RxvbL0PLo+28ZmYYIZCLCUTyJSpgiWHkpN2ojBXw5yV/mNYRRZNIl/jAmXydboMJAjy0WODqTScoTmomE3TzULm0fpwaHFlTCVTudLrxfXoetvj5u7xwaNVHsPSWfq/O8ilQf/RoXbctf5RmAGjfE89ww3zM/I/LQbVWiXWHH7Zob2lnfgTjxo//AyLRtyAACaszrEaaoBlYKPYrlIEcv4VT/X2QBsnxzF87Kmwu2y12jpZNzgMsXwa4ETBy2S+Tqu/6cL/pd/CdAldnPvzEaLms8zduFpJaLtdI94ZW6np+CDjbSETw7YIt0LVRq5fOw== 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=tusvV1Y5IqVEMp+mGAs5Gmb2Tg/Ka4zR4RuLpMxZp8s=; b=JzS+eElvca5bczK7r9zXJwvwf8uq+8sNJUdTxn6kd2LLgkAMzklK8mVXGbjWUSOrb3eqrx7RVW6UsbGi4CvkGWavskzadYmmlNbSxSwvIvG5hjcN4RKaGl2NbXrhByFBISbumlzPJ205GzsquATkBf/fYe4r+/ZQWpSUJiYc92k= Received: from BYAPR05CA0074.namprd05.prod.outlook.com (2603:10b6:a03:e0::15) by IA1PR19MB6227.namprd19.prod.outlook.com (2603:10b6:208:3e9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 18:00:52 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a03:e0:cafe::58) by BYAPR05CA0074.outlook.office365.com (2603:10b6:a03:e0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.18 via Frontend Transport; Wed, 29 May 2024 18:00:51 +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 CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:51 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 3E06227; Wed, 29 May 2024 18:00:50 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:36 +0200 Subject: [PATCH RFC v2 01/19] fuse: rename to fuse_dev_end_requests and make non-static Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-1-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=2022; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=JBYJJyOhONGEWcMQZtn6PSf+1+tV6dhuuXcUy7sQHqY=; b=fSlOgI41ITeTFunOzCo//OkrW2CIJwi/+wTiJv2VlzItPpZZ1zeMhbPaWm5YCQn5o1Bee34xR zhh7SAtdd75ChnKSNY7WCWU9gc6KPSZNuac5oakhzu24HYB21rR4db3 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F4:EE_|IA1PR19MB6227:EE_ X-MS-Office365-Filtering-Correlation-Id: fbfd8dce-055d-48f6-dc3e-08dc800946ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?U501DZnIvp1uG4pL2P7FU2B6wn19gIW?= =?utf-8?q?NY8a2AlxQpHREpnCeihVxLhWI8LTqX7FuCBgoXs8jv0pxkETYH0xmiiIDJ4XjEs8f?= =?utf-8?q?SnvEOO8kKka7eh8dTP8w1u6j+V/ZjRcOuNEbkQf+gPjMrEaXycRIyXSvXmkLEH2yY?= =?utf-8?q?oeOwma0IDtMDYviL3tH9SZRPeNb5NsLwbjOFcVMqRAApiAIhpnibpi9WZMp0u294x?= =?utf-8?q?j75Ado2iRrCSt/7ePgZqj5WCh4T1X4sP/MIfmn1rsWw8ZVR67waW4x4vgMnep0ixY?= =?utf-8?q?f0jYGvFcFmWOFuEvsRQpj0xF9g6ZnM1Ctroe8MGZ/Xt8C308lKgxF+1axKFf37+Wq?= =?utf-8?q?OyKu9kyXmgySUCorLj4P3eUIz2swC2GNuVTTkWpBaSV6Nuyhd+6oWcaEuL9CQQc2H?= =?utf-8?q?McQZaGsRxu3g21wXqUO76Li9JVSQJDFEcxWeMJrXUCwMzfOqjObvTqlQ3qvbWPFQ1?= =?utf-8?q?bn8uOrJIUnmu7EhCEY/0B1BPy6PYqQ1JDyzHME5xMl5r6bOZLyNcohmfislb8n/43?= =?utf-8?q?bl5bH/3NktaILu1Nug3fQFrtyO5AqI+/4Ua3s2co1w0xF1XLjke2CCoVm75mZwNem?= =?utf-8?q?h6CrTKmxLC5KexuKuYa6KWfVOEv0OJCaQJiwDScGinTOcKs4F1HxtNg8mu7nJkVwy?= =?utf-8?q?mBpUqn2rPS30mwRh5id8iiBQBqFua4MoUp3kt6wm52jjb0R3M/4VWsvB5AlgASu0N?= =?utf-8?q?YziAWIo1yVd0JJJX5kB6ZQW7VDv7BioN9RGSuNGd18XNEB9Z2oei+0Ir3jJVExDO/?= =?utf-8?q?FZi0E1tlH+XJADcWmaI5nB5mVZ2XM/4qjvZoohArSGVSPidnvh+gmokJQXfO6zEk4?= =?utf-8?q?uxQCy7q+8HJijIS19YuRbWdu879KLCtc8jRzew/2dtlDNv9rsfK0neOpsPZq1bPW3?= =?utf-8?q?UthJExhrluFSc4DWtd+IvZO+wP6pJ4L0JDYsMk/nr75oM6og8nVRO5S6jBUnyIZlO?= =?utf-8?q?dK7029yDIEMrqNPR32S68SuvxECDpwhfKsdfyYy0Mo//y7y1TPRWKOfcsZE9NImRS?= =?utf-8?q?ouSxneBUw7yWLAk70xbM/nJ3P7juSsUeQOSo/q81raUs8GQLJP66LTM3kX7KW4JaI?= =?utf-8?q?+QB3tWO2uV0Q7G8xtFzR0CR1t/KuCb/6jeD7hSdaJoeE4jV7f4OIn2+HYFsf7jsE7?= =?utf-8?q?TTYjhtrLXDa/o/iyUefGuG9mnVeY2lRv54CyKDByh4faoerWQtXsalfwQa7AZzhEv?= =?utf-8?q?TH0v65kr3XKSvHzYrGG0QV+vjkFUHeElP2pTBoXBm/Qvho1j4iHDDwgcxLtx6faSN?= =?utf-8?q?VG/tbxy44syZ/cDOxxPL8QOtZDgB6Wc310RZtBuADWhmrlexs7A3U1oo=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:(13230031)(36860700004)(376005)(1800799015)(82310400017);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YvBmqkwT88fCeJ7ukNjhCjxnKyArCTchq9qhRggaCxtSKATKWeBIWBEy56Q4Md38WnyMsX9sQssYSFoHDdXeDeMtgiWYmjy64r0TvM6OcubdbxSxdw/Nbt+5UE0/vnpTo9zVShoSnoHeTIxv0t448md46QOtu/95OuEFYoLIvJiEyBuTb7f7WJ31hr62NLc3spf7/bAX4juIw3huc1mQoHkRY2PH7OPJH9liM26vD046DlruYuoDcRBlwQ5twQShKcW4AhjdDMoVIZtw+hAzjhDrBFIzc6ZGD2xf3AHHkN+3cVh/bMhPSb9cXHjZYXtoGhwz6D09tOawuKIL3G+/FNfymUVEtyb6BT0icTPyIAdLSbtT/HP3jQFxpF19n+MyJ+KI9CUmIxKu1DvdnxlINR5d0MwAH60pVT6RcjetGscuKTet+rRQoQ/iaT7bo++CioiuoqiQlYlrqcZKqay03P3y3+91966QZEcDAAzJZh4SkwMFgDmit3jrrqmfQA5FO7ET6lYeEW6ivbe0YRbyADHrkbCZRtyFHTI1v7Jd68EJE+mTo8oK5zVhCCvJzf/X9t/Yuat+rhXM8ZH0hPmvyP0eFXtvnGp/UPHjZBcMmcHlHOeyTGwBpnR4ggRAWz1zpiyVBYlMURoAqyBm4VpUfQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:51.1728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbfd8dce-055d-48f6-dc3e-08dc800946ed 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: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6227 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011368-112195-23577-6509-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.57.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaWpgZAVgZQ0DzFwtTIxNTQMs nCzDg52dwyySjFODUtOTnRLNkoNc1UqTYWAIaVj/RBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan13-33.us-east-2a.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 3ec8bb5e68ff..5cd456e55d80 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 @@ -2135,7 +2136,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; @@ -2238,7 +2239,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); } @@ -2268,7 +2269,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 Wed May 29 18:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679412 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 9910115CD55 for ; Wed, 29 May 2024 18:34:26 +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=1717007668; cv=fail; b=JS7R5NPxfkDfHzzrwf0QUU60yPrJnxZR67YxtN1qvSVUdTpplwA85hcmky5FCTpD/u8D3aAwizRvUZpF3msFB0emAXDKpRW/72OH6evkcfM/uREtVWTHU3tJg5487CtBb7wvabPe0Vm4y7XsQrzK1yU9BTLyqvw3EhvNPaP2tqM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007668; c=relaxed/simple; bh=4k8YX2uhmq6NNHqAE1xe24NaFCdx6sUL+ZTYCqUjITQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=rMg3ZJUXK1znpIbU4lY81Jw9xLlOa6L+xiWJsce/qAw4uk73UDxgFJYH9bnJWhJRA5zbgQUiABFyxZUw6cmywYhBJR9M4ACQiQpk0G55/VDx1dT9KBd2sw7/eE5F47gnT8OVk5vB1xQlX1aZHhZH9xWxmRFJdmduiFxROcxm2JM= 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=e6EcmiMt; 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="e6EcmiMt" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2043.outbound.protection.outlook.com [104.47.55.43]) by mx-outbound16-229.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:34:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dV6tjiPPoODNV7dDhwHNxpdlS5Vj/dYyxIFyW1u7PudQ1bFJxsiNataNC6xMEUc+GLyB2EbEuV+1OEK0JiGGuBI1Uf1GukmUNDU96M4MmYOtSFqXt7O3QFjpE2x9XOV45B3yHsw4tcPOSAPCo7QDWcgOXGjhhZzzpUzCEjz6V/Xx2SKooATCiheGI81U2xF2VTxhOrRTGxzSPSbqjZt/W7npxU8VbrmUbDhUvDHge/hfpwbjjinEt1uX5xnNEhrYieRgSAdhqKrvh8q0HpgW8vudjMC97IG2TMMnrVOITNcr7iw9sWNy5iQjRoKW+sJ9bAXXe6cNVDw6DMa6hqwusQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wgOGu34MpTstBJAxRXm1ROFLuPZmdBBRewx3OfzSaKU=; b=a1Gz46GeFPfgnYyD1an/IkvbSc9FTDUerIHigUprH/lu/JZnmmwgd3utAi8QUtx+mfH4Ny+dA80hsjDMG5pt1l/etxNu3ABinOWxUrMtAK8HTAkrvBiR3HxN3lHMyKaZSOv0+UKZxZ/Vb2N54myrStMfWZi2UvvZmTFBvaw4AJyOUnnk/1TqzTUnLUvhpenO5PcFNYZB/JmuRnGECkl3MrPJ5L56a5caja8rkHHgAchs6ka7XWLeWAw/p0epC+lao9sUcmz8sPfIEjf0YwIMtpchqRVW7Qxrbe/TQ2U7BhWVQrow2aM+7KVMD83kTBsATFYU0hKmlFRsmkGCnaE53Q== 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=wgOGu34MpTstBJAxRXm1ROFLuPZmdBBRewx3OfzSaKU=; b=e6EcmiMtynTxgSizlrilaynOhafpzWUq87CpJyhDtzJs4Pc1YMP0lwIx0KcwPLApSAVkYzWIJ5bbULBo/zChX6feGKQ1f21ohQ9FRFyBOaPE2GZ8P78OpEjwFsqnQz1gV6p/b2bmRQwfOg6oweygVNz2vxomoDUn/Ef/shTSbLM= Received: from BN9PR03CA0808.namprd03.prod.outlook.com (2603:10b6:408:13f::33) by IA1PR19MB6524.namprd19.prod.outlook.com (2603:10b6:208:3a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Wed, 29 May 2024 18:00:52 +0000 Received: from BN1PEPF00004682.namprd03.prod.outlook.com (2603:10b6:408:13f:cafe::36) by BN9PR03CA0808.outlook.office365.com (2603:10b6:408:13f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:00:52 +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 BN1PEPF00004682.mail.protection.outlook.com (10.167.243.88) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:52 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 3668A2B; Wed, 29 May 2024 18:00:51 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:37 +0200 Subject: [PATCH RFC v2 02/19] fuse: Move fuse_get_dev to header file Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-2-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=1418; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=4k8YX2uhmq6NNHqAE1xe24NaFCdx6sUL+ZTYCqUjITQ=; b=dQZVlIdsu9gDX1ijkm9ihfHbc6liz4BULyR22YA8vWCSUD4U5wxFypaQ894tbpUmb7WzGzsUQ oHOPTOeZuoNB1YoHCTVVWb6bGj4jgr0fkybTeS9lvDqrOyL6yiUujtQ X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004682:EE_|IA1PR19MB6524:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b000c26-37a8-4db3-9cc2-08dc80094799 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OknXnStMvL2shXERF1bgLCsBIjV+Xsy?= =?utf-8?q?lmDYfPCxPooqrnkq7tLR/EN1WCZkdb2S59O06X6MDpehzBxBB5nZJyI+78/e+Nrb5?= =?utf-8?q?XYays2l2Lb2ibwDzcWuQUse3zIBvBqS9tP3hXjQoaasSDo9+RePL/n65BrZ0mjlRq?= =?utf-8?q?Suw1TOb41WN9vjiPK/ndCI2T3l+40b+l8Ud/O59DL93qV6u1i9/Q4XUjs8r52WJ27?= =?utf-8?q?BiGWlcACm330x+eFD1V0XIzsR1GS9iI3xju5A5bbH7A8FG/tuvB1JSg2rHxZswC1M?= =?utf-8?q?J5zz2mvTLSbF3NV2eY1HSyqDNbweHYAdPaUd3dO0DBYTgAB+Ai9gI9XTBM31s/ulq?= =?utf-8?q?8NI1cpjmwANOBTgatAOrv9YNlETfIU2eszqJsP6vY2PpE8Rs14Fwjjq9aIYQpLA9M?= =?utf-8?q?t8/FtiCvYBdqbzz2IBMmwGd4G25UX7PlIXR3Tm1PX9RhjuPkrlpQmhn/8KGwoMs2E?= =?utf-8?q?46VwTN01ES7eeLZN2p6Wl+mZHFZxSaakiYZignnirlkIO5Fs00TY3VfEXauj0T094?= =?utf-8?q?jW3OjVpSI4gwSsLOpefQPQiD+B0k5FBjLFCM78DlwnTZATDFQ2Vtypvno8E58GXsn?= =?utf-8?q?j2UxXJ8JZsPYqKL0D400P64T5LpnL4oJCEhxVkp5gOqaiYSXF4G8m99ZEmzj4djWB?= =?utf-8?q?YQU4E0yoMfvAujTdJQozuev+7QdZkPnz3+NbuItvqjkGjUihoObm5YqAzY0GZ/+dz?= =?utf-8?q?WINqisDWZrJ3EdZZPOkSLHtpHx4KIaTpdiuqt4QCIebq48wd2pjQJahLBijAA60JW?= =?utf-8?q?uoaAOGnFo5vLZ86OCg/iXoYLQZcgQ6p0XwHXA54+ZYgTWk2lyhOWNzdf+lpBTszML?= =?utf-8?q?yErtoosUR4bHW7gjBIgsDfpWg7KKdY03gvqShIkYy9leqdNl23pjlP2dCNxUzRz/J?= =?utf-8?q?tFtzp/GB+C8wqeg5RHZLRbA7JDkhEn1nB+lgP2dYZ6zuZUUsl71HFQZU8KcWVs9H7?= =?utf-8?q?ENyIVW7IkiqT7ASk1JMwYnupdY8PaETz3KGxXms21KI/T0C/2vRk2gKPh0+YlQtzN?= =?utf-8?q?m9RJ9qrlo8fetm0gXJGTnnq4rCii46ziCMp97q0I1P3mKsXbbXc6wXKx3ZQCe9zAt?= =?utf-8?q?eU99DzzpFyo37zsn1p230vw8UKoYe/JpOPjMrF7OqmXTdp3v6nLhjXdpawsIFFPbW?= =?utf-8?q?kA1EvgJAsym+UmJ3uB4QgtgWrXoz9LdMiIfula2E+QHPo7iayU7avkkdRKtKQvWHN?= =?utf-8?q?qpYaKrl3cXMHEPjZ3DcnV2+w7ud20l/C3olRk8t3itJtqZPm/hXbytNjErLLfVP7G?= =?utf-8?q?3stfFzLHQeTliFz3c/+9kLL+dacAS400PuAOk5bcXiG4ttZ8ImP1cKbY=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:(13230031)(82310400017)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HeQ9JodxLkcj7R55VkCC/gGkAtwoCknKLq3LFMffzjms6iIiW0tNHuIgzMGrZ1WqdE4AXKSRvn9cUZn8OCFe+EDoynLi29Xguoh+CZ6SNDyVM3XrhzLKwD+9+KBkKMUKgegj1EIr71s8rjWksuphHbv3l8ZBHs0WWF+6eP2NfFEW45RbxM8EdknpFzfsXEZo0r52EIcmB74lxPAkwszG7gfnh2aqngPXgAV6EL+yTMiVMSYWDKIMBDYNI77Vcul7VdnO5BM5iFbTRNxD2M1ebPdTRsriN3wTsjWBn06BJqTdyM9a95kGnRi8TNomrF9TnIMFZkBQuyHmypn3qNloo7knUb1JEHH6cZ+ePo7/z4zpxxGzKV+j3x2y7CKolAd1+Pd5YsUF/mcK45cXlJg9tQ1yJczG7jhPsx7O5B2bL29UXMRPFGEa7GrEQAEUdUA3POPbiHephPs5boJiOnqDmjLrBLsQ4EePV4LAPrbOwNYOruo/9qOeKW3DTGRo35Ma7hCuII74P8YhhrFq1oFoeQBgv16Xz+ZHmP1LodqXxVc2DxfIBdGIprhSk0RzZ4pkm/PtHqJu9FVQ37NhVZcqpeqBkGh93lFkpSRge5mklMQ2o8mNKzzkK8UO2hDYH9wORa00rdBGe/53F3tttQ2hoQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:52.1109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b000c26-37a8-4db3-9cc2-08dc80094799 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: BN1PEPF00004682.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6524 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007665-104325-16135-2858-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.55.43 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobGZuZAVgZQ0CDN1NDcOMUgxc TQ0sIkMdkoLdHcwMQyOdEoxdAsKTlVqTYWAOLVMt5BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan23-4.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 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 5cd456e55d80..3317942b211c 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 Wed May 29 18:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679406 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 58DC015B990 for ; Wed, 29 May 2024 18:32:34 +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=1717007555; cv=fail; b=YoExcxU0VbkIE8kTNkitujN4ltW4Y/yzI7fsnkpnP6ApNKekrKtvyNpcAJPyAjgYd2x0uReKpKrueA1I7BY1oASQeo28zn5bQk9ZcXrwd9O4rYKWqG586qBdZcDCrIimh0VNX7mWp8PFEr/DvsU8Q3gfo4yDtPyWS17INcHNbfU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007555; c=relaxed/simple; bh=5P+SlHhnYL+H2qDGLLceYVEx54wv23x8rBxC3VHaBIA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=kaS5Pksd5SfEF69d0wb7nr2aGPm4n4VkvpXS4UFSuMqOpL0/Sjr4j8AnZXXMNx70j1pvVYJpUd7jp77xJ4tbXqu2XuIg+xyQ6vuDS8hxhQG8RJOE6bphtUoEjIVHvtoDxeu7bmDk4o9umRpssc3WApyh1t50iuTSDM2GdhZAnYc= 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=Udz61Use; 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="Udz61Use" Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2169.outbound.protection.outlook.com [104.47.73.169]) by mx-outbound43-95.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:32:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HqclSzZedTANCDhEVIwn2Uqslv+qXaq2tmWYFSp2T0mKH5ttfp/KxpeSopSoaXMQ+sIXHDTiYq26SUmolqdqZ+7oeKq2edU9XMj0NOiQYvaubXi34gU3AAjhlX/5tTsAOHiY4DUfoRBq0xSne11teF5+nZc47cq1z4KFVvscvbvwkRWZCV7MNBsP3xNVfdD0K8KlXWrAeWWFGG069dg+vmfzWga+Y8Y0IwcpwH6WMqtzOx9PKSGMn8rHG+IZSJ6ByU8FlKfB5FkHODr2XtbyXQ6H/kXrjFwh7rPHVtYiXwAijuYS5TsKG42PyEfwYSBVtnUrPqu7NQ0MaobRqOe23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=aASvbKn+gE8AZu7tSrVfXZnhZs5w6zP3ns3NT3u/usU=; b=NEikDEAGbKFJZzi8BfyUpaCTRqXNzU7BjOqOSTeWZWaEcDNnKWvrn6n93L+OMI08xHIWBg1GrSq/WVYAzTvR53XaHsCq/b2bzrj/K/LvAM7CQcRjLkZs/HCgTwdcTdEMnPhgGnpcJuhODhLEuWSc7rjpO4Y4OrT01cZD2ulW6JeDAkl9XgFPZ3zceuZUzUxMZ+mpOBPx5odguOKuW8CTexm8nP6Og8eFh3O5gBhXyEWEV3h3N8//JNm3qvz3OQkvIXKXlDqU7oReSNg4cw8NS176A3a/goR6HVeu1s8hmSWHW/4h8jgOMcvUm0dAAdkLvoWD7NXivIk12vX2DDUjmw== 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=aASvbKn+gE8AZu7tSrVfXZnhZs5w6zP3ns3NT3u/usU=; b=Udz61UseCywoXwA/gVaxbWtYym3nRkApKTbJ0mHFzLgjcHZ1LkuMe0MmkBAOzvPsQHEnYxyrQipV8EpnyWk6wIE2Ca2gLyDhrbPOHUZMxDSCmUg0B76gBoORTxqbAQuLn7xRK83GMvcn5CQyTnPWTdQhrEc6PdwBu1/Iw5t7zGw= Received: from CH0PR08CA0002.namprd08.prod.outlook.com (2603:10b6:610:33::7) by BL0PR1901MB4721.namprd19.prod.outlook.com (2603:10b6:208:1ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 18:00:53 +0000 Received: from CH1PEPF0000AD7D.namprd04.prod.outlook.com (2603:10b6:610:33:cafe::52) by CH0PR08CA0002.outlook.office365.com (2603:10b6:610:33::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.18 via Frontend Transport; Wed, 29 May 2024 18:00:53 +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 CH1PEPF0000AD7D.mail.protection.outlook.com (10.167.244.86) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Wed, 29 May 2024 18:00:52 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 330C825; Wed, 29 May 2024 18:00:52 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:38 +0200 Subject: [PATCH RFC v2 03/19] fuse: Move request bits Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-3-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=1165; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=5P+SlHhnYL+H2qDGLLceYVEx54wv23x8rBxC3VHaBIA=; b=2R0WPTWASSU0CasQsjhXxXy5gg3mO1J70SSQpabQ8PaV53rTL2NjybsBhGNBPuEX1Jijwyj0X IHtxp/AeQGdD3pfvxSJsgPDxZp5CXzPIvDqZ2j1F67FHFthCilOV2xd X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7D:EE_|BL0PR1901MB4721:EE_ X-MS-Office365-Filtering-Correlation-Id: ec2e5acf-91ff-4e9a-7471-08dc800947f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?zY+3o6Vfq+lEJ8iuBTK6Ekuh0jG3s15?= =?utf-8?q?9IDaKIOCmAJKDeNUSMUJlGcl/nL5X2gLkpwljf8e12XpcwOoH758Gb1vj7ZlJ4oOC?= =?utf-8?q?UhzdJTLpJWMgXgkWwCqinSockEQTGQMo7H04C072w/z0xCzgp1cO9yqZ/Y5575dNR?= =?utf-8?q?V8iNtZJsAJ/rJzkBl7/i/AilMBqkPd5R9j8rl2Ybt9R7Rdgvtt85Dso2JXVKI2v8G?= =?utf-8?q?RAXKQOiQIxIeiYbl8pKKY/Dk/qwXOYAdvybHS3cZF1l48X/6OKSzoYQd1cHchQOXN?= =?utf-8?q?uYxnPbqbbXpep1Ym6NU6KiY6shCo3fY0Ws9q1aMtU7HzR1U+Ws6PZqLAT8YqRJpCY?= =?utf-8?q?p+Z1T0MAzrzMRhF16KK1gVYhhXVbHMCctITtv6TEgetZaY0XI1w5lK5TIrb9b9SB4?= =?utf-8?q?hbJQRCRVU92dieE9wEeCaFRnjRUNTylck4oON/DwfaJtjLFnnYZvjXw77S+XvlTkZ?= =?utf-8?q?haOZCB9w7KFbA4silvG7S39PlufMUHWRboY05aAxaCmKuDgr1pGc7aZgkCgbnUba2?= =?utf-8?q?zAjvpPPBlK6tDULWswBoIijcCrNe20Wssa/l6iDq7lGu9YgbPervO/wT3rEg2IM9o?= =?utf-8?q?rVVcCneZxFSUj+WGnDcUlgLeBbY9CZ2OyRHWHE2e7vRHuLnE/Bm4U/jnuF8WVMzVm?= =?utf-8?q?wUAcsKPcrZp2mYcOKeA0l+sqaTj6k8iIK/RjBLUCedPj9fzr++sQPJFDZKwogQjvh?= =?utf-8?q?tYkVyHxHkGk9SzEGw2G8wmRcdfOfDPsb8EI14y39cX2n38iIRzhAw85TEAEIuvtsd?= =?utf-8?q?j0k0XYt+bLdCgXDwetk+Neia4fyodKsNQCR9Yk9ZiQjpJhjzeWrOfSxA1XklPiJmP?= =?utf-8?q?OSqEo8ILtlK8sQLyP5hAETOO6mfgUUbpkqUGCmlCNddDVkn5MbpNPFVaS2FXen0Hc?= =?utf-8?q?yEske0SB1+3w07fdlvsZRnM66NQEYInFp+9QeRTELRkUSTuEQHXPySRVEVpb/Fsl4?= =?utf-8?q?7/5/oyGBP0RU76q0oMnStg6JKJ6hXJmyke6EAUpn5SM7IHMgSeP6aTqn1wZSW5n5X?= =?utf-8?q?d1nzqUvxFeCzjYxgKI2Zb5lL4wD8JDsFdOzVl/tkPbb5E2J/VcnLRCnRPULNHD4i9?= =?utf-8?q?TO5qKrVavarTubLR6DgxRix8l7IAW+YrZpHG3SD3gkLoE6idpe32HAbMuGAO83bbA?= =?utf-8?q?UmtJpQtW+wLHS91fWNYxQzPVBljyqd5f3ZU9C/Fc6Zfw3JMsNEXC3iTDTlHFXLjw7?= =?utf-8?q?L9nSAStFmOlWhUD49WTwece8aZIjeY3x2gUE/Visw7Wqoqz2mixlvnUZQ2jAoFzyv?= =?utf-8?q?C0wx7sv9jb6t0aLBnNz5235xrZyguGe/WU4W9YFBSxwz57KInDvWZ+Q5FmWUf8J2D?= =?utf-8?q?abVB3LwczaKW?= 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:(13230031)(1800799015)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: A4S+gPmxwDTpzhEhl1Gt7vC328WqgahzDYJNElAkOfQhkiW+++3XozU2HlR9gBHAgrFjdSXilZ5GAFgbIokFAbgt80f5ej6IkEIXcgDNRV8nJq+6QmktCG/of5L2g5WGU1KRVQwHOit+izs8EoVrG8/wyWVHD+3JbtqQ2kEVyH5QGdHg7B5tKtuHlfVJ77xXs3yw4Stxa2/WSCustXSq6nAy1BUV1am7cCdYGDdw0idz6IMgxtGqaOSeiBTOMJxKy0GqE0dk7LxpuMVTsKanCaCKZa/YWxChBIj76J2o/Yw4y2cbbdFeFGdDxqn9DXJ2i/wPV9WNphAlWnL4VHDxFGICEugOs2cux4w8Z7nWXKY0ODedGYULSIalyulUCNkPvNtyzNLXonmGRhDbJ2TY8J7aaEcdGZMgUOkZH9OlGfryOY12VuONjjPrNcK07r2uTnIVXQ26/cAEDmLY1iC/9OAtnXBDb9AnzpX3YtusnJZTh1hV1ReDXPMkg6iAtPJe9W9bSVruo3KUlZT6mf9my493ZbiqWNflt+2OW1ZOXi8C3sFxCWsABL0GOt4XuSE3bqaWbzP5jwOZKU4LLPAM7WYT3EohYi4RdToAa0gAswOxC2cR2WRYJL0izDZK05/QlxBS4DGjoz5d/k1UinyHWQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:52.8872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec2e5acf-91ff-4e9a-7471-08dc800947f3 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: CH1PEPF0000AD7D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR1901MB4721 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007552-111103-12694-19299-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.73.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGRqZAVgZQ0CLRNNk8zdwyLc nQLMk8ycgi1cLAwiDV3NjSKM3MzMxAqTYWAN+niK9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan13-251.us-east-2a.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 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 3317942b211c..b98ecb197a28 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 Wed May 29 18:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679407 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 B024A15B990 for ; Wed, 29 May 2024 18:32: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=1717007581; cv=fail; b=TA486xAn54uQ+GMqlo78hLYGQCDKeCiqLCPT0hhGGjXvP/vdyCsxdjVVOLDbje9hu2i95RpsBFvXI9R+jnvvihEh5hJl1vZ5HHzC02z6T1CijKA9YpCKiyrN8P6uOPrs6JFEvUoH0MFsGRIFnMkB/psBwD4HsjJkzqx5rGwTlZo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007581; c=relaxed/simple; bh=2oRBpghdIVzUmIomRZOx7rijf9klETRUjTUcOQyERag=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=BoAhx63WaEZsyyQf7ubYUNUfxz88DbjV6Mvb9t+0HuNpkzuyNcw5amtlKLjR7B8qXm07JNSYBW0jAjms57BxZ80wV3EC/1OOFlQiTsos+BLXIrffuYvFminYFKorTl2P7ORF/Zb04mQvvO3rWhMeyaibtsC73lsUHiZYeryhwi0= 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=hNQBDhW3; 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="hNQBDhW3" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by mx-outbound41-156.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:32:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMoJjpp/J+7JnKEpYP26GY4xTcQrQIIIm3JqPxm2TlVwH6/49+3xE3q3peaYJsoRqRDgw7xtvta+9zap8wQBBicY+AWFTfYusTXeur+KbUb0k8jr8gv7LyZN2c9eueI0aW0/2T5cG5lZ4Twn581ZS5VMgA34YvG6NZZvkLUxwEKCx11LUWJV4KBUbZDDfQ1VEzULvMPvWhDTNN6JFl49uaH08kvI2nTslIzN2jgDKSd2X544iGLT/tNcKVp91nmxfwdeO+9FJc0xouBWnXhFe6CmhJOVjD3sQmbbde7IlFCVHJPgMW9MCXuTKyYbm6s1BeGSU//JkzbuaYXY3LD2TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=GVzBvKl+FMCpgqb1qLNeCiaW0jRxWaQYCrVD+BGV2nQ=; b=KWVumjVMY7jtgNWn2PUIHZjRXNC92+258HktujTztWAFYtZ5ylle+MdgEfh95FG+5agt2cZbT50RL9ssnbSrq0Xxx7TYZUT13GY+iVCMBR8JLerdUhvQUgna6trdNMwBkpzd5wRr8WPpIu4sH+/B/y9zjz8q/C23bbB6m9FtZYRz4TCh/WUteC/sNfG/JtrqDRSu7BsPkmxAZi9r+FCU34JLlXGf7LzujdnMaW2E8sBTYzuIS2aiy7OnYUbjpfm3w71/1C0FJGZd2AMtwsIKcvsTDjT+kuGi5ZGSn0PrlwcneoDryxA6MrYeceah41DZf5JhpxLqs6u2DFMyyZX+PA== 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=GVzBvKl+FMCpgqb1qLNeCiaW0jRxWaQYCrVD+BGV2nQ=; b=hNQBDhW3ONsK/t5LqtbcPFml/ehDDyhmOaP8raCq/yO2pWMVW/CrH+wntne1sps8DAUhlm69XlLx4Dg/uKgOb26BjRj20oRBhna6b+/JxHmlpmB9V535/tjV4hhOSwLSw6cI8dePbqyxzRUGI7PTdqnKDxZ6Sxebs2/g1A85DQk= Received: from SA9PR13CA0147.namprd13.prod.outlook.com (2603:10b6:806:27::32) by CO1PR19MB5221.namprd19.prod.outlook.com (2603:10b6:303:f1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 18:00:54 +0000 Received: from SN1PEPF0002529D.namprd05.prod.outlook.com (2603:10b6:806:27:cafe::e8) by SA9PR13CA0147.outlook.office365.com (2603:10b6:806:27::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.16 via Frontend Transport; Wed, 29 May 2024 18:00:54 +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 SN1PEPF0002529D.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:53 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 2D79627; Wed, 29 May 2024 18:00:53 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:39 +0200 Subject: [PATCH RFC v2 04/19] fuse: Add fuse-io-uring design documentation Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-4-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=6989; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=2oRBpghdIVzUmIomRZOx7rijf9klETRUjTUcOQyERag=; b=Yfj94flXUxOiHkrpgmCnqepkj00eMggRc0IBC7d4VDZZlyXgtD94CKYZDUmeUKX4j3b3i10yV rycp9/EvLxgCfmHLctTCNcM2wTN6g3YO3/H7f1Q+KohT9peVJdxKdnu X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002529D:EE_|CO1PR19MB5221:EE_ X-MS-Office365-Filtering-Correlation-Id: 52c2b771-85cd-498e-6541-08dc80094896 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?67vSMBD4me/8An4QRQ2uXuim+tP5DnR?= =?utf-8?q?BZbHWPzMuUEPhj8vSQ3Rg19S6f+z8JB9s5aeI4La1fOyZiGOUyuaXGZxGH9oSMnij?= =?utf-8?q?ZsQ06F8v1LKyB24LZq7l9YdzLNWI3GxcWYRRA1hwm/a+v+BZSLYe/qo2vEHu7JQ/W?= =?utf-8?q?mEvnxgeHcUtjD5B7elZJO3jU3vCXPVAOVi++OG/MmPdwy4AUX/8SpeENn4T2QerP5?= =?utf-8?q?eSGNxPtyxTmCQuWIhD7u0llO4wjjlqUUSl3os9aK5jiAXYxZDWUAAmMa63ekBEQjz?= =?utf-8?q?vpDP8SdN5Ayq/t+ZpVx/y9O7FyUxwfQpQnlrsDf0FElknywIqmUOsVgrmm2d10fJ+?= =?utf-8?q?pf0PQzN2fxyTB0gAynCUFv/c14sGNkQmHPW0hPPUwCy0KwaxwXWdbZEZ2lp3pK+lh?= =?utf-8?q?A3cR2kzGSSIHuf8K+1ZOlIOb+wAUez/R5pbnQWYhuUKf9FpItlqOSiobgYZVxP0bf?= =?utf-8?q?fS08A+GhnGbmLTzrtC0FjeOYpf9UDslNfrDw2A1kielpXpD6inh/KS6hlEmrSzK9T?= =?utf-8?q?HGcyARQhMVPEtfgVQJuwHU6FLYpj4tmrj3Y2odSULKxnda0UrxK8sClTaKHMWuWwu?= =?utf-8?q?NoYS51UNYj+AWeU3pPAXsIqjlKMQrA4kBOKbZ4YI7VqikiSJuMDIKM7J/nPBtWV4f?= =?utf-8?q?96H0IyqT765/4sbTjlYjS0/w8C/78eecu3QmmrM44qHHC9Fc1KlPvfOgr9cUzNk8C?= =?utf-8?q?iQX/bouFezMcb2TVFvjxltqmCnko1DG5uYXV+jKzKsq8V/u+NME82fixTB2MPQxpn?= =?utf-8?q?6XB8am6OiiUlKavJ0VJ/0K1VsJZj74UVp9YEg9xrdHg2v5+wy4YOFOi/rtomyduJL?= =?utf-8?q?iup0m6P8Qbs1IJ5QZECFrCxSwFXUp8NxoSNk83i+t58PPWurlI/AoEKIfzwf8QpDv?= =?utf-8?q?VgCplYsgzEP/raOrkvuKfgXE77esofmFKFJGE9YYCeO2Y8LFdG6px4YcLrwyxb1PG?= =?utf-8?q?RRD0/31bn0zNFNwyk6GkCOxGeAlaG+/QKESySNHNAg7NRjOFMzJmmJqZJHM/Kmg+R?= =?utf-8?q?+qURK0J96AbV/g7AxabHLvSISuB0WU0HSkVk+2o00q32z+xBnlcOUpg2fbUSA79+Q?= =?utf-8?q?h83dARTdIh3cJ43euc+//cf6e3FuzISvl0Y9E2k3oVADwuggZySmamTDD07K9ltlm?= =?utf-8?q?OlFKYqSST2Vnu0ljS06PMeBBu1xDYPTHyKxLQrYs5zi+HLq5xtbtdUXi/ISsYOllE?= =?utf-8?q?VmKvsvs/e7IXClAhDyHl9eVk3WvYYzZnrfXOz2xjkHWx/yr53x9fB31joyhJ4JnSx?= =?utf-8?q?jiKxzfxdRMGrMSitbqqcV7TXIfVWNBmZEyWdtfHLKIuxMoRzYb9twB5iWi4t39XoO?= =?utf-8?q?wP/GGzJ5deem?= 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:(13230031)(82310400017)(376005)(36860700004)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pXkyx3z958LzrmGxmBjK2HToP+0c+QN/8uF3Nybvw4AMm5knUwXidtYUk9XKKjBaiCaQmyi77TC/GA8CS8AA5uUIG7qFq65FaWkW4JBR5yWo7VVdReG3q1CogAB87DluACpJ7aO8GXkGlIEuN/UD8olTIAJJT4HmgzTbzfK/jUML1aTruuRuRtc/SCdiMB2SWc83DVfFd6EiCz3TnOy02z5J5p2raKWLhYv04mJqcOMLiryZtS3X2sm/T+nJGnULp0ot+2RSz4zvFpAla6ZkxLa8B6ygQ75+ADz6ycB7BkaW35zSqAKyfp9mtVmEEctMLNMblDH5FtTrQvoocObJHGUMHdByhvZjpAjQdxLFD9YwSWyz5cS+GVG4ib7cjDKbP2bwDq2xpbO4mxohNlcYdlM5O34Gn3f+emoQ5Ot7WsvceLzBcQreR2J84I7ATvdJjukweHsbu7CqxqqdtHSdfcgWl3SYSwvFtkLLT1z5XEjyltboL56u7y53TK7ZedUNWobv2r0g5wPkLLpX6BMrXQaycZTj9pPjOxcpylALwkwqfuPw9FkiDvdXw062GH0nvUCPUHJeAwOMjfpjD+ZBSnXYogmQMiAuZln674mndJRBAG6R4kUZVxyPrXISHbMz7JltCdFHJVUyCcB7PNApgQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:53.8300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52c2b771-85cd-498e-6541-08dc80094896 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: SN1PEPF0002529D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR19MB5221 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007578-110652-12831-23228-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.59.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYWBpZAVgZQ0DzN0NQkNcXcwC jVINXU3DwpzcIkxcQg2dDS3Ng4xdBIqTYWAGWnJZNBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan10-167.us-east-2a.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 Signed-off-by: Bernd Schubert --- Documentation/filesystems/fuse-io-uring.rst | 167 ++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/Documentation/filesystems/fuse-io-uring.rst b/Documentation/filesystems/fuse-io-uring.rst new file mode 100644 index 000000000000..4aa168e3b229 --- /dev/null +++ b/Documentation/filesystems/fuse-io-uring.rst @@ -0,0 +1,167 @@ +.. 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 +side is required to also handle requests through /dev/fuse after +uring setup is complete. These are especially notifications (initiated +from daemon side), interrupts and forgets. +Interrupts are probably not working at all when uring is used. At least +current state of libfuse will not be able to handle those for requests +on ring queues. +All these limitation will be addressed later. + +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 ioctls, +mmap requests in the right order + +1) FUSE_DEV_IOC_URING ioctl with FUSE_URING_IOCTL_CMD_RING_CFG + +First the basic kernel data structure has to be set up, using +FUSE_DEV_IOC_URING with subcommand FUSE_URING_IOCTL_CMD_RING_CFG. + +Example (from libfuse) + +static int fuse_uring_setup_kernel_ring(int session_fd, + int nr_queues, int sync_qdepth, + int async_qdepth, int req_arg_len, + int req_alloc_sz) +{ + int rc; + + struct fuse_ring_config rconf = { + .nr_queues = nr_queues, + .sync_queue_depth = sync_qdepth, + .async_queue_depth = async_qdepth, + .req_arg_len = req_arg_len, + .user_req_buf_sz = req_alloc_sz, + .numa_aware = nr_queues > 1, + }; + + struct fuse_uring_cfg ioc_cfg = { + .flags = 0, + .cmd = FUSE_URING_IOCTL_CMD_RING_CFG, + .rconf = rconf, + }; + + rc = ioctl(session_fd, FUSE_DEV_IOC_URING, &ioc_cfg); + if (rc) + rc = -errno; + + return rc; +} + +2) MMAP + +For shared memory communication between kernel and userspace +each queue has to allocate and map memory buffer. +For numa awares kernel side verifies if the allocating thread +is bound to a single core - in general kernel side has expectations +that only a single thread accesses a queue and for numa aware +memory alloation the core of the thread sending the mmap request +is used to identify the numa node. + +The offsset parameter has to be FUSE_URING_MMAP_OFF to identify +it is a request concerning fuse-over-io-uring. + +3) FUSE_DEV_IOC_URING ioctl with FUSE_URING_IOCTL_CMD_QUEUE_CFG + +This ioctl has to be send for every queue and takes the queue-id (qid) +and memory address obtained by mmap to set up queue data structures. + +Kernel - userspace interface using uring +======================================== + +After queue ioctl setup and memory mapping 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 on the kernel side - it sets the according +entry state and marks the entry as available in the queue bitmap. + +Once all entries for all queues are submitted kernel side starts +to enqueue to ring queue(s). The request is copied into the shared +memory queue entry buffer and submitted as CQE to the userspace +side. +Userspace side handles the CQE and submits the result as subcommand +FUSE_URING_REQ_COMMIT_AND_FETCH - kernel side does completes the requests +and also marks the queue entry as available again. If there are +pending requests waiting the request will be immediately submitted +to userspace 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: 13679443 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 2C73642045 for ; Wed, 29 May 2024 19:34:59 +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=1717011301; cv=fail; b=j239A928y+IV62UZL9fp3QupucOq5SVcF1mdv23rKq89WfpmDPkuv+HwNS2SDsVlx6xBJb/1vAHT24t9J1GNmYNcDV7HKhTmz3dHFYJqmOlTXfj42lA51FRDNjk+Cp2lk7RopeCs1aei1FPXIFnNDwmV2FyKFF44ent5r7zFj70= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011301; c=relaxed/simple; bh=yezGSbNY2m7pcLSUKK3aAEUBUzPfBv6e8zEqydNY0To=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=Vo7DvKEpfGLddsAcrpne8HwbKC8LLU2KKDsbKbxYIRhg1BOFlwwdOrNHsZ19BC9Lk8+ECj93h5GN9PGVTmebNBq/PKo/2URVrT5y9WFV6v6i8dHnzuf/TbKllAeHILMJHAH0F4Ze+HzNMmFaeEIG0NHttv9n1eaQk4X7+9Og2uA= 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=SYLWaX5h; 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="SYLWaX5h" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by mx-outbound45-109.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:34:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m3tEniMkbe27CjKXn0HugNAe7ub3DyC6ei6f2i69eMZl13Dk0+kR9bnoK1wDEc9ySdw6HtMWtaWUnBO5phqEh4wxfqp/7XiNJnhBqPeTxKtOkAjchYGG0l74gEhK98BLkfBGdCQBdiQUWEQ9tZpVXsS6aZNTptHq8eMZE8ydeZdjWc+nfn076ILEhwWsnowgGVQZF2roY+dwNH9RsDFb28zbmsG4hFmLX8r2Gja5e3PyJiw+vqfuPopDKt7mhiFlx8IbBT/wvETTVL7ZktflR2L0jBJx3XHMGmuddniO5CDegtN/8Np3ycqOlAeqB77eKMiy1XWvPRGtUJ5k4fjqXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=JGz3EdpLhpl+Oj78BNRT5SmWtw4gwscCrGD822CkXqs=; b=ignQCiWLsiVXRz9LYhzYBs0SCkz/aIzsVRj6dlPvUaFTixCuH+RJEcq7/eN779wHDJaxhAeeT1sDzuiDu1Ln//Tp2Go3xIiIWbJ1gfZE1CaCCYrUWQJyekJCB8PvAR4D3XlfyaHdIa7WJcelvzVyVtlNQuOglKZ9Ck3eE8/0KuKA6paiGSKOvP9SF6hVvzNr6uYSdGzrmkMrnZMHX8ZZYC4nfNvukW5U/+bdK8FyLCpmdbbboUOq7MfivAxLsUSnQujAMUOYi1+Jnbs3cA+oYLDeY5Wj51L+lovHNfwRKqOrAivSGEZX3GKIFE6SXTgQUycXqlwtPq4iemYLxkhP3w== 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=JGz3EdpLhpl+Oj78BNRT5SmWtw4gwscCrGD822CkXqs=; b=SYLWaX5hEJiYC+R3J7cbDELdzaHQmQnN+HCg1myJ4P3IO3VbeO+kTNXwF2tktyq3srtrh0//+6VFzYmGLu8qlzzA3TAqyIM65XcZPVtQeXEM+Of2EXQ9yNPaqcTBdiXUZkCZ8AnNmD4UpE3+lWbkGtC2RxKlzIKTZ6/qkIZ0Hvg= Received: from CH2PR14CA0049.namprd14.prod.outlook.com (2603:10b6:610:56::29) by SJ0PR19MB5367.namprd19.prod.outlook.com (2603:10b6:a03:3d2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 18:00:55 +0000 Received: from CH1PEPF0000AD7C.namprd04.prod.outlook.com (2603:10b6:610:56:cafe::67) by CH2PR14CA0049.outlook.office365.com (2603:10b6:610:56::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:00:55 +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 CH1PEPF0000AD7C.mail.protection.outlook.com (10.167.244.84) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Wed, 29 May 2024 18:00:54 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 26DBC25; Wed, 29 May 2024 18:00:54 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:40 +0200 Subject: [PATCH RFC v2 05/19] fuse: Add a uring config ioctl Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-5-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=18468; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=yezGSbNY2m7pcLSUKK3aAEUBUzPfBv6e8zEqydNY0To=; b=s1lu3sRwXdHn40yCWrk3zpjfwkhpCiInCuCDVPLx3xbRcZCKlfBGRbvsDV2osS55WQlMMvBb8 QmsWG5tMlhdC0UGL8AyLHftwP74snSzXBi8pEi9d5Re25R5nQugvz9K X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7C:EE_|SJ0PR19MB5367:EE_ X-MS-Office365-Filtering-Correlation-Id: 8302581b-4122-47aa-d892-08dc8009492b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?T7RIklFlCdXrEP/IzN88y6xRmYF8JD0?= =?utf-8?q?vA5vzdPLoyct2WpH85ftrS9fCBe9HBPvrEdgyT9nzNBFDTrVbrORJEi1Fk7JYW+Nd?= =?utf-8?q?M+olmOgB9voZbLyaq+bKDa6iXuAwhGOmeFBOemIqY0KOewL9ou8yzLWDvKMl5ZoiF?= =?utf-8?q?hSP1CXOd67CeVeW8fu2PbSQc6AIr2kqRFz7nqCtSL7SmqAMpOn9q0BJAQ0bQght0B?= =?utf-8?q?xKasaZssJG1dSfseLcVP6UDu6OQxvszHVlM/e32CNmku91mHfC/bkNtUpo/9gZU69?= =?utf-8?q?1u5WQ+6NTYQON/ShVFt7OkHTwZ8AH1k87M34sy9QZl5+HwKFHq1J4/JH/VFfWR9Rn?= =?utf-8?q?hg1zUF2y/334bVG8wANIrCgSFFA6crM2TYRMEOttHudkesvvwfW2cVjVk5X2Kisik?= =?utf-8?q?tfC6Vw1tNyc0oLH519zyctYMD8mBsItz9ya99t85oy9l1gAVALjshvHEksEjmynu/?= =?utf-8?q?9JCpKT8M3mLPjRy7GPWI4KFrKUt2fqDpspDzcvkR2QHxeoJNehezaWmnToDvPrRdp?= =?utf-8?q?T+REn4uNiN/IfbR7D7JuTQ0G2v+qbetDSj1DMlkbmGoE+nMYT9tJEJtUiFSUkCT0b?= =?utf-8?q?2WBhdSr9N2RLtDMrqpMQsURBlfb3EM4T1999siRd49Se37xUUD4ok0kP4Gjqy86Qp?= =?utf-8?q?xrIK99d5vZmopUj894O2CI5f9DV6oxdgggrnIiCJVwOTSGp7V3SZ8cIpqRQOgg3WZ?= =?utf-8?q?TYCbCjhYy/Bhq5RRBrTMzPaM601IlT2XClqy66z5MLXkaEt8F8tHRV+A3GR1H5RiS?= =?utf-8?q?7q7U1jCvaYrMPdXPEQ5ZQxYo5MFLPaUcjLE5wskYql4qaDfg3VJKCEro2+pkzdlV1?= =?utf-8?q?d7vPCkRbrLTwMlivU9BLHZgmD2xvuBktn/Rmeans/C1jVoXrIVUhW7rCZrmXyeJUl?= =?utf-8?q?CDV2pcDSVSW3gC85yyYJHq2aWFF+wWLQvNWJBHaryU4uyL26f8nho/XWs8mHgLR6I?= =?utf-8?q?0DI+qh8h8dMWT1+Rb1fJ1NuMD1rL+QIlTQJo1S7rfP+oRgT0YhrlbzKwqEPJag1D6?= =?utf-8?q?8lFHy//i270BaR0k4ozkF284WY3bpDprJCbKHzdGOC2D584h39dTsrDLhHofZFhll?= =?utf-8?q?MyQwoHMjHSz79QRHNjCZHhHQ5m9tKtb/9vcxq/RQeqUclRsoz1cFYZ/kLVX+PBNM/?= =?utf-8?q?gA2zolN8cqoVaIn3YS+M12ZZ9oMh8fvYv43sJL6loV9S8MnbnXs3DLbhyOctl79b8?= =?utf-8?q?r7TPK55ub2TzC8iNpxMFyo/6fVDMN6Mfj4l+HUwBXvIkMa8/5FTRjU6q/GBoQDbz0?= =?utf-8?q?LBoW2Ppt6PbOSZjam8X+iZn2RlrKMWiTAukkGm3efrvOYFAHgmYq1PIKLGjJPaQVZ?= =?utf-8?q?oVnyaR2BLik+?= 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:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: oLkGfebqruS8bTvLGSUcZbIsPKeVinlR0TDX6oSm27+nAN/xRYTzMGq0x1WfYUj3aPC2kdVdhBbpQKvgywuyN8afb7zAhgI7ABNk2X+O6DESXPXQq144fArXQXDGHeypmYdgRIUzj+mDB7ye7os7UIR48B6bcQdiigFNh0vLoSGhJ7WGS2jWveZGETOznsrZc4s2Hfi9bBIVImE3KJzTAkJI3bj4Mxba3oMqvrbWlRHcsLE3puSOJAF56X9NXDnuAQwamhWTKNBOjY5mX/WnrQDPnqNWOz160hCdooMIcSBBqTIOpHw4IY6JO3cZKAsE57GTq22FPCuuyM69pTPVZFTlb9zVWwImIfLvg2ugiGZUV45x7eYyx4Or61nwgy1ns/0j3oOAlk9qnBLhdGyo62ao4EWxWufMt8269NtWD2BU9qabyTSzlryXpn5VcHa2H6j0BlGhKSiNwwXaF2ydldor9Sxw3J7yg2KGBenBQ590tCSTFQv2No7jzUaFUCX/sbk4o8S79S5SEshMRnCHuAWeM/UOzkQUgWJIm026oPTkf1tt3clHxmysNG5l1Nik3ZlJ3Nqpdt/0neRpTw7Zv1DZBVkmpspz9tPjdv33uGEk3GiPX0hAv/+GSYSK6Ph2wA8/KydTl+vBNxUfUjszJA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:54.9345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8302581b-4122-47aa-d892-08dc8009492b 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: CH1PEPF0000AD7C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR19MB5367 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011297-111629-12835-26231-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.70.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobm5qbmQGYGUNTMOMUs2cgi0d Qo1TQxNdHYODk5NcUiOTnFwNA4MdUgWak2FgBSAWHIQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan10-140.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 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND, BSF_SC0_MISMATCH_TO 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 | 91 ++++++++++++++++-- fs/fuse/dev_uring.c | 122 +++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 239 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_dev_i.h | 1 + fs/fuse/fuse_i.h | 5 + fs/fuse/inode.c | 3 + include/uapi/linux/fuse.h | 73 ++++++++++++++ 9 files changed, 538 insertions(+), 9 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 b98ecb197a28..bc77413932cf 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"); +#if IS_ENABLED(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) @@ -2297,16 +2305,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; @@ -2329,6 +2333,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) { @@ -2364,8 +2378,65 @@ 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) +/** + * Configure the queue for the given qid. First call will also initialize + * the ring for this connection. + */ +static long fuse_uring_ioctl(struct file *file, __u32 __user *argp) +{ +#if IS_ENABLED(CONFIG_FUSE_IO_URING) + int res; + struct fuse_uring_cfg cfg; + struct fuse_dev *fud; + struct fuse_conn *fc; + struct fuse_ring *ring; + + res = copy_from_user(&cfg, (void *)argp, sizeof(cfg)); + if (res != 0) + return -EFAULT; + + fud = fuse_get_dev(file); + if (fud == NULL) + return -ENODEV; + fc = fud->fc; + + switch (cfg.cmd) { + case FUSE_URING_IOCTL_CMD_RING_CFG: + if (READ_ONCE(fc->ring) == NULL) + ring = kzalloc(sizeof(*fc->ring), GFP_KERNEL); + + spin_lock(&fc->lock); + if (fc->ring == NULL) { + fc->ring = ring; + fuse_uring_conn_init(fc->ring, fc); + } else { + kfree(ring); + } + + spin_unlock(&fc->lock); + if (fc->ring == NULL) + return -ENOMEM; + + mutex_lock(&fc->ring->start_stop_lock); + res = fuse_uring_conn_cfg(fc->ring, &cfg.rconf); + mutex_unlock(&fc->ring->start_stop_lock); + + if (res != 0) + return res; + break; + default: + res = -EINVAL; + } + + return res; +#else + return -ENOTTY; +#endif +} + +static long +fuse_dev_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { void __user *argp = (void __user *)arg; @@ -2379,8 +2450,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); - default: - return -ENOTTY; + case FUSE_DEV_IOC_URING: + return fuse_uring_ioctl(file, argp); + + default: return -ENOTTY; } } diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c new file mode 100644 index 000000000000..702a994cf192 --- /dev/null +++ b/fs/fuse/dev_uring.c @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FUSE: Filesystem in Userspace + * Copyright (c) 2023-2024 DataDirect Networks. + */ + +#include "fuse_i.h" +#include "fuse_dev_i.h" +#include "dev_uring_i.h" + +#include "linux/compiler_types.h" +#include "linux/spinlock.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Basic ring setup for this connection based on the provided configuration + */ +int fuse_uring_conn_cfg(struct fuse_ring *ring, struct fuse_ring_config *rcfg) +{ + size_t queue_sz; + + if (ring->configured) { + pr_info("The ring is already configured.\n"); + return -EALREADY; + } + + 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; + } + + if (rcfg->req_arg_len < FUSE_RING_MIN_IN_OUT_ARG_SIZE) { + pr_info("Per req buffer size too small (%d), min: %d\n", + rcfg->req_arg_len, FUSE_RING_MIN_IN_OUT_ARG_SIZE); + return -EINVAL; + } + + if (WARN_ON(ring->queues)) + return -EINVAL; + + 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_arg_len = rcfg->req_arg_len; + ring->req_buf_sz = rcfg->user_req_buf_sz; + + ring->queue_buf_size = ring->req_buf_sz * ring->queue_depth; + + queue_sz = sizeof(*ring->queues) + + ring->queue_depth * sizeof(struct fuse_ring_ent); + ring->queues = kcalloc(rcfg->nr_queues, queue_sz, GFP_KERNEL); + if (!ring->queues) + return -ENOMEM; + ring->queue_size = queue_sz; + ring->configured = 1; + + atomic_set(&ring->queue_refs, 0); + + return 0; +} + +void fuse_uring_ring_destruct(struct fuse_ring *ring) +{ + unsigned int qid; + struct rb_node *rbn; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + vfree(queue->queue_req_buf); + } + + kfree(ring->queues); + ring->queues = NULL; + ring->nr_queues_ioctl_init = 0; + ring->queue_depth = 0; + ring->nr_queues = 0; + + rbn = rb_first(&ring->mem_buf_map); + while (rbn) { + struct rb_node *next = rb_next(rbn); + struct fuse_uring_mbuf *entry = + rb_entry(rbn, struct fuse_uring_mbuf, rb_node); + + rb_erase(rbn, &ring->mem_buf_map); + kfree(entry); + + rbn = next; + } + + mutex_destroy(&ring->start_stop_lock); +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h new file mode 100644 index 000000000000..58ab4671deff --- /dev/null +++ b/fs/fuse/dev_uring_i.h @@ -0,0 +1,239 @@ +/* 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" +#include "linux/compiler_types.h" +#include "linux/rbtree_types.h" + +#if IS_ENABLED(CONFIG_FUSE_IO_URING) + +/* IORING_MAX_ENTRIES */ +#define FUSE_URING_MAX_QUEUE_DEPTH 32768 + +struct fuse_uring_mbuf { + struct rb_node rb_node; + void *kbuf; /* kernel allocated ring request buffer */ + void *ubuf; /* mmaped address */ +}; + +/** A fuse ring entry, part of the ring queue */ +struct fuse_ring_ent { + /* + * pointer to kernel request buffer, userspace side has direct access + * to it through the mmaped buffer + */ + struct fuse_ring_req *rreq; + + /* the ring queue that owns the request */ + struct fuse_ring_queue *queue; + + struct io_uring_cmd *cmd; + + struct list_head list; + + /* + * state the request is currently in + * (enum fuse_ring_req_state) + */ + unsigned long state; + + /* array index in the ring-queue */ + int tag; + + /* is this an async or sync entry */ + unsigned int async : 1; + + struct fuse_req *fuse_req; /* when a list request is handled */ +}; + +struct fuse_ring_queue { + /* task belonging to the current queue */ + struct task_struct *server_task; + + /* + * back pointer to the main fuse uring structure that holds this + * queue + */ + struct fuse_ring *ring; + + /* issue flags when running in io-uring task context */ + unsigned int uring_cmd_issue_flags; + + int qid; + + /* + * 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; + + /* queue lock, taken when any value in the queue changes _and_ also + * a ring entry state changes. + */ + spinlock_t lock; + + /* per queue memory buffer that is divided per request */ + char *queue_req_buf; + + /* fuse fg/bg request types */ + struct list_head async_fuse_req_queue; + struct list_head sync_fuse_req_queue; + + /* available ring entries (struct fuse_ring_ent) */ + struct list_head async_ent_avail_queue; + struct list_head sync_ent_avail_queue; + + struct list_head ent_in_userspace; + + unsigned int configured : 1; + unsigned int stopped : 1; + + /* 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 to fuse_conn */ + struct fuse_conn *fc; + + /* number of ring queues */ + size_t nr_queues; + + /* number of entries per queue */ + size_t queue_depth; + + /* max arg size for a request */ + size_t req_arg_len; + + /* 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; + + /* buffer size per queue, that is used per queue entry */ + size_t queue_buf_size; + + /* Used to release the ring on stop */ + atomic_t queue_refs; + + /* Hold ring requests */ + struct fuse_ring_queue *queues; + + /* number of initialized queues with the ioctl */ + int nr_queues_ioctl_init; + + /* number of SQEs initialized */ + atomic_t nr_sqe_init; + + /* one queue per core or a single queue only ? */ + unsigned int per_core_queue : 1; + + /* Is the ring completely iocl configured */ + unsigned int configured : 1; + + /* numa aware memory allocation */ + unsigned int numa_aware : 1; + + /* 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; + + struct mutex start_stop_lock; + + wait_queue_head_t stop_waitq; + + /* mmaped ring entry memory buffers, mmaped values is the key, + * kernel pointer is the value + */ + struct rb_root mem_buf_map; + + struct delayed_work stop_work; + unsigned long stop_time; +}; + +void fuse_uring_abort_end_requests(struct fuse_ring *ring); +int fuse_uring_conn_cfg(struct fuse_ring *ring, struct fuse_ring_config *rcfg); +int fuse_uring_queue_cfg(struct fuse_ring *ring, + struct fuse_ring_queue_config *qcfg); +void fuse_uring_ring_destruct(struct fuse_ring *ring); + +static inline void fuse_uring_conn_init(struct fuse_ring *ring, + struct fuse_conn *fc) +{ + /* no reference on fc as ring and fc have to be destructed together */ + ring->fc = fc; + init_waitqueue_head(&ring->stop_waitq); + mutex_init(&ring->start_stop_lock); + ring->mem_buf_map = RB_ROOT; +} + +static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + + if (ring == NULL) + return; + + fuse_uring_ring_destruct(ring); + + WRITE_ONCE(fc->ring, NULL); + kfree(ring); +} + +static inline struct fuse_ring_queue * +fuse_uring_get_queue(struct fuse_ring *ring, int qid) +{ + char *ptr = (char *)ring->queues; + + if (unlikely(qid > ring->nr_queues)) { + WARN_ON(1); + 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..d2b058ccb677 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 + +#if IS_ENABLED(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..0449640f2501 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1079,12 +1079,79 @@ 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_uring_cfg { + /* struct flags */ + uint64_t flags; + + /* configuration command */ + uint8_t cmd; + + uint8_t padding[7]; + + union { + 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; + + /* argument (max data length) of a request */ + uint32_t req_arg_len; + + /* + * buffer size userspace allocated per request buffer + * from the mmaped queue buffer + */ + uint32_t user_req_buf_sz; + + /* ring config flags */ + uint32_t numa_aware:1; + } rconf; + + struct fuse_ring_queue_config { + /* mmaped buffser address */ + uint64_t uaddr; + + /* qid the command is for */ + uint32_t qid; + + /* /dev/fuse fd that initiated the mount. */ + uint32_t control_fd; + } qconf; + + /* space for future additions */ + uint8_t union_size[128]; + }; +}; + /* 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 _IOR(FUSE_DEV_IOC_MAGIC, 3, \ + struct fuse_uring_cfg) struct fuse_lseek_in { uint64_t fh; @@ -1186,4 +1253,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 Wed May 29 18:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679351 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 1B08AFC18 for ; Wed, 29 May 2024 18:01:13 +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=1717005685; cv=fail; b=Hy1N7pmUOb/b+qEuSM0/93VyMXIfmDudBwp1knEVFHFkePxlBB5WiCXNFn1A+B3VhmvUnhfNsFgUxllgw0ycybEApK/pxiYJJ7boqSvPM53p4PoOqj/CIeNdZ18I01n7pCAqqoKf7so2o5lFWEwlNficClFgXuwz1ZGkYP6TLJA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717005685; c=relaxed/simple; bh=MEK1vbj5ymTp2LNfUE+mfKARrGzFvVGkw7vWcp91zlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=utUtLqm7AlAGeXeUMyrx6DJMv4G2Eh+RNNoA5xEK/6KUQVPk0WQV2laRTamoIhu5MdrTcOJDnCq1Dzn01fPYfQuEl2Bq5KAz7uKXajdiE5oRR9Yk3lD1+NlwgiBXDqy7zmz8miMmKhAJAFQg+Qfji2AgtDO4IBOVeRvtY0XVx2A= 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=jncKEe5e; 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="jncKEe5e" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by mx-outbound15-162.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:01:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l91R9yQOgcqDwAUY3a6CpDNcbTl1fI/N9ie8EnMl9ziTKvhGBTh3XdfrETJ35b7jup/bREwsk2PIOp51hPFBU77e7ag6vy7cbhH/My6s6LcYHzhy6bpuYpfcdV0uXS18fAS0mA+LfzOfnqHgu7B7HJfUHpMNe2VwaHs09hYZ0B7rhGc0+49YRsQnF45NNm2TyJzcQmTbN7bDDOi924r7SYZosxnu6Dp/2HQ0P9Q/zWhKgDVWsG7syCjTS7VcgKfKwMSKeL2n7AKhoKksgGtNMTsHC20NAOW24GqD3AJGiJFz77AbHrJ1COwA/gcAxBLxDv6MjV+sIu8gMZe6ZZkFJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=aSDWP2yoy4IFjpUm+Q8LhV3ckwRUXFIc/vCejQP3TmA=; b=N61dVFT2GElBIjsDgtefBKVsyF11tVmhLX8zFMBSdcxfG/s7rF3yh8kCTIZwuzaxcn9ktZFTYRRFsj/OUC40qyGMkc3JxZTcqCuZyeY8E0DWxI5ku8Ee+PtPuV9lHL+bQhYPHXoFWHNppfAkWVxq/dPgnMwKDaEopPW+boCU3yYX0VvJZ0Q4XWFLqsqT0Wywv+tZwv+tkrak8Ln0DlA2TCZ+jP3kTWjBU71nMYQt1+PsqvQjDl5VEodM7E9uT6dCQ7gOsT1WnsaUHEDNwW8O9RYgB3kZFWgs/bIp+CgQJ4bhDJUQV8bePWZmnGVVX/ERIV52GwXEm5/8riXfbMNHww== 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=aSDWP2yoy4IFjpUm+Q8LhV3ckwRUXFIc/vCejQP3TmA=; b=jncKEe5exS+Lj7juLD8tRH8/iE8mF6LtnDbljszqXWR3iHxz4d75wpGOAeLspxnJf+Z7XMI+jIOJSWDLitQOh10jJcQu7aBXFLI6lr5LII6Gs/lyBrn9mLzYEBAnoiHqziDNzEZAoXIxuK7qbvXLk170Oz/0tkgr1gU1fylu0zk= Received: from PH8PR20CA0009.namprd20.prod.outlook.com (2603:10b6:510:23c::23) by CH3PR19MB8408.namprd19.prod.outlook.com (2603:10b6:610:1ce::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Wed, 29 May 2024 18:00:56 +0000 Received: from SN1PEPF000252A2.namprd05.prod.outlook.com (2603:10b6:510:23c:cafe::f1) by PH8PR20CA0009.outlook.office365.com (2603:10b6:510:23c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19 via Frontend Transport; Wed, 29 May 2024 18:00:56 +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 SN1PEPF000252A2.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:55 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 2085A27; Wed, 29 May 2024 18:00:55 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:41 +0200 Subject: [PATCH RFC v2 06/19] Add a vmalloc_node_user function Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-6-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm Cc: Andrew Morton , linux-mm@kvack.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=3644; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=MEK1vbj5ymTp2LNfUE+mfKARrGzFvVGkw7vWcp91zlQ=; b=wvvWf+kh5GtFI/JGVzigS1TQbbczThjg3WJf1TqAJdEr6uffBA+v6LPQ0OKHxRlWpdp1EaBs1 k8Y4k4nEqlBBCHQgv87hXfFlemn57LisBD045TRX2i99U3l3zIH2iyo X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A2:EE_|CH3PR19MB8408:EE_ X-MS-Office365-Filtering-Correlation-Id: 992e47e7-78f3-4c09-0c89-08dc800949d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3P9cuVbhdMYYUo7tD1MbRJOmwAIOA2N?= =?utf-8?q?C2M7jBYptqVjoDo/8N6k+95TjVSZZ/kK6OWJXrODiPWbZ5n3T4+BL6aCO1zNs2NrS?= =?utf-8?q?Kh6dYCMI+pPRmzqOsKs9xpsLFdcFVp0uPoF0Gem7TkPY63SENtiYn+8n8iUcEoPAK?= =?utf-8?q?WeSP0Xdq2K0zKL4td7syRLxLPMw1pH1k2kfdL5FFyBkF3a0oohqJ/diK0ke0P8uew?= =?utf-8?q?YKwI2VN6kZGVfnCInByxxfUA5+/jO37weCYzmkyJ+eZQ75JKLPAH35SYTB35mqnAd?= =?utf-8?q?q/t+mEGqa9h0VoZ9EZAuislTAct3VQfttuTOHBPdlQGXwJJlG/uJvbRyXzQtSbPwR?= =?utf-8?q?4JY4t/Du+dqhF01qG8UMCkesfSzskpjScynk2GPnl9ugiMgycuEIgLIcL4H2rF5D+?= =?utf-8?q?VH5mX1bNMTBbwC/649ZjQExwZsU+IP2GzQ0+fTb8AlU01+8hhl0MY+zullQiuQTMS?= =?utf-8?q?3gV9dWwdWqbXLg49nXzia4ljzhXIqc9bLJz80O8yT814KGd3qyf+IDs68L8I6zSxd?= =?utf-8?q?HhYRHcHovKtyMG1+5l08vdNXmqVVTpKbND7htie5uR1dEmp4u5pf0JjXdqr6r/Md6?= =?utf-8?q?uB6bfF+GZC7ApOygnoH2A2pBFKddrzXZNvFf6RZLeEStQvQJhUnpam36AcFRrO2SR?= =?utf-8?q?r5Pd3HUC32SWUi2kUVbr6TmE9YW1k+DlqdqJTYTOrQl4sbRKPe8xOUzIr0ERwfIet?= =?utf-8?q?UifviOUhM94LBkOQ084qF1afV/yagv4Za6dD24yc29odKqhVRCqsUJg3tr+MqW+/E?= =?utf-8?q?nSQBztBTgnUD/tZ7mbTtCS3tj4aa+KFTONAAOZYafjlunSzl8Eo9Kn55zEmYGxY6i?= =?utf-8?q?ZQln8E2zk1U/tJOqhm7HckZKvUcTsH/KG+GefK/Qa741isCABoZdv6q7+0j+6FW8y?= =?utf-8?q?JvI2pT5/rAMvYzU+q7lhghyup3fMmx3C4cwVHgNDkrLrhCEuKUPvZpfJQ2M9ZvyTS?= =?utf-8?q?ykOKG+FbsjBuH923rCJUpqJMze+mEg1GBAMdWtt/K5+ObI+UOrrRU6f78xrrUUEB1?= =?utf-8?q?U3YbGsyo0u5SrTzFzYFcQ5KneL3azc+bcbiLn6F3VusttecsCCRXcMfmvdlypkbdh?= =?utf-8?q?y4X96xgqWl1jAwDnxatKuuPzdhuxhi8J+X9TOBm+vlDGj0f9c5HNcBqxztcd00ayZ?= =?utf-8?q?R+7YA11YRWLnlYZQWt54KDH13nfdNFvxhytTTjyvjSqA+0lkMAmQSrxwW18Bm2Xxs?= =?utf-8?q?zKQrGiOLvvhP7m1QgpbdMK+JGP7LREdR+cbByusz+OR3qeb890GZvMisuO5v2Et+B?= =?utf-8?q?6CGk4yT/ept+sBPlQ/kxxZqSSg5hyz6VzfsebtWRUHp/9CQ0Kcm922J0lzOOjxE+s?= =?utf-8?q?W2BgWCvSpGiQ?= 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:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LbQwQzfuSAD7NMDJn4H5TnjJWrGEx+QMwvSaAzShxa13Rp+0YXLpgdwxYTxytDUgzxuAx4WGuZyzRt6Ki6WrfTCjNb99cUJwUX6MpAD3vK7ED+P/BY8WHzMhIRYk89hMnhQSgaUKMD3c5X1dnedsr0oz/GO9cXOQLmnCQobO97ofMiPB2UkyoE7+4v6fODzth3DL+7jPYZy5/sZ5MQGlxrB7/0JYr323I1retzZy+VGkcTCutVtROJshM/xRGGOFRGUtcGCyhS8x2MhzbefMRlREb1vGIJckOjTYogW1a2KrYNv+TLh9SyRqUaiVQ70JQa0TERWBSro8YEDRSvborx4/pKaFs16jYJWAqqFXU5GxQpdXYFtYW6+upznC42jjB4qqpjv/qJQX8lZyTluqCVvShp/XHI1LWhmBIgGoOrsmBTTMxp0ejoKOkzOnh9TUQ8yWlI8zNHxujZLfOEnrevue0KFw7KJ43j8IV+Tv/VYticK5MCx33mZXQSDEEED5aJiCjVZ+cjG2tPXYbwSHSwUlUZasL2uuQ6vfjwaFQqXaUw07BQHdmAxa8N8L6XOeCxBKgT2bAwOXJwh+UV+wJjk4T/MuXF1B5cQTq64DhYYnMXYyM2tdjIk2yzPbtqOiXLPfFUqVP8z6GgEybbe18Q== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:55.8130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 992e47e7-78f3-4c09-0c89-08dc800949d8 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: SN1PEPF000252A2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR19MB8408 X-BESS-ID: 1717005661-104002-12629-48742-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.55.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsamxuZAVgZQMDXVODExzcTE2N DUNDE11SLNJMnYNM3MIMnQ0MzMwixJqTYWANJkkRJBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan10-209.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This is to have a numa aware vmalloc function for memory exposed to userspace. Fuse uring will allocate queue memory using this new function. Signed-off-by: Bernd Schubert cc: Andrew Morton cc: linux-mm@kvack.org Acked-by: Andrew Morton --- include/linux/vmalloc.h | 1 + mm/nommu.c | 6 ++++++ mm/vmalloc.c | 41 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 98ea90e90439..e7645702074e 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -141,6 +141,7 @@ static inline unsigned long vmalloc_nr_pages(void) { return 0; } extern void *vmalloc(unsigned long size) __alloc_size(1); extern void *vzalloc(unsigned long size) __alloc_size(1); extern void *vmalloc_user(unsigned long size) __alloc_size(1); +extern void *vmalloc_node_user(unsigned long size, int node) __alloc_size(1); extern void *vmalloc_node(unsigned long size, int node) __alloc_size(1); extern void *vzalloc_node(unsigned long size, int node) __alloc_size(1); extern void *vmalloc_32(unsigned long size) __alloc_size(1); diff --git a/mm/nommu.c b/mm/nommu.c index 5ec8f44e7ce9..207ddf639aa9 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -185,6 +185,12 @@ void *vmalloc_user(unsigned long size) } EXPORT_SYMBOL(vmalloc_user); +void *vmalloc_node_user(unsigned long size, int node) +{ + return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO); +} +EXPORT_SYMBOL(vmalloc_node_user); + struct page *vmalloc_to_page(const void *addr) { return virt_to_page(addr); diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 68fa001648cc..0ac2f44b2b1f 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3958,6 +3958,25 @@ void *vzalloc(unsigned long size) } EXPORT_SYMBOL(vzalloc); +/** + * _vmalloc_node_user - allocate zeroed virtually contiguous memory for userspace + * on the given numa node + * @size: allocation size + * @node: numa node + * + * The resulting memory area is zeroed so it can be mapped to userspace + * without leaking data. + * + * Return: pointer to the allocated memory or %NULL on error + */ +static void *_vmalloc_node_user(unsigned long size, int node) +{ + return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, + GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, + VM_USERMAP, node, + __builtin_return_address(0)); +} + /** * vmalloc_user - allocate zeroed virtually contiguous memory for userspace * @size: allocation size @@ -3969,13 +3988,27 @@ EXPORT_SYMBOL(vzalloc); */ void *vmalloc_user(unsigned long size) { - return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, - GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, - VM_USERMAP, NUMA_NO_NODE, - __builtin_return_address(0)); + return _vmalloc_node_user(size, NUMA_NO_NODE); } EXPORT_SYMBOL(vmalloc_user); +/** + * vmalloc_user - allocate zeroed virtually contiguous memory for userspace on + * a numa node + * @size: allocation size + * @node: numa node + * + * The resulting memory area is zeroed so it can be mapped to userspace + * without leaking data. + * + * Return: pointer to the allocated memory or %NULL on error + */ +void *vmalloc_node_user(unsigned long size, int node) +{ + return _vmalloc_node_user(size, node); +} +EXPORT_SYMBOL(vmalloc_node_user); + /** * vmalloc_node - allocate memory on a specific node * @size: allocation size From patchwork Wed May 29 18:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679408 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 5A8EE15B552 for ; Wed, 29 May 2024 18:33:30 +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=1717007612; cv=fail; b=MZry3alIM5YNgblTyxTv2BdzpczWSupLSWqhenwuyaQaJTFrn4kqZE5H7kyNLrtIuO6K+EnJxY8BQt0sfwhgkmWMIpZKPohfNkTYtrI7JNCCJA8Dwv8g6SFOjzqynD82iCXOfs4z5722k7khUvBDTN4caU2Igek+rwU0x9UbXHQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007612; c=relaxed/simple; bh=ykdZ3lsNXXK395eD8JO7ON7n6z6X51OKzfrXSwxvITs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=TgIBMAfVW/kuGoLZkUEK8+s7D1MOdq0If4tRXESveiiv1Q5/w4iAzDslaImfCD1oNar00UDS8byyhGP989fZIgU8JkwnPmSdg6ycp+bz5namEBBaZ+qLgtB6FiTqJawEnOas3IpdL0XsizsTcnV0FkYN3UuuivSvWUA1pVNS+xM= 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=1DdteggO; 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="1DdteggO" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by mx-outbound42-38.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBRKPBKCw0EI/SMrorFMEAr2wEomwhD5EmYr6YyZqASh/YGM27dLIidbpz+1xXR+Vw59DMkgokg+6DgeUPvTex9GVflIqBbX0/fkg6aLocrkRSRjOVz3M4VvDvo+DmgjybfXGikwENY7M5nskpHLmsGn7Whc7fK3WzS3wLAY3C/r1bdjjN/vCIECyf6iEqUgMU3X7LIfjxv6eFV7LknqLT4bj1XU77l7k48UPEeBH42F9sIJhhnugCnREmwJco4XOBHaWXVtxU+X7y8wTJfk5A211FbMeBJExfTdumFyPZMNMUE7E8lvFcvG5p+zbPd/ngGqJafFxEKzpPGKj1MS7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=zjv5dbjJ16GG3iK99Ld3pUZNQSnzorgHj+tlht9zc94=; b=jJ3DVv+TspziOOr0JcKDLudcn7TZuPID6+rh6Ksowa2DeLl+sdhhWx1UvN2F897Y/Yx2t2d4akbqnohTyv+rCNtC2QcgoFagxKPx+7gwKXhGV9Zn+pFiLaWKhMBPsUUBsqpe6nQ2dhCnmd9EvhINovij4EEcm7kL76bGzI79EPo/t9HWvpX8uibZ23gFX1cfs6RcQeGMy2SWcJm0sF/8HmfQbk1bRFSkyDOYf3DwTqUOUVTpEyMI0Fx5LFAxy1/P4aFA6exQREi+Jl1pBZEo7GruJQ/Z1DXL0vJvxo44kQRK79jyMh7yi8qwN+gdxgTG7E8A5pOovFXWql+IkzEb3A== 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=zjv5dbjJ16GG3iK99Ld3pUZNQSnzorgHj+tlht9zc94=; b=1DdteggO0vpQkJZJgVLAM0CYRARMJDXV8kW72YeqgoF2wPUL9rZDAiTt4fSsou9aNFHlLhdYLdqiqXA09Eg6ejdgCeP4zYZv30tL8okmGodWT4moGLZDL7b7SXk3+NR+2y+2zZmcpdw/1wkxFzmS7gf0QaOp5AwvwbyeQpOHhiY= Received: from BN8PR15CA0017.namprd15.prod.outlook.com (2603:10b6:408:c0::30) by BY3PR19MB5185.namprd19.prod.outlook.com (2603:10b6:a03:368::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 18:00:57 +0000 Received: from BN1PEPF00004683.namprd03.prod.outlook.com (2603:10b6:408:c0:cafe::c3) by BN8PR15CA0017.outlook.office365.com (2603:10b6:408:c0::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:00:57 +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 BN1PEPF00004683.mail.protection.outlook.com (10.167.243.89) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:56 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 1A5D725; Wed, 29 May 2024 18:00:55 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:42 +0200 Subject: [PATCH RFC v2 07/19] fuse uring: Add an mmap method Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-7-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=5745; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=ykdZ3lsNXXK395eD8JO7ON7n6z6X51OKzfrXSwxvITs=; b=6s6Jqt7xriWk0pHQmXWy1wE8RRBQQ80JOavLoDZ20WF4qs4HDHzjFfF/4V3YJMXh+5+f8zYC0 1n844CFktjvDjpXPSqBMAIWZQGeJj2nOSkjbbTO4rsTFhN0dwKfpljD X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004683:EE_|BY3PR19MB5185:EE_ X-MS-Office365-Filtering-Correlation-Id: fe5c6d7d-d726-4cb2-7332-08dc80094a68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xyumyx7NEO2Q0DAK5Nqjg6pWa9Aq5jC?= =?utf-8?q?mH/6ttlmIUssOMph8tYU0CpXAHwRPyi6e77bZndEkXdAMboXvpCN4mdbg2MAT7GeK?= =?utf-8?q?irZ5INCNNs7muNc0ClSBZtWNg+JDE1TKmGHuGmfU6/8/kutxF9IZ1ehB6tZH1spI9?= =?utf-8?q?Yud9qZnrS/WyH9YmmhWXuvbgE2SGuze931c6HVd4to2Zq9F+D4t9DDu6OkeVhOIz/?= =?utf-8?q?PJwPeqneFUWuWUWcEbVMCAiRWyxyWcvgj9Us3H9VyLahwYAnBEVGv9zY1H1dYI9zz?= =?utf-8?q?otrrEGuMEEiqpaeoNpzRpQEXYH4L4yN1xlZwEI2+q3Zacok8GiKI1k9uYiyxWWSSc?= =?utf-8?q?kydNSwmrz2LbxQ4wz9RD1bEd5sm1SA/D+B88WpuWvZWRMHnpUo+qbst4fVRkj63C3?= =?utf-8?q?2t4CG+e2TX36xsGTl03rYvR09usltnO6De8ml8fBITnMiQ9Idba7GWm7qV+0rhClB?= =?utf-8?q?gfs+2moxqSJfKNji/QKsdvHTl1AmFw+X65cr7CSsOSnWC7sTNLcEsmOSMdEDC1OSC?= =?utf-8?q?wXcNpzt/8iY3yBb7tCVVw9ZKNvl/L2m4JX/vCYsdFqMMJwkQ+HS17IRZhKQ2PoYq6?= =?utf-8?q?Z5Vq7r9WMv7Ed4WCIcaT558vo2b3DYjf/YmQD4cJF07TFrDRuW+Au1dsDXkCbPrEY?= =?utf-8?q?SeRELqC39+bGbrYphuxnu3gVMmb8cZlYwNSYIO+IjgcoRWFfgT1EJnd8BNkpqtohg?= =?utf-8?q?wXY0Q3om5PSEkbv0+PTqANXetRBpv/j39JYbWDh0gixtMjurwGjcUE/R6akqujduF?= =?utf-8?q?Q4wLzKRm1B+I/RnlWfohRdMeNHhsfGDnsj+qgVDQsTf0QNp4vIAQ/KS2G6gCgY/Hb?= =?utf-8?q?f4+YOI73FmQVLudI5W+yHNiCcU32KYgM6xh9INLT/NsX90DVmak1XjzD6kzggYavT?= =?utf-8?q?VF9s5Bm37RfsPm4IKag2bxEkH15ZrArtzLyUdPdfo3ddjOqy6skbSsZXOb0EeT3Vq?= =?utf-8?q?aEKRrEwDQDBBUQWTsfqZ8Umhbz1701viFqxSD0NhRXKfzlTfKAboTLBvMhixcl02J?= =?utf-8?q?TnbfJX7gOrkX0dhhFmDC2unrHQRjHdoWFcrRljLwSola6xdCDO5FafOzf8plxg5tR?= =?utf-8?q?6OFQwNuSZ4byGb+w0H0D4udeDY+Rsb1Ib17XaciFO22mNKuOXnWIDLGCTsD0ruDrq?= =?utf-8?q?Nkm48iDKlu+m3WhFXjf2klJC058Li2I07g71knFpvvmxNXI+PWwOPG3DDm8iAFr2y?= =?utf-8?q?BYqoWAIgG8I98KxKlVte+5ASFQfAnJSuNUvEjegsAYMALN695/uwCIcVRmwgApvco?= =?utf-8?q?KkjWba6Rc55lXsl81AdLjLuwL2Gt8QMjX3A+sOruIE52ND+r0L/Vd5Jjrty+0lsmt?= =?utf-8?q?5HJayX0Jpmvw?= 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:(13230031)(82310400017)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EDzWxt2VZc1gGdGdYEBxQXTH7zd8gZIf14vXuSzduwWkVv/9E2Ci75eqoWG6tjxd59kA3AKRyravaS8tHLdzF9A8odIXWkwfOri19ZzwJnbJIdmYywHUxkLm1l+wwDLzf+BhJcuxZeR09NxPOADBFKS1RPG0AbDKTRzHcdM7IqGid+iIi1tnasBwW3yls88h5B48cNTUPQRyTspS2yI3Ba4WG3lvz89cDojHdSs2w2Q28IfQF9j9lBcY/hyObnHgJPunWI02ReAiKTvt0CRpSUak6Hg7wJ4Fvp5HcVWBnoaeAxUFfY5a3CGQm1iM2Ofn75G8cwlyPK6bALW66yv/0RQFjDfLkNFcRsmsmXn1J7keiya8WY6kmpMB/h/yb2Cy/hID3W33JhH7sow0aSgI6oB7Ducdqf402pOQw0/f3VgaVPqstU7r9KvAw1XC7/Knj2ze5Vovt7l1tOjcZCDNz/ohPI9OEWemnFGZSk7O0j+wTEqRPjvtoDpJ7IY/fC6020O+NwTLr2AuLDFraXU4L1M3ggq1PpiH8msibqFk9qzek0vxX6jlNLpqiO9SRypyYF2nFbyGjZ4hiMG2wAIlg3osBecnUrVo758Od0ISB9eoQn2RsUKX2mXSy0PBCCVC0C/ljEvoQeINXf7EqLavDw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:56.9781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe5c6d7d-d726-4cb2-7332-08dc80094a68 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: BN1PEPF00004683.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR19MB5185 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007608-110790-12643-48789-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.66.44 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqamJuZAVgZQMNXYLNnM1DjVMs nYyNwg0cjYMNE4zTLJ0MI0ydIg1TBRqTYWACRdiIZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan19-133.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.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 Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 3 ++ fs/fuse/dev_uring.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 22 +++++++++ include/uapi/linux/fuse.h | 3 ++ 4 files changed, 142 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index bc77413932cf..349c1d16b0df 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2470,6 +2470,9 @@ const struct file_operations fuse_dev_operations = { .fasync = fuse_dev_fasync, .unlocked_ioctl = fuse_dev_ioctl, .compat_ioctl = compat_ptr_ioctl, +#if IS_ENABLED(CONFIG_FUSE_IO_URING) + .mmap = fuse_uring_mmap, +#endif }; EXPORT_SYMBOL_GPL(fuse_dev_operations); diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 702a994cf192..9491bdaa5716 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -120,3 +120,117 @@ void fuse_uring_ring_destruct(struct fuse_ring *ring) mutex_destroy(&ring->start_stop_lock); } + +static inline int fuse_uring_current_nodeid(void) +{ + int cpu; + const struct cpumask *proc_mask = current->cpus_ptr; + + cpu = cpumask_first(proc_mask); + + return cpu_to_node(cpu); +} + +static char *fuse_uring_alloc_queue_buf(int size, int node) +{ + char *buf; + + if (size <= 0) { + pr_info("Invalid queue buf size: %d.\n", size); + return ERR_PTR(-EINVAL); + } + + buf = vmalloc_node_user(size, node); + return buf ? buf : ERR_PTR(-ENOMEM); +} + +/** + * fuse uring mmap, per ring qeuue. + * Userpsace maps a kernel allocated ring/queue buffer. For numa awareness, + * userspace needs to run the do the mapping from a core bound thread. + */ +int +fuse_uring_mmap(struct file *filp, struct vm_area_struct *vma) +{ + struct fuse_dev *fud = fuse_get_dev(filp); + struct fuse_conn *fc; + struct fuse_ring *ring; + size_t sz = vma->vm_end - vma->vm_start; + int ret; + struct fuse_uring_mbuf *new_node = NULL; + void *buf = NULL; + int nodeid; + + if (vma->vm_pgoff << PAGE_SHIFT != FUSE_URING_MMAP_OFF) { + pr_debug("Invalid offset, expected %llu got %lu\n", + FUSE_URING_MMAP_OFF, vma->vm_pgoff << PAGE_SHIFT); + return -EINVAL; + } + + if (!fud) + return -ENODEV; + fc = fud->fc; + ring = fc->ring; + if (!ring) + return -ENODEV; + + nodeid = ring->numa_aware ? fuse_uring_current_nodeid() : NUMA_NO_NODE; + + /* check if uring is configured and if the requested size matches */ + if (ring->nr_queues == 0 || ring->queue_depth == 0) { + ret = -EINVAL; + goto out; + } + + if (sz != ring->queue_buf_size) { + ret = -EINVAL; + pr_devel("mmap size mismatch, expected %zu got %zu\n", + ring->queue_buf_size, sz); + goto out; + } + + if (current->nr_cpus_allowed != 1 && ring->numa_aware) { + ret = -EINVAL; + pr_debug( + "Numa awareness, but thread has more than allowed cpu.\n"); + goto out; + } + + buf = fuse_uring_alloc_queue_buf(ring->queue_buf_size, nodeid); + if (IS_ERR(buf)) { + ret = PTR_ERR(buf); + goto out; + } + + new_node = kmalloc(sizeof(*new_node), GFP_USER); + if (unlikely(new_node == NULL)) { + ret = -ENOMEM; + goto out; + } + + ret = remap_vmalloc_range(vma, buf, 0); + if (ret) + goto out; + + mutex_lock(&ring->start_stop_lock); + /* + * In this function we do not know the queue the buffer belongs to. + * Later server side will pass the mmaped address, the kernel address + * will be found through the map. + */ + new_node->kbuf = buf; + new_node->ubuf = (void *)vma->vm_start; + rb_add(&new_node->rb_node, &ring->mem_buf_map, + fuse_uring_rb_tree_buf_less); + mutex_unlock(&ring->start_stop_lock); +out: + if (ret) { + kfree(new_node); + vfree(buf); + } + + pr_devel("%s: pid %d addr: %p sz: %zu ret: %d\n", __func__, + current->pid, (char *)vma->vm_start, sz, ret); + + return ret; +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 58ab4671deff..c455ae0e729a 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -181,6 +181,7 @@ struct fuse_ring { void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_conn_cfg(struct fuse_ring *ring, struct fuse_ring_config *rcfg); +int fuse_uring_mmap(struct file *filp, struct vm_area_struct *vma); int fuse_uring_queue_cfg(struct fuse_ring *ring, struct fuse_ring_queue_config *qcfg); void fuse_uring_ring_destruct(struct fuse_ring *ring); @@ -208,6 +209,27 @@ static inline void fuse_uring_conn_destruct(struct fuse_conn *fc) kfree(ring); } +static inline int fuse_uring_rb_tree_buf_cmp(const void *key, + const struct rb_node *node) +{ + const struct fuse_uring_mbuf *entry = + rb_entry(node, struct fuse_uring_mbuf, rb_node); + + if (key == entry->ubuf) + return 0; + + return (unsigned long)key < (unsigned long)entry->ubuf ? -1 : 1; +} + +static inline bool fuse_uring_rb_tree_buf_less(struct rb_node *node1, + const struct rb_node *node2) +{ + const struct fuse_uring_mbuf *entry1 = + rb_entry(node1, struct fuse_uring_mbuf, rb_node); + + return fuse_uring_rb_tree_buf_cmp(entry1->ubuf, node2) < 0; +} + static inline struct fuse_ring_queue * fuse_uring_get_queue(struct fuse_ring *ring, int qid) { diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 0449640f2501..00d0154ec2da 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1259,4 +1259,7 @@ struct fuse_supp_groups { #define FUSE_RING_HEADER_BUF_SIZE 4096 #define FUSE_RING_MIN_IN_OUT_ARG_SIZE 4096 +/* The offset parameter is used to identify the request type */ +#define FUSE_URING_MMAP_OFF 0xf8000000ULL + #endif /* _LINUX_FUSE_H */ From patchwork Wed May 29 18:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679350 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 3E39A79F2 for ; Wed, 29 May 2024 18:01:06 +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=1717005671; cv=fail; b=V9ocMpOIMW8MKaS4N74rHuNORk9ay7lymHBicTCGNdV6sdH7l1/FVI5nGu3XALf0H1LDNaGhZIju2eHVs+cfiuMdz98T1fZoKQUeQfbF2ocb9d/lZflC/MC2LfYVVEYuu0r7jSQ/yf1fqmqrn4K1UoNJxTP6/PBaXZCgO0ESJmU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717005671; c=relaxed/simple; bh=8+CjjG7OosZE5XSf+uanhNXvMtjmVw5S8JIc4d1HJOw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=ekG2NI336u7GgfpoYTNroYbEVuqasV9CYACLvKlB0af96TWXZh+tX1ShtyqqUccWOrEOoFNhonY2/qxajrhPyrPHO3GByyysetJgjhGPr9Kfon6AgUl42z2oas2RjJKd4gghJPB/YcuQv47FiV0a2Vc1L4LAtoZAwYEY65z0630= 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=AHyPGfDd; 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="AHyPGfDd" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by mx-outbound42-38.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:01:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ca+oz6BUk7wuw+xHDboM1NiMN6RILdtCNtVgu5qRyEP7UCfd+u5qNReWlb/rxalAFQHeX1lmPuXvNAroogA5NMmyUCCuP0nGzx6vIVQveI/X9l3wSEZP1rDk6RT/zS8DzskcL1z/J1ccYHq8ZtDlWtfDnHouaRkLjV2PkJO6eybUxKVZn20jBOUmQwooo1umOtb1HRQV4uYdZKiEkvnP8YJIh4zHi45P0VJ24YhV0YhzGxImmXX9Viox+bOmcGv1a6+iPHpNRY5w9i4R312ImASVPrM2DS8m5Xai2r2GIZH2lQrltNW3ILEVbMoO/DQippoLnwm4na9kCZv5IAcyEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=erWeHlE34z5nFTynehSk7CTkJt6AlhU0HIM3Z++oz6A=; b=Wo25DO3km8rWAhmZgSYfcVYlcCnbBGk80kuYxoT3QtFO5TgGxWGOgBFeHIlmaA6uDMW6xP31u8axoCRClST7affhCDlmserT+LxHY6PUnUUKEnq/cCwp/2Rf1zCFq8C86FmJn5A8eggYbuv8+XOzFr3w0iDqDl+r7ujgUNt27mwT3OTcEbvmTBVasVNmHF12fsPZuevyouWkQGC16RM/8l0qgTfg2xjFtiaBE5stwFY3JH3wZQL5tSWl3bJ0W1Z6N3TQxgeaOvYU5LOFXe9oMrzrR9U/Ezf/A5nQfiQZtl/+++5mELXQoRAcjy+FNll1gQRWhpBaFUaig97ZJqpoBg== 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=erWeHlE34z5nFTynehSk7CTkJt6AlhU0HIM3Z++oz6A=; b=AHyPGfDd96741EDMnt3hiju1EmvB4AL/wYuNfPEsCtBwanTjgv0na5rPazmHroxo+Ajt33tB2pGLZI+DPfDBvX6KkwD4TBQaaT5X/OEr/DRmQhut9tqWk1YcHuCbfYmD1eQvBURLJ0S1Fb7DobnUXsynkMjXJ0ZhtmeyOnu6TrY= Received: from BN8PR15CA0023.namprd15.prod.outlook.com (2603:10b6:408:c0::36) by MN0PR19MB6116.namprd19.prod.outlook.com (2603:10b6:208:383::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 29 May 2024 18:01:00 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:408:c0:cafe::1c) by BN8PR15CA0023.outlook.office365.com (2603:10b6:408:c0::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.31 via Frontend Transport; Wed, 29 May 2024 18:00:58 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:58 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 12D662B; Wed, 29 May 2024 18:00:56 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:43 +0200 Subject: [PATCH RFC v2 08/19] fuse: Add the queue configuration ioctl Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-8-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=6109; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=8+CjjG7OosZE5XSf+uanhNXvMtjmVw5S8JIc4d1HJOw=; b=21TmzyP9Xo/y0AFbg/EKTEFwFtoNneIzi7B5zPXdGKXNCtqTCjQ4ie7i/ZCY6IoJHMFHZrOsb GdO4fd8rZLpBhS6AutMK+bOfYusk7/ssCzM+beDC2hQd8NdGIQph01C X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B077:EE_|MN0PR19MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 43de1859-d968-45e5-d731-08dc80094b1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FdzA/YWCrB/cHWSjcge4OhB1W0zjiw+?= =?utf-8?q?Q25fIi8G4CDOfvHjeckQ80Umfscd7ojffuS7qJZAmdZdzavawhqiCxPo/We8920yK?= =?utf-8?q?xnbyTLR5rREaPF9lnxJuUqtLUXPQ8p4T449hqmYInhe4NYBT1XnlKUB8d7azBA/te?= =?utf-8?q?Ll4vENfkd+xcnFucFl5nQa4a9VrEVP1PtgUJBU1EgKte1DTZSHzE3XzyuKw9GI/qp?= =?utf-8?q?YdkD1IhO6kJTevTMmx9/N6mrO7X6UgLba9AWF7eKI0QV0x060t4FvXiVoCLQ1mp6Z?= =?utf-8?q?ecFMyuKwdWNGQNSuNjuF36tlPtZ6S0oLEwk29UxLmW8+P3KeLxsFJwjtKC69NPM1F?= =?utf-8?q?q8Cnahu3AgDBzHg7oVNpABT+5OW22dzg1Iq37xdZsZJo4ROcKBLb1R53gXWB23MQV?= =?utf-8?q?+rvkwT6/gJGT9W7lVq988BtRUU6VkiJuEo1DYYaUiyXx6BAb182OSD4JP+fVsiQj0?= =?utf-8?q?7JQGIileV7geyomD03sEONBTprEmWoUVNajgqJi/sgyXymgQT1iW9EGU9C18E0Kbp?= =?utf-8?q?zBMDRm2tXTCTTawwBH4qBmSoDc2OFPpD/M7MU8fTnofC6+YpURaRr8Q7YVJ8sXjsj?= =?utf-8?q?Dhca3ig2eLySJjOlBgX3cjiR0m3M/Mg6dCW3IkFIbyVRYHNS1BtdoZlEvnTXj1MsB?= =?utf-8?q?+MoH4As6lM7383LDKl7m2357dBrc12nBHaUn3Y4DFQXwwRhicbULyVn3Y57PR9Vjq?= =?utf-8?q?+LY/pmNAExQHlXHsOpGSdkNzeQXoWral5yr6VjG/s3I0yuJq04XzslXm7/GbgeXRZ?= =?utf-8?q?kPcadSFSXOvpHC4er0/GNWIlc3bkJAj7KM0Yxmnu5H64CXO4W6iwK/8YsBto+c4O5?= =?utf-8?q?dodR/gtlWWfqTtm3jFgRe6zMoP21QDhVwMNkQvngUWOB6uLD6/5/eOr6HGr7e4TFI?= =?utf-8?q?OtoXbVs+XrFiIk0WOPRlHbUFg+wpPu7abuwR0aHVO9vY0ncYJK0P8kDG6ls4Da0H0?= =?utf-8?q?1b6OcZrvCy2Nn901TFA4CGRDvGyUsLkWyFHCLHoFPzJ419+7+gLSoZMdXdXDMCr/N?= =?utf-8?q?u1ugyM0TBOlj0DfzW3+x9IWWQ/l9+Sh36CLTzaraCvl25mj/ZEs2xWYLf5+lGQ4Sc?= =?utf-8?q?OZlI8EUMslxuES8St1ok7YNrlaHOW4vrQCbfcRimewGvHw9RJGn6ljZpfnlaXUgBW?= =?utf-8?q?L1i2Mrbocs/7+O+fhSDeJach89tKTtLARRbhRXy+eEj8ojxdEm5fniXsEuvSSWjtl?= =?utf-8?q?J20MvEEHPSO0M4Odt5Ok0QFxmfovw7ssF/JlTQid1F+eEBeTF5OJD3hQWNrC6apPw?= =?utf-8?q?IaO3a4IPThdK6e8Mc9ykKxIvyS0t+36NY3KtXX0HID7XS+wDks15Tyux15Kos5UVM?= =?utf-8?q?JxvmcEy32eL2?= 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:(13230031)(1800799015)(82310400017)(36860700004)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: s8dPYa1VK4ToZCwbnaWKvWeG8N3owbMIL1rsuvAZfkHU/p8tNEy7Ecvm84qXzYSyp28wIcD6VEgwjjM5dt9tqbrQRUpx3bi8CpqvX//riYhOtsg8BSHgJqKLJ/27NvlfWKgk2qwZvfLGJqXqMqwohvTdB+ZazakW2p2Z3sDBxLni/In9KP4cTB/ZqQ+hKSoMBkFsIVxldKBKax8dwYXodFTLee+MB8kZFqx3vVpcEK0URhKLaUS+fsubHAnDLr8v0wySwD4bS9km/FF1R3E8ckN+FcpTo6HCfmChUU0JQWb2y3f4RLz8QowuOcRfVR+SVOe1ON+ksht0vGqeRSllRMcLQbW/DAPNksUBxtL1up9Q60RMmQXX+g8b6BmS3ySzE+y8rkUIZGAm+YRAIjfkMTlZ0Z9qgMszTBxrkXB8wu5/+xUwwXxdJ1L86ox4C0E1q3uLJfCz25sHZPZizdDM60DKq7CF65Q2T8qwXhq9GKLSXRa8PJTXH2smxwoLl8iK8N+Gntk7bJFnP4VMiQcSlg8Dhr28SLqS7n3vxITBhOxD3Y7+9XDo/hn3nA5i44gmYAsB1UnY+Yu+Tzdq/nEaKxQYUcnMTJPTcb9iOUnAhV6g9Kni9G6GgcRUrXdCH47hl9ZWZXZCl30NekArBjJGRg== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:58.0379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43de1859-d968-45e5-d731-08dc80094b1a 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR19MB6116 X-BESS-ID: 1717005662-110790-12644-44257-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.59.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYWFkZAVgZQMNUw0cDc0sI0xS jR0tIwJcXMxMTEzMLAxDQl2QjINFSqjQUAgLxdvkEAAAA= X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan14-93.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 Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 10 +++++ fs/fuse/dev_uring.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 18 +++++++++ fs/fuse/fuse_i.h | 3 ++ include/uapi/linux/fuse.h | 26 +++++++++++++ 5 files changed, 152 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 349c1d16b0df..78c05516da7f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2395,6 +2395,12 @@ static long fuse_uring_ioctl(struct file *file, __u32 __user *argp) if (res != 0) return -EFAULT; + if (cfg.cmd == FUSE_URING_IOCTL_CMD_QUEUE_CFG) { + res = _fuse_dev_ioctl_clone(file, cfg.qconf.control_fd); + if (res != 0) + return res; + } + fud = fuse_get_dev(file); if (fud == NULL) return -ENODEV; @@ -2424,6 +2430,10 @@ static long fuse_uring_ioctl(struct file *file, __u32 __user *argp) if (res != 0) return res; break; + case FUSE_URING_IOCTL_CMD_QUEUE_CFG: + fud->uring_dev = 1; + res = fuse_uring_queue_cfg(fc->ring, &cfg.qconf); + break; default: res = -EINVAL; } diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 9491bdaa5716..2c0ccb378908 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -144,6 +144,39 @@ static char *fuse_uring_alloc_queue_buf(int size, int node) return buf ? buf : ERR_PTR(-ENOMEM); } +/* + * mmaped allocated buffers, but does not know which queue that is for + * This ioctl uses the userspace address as key to identify the kernel address + * and assign it to the kernel side of the queue. + */ +static int fuse_uring_ioctl_mem_reg(struct fuse_ring *ring, + struct fuse_ring_queue *queue, + uint64_t uaddr) +{ + struct rb_node *node; + struct fuse_uring_mbuf *entry; + int tag; + + node = rb_find((const void *)uaddr, &ring->mem_buf_map, + fuse_uring_rb_tree_buf_cmp); + if (!node) + return -ENOENT; + entry = rb_entry(node, struct fuse_uring_mbuf, rb_node); + + rb_erase(node, &ring->mem_buf_map); + + queue->queue_req_buf = entry->kbuf; + + for (tag = 0; tag < ring->queue_depth; tag++) { + struct fuse_ring_ent *ent = &queue->ring_ent[tag]; + + ent->rreq = entry->kbuf + tag * ring->req_buf_sz; + } + + kfree(node); + return 0; +} + /** * fuse uring mmap, per ring qeuue. * Userpsace maps a kernel allocated ring/queue buffer. For numa awareness, @@ -234,3 +267,65 @@ fuse_uring_mmap(struct file *filp, struct vm_area_struct *vma) return ret; } + +int fuse_uring_queue_cfg(struct fuse_ring *ring, + struct fuse_ring_queue_config *qcfg) +{ + int tag; + struct fuse_ring_queue *queue; + + if (qcfg->qid >= ring->nr_queues) { + pr_info("fuse ring queue config: qid=%u >= nr-queues=%zu\n", + qcfg->qid, ring->nr_queues); + return -EINVAL; + } + queue = fuse_uring_get_queue(ring, qcfg->qid); + + if (queue->configured) { + pr_info("fuse ring qid=%u already configured!\n", queue->qid); + return -EALREADY; + } + + mutex_lock(&ring->start_stop_lock); + fuse_uring_ioctl_mem_reg(ring, queue, qcfg->uaddr); + mutex_unlock(&ring->start_stop_lock); + + queue->qid = qcfg->qid; + queue->ring = ring; + spin_lock_init(&queue->lock); + INIT_LIST_HEAD(&queue->sync_fuse_req_queue); + INIT_LIST_HEAD(&queue->async_fuse_req_queue); + + INIT_LIST_HEAD(&queue->sync_ent_avail_queue); + INIT_LIST_HEAD(&queue->async_ent_avail_queue); + + INIT_LIST_HEAD(&queue->ent_in_userspace); + + for (tag = 0; tag < ring->queue_depth; tag++) { + struct fuse_ring_ent *ent = &queue->ring_ent[tag]; + + ent->queue = queue; + ent->tag = tag; + ent->fuse_req = NULL; + + pr_devel("initialize qid=%d tag=%d queue=%p req=%p", qcfg->qid, + tag, queue, ent); + + ent->rreq->flags = 0; + + ent->state = 0; + set_bit(FRRS_INIT, &ent->state); + + INIT_LIST_HEAD(&ent->list); + } + + queue->configured = 1; + ring->nr_queues_ioctl_init++; + if (ring->nr_queues_ioctl_init == ring->nr_queues) { + pr_devel("ring=%p nr-queues=%zu depth=%zu ioctl ready\n", ring, + ring->nr_queues, ring->queue_depth); + } + + return 0; +} + diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index c455ae0e729a..7a2f540d3ea5 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -16,6 +16,24 @@ /* IORING_MAX_ENTRIES */ #define FUSE_URING_MAX_QUEUE_DEPTH 32768 +enum fuse_ring_req_state { + + /* request is basially initialized */ + FRRS_INIT, + + /* 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, + + /* request is released */ + FRRS_FREED, +}; + struct fuse_uring_mbuf { struct rb_node rb_node; void *kbuf; /* kernel allocated ring request buffer */ diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index d2b058ccb677..fadc51a22bb9 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -540,6 +540,9 @@ struct fuse_dev { /** list entry on fc->devices */ struct list_head entry; + + /** Is the device used for fuse-over-io-uring? */ + unsigned int uring_dev : 1; }; enum fuse_dax_mode { diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 00d0154ec2da..88d4078c4171 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1262,4 +1262,30 @@ struct fuse_supp_groups { /* The offset parameter is used to identify the request type */ #define FUSE_URING_MMAP_OFF 0xf8000000ULL +/** + * 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; + + /* enum fuse_ring_buf_cmd */ + 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 Wed May 29 18:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679411 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 CF3851C0DC7 for ; Wed, 29 May 2024 18:34:08 +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=1717007650; cv=fail; b=YogxCJIMZBE/p/IK9Xs/UM8EQNl1R4Nz9KvLBX7au98NBMQYjQ0g+6hZwZmLP503e/qrEp5h6TOmImkqpK13WIcDZI8qLDoTMrvsOTLSQWFWuOzz6hd+OIEtO/uruwI8Za+dxK3xXWR9lR+zAva94bG1bz+TkYV0EjyhER+vrTQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007650; c=relaxed/simple; bh=RGsm+1aSws7TJ9BCCQvgJZGEWH8gdvkYr6JlgxeDFII=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=TsQJzK4uq5Oh8JjdVSN8V39NIxVO9BpKDDBUgNo1vErxup0sdSHijkR1g1lc54QwnNu4H/UplaeI5p1zi7L915r/eJRln+hHU7uqfmgPDsUZ08mFqY1+eMDtpySPQmJf3t/o12anlMYFa4BG8g/bUJxvpK98uYNxgWmFfSfGSNc= 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=UaT6hxpA; 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="UaT6hxpA" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx-outbound16-229.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:34:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=buReJJL7Ewgz41aDIzhke4OryfPsSyffYkhzaEKviTz+J/MBWi2Xnb1VQT9xHCp43wlljkWizDd5C2UXpxO82MHaGOsGEY1Xg+fREMlijO+vDgzCdSoU9wYELI4kgnK0yZDwfHWAlnv/JV09sJjB9CQLmbHKKH934xYaZrKRo0fIV1SJwWHCNPrbWMpUP7wyqvfCIhdSsVElMCA83O6FvxJ9xAQMbAkn8HP68D9uEVyIpAxTu1CHb3qGrTElpsCKxGMoQJEliKBxh6rrVWIP5C+gTjtOpBJDIVCJ4gq69e+WRMrJdclypg8vFM9RCmryZUHgf8ekBb8BtN9mgOR5rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vOxclaByjsl02fVv3OvPg6rNpLPA6MpK7aw/CaeLL6E=; b=RMKNOc278Ip45GVB31EoreGWIa4aSofTgKi8zo/QjeupW/az7BTVLeG4AQUR6PL6w946VwDoSKHjVyDuhEN8I3uDQ6NKFIgZyhsH6AFwgklRuqgnv2zUGmPVI1DiLgwDxE8mgXFe/SX20DUNfAeb3txcvGx7HBhPBkyX02LmoxwwWpsEeGwAkAQpT59m8H8/bNXeVHH7JposaV2lPe/iD3hZgiumhTFIg686sK9bh8/ajVZMqOUqkXeGVw0IZ4arScghMmgThuM1eJGCxj6KCKcWq6QEq/Ct9UtPZsHjPXi78VovC5et85FT+yWDiiTcHBc2AWVV6iPyxfRMURMGPw== 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=vOxclaByjsl02fVv3OvPg6rNpLPA6MpK7aw/CaeLL6E=; b=UaT6hxpAnIjEBZaFMS83980RFKNqOd8NzTLCTUC0sseAw/AFt4kWCJkPDYkVkSTqFX0Ub7tgNmhC6bzFLb1MpezEuQelaKTCD/WFgrqAOFHbKXkOl3W2LmjmRDxUsYg2pZw4dKqjlA2DGIOWAP2JRnip2DpVXWK8yWKlh7HjKow= Received: from BN9PR03CA0675.namprd03.prod.outlook.com (2603:10b6:408:10e::20) by PH7PR19MB7995.namprd19.prod.outlook.com (2603:10b6:510:236::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.27; Wed, 29 May 2024 18:00:59 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:408:10e:cafe::bc) by BN9PR03CA0675.outlook.office365.com (2603:10b6:408:10e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:00: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 BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:58 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 0C51827; Wed, 29 May 2024 18:00:57 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:44 +0200 Subject: [PATCH RFC v2 09/19] fuse: {uring} Add a dev_release exception for fuse-over-io-uring Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-9-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=2894; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=RGsm+1aSws7TJ9BCCQvgJZGEWH8gdvkYr6JlgxeDFII=; b=e2EBd7Y6d3n0uUJDJni6S1QNWHsP6mwpeWGzOdyM2t484MYTXEh3u5mcpLEjismVmt6a76siD 1TPiCU2dtdUD1neP4Hgj4z/8QNVzb9BACg+86vGZdZXrc6ZGFuRe8CN X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|PH7PR19MB7995:EE_ X-MS-Office365-Filtering-Correlation-Id: 2aeed16e-2cba-409c-124b-08dc80094b9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Vzhr3XV9nWmSJWDkCjt3xwPySUkNB/C?= =?utf-8?q?le+0x4DJD1fJIOTPVoinkgMQQ1NIvgKlc31kZ+lbmVSh14I86zQEuuy56avLl8vhf?= =?utf-8?q?DDCGeRQtUiRwoXIDFhTFsnhNWGEbTM4i87U4Mj8IcEYO/fyybY2aDDdH+Sb4K08Vi?= =?utf-8?q?yyVrKC3o7mQWky5WUONYIrfKyiKesAZ/FVT7ZYec0dRJakoO4pO09ydQ/6CIKr88h?= =?utf-8?q?IhvvEGp2MqUtjeq2VJmLr18tDiQrTGKfh2c2xesWwqLzyewqwAmMLSqfWqEvkXwhz?= =?utf-8?q?Wy47cbYnSeZVrdLouIo/ExRX+SvT1aXKBAdvu35mz6KxrSllhWf1qSOTwCtBxj7cf?= =?utf-8?q?SLt+YPYN2LNfAq07CHSfNjBnvOEMmhJQ7fzWxy4Vic5AFCA+HHy8B1juCdb29jO6R?= =?utf-8?q?hmh7m04yPpNkff4pMkrVCp9ki2SFJ8W2zOrMDqW0w3fEaVAMiU4ZtU4VFH4t2OmiZ?= =?utf-8?q?4pvISBCevR+ppCjJ7BGcDYef6T1Pjdv5vz9MvwWkT4doGRnxYoBWTRtH1AcYMOnkM?= =?utf-8?q?On9vWQKMLUNYU0jTrqDhDJ+/YrxjZHARSCVJ0oSTt5cz0TRfDAFnnEHexuFdxnZpa?= =?utf-8?q?uWBPXSIGX2o3GRdnviHdLhobof5ajUQogw4kuJvM4qfOjNH74kQ5icOUzgLa/TnZN?= =?utf-8?q?sYQMYT3z8gLMvem78j+sRHow7fZtWWHuCM0Wk7fGeRk6UhfivVX/XHee9KE4OVapr?= =?utf-8?q?m0tOgi4sD86N3Fp3wSb9EhoMHFIaeB6vaihi5bFihCIJj+bgsvuEGvwiLY0QqFsBv?= =?utf-8?q?SqMzMQ77U73zyBAVT4QE5L7FX2qj7QVxwjla9V1QusAR/zgBoSNub2a16tyxQGMtq?= =?utf-8?q?1+R+QaclkSSM59SdFYmDiyZ6B1qz26hx84BguEAdQpiLJbmc5baFDpTHmM+SRlBv6?= =?utf-8?q?AieSdicb7TxxmE+JPz0S1NfXnHknPDzr9XctW9MkxX5qwArG9HKpJsSmqlAhpZVYW?= =?utf-8?q?OWdf5+hvG28jHdMz0QINY8kRUHR6lakaZW/DgWzli3lvJGO8XnSMcYvJyCkEJSCpn?= =?utf-8?q?KCwnjzxDjIqz8PChiU48QDR7zkV2Q/ghz4QzEU3XrCkfUTHKf6wiqYDnNNcSMkIBQ?= =?utf-8?q?5I0lfFX/lBuaky3Y6qmEHd0BYQIeKqbyhVk5RSr6veL9ptpKayJDfmILwH72I3E7e?= =?utf-8?q?Sirw8fSOKZBGEY+FxsfqNpRL4qLv0L+TIeeRz+nsO4AL9dy9xN03DLS+wwzsx6YUY?= =?utf-8?q?KXOEei/4Ra4Ls4si4wy/Qc+LTl++u0qSCfFKgz5fI8NTtlb/soobVsMjPFLnN7pbc?= =?utf-8?q?McNRIfubIaCH7niul2/Vo+6dRBgwFnSXI5UT0Ra5sWN/SA8pLSHo72ILlPICfVUzm?= =?utf-8?q?H5NUsCeoRSyY?= 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:(13230031)(376005)(36860700004)(82310400017)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8I28263zNowyKWsa3hSHD3RfD0KcWgi5+ZevsLMlFOfaPr/FQKeQsuwJ5gVxXBoGoO3MgDhXD++X/A09+Dw8FBVP1yq/WquE/Mc+BpwLJVEFddp7wNxiV767s6+sGLZG+vJ1I3tIB2Ex+OW1bZbYmijmfokIXrv/OxamFHkjx7pbZ6uvSg/6PuFMvQ4jzHtC7WUVMk9OG1NXcByKzsO4IkMmNdE9E1hTTFqwXedIPu/JQdPIssV37nFh/LGi7DsC4Y2//2MzkAx6nUd3+asK+hRsQUVDr0gtGO21GhCbxU1aSPQnzaQvNddW3K39KMcljt6cT+xyiDgh02bCpen8jzZ7m7jMHMX2UMF5d5mpcVpWeWdLEOJ46bniFf/VhBow8lL7ptfUmLKSWcHX2gRFPsC0fd3GM5FPf/ywx6rEeX6ZWk2rekq5pLjpoYQrP4ITPx+GORbj3Z2Qe0EgbGgylmef15ZisL0qBYHsThukjwytzUutKGFJL15jCZXgvXdCIcZQhNI0dg3zszrdm4Ks5jeBfoUtbC67tbuhHrO4/I0RxHCOhyTq03HlnL+qd5uA+ODffgIC2044gluD85OJ0M8pgKvpf5DWdlhpm2l3UUuibUJLwDbscqZrlxtnLJmYG2Z45HzhWMTzpuzOI8IvGQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:58.9785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2aeed16e-2cba-409c-124b-08dc80094b9c 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: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB7995 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007647-104325-12753-9546-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.58.101 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbmluZAVgZQMCnN1MAoLS3ZxC jF1CDJ2MAkLckw1SjZ0DjFOMky0cxSqTYWAGp4eEtBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan16-161.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 | 32 ++++++++++++++++++++++++++++++-- fs/fuse/dev_uring_i.h | 13 +++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 78c05516da7f..cd5dc6ae9272 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2257,6 +2257,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)); @@ -2266,8 +2268,34 @@ 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; + + /* + * 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->uring_dev) + all_uring = false; + } + spin_unlock(&fc->lock); + if (all_uring) + abort_conn = true; + } + + 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 7a2f540d3ea5..114e9c008013 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -261,6 +261,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 (READ_ONCE(fc->ring) != NULL && fc->ring->configured) + return true; + + return false; +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -274,6 +282,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 Wed May 29 18:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679349 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 9B4C3FC18 for ; Wed, 29 May 2024 18:01:07 +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=1717005671; cv=fail; b=gxlJFAe3ZNvpsTKj4WALN3Fw4TRy8amNwVY3vdb6oTSSXUdOrIqyav0MvKqXXyPoJt0+5+38Dz95uwU3iUNP2vdcSMaM4ZPgVsEwBE3mZeJdOaMMcfhfwBwpXJYyOOdj9oklytRVXlgUUS+O9BsA8VLbB/TP2677APlBohksAZs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717005671; c=relaxed/simple; bh=C1p2PtJLJE1c+rZEkuPKHJCB+Zf7TFnOk5YPoSiXGLk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=QFCxqNsBgVlFYQOM9Fm4OZ8nfMZwHZZ4Cf46mTStxhtvMoDZD+8htruw2xxqDLGq7siQ0B8uTrqlJaNCSRmbzLaCrV4kqeJIkNIi9ie7RU4JVSJZCViaz7Hht3BWGYM1nc3uOQFZsTUx/XtCCoHULPwW+/sB2PGte1slo9yfkQU= 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=R/XxNEC0; 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="R/XxNEC0" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by mx-outbound10-102.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:01:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j1qy6YqpuCRisnMwyiRtNfiBiUuwPloNS09IlyppHLL+F6UuuFeptPlTa/ERvGUhqVbEohRmJn93050GSaPnbNixoaAzvWMep8/2cr+h3knZplAhWZoa30KD3Ceqd/JnXP59Ti7V0m33yK/OGszO5Uq86/wgt6uVLA/W3aPQBbJ2aghLH0/N+s0jAyqjmNatFXfRo0RGj7sMEE2k2VII8/7oyOPcr/KcHGu5SoMNNJSUgRhJqR4vEJEAuH+yvbkMc6ZPXhCYcr3H8AJGe1EUhs2kFRhOCvmoGWJLcwWzE2qZDIYHSJf3B8RZCn06U0xhY9OLDyKsjfFBBTH963aEhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=d58Fb7eWCfXXD2AjOmf7GeNgOnaeXX7gLzBgZxJ2iKU=; b=O3aTmpxnmVknaBilCeNWI7J4u8cr3wigVmWjpNJnvDB/qeY1v+BIT0/5WuqcY08rdD3lvT67gb++s/EuKJbQz/VChYPLAskYTh2N1BVX6Dh28dviV7ZvpwBAcDDipPz6cvbkB8BRR9kHo4yJLNTV561R66WK/qtOIbvZPraqUPjVXrFFnatZtgi2P1rWYvT1Z3OfERaxU6ve+AKRygT8yTUSbGcUfqYYvw0V9xz4qzY+botA2g43aqvbWI1/Vrq10ps/w7E0UPL7Z/aGSTTVwvHLDfyTmcbXC5ITRm0jKzJkWsk7vgi4bUuBBynaIDHefiSKjjRg/Ocx+HdAfZG6ig== 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=d58Fb7eWCfXXD2AjOmf7GeNgOnaeXX7gLzBgZxJ2iKU=; b=R/XxNEC03E2H534ofm06LvTrYtOnnQTZPlWSgMmsR2pR3jPcR+55rERKCEctQA7PeQj5C2eWJidDJ0bDfHOXzwxzzGAHL8ypAt0UIhNFJ7Rao4AfxnNXXREEX9tq04X01jKprghmk3s6moijSfOss9AoimQ8IBMuvS/j05YFjls= Received: from BN9PR03CA0663.namprd03.prod.outlook.com (2603:10b6:408:10e::8) by CY8PR19MB7084.namprd19.prod.outlook.com (2603:10b6:930:54::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 29 May 2024 18:01:00 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:408:10e:cafe::9d) by BN9PR03CA0663.outlook.office365.com (2603:10b6:408:10e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.18 via Frontend Transport; Wed, 29 May 2024 18:01: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 BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:59 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 04E7E25; Wed, 29 May 2024 18:00:58 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:45 +0200 Subject: [PATCH RFC v2 10/19] fuse: {uring} Handle SQEs - register commands Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-10-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=10938; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=C1p2PtJLJE1c+rZEkuPKHJCB+Zf7TFnOk5YPoSiXGLk=; b=jnZ18oUVfocVPjF2zKJ8qvxeTNoz52gMrySqj5BkrSr6IYJKfrXumKMZtQJsPPfwoEcCsbX9r PHNvCoWcZmYCgCNUD7ExlyacgVeH15AsJVfdwDKBdsTApEBfjagSL2G X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|CY8PR19MB7084:EE_ X-MS-Office365-Filtering-Correlation-Id: 70772f62-19c7-446d-5ad7-08dc80094c26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?W7b5QCHNDGz/7FmYtMf7HDIobzpVM8J?= =?utf-8?q?n+Y5m0jdGMK8S/WidzKv0tkdlJY2gF4C+fd/w/9nOv6nG3nj8xfIJIvjLjQH/Y67Y?= =?utf-8?q?URpZatnOztXMfwSnvx2nbikmnB1QGPZTBndh5aHe7Tv/Jzw2gqoT3lHPEjDRnDOB8?= =?utf-8?q?scaaDd078QY4U3H49RmhYSPeDgtK5h4h17a8s4zMF04TfmV3gB1E7Hbaflc61eZLd?= =?utf-8?q?M61MGg6W9ZTvzVhZgxN3r7aQ/6/u423sDgzVB5V55IX2eQsD8/x6VC3e0N2asUwqe?= =?utf-8?q?tm60LZOQ0NYBXaSRsYFChB3IAwKkRTwFZLp8XwHvU3BHcpvMkw9pi+v7Xn3Sd8lBM?= =?utf-8?q?MFRn705g4fbyHfBKgQpJHTEBraMWoistTxn3docVwSjBAQfx+fCoXyK/eidEhseHs?= =?utf-8?q?+wLTesGjCjJS51YhM/gfTW5pauWfj8q6agSKXuGWglkKzs65T1uFgXN5WR4L+EWiS?= =?utf-8?q?T5XXRWONZtXYMTcx+a1Y6d4ruCI/qwkUN1WEQVp4n4d3xYyH1HT1CFd2aTb9dXE3+?= =?utf-8?q?aECS/41igRcpihexmLr/9EYVo0jQWVKqRCl+Q5BVxxNuho8O0e6ozYsVevXZF+r9N?= =?utf-8?q?XBfjfHrYc/b59lxx8v/cniyoIs3/ig/2nCc+z8OuyhVgxaypUDFAs6GKgW2iz9bcE?= =?utf-8?q?SaybZyw/D7Uu9+KdhEDeMySTwlEEckzJ+IAzVOjvJmPzIDnuTgsUmM9XauK3PnCeW?= =?utf-8?q?qN/HyMuEnYmq7ZgGuqEl7x5+yHB6V+9m/SyHMLHx6ZYOsulj+zOKjT9VrfmbzCZmt?= =?utf-8?q?Ayx09PBTVScNK3dJbNh6anmvP+vRB4goefadknvinu6oCcDITrnnb8Ghn5YZdkpFo?= =?utf-8?q?aTWilKLevrOCBXB5yTV7B01utYgdCfdKvRaQOFDs5RzboWtcWU5ZIG5PsKjA7ds0n?= =?utf-8?q?9r8qf4eKPDvBVpmJq2SI/0smZIpwmzKGTPbryLktl4DMQ+epjJO5NLEfvupNAAMxS?= =?utf-8?q?vcIJ/CcbWoUU3M5nGCysjnYJ92/cCjIjEM4u82ukbxi7/athB2fp4YN1BGVMKTZwS?= =?utf-8?q?h3PvQkiYbp0rKYjVKg53Ffq0SbE70p7sJKkzaGR5YcWLBdO6wqOOIdFY473P2HWFk?= =?utf-8?q?tGOduW+aB3cGqQU4O/I7D/DoCI/huAo4l8h6lFGHtpmef7O/fyHCGeXgGSUPUqjqD?= =?utf-8?q?NkqlRX4FVoIU813dJXv4hbqM86IijpJvOf+tjcZSSwqVZxjZXtqIzBQc83EITvc6Y?= =?utf-8?q?Vb1j9xWHNcs7+i9D3vBxUmLBx44Ct1B9CnVkbjDpbxxrlfHWnthDiLfaS/t8HhYJs?= =?utf-8?q?Thbx41l7KOm3KKyZd5Ld8HEuvdYxUbv8GttPzgSn+VKqHo5aZjb6ip7LiwAzbfQd1?= =?utf-8?q?dy1xj1+awq+U?= 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:(13230031)(82310400017)(1800799015)(376005)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iQZkm4UMGJ5K2yCP1OMpWFCgHVkVDAMaAtVhE3OQrQbXMCZ8LwiqwklHW5G9Vdt/ObTRzZgY9aLeY/bwDSPPfC98Urq1PvLuH7NUPyzaKVLBKehu63WNEvAIT0QCXoILM8+YXguZxLUqZQYktYAZN9roZnttDL+BdkTLKrntVYlJI6cABFs1AoB9FDerycRkEezOVMznCegne6LeV6TTya5Aqzkuh4o3i//e5DQEP6ZA97eW8IFF5kQdtU0SmBwyLJUeyAQ7zjakzeYQ03O08Q9LnRHaGCRr7MwgUtFjuiHKWd2gz6d5AJoiC6rwEV7aHjhbAC3bdzf/XNLJi1nxtdEkxVU/qRzSzvyd48m4IsdLbOGQhZf/9Z8H/wQNIHQOylhW1bd0nVDqzHoL7wjUfZUEXh/CBt1NRVFvHdwg8z/cLCJoKwV4tNZagCGZU+asaH9pUxr5CBH4fmW3jlZD8kpVepymy4TQ+/H1soQRg+7WTWTWAqmVoUeY4x9E8rH7YqPJKwZ3thGmCyQ25GC4oak1bRQo58dWkPwemb91DB8E00fl3vbjghP8+UhLEUlkfkwx6UGU2m8bBJAh6HaVClVqS3lA5S9iPZNk8ueZDM1OEndR5zsi7X0RZCLOVK+T2IZO1MjAYL6uG9HMtz8ejw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:59.8848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70772f62-19c7-446d-5ad7-08dc80094c26 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: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR19MB7084 X-BESS-ID: 1717005663-102662-12708-16973-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.56.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGpiamQGYGUDTJwCgpKc3cxD LZ0tLQItnIwsjSINHAyDgpOcXAzDQ1Tak2FgBvodBkQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan20-244.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 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 | 1 + fs/fuse/dev_uring.c | 267 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 12 +++ include/uapi/linux/fuse.h | 33 ++++++ 4 files changed, 313 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index cd5dc6ae9272..05a87731b5c3 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2510,6 +2510,7 @@ const struct file_operations fuse_dev_operations = { .compat_ioctl = compat_ptr_ioctl, #if IS_ENABLED(CONFIG_FUSE_IO_URING) .mmap = fuse_uring_mmap, + .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 2c0ccb378908..48b1118b64f4 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -31,6 +31,27 @@ #include #include +static void fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) +{ + clear_bit(FRRS_USERSPACE, &ent->state); + list_del_init(&ent->list); +} + +/* Update conn limits according to ring values */ +static void fuse_uring_conn_cfg_limits(struct fuse_ring *ring) +{ + struct fuse_conn *fc = ring->fc; + + WRITE_ONCE(fc->max_pages, min_t(unsigned int, fc->max_pages, + ring->req_arg_len / PAGE_SIZE)); + + /* This not ideal, as multiplication with nr_queue assumes the limit + * gets reached when all queues are used, but a single threaded + * application might already do that. + */ + WRITE_ONCE(fc->max_background, ring->nr_queues * ring->max_nr_async); +} + /* * Basic ring setup for this connection based on the provided configuration */ @@ -329,3 +350,249 @@ int fuse_uring_queue_cfg(struct fuse_ring *ring, return 0; } +/* + * 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; + + /* unsets all previous flags - basically resets */ + pr_devel("%s ring=%p qid=%d tag=%d state=%lu async=%d\n", __func__, + ring, ring_ent->queue->qid, ring_ent->tag, ring_ent->state, + ring_ent->async); + + if (WARN_ON(test_bit(FRRS_USERSPACE, &ring_ent->state))) { + pr_warn("%s qid=%d tag=%d state=%lu 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); + + set_bit(FRRS_WAIT, &ring_ent->state); +} + +/* + * 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 ret = 0; + int nr_ring_sqe; + + /* 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 (queue->nr_req_sync + queue->nr_req_async > ring->queue_depth) { + /* should be caught by ring state before and queue depth + * check before + */ + WARN_ON(1); + 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); + ret = -ERANGE; + } + + if (ret) + goto out; /* 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; + } + +out: + return ret; +} + +static struct fuse_ring_queue * +fuse_uring_get_verify_queue(struct fuse_ring *ring, + const struct fuse_uring_cmd_req *cmd_req, + unsigned int issue_flags) +{ + struct fuse_conn *fc = ring->fc; + struct fuse_ring_queue *queue; + int ret; + + if (!(issue_flags & IO_URING_F_SQE128)) { + pr_info("qid=%d tag=%d SQE128 not set\n", cmd_req->qid, + cmd_req->tag); + ret = -EINVAL; + goto err; + } + + if (unlikely(!fc->connected)) { + ret = -ENOTCONN; + goto err; + } + + if (unlikely(!ring->configured)) { + pr_info("command for a connection that is not ring configured\n"); + ret = -ENODEV; + goto err; + } + + if (unlikely(cmd_req->qid >= ring->nr_queues)) { + pr_devel("qid=%u >= nr-queues=%zu\n", cmd_req->qid, + ring->nr_queues); + ret = -EINVAL; + goto err; + } + + queue = fuse_uring_get_queue(ring, cmd_req->qid); + if (unlikely(queue == NULL)) { + pr_info("Got NULL queue for qid=%d\n", cmd_req->qid); + ret = -EIO; + goto err; + } + + if (unlikely(!queue->configured || queue->stopped)) { + pr_info("Ring or queue (qid=%u) not ready.\n", cmd_req->qid); + ret = -ENOTCONN; + goto err; + } + + if (cmd_req->tag > ring->queue_depth) { + pr_info("tag=%u > queue-depth=%zu\n", cmd_req->tag, + ring->queue_depth); + ret = -EINVAL; + goto err; + } + + return queue; + +err: + return ERR_PTR(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 = fuse_get_dev(cmd->file); + struct fuse_conn *fc = fud->fc; + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + struct fuse_ring_ent *ring_ent = NULL; + u32 cmd_op = cmd->cmd_op; + int ret = 0; + + if (!ring) { + ret = -ENODEV; + goto out; + } + + queue = fuse_uring_get_verify_queue(ring, cmd_req, issue_flags); + if (IS_ERR(queue)) { + ret = PTR_ERR(queue); + 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); + if (unlikely(queue->stopped)) { + /* XXX how to ensure queue still exists? Add + * an rw ring->stop lock? And take that at the beginning + * of this function? Better would be to advise uring + * not to call this function at all? Or free the queue memory + * only, on daemon PF_EXITING? + */ + ret = -ENOTCONN; + goto err_unlock; + } + + if (current == queue->server_task) + queue->uring_cmd_issue_flags = issue_flags; + + switch (cmd_op) { + case FUSE_URING_REQ_FETCH: + if (queue->server_task == NULL) { + queue->server_task = current; + queue->uring_cmd_issue_flags = issue_flags; + } + + /* No other bit must be set here */ + if (ring_ent->state != BIT(FRRS_INIT)) { + pr_info_ratelimited( + "qid=%d tag=%d register req state %lu expected %lu", + cmd_req->qid, cmd_req->tag, ring_ent->state, + BIT(FRRS_INIT)); + ret = -EINVAL; + goto err_unlock; + } + + fuse_ring_ring_ent_unset_userspace(ring_ent); + + ret = fuse_uring_fetch(ring_ent, cmd, issue_flags); + if (ret) + goto err_unlock; + + /* + * The ring entry is registered now and needs to be handled + * for shutdown. + */ + atomic_inc(&ring->queue_refs); + + spin_unlock(&queue->lock); + 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 114e9c008013..b2be67bb2fa7 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -203,6 +203,7 @@ int fuse_uring_mmap(struct file *filp, struct vm_area_struct *vma); int fuse_uring_queue_cfg(struct fuse_ring *ring, struct fuse_ring_queue_config *qcfg); void fuse_uring_ring_destruct(struct fuse_ring *ring); +int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); static inline void fuse_uring_conn_init(struct fuse_ring *ring, struct fuse_conn *fc) @@ -269,6 +270,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; @@ -287,6 +293,12 @@ 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 88d4078c4171..379388c964a7 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1262,6 +1262,12 @@ struct fuse_supp_groups { /* The offset parameter is used to identify the request type */ #define FUSE_URING_MMAP_OFF 0xf8000000ULL +/* + * 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 */ @@ -1288,4 +1294,31 @@ 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 { + /* queue the command is for (queue index) */ + uint16_t qid; + + /* queue entry (array index) */ + uint16_t tag; + + /* pointer to struct fuse_uring_buf_req */ + uint32_t flags; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Wed May 29 18:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679410 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 4580C15CD55 for ; Wed, 29 May 2024 18:34:02 +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=1717007643; cv=fail; b=dTQjCBVWzRGG1jiWjpZ2y5AiKcaLwi8KijjhTeB+xKrsjh2F8XU0gMiK/tSjBlXM+kWP/4mcVBGMn/VnwRPCd5GKNChhFnGbbingZmOsjrMb1pL7uga3dkVf5MsFaKmtHOWU9F0lxoodWEvVkNTk1uW08tsUIj0en92PDh88A7g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007643; c=relaxed/simple; bh=6Xg0iKKnVzbp5OdLGjtMLFQQe/7/r0SaUxJHcWiqYN8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=OLKIJX4m9fHvf5J4jSigPBCacCbOGqghgHW57KY0deVefLlUDSa2opWGwSuiM6fUFTXlYXRWkS6pothA8IAJXXF83A/Zf3jEQBchubrTM/aJRWWznq6PJppNbKrDg9CdE2UqPh8x2m2PGk1zUlPH2m0x2iPQQYzF/wbFqw7XVaE= 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=M04LijKX; 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="M04LijKX" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by mx-outbound19-65.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:34:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cgwy7otzh6R2NUcGQUdptef7oTu1EjUse3iqd11YzoTGhLqwPlHpP8dcLA9tOz1nkMEN0mtYlfA6JDCcBTD09iSc//0SiTma8DwemyW/VdDB2hoNhtoiVErF58Tl68SQosVvxu+CUTJRvhVG3X9w3fN03qXrO2g6qiN9Xk9rG4H7whSjij8FoCKbhri6wLsBGAHl9C2QDXyGiJAuXeGCiN7QghbE9PMomANvkqronLg1VDSFWlVIIVb4p+1lrjLuzxKKVkSaq3mhJRBDMBpTopY8MewHnSdFbWz40Qkw9R7/Pmdz5dwBTBjJKw/Wkj5bAW71C2rgYyL2emW096rpPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BG640MqD/Os/tHDKOApjDxHCLIyhhaZPAgmuiLKGdsg=; b=C416VSR1rJK3a2BTWhL+oIza3nBn7XT59QHL85DS8dFPAjSrP0Zw3FFc1UfEmlS2anCCKJ2mMTbV4UW5xgm5MK8noS+W53Da5ElxOsc/h5AhikOAJ+FcS8AYHwqML7l7P8F+P6VPCz2ShwqUfbatWrUTYC2GdqKiPlBat/jx1muw/QxpDg+ZKjTvXhsFQdoBmsUtQhNon4QnnIdkUP4qRCeez56PFHfNAjbRxXwpPPzbt8aCkplrn2rMC8xv92rw9iNh/1wyrl5DX4uRg/g1hn7lC6IGL16l5VQdfGN4BFroo03xQIuJze07W5dtjB2/FaY+lA/25zrjr6BWI6n9dw== 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=BG640MqD/Os/tHDKOApjDxHCLIyhhaZPAgmuiLKGdsg=; b=M04LijKXtVREeODP8XgZmfener6imOkJsmF1BqmoG+gCGPrTfQnHbWzAbHW0SAdv1FgcUBa4bog5bVP1LIreqhVV/nJl24DqGcmb5J2HvXSjWDERiDekqMXvnG9NjbUlPhB2HvN5lcDhpuP4Zo7PuQPGua7cqEtlPPPlD9u1CYs= Received: from BL0PR1501CA0012.namprd15.prod.outlook.com (2603:10b6:207:17::25) by MN6PR19MB7889.namprd19.prod.outlook.com (2603:10b6:208:47a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 18:01:01 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:207:17:cafe::9f) by BL0PR1501CA0012.outlook.office365.com (2603:10b6:207:17::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:01: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 MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:00 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id F178727; Wed, 29 May 2024 18:00:59 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:46 +0200 Subject: [PATCH RFC v2 11/19] fuse: Add support to copy from/to the ring buffer Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-11-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=5641; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=6Xg0iKKnVzbp5OdLGjtMLFQQe/7/r0SaUxJHcWiqYN8=; b=jHb2eDZCHYFD+W4vYqtAB7IqDYKSS9JmPo8tKdx6ZfkxS/z/5WaiOtvMLYKSgVH9Ds3p10qqF 47KBs6TM4flAtuIej5e3DA0u9Qlxf9K48EGLPYnx4YKzE5MknYg8pHC X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E4:EE_|MN6PR19MB7889:EE_ X-MS-Office365-Filtering-Correlation-Id: 0649a581-73e0-4536-f077-08dc80094cc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|36860700004|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rLoYdBqvWwNlsJTELpARwLO+PHNkfV1?= =?utf-8?q?WMvptaVwPYQ28kannj1uv4+esWgXb8oE9/viwf32zOixXRmii3ftSOQ86MSiFQXEl?= =?utf-8?q?6BuaVEqtpzEiYOIoqatOPKQnMumWze27Zf74sbAOhyU+bCkD2EWtmqbvojqZ2tNuC?= =?utf-8?q?95npcH1HfWeL6m+bhiVLoqKmpI513M/c4z7+LINjqJJKgNXOhI6Vu3th3ptaTN3vI?= =?utf-8?q?UBf0L6x7F6hZffuvdM/Zv1sinA/MBZPfFJhxtMw+rhdk7X/lql52/YjEkBjC7hkVw?= =?utf-8?q?iMRm6nSeKg09hoVRtoDHT4rKbbh3Vjc8jTQVqK6p5cV8ISfNkMd3emA4huzmDF5Gj?= =?utf-8?q?nlp/3Ig7l/5Q9kTLBRU1kmp0o8vDMd5ymS8qOofEeIr1zFDEf6sEj2Z6tfUWNc7Kg?= =?utf-8?q?AiPHEfaeD3URMrX7Q8FF5UuUyP8oLFhqhuQd2Tdt9LrGn4jYJ9vNRNmi8OMYGlTb+?= =?utf-8?q?Nn9S8+emsc55dq5LUNgWTiOIogTgvGIf0w0McSFNaAQ5bq8TdGpAFwPEzzuRofVos?= =?utf-8?q?N9FDZaiIqIV8SL8JaKXgUdoRgXh3XRcaeSI9S7ae5f2WB2cAXBEuKc2HgukKC58PP?= =?utf-8?q?Le2NjTGXF7KG9eDH344KG1wWulo0A0DYqvi6u2NE/b9/zdPaO8Ro40OOpaWDeQNvD?= =?utf-8?q?AaMN/PaN/FJlrpOZ+rHkq5hVEJ1sas+Wc3LwUtUA4FqcliDWxtdbAtbwMguLkVGdN?= =?utf-8?q?dZR5aZqMLajzztbLfTG8JyzESJEuWS8mynBXApU5stpf7pWxJNAdRDMgim0F5FH37?= =?utf-8?q?Rlv1OQIBRHWAmIbD+dF7fS9GEEbmc5r+fbq8+LjmYtmi8EJ6nP99xanelASGpksY8?= =?utf-8?q?zGJ7h+yoPpzLEpUJnxGuIkrg40J8qytAJJF9M/xTqTu8/Dcl2a+WRHhSIFOR1JI3S?= =?utf-8?q?jROVz1+WLFlXoI2XtFXVypeFnaYxFXKJypw8IaRsmBkXzd5wRvOCAYczO0qTtFcy0?= =?utf-8?q?JC7yD0PERL+9uaak4WAr4ACGWasE7fV5GNsW9F3yWqY64PI3tChfAwhIdm4xLziVq?= =?utf-8?q?/pKCyjGPRJtH3LdSLItPSRfYokanvui4UiqX4AJkor+Q6ZCKdph7yjzbZgdiwaeEl?= =?utf-8?q?NZ5t3m8Es+dru4XW7kOa4r69h3/+fmTZaDjeYohwXi7ArYor3TeNQ4IX6gz3L1F7t?= =?utf-8?q?GGDmNr/aijPVw47mgUkwJpq6HMZekxjoBR5Zjf4DAiyIx7v22gVnElfWT0ZqUVNVG?= =?utf-8?q?o0nUqdlfURfz9QsP8PzPMU9Q1k6ofeK3XdMAIcfxcQtJQ1eqjeMaTEicpL06Tmukn?= =?utf-8?q?l2PwN0QSiv414tj7clUZ0NZdfQLnqzzKruXSh795OWjTt5LYdQK+FxC9K+Hj2A29y?= =?utf-8?q?xb7d+dOw2m+h?= 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:(13230031)(82310400017)(376005)(36860700004)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: L/lNAE0VhxDPxbtAOTQiuBaHdD9LKNWNP3Tp8nFNYDibj4BzCCPXOjTkf2z7K8LBlYm+4YnuxL38wli8Gtpa7EleoiC5o+rAG7YBBLgpVC+YtmKZiozjjm/q0W6mbpTO7aiRHNUmqMJyM+6khwcvTuLuZ4XJWKRQ5snV2vkOETVBHB6PO3p4N/nlwraGEBaKHiHlC8XQMcP5v7mN2ddufKdLNnX+jwaQ9d1FENvJxaPG0niX7RJoS9WCthohpk6qLkn0DxI5n4oTbBBCgX9WSOFiQVHDaT/dX9oKSJcfdu2MnfcKt+t9wM9SRGJPTUZYp9e4IEIvxmIyNwWDE8FWXKxsv87HOZMBKDANRLZrvLSBon0nWdnqNgHBgLapDuJs8K8BhVmrdCyZ9RmveJXRh/wEVtvdhFdJuQD3vBpIP/A86BKz2sFYK6d6lk5bDNYxJ1h0ZaiFkYX8adKV1THjuy/cbS5n9vH1jjyCpW0aEukRz+El0G9UhVaRzm5mqboQTFgS51nwHqbci9Ppn+l9S5GtEYKBE6XYNQQGFx/IN7b6/PnL16fMudAOwbRKzB5W6G/rHqINrwSL7BqQiusTW43rlt4NVN72l3GO1t10cjXhcEYkH0Q+gOqFF4YQcvUHuVt9xpFEiopBK9xRKimxSA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:00.9659 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0649a581-73e0-4536-f077-08dc80094cc8 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: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR19MB7889 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007640-104929-12620-55610-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.55.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYmJqZAVgZQMC01zcTELM3QKM k0xdzM3CjV0tLS3NwwJc3YPM3U0iBZqTYWAPAlOPhBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan17-187.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 This adds support to existing fuse copy code to copy from/to the ring buffer. The ring buffer is here mmaped shared between kernel and userspace. This also fuse_ prefixes the copy_out_args function Signed-off-by: Bernd Schubert Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 60 ++++++++++++++++++++++++++++++---------------------- fs/fuse/fuse_dev_i.h | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 25 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 05a87731b5c3..a7d26440de39 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -637,21 +637,7 @@ 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, +void fuse_copy_init(struct fuse_copy_state *cs, int write, struct iov_iter *iter) { memset(cs, 0, sizeof(*cs)); @@ -662,6 +648,7 @@ static void fuse_copy_init(struct fuse_copy_state *cs, int write, /* Unmap and put previous page of userspace buffer */ static void fuse_copy_finish(struct fuse_copy_state *cs) { + if (cs->currbuf) { struct pipe_buffer *buf = cs->currbuf; @@ -726,6 +713,10 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) cs->pipebufs++; cs->nr_segs++; } + } else if (cs->is_uring) { + if (cs->ring.offset > cs->ring.buf_sz) + return -ERANGE; + cs->len = cs->ring.buf_sz - cs->ring.offset; } else { size_t off; err = iov_iter_get_pages2(cs->iter, &page, PAGE_SIZE, 1, &off); @@ -744,21 +735,35 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) { unsigned ncpy = min(*size, cs->len); + if (val) { - void *pgaddr = kmap_local_page(cs->pg); - void *buf = pgaddr + cs->offset; + + void *pgaddr = NULL; + void *buf; + + if (cs->is_uring) { + buf = cs->ring.buf + cs->ring.offset; + cs->ring.offset += ncpy; + + } else { + pgaddr = kmap_local_page(cs->pg); + buf = pgaddr + cs->offset; + } if (cs->write) memcpy(buf, *val, ncpy); else memcpy(*val, buf, ncpy); - kunmap_local(pgaddr); + if (pgaddr) + kunmap_local(pgaddr); + *val += ncpy; } *size -= ncpy; cs->len -= ncpy; cs->offset += ncpy; + return ncpy; } @@ -1006,9 +1011,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 int numargs, + unsigned int argpages, struct fuse_arg *args, + int zeroing) { int err = 0; unsigned i; @@ -1873,10 +1878,15 @@ 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 int nbytes) { - unsigned reqsize = sizeof(struct fuse_out_header); + + unsigned int reqsize = 0; + + /* Uring has the out header outside of args */ + if (!cs->is_uring) + reqsize = sizeof(struct fuse_out_header); reqsize += fuse_len_args(args->out_numargs, args->out_args); @@ -1976,7 +1986,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..f3e69ab4c2be 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -13,6 +13,36 @@ #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, is_uring:1; + struct { + /* pointer into the ring buffer */ + char *buf; + + /* for copy to the ring request buffer, the buffer size - must + * not be exceeded, for copy from the ring request buffer, + * the size filled in by user space + */ + unsigned int buf_sz; + + /* offset within buf while it is copying from/to the buf */ + unsigned int offset; + } ring; +}; + static inline struct fuse_dev *fuse_get_dev(struct file *file) { /* @@ -24,6 +54,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 Wed May 29 18:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679413 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 A96311C230A for ; Wed, 29 May 2024 18:34:26 +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=1717007668; cv=fail; b=dZw4GlbAMMVM6nIcFVHabMGnr5fJ8sdXH3iqG1suooqNbvYhDTSsgfZPSpPoWIFvK/gWjQmO3jJL4kP+SW2nhF/nt4HiQLwogUabAVFA25VBle73rxYb5CEYb2ZIXL/7Ii8/gRMtlsoQb433ZLSXFLXcLOaAm3iKQ8wkySSPRBI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007668; c=relaxed/simple; bh=CcNl+4uTqsWv/7y+EkzMH+0ATQoShxOMuW8cNxxdZ7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=Ll2agXQrD1lqnhr3HXQ0/Wj+imAHbMszsKr/Qkj/Q1OOpF56rdHcYIanHzTAlxXQjMLduQUIK/MyF8gdTYjZNQ5/w5TmHTUYWvPPx6oA75ZsG1CSPisRP8AvnhZwsZtOMie8O/ZvCpSqyLzhEUzN9gsPDEIquSvOPp8eSBzugoE= 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=f1RAq/Mo; 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="f1RAq/Mo" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx-outbound42-232.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:34:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C4zzMH1PgZcMCFoui3rjEtsp+KlrIibhlcT5C8YnrnCRNoNBTeExbA/+NZjssYLsOXJRaNngB8ya0Kc2PtsxIbwFIPsduvA1+f4mlMGrgOb1e8uIA8zflA0qQdrCQik5EJ5rqBhbq4oJJM/TdEIGBgyNcD5Xb2cUHdmSQN8adg2p97umjpJQW/jW8UJnH33WEnbFWtNxEFvE7AFo9yR7uGbOiX90jaDkDWqM9z5HtTFz7zx+GoFZH357vFB67zn+gssTZXfTyMtPqpknPxyRhbMLKxioW8kxQNtn/PrUyE5d4m3XVroXZEoGOLP/IQhVPQa934qMxWxfD6Mi8mTLKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=RNT+UV/N3hr4vIJIzccOWfOyrxWrlI6C93qZpFpW9jw=; b=LAOjynm10bfX0BUZl4fb70RE7PYhTQ7gipVXCvtm36DkiRvs413CYQ8aAKyIzvIiRBIzV7t/dyNYwuazEIrRPyU+CckUu3n/iNn7FXR3SU8I+WyJMuFof8p+74TN0fwmT39zzPZOU4T84yR154S9708NAzlmmmiKYAIGB/ZgdThuxIw2vmoC1wfH9c9dMJzi6LI1oFX2wFa5H/E5lqev0Cn0D+wDYY3FnHOCaHsnZq+6DgcJ5MsmY/Mfc31tkFTj+yzJlO1FbKKA82cgmsuU4O+rE/VkHmOAcLkMx/DxpOAyDgaxGD8l6RUtQj66d2K/rm292y/YF3/yKHlrj3QFCA== 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=RNT+UV/N3hr4vIJIzccOWfOyrxWrlI6C93qZpFpW9jw=; b=f1RAq/Mo8vD5TgNlu9ZhkxFwTcH2IKhXe6PiaZF6hc9It0iJMOoXbQEDq9HMGROk6kDdwCb4DsJNgz6YHmhIhB+0T8Zs34tK0APk1sN72t02U3GlUm2Gs4XILgWi4HtIe3Z7gStDt1IzcaqTrZvHZXC/vw/Lc1+I2QCzhk9Qxyk= Received: from CY5PR18CA0021.namprd18.prod.outlook.com (2603:10b6:930:5::9) by DS7PR19MB5902.namprd19.prod.outlook.com (2603:10b6:8:7d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 18:01:01 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:5:cafe::15) by CY5PR18CA0021.outlook.office365.com (2603:10b6:930:5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:01: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 CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:01 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id EA6914A7; Wed, 29 May 2024 18:01:00 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:47 +0200 Subject: [PATCH RFC v2 12/19] fuse: {uring} Add uring sqe commit and fetch support Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-12-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=10804; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=CcNl+4uTqsWv/7y+EkzMH+0ATQoShxOMuW8cNxxdZ7Y=; b=1t06uYdiOnqSWK6L83bgG+n3vXy8pgvag0ewKOfcjVp+SWF5HHPGjTbEBgYFsiMdBbpBKasle 3/nDd1eFP3/AbewAB81K3N2bZB3sijq7mbO73UuXPKI/LsHhsHfVgAg X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|DS7PR19MB5902:EE_ X-MS-Office365-Filtering-Correlation-Id: 3525fe56-4137-4819-e507-08dc80094d0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mET0F0hKVxq9ZGzV9zALiYH5t3Bnr+F?= =?utf-8?q?DHqEZvjL/qNi8Ab+kV48rNymunwZCv1YZ18xQqQjJvH7MtJSPeOnJEZSO9HV+VIk5?= =?utf-8?q?s1xF/kZ/MmKzWI7OupkioDXviHwn0jaCF6/lZ9OntabNZ01OTARhLEcAR7OB6HkkT?= =?utf-8?q?6tkLxO0/4HcLap7GWC/Vp/J6pjvDJW5cfLyq9RammxE2QTWUksDt94Hrzxd+JD1Of?= =?utf-8?q?yvoTZ2PctRTjdWQ0g4st5OipDcWj2WzwwHC4102hEpV1HvNy0E6b9+A1xVZdjYsps?= =?utf-8?q?F68zgZRTTfDSjrX068OOi9oAc0DIOxF+s7UK5So1AYtYnQvTPOYNVM7LXuBOxY+6G?= =?utf-8?q?HHXrmn5jPHd/IPSfB1DlMECRrE2ukWe7V5CEYrAaXR5Y9uCdCgS6tk1wubxXFKldM?= =?utf-8?q?Bp9CtfEPO0spmhBqYycvSbicBwsNShYZSiJ4Y89n3iKwb96IxNROCD0gQBBogDtSY?= =?utf-8?q?BrqICU2vASf334CPeB+4NEbfQRIpPyoEEkXKYLdi4NQcS2LjYbARqnC9ceM+x9y0X?= =?utf-8?q?vwQTOyXRcutZnLflm0i/Vnyf7+0Yts0k2/8UWzABxkcr0ZgIfWa86SjNUGBne6C0l?= =?utf-8?q?Gs2ExcaskMMsUYo0Y1ljHfNIZ01zzgwl/s3/PvTuEL5qmEZgr3gcoqSaulAMjvYnl?= =?utf-8?q?Obn6agHwa8cZZpY9hYf3UjBb/6o4CsjFi57WuUBs7m7GvH+GbsqKZ5dGGjRm7PCcH?= =?utf-8?q?5Tiod4oCAfGWZrEQJZ/4hC3+CnsBhbYtZxKTqdkTQJD5mSAVZ/SBK3FeKaLcBenVM?= =?utf-8?q?FZW70+EgOMtPlkCrNtZxnuT0Rx469X76pQ7/8mXU3dlxDB5AYQpd81yIQSvr1rCIp?= =?utf-8?q?0dcQNiaUWt76egnmUxVXGyEmJW9yGDGR8GhUbYqXRE39qAsGEDAlRPMBsSDl6LmDQ?= =?utf-8?q?upDz/0UI4X4xbUP5RO7a0U8XPJWH/uDM/X8A2T5/BzF/MFLy08vn/Yo6M225MPb52?= =?utf-8?q?bohSCndbaoB0VHSxJrSUGjxdx7OfCEgTvKXvpRt9AcKc8gSHpZaVccOVOn4R609LZ?= =?utf-8?q?qW8z+L2yFQB1BWNCa5DhWHoOaUxcqGxoYX5nhRqLMaUKgMRxencqCKdML1iH2mjMt?= =?utf-8?q?WFQeDhrRsKibYOCCMIX5gFvHOmhmk+uFC0Ii9IxX+iKNKn5Ewo2Vs6tmOk2GYXNqs?= =?utf-8?q?ku1tYs1fmAPlfY6QbfmgUkpU1VWIe5AQt4pqAxKlVAWyEeaWdjh6g7aDUQkZzUqbl?= =?utf-8?q?T/9XLc1GegJPKvFgy6Tm5L0nWdPAn8hGJItZVbxsgTdGvEMIvlh+r5xfb+3nO6LzY?= =?utf-8?q?9etV9Zo9JyNlrJJTbV5SnimFFOjapU+lmo9EWfU47OKZghZwY1RCfskpVo+FWwf87?= =?utf-8?q?NhV1KgRP4hP3?= 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:(13230031)(82310400017)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5n4tV6tMXqMjIa4tbJQH6NMorvoow+uKrvHfIam9IerE2YIXd1aA/fifgfxJD1CDpIaYeL+3rZ/G5HxBkPE3Mwan9WTKcAzodYmEUWc8WWp4bCJ2SMPd7ZI88TEt12yhaxHWCjT8vovJakmxsdE5PJNrefBDGWJp0msweSE+P+JFld2gM+ra67VO+YyfCYeQhsfcKQF81N5yFpvJuRQohJd6ioGGJMh62xgrKdI5SAnzQJVIQDp+WUzEI7LIgNvB9I+GE6TeTPilbHNVX+Mtd+4DvNdNyypboKjvNE5qiG2dO36llWk7ke1fHkSn/+Ae47tP0wMkp/uNVe/NbQfBmFXpzTj2TWQcNnM7BMIj2jNRJssU7wkgQoASnENZhFPcMo6obPNShpI/5V0KX+oaO5mrjmqQQzoNrCRxEmX63ysfYQzo1ImpDTph5PVOWWq2KqQT6eCizXgXmAT0nVJhSpfiR1Po/UqL9rC+r/awnCeXjlVHokagT39fXvYcJAc7+UIOQWjhRoHXhKzKQe6g9z+JwXyS8DQ1L/WWuZ6dBMYkd8WamQbUKddIk+A5jomwMPQ6sFOTGHcXzFc5dN36PpYcqjPMHUBt2kA3N5LCSlzv2CFdaVxd8vATpYSZ7/uYO9wt2yMPIIz/BmXTl6gX+Q== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:01.5025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3525fe56-4137-4819-e507-08dc80094d0e 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR19MB5902 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007664-110984-12677-56636-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.57.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGJsaWQGYGUNQiLdEiKc0sOd HA3Cwx1TglxSwx0cg4yTQpycjA1NjIVKk2FgDRJXdiQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan23-125.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 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 | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 311 insertions(+) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 48b1118b64f4..5269b3f8891e 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -31,12 +31,23 @@ #include #include +static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, + bool set_err, int error, + unsigned int issue_flags); + static void fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) { clear_bit(FRRS_USERSPACE, &ent->state); list_del_init(&ent->list); } +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) { @@ -350,6 +361,188 @@ int fuse_uring_queue_cfg(struct fuse_ring *ring, return 0; } +/* + * Checks for errors and stores it into the request + */ +static int fuse_uring_ring_ent_has_err(struct fuse_ring *ring, + struct fuse_ring_ent *ring_ent) +{ + struct fuse_conn *fc = ring->fc; + struct fuse_req *req = ring_ent->fuse_req; + struct fuse_out_header *oh = &req->out.h; + 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; +} + +/* + * Copy data from the ring buffer to the fuse request + */ +static int fuse_uring_copy_from_ring(struct fuse_ring *ring, + struct fuse_req *req, + struct fuse_ring_req *rreq) +{ + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + + fuse_copy_init(&cs, 0, NULL); + cs.is_uring = 1; + cs.ring.buf = rreq->in_out_arg; + + if (rreq->in_out_arg_len > ring->req_arg_len) { + pr_devel("Max ring buffer len exceeded (%u vs %zu\n", + rreq->in_out_arg_len, ring->req_arg_len); + return -EINVAL; + } + cs.ring.buf_sz = rreq->in_out_arg_len; + cs.req = req; + + pr_devel("%s:%d buf=%p len=%d args=%d\n", __func__, __LINE__, + cs.ring.buf, cs.ring.buf_sz, args->out_numargs); + + return fuse_copy_out_args(&cs, args, rreq->in_out_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_req *rreq) +{ + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + int err; + + fuse_copy_init(&cs, 1, NULL); + cs.is_uring = 1; + cs.ring.buf = rreq->in_out_arg; + cs.ring.buf_sz = ring->req_arg_len; + cs.req = req; + + pr_devel("%s:%d buf=%p len=%d args=%d\n", __func__, __LINE__, + cs.ring.buf, cs.ring.buf_sz, args->out_numargs); + + err = fuse_copy_args(&cs, args->in_numargs, args->in_pages, + (struct fuse_arg *)args->in_args, 0); + rreq->in_out_arg_len = cs.ring.offset; + + pr_devel("%s:%d buf=%p len=%d args=%d err=%d\n", __func__, __LINE__, + cs.ring.buf, cs.ring.buf_sz, args->out_numargs, 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 void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent, + unsigned int issue_flags, bool send_in_task) +{ + struct fuse_ring *ring = ring_ent->queue->ring; + struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_req *req = ring_ent->fuse_req; + struct fuse_ring_queue *queue = ring_ent->queue; + int err = 0; + + spin_lock(&queue->lock); + + if (WARN_ON(test_bit(FRRS_USERSPACE, &ring_ent->state) || + (test_bit(FRRS_FREED, &ring_ent->state)))) { + pr_err("qid=%d tag=%d ring-req=%p buf_req=%p invalid state %lu on send\n", + queue->qid, ring_ent->tag, ring_ent, rreq, + ring_ent->state); + err = -EIO; + } else { + set_bit(FRRS_USERSPACE, &ring_ent->state); + list_add(&ring_ent->list, &queue->ent_in_userspace); + } + + spin_unlock(&queue->lock); + if (err) + goto err; + + err = fuse_uring_copy_to_ring(ring, req, rreq); + if (unlikely(err)) { + spin_lock(&queue->lock); + fuse_ring_ring_ent_unset_userspace(ring_ent); + spin_unlock(&queue->lock); + goto err; + } + + /* ring req go directly into the shared memory buffer */ + rreq->in = req->in.h; + set_bit(FR_SENT, &req->flags); + + pr_devel("%s qid=%d tag=%d state=%lu cmd-done op=%d unique=%llu issue_flags=%u\n", + __func__, ring_ent->queue->qid, ring_ent->tag, ring_ent->state, + rreq->in.opcode, rreq->in.unique, issue_flags); + + if (send_in_task) + io_uring_cmd_complete_in_task(ring_ent->cmd, + fuse_uring_async_send_to_ring); + else + io_uring_cmd_done(ring_ent->cmd, 0, 0, issue_flags); + + return; + +err: + fuse_uring_req_end_and_get_next(ring_ent, true, err, issue_flags); +} + /* * Put a ring request onto hold, it is no longer used for now. */ @@ -381,6 +574,104 @@ static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, set_bit(FRRS_WAIT, &ring_ent->state); } +/* + * 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) +{ + clear_bit(FRRS_WAIT, &ring_ent->state); + list_del_init(&req->list); + clear_bit(FR_PENDING, &req->flags); + ring_ent->fuse_req = req; + set_bit(FRRS_FUSE_REQ, &ring_ent->state); +} + +/* + * Release a uring entry and fetch the next fuse request if available + * + * @return true if a new request has been fetched + */ +static bool fuse_uring_ent_release_and_fetch(struct fuse_ring_ent *ring_ent) +{ + 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; + + spin_lock(&ring_ent->queue->lock); + fuse_uring_ent_avail(ring_ent, queue); + 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); + } + spin_unlock(&ring_ent->queue->lock); + + return req ? true : false; +} + +/* + * Finalize a fuse request, then fetch and send the next entry, if available + * + * has lock/unlock/lock to avoid holding the lock on calling fuse_request_end + */ +static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, + bool set_err, int error, + unsigned int issue_flags) +{ + struct fuse_req *req = ring_ent->fuse_req; + int has_next; + + 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; + clear_bit(FRRS_FUSE_REQ, &ring_ent->state); + + has_next = fuse_uring_ent_release_and_fetch(ring_ent); + if (has_next) { + /* called within uring context - use provided flags */ + fuse_uring_send_to_ring(ring_ent, issue_flags, 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_and_release(struct fuse_dev *fud, + struct fuse_ring_ent *ring_ent, + unsigned int issue_flags) +{ + struct fuse_ring_req *rreq = ring_ent->rreq; + struct fuse_req *req = ring_ent->fuse_req; + ssize_t err = 0; + bool set_err = false; + + req->out.h = rreq->out; + + err = fuse_uring_ring_ent_has_err(fud->fc->ring, ring_ent); + 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(fud->fc->ring, req, rreq); + 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_and_get_next(ring_ent, set_err, err, issue_flags); +} + /* * fuse_uring_req_fetch command handling */ @@ -566,6 +857,26 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) spin_unlock(&queue->lock); break; + case FUSE_URING_REQ_COMMIT_AND_FETCH: + if (unlikely(!ring->ready)) { + pr_info("commit and fetch, but fuse-uringis not ready."); + goto err_unlock; + } + + if (!test_bit(FRRS_USERSPACE, &ring_ent->state)) { + pr_info("qid=%d tag=%d state %lu SQE already handled\n", + queue->qid, ring_ent->tag, ring_ent->state); + goto err_unlock; + } + + fuse_ring_ring_ent_unset_userspace(ring_ent); + spin_unlock(&queue->lock); + + WRITE_ONCE(ring_ent->cmd, cmd); + fuse_uring_commit_and_release(fud, ring_ent, issue_flags); + + ret = 0; + break; default: ret = -EINVAL; pr_devel("Unknown uring command %d", cmd_op); From patchwork Wed May 29 18:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679441 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 8EE2615B13E for ; Wed, 29 May 2024 19:34: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=1717011256; cv=fail; b=hbERsmdOloQL0uaaoSYpaDq0ayF6Cp3nEnfQf9l9Z0ncPc00YKuRqRsoYw/zYxFPQD95RQHLPeQ+0YWuPR7ewX/qD0XeQ9bQjno/1zhvCK13D0CF7qzQcsarOmJbZ+tio57t1eE/Pj8PiPNY6M0AbZyts7MNWO0MndNe++lH/UI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011256; c=relaxed/simple; bh=HorOtb32wYZnnjwl6WMg5S13aoIm4pN+nPF9ebPVagw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=blRwtb8Qad3W/2vAOZVRzWNx4bez8CyjO9V87+jKtMd6wd/P3XzjkwWzo86GlVZ03CAmqQb6mMeSgQbDp96+TmAMIWYOtIQTIRyq/WsCZY0leZujcdhwFedI8N818aBfu+zl7L+LixYGWNOcU9dR5eejk/XNi5nyEqur+UIP5JM= 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=sbwUPMR8; 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="sbwUPMR8" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by mx-outbound8-137.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:34:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BbLYRNhaOUKAbcbiXndCikMO2pHKQUz9sdapGbgVF6ZyMpfo8XfWhhYs1kRi/dZoQTGy9sjeaQ6gyv8V7osuA8lB91PJDIBD4Ax60XnQWKcarwGjpsEYse3rn9VVLIipO74rmqs6x+/fhIeLhJZB6I4epO3Bvj54My9c/ayJ19XqZ30RqLTuIFOuJX6a0RVmGasG1sxQ1PUhaKNlHgsnS/WPxyvy3okSHx2X64KEMv6WfSdSvHWtHmZuX6ElZSyzObbDSMdUYQdAwS9xyTZvW2UWonf+XygbxXV0bPpRFF7/1ZJaSzBaJDcdV8EBXeCmoDTG7watXIP78WGCaI6mDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CnOm1jqq/94uMhfygXgUHjQKz2mFXhxEHG+ZipgV/w4=; b=oFaVOBzHBlqF9R3tMeqqJw8xiDzyt30y9D4wRZjyHSVxk0mUhmv3rXJW3DlHEVqIiiKOl/ZIqpkLgz3Aa2iy15uV8EFNGbxIHOiFY3gdK0ibCCf7+/G4mnKZwvUSQtZzooaMxTd7/0fAFtD6LqkrEeryC125zueX3NsR+61nubq8aSrVhIumEHQHXjsSyILbK84SV4iSjx82WbQyBEXRDXfFadHNkm6ls6YT3UfaccpUzo4qHafl5zj71bsEDs7yHZXPNOLtuq4tUmOhqaLJytMDNJpO6oOsOqvweF2Qo91V+83PpLj7olJ8/gyismL6qUmnlOTZPiEQ4+L0gReccQ== 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=CnOm1jqq/94uMhfygXgUHjQKz2mFXhxEHG+ZipgV/w4=; b=sbwUPMR8NXooTFqwiVpd4pz/NOW578yuOR/ld1NLRipyuDnYmlUf9ch4AcPDEoiO5Y/Q6GsWWDmg/OKmi45azUrq9M/bjO0TY0onCaJ0B5LnhvyM9Xaq1qx+6croqb4gyrcLhziPF0YglHCuJt8SIUys6D68HI2eC5xzhZM8bqI= Received: from PH7PR17CA0021.namprd17.prod.outlook.com (2603:10b6:510:324::27) by DM4PR19MB7192.namprd19.prod.outlook.com (2603:10b6:8:110::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.37; Wed, 29 May 2024 18:01:02 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:510:324:cafe::67) by PH7PR17CA0021.outlook.office365.com (2603:10b6:510:324::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.20 via Frontend Transport; Wed, 29 May 2024 18:01: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 CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:02 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id E33B725; Wed, 29 May 2024 18:01:01 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:48 +0200 Subject: [PATCH RFC v2 13/19] fuse: {uring} Handle uring shutdown Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-13-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=9764; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=HorOtb32wYZnnjwl6WMg5S13aoIm4pN+nPF9ebPVagw=; b=sC+hBXO5NdrYI9epeJGOikrsEKMPdTyVMzSJ4EtJwWJeBSmGXN0LsYrAaM94JN74scU1p8WJG eLTzyeMqJZ/DOUy4AzQTDDc6lPd2sHRyBzU6jcQ3sM0KaYuJPHsc7jK X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE30:EE_|DM4PR19MB7192:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ece4a91-5ce5-4d02-9e4b-08dc80094d8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?vFogUlyfYVnU+vd/c/eaxuK+12KM5EN?= =?utf-8?q?Uo8Lf4sPIaaH5le7Uf1gEe6CKj1FW5PNIo7XRZUW2ESaYvh3Fl6pkUL6nZEA286Un?= =?utf-8?q?NhtqXIV6SuPuC6X3mysa0BmlmtWaxfh2/G/C0nKksWt5s8T/5IbLQCUgPWqajti8N?= =?utf-8?q?6jeGqQIuvhBCuYcFHgI01OwOfvJ7ZoDpH/Vahdu8+qWROti8r9hTjMRBvCDY6lPIO?= =?utf-8?q?CDjZf0bE6v0X5odKDCErgtlamRqthDIRO/qEcz8fSmfnwwepLTtrDhpjHVPD2wclI?= =?utf-8?q?Dr728DrZGIE0JiA3/ZzpYlWSHL6e0cm0bOZ3KL7hSoXuHOtJHjNj+Gflm859Bi6Yw?= =?utf-8?q?Qb7747Ozp9amRO2NPXWdx0JIq/3svwoB/TxxOUb3NMQT81UBPI560kBIfgZsyh9gq?= =?utf-8?q?5M2OgRKZXMHsI48IKh91GE6YrFBaNq8n8MrlRA5Bt1nJGiUwrALi45thoN1XG0efT?= =?utf-8?q?M4w/lvQTyAamuX8RiSdEoDPwH97nrk04hoB/LeZxvGQa04j8GgaalVKDw8U6D2Lde?= =?utf-8?q?HbK8paknEyCeVJQhNhTV2a7951nn7cPlrY5RllN7gREL/cL4idKgm5NT3ywbLCNXX?= =?utf-8?q?v60v8Q15Uj8UmuNb8uQH0uYYqzyOruyo4mQcIZTS9rBhwCV2NWM16IdVguZBshz0l?= =?utf-8?q?YNSWae7rWdTDQltwQgBrkGGnYCgA7ydIIdnxM0HzhAwZwOqTyUXKehVxrjJIlvENH?= =?utf-8?q?eCu7J+DUQ/7VuSi7dvRRm83nGYpQnDV+EMwyD4sD+8CXmK3JQZzGlybkxfjPsEQIQ?= =?utf-8?q?NdAV39daD4jB7XrEb1LzZyke/Ul9zDtg/g7HXxkwWD2yJgbI/IzAJFjFi11/xsPj6?= =?utf-8?q?Jwbh3esO7lAZ05Kt2mzxPEaDc0iZSzj4+TMMTu1iovy0jg9U+/7nqt854LxOeTZM+?= =?utf-8?q?inHfxyU4Po4k/gHCmJhp6awOvAq8Dqnm8uFpcQVpLtW7PjAdlnoMzBxipsDxLcXxZ?= =?utf-8?q?+2aaadlS1tJHKNVmS4PVREnue8gAdtnNukKObghkcRFo7FH5SKcPJCXvfCQ+7Jc9x?= =?utf-8?q?lR9HGrBZc6Jbze8tDDzXTNupon0oUyjzr3rC8LL8JdhG1M5rd/fyf/zVZX6FURdnZ?= =?utf-8?q?tu/tfOMHHHOLl1NO5tROrJOKzNUXbO6ubDaCLC5bOnCrnWHsdMnPLE0l31MVpc74I?= =?utf-8?q?0DOB6ZVlh8s6AaiGa5to6QX/invjVVqmT7nMTQuYzaM4LSopci1dYzJtxDvDkpMVz?= =?utf-8?q?WCogOBGkJ4vMZzpmSsYg7ZGZDNs6o2QgLlciedueDdHM/bN3A0zj+8HyPCX7LhLhE?= =?utf-8?q?CwtN/HQ/sRh3Hs2U+5f99F6HGEzUGtGCjXP5gzfSHyPR/L7ByWYQsXfeeXo8esllW?= =?utf-8?q?GH4v2onA20zF?= 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:(13230031)(82310400017)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2e2kQgfFuQg9X7x3uJhgw31wXlKsCYT13TytN1drawQWX/cscGq5y2rpV5veP1L21Wts1BEeYjw4yW43HZrbv6Tlvq1AzAeQBoLfPpgwpKZcjYhDfH0mdgVxe5hmrR3AEr9iLo6NHkwUj72b9fnaANovIofcJC2g7bJqBepsq/+0aRzlkOUeVqgnf9na9EnmC5L/GOwKiZNMfPA+OrSoARV38LGxiV2WDbeKAZ/5N2IjngevJu39E/IXDPnrHzltAxaUQd1xSFiY7wgLBMBFfVb39IVQDhFNBn741TZCjl2epo8HwhbWhB7vAcfzXrvX3bqt5ot/KO0pTBnYsbqQEQLoEZ0Jzk7aHCuSqa1sVVFc/U/vn+TFCuGpOdaOjmMi/pZvHGM6xG46u63N5y7XqkDX+odB/Y0Or+ejoqeTo27WGgxV83jOieNbC3RERrBE+//G3Ts7F3UCqMOxObWmGS0vvR5auXn9D3pyKcNIU8ObiMs1246UctVwHvgFjwhixxes6iPoJHPHszUhz80WJGnp/oG47qzfXL3p+Ol9hk/KVbv8rDRaXb2ntHdXs0spLCQjywEmGywPFpEnoL7jbc+5LAj+YZLLws5BJmwhcKGu012iW72dGDWC4C2oNU0yroQsYtNvpsMHiSWCoLjRjQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:02.3552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ece4a91-5ce5-4d02-9e4b-08dc80094d8e 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: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB7192 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011252-102185-14207-17562-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.66.49 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmBpZAVgZQMMnCzNTM1NDEyD TV1CA1xcIoOS0xOcXC1NDYMjkVyFCqjQUA4rMqH0EAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan19-121.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 Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 10 +++ fs/fuse/dev_uring.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 67 +++++++++++++++++ 3 files changed, 271 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index a7d26440de39..6ffd216b27c8 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2202,6 +2202,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; @@ -2245,6 +2247,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); } @@ -2256,6 +2264,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 5269b3f8891e..6001ba4d6e82 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -48,6 +48,44 @@ 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); + + if (!queue->configured) + continue; + + 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) { @@ -361,6 +399,162 @@ int fuse_uring_queue_cfg(struct fuse_ring *ring, return 0; } +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(FRRS_FUSE_REQ, &ent->state); + clear_bit(FR_SENT, &req->flags); + req->out.h.error = -ECONNABORTED; + fuse_request_end(req); +} + +/* + * Release a request/entry on connection shutdown + */ +static bool fuse_uring_try_entry_stop(struct fuse_ring_ent *ent, + bool need_cmd_done) + __must_hold(ent->queue->lock) +{ + struct fuse_ring_queue *queue = ent->queue; + bool released = false; + + if (test_bit(FRRS_FREED, &ent->state)) + goto out; /* no work left, freed before */ + + if (ent->state == BIT(FRRS_INIT) || test_bit(FRRS_WAIT, &ent->state) || + test_bit(FRRS_USERSPACE, &ent->state)) { + set_bit(FRRS_FREED, &ent->state); + + if (need_cmd_done) { + pr_devel("qid=%d tag=%d sending cmd_done\n", queue->qid, + ent->tag); + + spin_unlock(&queue->lock); + io_uring_cmd_done(ent->cmd, -ENOTCONN, 0, + IO_URING_F_UNLOCKED); + spin_lock(&queue->lock); + } + + if (ent->fuse_req) + fuse_uring_stop_fuse_req_end(ent); + released = true; + } +out: + return released; +} + +static void fuse_uring_stop_list_entries(struct list_head *head, + struct fuse_ring_queue *queue, + bool need_cmd_done) +{ + struct fuse_ring *ring = queue->ring; + struct fuse_ring_ent *ent, *next; + ssize_t queue_refs = SSIZE_MAX; + + list_for_each_entry_safe(ent, next, head, list) { + if (fuse_uring_try_entry_stop(ent, need_cmd_done)) { + queue_refs = atomic_dec_return(&ring->queue_refs); + list_del_init(&ent->list); + } + + 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) + __must_hold(&queue->lock) +{ + fuse_uring_stop_list_entries(&queue->ent_in_userspace, queue, false); + fuse_uring_stop_list_entries(&queue->async_ent_avail_queue, queue, true); + fuse_uring_stop_list_entries(&queue->sync_ent_avail_queue, queue, true); +} + +/* + * Log state debug info + */ +static void fuse_uring_stop_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 (!test_bit(FRRS_FREED, &ent->state)) + pr_info("ring=%p qid=%d tag=%d state=%lu\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, stop_work.work); + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = fuse_uring_get_queue(ring, qid); + + if (!queue->configured) + continue; + + spin_lock(&queue->lock); + fuse_uring_stop_queue(queue); + spin_unlock(&queue->lock); + } + + if (atomic_read(&ring->queue_refs) > 0) { + if (time_after(jiffies, + ring->stop_time + FUSE_URING_STOP_WARN_TIMEOUT)) + fuse_uring_stop_ent_state(ring); + + pr_info("ring=%p scheduling intervalled queue stop\n", ring); + + schedule_delayed_work(&ring->stop_work, + FUSE_URING_STOP_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); + + if (!queue->configured) + continue; + + spin_lock(&queue->lock); + fuse_uring_stop_queue(queue); + spin_unlock(&queue->lock); + } + + if (atomic_read(&ring->queue_refs) > 0) { + pr_info("ring=%p scheduling intervalled queue stop\n", ring); + ring->stop_time = jiffies; + INIT_DELAYED_WORK(&ring->stop_work, + fuse_uring_async_stop_queues); + schedule_delayed_work(&ring->stop_work, + FUSE_URING_STOP_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 b2be67bb2fa7..e5fc84e2f3ea 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -16,6 +16,9 @@ /* IORING_MAX_ENTRIES */ #define FUSE_URING_MAX_QUEUE_DEPTH 32768 +#define FUSE_URING_STOP_WARN_TIMEOUT (5 * HZ) +#define FUSE_URING_STOP_INTERVAL (HZ/20) + enum fuse_ring_req_state { /* request is basially initialized */ @@ -203,6 +206,7 @@ int fuse_uring_mmap(struct file *filp, struct vm_area_struct *vma); int fuse_uring_queue_cfg(struct fuse_ring *ring, struct fuse_ring_queue_config *qcfg); void fuse_uring_ring_destruct(struct fuse_ring *ring); +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_init(struct fuse_ring *ring, @@ -275,6 +279,58 @@ 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); + + if (!queue->configured) + continue; + + 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 (ring->configured && 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 && ring->configured) + wait_event(ring->stop_waitq, + atomic_read(&ring->queue_refs) == 0); +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -298,6 +354,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 */ From patchwork Wed May 29 18:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679440 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 5773C42045 for ; Wed, 29 May 2024 19:34:12 +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=1717011255; cv=fail; b=PuSylfZBpy55rv0+ItOffyYBX3XUH99KVljHb/GQwgesdYAdT1m0meJZ28zYEWFeKJthi4a1W62+zQcoN1shBRqm9KRBWJRdrXGCSJctjvuWKhu2pPECrin3Z3NpjZmcevbDdY0p056IRn7bmfr/FV49jom62ccxUDlEWzKgXJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011255; c=relaxed/simple; bh=/pLIyPnvASdj64wbsfVkAhSoyaqRjGH28OSgLGgAZtQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=gtN5GGNF/4bb7lLEKZCLn2HLlN6fgREVIttbrZYoNWq4I1gfmwL2F9viey5BeLApwN7+L2NslHOyyT1sHM6AelpJqCz0dCP5/11BlW/daU4Db7TW+GqmCmo0LWYyVT/wZqv1mxFIIstc7eWFPd+kLEwR62ejDzSereltkTlN6Yc= 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=m0Ks7pmV; 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="m0Ks7pmV" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx-outbound22-6.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:34:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GwsGQSkEqAvBfAQgez7/sOOmWxZ+AIpCRaf0YXJaaczpWJFlffmdVLaPtwJHH3Fy2QY5477qQsv4zuGcMoLdVMCWtzPt+XRWKjEa+QloW9h1d9gqBx/E4WVMogsKd7U2jP/6pZCXwc3uaD5u5eG5Sat0ThbHZJKDLbOMAhuX0uVNp2uf0biw2uQbf0ZA789mEweKVxkZclHS7hNqwfBiVOQZgQ4y4jECAg2WpxHDS4C3qVooPjB0rK2UHCYgC+Dk9NdHwpk1MsfaFB57rVqOqLt6QPPm8JyrCPWlbjwkxthNqa5hBCEBgw4kxZWKhx3Gxsgd/RLQ0MiszkrUbiOMrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Ty0yFi5Cn7xiCqb9JGfMVtY+eoKue0HUdd+30MJ2MB8=; b=ANmGI1AEqsn95226AiMUL3a9JN5TqfEYBcVA9RUJ3gJYrMQyzPXqttB5ALVY88wkQHvN+cP2IU+bno2Vy8x7VgLdNnQZLvrmidEEXxRtw9IEuv1YhR4inTdwbGJ2LKIzpFGxHLJCVDDQgvx/f7ZxVWWtVwK0WBi4UhSEjhpKctsVMTE0GT+Xv6943wVB5LaZUYvfgh88JB7OxSb1YI+lhsRzprghtlOTMSPkfKbKdZ2geAAJdNL65jsJvd3/J3Eb1AZtZzf556wIRYCBEKVO0/sundhAOcXqgblWVo8oPlmXy1hM+LYsNUYPh+ZEFU7iRW7YxYYWoW95nfTIX6RgsA== 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=Ty0yFi5Cn7xiCqb9JGfMVtY+eoKue0HUdd+30MJ2MB8=; b=m0Ks7pmVCjQByFKoZ3TDNs54BK5cSoopn3fIXbb7AJ8++jizkR4fXr29rN1dlfPB1VnNR5oGN8N62DomizijnXIZeAr23arg/BizfAkMwKxxYDj5/pQBo/XqzWwKt0YnIMtLsSIH5xBDzslLiDOWKLE+V2mYlR4yeSlO6qfgS5k= Received: from BYAPR01CA0056.prod.exchangelabs.com (2603:10b6:a03:94::33) by BY1PR19MB7775.namprd19.prod.outlook.com (2603:10b6:a03:523::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 18:01:03 +0000 Received: from SJ1PEPF00002317.namprd03.prod.outlook.com (2603:10b6:a03:94:cafe::a3) by BYAPR01CA0056.outlook.office365.com (2603:10b6:a03:94::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:01:03 +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 SJ1PEPF00002317.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:03 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id DB2B927; Wed, 29 May 2024 18:01:02 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:49 +0200 Subject: [PATCH RFC v2 14/19] fuse: {uring} Allow to queue to the ring Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-14-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=12157; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=/pLIyPnvASdj64wbsfVkAhSoyaqRjGH28OSgLGgAZtQ=; b=XtgRgTtjIPhL5rMlpoFzdZfD56yCA04HrayoANUNDG0S45+YhC4oUVPXYdpKXn5jiOjR3HyZ7 LNFEWbbVTH7C9av34wbArqibGrK+92KMxY5xD5vcPeXA7UwwhluHl5W X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002317:EE_|BY1PR19MB7775:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bc15e17-da03-4ca2-6192-08dc80094e52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gMu/NUyOnYf837ILASpTmtsAkcmf/jq?= =?utf-8?q?fFChcqvaG9VvbilpgZPuzoMuMBOOehiDCfmkUQT/arjuGzH7JALCUNU5hbAAnTh+k?= =?utf-8?q?vh/5GUO7V9IhaBgMQ75SvHlhK+rtzI6hSL2Cf+CpXyfuDWSwV5p/qR4e7z0aZxLEt?= =?utf-8?q?kZl6AJkPbVJBAQf7ZBu+bG3lXsQG0I0qMHiMznw0YMwbtCW1ydkTb/2erTA0Qwtnn?= =?utf-8?q?X9fBdElUrh/X5eEbobhpt+Fk75RY9KmKr8EAO9GudhzLKyse4ifb4FLw3T2lwlWg9?= =?utf-8?q?B1CtIxfKBnQgaPWPiFlxbkcfATrWlUwRJUx5Rb0tMkWbeSTTuutgFXNgOdXxD+5+l?= =?utf-8?q?oH5SxUGjX+7Kk5y+V9BJY3I8s68fF1Phn3OlydEQGGIQ9DXWgoODhn+QFiwk1h/HN?= =?utf-8?q?E0zKGpRTarSewwhcY9e4H3laIM3iWp/X8m/YVFjTsBmAC88YMZAVdNdqdNO2K8UvS?= =?utf-8?q?TQCsJY/4txSksHBNRaJUOVT1ilB6It9sKiF6X+dFPEhx5vQoau5eXSG8i1h76ouDe?= =?utf-8?q?D7CKOqx9jmFzAY/F7GtPyPt3/EN/uorJOKfC3Ri+MM3/0NEsMmll+kyEb5lz0AfQc?= =?utf-8?q?c9yyJXkZ1k6bUDRewfWriuezwfP/cMiO++jA3gcS9Nk84+D1rGN3W0Jws+24mwYSQ?= =?utf-8?q?K5Vs7BkjxiEMDVu/wVCTx3wykssHAUnmddrpgSkvSDhNZzA5zzy5vxcHzgiFxREf5?= =?utf-8?q?j4ItBzxUkedvBCYD6sQAHfJtfzrq2ZsgCpKQq5C1y/bC3rHfzvhKbnwv8JOAqu9Yh?= =?utf-8?q?uvNkEek60AtbQMacjdSTqedmtf8mqPGUHbrN3uX0AyIZv+pft1xaurQDLF6ULyipU?= =?utf-8?q?HZkI1TNnThquJdCSzWhMeOy3ACuTbf6SuCBrxgN6eHAzqwvclchOl6JD2ybSXhJHk?= =?utf-8?q?Q8bVMWBV68Ux8Xgr8p7OKxV6y3PhL0hgnQ5CClYAibvSTBV7G0V1+GzzU5IBEmVe1?= =?utf-8?q?924aGUDSo8M6znlcPU2sYhxQlVY9+xyHh2sImZNp3QSAOZFaA9HTaS8f6yjrPbkv6?= =?utf-8?q?tFke4GT7wQQTSagTwcV2L/tJ+vZ2I5pqideuTlzH8IjKdsoyerhU4Xge/B7SSvWp5?= =?utf-8?q?xAfT1LhG3cdjbXSHp0UT+pgFXjGz2CRhfgct4sfgoDR3vUCKje1Eo72/gM5u4/aLs?= =?utf-8?q?C6zl/WVOENe9nEHi8zPbrKpoY93y1mxwwWmYG3vhXyq6wFZUjY7ehP7hggBTndgd6?= =?utf-8?q?z4yaiqC1/YU8NtqusGxj1ffWVkgGy99sbV9s10dLdfk0BNxFmSld3elNA8f7dFgcr?= =?utf-8?q?LlhSH+mWPVjGNbyLe4hwYQa0Kh2LObbmFslXOIOjhKhQWP4s2gVLPcMNRvsXasRWl?= =?utf-8?q?9XqcJhIwjWwG?= 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:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AyseixRltHjlva0lM3XP+FnsoFaRh57nOEIj3bZ7pyyY8o2uowO+Mww1s6734t+tZGXetjo6nBot4BSLL35aLy2S1TIhXIe49eub4U2q77/4qA7gC/1Evt6pSl8FP+04GGZsnCmYvd8Iq/HODT7ORnxjIKgA7A6B+vx57wZi7w0Am4VEcDQIreIIlXXarlZFcfPAYXNbwJDpiwLJeEe4+DJy0rak0kYaD8lnL9M7sTw7NyGkj5HgkICoKvYSksFw1q/xRSLaHN/DWOv9pdiI2x4oc4LuVUvNhkco+P3Kh9Y1oYARlAICTDUyxpVEopZp86JfSrmRdVPD2pdbf8+HrO5yYZUmH5D1xOqM4erHT7TJcBlC955jLlp/91Yc7mvCyDtJO0n3kD72JSPmN/6dToBl5odMnNnWadu47vJimgeY987E8ARGHBrSLt/S+fqhhvJMEo1/hnygOGEJJjewb+5/Tn+vWzoDmWI6MOwQuzD4NvAK6mckPeh7S7UpPCfXHvf8X0M8iRKpx9WNT0v02jgh6t5TALwVOuUDDcbrVBZJXyw7GZYi6r/VXGT0k/KK/gNF/d/3kT36yoIVMqqKCSpmLlefKuPF2assTlrrzA5WVe5O4jepvzkSKYN6bUG+8cVYqX0umIdjrg625124hg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:03.5756 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bc15e17-da03-4ca2-6192-08dc80094e52 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: SJ1PEPF00002317.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR19MB7775 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011249-105638-25772-13383-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.58.101 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaG5hZGQGYGUNQ0xSzFIiUlyT zFMjUx1TgxxTAlJS3J1NzULMnQIjnVXKk2FgAMatQKQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan13-62.us-east-2a.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 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. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 80 +++++++++++++++++++++++++++++++++++++++----- fs/fuse/dev_uring.c | 92 ++++++++++++++++++++++++++++++++++++++++++--------- fs/fuse/dev_uring_i.h | 17 ++++++++++ 3 files changed, 165 insertions(+), 24 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 6ffd216b27c8..c7fd3849a105 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -218,13 +218,29 @@ 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)) { + int res; + + /* this lock is not needed at all for ring req handling */ + spin_unlock(&fiq->lock); + res = fuse_uring_queue_fuse_req(fc, req); + if (!res) + return; + + /* fallthrough, handled through /dev/fuse read/write */ + } + list_add_tail(&req->list, &fiq->pending); fiq->ops->wake_pending_and_unlock(fiq); } @@ -261,7 +277,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 +421,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 +434,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 +504,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 +535,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 +636,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 +651,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); @@ -2205,6 +2267,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; @@ -2478,6 +2541,7 @@ static long fuse_uring_ioctl(struct file *file, __u32 __user *argp) if (res != 0) return res; break; + case FUSE_URING_IOCTL_CMD_QUEUE_CFG: fud->uring_dev = 1; res = fuse_uring_queue_cfg(fc->ring, &cfg.qconf); diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 6001ba4d6e82..fe80e66150c3 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -32,8 +32,7 @@ #include static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, - bool set_err, int error, - unsigned int issue_flags); + bool set_err, int error); static void fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) { @@ -683,8 +682,7 @@ static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, * userspace will read it * This is comparable with classical read(/dev/fuse) */ -static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent, - unsigned int issue_flags, bool send_in_task) +static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent) { struct fuse_ring *ring = ring_ent->queue->ring; struct fuse_ring_req *rreq = ring_ent->rreq; @@ -721,20 +719,17 @@ static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent, rreq->in = req->in.h; set_bit(FR_SENT, &req->flags); - pr_devel("%s qid=%d tag=%d state=%lu cmd-done op=%d unique=%llu issue_flags=%u\n", + pr_devel("%s qid=%d tag=%d state=%lu cmd-done op=%d unique=%llu\n", __func__, ring_ent->queue->qid, ring_ent->tag, ring_ent->state, - rreq->in.opcode, rreq->in.unique, issue_flags); + rreq->in.opcode, rreq->in.unique); - if (send_in_task) - io_uring_cmd_complete_in_task(ring_ent->cmd, - fuse_uring_async_send_to_ring); - else - io_uring_cmd_done(ring_ent->cmd, 0, 0, issue_flags); + io_uring_cmd_complete_in_task(ring_ent->cmd, + fuse_uring_async_send_to_ring); return; err: - fuse_uring_req_end_and_get_next(ring_ent, true, err, issue_flags); + fuse_uring_req_end_and_get_next(ring_ent, true, err); } /* @@ -811,8 +806,7 @@ static bool fuse_uring_ent_release_and_fetch(struct fuse_ring_ent *ring_ent) * has lock/unlock/lock to avoid holding the lock on calling fuse_request_end */ static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, - bool set_err, int error, - unsigned int issue_flags) + bool set_err, int error) { struct fuse_req *req = ring_ent->fuse_req; int has_next; @@ -828,7 +822,7 @@ static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, has_next = fuse_uring_ent_release_and_fetch(ring_ent); if (has_next) { /* called within uring context - use provided flags */ - fuse_uring_send_to_ring(ring_ent, issue_flags, false); + fuse_uring_send_to_ring(ring_ent); } } @@ -863,7 +857,7 @@ static void fuse_uring_commit_and_release(struct fuse_dev *fud, 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_and_get_next(ring_ent, set_err, err, issue_flags); + fuse_uring_req_end_and_get_next(ring_ent, set_err, err); } /* @@ -1101,3 +1095,69 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) goto out; } +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 (unlikely(qid >= ring->nr_queues)) { + WARN_ONCE(1, + "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; + } + + if (list_empty(ent_queue)) { + list_add_tail(&req->list, req_queue); + } else { + ring_ent = + list_first_entry(ent_queue, struct fuse_ring_ent, list); + list_del(&ring_ent->list); + fuse_uring_add_req_to_ring_ent(ring_ent, req); + } + spin_unlock(&queue->lock); + + if (ring_ent != NULL) + fuse_uring_send_to_ring(ring_ent); + + 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 e5fc84e2f3ea..5d7e1e6e7a82 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -208,6 +208,7 @@ int fuse_uring_queue_cfg(struct fuse_ring *ring, void fuse_uring_ring_destruct(struct fuse_ring *ring); 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_init(struct fuse_ring *ring, struct fuse_conn *fc) @@ -331,6 +332,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; @@ -366,6 +372,17 @@ 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) +{ + return -EPFNOSUPPORT; +} + #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ From patchwork Wed May 29 18:00:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679444 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 E4D2942045 for ; Wed, 29 May 2024 19:35:23 +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=1717011325; cv=fail; b=jN0egr/ND6hIcjTs++PXukbdb6k6E+tfYNACFfbSA25fSZ114BFlUdnEyVh6MAJ1CV2bkxP/aN90wguhicWTR99CM9rzMFUc8PRtFGbvnmgyLhRtskCHo8RHiQXC2Hod5KPGvv0gEs9ddizFqgYHK/TgHrgEdfDDpO6Qkq29krM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011325; c=relaxed/simple; bh=hGZY0/CVL5YnixNcNqwYzhhkGec435ldTQG/hUg5tmU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R61Fxv3jp4S83/ydi/8qW4h3DDQGVh1lgMjqElTMPOnJVNYbqH3FAO2ceKYIDcYtSsKV/qHOBwY8VLu5xSwW6rmfLO1A2xBjEjlMHsiZgP+YYml26wihaM3UCJZRhD5g68HPO/wgHxvgmcIBg5s1lOtwkuQKusbndwlsykloeiE= 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=Kyyw6/of; 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="Kyyw6/of" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx-outbound10-110.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:35:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=REFUz4tBTgf3ZMyHCA8dmH8Bc3i6lf+PvZumcMr6JazAQHOLIggRBPf88jydTZ+JrrZnhz+VNpeCB9G1/uBSfxwiEA6tywV/A0MxOSmbRbAIR03Qgc5UOsUd11zhdpeEpEjmiWNE4CGuS3mvagD2Hz1oCIl6MOPyH0fRhHKDXYA1ZDLQCRV/Iw+14EfkNNsPr0DpBg2v5kFY32XcnFj/K4DY0Ze0QQsS9+W1FTOXzDrvsKtIdsT0jAdMtLFDO+peQKqtuCDCoKU1fW872dJWfSYoAgioLwLMbfwwvr9EIlP9p97X0kG00o9UAkeqn95GZZGj2s6xyg4QF79wi5YN6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Wg1bCdmL0ksCHj/ERN1DKLMkr+cbKMVzZ+pUtVnyp0Y=; b=LVG8Ye8NWpUBAzbr6USm+vmZKW2GwISg98zLeQJVhyiEFwEmC3Q2xM2cdSm62F87NTJBnLthH7GrSEe9jXP7DE46E/k1ihsTLbl4UVH3gAgzkRewcx0fuf7N/wPy2PYgdUSq6v61yjuzurFxleapyTnm1vBB6SFg7GhiI5PckTwwo//lFMaJCLPpqC1csBX0pZfvv4EqgAXYF7ciEWUNsfMbres39CBustZ9NZGWPjn7E5eu5cwwN8pabQhJJq1Hb6spopnRi1BFPd40vWr7g0QVQ9Mi2AaRySGrdLt6dboPVkfpzMJuAEfqTEBeAxgd5w4gWIG/g2vkmWDVTErKAw== 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=Wg1bCdmL0ksCHj/ERN1DKLMkr+cbKMVzZ+pUtVnyp0Y=; b=Kyyw6/ofXtHhI+6HWGEIJZwUWF/NEJrXuydgXLyVaQjUSNhiFndhC2ptgmNhxkYsiVNVeEEtVXm4LqWfRz40hcD0TXCPACyzB/2BOrJb2YIKVffEQyJmED7oFNP6bxFuBkUDPKPecWfNdlsIF2KuhFleL5PsqjMrEV7BmIZmq2M= Received: from PH7PR13CA0012.namprd13.prod.outlook.com (2603:10b6:510:174::18) by SA0PR19MB4635.namprd19.prod.outlook.com (2603:10b6:806:bf::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Wed, 29 May 2024 18:01:04 +0000 Received: from SN1PEPF0002529D.namprd05.prod.outlook.com (2603:10b6:510:174:cafe::c5) by PH7PR13CA0012.outlook.office365.com (2603:10b6:510:174::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.20 via Frontend Transport; Wed, 29 May 2024 18:01: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 SN1PEPF0002529D.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:04 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id D3AFD25; Wed, 29 May 2024 18:01:03 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:50 +0200 Subject: [PATCH RFC v2 15/19] export __wake_on_current_cpu Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-15-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm Cc: Ingo Molnar , Peter Zijlstra , Andrei Vagin X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=935; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=hGZY0/CVL5YnixNcNqwYzhhkGec435ldTQG/hUg5tmU=; b=pUctWm5Q8BHDdNUsGmPBDpqG7t5bfcizOYdOOIGmgb2r9MNQHtHGnZjvgN6QyPrPnxZ8PbIQ3 CJhOvtDXXx0C8QHvz/7LaW0VDttIiGDJlnhK2mKmfjfG640MkEedvd1 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002529D:EE_|SA0PR19MB4635:EE_ X-MS-Office365-Filtering-Correlation-Id: c7720fc4-52b1-4beb-a642-08dc80094eeb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?qkdxLn9k8A1Znu96Zplv+yvv/sUV7zL?= =?utf-8?q?DGS5U45T2ad6bbtQxMdFeVB6eRscQuJEl2qGZkkYqETe74blAJQCEr25F+cb1ebbb?= =?utf-8?q?z7bY1Klgx/L5Xy9E2a2rV5xK/1/sIxuyIqgTG3mDG0jGStJB9NTGVC0bOLg+Nbg9H?= =?utf-8?q?CGJPlHlMYiWVHG4IDajJNVPlgZxdkJAyzSKcQt684JDGq1AmF9SwMQtE7fqms2Bl/?= =?utf-8?q?v+gAJk8TBwtjiBNHS3zfNhlWmrwjhisIVozVa8TOQ98Ps6JZgVOrvJ7XTOENtbJOc?= =?utf-8?q?qGcdhA/OzwFG80JydO3a2OWQZJILR0bR/e6pzv9fI4NQPgaJUjMU6ru5PERUNOavl?= =?utf-8?q?12XlX6/JNZG5TLMx9nB9YoFQiMB5D95ZO4N0eUdZEXbvN0Kr9woTFBPfdmo3DrJ8k?= =?utf-8?q?4jytpKyAOI8Lk+TMN0riXwp7COsSnIk3cdLK7lteqHQA7lA9D/jhiCoMrGcqL10X5?= =?utf-8?q?qaVW8yMpMs9oCJpL0KXXLY4gqvSd371VPa6/PVXA+Sn9qOzJKr3pD3ek1stKus9l0?= =?utf-8?q?ltTBQzVTRJwuv50B7bGps5HgKkyTu1kXyUhDZI0Djtyy9p3JIrOUbXJ8wMaoOjfPT?= =?utf-8?q?HBM9BkzTcnxrXs03wG/909e+l9+/oHAqbwJ7pn8vHxnGXoic5DLoLK/IT8VPVY0tW?= =?utf-8?q?8pdc9TScOyiWUMW3mh1i2mIpxhAgUXxGo0w7MMgYugTnNnuGpHDLPV8ajbvnEMZ7Z?= =?utf-8?q?457NE3aJlF9yPVVOYc5Wq6WwNAfmL3OcZUDh01RHE6Mr+40vPhNgSZve/MeQa+iNP?= =?utf-8?q?DJuY0Tm/C++GCplJ/ZLb8F4O4liK34Ob15MSqHMu/A/hPvW5907FIx5MCQqIsFcVh?= =?utf-8?q?rYG0rnzdzT3G76qJw8ggALL71BnS6RGaT8VmIt0REzC1S4eNIxjzdqFlLholABksA?= =?utf-8?q?PBItGOGn12zwpwoMKB4RnzjtJKwWdHp6lUUo8Nqa0B3Nm1As84RgI2duarYObvIVY?= =?utf-8?q?gk54LpdVbQ+fQowRsDm+hAxw881aIk0P8h2fC1zJrs9QKMBqtBAJBst67lkJxXm+L?= =?utf-8?q?vKb4BPUTz+63QF4Lis2G7WwVmVqEAArHjxaIDFom4Ac1sf7i+AC66qGiHCHs7GHUM?= =?utf-8?q?4aQ/TCTmxbA1IP0wrnzCm7DSe4mOq5OyhmHVegbtqye9uMOpaRcXNc0OTaSLVkjHs?= =?utf-8?q?RMM/ASwJanN3NkxlyTzrUiAI+tBjgRWWb5u3LLHKiGYertkK33foDtTaN9DT+XyOd?= =?utf-8?q?xpK74B/ruw3fLZCiIviU10UMYhlph/BbwbVmP4/eJILJUqZXzfyzl9m90gWtVB0g6?= =?utf-8?q?XBinMLsxc9uvWeSvC4qn7AA3kR/pcgx1meohVy9WObbq0XxORc3aOzR/IywkqIxyx?= =?utf-8?q?sOeuPn9c6GGd?= 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:(13230031)(376005)(36860700004)(1800799015)(82310400017);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DucuI3X/3Amf4l/znaspGNIwabsmwGPpQ9CWNpEQQ7loXrCnNjFAD59+mUjKD7Q+9x2Vnm2ZAtuumLkQs9WnMXWe7lwab4IVyM66AQNm06Ejy/bhhhA3o+fAq4lepZe5pw/YYu/lrN7R8414XTuB3YE1EMnQpMyhBXrYAmB/kQgpv+oy4DAh3pNREUF0ftKB+KjJEwZ31WAqgXuyua3U1L2dS6OFnWi/meEhyiJOZ7pVCwAtpjx4uFk/J3hyNh6yUlg1Blw2jrhPr1W5rVFtK242fSJlso9cr2mDeHlKh22NpzZfTvGsyVGypEHi3ZEK37ueKMRXj8WDfkFgXdA7lPZ1MzCUTGyJgMbW8g8O7OUNeyakBvh/Yx+huYCCiTIqzziUXQXV0GjuwQY0YNr1hNYO0soiLqa0fE81Fh/uBg6U4Kn6NifvmSZafS7XRRiB0fKzOsil2ktnii7sI8/fzZGkwWEBp1Mpq03+DnfQCb2LuHH1LN7QMgN3I3hHti64vzvFh79eTuz3N0lVN2/VG0mAO00i1raH9xYD97Fl0vX9WtZq+FEwRCdQhZKbzYtpZCNa7Uey1wGFSzxauueEm4OlMQvr/0SIGAJDa80jM6J23i7Bs9MEsjCj60JTvPIUJAGsD+PrSomG+P4WpEeiBg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:04.5957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7720fc4-52b1-4beb-a642-08dc80094eeb 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: SN1PEPF0002529D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR19MB4635 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011322-102670-12914-11745-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.58.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYGFkBGBlAsMTHF0MDCItEw2d IiLc3c2MA42SQ11cjA2NLIzNTAKEWpNhYAnFFnxEAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan11-249.us-east-2a.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 is needed by fuse-over-io-uring to wake up the waiting application thread on the core it was submitted from. Avoiding core switching is actually a major factor for fuse performance improvements of fuse-over-io-uring. Signed-off-by: Bernd Schubert Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Andrei Vagin Reviewed-by: Josef Bacik --- kernel/sched/wait.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index 51e38f5f4701..6576a1ef5d43 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c @@ -132,6 +132,7 @@ void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode { __wake_up_common_lock(wq_head, mode, 1, WF_CURRENT_CPU, key); } +EXPORT_SYMBOL(__wake_up_on_current_cpu); /* * Same as __wake_up but called with the spinlock in wait_queue_head_t held. From patchwork Wed May 29 18:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679446 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 2062B42045 for ; Wed, 29 May 2024 19:36:21 +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=1717011383; cv=fail; b=fw3iM+WwQ/xivGJ2mGe03hFgfVPsZYPHgWQE0eRJX3h27hFMRlaUwa+diuS4mSDz22nJ5VaxzZ4Yw1ayK8UAChtzvaeb+t5VcBEnvaya6iH1naxCED9zIrecfI/pVkuE5VgPipLeQvmoX/rpKI2SHCcojL6KqXeofR7cp9Rw8OU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011383; c=relaxed/simple; bh=kEi5pklCQr9uYBS4gqJHBv3XOFdiEeSBKRiSPtW205M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=u15cZmmtg431dsZzRJTGCKXrCmL+dgM3pk5riWBYILB7QtL7Fcx8+i5icMsWFGHpJzWu2iFotBVx4llrBDn9JbJoipj1at4NzMTjr+wNVIpR65njjZ3cFboqMVK3ZsTRqAA516LwuFIpdMEcvoOkoJyoKFuzIDtxUm/3ATxWx9g= 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=HoeWFEc3; 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="HoeWFEc3" Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by mx-outbound42-38.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:36:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H6KM0mWhS0SUKg2BCxpKkU8K8md6dOw8/O3nqI2VZwkUKfkyHq+Ty3X7sULEFagDOYBY/HnUGH2Wysdy2kHYJc/ZvEHmECZ03dHOGffj7S/UjQTeOuwQ1jCxiQ82PTcPuD/CmIHNupdYulMD8dC2TO9XM5X7BkBttH0Pm+2e1KanGcWFD1F24+Ng6QmhFDTBJnWfLNlPy8lrOrCYZ3qQXBR4XegPEKefUd8dL5uBqtt4z9NhdGTqZthNCkdXAVN5OzylgDFJO0q38IsjRR2gUniC7NiuFMU1NtjRsWYHtmjrxUiMZtmRq2FrSX/mKBATyZQcLJN4ihufp943x/huZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lM/c7rWS/iOwcfGkdVctZy+ojT3bQHmnD2IdcozDka4=; b=OTU1FE3bW9HOR5m9xoGcL/2UNx23cYKXg7SMvtfcHtdjivq99mFMmlz8ikmqFVC3rpKahjhWdioGhLH996ZQiogwZbFGQz4RXFBB9BvX6DDSZGSB0Qetsbp62bs93ZjlnzqscwuYb5M4RXSJkuOmZNYkA6EPDmT/Hvc4RoH1XxuneZq17AEWnB1PrOOX4EwELmCeMDfgqsrsIVDfqtzmeZgYv0vBDOqxRtG42j/7BJoyBZuNbFNthw2ANlR+AdwyXHmbVjJZBMlfBWYBIbo6cqI+jCi7MWtTY0mhhH99evJc/dQ3XJsjuXsNCgp8pxp9yxl3FQKBq7iqNPCm5p0YsQ== 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=lM/c7rWS/iOwcfGkdVctZy+ojT3bQHmnD2IdcozDka4=; b=HoeWFEc3r4rawdX5+IIA6xKvSNBhYvN2V7I8FlpO6N5Z6uHfq6bDKRmngo7p15VXzIlRwJb86clknyUj7suipuT3V/hYZHTFn6qZauieTx/3KlNLTQgl0I6rSaS0oV39L/POQb6EykstkrCHEQgL2APip6jiUpDdKwcscOdPkbE= Received: from BYAPR07CA0060.namprd07.prod.outlook.com (2603:10b6:a03:60::37) by MW4PR19MB5518.namprd19.prod.outlook.com (2603:10b6:303:185::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 18:01:06 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::1f) by BYAPR07CA0060.outlook.office365.com (2603:10b6:a03:60::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:01: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 SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:05 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id CCCAA27; Wed, 29 May 2024 18:01:04 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:51 +0200 Subject: [PATCH RFC v2 16/19] fuse: {uring} Wake requests on the the current cpu Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-16-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=894; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=kEi5pklCQr9uYBS4gqJHBv3XOFdiEeSBKRiSPtW205M=; b=MWkX7ZsgkHjk4f6mUaeq3J8bhjt0LmS61Xbq+nrxT+b7gvyqRV2o27rHC+6R+Xdu6cQtehfdI C3BdBPBXT72DGEFOyl3JLkS/rmFJbZSYQjQtAECoHCd3/iY8QfZcE2w X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002310:EE_|MW4PR19MB5518:EE_ X-MS-Office365-Filtering-Correlation-Id: fe7a61fe-8441-4e31-c7e1-08dc80094f87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hJ3ypMvcdl3AUr2KYCoDsmuGhJ2ZD3B?= =?utf-8?q?a0Dk6QJASC/a9RdO4o2a2+HI+b4EUbJ+oGGdrFhsv1Yd9wpu8j+LqpDLG7ldlMgIE?= =?utf-8?q?zXuwdCNujlguoLer/pQVGA+wX3Ck8FpZVzlXzBjfB4NqlSRiacVX8ACCgNzh2vO1s?= =?utf-8?q?lil6PK+340BRQr0r/hvntRcVcS1rqzmeYsV1G57TNIq3iCHuXm7V3JCCmyAv+pHwl?= =?utf-8?q?6xng3G6pR9Y7NSPau/9wL+bhzFZdUJxsMKhBZhtC0uxTcEzV0ey6BBRohW0MA1L2v?= =?utf-8?q?iZC32QXLAZA7iCdEHpLwVDE2wjSdoY/GR0sJmvL2D8czQn4ZhBWPsPQ4CPlQQmm12?= =?utf-8?q?xd6H/R5L5P8ajQ6tOpP8JEFCOhRralumVTIane6IjkiH0MwSOclR1irUNCSb6MfU7?= =?utf-8?q?IS0XZ4WMviPjCiDusm1/ST2scq9rpYbGlzFZv0KCM9Y90C4DdhXYcMfFKl1djG6Nf?= =?utf-8?q?A/uerCQfkcktdftzoitAksYCTKRD1LVVY33Iouj1jg/5TZkm3XVhxxkN6cjjC6xM1?= =?utf-8?q?Rs6JKWjPgREItcNZHEwVqhgyDt1Kd3CESTo9MfvIkCUh8oxRlzOV0Gwfq8MLzK9Ub?= =?utf-8?q?jL1wW6WMlSRdyYFiJWrLPdloZE8W/ltfhaBXAcJZpbvXmjIbiaEbu6uTeZOB4550q?= =?utf-8?q?OQbLFgnX82oyucPmH1yKy2uDFZuB7Oz24xcjmHlu1krbyRU5FS5WhO4fjMjVJXkPl?= =?utf-8?q?MhvC1pyaaOAqNX55KtkQA4p0DWXhuiBuKbrXy0lkwZQVHAa9ux9yim3NH3fGuf8ud?= =?utf-8?q?+Vwmc2oy1tDqPvXVOTftY2eeRENu3z8dlrdpX8DbRCNZrtMvdIzRgZLSzaETq7iyk?= =?utf-8?q?ZhjUsTO+Ezh5wkvM8H07b6lFK5528ZOJrQRid1PsnY0BCTYb4NzuYHOLUwqEelVJE?= =?utf-8?q?H7nFdH0rrcFsM4bTYm/QgDxQFP+B9uMMsBNgMy5w5otZdkEGc8pcpN1Qd7o6PWlYC?= =?utf-8?q?sXolpbw9rLdKPSfdtCL2bKCCxtb1MeqV6c2yjgvOp2lZ/yaTH+ebg6/SdRl687l9q?= =?utf-8?q?eGWSBansTbLk4jaB+DqDc7bRGHDEtqIPPvwpI2SZcYq9eOlDIkjwm+tyYzBeURoyp?= =?utf-8?q?rNTMrb5YmMH3GxZQB9M0czlPK4iOTjbl8JuBIDSJQKKWu0uTOp/JDxS1gS092+OF8?= =?utf-8?q?GimeC3WHUVCV2iwf7lA8lOs9xjo+6PuCpiYMoRTzv1z/sNQ1XxEEZNwiOd/3JSYqx?= =?utf-8?q?Rih5XQ8wNxdIq67sTffZCbkBUXed8ZB/ptdvsiuAfVeXHpZZ2RLugBgkYvsjZwGMR?= =?utf-8?q?f1ECOtEl1nYYeUOFHg6S1RwGuvPF8L8TaPXMs/VW0KnETi/wzDe6YvAFTu2aDEKBp?= =?utf-8?q?DLp4KkOtBh8Y?= 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:(13230031)(36860700004)(376005)(82310400017)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Jh7Q4lurF/y8CnSy6QF1EhPqt+0vnUrqmZhxEm2yAZAGTu83r+DDuOUTmKlMlZW8dV4IfgNvMGyNsd1g/MRR8NOdRsoD7SIWAYu95AlCIcM4GKwaedFpOh3gkR6uUUjWb85kRfk1EAISDQbfrs3ZHO7v0Tn3uS25cvmYbYIETw7GezHyeBaixH9sc5sIbTHZyEPEdlhewoIzZv867nAZ/Vv6VZ/IV3P5Pw4oIpVy70DQ3Y2CDgu77UCIH3YSlA0Ly7Bl3+fDE8cWCSGn+KPXnmPR1+mbWNncS/mPnd8sZu12HR9X9XFieb8x9Ex6MNgzFun1MbrdTuvNCGBVs5Izy0DRfTcnBpSLjidaC1Bu7wcx+Y8aWeI0tlXxBX9bh2mpRdb4EgOFubxvK18TKNLijbT5njl9Io4MzvmwBvBwC620VW8OKANH74Eqjg+hDnllYNE6aQT/0bajQ/cJeVEO6xn7iiF1AaaAnBU7kMJmjBtOij8Ft0RGP+sEDwyDAq15J06zOhVJY4oljH0jL9Edis0M/p42xD7LZBKvaixY+COFDBBTcg4S4CRAHgCqt89b2j0Da424tWkqy6WHl0vJgToQ4JW5mv8DM5+JYPFrxX7I8HKVcT5zl3DXUM13qj8SUtRcK5EoRToo2FPRaUZ65Q== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:05.6189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe7a61fe-8441-4e31-c7e1-08dc80094f87 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: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR19MB5518 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011380-110790-12649-56438-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.73.41 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhZmpkBGBlDM3MQ4yTQ10cjSzC QxJTnZIMnMzMLQwMIixdA80dTCNE2pNhYAuUahtkAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan23-122.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 Most of the performance improvements with fuse-over-io-uring for synchronous requests is the possibility to run processing on the submitting cpu core and to also wake the submitting process on the same core - switching between cpu cores. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index c7fd3849a105..851c5fa99946 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -333,7 +333,10 @@ void fuse_request_end(struct fuse_req *req) spin_unlock(&fc->bg_lock); } else { /* Wake up waiter sleeping in request_wait_answer() */ - wake_up(&req->waitq); + if (fuse_per_core_queue(fc)) + __wake_up_on_current_cpu(&req->waitq, TASK_NORMAL, NULL); + else + wake_up(&req->waitq); } if (test_bit(FR_ASYNC, &req->flags)) From patchwork Wed May 29 18:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679414 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 389341C0DD0 for ; Wed, 29 May 2024 18:34:32 +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=1717007674; cv=fail; b=W0sUntyL/Wdm/DkCJlYTr4uZQd/juBmp5eM2XiiiCPap+9MBqz0GEyM276CBIlORixGR1zCngdLYVKLwNPjrmuY2htweIrKu8r2Ta74sN2U+1MnPxS0kKXsd1/zhqTs/koUQxwCixpyjk+A3/SoisypVD+q6lBV/CmFjGI37Ls4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007674; c=relaxed/simple; bh=peuavuWDg6/F1rstWppmqi4fhIXHPXqJjVSujb8rG0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=urJALOCxT2qDZA1bHYAgldljned5W5Kk9+FbA3JeWYIvOr5Uyvqic2WJ1rz9TFaiMD2pfj/ffNzGg4kk567fBohiQe5uO4AAO9xgZRtLHvJvRjed33P7/Fs32O2XMI8wslVCoSBhsHLueuR3E7XF11aMRB4dH3zpNTYPiqrsvqw= 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=mWbKT+HW; 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="mWbKT+HW" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by mx-outbound17-84.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:34:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lrjz+/OL6RZFm02vOdzOcgE27Z2oqxUqAxfxnnfxLQ44auAfLIVzsstWBocMA3Mmcaf0Bg1nizAU9t8ipOnheqcKWTJx0MTLh1ch5iTfnvHA2eo457zAhip9X5yMFxJUxDe964/vZaxr0smT8FDTI2DKB57UXp3ucIxlPsgBWvLAwN2+nFMDV8diZf9H6UJVz5Zoz7BznTzENXJ+suxTYHpDLkYS5rL67NiO6rKH7v0F/w8iBxewliX9CKgPRdq5l2Z7zm5Sj52qLnXjRTAuB21SiUtmncYG3sLckSIpf5utRsd9ToIwLnRMpFJ+0pbUbuKN4AivqAZYnG6XMJcuGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=MwaQa/OaVGNrDMOeRXemJgYoo0zuNyAJRQoBYiIlNew=; b=HogLoWLyALaCirTe53okbi8iAQ3p7dpjOyrHUH7tEdkL5mPdOgD3Txyv7pjwyXrIZvXNlLnW7Smsj6e0jtnRRnXVCxTA+Hw+z8rax+TDqdddCHJcQO9zX4I9OH0sMDjRERh0uFs+f490hcjkNxG8pun6w2SRooB1lfzW6N64wnrtD5zFwYlmZY2PcEsm7YeDljdZEMczTIGLWzqREj0soAgw2XvIXTepNN/m3InqzUIkGS3iZ9VECjbY1vgNoCc3Q/fXkuzMecBe0urOjIqZd0v3z5K7bDLccKVmICojuGslYjitTRTvQzhe58xUL5z2WIR/IsA7FXRJfIoYsPS8Dw== 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=MwaQa/OaVGNrDMOeRXemJgYoo0zuNyAJRQoBYiIlNew=; b=mWbKT+HWvFY1BjLwk8rwhxlsrpj/m4Wc4/TPUCLVfwox6YIYBjZDIOq4qdMFHp2s9MZpV0+dMIkvMhhvMMiAyvsUYPYgZyEnZ1hzILeCaT3i0Fi/ImYjdWNcshigLQhmVqkVeyXzjcv18JzTOtxVC6Kbr3Z3en2bs4qr9lsIjaw= Received: from PH0P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:d3::28) by SJ0PR19MB6897.namprd19.prod.outlook.com (2603:10b6:a03:4ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 18:01:06 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:510:d3:cafe::10) by PH0P220CA0014.outlook.office365.com (2603:10b6:510:d3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.18 via Frontend Transport; Wed, 29 May 2024 18:01: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 CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:06 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id C567D25; Wed, 29 May 2024 18:01:05 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:52 +0200 Subject: [PATCH RFC v2 17/19] fuse: {uring} Send async requests to qid of core + 1 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-17-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=2986; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=peuavuWDg6/F1rstWppmqi4fhIXHPXqJjVSujb8rG0Y=; b=XMo/A9mQJ6prhSRwSBesFLe3o7FtCAyEIdt2xK39m4n0AwdD9YikFmD3U93swj8z/GeE4imxp n8UeWOb8025CjWxosHS5eCauK8n4rXtq4NN9BNvxZPCAZF7JejzIUVB X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|SJ0PR19MB6897:EE_ X-MS-Office365-Filtering-Correlation-Id: c7ca7a9f-24b7-4df4-98b0-08dc80094fe2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nRPundpLfYLzhRLXvj1dZhXXKDfMxqK?= =?utf-8?q?xiDzSj/U9fcaBg5bXjXmHPee5f30codPMaGrEzPZY8/rl8gT8q1uaYv8S8+3U1TP8?= =?utf-8?q?eWbxqWaofF9pn7nN9lBzrikbfgJRuXVctBikwNfPeqdr2sZ8n+49SG6LiBHzhEl0w?= =?utf-8?q?IZnTmkOur4v5yaRMCQkFsn9rrHRoADeuH7R+oXDfZjEPrsadDckfRuG/79c/nv7up?= =?utf-8?q?uwfmnqrd9VyLhiEF9bowobVQrZoBYFCCSAOm3GiDW0SqRcZixpcGDC3lMzvA1AcBI?= =?utf-8?q?yPeA45kL54lReL+CqRpG/DKHPHkx7UIbHQpKsri0weTa82d81i+8uOKoZMnxxTWzX?= =?utf-8?q?YG1kqm62rMQdrRTnCWzBezejCYB4YWNoJOQOS0nCF2pueyrHb2Vb78KiiOFn9gizw?= =?utf-8?q?cvJuReC6FdTUcm2M9PxXfm8Uhoz3tTNKwHdwf31KTRGXra0IDCk9gsURVCY0I8+7u?= =?utf-8?q?yw9egxdNHahVvoJPU7LvcztQ2Q8TqU8B697k4v4q3PbN4BfbnDpZuJfhSMsW3lsKp?= =?utf-8?q?9YYIEYCwMU6dGrRHhTEkfa2HDHDCFqSC+pRrgLF2L/+bxOuPXIhKPOq6QrXOsE7GS?= =?utf-8?q?6+wflRgD0CilOaOVD3DKgR3KZvDalWqDQCYrMXbt9smM4k3TmeaoR6iX2i1zHaVrx?= =?utf-8?q?76cWsFWYoNv7Eii3pXEMpRUKRrBD/bkCA0MCoLn5dESvALdEEbCPYeejh3wcxbVB/?= =?utf-8?q?0tnZgQcjvYREn5m1dCjiBLI2ByXElMNiYVwHEiiVFtCeHhIfY3HGS9KPA5/3mft3p?= =?utf-8?q?9bUgqDeJqAS1RROxT3B0kRYgIhGzZSuo+uez6layEl/Nxx7+N9GC+qya56ZyG/8Q2?= =?utf-8?q?iLzseiA4DXkY6YjE8S1NRIJkkNUs30PAZ8Cubr7kFg4fBIsr/2q8vMLMLW/Ajh19+?= =?utf-8?q?H6jMTI9Ds3P3zQJ4209wioCr4/UFfeCRlQ90ytGtX71qYkt3Ss2P95SiO47XFRR5U?= =?utf-8?q?I4BQ1goYuyDTLFYKBTFvCnIQRAhh76ptEyI39cEy/rb1oBwM//Yry7gdYVVyG4ohG?= =?utf-8?q?kh0r/jQ2CEhONa9a8Vc6VlWpWC1tGug08GTrztt44tCYdjRbGnEw8xaM9t9HS4p2y?= =?utf-8?q?1uAcslyX+ZdihamxbgEs60FJkhUox73F81XK8byZQ9H0TZ826nw6XG5cFpdNsHT06?= =?utf-8?q?Y0W7eilYcu4rEK3VZwBsSiAXKxJDp5U7uzAzdeDDClUyeVxrc3b09jay3g+m1dJyS?= =?utf-8?q?dvYNfFqRu93Ayuv8THX8OjVvX42HJL5LhosTAsW056x/HjFUYtlreDGFLH4apj+Z/?= =?utf-8?q?tybyOrwXw1z6+uPUzjJtOrNeZgopCX09nXJJ52Qx9tol/OsObIvddW8FrwP04NeKM?= =?utf-8?q?byPizx9bajAH?= 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:(13230031)(36860700004)(376005)(82310400017)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UCwf7lZhZDBBmU4cuhW9KXB95dgc+34/l4bE6YA4Zu0QXI2CW8IS/4d+lT+Q90S5aCmMGDOh1f1dToDHcQQiHyGqI2+r1evArMF81EsyH9wosudVKcs4rLqblIQR5o1Dxk4iAwEqQ9pr0lVBZQPV8+6JS1hKsA9hyv4FEsU5K7YUJXqLRRGtDq/vmcArAYZpHHhLkvMnB5ewzfwx8VzNalMAma8uGHqeUuInLPicJFhMvCOgUsvttCnf8MrG3n4PqvPz8KJYSOta+K9ks88gzBL3/foIvx5VREZXSJzA+Hy97T7uhEAMTUIK8KcVjSYwUl/g4cXe5UpK1p4bmDUZsV7L3zHstToChqwetRtL8EDVLbqg/vAZfClE/GC7o+iyup1bdg4U4brTM+qYJz+KOyQUW5Lrcp99i/CtoNO0jnM9GxJPzIACUcHJkIZyBqQRbD5BFSq2JEiSxQqvqUDLSvoqq3bkCazgvPh6GQ5qjLFldZu+Z64QShYcxTIcx3VLPlgeUu1O2NE5wU8YMkMlezq+WATgAbqFou47fJW1LIjRHCz/1/1w2g3KluxaAa+jl9LzzTZgmtrATbr+2MXd9BQEkSGISUDnsmpujJGFOh6Mal4x74+xGKbfsKvhC3LbzLH+Mj4EhA8JtKyh2viU2w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:06.2610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7ca7a9f-24b7-4df4-98b0-08dc80094fe2 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: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR19MB6897 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007671-104436-4473-1004-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.70.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkaWBuZAVgZQ0NTUJM0oLcXEzC Il1cIw0czAKNnA0DzFxMTUyDAtOclcqTYWAH6DsiBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan18-74.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 is another performance optimization - async requests are better served on another core. Async blocking requests are marked as such and treated as sync requests. Example with mmap read fio --size=1G --numjobs=32 --ioengine=mmap --output-format=normal,terse\ --directory=/scratch/dest/ --rw=read --bs=4K --group_reporting \ job-file.fio jobs /dev/fuse uring gain uring gain gain (core+1) (to dev) (to dev) (uring same-core) 1 124.61 306.59 2.46 255.51 2.05 0.83 2 248.83 580.00 2.33 563.00 2.26 0.97 4 611.47 1049.65 1.72 998.57 1.63 0.95 8 1499.95 1848.42 1.23 1990.64 1.33 1.08 16 2206.30 2890.24 1.31 3439.13 1.56 1.19 24 2545.68 2704.87 1.06 4527.63 1.78 1.67 32 2233.52 2574.37 1.15 5263.09 2.36 2.04 Interesting here is that the max gain comes with more core usage, I had actually expected the other way around. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 5 ++++- fs/fuse/file.c | 1 + fs/fuse/fuse_i.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index fe80e66150c3..dff210658172 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -1106,6 +1106,8 @@ int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) struct list_head *req_queue, *ent_queue; if (ring->per_core_queue) { + int cpu_off; + /* * async requests are best handled on another core, the current * core can do application/page handling, while the async request @@ -1118,7 +1120,8 @@ int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) * It should also not persistently switch between cores - makes * it hard for the scheduler. */ - qid = task_cpu(current); + cpu_off = async ? 1 : 0; + qid = (task_cpu(current) + cpu_off) % ring->nr_queues; if (unlikely(qid >= ring->nr_queues)) { WARN_ONCE(1, diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b57ce4157640..6fda1e7bd7f4 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -791,6 +791,7 @@ static ssize_t fuse_async_req_send(struct fuse_mount *fm, ia->ap.args.end = fuse_aio_complete_req; ia->ap.args.may_block = io->should_dirty; + ia->ap.args.async_blocking = io->blocking; err = fuse_simple_background(fm, &ia->ap.args, GFP_KERNEL); if (err) fuse_aio_complete_req(fm, &ia->ap.args, err); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index fadc51a22bb9..7dcf0472df67 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -309,6 +309,7 @@ struct fuse_args { bool may_block:1; bool is_ext:1; bool is_pinned:1; + bool async_blocking : 1; struct fuse_in_arg in_args[3]; struct fuse_arg out_args[2]; void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error); From patchwork Wed May 29 18:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679409 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 E3BEE181CE2 for ; Wed, 29 May 2024 18:33:51 +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=1717007633; cv=fail; b=JZkse7e9ozbYn02HALUjZy+B9T/fE1Qd8uf9MDbsWw1E/6uqTMEAWyCnMWteVthywG7dys2kjjSZT5e2Q0/90pummf7v1o+gcC3W8lmOfm/mqOot4maIUPpumNCSXzKVT4wpc6St7GQ5Rv0Pe13rhAxTxYL1qjtfk/esOyENdd0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717007633; c=relaxed/simple; bh=UiR/dNZ7dNJHF37AOJKOZ37hrNUD3UcUslqH4BM6T3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=U8XZZfIo+hDj0GLmffcWO2ZGY+wvWcTkuThCt1EHhqM5WXudeOnWZXPVAWEZZSTTzmuvVlqnckD0pDZb40OchKwAEdcLtshaEIYcv5/K7De7/fRDucwQTiC6NSOPtYb4Ph1gTF2dTq4WuKNk4KlBEWOTh80SE5UGYlQ7QKjMDNk= 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=nwYjA5cZ; 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="nwYjA5cZ" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by mx-outbound41-156.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:33:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IY+ucr4HPA/PVnQQTVDsJsZlpZT/s3Q8CY75ICGFjpkNiWQg+k/ITDfoRBUVyRPKpS1EVJxveOOUsANw0O4WN8aa3TzJM6uyiLV5pkwfofPPXW0oHfHR9dQ0snw3x8Aeag/q/RmudGs1AIcT43YydnMymtTQE/VUM6tTtqiMBFUngP9yp7Qo/TK+V3EDK1Agaem0IsNi9Elr86AbtXy0VEmHaDy+I4N1tAl23yas47WGqTP7UhgU0iwUqJYkYTBvwdwmQR09J2IqNRHTTeAf+s1sRxSynr70Di/Cmsv0ScoM/0tO9W9bs0qrTqFoYZ2sLRw/8zAgV4rbTXnMQ1N3aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Vr/NW9/YhGdBIcMKJqXrTkdg0mxjcMZw+2iyxtlJgSk=; b=lkAB4O8wxrd0irYPkxg5wufWGIa+unBXA9NEm55Ayvi675T7SKb+lWX5h3T97Wn5xwfClScLNvG75fUeZiFW11ruyyvbO0q9w5fGRGTIDzvcyTp5L/sAZrxBDIsJ1DawiTBHiZbytuih3Eg2Fw+q8fdP2x2IDOJ6k2JtoqzFIpkqehhZM+C5Fl7N6n0AlPONcldEVcggRUpKgMNl3/oJB47Et3m0IeXW1fvunjuvY4sSjQqyJ+JcrnQhY9SblS1whzPNILYQCNPZwLLOvtSwEjXNLW6DiyK08SU8FVeb5SMD7k6LHSHRnXTaCJ+OXhCmqeugP/KtmBMpNIc4klSawA== 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=Vr/NW9/YhGdBIcMKJqXrTkdg0mxjcMZw+2iyxtlJgSk=; b=nwYjA5cZwQjpAR+VJrgMS+wbckSCBPgxe6pD28NzszCrIDAIQkQ5BWquQNjkh7RPGKSrp3h1TjPhrCuOUeJxZctl+m4b+icU7pKqMKk+t7kCyY4NS2s+lSlNGITNcxjMrXsUtR7KJEod+hFHOxJdRKaxwlXtNV+8Od/XfwX4d1M= Received: from BYAPR03CA0025.namprd03.prod.outlook.com (2603:10b6:a02:a8::38) by IA1PR19MB6348.namprd19.prod.outlook.com (2603:10b6:208:3e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 29 May 2024 18:01:08 +0000 Received: from SJ1PEPF00002314.namprd03.prod.outlook.com (2603:10b6:a02:a8:cafe::ce) by BYAPR03CA0025.outlook.office365.com (2603:10b6:a02:a8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19 via Frontend Transport; Wed, 29 May 2024 18:01: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 SJ1PEPF00002314.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:07 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id BD54927; Wed, 29 May 2024 18:01:06 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:53 +0200 Subject: [PATCH RFC v2 18/19] fuse: {uring} Set a min cpu offset io-size for reads/writes Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-18-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=5938; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=UiR/dNZ7dNJHF37AOJKOZ37hrNUD3UcUslqH4BM6T3s=; b=jwH1NNkTB9pgVCT+hqR5xt8DCT3lIlxqLWvGXzIiX9QJ0pUcnW/141MPj6iTve56legg9KqjK TicFkZX8PwfCu9N+qYLyUVQBqnukk749rGmCUuGLc87fi5ttk9cyR9y X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002314:EE_|IA1PR19MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: a40eaefa-da25-4f7e-9d59-08dc800950ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ASqggR2SNDQsGtmCJo2ej9OHyuwUAtw?= =?utf-8?q?CMoUY6ncDpstl0Gm9kWjzMHnyjZN4kfD/Jcgfbpe5w+g0a7N2+d3T/e7H6ItxT+9u?= =?utf-8?q?ZLWhDsrY1xPBEiOVI82wlr0pwhHxSk1saOdzRq3zDWi5o4YgZViwdTsJH36vModr8?= =?utf-8?q?2JCXjEo7v827otHnUjWBZa27E38Bn09LEWu4TCYi0VXM/tAT4QhvJnlEuRU7Ruh6O?= =?utf-8?q?N6rSy3CUMrKj5W/9ihr6nyAFrxTAyg8RI+rC1nIz1ozrNJNz84i6jFQjrkGizCmZu?= =?utf-8?q?BaNghP2hgx2zEMuWtEXoIqn4/jM+uYT/jY8WHc0yjLNEA94PDxN56MAe8waou8UCR?= =?utf-8?q?bz+3gSVOd5YZ6feIo2dyhYtMF6iPy+Q/eI18zfiX34F46wpgu9grjhSWVt85b/O2c?= =?utf-8?q?6Is1oc/FSbjYyg8extTWHYKOnJKEdSkbBw96soBdQ20P12qu/ny3OIzx9W87pUPvz?= =?utf-8?q?G04/iET8VN/FvYKOzM3Yxa2KmoUpjucUTPvNiQTcYHjXFQDhAOv5f4tuvVKmWACfu?= =?utf-8?q?vKfjHJogKMJWQ+1hC8bG1sqWUSef8+Xnuwb5j3feI7MGCBfYf8M2aa26TF6EEC+OQ?= =?utf-8?q?yive4fflrlFo1YYBFRN1yfW68Ib76zCQtDER6nyZCa4ZzDknko5P7eogowgA/SyUN?= =?utf-8?q?cKRd0ccnMdiIrcmNrOeutUAMOqWJNvJfWoz5F223VkMGjS/MTuwAdsEvhbsl3iJ+c?= =?utf-8?q?YrDdWXkdg9a1+V2elxGEQAtH4zsGrzjdGr9zINaQ/pQUQ6UuJvPVoeb4DPgEh39tX?= =?utf-8?q?zuGLpgo8j4wEiSBhBhtcRFLwg0xdi1dybN3Bl0MzlLmOMIu5SmdM6jfvz448nW4Lq?= =?utf-8?q?P7PFkmW53ufuIgGpV/fzEgXC3jwQMaJxyxPbNzO0lsPSgchiNacjYWav70t7kbDrZ?= =?utf-8?q?jpU5A86ps0qHzu2m2BEWBr9PjNG/sRP9FFxcwauLlf3YqPikbj5P+FbXEIpnAoozg?= =?utf-8?q?6U8x55dDUHQpWW48LOXBMPr0hqNsTquGXu7PSDxYSBQmp2hkFaS+uDHLfONR/MxNw?= =?utf-8?q?0AIhUAYo36APnfdKgQq8BsxsSuNMuel4bSldYCFhm5z18OOakBewtynDDSbdJtSd0?= =?utf-8?q?Ly8rbvPLftH+pwA9ceJScykmLuqe627Y4iGezCkQkU4FyiW1liTOlaygB29n6uD8x?= =?utf-8?q?lNkf2J5x484qaDsd8+aY0GVTNn1r9EqxTyvqtUWc9lhIp0YTtGyY8qGHGQd+VD1QH?= =?utf-8?q?Qu+3RQ2kCiHd2POEPAEWHAFwc6mEJd4shJv7JJhVgCxs+mllxoAtrmIMSI6IxSov1?= =?utf-8?q?DjHSEGJs8yxTmKkeMrgW/5P5cK35j+xhD0WGW0ZN2NGPnSWFioBwI3wA=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:(13230031)(36860700004)(376005)(82310400017)(1800799015);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AZiis/IZ7zm9bNLJt0Y+FCVRFNK2aWOY+mqfavrrfQZW3Vfhn4dI/7DaRR+i/1bKXhmFY9A1Qu1sunvo/A+qICdD8defzA2aq6v/NJKAtGcdgKPjJ/kGajOt8HC7gCvRQR9Td5cy00K5wHAnCVFzyw3X3J1mgPfzvpdvy61PUBiJWONvuoS0s2wxwZww4YBU7Txv5tLYJU08JqEpFjYc6O6g1Spmn/GXp+LZHacWExZWeFVfSrCvbK/H7Co2+mJxxIw3a8vQU9XPUC3HwTma41Liu30mIFKK9VrNk/er3VzuM38pNFflBUFf/HqWB4rn2Vb0+wMpVQtuZS8bYCGVBvRt5jKVytfOHYuBdcke+n6RQDhggJfOj4cka76ZtM5mEyXt93TK0CsCCzOfMZ8VE7hafN5miNvJ7U6lBArZMF3MLd+8kz1UQH231pILniyyUBtGTCeFbQ7/ph40uIBXtJ9WWVBL42HfRVM7mwela4MfIoqsF8qpryIdqcLWPLLQ4GsClbFZMu55xyv5RKl4o9ZwfS/EpYouNhjZLsJc1BDb9zGdzVFOIU6Mz/PMKi+/QBNnI16FWZlcvPqSm/1L66455XzHx6cbG0yxWVmx57swlkoOePzZKyDhvzAynCmZVdbb54JSS2/NGLCtWyJW7A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:07.4574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a40eaefa-da25-4f7e-9d59-08dc800950ae 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: SJ1PEPF00002314.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6348 X-OriginatorOrg: ddn.com X-BESS-ID: 1717007630-110652-12823-23279-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.59.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqbmpqZAVgZQ0MzQKDnFzDDVyN zM1DzJ2Mw8zdwgLS0x2SQpxcQ4JdVUqTYWAOD2TRlBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan13-24.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 This is another optimization - async switches between cores (as of now uses core + 1) to send IO, but using another core also means overhead - set a minimal IO size for that. Signed-off-by: Bernd Schubert --- I didn't annotate exact benchmark data, but can extract it (but needs verification) jobs /dev/fuse uring uring uring (same core) (core + 1) (conditional core + 1) 1 127598 313944 261641 330445 2 254806 593925 576516 551392 4 626144 1074837 1022533 1065389 8 1535953 1892787 2038420 2087627 16 2259253 2959607 3521665 3602580 24 2606776 2769790 4636297 4670717 32 2287126 2636150 5389404 5763385 I.e. this is mostly to compensate for slight degradation with core + 1 for small requests with few cores. --- fs/fuse/dev_uring.c | 69 +++++++++++++++++++++++++++++++++++++-------------- fs/fuse/dev_uring_i.h | 7 ++++++ fs/fuse/file.c | 14 ++++++++++- 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index dff210658172..cdc5836edb6e 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -1095,18 +1095,33 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) goto out; } -int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) +static int fuse_uring_get_req_qid(struct fuse_req *req, struct fuse_ring *ring, + bool async) { - 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; + int cpu_off = 0; + size_t req_size = 0; + int qid; - if (ring->per_core_queue) { - int cpu_off; + if (!ring->per_core_queue) + return 0; + + /* + * async has on a different core (see below) introduces context + * switching - should be avoided for small requests + */ + if (async) { + switch (req->args->opcode) { + case FUSE_READ: + req_size = req->args->out_args[0].size; + break; + case FUSE_WRITE: + req_size = req->args->in_args[1].size; + break; + default: + /* anything else, <= 4K */ + req_size = 0; + break; + } /* * async requests are best handled on another core, the current @@ -1120,17 +1135,33 @@ int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) * It should also not persistently switch between cores - makes * it hard for the scheduler. */ - cpu_off = async ? 1 : 0; - qid = (task_cpu(current) + cpu_off) % ring->nr_queues; - - if (unlikely(qid >= ring->nr_queues)) { - WARN_ONCE(1, - "Core number (%u) exceeds nr ueues (%zu)\n", - qid, ring->nr_queues); - qid = 0; - } + if (req_size > FUSE_URING_MIN_ASYNC_SIZE) + cpu_off = 1; } + qid = (task_cpu(current) + cpu_off) % ring->nr_queues; + + if (unlikely(qid >= ring->nr_queues)) { + WARN_ONCE(1, "Core number (%u) exceeds nr queues (%zu)\n", + qid, ring->nr_queues); + qid = 0; + } + + return qid; +} + +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; + struct fuse_ring_ent *ring_ent = NULL; + int res; + int async = test_bit(FR_BACKGROUND, &req->flags) && + !req->args->async_blocking; + struct list_head *ent_queue, *req_queue; + int qid; + + qid = fuse_uring_get_req_qid(req, ring, async); queue = fuse_uring_get_queue(ring, qid); req_queue = async ? &queue->async_fuse_req_queue : &queue->sync_fuse_req_queue; diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 5d7e1e6e7a82..0b201becdf5a 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -11,6 +11,13 @@ #include "linux/compiler_types.h" #include "linux/rbtree_types.h" +/** + * Minimal async size with uring communication. Async is handled on a different + * core and that has overhead, so the async queue is only used beginning + * with a certain size - XXX should this be a tunable parameter? + */ +#define FUSE_URING_MIN_ASYNC_SIZE (16384) + #if IS_ENABLED(CONFIG_FUSE_IO_URING) /* IORING_MAX_ENTRIES */ diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 6fda1e7bd7f4..4fc742bf0588 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -7,6 +7,7 @@ */ #include "fuse_i.h" +#include "dev_uring_i.h" #include #include @@ -955,11 +956,22 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) { struct fuse_file *ff = file->private_data; struct fuse_mount *fm = ff->fm; + struct fuse_conn *fc = fm->fc; struct fuse_args_pages *ap = &ia->ap; loff_t pos = page_offset(ap->pages[0]); size_t count = ap->num_pages << PAGE_SHIFT; ssize_t res; int err; + unsigned int async = fc->async_read; + + /* + * sync request stay longer on the same core - important with uring + * Check here and not only in dev_uring.c as we have control in + * fuse_simple_request if it should wake up on the same core, + * avoids application core switching + */ + if (async && fuse_uring_ready(fc) && count <= FUSE_URING_MIN_ASYNC_SIZE) + async = 0; ap->args.out_pages = true; ap->args.page_zeroing = true; @@ -974,7 +986,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) fuse_read_args_fill(ia, file, pos, count, FUSE_READ); ia->read.attr_ver = fuse_get_attr_version(fm->fc); - if (fm->fc->async_read) { + if (async) { ia->ff = fuse_file_get(ff); ap->args.end = fuse_readpages_end; err = fuse_simple_background(fm, &ap->args, GFP_KERNEL); From patchwork Wed May 29 18:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679442 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 4F8A11C2324 for ; Wed, 29 May 2024 19:34: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=1717011274; cv=fail; b=qBWlp+AjR0c13pUDmc+9zBhkPI7XRgM5oH9m6MI8Wfpry8+maMIbPfXMDH4gIND4M70rrQpLhPmmfAQaZSGS20ajwmvLnootZjiN16jRsU0XMitu9TxbDaJahJzsUvTMlNlmH9KKRvMAcHzXPLIMNancd/Cu4BT19DueadnkpuI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717011274; c=relaxed/simple; bh=6nLOPBYBmAXqnJ8sBNCyQIY8UbBZnkgg9dgN9vA65fk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TgnP22tbWewiOE/xTkD54caJKYlufrLfaT9mdz2eqayzadw0EaukJBNKcJuvk53xavoJFTvzcRKVGhSQctUeOePmJurjRo3OjbEbD75rtNHMVmbAbQzSsaCv0OCyV7CQjjnHlWcLcoBtTbTrtsjmKEYHhcf13fqCNlbk6GIf6GQ= 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=UVVZR5ri; 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="UVVZR5ri" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by mx-outbound19-81.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 19:34:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K2L0xrb0N3G4R3TPNovBtEq1HsLMckdd6tjjkOQp7KDtsxShQzhsFPOOvlEjJ4g5sPQTEXpSUYXjKD9+R519jNmY2Ch3uPFXihtPeP2q1mjb5l0VxqQuAckclsv7IRcRqSuXej1MgxzPg8COffiv1DBoCKuYsOBz5cPSyBpPzPX5h//Pi5aMAVW4/0HyKev406La7Mqp3nlrPbL0HNfyaFp2LH/TcPTmx/ZmuoOzKMkcL0dTu9zYNPbHbboRZuE7veBsD/XuV+htFwc6c378+ESsyvBUiAm537gTJ1gH+56mfLES4ppgKLJketVjS7lCPi5P7By/MVL+hGbeB0uwTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BVOW3lpBCXsE91W1B9cz5GiMA7CnbbQ2oNomuKCRLbE=; b=IdNgkF2Wl2b2AXO/fTOiki821pzDnq/2A8698SmjxiT1RaqSfxUbcTsC2svVdntrPvqd2usaJE9xSDiRob6d1u+j4k7NydVe2w/24xd6WTP4eF/ZD05OCiMrk+kmXwj2oAa7nXkjXMx/9gujoJufowuj/XHXOqiGQTLUAIhGolioCAwmgKXBr9fQITFf4b3gTYeZxRvWogv9jRQMR2zSn83Yt4kdRiX9fTLCSm66jtqf35Rd16W1MTeU3N2KscFWWq7r/BIUqWxx/rPLC2zXwtWkfVVaTv610EYMsIpMwMKSI9MR367edBlUYr97xeLTEjAi1TVb4AHK+f5Hgn520Q== 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=BVOW3lpBCXsE91W1B9cz5GiMA7CnbbQ2oNomuKCRLbE=; b=UVVZR5ridQBhWsgPp9Yy7Zq3ziyhaonhp2w8PL7gxgRxHCN/2rO6Qxr4NSgPAGQlCK4oz3g1xWnqaDQrM2fcSzEbnlraz1uH2mxy4TG4HAoyNua9uX1z9BWchRfG80plTNaWxFJy87VZlR6+MM6nwn/vN2GMcwe++nyOOSK3ifU= Received: from SJ0P220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::9) by PH7PR19MB6061.namprd19.prod.outlook.com (2603:10b6:510:1dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 29 May 2024 18:01:09 +0000 Received: from SJ1PEPF00002313.namprd03.prod.outlook.com (2603:10b6:a03:41b:cafe::17) by SJ0P220CA0004.outlook.office365.com (2603:10b6:a03:41b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 18:01: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 SJ1PEPF00002313.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:01:08 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id B5B0325; Wed, 29 May 2024 18:01:07 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:54 +0200 Subject: [PATCH RFC v2 19/19] fuse: {uring} Optimize async sends Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-19-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm Cc: io-uring@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=5240; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=6nLOPBYBmAXqnJ8sBNCyQIY8UbBZnkgg9dgN9vA65fk=; b=oNFZMkYn3UU+NgrSqJaki//mVeNFQqLxPYT5gdt5fe/G2go2yBu0HK75zU3Xgap236r6BCDBm ZYwqtPi0n4dAt6kWsMHBwOQHNjr/NkdtV3awJeBzY91VqIim7xYtkSM X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002313:EE_|PH7PR19MB6061:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ba9bf97-1abf-4483-8cd4-08dc80095165 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8AoXXx44pQtfhOfFlecIDzRo/fFRclF?= =?utf-8?q?u+XfH5RThlHN3P6/rrt1E1V4LAUNoCaY5XFE0J1wQEQWDs6AgpWvGVFqitXdvhDyx?= =?utf-8?q?eIRIKRyiYHQQtEI92nuyjiEW5mwbFV0Z9sf1yJsbFqpTNhqoGHhjRBNXTULyzojeq?= =?utf-8?q?x7f5nB3QKFRh7RNahYshAnSOJo+17CtBy+jTKf5MqjK+8VPgKsjljcSHKkd+ZPCVI?= =?utf-8?q?urqPQ7ZAYfoksPJMRYGGXfAg0eLQQTF5iaS/F9rvFgu1wVXrh/zqWYN+Ctd24uD10?= =?utf-8?q?+LLGok2T0vfVRMliClt/c+euNUKiw4hPdNQBVgij0OrfYIP59u0yNIiFWLfUHpDZa?= =?utf-8?q?45tCM06osdiAN8PAJ0EjgWDmWSu03rtSshYCcwBAsOymnS6c3zR3JghMEOnNivWW/?= =?utf-8?q?ykmI5Ed5vJIAqZKExSvF0c79YDxV9zXT5Mvl+8oKn1+AWjY9hhQT7JmUUZRITVORy?= =?utf-8?q?oaqP5OTQ8S2lK3h4oM4AAkCA+dTGtlClA1lbAyeKflbpJQCV+yPFEUz0Rdafu21jT?= =?utf-8?q?D2cTDQoAPDlOBCd3mvvp6dGP6Uxq3fq1/q6I2dqLBmQJ3cBNtaV/RmXyra8+Cck2v?= =?utf-8?q?eT9+jBNyadaPp3+oSp8ix6lnlsa23q381evvjPapaAICQfJB8JBUGAt6xjegXR/se?= =?utf-8?q?46/A274Sm9TBs9uQLSs1HqsECXyqNyTZXFY4fFcpxlmVa/Yb3UENf2ihelhNHkYEc?= =?utf-8?q?DKK62WRg7tOfQ7QYSKYuhd8AaMBQ/dyCzUU8SaJKSJz0aj9sD6fx37xs2b57SSuqL?= =?utf-8?q?GIcL/KyYjdBMd1EpIR8aMluqWJPaekThnnauFYXaNcU/JVlqjhLS4MNhZFNQy2p81?= =?utf-8?q?bzUxkwkc4bQwqbazPeyphx4fMgPTr9JmeAePD4PLCJReUUNJOd0zezxm0jIfF5maX?= =?utf-8?q?zkPkTS5fAHFlDrSUOxfFoEhXxI9SGLfnRkrdTa6mwz123qBibDqe48PYKjr5JoFdI?= =?utf-8?q?zLY3+LjN9DLOPSOEu4NZ71GSrWBwwhRb7GL0kGB09T2s3G/0MaD8VnLVLds8SGr4H?= =?utf-8?q?U19Lt8i82SgJx1kskQJhCr+IxqBMbVvoH2/Z0k4iW3QNETFCFgJqoVqlAIr2H2yje?= =?utf-8?q?cUQLimrP4CCSV91c9FKNkVacz8GI7FoThQOHzbxCe41m8A8r9vv/1bWhPxlBOWvB9?= =?utf-8?q?qqKfCqHFYn0wreMfUXkIQJkqJ9TfuogtAIdIAo5HH9vuhC2c6aPP+GJ2GYgudljCh?= =?utf-8?q?kzOcohf/3hUx9Wkbn4bGRIB2qIYTcfgRRfEdu0niGlYi293crF42wsKWPfjwmv+/u?= =?utf-8?q?L4p8xGo54gLvCYFhT8mVypK4SxTt5WlS3G3p6ayFVQMLLL15q0BBWoGM=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:(13230031)(36860700004)(82310400017)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: trfRWF6rGs0ZPnRfwXTsK/1z7MIKk7o4oo08ZB7XLjeIWSzNgLN3Vxl1hcXIhvSq9z5J4ZVqnLvCy0VycFMUzL5JZBhJiDbo2PZHXgHwYS3zHAHX0mFmdZT1LtZEcMuOxtpwIzBWclWlT2KBJ0nOlO3hLyps7RA9zMJlY11oH8rpUgoszOSPJccGuk46Kkm6ae8V/bISkoOAFjhkZr8KacazyTEiwOZi9q8Elf567VARk8Ea0xRdSCCI5cLoMkqFYlOWTshfonGkdx0bf6/TEgM2WN1HUuq/XFxctv4SZSX3+VG9uURNJONRP+OX5NBK+DhIiZ6sh/ZrudN5XslXk5SjOZP/LKCGVW+Xw/c7oI87JDMup6sbDPLFo+FcuMoGsxp4FJ7pvBzKWJT2ZYA9ELQNNrtIDzGgj3RkYK1IWq5tTh96UzDrGS2HFujhWm+j5NSzKyhUxDx/pWdf/f8jPWd6qdQHTFAXbcEzKz8YJT58N9JJDy0ZlPTCzsHkHWn4QixFARU+FylSgBm75/0c5ttFNGs63L0SJ6DHF/YM8aMEicEZp2EPUuEYQOdkx6/uh/anI5DN4RQ0HnFuDYPtzX0WITGRTeluFGLibVMsKjmL8fimr1Nb187VlqdwtPsawSY4PDjav4yqdS4d1LUjpA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:01:08.5938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ba9bf97-1abf-4483-8cd4-08dc80095165 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: SJ1PEPF00002313.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB6061 X-OriginatorOrg: ddn.com X-BESS-ID: 1717011269-104945-5143-50158-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.57.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYGlgZAVgZQMDU50SQ5ydzC0M DI1DTR3MAyySLNxNTAzAzISjG3TFKqjQUA4Et9TUEAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256586 [from cloudscan21-209.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 This is to avoid using async completion tasks (i.e. context switches) when not needed. Cc: io-uring@vger.kernel.org Signed-off-by: Bernd Schubert --- This condition should be better verified by io-uring developers. } else if (current->io_uring) { /* There are two cases here * 1) fuse-server side uses multiple threads accessing * the ring * 2) IO requests through io-uring */ send_in_task = true; issue_flags = 0; --- fs/fuse/dev_uring.c | 57 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index cdc5836edb6e..74407e5e86fa 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -32,7 +32,8 @@ #include static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, - bool set_err, int error); + bool set_err, int error, + unsigned int issue_flags); static void fuse_ring_ring_ent_unset_userspace(struct fuse_ring_ent *ent) { @@ -682,7 +683,9 @@ static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, * userspace will read it * This is comparable with classical read(/dev/fuse) */ -static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent) +static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent, + unsigned int issue_flags, + bool send_in_task) { struct fuse_ring *ring = ring_ent->queue->ring; struct fuse_ring_req *rreq = ring_ent->rreq; @@ -723,13 +726,16 @@ static void fuse_uring_send_to_ring(struct fuse_ring_ent *ring_ent) __func__, ring_ent->queue->qid, ring_ent->tag, ring_ent->state, rreq->in.opcode, rreq->in.unique); - io_uring_cmd_complete_in_task(ring_ent->cmd, - fuse_uring_async_send_to_ring); + if (send_in_task) + io_uring_cmd_complete_in_task(ring_ent->cmd, + fuse_uring_async_send_to_ring); + else + io_uring_cmd_done(ring_ent->cmd, 0, 0, issue_flags); return; err: - fuse_uring_req_end_and_get_next(ring_ent, true, err); + fuse_uring_req_end_and_get_next(ring_ent, true, err, issue_flags); } /* @@ -806,7 +812,8 @@ static bool fuse_uring_ent_release_and_fetch(struct fuse_ring_ent *ring_ent) * has lock/unlock/lock to avoid holding the lock on calling fuse_request_end */ static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, - bool set_err, int error) + bool set_err, int error, + unsigned int issue_flags) { struct fuse_req *req = ring_ent->fuse_req; int has_next; @@ -822,7 +829,7 @@ static void fuse_uring_req_end_and_get_next(struct fuse_ring_ent *ring_ent, has_next = fuse_uring_ent_release_and_fetch(ring_ent); if (has_next) { /* called within uring context - use provided flags */ - fuse_uring_send_to_ring(ring_ent); + fuse_uring_send_to_ring(ring_ent, issue_flags, false); } } @@ -857,7 +864,7 @@ static void fuse_uring_commit_and_release(struct fuse_dev *fud, 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_and_get_next(ring_ent, set_err, err); + fuse_uring_req_end_and_get_next(ring_ent, set_err, err, issue_flags); } /* @@ -1156,10 +1163,12 @@ int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) struct fuse_ring_queue *queue; struct fuse_ring_ent *ring_ent = NULL; int res; - int async = test_bit(FR_BACKGROUND, &req->flags) && - !req->args->async_blocking; + int async_req = test_bit(FR_BACKGROUND, &req->flags); + int async = async_req && !req->args->async_blocking; struct list_head *ent_queue, *req_queue; int qid; + bool send_in_task; + unsigned int issue_flags; qid = fuse_uring_get_req_qid(req, ring, async); queue = fuse_uring_get_queue(ring, qid); @@ -1182,11 +1191,37 @@ int fuse_uring_queue_fuse_req(struct fuse_conn *fc, struct fuse_req *req) list_first_entry(ent_queue, struct fuse_ring_ent, list); list_del(&ring_ent->list); fuse_uring_add_req_to_ring_ent(ring_ent, req); + if (current == queue->server_task) { + issue_flags = queue->uring_cmd_issue_flags; + } else if (current->io_uring) { + /* There are two cases here + * 1) fuse-server side uses multiple threads accessing + * the ring. We only have stored issue_flags for + * into the queue for one thread (the first one + * that submits FUSE_URING_REQ_FETCH) + * 2) IO requests through io-uring, we do not have + * issue flags at all for these + */ + send_in_task = true; + issue_flags = 0; + } else { + if (async_req) { + /* + * page cache writes might hold an upper + * spinlockl, which conflicts with the io-uring + * mutex + */ + send_in_task = true; + issue_flags = 0; + } else { + issue_flags = IO_URING_F_UNLOCKED; + } + } } spin_unlock(&queue->lock); if (ring_ent != NULL) - fuse_uring_send_to_ring(ring_ent); + fuse_uring_send_to_ring(ring_ent, issue_flags, send_in_task); return 0;