From patchwork Thu Nov 21 23:43:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882452 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 379351AAE06 for ; Thu, 21 Nov 2024 23:44:07 +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=1732232652; cv=fail; b=nF9magJQ2rG05Y176O0au7tGj8vqJ8k8+/GQofEX5m4zuX96yTfSmwORk7KSVarfRxkgZVFrHVHtE/liLpeoKssKlkJZR6SrWN8v+qztZ1wiDPUQhjsFB0IdQ1KMTm3LCoQyoV3KeleHlcvgxd2mkdGpivaBmjF7r0VwsWsCWrk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232652; c=relaxed/simple; bh=uUXs1hSMjDEi/7Epvfs44qM9emPwLUYdDB03mRcLkH4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P4h61DeuoaZsvvn5waio6U9Qxyixt3Y5z66Yug9aMhvyKwSgAIG2WuFzEIbldOYvhy0l1Tgs9jgHkW4ou/XQdRveMCHl3vXNZIzMYajpeBz8VXq8I2wKEN9LewKsGOCW4udQA4Np7Ajw794Aj6Izs718YCAtL1VPvLB9/lTUT0A= 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=mOvk1by5; 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="mOvk1by5" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx-outbound21-109.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:43:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jeSWMaXNj+2rQm2H2hq0Y3FLsRecSrhucsvphRbTrdnD7lOjoUE4OQUXGHtxDkopaDI8g+IS2hZZggZQto/U30XkLVrcEjCtFRvlkwRMObjD98/Tlnc0iXUC1dbnO3rwV8655rwnZd0wzdV5d7X+n2YfAYDdvg2VXOr/+FMiBMWXI1ePO30MOUMV5yLl10sdg1fxyDLcMVBawntXy094R9vIdy/qLlyDO3W9Bir9Aul6+htgFXz00/wckUzoMEVfTGQzfVCloKNTdJ36W3mfT9dUZYMX8usM37e8q9VSfEnDGkzGPRLpCM6NEGHBVfKgwC/w7w4yRi8ZXQXTTO7ziA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rdyDw2y5vJF6YtfioCiYZQ1YHjH3jaK/Nj7D6eeI1eM=; b=UCkhnJ/WP0eW7A8pDiTZfTVd4fwR5OtM9xrvkVlYUijb+Hbh3dZfN3uWdJUOWynXE3B5HqjJ/nzx27GCHnjlngSnHbAK5o09B3NoDPYMmqW5EfkdmANrCYqNvyaqfkTw8PawGgG7HrMGR+qrkSGp5na+XdxY82hyA/P+XLPA8Yo+18rCL5SupmKKbheqFj+8uBYEMYvPHoeihvv2HfR9v7gzYfdKJd4i4mSz/8bdx0owea6OvWdokokxxtVNYlvC//Jnc/OPoejvfs+rfzyXK6LMQNn70feELsxYAqI1LOoTV/Vsh1ycalGSskPu0mXRNFtiTaKBQUwrdbSf+mE/Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=rdyDw2y5vJF6YtfioCiYZQ1YHjH3jaK/Nj7D6eeI1eM=; b=mOvk1by5aLHUwiesV6ZZx5v9tfBthzdNgTJwEdFW63I8DLToPqY/WuudQ6Dvz4rBURWjHMSUjEFVvKBYGlS/G1ZbP9f5vQX8DP1M8M2taQBA4fMFhZ3kpRII7/jXh8ESv4lsYEWcFGrSXT1xtK6t8g8CugRQ0z0uLcfBBvEfQfQ= Received: from BN9PR03CA0031.namprd03.prod.outlook.com (2603:10b6:408:fb::6) by SA1PR19MB4880.namprd19.prod.outlook.com (2603:10b6:806:1aa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17; Thu, 21 Nov 2024 23:43:52 +0000 Received: from BN1PEPF0000468A.namprd05.prod.outlook.com (2603:10b6:408:fb:cafe::bc) by BN9PR03CA0031.outlook.office365.com (2603:10b6:408:fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 BN1PEPF0000468A.mail.protection.outlook.com (10.167.243.135) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:52 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id EC5C332; Thu, 21 Nov 2024 23:43:50 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:17 +0100 Subject: [PATCH RFC v6 01/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-1-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=2733; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=uUXs1hSMjDEi/7Epvfs44qM9emPwLUYdDB03mRcLkH4=; b=yOS0tjfGNPy9fEvTuavjFUWWyFUkiDcMWd/gPLwRRaWZcsBqKmMmVNC8cNYfSOyvdLGTriRRi wyfg2yFvOyDA71N8ASUXW/fp4Cz11JiMNUGO47guXsHh+1dYnm3RB+J X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000468A:EE_|SA1PR19MB4880:EE_ X-MS-Office365-Filtering-Correlation-Id: 48376ed9-ddf2-41ca-689a-08dd0a865ad5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?deOugaYTDH+QsYicHVDLLJrBoOXNtwJ?= =?utf-8?q?s3y2ktlEeKjRxLSLkXpwJ339HLp/U2T4BDmXT3oQpRiPu8SIh5gmpnRvuAw57xVeT?= =?utf-8?q?HP9nJyAWBRHWiVxib3mBKx1Ikf7lL6HwCUSzD4BWlnI8QJ3YHStXzskbmn3k9ljDW?= =?utf-8?q?3rchFktRrradXJ5dVsTOsZGfljw+oizT+SAncFliCBsoIRm2cxlz95YBKqQo85nHZ?= =?utf-8?q?5NEeFgkCICIpp0h/Eyji2mH8evcTntdYFq3FUZWsFIL9YywgkOH65vZeFHTTPuGmE?= =?utf-8?q?l0UNr9+LSVXhFC34Hz3skhMMVcsiOmDZMwOcGgKGrxXY2QYKVJQnXsiNOFO1KXYAu?= =?utf-8?q?Dv44KEpcGoTHcu37YUSASJKnLosnoSU4RwQIjn2adOCBrzv2s4Zbr8rVIZs6Z5Nye?= =?utf-8?q?zRUc7Qio/hZ6BdZS7WKvwgjS6lAgjYFrJVj13Kj6lqPyhhilNcBj8051pb7NOW9Nr?= =?utf-8?q?51D4381j0yQ4nN2mrXDjUwsF7qdq+4/LhLr0/NqM9bfTqEECgfg2ySi8w+s+rKCK/?= =?utf-8?q?WYAPwNGvwVQJI8YtViCb9jVbpFbOO3JocYXegPOYJiJ10JUptJhfVitQnAtruZSmu?= =?utf-8?q?AbT6elPolLGB0l6Cg21zv066MJjDnhoy4l6Qyo3/QPgbwUMv5QJmzdba59mbnwzaB?= =?utf-8?q?hqBYGyLMCyCdDMFpfgIGkJ9c7/CXCJGZkLhyIabeDNFJGjepeHxkwf060NdWkMXF2?= =?utf-8?q?VT9J2FqS5IqxxUH7jQ5SBI3WcTjmosgqKtjZaT0UembOp5wj1ZxkOXBbdZERmx8LP?= =?utf-8?q?U1l3YfyaWUhFqqzYZxr1R89vdUcT9OiDqh7VAeEAbdRA2atr6aBGSA26lv7sKsXmk?= =?utf-8?q?37fxG2Rlk1sYGOTwaU2QPaAAHs1lEoijOPDg12tH94LkwNpzo2f8Pd92vGZD/3gRd?= =?utf-8?q?6oQZ/uPSGkMgfNfvgL+fihZayOHwT6aGr6puTLSgj7gIW6k1F/i6lMk5xjUfP3R+Y?= =?utf-8?q?WG71rPHIbResXzleOqdyUMNSGWDS5VZnxjksZSOUcJ94m82pdGJNuMlejDTDznpsG?= =?utf-8?q?xHY6CQM8EjPdDDtZqTL92sD3RjoItOK2k2J0oyqyIp84mgsmH0tcq5mLmUdMxPeXM?= =?utf-8?q?P1y9FFymTNgz67L3kbRNzvinbvsgAyI6rBjhuf8KcU3qk0b+LY8f9cKaqPWgSsPkd?= =?utf-8?q?u7jgcUUbWu+R1eZ+lwIcEswhZwy30qxiiGPSIh2PbTygojQlcCO1+Evqx0Tbfywnx?= =?utf-8?q?vpRi40svlf18GvXSgbNylsrmAR7t8O0N98z91BOJ8RaaIBHJnMsDF1Rul1RbBh65a?= =?utf-8?q?O46po7bUW29wg9pE09PSpqJoiMteV9j+eDfPNNz1XMdtZ+9jDMWqDYoFvM4gtn9Zq?= =?utf-8?q?UsLoZCK68xBOTJntSL6wgoyPSTFWMoA3pw=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +wiY5czHwJq1Vc7RRU2ToWIHnsed19vIgJqsImZnvj4eGrmeKqU3qjJKRGSV/0qVsNqJ7VnbOHsxEgAF/aH+BZ1Jb9b/67Impn+7eTEbGp/pHXewdO/qAlSPBv0yfe5xuDKt3pwHunPCvZP9qX28JGc+69nhYj8ZOYc4w5gqZNM+8YoslDVM3rlfpcSVziC8ZntOxp65XDMP88gOW6UCVnYaElut7VUGvSP4NV5niJl3u9k1bzmoYFB45K9WN4D642MYXuxHYOAp8bS11kSNzWDVSA/IGb4j3Gck55Ip4dExBfbh+lKGHZftCBWUDmek0MBitIWojkgxv4RIP7BgydZOdiwAAL0iLr8AFVjr7IofBPuxoyKkatX+acUCcXqgxBG/jKgA/nhovXSySK5uaIuWH1+UXRC0GcBZdsXuUlDj1rId/D897ofXTYUIPesPyHUwmUFm1tghpK6Fu6SrokQXNi83foSQqNg6Yo0r4lq2CZNvrjfTINYtl2PSw1AvO3NZDza45N0W/ruuNa2gSTIARR4kbsIBSCJwJd10Cwa/0McMzx6SlcSMQWI7pveGKakSF7+SRWR+DIXXtL7be4PIL/NfiPgJ4E0hGKJYiLMSDcdCgYD99tgBXKv5XEQ40tje7tmxp4e33SEqK8rXOg== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:52.0903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48376ed9-ddf2-41ca-689a-08dd0a865ad5 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: BN1PEPF0000468A.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR19MB4880 X-BESS-ID: 1732232635-105485-26950-12847-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.66.47 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkZmJkZAVgZQMDXVyMDEJDHJ1C zZNMXMOBVIWRgnJ6VamJoZpKWkGinVxgIAekW70kEAAAA= X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan12-68.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 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 | 11 +++++------ fs/fuse/fuse_dev_i.h | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 1f64ae6d7a69e53c8d96f2e1f5caca3ff2b4ab26..09b73044a9b6748767d2479dda0a09a97b8b4c0f 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 @@ -34,8 +35,6 @@ MODULE_ALIAS("devname:fuse"); static struct kmem_cache *fuse_req_cachep; -static void end_requests(struct list_head *head); - static struct fuse_dev *fuse_get_dev(struct file *file) { /* @@ -1873,7 +1872,7 @@ static void fuse_resend(struct fuse_conn *fc) spin_unlock(&fiq->lock); list_for_each_entry(req, &to_queue, list) clear_bit(FR_PENDING, &req->flags); - end_requests(&to_queue); + fuse_dev_end_requests(&to_queue); return; } /* iq and pq requests are both oldest to newest */ @@ -2192,7 +2191,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; @@ -2295,7 +2294,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); } @@ -2325,7 +2324,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 0000000000000000000000000000000000000000..5a1b8a2775d84274abee46eabb3000345b2d9da0 --- /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 Thu Nov 21 23:43:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882453 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 3C8711DE4FD for ; Thu, 21 Nov 2024 23:44:07 +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=1732232652; cv=fail; b=RdYhrV9YXxZupgEcHbFLiYp+0kJMYoQts5qVs8yh4Q8Kar2947YWx5s8/WRoe8/HzeyTIwT2dD5+Im9PGH58RY/TOQNtxIl+A8PzgSp9BrDuBkbjHltvtXcGCnfY29Lxgy4kDA/M9JEYlJ6pGAFdG23q3y/+f5uCteUoj3i03oo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232652; c=relaxed/simple; bh=wFhm78xifGsHJGTcPsAEgLJbclAp6ONom1hnh4n4ZrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FnDd6ACMRfvSJBUGwfVMzi1bUJs//+IbTVYdcwYEL2wD0ogeFLba6SSt0yMcA4ItZFfxssmkuaiwN22mdHuhVlXuVAzeSQ4aoKg1qXG5ZYpKCWbYF3wg7ktwZVnDxAHXSyQGzy3aGc4QK7LWiVM0iz2brVmC/XWgQPMMnugo0d0= 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=m9Vic+pI; 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="m9Vic+pI" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by mx-outbound-ea46-177.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:43:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rehRA671jj3crVULfIPkC9JqA+OSaJg4q/Jvv7kM7zgoQXV+ajUJVyAO9bY+IPndeOrdVw/ZJDr6lKfxV93VYIBG2IFYQiV6TxoppuNRISKvaD7Tc116iCz8ZknAR4pFvNnsuPa3isi2trGQlk9NyHJzV2Efb5lvs676CV9hAlXCBwks77cI2YJ7ti2LEwDLB4MrMQe8cWyMcOmcVpTXdD3Mq1TmmGv2UpgDXnZvaw4ko8dLXRMB+cVbkREWtRK/fgZmFKZ3M3QStOCbd+BIFTnCyfdv7koqvHVTahN5Re3BgbC1F0obhrE00O/6EgxdQ14c+Wm+UdgBvZJkIddeOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=07wxmk+cK13LRNaYc1CIxXnkiT+Ze2z+1SUsQA8ZH68=; b=ILFKtPd17PUXUfuYUB2TrbFwy8gQ3+kgEEMcjjOBwVhZCCyRXk+3azjMDUhYNn7RuC3zK54ZbHK5xPDoqwu6s9rd3zyVBv8a8TvOlpgz8wOasTlj127s5ONwN3PZS8nc7wVRFM2Zlg6SUYAXdV90eCEbhYiii56rldHt6RHdLBAuitNNc3pzmI+quXyVxbaaGUYXXsbgcRrNOqc8+kpM0dfsF/FRFtH5sajmny7HxesmcEw0ayXzwX1WrZeAUZxOl70w2UXkDUTLO/ltlvrNDHOuD1hcsxn2MXqBR8ujBj/HLpXLvjIqIyDQtaWnGx8Zci3ZlbCaCdUCBsjpywh/Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=07wxmk+cK13LRNaYc1CIxXnkiT+Ze2z+1SUsQA8ZH68=; b=m9Vic+pIxcyvWnclMZjmOyCcdPRP7QbZX7px3AxcdyQZvTcmy7GbYvkqVmq8N532fTeGfqbEZvboN40OCzsvBRiQwSl4ORa3JVW3AZW6I2FxWZ4OzkooLeqgQlXQT6YnXs/bGn2b1fiksk3ZfZtt5XhpH3F4BDIWRrh+MbrkKlA= Received: from MW4PR04CA0176.namprd04.prod.outlook.com (2603:10b6:303:85::31) by BY5PR19MB3956.namprd19.prod.outlook.com (2603:10b6:a03:22c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.27; Thu, 21 Nov 2024 23:43:53 +0000 Received: from SJ5PEPF000001D2.namprd05.prod.outlook.com (2603:10b6:303:85:cafe::c7) by MW4PR04CA0176.outlook.office365.com (2603:10b6:303:85::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 SJ5PEPF000001D2.mail.protection.outlook.com (10.167.242.54) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:52 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id E4ADB2D; Thu, 21 Nov 2024 23:43:51 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:18 +0100 Subject: [PATCH RFC v6 02/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-2-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=1579; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=wFhm78xifGsHJGTcPsAEgLJbclAp6ONom1hnh4n4ZrY=; b=Gp+HMW97ZkmO2L+kypCqE181j7rO1F5aJVjwrYcXEbOHuZaP5U15+2rWyxHWBgpqPzEm1VrCj d5AP8aCwrv9DdUoVX7EWyhAKoGxSdeNwMcQqqLJzjnSOIvl76dFDJ6n X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D2:EE_|BY5PR19MB3956:EE_ X-MS-Office365-Filtering-Correlation-Id: ad81115e-ab08-4b14-f7b4-08dd0a865b66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?r2ufumdGOXaMEjMp2/fu90fQ5RQKaRD?= =?utf-8?q?1ynzwH/eYgF6PzvhWl37JywJnXgZmINeFZNbZ4uHoenwsDd+3Oo5kd+4Mxuvj+BqD?= =?utf-8?q?dg1cFht+xItPOO+0/L1mdDtYw6BA5SMcrVRQViBJ3cXkLLIE/i3Hs54MnBGDWOLLK?= =?utf-8?q?s0AMIAVZ02T5FBdV/zhP8PNmUm1TULO7DC8ItnhMB1ny6nMV1/GAkX+BchtG4cTi7?= =?utf-8?q?K5B2+kVFAeRd7sRi6ZmsG6e0vOJEhzpEVMJBfgU+ZaLsl7YnGL0g+yCQuZmuXJFOu?= =?utf-8?q?Ishru1NUJBcdvZBCJQB+Sv3Uwm3NVmF5SLXXFALdxYszIW/F4j506uNM16oxSIWiF?= =?utf-8?q?J9YwLSBUkQU8cmdZGdJ0xAwivLSUNrc9Nid6dVV9aFqNTbwnApmdnZbnUPyZREGEp?= =?utf-8?q?fVQzrFMyrOS8Y8fXQiJL1Z1+1RVpQYDWHh2ZdqhrekUzM3FVrq8bHiG61D5CXp8Mh?= =?utf-8?q?h5yPhQbyUUu7J9w8a0L/VVJPGTGH9A+D0slsv8F1BAUUdja9CBCyuKEJMg8f+mWjJ?= =?utf-8?q?FgTiW6EmfylTH6Ads3rOUZUXxlc2FtZAuN/A2BIhJ1SchvsQfFFJ9pvO6vJShdvek?= =?utf-8?q?UfgATbi2eq1VU4giA2rFSI7qHlQzZu6l+oI3NuZi59OvdIQ3S4xD4chmoWuQfL/ct?= =?utf-8?q?aJJc8IURV1tA+6CdrIEF+2r+6sTelrolGhFuafVJgnGBw1iRmnOH0LbJ8jCsaGN7A?= =?utf-8?q?b7XAh46LGMY2GDl1lB6NEg5wN7mctlat4FMytb2wAF//3ZZE4bIvTVmhQVvZD8CXU?= =?utf-8?q?gHcjkf/qu7DUlJSjrIMnofqasNqQnjSfYoY50k8ZwGUNFe+htLWamwt41GF0RnmA8?= =?utf-8?q?S1ZQqnOiVVMvheK7uZ3Clb/hq4VEoqYYB2ndNEmmjuK8zom/xWT2XrilcyJniZk58?= =?utf-8?q?GbbkuHSBNJu1O6nla1+qozVjOaAvE26AzA96RCHu4mSiqN2Z5t22IkMrQeDpQLWAS?= =?utf-8?q?6gRVcULS3iLjLAgXIfu1MQ9amjvFIY4kfT7IgSt1wWYABkaqy0js0njleFk/J41pa?= =?utf-8?q?N2NNFPLIOb/y4uRkrrAxemKLMThYqf7W74O7SC++VPvCNMkLLPxYbaFntZ5TMk1sE?= =?utf-8?q?21UhBYwORXyeiIjyxXsGW44EfjEtCQK83RLPnfX3uuFx6q+eToo0GGClXCZ6NRYjN?= =?utf-8?q?ClayAro3+fcs8DuR5hLsEAEbafb0w5ntDwhnQFROX29uQqIb90uhWH4mABLndC1Rz?= =?utf-8?q?c0GxvxHW3BwvlQ3LEki5x+sfzW82lpEuYpJji52uoLvIQSwP6da5RgXfat12Ql4H6?= =?utf-8?q?U8q8jwQUzNKWzFvj54UBFLMUFjsCBJkA9tmD/Dnf6Fz0lMtouY3cwx64Ilf90busL?= =?utf-8?q?ix5XfIKQEO6K7tfal6VacUvTKw/fJN4qqg=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: D7mMqs+jVAZi0cCOQX4KPm1MzMGq1pMbycfyrDEE2xPI8tOli34s3cN6iyTGydOA2rwsz5dkgTlerugjUSh/8W+BKBUIdZFTjxomlpZSVPJBv18KqnDxgQ8XwwDkJ9//0sdF8NDjt7M94y/M6rBKcqRbS5lF8bZETl5bb9SzeP262CCLv8m5bs/SL5W9DpfNZslSY6ZR+WtZm/5NDkzuSXERSgm+UaVJh9qWAusC05YWIWzXql6/zj7TTJqgTWhzrhKHTqY5v+hXf7zNhoIGh4d/ylwwkcSwQxd0ZyC7i/G0H2L7cm4iZiwJkka33PycnlYvM8672j51xU8y+IdQ/t3hwy8FjsPDLXhRJp64Q0kxGHCu/PIqQ8lvW+Ll8ufG0JLbuJMmCbJl/Zh5HqyGPqTnpoc0aOH+bWdsUpJo5cPToIkV6QVSjmcuuUDdM3TMUfXWw0gXWzwlfZebPgvAI6plRNnE38OmuiSUB882WCYXgr0e3hx3lAh/2XrGfd133LTwOBoGrY7+6mA+/tvfsjkZ1fUgmF1pRvXak0aSqBBgUIIZemOlt7VnYLce22uGTH3ESDkSrgdcYmRpZ1i9EfElSMLR5DJGHKebjOcHjuX/fcU/WRDZu4heYEqAjDT5w1mnydNLzSprXsMU25pSVA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:52.8879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad81115e-ab08-4b14-f7b4-08dd0a865b66 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: SJ5PEPF000001D2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR19MB3956 X-BESS-ID: 1732232636-111953-31783-23237-1 X-BESS-VER: 2019.3_20241120.2021 X-BESS-Apparent-Source-IP: 104.47.57.49 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamRuZAVgZQ0DLFxMzUINXExM LIJCnNMiXJyDApxdI8NTXZINk41ThZqTYWAFd7jrdBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan19-236.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 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 09b73044a9b6748767d2479dda0a09a97b8b4c0f..649513b55906d2aef99f79a942c2c63113796b5a 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -35,15 +35,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 5a1b8a2775d84274abee46eabb3000345b2d9da0..b38e67b3f889f3fa08f7279e3309cde908527146 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 Thu Nov 21 23:43:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882459 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 424FD1DE4FF for ; Thu, 21 Nov 2024 23:44: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=1732232655; cv=fail; b=uY9rieUMKSG8HzCNy+oXz+AUkDUKkPprkEkCIHTShTgxjExIbFLqMby31hZ6s0ntX1QWHm0xJmwXc+VLcYtLL8ift3Tl99gL4LINDcTuAji4W6In3UqI7xB8l5ATFTu5iB4hlmqZljn4He7hCpdD7AploKhiedDpHK723dIVO+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232655; c=relaxed/simple; bh=+WrcrOS7S19aGaDDvqYM7mR3M0AYD6vNepObBY/hSHc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U/417r11xInG1xkhpzxP8W3qCxB7cqsEHpgFoJLTnqtTnY0qiVMhc7bJ0o2Eb7SWRxnkfNEQcIAl3L/qxbNZ5+Ur0hxRo3azkw78+QpX3sLJqasd1XEZKI3C3mBsYHuT+KSMKlfqGoNMo26QgyJ+66fpWDbR2jQWXr71s0D3Who= 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=N2iWj4g0; 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="N2iWj4g0" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by mx-outbound11-87.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:43:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DS9+sb7IoztOLiPl5x69R/B0UnQatBEZfIfBLGwzn/7mMGyU70pATCS5j+kgosURx9Lq/jChX8v7ueDTQdA8GobWIspjmDaia7XmxgkMKr1sAcbDbjisYaNS50no/mBiSJe3vH9iRSNNmw/mDPC140XZy/zSTmVXCQvCUuSZvYVnKui5R/vMKEY+eCpZhZD0cUHBXAnE9TuQbjwShKTqwI6XCgMiJ6MTsNI7NquEAicTI9MqqjaQYSWodMOy6YGXfoyIJDVw32N9WPtG48FR9wCzPk7/YYNGfaPX9LEXqGTdWHoVkZxDVy0sgKdrU/h8EnZEWfhTTyuUr1xp2g8z0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OGwHhHgxLXrT76ri17FP1dSIOhhMaSHHNs95wieBHF4=; b=ea5bFWGu7+r6nLGee8n9j/1pns0Tbu/Mp/WxIyt1TQReJR/5XoxFEFEHJPh3dZu9N3sdMIGmCj+zAARP2B4mX8uy7MezZddl/IUrIZ7wYFVZgycNhvt161IvbX9uZ0OF8PEuwup4nAUP6480KdbNAfHiE1Bvjgia/n0qYkrc3sQOGucIC4VVFJgpgUUajHAlJA7PJgZ/6QJDNxFt0iZ/BTs0MyFjHsBNfaw4UkCaEm1d1ZaXzyr8CXzUTTojEUjp3qjaCrynLKKm0anXq541CL2QWCf6+qYQDZ+7oxeR9K3Ic/E3/STT4fnYS0vahaOlnXN+8txdHX8ZFYa313Zgfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=OGwHhHgxLXrT76ri17FP1dSIOhhMaSHHNs95wieBHF4=; b=N2iWj4g0mBS/M3G3HF7h5K3RsQZbzrT0Qfj9LQrLdxKUt2tLTe9n0lQeuwSt7BsWLQ2pwCpEVZ8j57sN3vp9rIEsGmzk2w6z+y+NIJ7tLP+AW/gUVpTsU1Kqr2dxQNtCJuX+CC6YJzxT7+Mlgd0B3ghhXSCQpOeZqcW89cdCVXg= Received: from SJ0PR13CA0183.namprd13.prod.outlook.com (2603:10b6:a03:2c3::8) by CO1PR19MB4918.namprd19.prod.outlook.com (2603:10b6:303:db::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17; Thu, 21 Nov 2024 23:43:54 +0000 Received: from SJ5PEPF000001D3.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::e5) by SJ0PR13CA0183.outlook.office365.com (2603:10b6:a03:2c3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.14 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 SJ5PEPF000001D3.mail.protection.outlook.com (10.167.242.55) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:53 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id DD62732; Thu, 21 Nov 2024 23:43:52 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:19 +0100 Subject: [PATCH RFC v6 03/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-3-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=1326; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=+WrcrOS7S19aGaDDvqYM7mR3M0AYD6vNepObBY/hSHc=; b=r8+ixa7MdtUUyQTP7c2EEFhEqb693rzECsQs+yYsrA6YOet75wvcO1n8F2yYsuxs2qykv8DuD IctOsq3HfIbBwLZga4E6n0pJs6kFny/xrjrQCfS+734xmWvhUIxeOan X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D3:EE_|CO1PR19MB4918:EE_ X-MS-Office365-Filtering-Correlation-Id: e907f289-0d7a-40c2-b213-08dd0a865bdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+uc3MJLcS5JFCKgmGmy5k41r89MHu5H?= =?utf-8?q?yXs3gnHy2dfdv1UmsYCU68gUsvPx59h4E5GRH1RH8geZ8cngc6D7XU/IrDe8QIuaW?= =?utf-8?q?f8Bw6VPmN7ICOKiOu5h1P8zcJhGX4tnZB+0Q+xtFOIS6AzzjsoG8tBbJcYCITIRCi?= =?utf-8?q?n1s72MZR3vVLA79oFMw6Zolf8XqoIDY4IZWmKbh1Ly1Rv8c7FoiXpngPBD2e+qW0e?= =?utf-8?q?AWZJ31ycHB5UFBFhde4UCaDH3NrRUwS0M6mjnIBUwMidOrZnkIoRPjiZtSausX86y?= =?utf-8?q?/ERCHDLxia9/H2q9vPIe5I+2tBSd+KK49ErbR1JKJtTcDWxCoH+J04WhFB3RSzC/L?= =?utf-8?q?/TbyxJRB7w44bLAFpG+V+fOdJPmSqhs8EQvdeOhNbVodVGSnjRX8LstfF7B3fHk96?= =?utf-8?q?pQJ/pEP9c9YkRjE2w+kPaqM21MhH190+beyq+XQUGTCUQirDKcZ1BTI9Y6Tkaqu2W?= =?utf-8?q?MPNHLd6Nrb2g/4jgiMeIJHs5O2hPGkTlVlFZfPbGQWl8cA21q7eRlj/meUu6A3Qs6?= =?utf-8?q?rILq0UK3d8LHC69rDcRRxAWNwnTKVTOfykilO2msxPQbjebnPKe02EeHtqhTOysUf?= =?utf-8?q?x8fhBLYmYX/yHglbbqE+EX2aKc2fiwdSh+HJtra9zhNcGCZVd6ldZeibaQp/aDSwy?= =?utf-8?q?CwZjWGSDv4A8NJMoLFEnbiQEEoA4om3pr8IhxT25LZzUW0ed/xkW1gN5HAUIjjgFd?= =?utf-8?q?B8G+wbweq9v68skQQ10O/JfoboMENK03Dd969MSLftjXve3L7LPGBAS/x9qBeGq8W?= =?utf-8?q?z25PQScH+xkS/G5QiZLMiJBOYm98MxLJBx15jTOEQc5hOq860u7YiFWyfeo2Id2bO?= =?utf-8?q?mxpB0rj4wK7QqVEjDaCkNGVXN0XbuNDu7i3Zf8gFDCG4gOL7lmIM+D7H/ft5IVxls?= =?utf-8?q?0fVzm997cvivvlIaiEaa4PBx8++PdkBrzttP59Id8AVMrlgdzCAsRE93fjBE0rA+n?= =?utf-8?q?m9eWXA+0yTo2TgcTAODAcBemR9B7F+1+I0kw+x47vSrVYVnfojx9XviBHYcZOBSoB?= =?utf-8?q?+UOncCQv0mQ0TbCWD0VRSwZq+P+WiaHCOTITyVDdNJnY+B3nyCGRltw9xVNXH33bX?= =?utf-8?q?/7LYTjAHUOXxSNgxkoXySUeL9ATUoOJGRDHbNgOOuAg1W6cMlR/UqjmMkcXKbuAPI?= =?utf-8?q?QaYr+UJmsmnYG99Ttcdiz9EUkBl2gnrJX71+v6FyQs+hntf7FWCK6cii+40kmRVXE?= =?utf-8?q?DvJXyZSW2VNNZapoUneWnWth9WEGdpU2Jbx8jF09qi8DFAA89rosbNILTkgaZ2oyP?= =?utf-8?q?YM3retdetXY+SDTDgdezLR1lerg44hUQQI4eq4rItY7+jV5R0/nOTmcYJ3viQgAUW?= =?utf-8?q?t+mn12zHgsLCuOtOwbDk0Z+c9OtFoWkJXg=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: a7oRsqiTtLpHyUjhSWAx1fDVIHVCIh+iIMgQptVo+LQ3Nt7+geWF8z86pqocBAh65/BIvLgoIZpP/E1/q/ebOctgND7a3n51bKGlpwmHhrDqS9CTRFC0dLujHuRc0j23bYZhb0GmkVp//XeokCrBk+b5SN91S9H4E066zReMRhhU5nqntiYe33qGPwJtRrnO+yTPRQ56M9j0TU82XFA6YKp6glYFgPKhu0DyxuQt3X9UNl4nhD1MCMq/a9QpQ7H0RPgOOH8rfLF4Iitx1RFsifydxAAeGvvIDgd0gBRcziJZo8NFG+xQRxKQf7+PeCN8r0fIADrw8cIk1Q0qJXqnDVBC4IZNTqcWudiKZmO1KV6AVO0lV1gTJjlz3yqmJjnU8F57x3PcqpELoLaIt+6SA89N820fO+gRsh7k+4oTUK5rGmqFNUjruqGuxfbGnveSALA4ES4ui6N4BMDituaCcr4PMLNex5a/MPdCAnycIbyCaXIJNcerS/Yj9Gqz2aRdDaaUcwbKbDzxl1oubPvP0YHotWbmtzDVkfZ6+i9Nyy1v27WQLFgrUPEvL0eso7J/wKGhNlVAL6BKfSm5c6KSdQLPCzIfuN+UgMyrw5iwwLdIY/mQnkMB4nkZ1JTsispKfJl4foKOmFhXpMCIn8wsEA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:53.8561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e907f289-0d7a-40c2-b213-08dd0a865bdb 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: SJ5PEPF000001D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR19MB4918 X-BESS-ID: 1732232636-102903-22458-23775-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.57.48 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGFqZAVgZQ0CIl2czU1Dw1LT HJLDElJdXSxDjZyDw10TLR0DDR3MBUqTYWACnVpbpBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan17-84.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 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 649513b55906d2aef99f79a942c2c63113796b5a..fd8898b0c1cca4d117982d5208d78078472b0dfb 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -29,10 +29,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 b38e67b3f889f3fa08f7279e3309cde908527146..6c506f040d5fb57dae746880c657a95637ac50ce 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 Thu Nov 21 23:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882455 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 4B0791DE88A for ; Thu, 21 Nov 2024 23:44:10 +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=1732232654; cv=fail; b=mgVrVMWq1TLuX06/X09ft1F2KjFtluEBWzKER1SeVR6Vk3H0DeuyFMadSXjJXWiow21op7VtWLZvYZcBxlRgRbOBrV1MeCfqx2sFSTxPB+2IpfooYrVffKyaqEgNFcxdWNxF1mlXRvMZY+RoNvRyYlufDGRgsVg9cLFHBvX6ZYw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232654; c=relaxed/simple; bh=LFN5iHBpQL1ZELcsQiNVADSnkWR8kAU4UAejqcRjIy4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=msfIp8rUk223/4lQsutojpvmAQeyboKitXV8V4JDK8gG8yYS7yD6WYTTFotIBnawufSfgAOU0Ustl8Cv/jWEz6QIn8QQetQkZhVbRpMTw29681LaPAUboIKaYLbiBappaPk/vpQYxppLPsVEpyuyFC8+MR34+FSgFMB6vFON5uo= 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=mSg+RKim; 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="mSg+RKim" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx-outbound13-231.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:43:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XZqegilG728F8BXJdVpftIBaMOSySjlZrulBziwodEIIBwea0ak6NsLnMqR5606PQ1XFic/iNhtRFiLN9WuVcbfktv4cOXLclQ1LFi3uLCFaECeedwDel7xjD0paGHct01rlKMyZkO6oGmH8ZRdZU8YFDElDzwQsaNWqVBI1lFFwBZpe6MTg/6L3afWbQXUD56S1bD5cT6lDVPgkfD/2vZ0f5XmutUlF+thEGOhAlZRkbKQs5oRbInHtG9Wk0o/CSne5Hv6lxQkAuWm9gX5E0Z8PMcK3wd2M/vHFS//nX29fpMD7toeKHfoy6tEQWk0r6Q3RGXSsWq9J2jOIoquF2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LHa7n4UGF0oKchdUGLawEi6S0wIRCEXCHai9Y5sQ2zM=; b=zBhcEOsLsHcYkChJl5esjtXBxYvp2FbSWyqA2e4gVIzXBVYZuccLvKMXDOplYVIlYbwdj+Esy32ocIXnDnNIQef6rRFluIWbtK52eaHTMzA9evE9wf0stmFwJdLIxDvgYeSAuqANlL0KX6ghPkfGr7E4knxauh+Jbys/oK959lHGT7yUlQ2ndcv3Znjpzr9U23b5SmQFsCzzEekqF5aelVzcqFceZXyOEiDk7v7w9h4XdMQrRHsKk09zi66kAj+WRe1HAPV5uxI47okahzaLssI80r6KQ11ypqoYR+ZfzaGzMYlk+If9YFHzfU1Jj4MixdLEFUvI6iNXA5MzqE+0YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=LHa7n4UGF0oKchdUGLawEi6S0wIRCEXCHai9Y5sQ2zM=; b=mSg+RKimF3SYVcdQHxwtP4Wftm2NRSnWafpEvZfc8eR4Wls2jzKwyQq+cKMcEqWxt5u1iNbrobIw/uxg8IOvHQw77TiDqZpE4Tq2a1/hvtqs7H4bLLO8M1ipiQrmVWls8Ipwczs7c8S4fYHm6MoAlIIWhv2R5RgzHKjI7348erY= Received: from BYAPR04CA0019.namprd04.prod.outlook.com (2603:10b6:a03:40::32) by MW4PR19MB7053.namprd19.prod.outlook.com (2603:10b6:303:22a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Thu, 21 Nov 2024 23:43:55 +0000 Received: from SJ5PEPF000001D0.namprd05.prod.outlook.com (2603:10b6:a03:40:cafe::6e) by BYAPR04CA0019.outlook.office365.com (2603:10b6:a03:40::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 SJ5PEPF000001D0.mail.protection.outlook.com (10.167.242.52) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:54 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id D60FB2D; Thu, 21 Nov 2024 23:43:53 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:20 +0100 Subject: [PATCH RFC v6 04/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-4-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=4808; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=LFN5iHBpQL1ZELcsQiNVADSnkWR8kAU4UAejqcRjIy4=; b=ImjyiZYMgxNFgKAHWb+Hgf03yFzCrR6vM4RZCbRix6+4ARSQ+QDqWRTHhtn3kCvBxibSrmzHn gIoYh7d0byLD1fPE1gxUUIW8KasMeC0cKdSLlkKp2KSuJWScOpHu3md X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D0:EE_|MW4PR19MB7053:EE_ X-MS-Office365-Filtering-Correlation-Id: 155f6767-647e-48b3-2026-08dd0a865c6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Je6k8hHOTyy2q7AeUfNHdSm+yAjQP3U?= =?utf-8?q?lS+L36bWw+oKFILFuHxbPe7FPZz6GFG5WudX9CLOM9Fe+Y1tTbQlMBE7SUAVdAi9L?= =?utf-8?q?WVBzsKJsyrZ9h5tZptJbEr2WMT3uOU3WBVihdwqWBflP3s3PsZK0vl3qpiOViWVF7?= =?utf-8?q?gmbAVmTgQMRSKzaEy1u9l4tjVRbpRT9xoh0577amnZRY8ASEWt6Vbq5h/fOgmVLXS?= =?utf-8?q?rmeG+lbD+z9KzaGLXYgB+6SdYl3y7kKYBikOnbtnU4T0+Ff0xC9YxGDc84Zm0FJuA?= =?utf-8?q?56XYjaEYBEAI2JRl+X/UBs7H2YJKuleGKLaHtKQKFQs0f9gDp5vSZKzOh7SHsjk92?= =?utf-8?q?lAto/nBYQOvh4yX0mw3ofDl9WbO7inc1oOB70HAzXAb2KD42j/Xq4WZA+Yu54sgka?= =?utf-8?q?um1xR6zY1FZEcPcsgI+YLRh/920firPr3QVLebO7Pf7vJDMyYIEX9cB3AcwObpqIe?= =?utf-8?q?sKI5qsy/vjBjtDeVDv9cNlI3Rcq/mm3fKqhtVsd8C5cLgnWczBUsWCSrwNH5dS4SZ?= =?utf-8?q?eNdUDPCPuGLPliqKVnkh0dIYIqBqqHbBlusLTP+SALJ8mVcVBZiH3J2aBakYzHWpg?= =?utf-8?q?XovA3KAaWRhFbp9qKbkLdvZaSOG4JYgAKi40hQzIk/skEXQWC7WQ/XqcaOGIsBV20?= =?utf-8?q?LwB/YHn5aXC11F7UXZYBH58UTzgbvY2cdFHo97QP/o6z/1z2ziGAETdi32fmJHJvw?= =?utf-8?q?/9B1LLv2TJRjEkgJr9iQrMjqeSTanefsczuXzUAlesBGfnIhgcE45zdAEPH+/Nw02?= =?utf-8?q?SwFjFNRXO0VN1eDkUz8bDnbgfXKhZ6NMmsVUE97e1E1520bBisY1muBj8g6YDGBjw?= =?utf-8?q?Ms4pB1LsMgyJ5CEqgKEuvgt9ye3XNnzoz+17VYfnWCz98QvoNYEOoKNXBzEbd7N4j?= =?utf-8?q?9tkhlrd1hlxRHNPgT/ZhEVprYgA5MMTkF0hmnWgcZjVM1Hs/T+ToM3H9wrSdE7jLV?= =?utf-8?q?zgNSn0XrT5L1OsYKbvS6gKgBt0FIMyGrRBr7s2gY8KY1zOxbFd7TZ3BVw0Qc4hjjg?= =?utf-8?q?BAjjk8Y5EC8c1Zbs9wdHr52s3m+xiSSkZuzXPeTDMHjTUCS4zbXN2y98oBqX2Jigt?= =?utf-8?q?nds5AIl3uwgrVw7CiZw8GaWHFRG12lOrKkvNORx8RanzDqXUw3dipmbWB5z/KuaJV?= =?utf-8?q?veAYoYQSH5KjQoJZs1JHo5D/DRtnYZ5r551Ec2jM10AUtv0Izdw1cSfJNwuFkPWBw?= =?utf-8?q?uubt4qLpa9zyzMTo/iORWsRZso0cuYS2F1mZ0n/OIaoRbQZXGEn4+2uRVISQhdRm1?= =?utf-8?q?5qDyiRFhfgDPnfIKnF4SXDz+8pKxJJHzNdWjt4SsXR/UmWhwxIE6/r7bkDgOqwZaS?= =?utf-8?q?BTw6mzPGA2S6wqID7aPLyroJLvDS8OrCZg=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IsXBo779Zz1F0gVLq7yd7+3GsHCsGEXK0NsL/AxK55l5fdlTuHT5xyaIF2qgrhtDDPyqDJIqyloUVSrjU3QdhxbBWoqGV5WOoBIe4CHjNsFtrUYYl4QeaWZuVqceQwmKqSt1Pi6cOu2hZPVxlpFUk1RSYmAWQsTbHc3NABWucMLl9vXUorjaDE73ip9KE08l1xwJGoEI8CXtt3Wa+uBx6LutDNyJDxvk3pWkpvvobQi3VK1TCGOiglg3XMXwZdhjwnLFl7KcLkUUXXBqWHlUDkg8DvA4+hTgOLYZ65KVO61czsdVgU8K5/X+YivbALv7nEYj7e7MRy4/BMz3xrwet1+D4ttyv4M7Vh50SU5sa7pMTtfg4oNcpWRhBsrHRcZGGialqK/owKQcmpYGMxpc++TvwwJQeHPR0A8HuDWdEkBdUWvIuScODd2I+n8C7v83a5nGcexjexDrsLG/nt7woobEU6Y3vAo+cLgwgnyQUldbVWbbK5Fu+oOyaNu0B2Iw5RZ5tH2xBQ8rym2KENAlstR05rNuK3bnrHE3S5eA5088uiBkxJi8x7d6FFbRW5fGFFMzfch7Qy3VGQwDAb6eMpulP84FWQG9ZQ+/8GZ7IoC+Wo3pHp3aV34IGks/m6DOMyGmyenlXxnyn8HBV9D1pA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:54.7739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 155f6767-647e-48b3-2026-08dd0a865c6a 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: SJ5PEPF000001D0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR19MB7053 X-BESS-ID: 1732232639-103559-13385-21684-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.58.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViZmliZAVgZQ0MLE0ijFNMU8Nd HA0sjQ2MjcPM042STZzMTIIi3FKNlcqTYWAKwEH+ZBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan19-61.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Signed-off-by: Bernd Schubert --- Documentation/filesystems/fuse-io-uring.rst | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/Documentation/filesystems/fuse-io-uring.rst b/Documentation/filesystems/fuse-io-uring.rst new file mode 100644 index 0000000000000000000000000000000000000000..50fdba1ea566588be3663e29b04bb9bbb6c9e4fb --- /dev/null +++ b/Documentation/filesystems/fuse-io-uring.rst @@ -0,0 +1,101 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=============================== +FUSE Uring design documentation +============================== + +This documentation covers basic details how the fuse +kernel/userspace communication through uring is configured +and works. For generic details about FUSE see fuse.rst. + +This document also covers the current interface, which is +still in development and might change. + +Limitations +=========== +As of now not all requests types are supported through uring, userspace +is required to also handle requests through /dev/fuse after +uring setup is complete. Specifically notifications (initiated from +the daemon side) and interrupts. + +Fuse io-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 fuse-server (user-space) +needs to submit SQEs (opcode = IORING_OP_URING_CMD) to the +/dev/fuse connection file descriptor. Initial submit is with +the sub command FUSE_URING_REQ_FETCH, which will just register +entries to be available in the kernel. + +Once at least one entry per queue is submitted, kernel starts +to enqueue to ring queues. +Note, every CPU core has its own fuse-io-uring queue. +Userspace handles the CQE/fuse-request and submits the result as +subcommand FUSE_URING_REQ_COMMIT_AND_FETCH - kernel completes +the requests and also marks the entry available again. If there are +pending requests waiting the request will be immediately submitted +to the daemon again. + +Initial SQE +----------- + + | | FUSE filesystem daemon + | | + | | >io_uring_submit() + | | IORING_OP_URING_CMD / + | | FUSE_URING_REQ_FETCH + | | [wait cqe] + | | >io_uring_wait_cqe() or + | | >io_uring_submit_and_wait() + | | + | >fuse_uring_cmd() | + | >fuse_uring_fetch() | + | >fuse_uring_ent_release() | + + +Sending requests with CQEs +-------------------------- + + | | FUSE filesystem daemon + | | [waiting for CQEs] + | "rm /mnt/fuse/file" | + | | + | >sys_unlink() | + | >fuse_unlink() | + | [allocate request] | + | >__fuse_request_send() | + | ... | + | >fuse_uring_queue_fuse_req | + | [queue request on fg or | + | bg queue] | + | >fuse_uring_assign_ring_entry() | + | >fuse_uring_send_to_ring() | + | >fuse_uring_copy_to_ring() | + | >io_uring_cmd_done() | + | >request_wait_answer() | + | [sleep on req->waitq] | + | | [receives and handles CQE] + | | [submit result and fetch next] + | | >io_uring_submit() + | | IORING_OP_URING_CMD/ + | | FUSE_URING_REQ_COMMIT_AND_FETCH + | >fuse_uring_cmd() | + | >fuse_uring_commit_and_release() | + | >fuse_uring_copy_from_ring() | + | [ copy the result to the fuse req] | + | >fuse_uring_req_end_and_get_next() | + | >fuse_request_end() | + | [wake up req->waitq] | + | >fuse_uring_ent_release_and_fetch()| + | [wait or handle next req] | + | | + | | + | [req->waitq woken up] | + | X-Patchwork-Id: 13882456 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 3DEFC1DE4F0 for ; Thu, 21 Nov 2024 23:44:09 +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=1732232654; cv=fail; b=rIMG2HMe3vk7NJyz7o/OfFc/RFVFoAuv9EHJKWFaGJsYiCGNwIiMOphpOhRSPupeaIx/Y7/mArtJQEWne0GdXsPOjIRgtiqkLacVP5GVeVDSsudpTyV2ZCw+ItFQ+ogyN7hDU3ulJ2I+o5gdcIMnADVlWhWhAtbBceSjJbFfEBU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232654; c=relaxed/simple; bh=9nUysfJUfbYWnpD6A+/FByuJ1TitHWotQTdkRx7URnI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IDubnQGNBDa9lV4YwrNFj/z5B3nPhecxmSgthoeCq+ZUs50tj4XstHHjCXci2Mm2pX35EOndH2PWca9rAhVEWyucqgNYTbGC7F7Ahflqv/OyvG96EjM8D0E4YI7IRhkchc0cRL2+2iVbzm+kiu1tlR10UKsmlzGQpjylgSkxm40= 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=oEGM8LD5; 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="oEGM8LD5" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx-outbound20-133.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:43:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tz3eusSambYjmIbTLDA1mizWmlAgNO12cGEGzsS0Q1jIx2160XxM2ae2nPT/ETwrvyoFOzk75UHuM+HQBW+KYlllL3QEtu2vBaBIJBoX6K+9rTBUiAn4TQ8uXLLOMOow9ekYFutA18/X6lphgkg0+/Q/7/NvncZqHspYNe5P8K9jiv3gjV7R8syNTtKKTmTl2gGqGBPUcJXvTIL/8D/F2gZrkqmQqfoI1VISNvItoUv7/tKqpcBXzCXF3ls6fTArbLYofwK+MiLWjj/lXMo4k6nsn6ACraTGVJaQ9eco/Uwd7//zk/n8VwdE/HTUZ/Mb6qs878e4WA9F/08b59RBxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=74kXzFNgXKq9vGFv4p3Y9Rxl5krqWGxnaq50CydloCo=; b=Eaiv00qdJW4745mS5p/4GYD4PaTisVmXztc39mg1AZqeTqvrBmbqW0WyXalSsrGXNwhxBuG++VxCajoDa2M4MGJRaIZ2aMBzRLOgshmL80c01YzpYxb/efrLBXH4ZyuNcySRpifhE0hqai2MTMgHvmzX9O6zbJmLHwpMWXTwfShpp6zqfuZW5NP/Sopcq1GVukD1c4sHYi8tMydrMiD4/t9EPWo8MSaFJRhprTqeHtAh125Fg9Zk7yKAU0C2ZaUohKsCzvLvzwc7dVb5OHogUDE0uR7BPpEObeG82h1xjU1AhVlrqHQ5CdNnkUsvtr1ptZJcmCwti9k91r2RLoHzaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=74kXzFNgXKq9vGFv4p3Y9Rxl5krqWGxnaq50CydloCo=; b=oEGM8LD592MzVRDrJhSLlk/rzjypDylcPVFAnUhLA6MJ0GABTp6J4d1UOkj5coCu2mJjVfq+zjW5CAMz6Y/1vBpTyjGDvJjSklJnjZJSsRy3k243yhjULqVwXdkKACEUaF1KJZCSxunXEuloPvwu3wQDrtqbDvYgMQ8H2fbyii0= Received: from BN0PR02CA0035.namprd02.prod.outlook.com (2603:10b6:408:e5::10) by SA0PR19MB4382.namprd19.prod.outlook.com (2603:10b6:806:90::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 21 Nov 2024 23:43:56 +0000 Received: from BN1PEPF0000468E.namprd05.prod.outlook.com (2603:10b6:408:e5:cafe::2c) by BN0PR02CA0035.outlook.office365.com (2603:10b6:408:e5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 BN1PEPF0000468E.mail.protection.outlook.com (10.167.243.139) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:55 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id CEBD532; Thu, 21 Nov 2024 23:43:54 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:21 +0100 Subject: [PATCH RFC v6 05/16] fuse: make args->in_args[0] to be always the header Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-5-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=8701; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=9nUysfJUfbYWnpD6A+/FByuJ1TitHWotQTdkRx7URnI=; b=hGFVLgMRV1e+kbc1b77p7PqP+IN2hcbVTzIII718GoTe5qaXdpM63xU7sLrvCV8LUiLV9/3Rl 0LUXP0HWuHVDaptfqaNXVyzvgxEbboKjyhh/fUgVb6L/JEA0aD0mnh0 X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000468E:EE_|SA0PR19MB4382:EE_ X-MS-Office365-Filtering-Correlation-Id: 93b811ef-6573-456b-cd0f-08dd0a865d2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1eRwYeOFJrVMyFh+3y42b8QhzacIVxo?= =?utf-8?q?Wh/Qi6Sn1nfJCJ6LzbcNkfIIFuUK/Vd7+a7rS0BfGkg+yC9A7CYV5v9E/gRT3+TZS?= =?utf-8?q?x51recEumTGqMujUbaS8glJ0UBWuHrCVet0XN10yZp9TAeBn5IKxdK4fWuv0HEU0m?= =?utf-8?q?BhH1QDToDUsafou9NT+qm7uR+grIYAcXjDwuHijcMXiuar/vfmMHoAY5/1RAlD+7p?= =?utf-8?q?rCyO7jyJqeQRpfYYGoS1830cTM+ff85uuJgE51RCFtCxR7D9C1g6SI4htGmx+e/eK?= =?utf-8?q?iEpTP6TQFBRbHt8nQ0bWQ2fj8coa+bSJwVZkp4lp4Pa4F+C345HtEbfKAbEtqWpNp?= =?utf-8?q?m7hC9mp1MSJsT7PUNmbSSdGpX4ETZCjGiyeBZM7tYs0OoagCxxSCOAgGe6T63xhTo?= =?utf-8?q?QU1CDK6zT/MD2tp8yh2O861RvsKwGTBpFKPJ9mYlq7GbH75ol4noaFgwvs5dwU63g?= =?utf-8?q?I9JuflCN7PcITJCutIn5ywhMuhwuFuqhycBJ9b3JqMKkKB+CAmqtzTkvnWZCTxWp4?= =?utf-8?q?gXcCTKk4VW+UBKCZTvHF7cg7Gr5x0ldvsOEsOyQnLrl1zDciqFVpej4S46pYzxIme?= =?utf-8?q?xP42GQarUBzKWtxT2d1qFOj9mxhrZIHspUyZbTmeWKE7gzskXO0ZlY+O2E5Q334Oe?= =?utf-8?q?d2rLVRlorhz2K5ZDwh1cEbCIpIarHu8BEIwzthFog2O6xnuruDPqqPl9q4L+SRyAK?= =?utf-8?q?ic3570y9Nrnb8ug4pxFpKUUUtIqO0vljtmSPJrB+ojNHVSSNtkxqmxxKxrSexFh8Y?= =?utf-8?q?TdwrOGB7br2DLSKJ/T6AbhNumMEBIs3oRMmj3txl6K4rVeWLtC3BV9x6tP57h5K+p?= =?utf-8?q?EpjPdC+Tcsdj1vXu0yO490fu7BJWcNIfJlDUObPFD7Rlv805bIpNKbE6njRF6seEb?= =?utf-8?q?rRf95WJAHMF3hAqHZMziQP3uhL1WA/GrCzXPN82qpauHiNnm9EGziJsLVNcOctJ3c?= =?utf-8?q?DqNPpWVL6jfo6LopvdoO0s5mKf1jKawc6ZRXsZa4IiZL9K64LaxO9ov2MiMXqHy0p?= =?utf-8?q?C3iaM3gS+sXABQZ6hmxhjluV2lHTbT9EYG3fMtEfHe+jqBAbriJ8Tb5I8qImqItA9?= =?utf-8?q?OkwiTX0SC//sO0fElN+Rh56oKmR8XU8ltsZVlKJertl232WsTyLmQW6sLnB95nAP+?= =?utf-8?q?NjgJh5y2xf6rCoGnLxPiKBNAqnbFhgUBLMc5l7QsTvmw5O0xL/KWHxuXhE6IWQduW?= =?utf-8?q?LQwwSKXpjSHDCPkpvJXF5ieYp7O7ntpZLN9INxvWNJprejVafukh4BKFfM6Wq36bA?= =?utf-8?q?tyGHKjC/Os/Zl3C1wJ2pe1kXmc3wPBRu0NIlNILHR9A9RvsqBn2KOErQ6qkK66FtH?= =?utf-8?q?bSTy/IMgGQ6u23ovZbEaYMMwmkQZCcImlA=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nVwDaZmUEhwUt/9VRqb2xiII3GplHLwiJAtqMd6wlIOEc49pZFIZCK4A5HXzCFwwnyFMLxJHOZuY4Gn1gDSeHBBBbqCzP21cLso3oCIEeviok3WR1z4k9qVlNqd2HDvwVPbtO4CKg8bWBBdF+Zy3qc4xBq3hALewGnL5zfh5bMmSdDELX7rWfo5tZEvd14QB/PzlyoxYJq6PUx0FI86ID0NQDxAeyibv0Hm/0SaYrqfyL0i/vicAYeNGE5HliWstaFxEWpmP1p1RygfPUTXC9Kevi2BOMORJnyJIiBa6EctZVWWO4QUDOsI+1OHRkmvryCT4mwDMiB3TBrEcF/QCMmahGYdsfn81fR1FMBaT4eJc/ED5UjrOMBce1vplSZIoNhVlX/X1NSM4djKv6gHvKfT3gLHczO3E0YSDoml7AP7sgfGnJfmRJ/uvuE0feAOQuWAzexeaK8CQTefVWAvNExG/TO/6i8eim0xKXlFeKenckEYWJj4zcf5AQCTbUFugxZ+JWZ6dn2od4NMA5S6dVGsfh0GHMboIFaSI2mkkr86zLchRPJuAwu59PJ6RMwsu3NeMycyK2CGA0Duh1PbdrAr5LiXstZlOnqlg4+YxT27JEERHHxM8xDWnxttcaDNjzAD2T4I7bpNSjpWaQOLRaQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:55.9025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93b811ef-6573-456b-cd0f-08dd0a865d2b 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: BN1PEPF0000468E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR19MB4382 X-BESS-ID: 1732232638-105253-13353-45917-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.57.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhYmphZAVgZQ0DjNLDXF3NA0Nc 3S0ijF2DjR2Cg10dgi1SLZNNXEJNVYqTYWAM4sfFZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan16-35.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 change sets up FUSE operations to have headers in args.in_args[0], even for opcodes without an actual header. We do this to prepare for cleanly separating payload from headers in the future. For opcodes without a header, we use a zero-sized struct as a placeholder. This approach: - Keeps things consistent across all FUSE operations - Will help with payload alignment later - Avoids future issues when header sizes change Signed-off-by: Bernd Schubert --- fs/fuse/dax.c | 13 ++++++++----- fs/fuse/dev.c | 24 ++++++++++++++++++++---- fs/fuse/dir.c | 41 +++++++++++++++++++++++++++-------------- fs/fuse/fuse_i.h | 7 +++++++ fs/fuse/xattr.c | 9 ++++++--- 5 files changed, 68 insertions(+), 26 deletions(-) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 12ef91d170bb3091ac35a33d2b9dc38330b00948..e459b8134ccb089f971bebf8da1f7fc5199c1271 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -237,14 +237,17 @@ static int fuse_send_removemapping(struct inode *inode, struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_mount *fm = get_fuse_mount(inode); FUSE_ARGS(args); + struct fuse_zero_in zero_arg; args.opcode = FUSE_REMOVEMAPPING; args.nodeid = fi->nodeid; - args.in_numargs = 2; - args.in_args[0].size = sizeof(*inargp); - args.in_args[0].value = inargp; - args.in_args[1].size = inargp->count * sizeof(*remove_one); - args.in_args[1].value = remove_one; + args.in_numargs = 3; + args.in_args[0].size = sizeof(zero_arg); + args.in_args[0].value = &zero_arg; + args.in_args[1].size = sizeof(*inargp); + args.in_args[1].value = inargp; + args.in_args[2].size = inargp->count * sizeof(*remove_one); + args.in_args[2].value = remove_one; return fuse_simple_request(fm, &args); } diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index fd8898b0c1cca4d117982d5208d78078472b0dfb..6cb45b5332c45f322e9163469ffd114cbc07dc4f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1053,6 +1053,19 @@ static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, for (i = 0; !err && i < numargs; i++) { struct fuse_arg *arg = &args[i]; + + /* zero headers */ + if (arg->size == 0) { + if (WARN_ON_ONCE(i != 0)) { + if (cs->req) + pr_err_once( + "fuse: zero size header in opcode %d\n", + cs->req->in.h.opcode); + return -EINVAL; + } + continue; + } + if (i == numargs - 1 && argpages) err = fuse_copy_pages(cs, arg->size, zeroing); else @@ -1709,6 +1722,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, size_t args_size = sizeof(*ra); struct fuse_args_pages *ap; struct fuse_args *args; + struct fuse_zero_in zero_arg; offset = outarg->offset & ~PAGE_MASK; file_size = i_size_read(inode); @@ -1735,7 +1749,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, args = &ap->args; args->nodeid = outarg->nodeid; args->opcode = FUSE_NOTIFY_REPLY; - args->in_numargs = 2; + args->in_numargs = 3; args->in_pages = true; args->end = fuse_retrieve_end; @@ -1762,9 +1776,11 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, } ra->inarg.offset = outarg->offset; ra->inarg.size = total_len; - args->in_args[0].size = sizeof(ra->inarg); - args->in_args[0].value = &ra->inarg; - args->in_args[1].size = total_len; + args->in_args[0].size = sizeof(zero_arg); + args->in_args[0].value = &zero_arg; + args->in_args[1].size = sizeof(ra->inarg); + args->in_args[1].value = &ra->inarg; + args->in_args[2].size = total_len; err = fuse_simple_notify_reply(fm, args, outarg->notify_unique); if (err) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 54104dd48af7c94b312f1a8671c8905542d456c4..bea9fba2b1473750c70a1c336d695c5c205d9c07 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -172,12 +172,16 @@ static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args, u64 nodeid, const struct qstr *name, struct fuse_entry_out *outarg) { + struct fuse_zero_in zero_arg; + memset(outarg, 0, sizeof(struct fuse_entry_out)); args->opcode = FUSE_LOOKUP; args->nodeid = nodeid; - args->in_numargs = 1; - args->in_args[0].size = name->len + 1; - args->in_args[0].value = name->name; + args->in_numargs = 2; + args->in_args[0].size = sizeof(zero_arg); + args->in_args[0].value = &zero_arg; + args->in_args[1].size = name->len + 1; + args->in_args[1].value = name->name; args->out_numargs = 1; args->out_args[0].size = sizeof(struct fuse_entry_out); args->out_args[0].value = outarg; @@ -922,16 +926,19 @@ static int fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir, static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir, struct dentry *entry, const char *link) { + struct fuse_zero_in zero_arg; struct fuse_mount *fm = get_fuse_mount(dir); unsigned len = strlen(link) + 1; FUSE_ARGS(args); args.opcode = FUSE_SYMLINK; - args.in_numargs = 2; - args.in_args[0].size = entry->d_name.len + 1; - args.in_args[0].value = entry->d_name.name; - args.in_args[1].size = len; - args.in_args[1].value = link; + args.in_numargs = 3; + args.in_args[0].size = sizeof(zero_arg); + args.in_args[0].value = &zero_arg; + args.in_args[1].size = entry->d_name.len + 1; + args.in_args[1].value = entry->d_name.name; + args.in_args[2].size = len; + args.in_args[2].value = link; return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK); } @@ -982,6 +989,7 @@ static void fuse_entry_unlinked(struct dentry *entry) static int fuse_unlink(struct inode *dir, struct dentry *entry) { + struct fuse_zero_in inarg; int err; struct fuse_mount *fm = get_fuse_mount(dir); FUSE_ARGS(args); @@ -991,9 +999,11 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) args.opcode = FUSE_UNLINK; args.nodeid = get_node_id(dir); - args.in_numargs = 1; - args.in_args[0].size = entry->d_name.len + 1; - args.in_args[0].value = entry->d_name.name; + args.in_numargs = 2; + args.in_args[0].size = sizeof(inarg); + args.in_args[0].value = &inarg; + args.in_args[1].size = entry->d_name.len + 1; + args.in_args[1].value = entry->d_name.name; err = fuse_simple_request(fm, &args); if (!err) { fuse_dir_changed(dir); @@ -1005,6 +1015,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) static int fuse_rmdir(struct inode *dir, struct dentry *entry) { + struct fuse_zero_in zero_arg; int err; struct fuse_mount *fm = get_fuse_mount(dir); FUSE_ARGS(args); @@ -1014,9 +1025,11 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) args.opcode = FUSE_RMDIR; args.nodeid = get_node_id(dir); - args.in_numargs = 1; - args.in_args[0].size = entry->d_name.len + 1; - args.in_args[0].value = entry->d_name.name; + args.in_numargs = 2; + args.in_args[0].size = sizeof(zero_arg); + args.in_args[0].value = &zero_arg; + args.in_args[1].size = entry->d_name.len + 1; + args.in_args[1].value = entry->d_name.name; err = fuse_simple_request(fm, &args); if (!err) { fuse_dir_changed(dir); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index e6cc3d552b1382fc43bfe5191efc46e956ca268c..d9c79cc5318f9591c313e233335d40931d6c7f58 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -938,6 +938,13 @@ struct fuse_mount { struct rcu_head rcu; }; +/* + * Empty header for FUSE opcodes without specific header needs. + * Used as a placeholder in args->in_args[0] for consistency + * across all FUSE operations, simplifying request handling. + */ +struct fuse_zero_in {}; + static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb) { return sb->s_fs_info; diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c index 9f568d345c51236ddd421b162820a4ea9b0734f4..c26afacbe53c1a164e27d6253360e0e1808e2ea6 100644 --- a/fs/fuse/xattr.c +++ b/fs/fuse/xattr.c @@ -158,15 +158,18 @@ int fuse_removexattr(struct inode *inode, const char *name) struct fuse_mount *fm = get_fuse_mount(inode); FUSE_ARGS(args); int err; + struct fuse_zero_in zero_arg; if (fm->fc->no_removexattr) return -EOPNOTSUPP; args.opcode = FUSE_REMOVEXATTR; args.nodeid = get_node_id(inode); - args.in_numargs = 1; - args.in_args[0].size = strlen(name) + 1; - args.in_args[0].value = name; + args.in_numargs = 2; + args.in_args[0].size = sizeof(zero_arg); + args.in_args[0].value = &zero_arg; + args.in_args[1].size = strlen(name) + 1; + args.in_args[1].value = name; err = fuse_simple_request(fm, &args); if (err == -ENOSYS) { fm->fc->no_removexattr = 1; From patchwork Thu Nov 21 23:43:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882457 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 2A15F1D9324; Thu, 21 Nov 2024 23:44:09 +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=1732232654; cv=fail; b=eIK2qFJVD/DAB/3iYLR5tXAOXGBt6VM+HdyAVstojdOd84vjfOt2sQN2rwvzwRein3WmRdpSD6JpZAu88gIAKpNj6tKpbp69QQgbscx6tkHThXrjyH+F4C+axCnZs/fWQ9MBEvz/bq7dizgrKTLAoROmVS8j/3qJbqDCAZ4EIb0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232654; c=relaxed/simple; bh=hHIbt6kUTJcNo1h8PKVWdB/7uc2niHFVNzyHIghBQ4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KUjS+wDurN/8CbGJ8SyoCL8KOs8cetp0tf68saqoMiZNiH89vbBsQa+ZDhWPFLljLv+G01CHAJm+MVKEJuFDJ7qj/Lq1tCLSCnedWzg4V1lLgFB+aqN00tFzzPAriMMaM9ZPLOzvpmSsBfUo0xZKy/9kOQcH4PREheNEwO1Gwmk= 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=MsD1kFTX; 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="MsD1kFTX" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2049.outbound.protection.outlook.com [104.47.58.49]) by mx-outbound47-71.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eRonKsk4sh3JsuSfhd9ckwQ5jpGjVp98gcAKyAJEPvdRQyzYdpkn/mrFOPUOaWtVbG/n1e1niRs1LACMiHt4f2xPy1vyvqHJAz8GqKtV7KjrsynpAp1tth0MD6LOacZjwzznOi4cVDeJZZ02sU2dDGkqIc80TRKYhEZWtGNo/q6yuD5rR5LkbcCq5fScNgwLNJv5hEp1LFa+AYaqWhvWbGHgnX2edJddC55nqSL/xHNM2ZklB+ViXnuZ5AixwnyoKL3ZNbkbbJqaJm14ne/wu3tBw/pFLdS6RCDtqjlCBwTRwRq0YzJtBn73046ZWytxfP7iBFlbra8rb6akiOMs2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lpCM0cnd7z4dUwxOoylIpx1vAuZ+bcl4BQ4GDi1yQW0=; b=DFnFrj3rq1TK6gsznvmPp4Ot1J9T3o/K0xH6isxdolqXc/ujjLRvgYqz/chfXYVkvzbOGWZ2fjWhteDU7FEatDyKprc619wlGGCUSucptik7XKd2sWtiruERyEXSPYGQWf1BGigJDsob61UXruhxm6xsIoF8Pr4i91tEw/vGWyFLRymtIAzjJjQeyEjxybWc7AlFLXQZEAqjzBRzsfEu0M0FHxnc+ONZpYLk9hUFQGKVhoKQsPDjhva08BHzP06zi53Nuf/yBi6Y17AhO7HMxQPBGSgh2MlAH8b9bicyfVMe7u0k97whPvJLV6SKMzvdUrzAFFOGft6YwVlT4AMyUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=lpCM0cnd7z4dUwxOoylIpx1vAuZ+bcl4BQ4GDi1yQW0=; b=MsD1kFTXHSIqUTaGbb9VsQztiY28Nf9nJvPlymQmT2pfM4qJ21tlUF8tu1BrLrXuojT/pWMbs7lDtK4tM80R/1pLdLc2OnNkjCUqmvVKV9CZVB4A+yWxgSmYJ/hb7sAU+SEWc9z9W2MY9XjqUcsz31CVZUUv5zVLsODRuJvtnC8= Received: from SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) by PH7PR19MB7001.namprd19.prod.outlook.com (2603:10b6:510:201::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Thu, 21 Nov 2024 23:43:57 +0000 Received: from SJ5PEPF000001D1.namprd05.prod.outlook.com (2603:10b6:a03:2c1:cafe::5f) by SJ0PR13CA0211.outlook.office365.com (2603:10b6:a03:2c1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.14 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 SJ5PEPF000001D1.mail.protection.outlook.com (10.167.242.53) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:56 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id C6CEC2D; Thu, 21 Nov 2024 23:43:55 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:22 +0100 Subject: [PATCH RFC v6 06/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-6-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=16736; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=hHIbt6kUTJcNo1h8PKVWdB/7uc2niHFVNzyHIghBQ4g=; b=q9ArzBukrXUE/ImwUWwVmR6uPwF7Nn4412gg6wEt0qOjuEhO6FiJfA6+zoj87WvO/g4snpTA/ H/rPEF4wikRBldo6fZKy9z+jaYYuyq4z8wxds4uoULJeV2cH2So7q4T X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D1:EE_|PH7PR19MB7001:EE_ X-MS-Office365-Filtering-Correlation-Id: 1256a60d-90e5-43f0-e183-08dd0a865db0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?C/hq9RhspBgkhZbhCxwal+I2Lr+XAz3?= =?utf-8?q?k+j+l+6rLceCH2he5pL4GQVJWUpbEfg5KW4brcb08iJSARGNe9ra7nLTllQGdMJW7?= =?utf-8?q?WUiSys+k+tctIy+7L/vj35wm93ITNVx9wU1ZAp4mBGMUfY2xrDnR8A4PsvsERBI+l?= =?utf-8?q?cPbDKBlWBxKnY2R6t7S9WZtzljbSAGW3uhO1ci5zL4ma03if9n7JJoYg2RxXGw6dC?= =?utf-8?q?MBOGw4S1y/yDWNuawDlZanUvMiyP4UhVw4GxfSk2il7dbFayGMzflDg/sENQ8BgYX?= =?utf-8?q?zB32n5FHJQnNs9axspuI8gcm3QPkCSslWYN6wHTtW84yB8QRaGnTnjtoGzMj5tfWU?= =?utf-8?q?dqoEWoHjOOoLQn6dtRHz/igXMkCk5rVPc9HPdrYuZMc+PQ9VDTyydnQeB93Lskm/c?= =?utf-8?q?kcQhGI7jCX/ZBf4zT7QoABOO0zqeBxgJof5kkAUsmSN2QwKAP3Eri/ECvPOS5SfT8?= =?utf-8?q?c9LqGpYh8OfwqxuUmCVZUd9SqMW7ZzHWJXZD+10VJXIerqGarhRxXn6xa+Vepogzm?= =?utf-8?q?rZlbMjuc8SzEeWQFoMR//JM+MK78SeoZgEmp/xCCujoYNieO2H588W0d3baOYa+Z4?= =?utf-8?q?vmEW0V4wb84Ckd29FlC9+N6DZn8sbQtbix3eb8JNcXP5qPmNkyOl4/aIjtq8QhUf6?= =?utf-8?q?ncXbdktiBQbXmuzdMuSRZDmMf8E3OoBQ7KK5JkYOiajPL1Go/ndp0qNQeJt08JAoO?= =?utf-8?q?NxQUchHyiZPXmeFGzQukLcybp3OOogpkzWGG9W+o7SA6Q4cJpQ9m8noz+vLUkDfIt?= =?utf-8?q?k4Ic6GEEhFQK6S/geFbgWlv4tN9wIA/gqkTlVTeywAAImWAb138XoCpo/K0TAi8S9?= =?utf-8?q?Ir11x79Y2wOJi9CFQOW4SUzFUT4QMrKvB4W/T1wSDrq9XVRWfVBD6jzjoA8JDUuix?= =?utf-8?q?2Dl+vgy66cyKFzslBBx5GlSTHKK8skn+4ClUBDwQyWMF6ZzWui6sUMcgx/inhW19c?= =?utf-8?q?BvHpgyumvfbiA/3WZwisfnZeGha2nh0ELWM/4Z9IKyDEgFlIfCv8oTOAaKMONBO1K?= =?utf-8?q?GpxmNfd2yyMYVEiq3fRjlWq/eaDogvCKYGOWH3uV6lc8fhr+mShmmwuckmDVOGKxP?= =?utf-8?q?Blzg3u/wIEcD97CWKNAxMaTx0IwJv3riDU9R5yanAznpsa08OjE0p0aV4pTQ7thoT?= =?utf-8?q?wIeWRBLZf6hA9NCttw+alp27HNROS+oFW2qJtd5DGl4kf8doRJL4/D6myx5ChR7NM?= =?utf-8?q?P2R495HQoGYzKd1gVE+TCN82qgqb607hhjHXjj6avs5hcKP1xuOmt7YI3HFuIRzew?= =?utf-8?q?rm4bC1wH4ZUInALoza9Jd9fy701jhTyKDCML91jH+tipydp2JywARE7xwV68sTF7z?= =?utf-8?q?Ef37WZ3FtByj6ekUynmXGFyxCNWRm1bnJA=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Q45rox9UxU7d3Lg/oPly4zbpBY4KuoJU2/WJTXAuoUh8ziKj/bNMWAqGi+juP72FaGWZG6Sn1ih+56Pco+8tXVNSL2P6ZRBqNtCldzN82H4Yn1QrNmHIB8zvpuOKAgrvgAIu1sDL7Je1g7moyQiCAzpFBx5zj95ysLlRUdveSuhh9gX7qwDbkgeXCTU5InFRsKeo76oQekDm4I3t3/7uYLqoZsLdmbrphEaY6HVcFLsyIK4F83ctv6aNssh9fQzV6atJMWQqP8EZUPdWy0SsOUUmhAsU0tvaAqXGo0iQ7tjy2kIM2SGrqobDeARIJwGNX0VTrvOYCKUjJErT673FSR0bE2ASE+/fQ+6s/7q933to/vo7uu7lVPpubEqhIq/sFLzN1WXVmTimlBSoDlEOEXCwi4KOxkudA87jErUgOH3An6W6IX/VCIsRWjF7wUjlhu9Los8dBsYzCviFJLkg6Bet5GKSFom07dw6VaikTyOIjYbonJIfCDFoRtRuzC9QVwDcS1JlK40NH0ATzfTLxHlOzDwXfbyMZUXaDXKGYNuwUAd95gMllUBF46zjagoooqgNGq8frBHYwEOngwprYTHKkieL3LInwUPyNZXM19dSPs7pOkpuLYyHUjjKGSY0VAiSvt6RsDjrAOsrkZGx8g== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:56.8215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1256a60d-90e5-43f0-e183-08dd0a865db0 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: SJ5PEPF000001D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB7001 X-BESS-ID: 1732232644-112103-13742-55435-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.58.49 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmBhaGQGYGUNQoNSXV3MDU0t TYMDUp0TjNzDQx2dDS0tjMOMXYONU8Rak2FgA/zZplQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan8-206.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 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/Kconfig | 12 ++ fs/fuse/Makefile | 1 + fs/fuse/dev.c | 4 + fs/fuse/dev_uring.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 109 +++++++++++++++ fs/fuse/fuse_dev_i.h | 1 + fs/fuse/fuse_i.h | 5 + fs/fuse/inode.c | 3 + include/uapi/linux/fuse.h | 57 ++++++++ 9 files changed, 540 insertions(+) diff --git a/fs/fuse/Kconfig b/fs/fuse/Kconfig index 8674dbfbe59dbf79c304c587b08ebba3cfe405be..11f37cefc94b2af5a675c238801560c822b95f1a 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 ce0ff7a9007b94b4ab246b5271f227d126c768e8..fcf16b1c391a9bf11ca9f3a25b137acdb203ac47 100644 --- a/fs/fuse/Makefile +++ b/fs/fuse/Makefile @@ -14,5 +14,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 6cb45b5332c45f322e9163469ffd114cbc07dc4f..53f60fb5de230635d1a158ae5c40d6b2c314ecd2 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -6,6 +6,7 @@ See the file COPYING. */ +#include "dev_uring_i.h" #include "fuse_i.h" #include "fuse_dev_i.h" @@ -2467,6 +2468,9 @@ const struct file_operations fuse_dev_operations = { .fasync = fuse_dev_fasync, .unlocked_ioctl = fuse_dev_ioctl, .compat_ioctl = compat_ptr_ioctl, +#ifdef CONFIG_FUSE_IO_URING + .uring_cmd = fuse_uring_cmd, +#endif }; EXPORT_SYMBOL_GPL(fuse_dev_operations); diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c new file mode 100644 index 0000000000000000000000000000000000000000..ef5e40dcbc5154d8665c7c7ad46123c4a1d621ee --- /dev/null +++ b/fs/fuse/dev_uring.c @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FUSE: Filesystem in Userspace + * Copyright (c) 2023-2024 DataDirect Networks. + */ + +#include + +#include "fuse_i.h" +#include "dev_uring_i.h" +#include "fuse_dev_i.h" + +#include + +#ifdef CONFIG_FUSE_IO_URING +static bool __read_mostly enable_uring; +module_param(enable_uring, bool, 0644); +MODULE_PARM_DESC(enable_uring, + "Enable uring userspace communication through uring."); +#endif + +static int fuse_ring_ent_unset_userspace(struct fuse_ring_ent *ent) +{ + struct fuse_ring_queue *queue = ent->queue; + + lockdep_assert_held(&queue->lock); + + if (WARN_ON_ONCE(ent->state != FRRS_USERSPACE)) + return -EIO; + + ent->state = FRRS_COMMIT; + list_move(&ent->list, &queue->ent_commit_queue); + + return 0; +} + +void fuse_uring_destruct(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + int qid; + + if (!ring) + return; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = ring->queues[qid]; + + if (!queue) + continue; + + WARN_ON(!list_empty(&queue->ent_avail_queue)); + WARN_ON(!list_empty(&queue->ent_commit_queue)); + + kfree(queue); + ring->queues[qid] = NULL; + } + + kfree(ring->queues); + kfree(ring); + fc->ring = NULL; +} + +#define FUSE_URING_IOV_SEGS 2 /* header and payload */ + +/* + * Basic ring setup for this connection based on the provided configuration + */ +static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc) +{ + struct fuse_ring *ring = NULL; + size_t nr_queues = num_possible_cpus(); + struct fuse_ring *res = NULL; + + ring = kzalloc(sizeof(*fc->ring) + + nr_queues * sizeof(struct fuse_ring_queue), + GFP_KERNEL_ACCOUNT); + if (!ring) + return NULL; + + ring->queues = kcalloc(nr_queues, sizeof(struct fuse_ring_queue *), + GFP_KERNEL_ACCOUNT); + if (!ring->queues) + goto out_err; + + spin_lock(&fc->lock); + if (fc->ring) { + /* race, another thread created the ring in the mean time */ + spin_unlock(&fc->lock); + res = fc->ring; + goto out_err; + } + + fc->ring = ring; + ring->nr_queues = nr_queues; + ring->fc = fc; + + spin_unlock(&fc->lock); + return ring; + +out_err: + if (ring) + kfree(ring->queues); + kfree(ring); + return res; +} + +static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, + int qid) +{ + struct fuse_conn *fc = ring->fc; + struct fuse_ring_queue *queue; + + queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT); + if (!queue) + return ERR_PTR(-ENOMEM); + spin_lock(&fc->lock); + if (ring->queues[qid]) { + spin_unlock(&fc->lock); + kfree(queue); + return ring->queues[qid]; + } + + queue->qid = qid; + queue->ring = ring; + spin_lock_init(&queue->lock); + + INIT_LIST_HEAD(&queue->ent_avail_queue); + INIT_LIST_HEAD(&queue->ent_commit_queue); + + WRITE_ONCE(ring->queues[qid], queue); + spin_unlock(&fc->lock); + + return queue; +} + +/* + * Put a ring request onto hold, it is no longer used for now. + */ +static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, + struct fuse_ring_queue *queue) + __must_hold(&queue->lock) +{ + struct fuse_ring *ring = queue->ring; + + lockdep_assert_held(&queue->lock); + + /* unsets all previous flags - basically resets */ + pr_devel("%s ring=%p qid=%d state=%d\n", __func__, ring, + ring_ent->queue->qid, ring_ent->state); + + if (WARN_ON(ring_ent->state != FRRS_COMMIT)) { + pr_warn("%s qid=%d state=%d\n", __func__, ring_ent->queue->qid, + ring_ent->state); + return; + } + + list_move(&ring_ent->list, &queue->ent_avail_queue); + + ring_ent->state = FRRS_WAIT; +} + +/* + * fuse_uring_req_fetch command handling + */ +static void _fuse_uring_fetch(struct fuse_ring_ent *ring_ent, + struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + struct fuse_ring_queue *queue = ring_ent->queue; + + spin_lock(&queue->lock); + fuse_uring_ent_avail(ring_ent, queue); + ring_ent->cmd = cmd; + spin_unlock(&queue->lock); +} + +/* + * sqe->addr is a ptr to an iovec array, iov[0] has the headers, iov[1] + * the payload + */ +static int fuse_uring_get_iovec_from_sqe(const struct io_uring_sqe *sqe, + struct iovec iov[FUSE_URING_IOV_SEGS]) +{ + struct iovec __user *uiov = u64_to_user_ptr(READ_ONCE(sqe->addr)); + struct iov_iter iter; + ssize_t ret; + + if (sqe->len != FUSE_URING_IOV_SEGS) + return -EINVAL; + + /* + * Direction for buffer access will actually be READ and WRITE, + * using write for the import should include READ access as well. + */ + ret = import_iovec(WRITE, uiov, FUSE_URING_IOV_SEGS, + FUSE_URING_IOV_SEGS, &iov, &iter); + if (ret < 0) + return ret; + + return 0; +} + +static int fuse_uring_fetch(struct io_uring_cmd *cmd, unsigned int issue_flags, + struct fuse_conn *fc) +{ + const struct fuse_uring_cmd_req *cmd_req = io_uring_sqe_cmd(cmd->sqe); + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + struct fuse_ring_ent *ring_ent; + int err; + struct iovec iov[FUSE_URING_IOV_SEGS]; + + err = fuse_uring_get_iovec_from_sqe(cmd->sqe, iov); + if (err) { + pr_info_ratelimited("Failed to get iovec from sqe, err=%d\n", + err); + return err; + } + +#if 0 + /* Does not work as sending over io-uring is async */ + err = -ETXTBSY; + if (fc->initialized) { + pr_info_ratelimited( + "Received FUSE_URING_REQ_FETCH after connection is initialized\n"); + return err; + } +#endif + + err = -ENOMEM; + if (!ring) { + ring = fuse_uring_create(fc); + if (!ring) + return err; + } + + queue = ring->queues[cmd_req->qid]; + if (!queue) { + queue = fuse_uring_create_queue(ring, cmd_req->qid); + if (!queue) + return err; + } + + /* + * The created queue above does not need to be destructed in + * case of entry errors below, will be done at ring destruction time. + */ + + ring_ent = kzalloc(sizeof(*ring_ent), GFP_KERNEL_ACCOUNT); + if (ring_ent == NULL) + return err; + + INIT_LIST_HEAD(&ring_ent->list); + + ring_ent->queue = queue; + ring_ent->cmd = cmd; + + err = -EINVAL; + if (iov[0].iov_len < sizeof(struct fuse_ring_req_header)) { + pr_info_ratelimited("Invalid header len %zu\n", iov[0].iov_len); + goto err; + } + + ring_ent->headers = iov[0].iov_base; + ring_ent->payload = iov[1].iov_base; + ring_ent->max_arg_len = iov[1].iov_len; + + if (ring_ent->max_arg_len < + max_t(size_t, FUSE_MIN_READ_BUFFER, fc->max_write)) { + pr_info_ratelimited("Invalid req payload len %zu\n", + ring_ent->max_arg_len); + goto err; + } + + spin_lock(&queue->lock); + + /* + * FUSE_URING_REQ_FETCH is an initialization exception, needs + * state override + */ + ring_ent->state = FRRS_USERSPACE; + err = fuse_ring_ent_unset_userspace(ring_ent); + spin_unlock(&queue->lock); + if (WARN_ON_ONCE(err != 0)) + goto err; + + _fuse_uring_fetch(ring_ent, cmd, issue_flags); + + return 0; +err: + list_del_init(&ring_ent->list); + kfree(ring_ent); + return err; +} + +/* + * Entry function from io_uring to handle the given passthrough command + * (op cocde IORING_OP_URING_CMD) + */ +int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) +{ + const struct fuse_uring_cmd_req *cmd_req = io_uring_sqe_cmd(cmd->sqe); + struct fuse_dev *fud; + struct fuse_conn *fc; + u32 cmd_op = cmd->cmd_op; + int err = 0; + + /* Disabled for now, especially as teardown is not implemented yet */ + err = -EOPNOTSUPP; + pr_info_ratelimited("fuse-io-uring is not enabled yet\n"); + return err; + + err = -EOPNOTSUPP; + if (!enable_uring) { + pr_info_ratelimited("uring is disabled\n"); + return err; + } + + err = -ENOTCONN; + fud = fuse_get_dev(cmd->file); + if (!fud) { + pr_info_ratelimited("No fuse device found\n"); + return err; + } + fc = fud->fc; + + if (fc->aborted) + return err; + + switch (cmd_op) { + case FUSE_URING_REQ_FETCH: + err = fuse_uring_fetch(cmd, issue_flags, fc); + if (err) { + pr_info_once("fuse_uring_fetch failed err=%d\n", err); + return err; + } + break; + default: + err = -EINVAL; + pr_devel("Unknown uring command %d", cmd_op); + return err; + } + + pr_devel("uring cmd op=%d, qid=%d ID=%llu ret=%d\n", cmd_op, + cmd_req->qid, cmd_req->commit_id, err); + + return -EIOCBQUEUED; +} diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h new file mode 100644 index 0000000000000000000000000000000000000000..fab6f2a6c14b9de0aa8ec525ab17e59315c31e6a --- /dev/null +++ b/fs/fuse/dev_uring_i.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * FUSE: Filesystem in Userspace + * Copyright (c) 2023-2024 DataDirect Networks. + */ + +#ifndef _FS_FUSE_DEV_URING_I_H +#define _FS_FUSE_DEV_URING_I_H + +#include "fuse_i.h" + +#ifdef CONFIG_FUSE_IO_URING + +enum fuse_ring_req_state { + FRRS_INVALID = 0, + + /* ring entry received from userspace and it being processed */ + FRRS_COMMIT, + + /* The ring request waits for a new fuse request */ + FRRS_WAIT, + + /* request is in or on the way to user space */ + FRRS_USERSPACE, +}; + +/** A fuse ring entry, part of the ring queue */ +struct fuse_ring_ent { + /* userspace buffer */ + struct fuse_ring_req_header __user *headers; + void *__user *payload; + + /* the ring queue that owns the request */ + struct fuse_ring_queue *queue; + + struct io_uring_cmd *cmd; + + struct list_head list; + + /* size of payload buffer */ + size_t max_arg_len; + + /* + * state the request is currently in + * (enum fuse_ring_req_state) + */ + unsigned int state; + + struct fuse_req *fuse_req; +}; + +struct fuse_ring_queue { + /* + * back pointer to the main fuse uring structure that holds this + * queue + */ + struct fuse_ring *ring; + + /* queue id, typically also corresponds to the cpu core */ + unsigned int qid; + + /* + * queue lock, taken when any value in the queue changes _and_ also + * a ring entry state changes. + */ + spinlock_t lock; + + /* available ring entries (struct fuse_ring_ent) */ + struct list_head ent_avail_queue; + + /* + * entries in the process of being committed or in the process + * to be send to userspace + */ + struct list_head ent_commit_queue; +}; + +/** + * Describes if uring is for communication and holds alls the data needed + * for uring communication + */ +struct fuse_ring { + /* back pointer */ + struct fuse_conn *fc; + + /* number of ring queues */ + size_t nr_queues; + + struct fuse_ring_queue **queues; +}; + +void fuse_uring_destruct(struct fuse_conn *fc); +int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); + +#else /* CONFIG_FUSE_IO_URING */ + +struct fuse_ring; + +static inline void fuse_uring_create(struct fuse_conn *fc) +{ +} + +static inline void fuse_uring_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 6c506f040d5fb57dae746880c657a95637ac50ce..e82cbf9c569af4f271ba0456cb49e0a5116bf36b 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -8,6 +8,7 @@ #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) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index d9c79cc5318f9591c313e233335d40931d6c7f58..5e009a3511d3dd4e9c0e8b4f08ebb271831b1236 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -914,6 +914,11 @@ struct fuse_conn { /** IDR for backing files ids */ struct idr backing_files_map; #endif + +#ifdef CONFIG_FUSE_IO_URING + /** uring connection information*/ + struct fuse_ring *ring; +#endif }; /* diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index fd3321e29a3e569bf06be22a5383cf34fd42c051..c8f72a50047ac1dfc7e52e9f4e49716a016326ff 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 @@ -959,6 +960,8 @@ static void delayed_release(struct rcu_head *p) { struct fuse_conn *fc = container_of(p, struct fuse_conn, rcu); + fuse_uring_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 f1e99458e29e4fdce5273bc3def242342f207ebd..623ffe6a5b20d73dffc8f2abe781953540c79c9d 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1206,4 +1206,61 @@ struct fuse_supp_groups { uint32_t groups[]; }; +/** + * Size of the ring buffer header + */ +#define FUSE_RING_IN_OUT_HEADER_SZ 128 +#define FUSE_RING_OP_IN_OUT_SZ 128 + +struct fuse_ring_ent_in_out { + uint64_t flags; + + /* size of use payload buffer */ + uint32_t payload_sz; + uint32_t padding; + + uint8_t reserved[30]; +}; + +/** + * This structure mapped onto the + */ +struct fuse_ring_req_header { + /* struct fuse_in / struct fuse_out */ + char in_out[FUSE_RING_IN_OUT_HEADER_SZ]; + + /* per op code structs */ + char op_in[FUSE_RING_OP_IN_OUT_SZ]; + + /* struct fuse_ring_in_out */ + char ring_ent_in_out[sizeof(struct fuse_ring_ent_in_out)]; +}; + +/** + * 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 { + uint64_t flags; + + /* entry identifier */ + uint64_t commit_id; + + /* queue the command is for (queue index) */ + uint16_t qid; + uint8_t padding[6]; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Thu Nov 21 23:43:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882461 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 25E351AAE06 for ; Thu, 21 Nov 2024 23:44:12 +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=1732232656; cv=fail; b=GvnY61XCdLHuCJuv0wejTl6LYkpB+9CkLTUkWghNuUXLLGLfUZ5qLaGPE9gqH0uOWIBm9fH4gdoMaq0yCQbEvlbyFdSK1iGWZmP26RuDkgve6YH9m371GXA98x0TOeWY21sY7KDUXAOhrAF8LoGgBFubXDnlcswE4KnPWVtFgTM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232656; c=relaxed/simple; bh=YF145zkUB7cYx+0Rk1Z2Wg1AFIYTLqbVRhKe5LqNvDA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nQsV/YMQDQMrP1D/RH+M5rTeCEqoAYUaxV3q2CTLfGTp4WimJJZSVziHRlFmBRDlTaktLHJP9xIrm4KmdgrB0GCom+pvkQnG057geXB4kE0+8WVgAdamtgeYrLQ/ahkD/pPJs/BmvsArBdsBhD6ni93RuST86QA1S3oYEVuHhZM= 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=c7deaYxK; 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="c7deaYxK" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by mx-outbound14-193.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G93tkcIekbJE7NXf6S0SYOcm/kAW1t00PfMcHpesJj41Eto4qe2O610x6xA8OrrI2Yp+qtNCATMyyx+Opn4dVpeazmGMjTw+c5aP942mvTmSYMp0qNKhwtMNy04hiW7kSwXvkzzv9qq60UhRMROoqkt1qsTyXLUhYFewQkTjKbQspUUFUgZWt2iNU9xK2tNHbIWEatMS7GW6bxb4ivPweGoDb1G89mqviHOY5Q9VaH3GyQIhiK9oZQ6JJQ9i6WbCOmplCV8vg3bPJKwMkUlGQ+kKH2EHngzQN99oIJD5FUOEY+2Zh35UpPJCLmLvpH8ROYrw1eHBGVqcHeQyKueyYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+50uXvpQ5qI9g4ehAfVRZtXE7FrOTbcJt349uDKqEj4=; b=iA05a8xjwSVQu29/nFarQ/9UZVVHubvgP9Uu+o8P/qzWOXh2GvrtPzFq41DlmJUX8z0+lOlKTYD2YOA60wKOZ7kBzs5R6n55OBtaavoBuJTNwMa+Yk3CoF/kuwlyjQOp8qf1G5jWmrS1I0U89IgnNV6XMLPyArKmqU2Riv2YvBMPJo2oDiAoGxYK7Jqwo1bHZmPc8IlKCuSTI8AaNdVFzYZXbcs9XwylBv4ROgYvZ/NpOnOcAB0iu74Fl81kR4LZ03x+x4Vi+lezsa2h9Jl4r3XXYpnHX/gVN6k/zseyd+D45V789e5JmgTaiZPsFIrdBPkQ4ep+9OBlsGXycIzjaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=+50uXvpQ5qI9g4ehAfVRZtXE7FrOTbcJt349uDKqEj4=; b=c7deaYxKZ/s0nDgBcbxzFRPsEUSHAb6Lo8kSc6vCWy52S9FGVrzaAnD3jo03S5PkYbiomgtv7nOcVGYLDdO2+BfOUj10OJv0xRt7x2YfIQkn57oBksJwlmAftRvMarXqNaaT0k39jJ8i4hfbRk9Ua1DsGugOkpQU+GY7H1qHLyI= Received: from DM5PR07CA0105.namprd07.prod.outlook.com (2603:10b6:4:ae::34) by MN0PR19MB8300.namprd19.prod.outlook.com (2603:10b6:208:3c8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.26; Thu, 21 Nov 2024 23:43:58 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:4:ae:cafe::57) by DM5PR07CA0105.outlook.office365.com (2603:10b6:4:ae::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:57 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id BF4F732; Thu, 21 Nov 2024 23:43:56 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:23 +0100 Subject: [PATCH RFC v6 07/16] fuse: Make fuse_copy non static Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-7-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=3665; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=YF145zkUB7cYx+0Rk1Z2Wg1AFIYTLqbVRhKe5LqNvDA=; b=EwYzswPXQGoQEhzWWCh6z3MdTIDvexwk9qA6/28u3drSd7/YT2ogDIMK6+CKqeQCRf+gpDh5m JUglYEouXZRC2sCxIxv0d4P03xgObYchrr4+z87aewKHVb8GMeGXr3n X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|MN0PR19MB8300:EE_ X-MS-Office365-Filtering-Correlation-Id: 078bf8e4-9499-40fb-374c-08dd0a865e0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?9LuSboCrZD37au4omztgJhQt4JRWnCh?= =?utf-8?q?KA/HYDafh1J0k8/rLRRH4abnRXHMQ6ggc4+Z7t2xkuSFUtjsSOWU2wZYUN2EPzelC?= =?utf-8?q?Gi3Xo2eMglSw7vaGOry8w+5rg9+L8j6zpWJwEaIpT6IMoHmONrDCJcKcViA0TlAKI?= =?utf-8?q?V0Lj5ZmFSa8UMKk2GCoJ7+SnpHFGwtlI4DIcx7CZxIQ+xRLI9SxCToqQyjam8u1t/?= =?utf-8?q?nl8FFdjlucJcnoNzISIbidXilS3UkpE+kCrY4bbreo7QBqaW+zlsHc8x2TAEp8Qky?= =?utf-8?q?yCsCk1NaWlimaXnkK2tIMXjCAi3QsXap94bbnZyOCMAWqEkd5bGhT40SBn8MXifQA?= =?utf-8?q?PENrlXdo+0iPVHRhMdpyM7+RiWf+pWaIUCjnt9JIe/E5wcDU4ZMXeiELaRTDQnZqj?= =?utf-8?q?bZXMRA4w4qOF8ITdaTiwgdixP/Ic5800u0LUd1SkZ1BhFQtovqTanbkpdZS+m/yK7?= =?utf-8?q?hMlUuGNDM1Q9rv8/MeN5RZIuUYG2Y0a708GS3HW/TL8O5yKqM9AQsTDD8yJokB8XF?= =?utf-8?q?CwrqcQUJrjJfbaHjNtLYbrFUI0FzQafhu4D2u8iXVsrRMUOBU4uwdczEVnTq7JUtd?= =?utf-8?q?Kt8QAkfPpvYwXubf6BbGhUSB+iO8J9w1udAB/jMbIlOIz0xNtKjAvKoy3FRcA0KoP?= =?utf-8?q?I6uCrvcZ8JVRxrvbr6wmCYpRwJk6K2Xmraxbdv0zNK+D/iXzHbTAcUJGjLJlqBH4P?= =?utf-8?q?RHorzLWEw7M+VQZ5j3gt0xISrpUbp4pA1eEh9kGBnY5DHm0gvNAmbUNIWqJZS/H0p?= =?utf-8?q?5TAE4JoVYrFM8kFk8pyIA3kzJlDPwRW1G+SCglwzxd2SihLpfqKgEhQJJyDUQRN9h?= =?utf-8?q?dq2PV4GyDhA2vgr2z6+w4EVTkev9eY19uy3FKgAqI+JsXr7MUPlAE6Sxfn91qtWKm?= =?utf-8?q?U/lD8jwyTNv8Ph0KAhn4lis9eE+anUp5/Hz53IOo2G/TJ3jwotgA4BhLkDq3LaT46?= =?utf-8?q?E3f1xWZ9tyhT6odxfuUTnKXEtNAYQDiPILR/bshSWFys57fOBUmybAb0kXcdiFpRQ?= =?utf-8?q?agI6M4mZI+HDeP+dhTi/OAiDZI0BczCkyr6Y3AwINX4ONKrFGEcuy+wzKBAX1e90D?= =?utf-8?q?9C7faC9uFgd8diDgb2LGgJzzBfxyOJL90NSnzBf3x5GZGJpeDvJoxhjqedwy7X2Df?= =?utf-8?q?XjVyt0rulaEoxGbsqldkD/7MHKuSgLm4omI1b+FuaiBrHWV5hvsDhdg+Z3e6pMG6N?= =?utf-8?q?B2GZhAI7KYHTpf1AfhQF6dv4LVaRylrQ0f3rf3St1zPdrwI7tWhQWlF6hYKiLqJxm?= =?utf-8?q?e/TrxxvoBVGiWkp9PPHewplAFn/oP0P1M8WOWDqiUgRC12O25zdCuoR+w5jkYlcol?= =?utf-8?q?SB/DL9VYvtFOuIRl2wAVT2FpxnGyAdO9Yg=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9mifbUQaRwt+dw81oO04rrsNDeHAs9S1St4YTQbKiZKxrsSuORIoceJ6+rWJ5N6gMsDLYkq9bKZmEN+9f+lzrrIL+Gu+annfy9IZ3IIhcy7ukn8GeWx8aGp+0T0dqUIBRoTPw69ZthrlacuumUl/E4jOlpJWHuAz/COYlqPFWuqT/f6IcMNiETmf449wMZETTcv+tW/W153Figqt7nFVjuULdbv5uQsU6Tyjz1iKb39ysXf3eqMAj6O2J1RsBjSSPCY5PMKnqwRoTnqTDzJjqd/UoMxBnlnC6PuQF1UTe9WbcGRhyT3DR4mApsfLki9tH+5xqfpYFLEy7AgHrBf6xCo4TAo7sTPNBgZC2IPZ2SB1Ns+Z+T2TF2b+0XVRYJJEIlJsJl6M9rqpcJC6IGudCQXPMXDWc6cKdQYrRkblNri4WXWw+22l/u/izmB57PySyX+JfwWrZJjb6dbZF3dVI9Wth62v3+kJ5ojUTAvyoFQVNxtRmrykWktPohibHd+h1W5HaY0DTaCjKRbsdiDPKaev1igf56qdagl/AYSszjlqEoaGUqw7PdX+gFlUTHRo/NcYdKuRVbec4wjrYlb+9OPUR8v0rQiGeE9pNOS/yr4yLNbIRCj/dUpdPYccSH0ZySWkagW6qd8YwTyb8lWcOQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:57.5673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 078bf8e4-9499-40fb-374c-08dd0a865e0d 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: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR19MB8300 X-BESS-ID: 1732232641-103777-13386-21197-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.55.172 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsamJhZAVgZQ0DLRLMnIwjjNKM 3QOMXAMMkgyczEPNHC3MjQwtjAKNFUqTYWAHlYYT9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan14-42.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 Move 'struct fuse_copy_state' and fuse_copy_* functions to fuse_dev_i.h to make it available for fuse-uring. 'copy_out_args()' is renamed to 'fuse_copy_out_args'. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 30 ++++++++---------------------- fs/fuse/fuse_dev_i.h | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 53f60fb5de230635d1a158ae5c40d6b2c314ecd2..aa654989d768df3dd82690ef071bbe0aa87817b0 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -679,22 +679,8 @@ static int unlock_request(struct fuse_req *req) return err; } -struct fuse_copy_state { - int write; - struct fuse_req *req; - struct iov_iter *iter; - struct pipe_buffer *pipebufs; - struct pipe_buffer *currbuf; - struct pipe_inode_info *pipe; - unsigned long nr_segs; - struct page *pg; - unsigned len; - unsigned offset; - unsigned move_pages:1; -}; - -static void fuse_copy_init(struct fuse_copy_state *cs, int write, - struct iov_iter *iter) +void fuse_copy_init(struct fuse_copy_state *cs, int write, + struct iov_iter *iter) { memset(cs, 0, sizeof(*cs)); cs->write = write; @@ -1045,9 +1031,9 @@ static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) } /* Copy request arguments to/from userspace buffer */ -static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, - unsigned argpages, struct fuse_arg *args, - int zeroing) +int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, + unsigned argpages, struct fuse_arg *args, + int zeroing) { int err = 0; unsigned i; @@ -1937,8 +1923,8 @@ static struct fuse_req *request_find(struct fuse_pqueue *fpq, u64 unique) return NULL; } -static int copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, - unsigned nbytes) +int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, + unsigned nbytes) { unsigned reqsize = sizeof(struct fuse_out_header); @@ -2040,7 +2026,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 e82cbf9c569af4f271ba0456cb49e0a5116bf36b..f36e304cd62c8302aed95de89926fc894f602cfd 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -13,6 +13,23 @@ #define FUSE_INT_REQ_BIT (1ULL << 0) #define FUSE_REQ_ID_STEP (1ULL << 1) +struct fuse_arg; +struct fuse_args; + +struct fuse_copy_state { + int write; + struct fuse_req *req; + struct iov_iter *iter; + struct pipe_buffer *pipebufs; + struct pipe_buffer *currbuf; + struct pipe_inode_info *pipe; + unsigned long nr_segs; + struct page *pg; + unsigned int len; + unsigned int offset; + unsigned int move_pages:1; +}; + static inline struct fuse_dev *fuse_get_dev(struct file *file) { /* @@ -24,6 +41,14 @@ static inline struct fuse_dev *fuse_get_dev(struct file *file) void fuse_dev_end_requests(struct list_head *head); +void fuse_copy_init(struct fuse_copy_state *cs, int write, + struct iov_iter *iter); +int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs, + unsigned int argpages, struct fuse_arg *args, + int zeroing); +int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, + unsigned int nbytes); + #endif From patchwork Thu Nov 21 23:43:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882460 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 010F31DE2DE for ; Thu, 21 Nov 2024 23:44:12 +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=1732232656; cv=fail; b=n9I5XVYGzDd4qjAmn+wS7luQa3rODQ30gBHeFeIF096w+gJHHawQNIb7Ud+ou4C+gCwakqLCIuKjMz1WbyVbpoe/nSk/3nFrRuSNSZE/OvBtb3ybLMp/tl27imiHLGEhlezHVzrC9rQ/FZkN9QZb0ZPt7lP3xXxiXdemuOde5Fw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232656; c=relaxed/simple; bh=5tWGsfFqIOTmbzCy1M1YG1Z+pGnTYUdhQKGU5bA4XN8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iIOya6dfB18fY/VKOPF9bXQcjXwFOKLes8+5NY8Px9N2btVsM8xoSbeCb92TBFLMugndT5lRNi6yM2kQjBF/dacqy2brCPwZ5qUO8FIOCN6NryBlgHbiRfi2vYC1aACjF4NXN93GTkVOsTwj9U+d9GpTdSiKi+MVTWQNu3j94A8= 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=j8pGNN3/; 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="j8pGNN3/" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2049.outbound.protection.outlook.com [104.47.55.49]) by mx-outbound16-233.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WJ3J2yk6S845xas7aiisHzTCX0vMg0Vq3hUadvIgE7uAhotfeL2juF3ZHkQPJf7aiePE+a6u8UXT8TO0m9V8/a2btp0fMQ8BxYgP2TcZkkUbdP2kGh8+Q++Nny9xRd23OodH1Rk7M1y1CDfqVjDaG2Yy3J771hqe7s2KZu+3dUrHG/2zuKx78lkoiKlQxTPfPXuN7sUUTVHcJSdjtt2AZiYM3ngVSckSqkfLzfw4VPVy3Y/xUQMxCB6WEeiBlpbvF1dWlfHN3hH7441pCeuz3ww1f1/G2GHbIeZfbPM/aKbjyvgUugSBHDPiEhDncjNm02AteKGEfMA0lOf7Opqg7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ic1lWTx2sk0ToMWueKYzM4z+GqjslhRxPuaqXsC8MHM=; b=abaj4uw9vx3g52m0FKik5bthz6afvGZijrKf56upoe9zm7aMY0SJrKrPYKKKa7+ZsxENJr7tKaTyckwdBQPOt9YJfB5fzm0MC/YmH5+ygBTKZEnYuFcwD3qZMnNx8mOiYog2EohLuxjHMh3YtKD1ghriMgYQB7RKCEwb+Zg2Qt8koXjZnPSqCrsqGKUIrDyaondm3aDjqlhKalTRbZaLyChuXHjqvJG4VgjO7vHzBofXgKF9GRO+pTAfzw6t/Hwy/zNXNbWZBBVCoRLPjPaIhZuIOpel9IAgZORQci3dFwd3ToQP8bi5yhKdXYlRJDEY47ubjB5ZDdDeHmDPKx7MfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=ic1lWTx2sk0ToMWueKYzM4z+GqjslhRxPuaqXsC8MHM=; b=j8pGNN3/DSizrzIdSrcj9x1aULBR7laLyECgVWshkJ9pODsDzlDz4hNpCRalQ0rwalUCwhA+TTmlKHTWMoSFJcTyTu4lQ/xGSsY6kJ0gyi/OLmrkaM36GAF3qTurvxAGts/aJ8/L0Kk4v+IxwHzP/UqDcAHV3eQcTYEqSzQmco8= Received: from DM5PR07CA0094.namprd07.prod.outlook.com (2603:10b6:4:ae::23) by BLAPR19MB4563.namprd19.prod.outlook.com (2603:10b6:208:293::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.14; Thu, 21 Nov 2024 23:43:58 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:4:ae:cafe::7d) by DM5PR07CA0094.outlook.office365.com (2603:10b6:4:ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:58 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id B75542D; Thu, 21 Nov 2024 23:43:57 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:24 +0100 Subject: [PATCH RFC v6 08/16] fuse: Add fuse-io-uring handling into fuse_copy Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-8-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=2481; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=5tWGsfFqIOTmbzCy1M1YG1Z+pGnTYUdhQKGU5bA4XN8=; b=pp/s7/6N4RG2lCoxWv1Xyaw1skp6Bq41fEnqQCizgByQlJG+DVCRO1TdySkBA5gx9WbnaizSO SYMdaNysGOgB5dD1JaYIk98em59/DC9pShRQktkPG3PR2ZtaYQnxjzc X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|BLAPR19MB4563:EE_ X-MS-Office365-Filtering-Correlation-Id: 749dd6aa-4728-4794-e2be-08dd0a865e99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?EYwJvsQh1jVfFJbrcp+c5wvwpN9WKT9?= =?utf-8?q?VK/XOpWcIts2gUzLijxsJIIWmVOwP5Gd7w3bj9vd+YAaHrfxRIa4ZcEx73Al94ud1?= =?utf-8?q?Z/tNko7aFPj+11B5Nn7RvgWcfabZ27vesxe471F35jzIaLOoqeL2e5WI1UvXgIdoM?= =?utf-8?q?DkQ2Ffp03Lk+idMMdd8oHxBNmNRmEwzIlgXrCUe/GRyUuYDXBtH9IThZIrithtpgE?= =?utf-8?q?U8A3hdyA7Iwihj6oCZW1xVA7njjlQ6wthiHYC3YvCQ+Mca9kw1mcpcVPH70wcdy13?= =?utf-8?q?57jhQkanEPpKZAFva6n3CcmFxJxhVN35eGtQ13hRYw6AihcF0ffps0YfCcMVovRAL?= =?utf-8?q?4AAU5XaA8YK4dZwosEYiSS+GJquSJM946+C4bv0ROzZ5UAG4ENtni2IClQI0vIixV?= =?utf-8?q?PKbc4dyTsKl8hJzz+YQl9Ihaq3fzQ9eKIozWJKZNPuOB4rCa5XOPjACe4/XJOZfSm?= =?utf-8?q?2C0WC8l7xcVWi+6ZvQl3CXDHc57VCoTFcgySbEOSK/ephMuekNwDbnBXSNUKM0D8J?= =?utf-8?q?6s4EH2SpDl4KVD9V/HAPdSCVSQd+fjuatZIJK0XXeRpMm8TdZl9T7wXgNZOlXQ8lH?= =?utf-8?q?rjwtWdQrgnbiKF6FfoQf1PiM4mA9j5VGbxXw1dArHIzGqw7+cAq3yEmO+3gj8fzLG?= =?utf-8?q?zDIsMQ2858FcV9/ZSY+CD4HJAjDfYH1PR7UxXwxj8V3FrsrgDJwWahsHMTzxsYJwg?= =?utf-8?q?+2ex+oWfMEMNpujC3Y+GTUwF0s4dpWxmAVc9/00mmxO2CZtP+tQMWTItMXk0em9xT?= =?utf-8?q?epoCkwNXlDLflk9mXshRl2dBhkeUc8jdo3F39eK+HUJtKbtgg/KBwkeKSK194/FBT?= =?utf-8?q?eC1qSlUmqH49hRFeifztNG+3fuD7jNx8GQvW5zRBdBUxaG2cT/Zg9sWWvp7128Kjt?= =?utf-8?q?bO+drQTGNkaiXZ4fqcJbWZcrHFg2cLhsh9O18rDJIa1rq67NLq1iB4xh8AAYUWD9N?= =?utf-8?q?q8pkJDjKMY51Ua6p5ttevGCsL1qRlYyCiUBRZ2cviltRsQrH/2Sqnh26qv69LRtcU?= =?utf-8?q?j9vjhdNYxqPqJvPcDKGnHx96Y7eEmy8/CPtpKEcIdd/YjHGEfFF1uAPAuPTSg+6AV?= =?utf-8?q?Iou26tYP9w9ubnt9hsIyzQZjkymSJur7JEVBEaCixqTS9TvncrRI6ID1jOJzf5ush?= =?utf-8?q?EexJ4zxiPOoZyIFHEsWT+2zVy6V6i1fX46XSsxDhN4Ct0Wda784byhDmbfwX3ugkz?= =?utf-8?q?S/yqmxV2UEzf1S1dExy2CBagdOh14M8ry/RGVK7Euw1KS5V8gIsgChZ2rLNpKgYUi?= =?utf-8?q?6+gJlfp3fkFjw9RSTIUgcxfUBIVIQi79CmLvtmQ16/dtjZOv6Q/83IsjjVaukGfAS?= =?utf-8?q?Gm94M5dFR4ksJnAmH8T288tigOEQGeQ6zQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(82310400026)(7416014)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vdjrY47o74wleiFj9FxxZNRLQDovu0JsbIIxgVKRGEjwja0+WN8x3DUfOPX7Qgmhsn7fqt7ieF1nGbH+zdQmbHpjklxUwqllT0b/X+7f4zfywU6L7LcXEACI8DMXe2zD2vDyDboUQrAGrh8R80V6xMZJeBekPfSlHrlibLrYJGL+VrpRdx2JcFmyLhtaZKVKaxOowoTPIvec3VyuxaxMalagR3MLeBXxT23NNy5PZpNirGisshvHgM6dBW3nGjvclQtnuwotfkdTtO5GFDQ8h1mA+2RzZ8k3tX9Mntt4BHIRdLqaFPFHzV6DgYJnyfjyVFFvkPNrtGLl5AnkWktWsYAVc0usN6/h67xwQkhTDf92MpaVcgdDPxOWHjFjPAatZBvhF7SvAqfiGwGmkUxKd3B7ukg5+F8/e0F0B4Q5dqIlyE96y0GBiXP1MR8Xi43RPSp+l2lvaswp+so9/YlUb5cFryz/8iY+zkdvwyOrGoMLryr8hxSMYwDP3dxZteCf98dM1fkBJoXSmjAGSM1lvZvjLRhn9neAYCeOTqaSITdBxNeMjOtkz+9Er5EDnLI/EoUIB4BeT3YT3k9C1lpwPTIPamMv84J6WCOAu+M52lAEQZSQ+J/eJwQ6AoJec62P4ORkmxcKLIcrW3mowAnv4g== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:58.4892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 749dd6aa-4728-4794-e2be-08dd0a865e99 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: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR19MB4563 X-BESS-ID: 1732232642-104329-12100-10077-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.55.49 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYmBkZAVgZQMNU0NcXcxNLIwt jCPDE1JSk5KcXSJNUiOTXNxCzN0jBJqTYWAO1Q/MZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan20-2.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 Add special fuse-io-uring into the fuse argument copy handler. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 12 +++++++++++- fs/fuse/dev_uring_i.h | 6 +++--- fs/fuse/fuse_dev_i.h | 5 +++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index aa654989d768df3dd82690ef071bbe0aa87817b0..ad65ede9c7723bb6f3589e64b8eef7429fa4b488 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -787,6 +787,9 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) *size -= ncpy; cs->len -= ncpy; cs->offset += ncpy; + if (cs->is_uring) + cs->ring.offset += ncpy; + return ncpy; } @@ -1926,7 +1929,14 @@ static struct fuse_req *request_find(struct fuse_pqueue *fpq, u64 unique) int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, unsigned nbytes) { - unsigned reqsize = sizeof(struct fuse_out_header); + + unsigned int reqsize = 0; + + /* + * Uring has all headers separated from args - args is payload only + */ + if (!cs->is_uring) + reqsize = sizeof(struct fuse_out_header); reqsize += fuse_len_args(args->out_numargs, args->out_args); diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index fab6f2a6c14b9de0aa8ec525ab17e59315c31e6a..17767e373d31969fe2987fed31c66b5077f209c6 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -14,13 +14,13 @@ enum fuse_ring_req_state { FRRS_INVALID = 0, - /* ring entry received from userspace and it being processed */ + /* The ring entry received from userspace and it being processed */ FRRS_COMMIT, - /* The ring request waits for a new fuse request */ + /* The ring entry is waiting for new fuse requests */ FRRS_WAIT, - /* request is in or on the way to user space */ + /* The ring entry is in or on the way to user space */ FRRS_USERSPACE, }; diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index f36e304cd62c8302aed95de89926fc894f602cfd..7ecb103af6f0feca99eb8940872c6a5ccf2e5186 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -28,6 +28,11 @@ struct fuse_copy_state { unsigned int len; unsigned int offset; unsigned int move_pages:1; + unsigned int is_uring:1; + struct { + /* overall offset with the user buffer */ + unsigned int offset; + } ring; }; static inline struct fuse_dev *fuse_get_dev(struct file *file) From patchwork Thu Nov 21 23:43:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882471 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 D948B4430; Fri, 22 Nov 2024 00:17:25 +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=1732234649; cv=fail; b=nD+qHaxPcIpw8398yI/IQ8mVjR8hvpIElULdqPwSu24vmfMAJ+W4NZjYsj4BxoY6Rnj2qIWtx+IGKPYuxoG0/haWj1sgV2iihbPZwabzMn00ZV1dCx414nxyd8cVlFCV0mLYtQV753/l6tHTBgfTBtVhv8xMvlKUnSY1AIjW1no= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732234649; c=relaxed/simple; bh=jgthYjzC6cbaVL5qIhUchuYhbBj/1i+GKM1tE/IWnes=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mDSRXXMRJzMqHS5Xn0pGtjNyM2NgtZ4ePMsCN5Xb+0sFabO52koQ2up+mjYbD5n9AH4UhyNr56+vYtb/T0RF+vNl+GoPMMsbr1yHhqg37aIizFHxhplwxuoVzdxQjm/HePasj7Bbj2z1hDwqOD2Pk8L1qMxyY7IvvZluogf+D8s= 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=QuW34mES; 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="QuW34mES" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by mx-outbound18-0.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Nov 2024 00:17:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XzwT5v8SMMBPkh1UPJF2ZyZ25SqsGayc8or1yl3ekmNNY49sCgKi4lVyX798TRm2gh2DVG3RsRNIQDHryZdrNkHYmHOI+UpMQl6jDdnewOCZn+hKxmdF/vM9QqikxYZMVg39SbCEDP3x5L88bLRxlZfKP2d/bqPLVJlm+MZljlk0lLWvoZmAGxu8mX8KsPNdiwWE3IVkQAP1MgvqZynjcjxEh0ILJolJSCPSUB6qthT6f35sV1KIzsWLH3/vRoyviqHqOwKsWEsXJxZpOMBA+dt1GCZ+D7tTYrzOfNpnCnaau6ZNIfdU0bwIEn0HwdGva76OXu2ln9ve9gPMZXqwGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mhU8Xpsr6eZYJ5Pu3Gi9ouoKQ5IjiLBQQwdmtKjQXjo=; b=oUrcmzohpKzZLmzIlL7D5/Y/0dE1474RIHj3b3aHgSIrAo8lV56UfmuzXxyA4RNxl4MHuzi0gEiTGvt9alkXqaVJCrXD1KCAdX8+rWlvx14qyiHablQfDzjVp6Db7GpJN0cJi88h+7fd1Oy3BH5n7CilfzLJHfxXn2MvLp7hDyv+bW++hBShG/d+pFLb8sEnU6ctkt2X65wcBuBjS8fcydSa5p6qvDKsbXvnEvbBp597kozzOzlXwPPZY8NzzVxvc5QxdNg1hhr5G+87mQG2Er3vwC3+loAudYsPPvg0nt2gST8YYrIxU2SO0VonC4n0F8+5yAXYaBI22kxT76eckQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=mhU8Xpsr6eZYJ5Pu3Gi9ouoKQ5IjiLBQQwdmtKjQXjo=; b=QuW34mESvVotXtClbchRyla/66GyXWRKQv7UyVldS+biYh25xfne/iVngsokDSD/0i7DIXdhOUEKgaj4J0Bkb8VqesxMkeKqLhtKYhqM2LQqZ9Hefl25gaYXqhSKOCmi5peiiH181NuNHAhOALoPGuedZn8aUEu8nfEr7a8GALI= Received: from SJ0PR13CA0192.namprd13.prod.outlook.com (2603:10b6:a03:2c3::17) by PH7PR19MB6753.namprd19.prod.outlook.com (2603:10b6:510:1af::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Thu, 21 Nov 2024 23:43:59 +0000 Received: from SJ5PEPF000001D3.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::ce) by SJ0PR13CA0192.outlook.office365.com (2603:10b6:a03:2c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17 via Frontend Transport; Thu, 21 Nov 2024 23:43: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 SJ5PEPF000001D3.mail.protection.outlook.com (10.167.242.55) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:43:59 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id AFEB12D; Thu, 21 Nov 2024 23:43:58 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:25 +0100 Subject: [PATCH RFC v6 09/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-9-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=19177; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=jgthYjzC6cbaVL5qIhUchuYhbBj/1i+GKM1tE/IWnes=; b=lpyoF+fbE3CmDpsMhqYEq8DzPtaGxWcxcckZvkx575wOTNuVwwP3xajfylDXAgHSzgHW4lzqh 1D0AmGpAsaEDSKO3GzG2s3plRRJKWa/Uu9fheBN+Zf3uQEiCeRZoWat X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D3:EE_|PH7PR19MB6753:EE_ X-MS-Office365-Filtering-Correlation-Id: 390b4d02-76d8-4245-9e68-08dd0a865f52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1ZyPXcJoN5HQIg4zJy9dr6ojAvO9IQ/?= =?utf-8?q?d8FkVrhnCYR9B5Dmn1NWaejwRUPE/6ynzXhZSgP0yFY+eJ/VZtm/l63hy1nWeQ9TY?= =?utf-8?q?TMA/XJxQzl4eIubHwPRy3sVLt9lO5ffmg/MA+GttTwkJr32mU3hWbArVT8P+z0uCk?= =?utf-8?q?dmVJOn8dNzePWTe7XTY9KXAeKx9NNa52y+n6oqNmsbJcmtJsaxfVhmvK7adfgEqoC?= =?utf-8?q?gOpyudhKtgjNJWooP7cdpegKYF5+hy4u6L0XM7gW2CqRkyHyLn2CY4MGBEZHsnjrB?= =?utf-8?q?+hbmD29fU2tP1C4JqVTQ6cQbeSOiZRNaRj5ENuIG64bPsV1eQ+OmvY2/3EqwLN6Rh?= =?utf-8?q?mz92RDZceAnUnj6Q8m9zjJmn7sm1CMS8MGMXxTfY2EuPzpP3ONc4xZ8AYip1il+bh?= =?utf-8?q?uzr4onVUDvjohBnLTjkHmhxZi+t9toANq+wc3FfVB+PQo2zHo+EjZZ8FSQuusl0jK?= =?utf-8?q?LxgcncuGB/OQjaDKPHCfgb4QB9d98BOfARoMmm8x9PEInFZle+kJqzca1oMx5pRct?= =?utf-8?q?BfeCBG8ZUTLA1KabzSH3WKVP0WYNwdzUa067qGqPm7vSjmcgcLRQ29NyZCXfKf1O/?= =?utf-8?q?LotcLTU8j3+p1QANSFSCekxN8WZ28BDc5ZriofRrcfrZV6UlSRNLeTWlUP/gsPTOu?= =?utf-8?q?ALbmjPrDs/oBfG3QJvTT4RwBMOkIdMgER/Vo95k3zll5jpmXKHkKqmsshuUF9w8Mt?= =?utf-8?q?d7unJB5Yn0OnRVmmPETuQo7OeJddnr/ac0mBSSzZGr/mqk3AsCD70GE7SfJJ3Recm?= =?utf-8?q?G3/0CF0FITrrLRPm875d0/qxje9qc4cUvKt4tcNvulFknxxcYTqZDM9nS216v4Kmz?= =?utf-8?q?2BXA8CGMgaKhft/8N07umWvpzA3h7X86c/rQra25a4CaQhScz4t2/fEVat2Oyc3hO?= =?utf-8?q?0ICxikQB2ILyM9epn/fwTqsTzIgJdKsLWOeqr+1hcE1vESvA3fydghsp2TqC8VTXL?= =?utf-8?q?H9SMa1mXOCfYWMZN4LdHjaxZ6Vw3zwRTZFZDUToeeP9fAU85LHu15EjZnyDrBWhKu?= =?utf-8?q?961SBHTb+7r33UayuWMPHowpicv8Me22CkTUw2HErKo+SJHXn1JRlUD0x9LOaSlyi?= =?utf-8?q?AePgkRdOTUXzWPP3ZjzO8btIw+HfjB6LGRXzFq6koN4pTiLjnRJgzePQMV+zPwndR?= =?utf-8?q?kz6CUgkcSL17zkgBkArM9I0Ik8/0l3uL8qLrES5uNbcBtv0/q/+1KpbFBLTlmoavl?= =?utf-8?q?Xng1WeElD55yO7ae4xohVFFyfvByyAqyUv3S5nW8vDyqK3oPxcr+5dr7W8b/3yORv?= =?utf-8?q?3RzjAY0VHxP2TOU7DiFvFo+dOSV6Y17PGvyjQbw+yaDCX2MdlYS7mM/ORwxzHUbC1?= =?utf-8?q?5nBkX3tKbQ5PTSvUYjPVtevW07NSHTfqnQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(7416014)(1800799024)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: i0RJZiNfb6pNrdAdLa2xqXAgsIBQLe9v7rW9vqfxpGW1FfPMfMsb48tN/7gRFOoF+f0gtvrqq+F57s2B6Vs1R3pp2D7ut806vYEMEPYzWD5kVoiU5Y8Z3Y1RQlkR+7Qz7wGMfYehkEJRpU+ei9MOC56Vt+KDI+WxPdCOsGMaHmLX6/QNkuJfe9D9ZgByD3AgbFoDo6cipoKEL1LQjxO9sZ6r+BGtBAp8JjVJ1Wnf8Yq/nqJlP//b2WKd+gwTnnxH/rTb4TlNUzsVzZlDPpovAy2dObjBr/bnws7GZZOXfteWiPpwUbFwaFHm6vPoeXX3uULrpqfIjv0LD8LpN0QMOp+/uaJx1UEriTpDnG/sT1xADe2hoicCaE5wHxW/JKn9rqn5Egcv2cearfRoj+iG6iO5/EljljXkYUvWSk0OQmy8Ork666giImE+1NsBDU6Si52Nmiq3nzXnXcGK55YKXiumzbKZNOWnh8uyD20b921zgN7wXks6OUELKyRBXd/toxV7saYw7TwsHNTbfKtnmIFX/RQDX2Pl2NhI67vYDpxpNPtUOQwAbb+i0TwkGMpP9wE+z9kVqCE572ebKwW8+fs7+2p6Mv8oLr8s62Cl1ES/fYaUPn/o6m+eOt6dyUkFANd/FjaY+Yi4ayJmC1u2sg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:43:59.6686 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 390b4d02-76d8-4245-9e68-08dd0a865f52 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: SJ5PEPF000001D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR19MB6753 X-OriginatorOrg: ddn.com X-BESS-ID: 1732234643-104608-31573-63567-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.59.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWpgaWQGYGUNQizTgpOc3Awt TIMNnEyMTANMUgNTUpzdDEwMTY2CDNSKk2FgBsHTP2QgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260588 [from cloudscan12-183.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 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.c | 6 +- fs/fuse/dev_uring.c | 451 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 12 ++ fs/fuse/fuse_dev_i.h | 7 +- fs/fuse/fuse_i.h | 9 + fs/fuse/inode.c | 2 +- 6 files changed, 482 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index ad65ede9c7723bb6f3589e64b8eef7429fa4b488..15dc168fd789bf11f27fae11a732a3dfc60de97d 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -221,7 +221,7 @@ u64 fuse_get_unique(struct fuse_iqueue *fiq) } EXPORT_SYMBOL_GPL(fuse_get_unique); -static unsigned int fuse_req_hash(u64 unique) +unsigned int fuse_req_hash(u64 unique) { return hash_long(unique & ~FUSE_INT_REQ_BIT, FUSE_PQ_HASH_BITS); } @@ -1914,7 +1914,7 @@ static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, } /* Look up request on processing list by unique ID */ -static struct fuse_req *request_find(struct fuse_pqueue *fpq, u64 unique) +struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique) { unsigned int hash = fuse_req_hash(unique); struct fuse_req *req; @@ -1998,7 +1998,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, spin_lock(&fpq->lock); req = NULL; if (fpq->connected) - req = request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT); + req = fuse_request_find(fpq, oh.unique & ~FUSE_INT_REQ_BIT); err = -ENOENT; if (!req) { diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index ef5e40dcbc5154d8665c7c7ad46123c4a1d621ee..46aab7f7ee0680e84e3a62ae99e664d8b0f85421 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -19,6 +19,24 @@ MODULE_PARM_DESC(enable_uring, "Enable uring userspace communication through uring."); #endif +#define FUSE_URING_IOV_SEGS 2 /* header and payload */ + +/* + * Finalize a fuse request, then fetch and send the next entry, if available + */ +static void fuse_uring_req_end(struct fuse_ring_ent *ring_ent, bool set_err, + int error) +{ + struct fuse_req *req = ring_ent->fuse_req; + + if (set_err) + req->out.h.error = error; + + clear_bit(FR_SENT, &req->flags); + fuse_request_end(ring_ent->fuse_req); + ring_ent->fuse_req = NULL; +} + static int fuse_ring_ent_unset_userspace(struct fuse_ring_ent *ent) { struct fuse_ring_queue *queue = ent->queue; @@ -49,8 +67,11 @@ void fuse_uring_destruct(struct fuse_conn *fc) continue; WARN_ON(!list_empty(&queue->ent_avail_queue)); + WARN_ON(!list_empty(&queue->ent_w_req_queue)); WARN_ON(!list_empty(&queue->ent_commit_queue)); + WARN_ON(!list_empty(&queue->ent_in_userspace)); + kfree(queue->fpq.processing); kfree(queue); ring->queues[qid] = NULL; } @@ -109,13 +130,21 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, { struct fuse_conn *fc = ring->fc; struct fuse_ring_queue *queue; + struct list_head *pq; queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT); if (!queue) return ERR_PTR(-ENOMEM); + pq = kcalloc(FUSE_PQ_HASH_SIZE, sizeof(struct list_head), GFP_KERNEL); + if (!pq) { + kfree(queue); + return ERR_PTR(-ENOMEM); + } + spin_lock(&fc->lock); if (ring->queues[qid]) { spin_unlock(&fc->lock); + kfree(queue->fpq.processing); kfree(queue); return ring->queues[qid]; } @@ -126,6 +155,12 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, INIT_LIST_HEAD(&queue->ent_avail_queue); INIT_LIST_HEAD(&queue->ent_commit_queue); + INIT_LIST_HEAD(&queue->ent_w_req_queue); + INIT_LIST_HEAD(&queue->ent_in_userspace); + INIT_LIST_HEAD(&queue->fuse_req_queue); + + queue->fpq.processing = pq; + fuse_pqueue_init(&queue->fpq); WRITE_ONCE(ring->queues[qid], queue); spin_unlock(&fc->lock); @@ -133,6 +168,232 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, return queue; } +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); +} + +/* + * Checks for errors and stores it into the request + */ +static int fuse_uring_out_header_has_err(struct fuse_out_header *oh, + struct fuse_req *req, + struct fuse_conn *fc) +{ + int err; + + if (oh->unique == 0) { + /* Not supportd through request based uring, this needs another + * ring from user space to kernel + */ + pr_warn("Unsupported fuse-notify\n"); + err = -EINVAL; + goto seterr; + } + + if (oh->error <= -512 || oh->error > 0) { + err = -EINVAL; + goto seterr; + } + + if (oh->error) { + err = oh->error; + pr_devel("%s:%d err=%d op=%d req-ret=%d", __func__, __LINE__, + err, req->args->opcode, req->out.h.error); + goto err; /* error already set */ + } + + if ((oh->unique & ~FUSE_INT_REQ_BIT) != req->in.h.unique) { + pr_warn("Unpexted seqno mismatch, expected: %llu got %llu\n", + req->in.h.unique, oh->unique & ~FUSE_INT_REQ_BIT); + err = -ENOENT; + goto seterr; + } + + /* Is it an interrupt reply ID? */ + if (oh->unique & FUSE_INT_REQ_BIT) { + err = 0; + if (oh->error == -ENOSYS) + fc->no_interrupt = 1; + else if (oh->error == -EAGAIN) { + /* XXX Interrupts not handled yet */ + /* err = queue_interrupt(req); */ + pr_warn("Intrerupt EAGAIN not supported yet"); + err = -EINVAL; + } + + goto seterr; + } + + return 0; + +seterr: + pr_devel("%s:%d err=%d op=%d req-ret=%d", __func__, __LINE__, err, + req->args->opcode, req->out.h.error); + oh->error = err; +err: + return err; +} + +static int fuse_uring_copy_from_ring(struct fuse_ring *ring, + struct fuse_req *req, + struct fuse_ring_ent *ent) +{ + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + struct iov_iter iter; + int err, res; + struct fuse_ring_ent_in_out ring_in_out; + + res = copy_from_user(&ring_in_out, &ent->headers->ring_ent_in_out, + sizeof(ring_in_out)); + if (res) + return -EFAULT; + + err = import_ubuf(ITER_SOURCE, ent->payload, ent->max_arg_len, &iter); + if (err) + return err; + + fuse_copy_init(&cs, 0, &iter); + cs.is_uring = 1; + cs.req = req; + + return fuse_copy_out_args(&cs, args, ring_in_out.payload_sz); +} + + /* + * Copy data from the req to the ring buffer + */ +static int fuse_uring_copy_to_ring(struct fuse_ring *ring, struct fuse_req *req, + struct fuse_ring_ent *ent) +{ + struct fuse_copy_state cs; + struct fuse_args *args = req->args; + struct fuse_in_arg *in_args = args->in_args; + int num_args = args->in_numargs; + int err, res; + struct iov_iter iter; + struct fuse_ring_ent_in_out ring_in_out = { .flags = 0 }; + + if (num_args == 0) + return 0; + + err = import_ubuf(ITER_DEST, ent->payload, ent->max_arg_len, &iter); + if (err) { + pr_info_ratelimited("Import user buffer failed\n"); + return err; + } + + fuse_copy_init(&cs, 1, &iter); + cs.is_uring = 1; + cs.req = req; + + /* + * Expectation is that the first argument is the per op header. + * Some op code have that as zero. + */ + if (args->in_args[0].size > 0) { + res = copy_to_user(&ent->headers->op_in, in_args->value, + in_args->size); + err = res > 0 ? -EFAULT : res; + if (err) { + pr_info_ratelimited("Copying the header failed.\n"); + return err; + } + } + in_args++; + num_args--; + + /* copy the payload */ + err = fuse_copy_args(&cs, num_args, args->in_pages, + (struct fuse_arg *)in_args, 0); + if (err) { + pr_info_ratelimited("%s fuse_copy_args failed\n", __func__); + return err; + } + + ring_in_out.payload_sz = cs.ring.offset; + res = copy_to_user(&ent->headers->ring_ent_in_out, &ring_in_out, + sizeof(ring_in_out)); + err = res > 0 ? -EFAULT : res; + if (err) + return err; + + return 0; +} + +static int +fuse_uring_prepare_send(struct fuse_ring_ent *ring_ent) +{ + struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_ring *ring = queue->ring; + struct fuse_req *req = ring_ent->fuse_req; + int err = 0, res; + + if (WARN_ON(ring_ent->state != FRRS_FUSE_REQ)) { + pr_err("qid=%d ring-req=%p invalid state %d on send\n", + queue->qid, ring_ent, ring_ent->state); + err = -EIO; + } + + if (err) + return err; + + pr_devel("%s qid=%d state=%d cmd-done op=%d unique=%llu\n", __func__, + queue->qid, ring_ent->state, req->in.h.opcode, + req->in.h.unique); + + /* copy the request */ + err = fuse_uring_copy_to_ring(ring, req, ring_ent); + if (unlikely(err)) { + pr_info("Copy to ring failed: %d\n", err); + goto err; + } + + /* copy fuse_in_header */ + res = copy_to_user(&ring_ent->headers->in_out, &req->in.h, + sizeof(req->in.h)); + err = res > 0 ? -EFAULT : res; + if (err) + goto err; + + set_bit(FR_SENT, &req->flags); + return 0; + +err: + fuse_uring_req_end(ring_ent, true, err); + return err; +} + +/* + * Write data to the ring buffer and send the request to userspace, + * userspace will read it + * This is comparable with classical read(/dev/fuse) + */ +static int fuse_uring_send_next_to_ring(struct fuse_ring_ent *ring_ent) +{ + int err = 0; + struct fuse_ring_queue *queue = ring_ent->queue; + + err = fuse_uring_prepare_send(ring_ent); + if (err) + goto err; + + spin_lock(&queue->lock); + ring_ent->state = FRRS_USERSPACE; + list_move(&ring_ent->list, &queue->ent_in_userspace); + spin_unlock(&queue->lock); + + io_uring_cmd_complete_in_task(ring_ent->cmd, + fuse_uring_async_send_to_ring); + return 0; + +err: + return err; +} + /* * Put a ring request onto hold, it is no longer used for now. */ @@ -159,6 +420,193 @@ static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, ring_ent->state = FRRS_WAIT; } +/* Used to find the request on SQE commit */ +static void fuse_uring_add_to_pq(struct fuse_ring_ent *ring_ent, + struct fuse_req *req) +{ + struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_pqueue *fpq = &queue->fpq; + unsigned int hash; + + req->ring_entry = ring_ent; + hash = fuse_req_hash(req->in.h.unique); + list_move_tail(&req->list, &fpq->processing[hash]); +} + +/* + * 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) +{ + struct fuse_ring_queue *queue = ring_ent->queue; + + lockdep_assert_held(&queue->lock); + + if (WARN_ON_ONCE(ring_ent->state != FRRS_WAIT && + ring_ent->state != FRRS_COMMIT)) { + pr_warn("%s qid=%d state=%d\n", __func__, ring_ent->queue->qid, + ring_ent->state); + } + list_del_init(&req->list); + clear_bit(FR_PENDING, &req->flags); + ring_ent->fuse_req = req; + ring_ent->state = FRRS_FUSE_REQ; + list_move(&ring_ent->list, &queue->ent_w_req_queue); + fuse_uring_add_to_pq(ring_ent, req); +} + +/* + * Release the ring entry and fetch the next fuse request if available + * + * @return true if a new request has been fetched + */ +static bool fuse_uring_ent_assign_req(struct fuse_ring_ent *ring_ent) + __must_hold(&queue->lock) +{ + struct fuse_req *req = NULL; + struct fuse_ring_queue *queue = ring_ent->queue; + struct list_head *req_queue = &queue->fuse_req_queue; + + lockdep_assert_held(&queue->lock); + + /* get and assign the next entry while it is still holding the lock */ + if (!list_empty(req_queue)) { + req = list_first_entry(req_queue, struct fuse_req, list); + fuse_uring_add_req_to_ring_ent(ring_ent, req); + } + + return req ? true : false; +} + +/* + * Read data from the ring buffer, which user space has written to + * This is comparible with handling of classical write(/dev/fuse). + * Also make the ring request available again for new fuse requests. + */ +static void fuse_uring_commit(struct fuse_ring_ent *ring_ent, + unsigned int issue_flags) +{ + struct fuse_ring *ring = ring_ent->queue->ring; + struct fuse_conn *fc = ring->fc; + struct fuse_req *req = ring_ent->fuse_req; + ssize_t err = 0; + bool set_err = false; + + err = copy_from_user(&req->out.h, &ring_ent->headers->in_out, + sizeof(req->out.h)); + if (err) { + req->out.h.error = err; + goto out; + } + + err = fuse_uring_out_header_has_err(&req->out.h, req, fc); + if (err) { + /* req->out.h.error already set */ + pr_devel("%s:%d err=%zd oh->err=%d\n", __func__, __LINE__, err, + req->out.h.error); + goto out; + } + + err = fuse_uring_copy_from_ring(ring, req, ring_ent); + if (err) + set_err = true; + +out: + pr_devel("%s:%d ret=%zd op=%d req-ret=%d\n", __func__, __LINE__, err, + req->args->opcode, req->out.h.error); + fuse_uring_req_end(ring_ent, set_err, err); +} + +/* + * Get the next fuse req and send it + */ +static void fuse_uring_next_fuse_req(struct fuse_ring_ent *ring_ent, + struct fuse_ring_queue *queue) +{ + int has_next, err; + int prev_state = ring_ent->state; + + do { + spin_lock(&queue->lock); + has_next = fuse_uring_ent_assign_req(ring_ent); + if (!has_next) { + fuse_uring_ent_avail(ring_ent, queue); + spin_unlock(&queue->lock); + break; /* no request left */ + } + spin_unlock(&queue->lock); + + err = fuse_uring_send_next_to_ring(ring_ent); + if (err) + ring_ent->state = prev_state; + } while (err); +} + +/* FUSE_URING_REQ_COMMIT_AND_FETCH handler */ +static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags, + struct fuse_conn *fc) +{ + const struct fuse_uring_cmd_req *cmd_req = io_uring_sqe_cmd(cmd->sqe); + struct fuse_ring_ent *ring_ent; + int err; + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + uint64_t commit_id = cmd_req->commit_id; + struct fuse_pqueue fpq; + struct fuse_req *req; + + err = -ENOTCONN; + if (!ring) + return err; + + queue = ring->queues[cmd_req->qid]; + if (!queue) + return err; + fpq = queue->fpq; + + spin_lock(&queue->lock); + /* Find a request based on the unique ID of the fuse request + * This should get revised, as it needs a hash calculation and list + * search. And full struct fuse_pqueue is needed (memory overhead). + * As well as the link from req to ring_ent. + */ + req = fuse_request_find(&fpq, commit_id); + err = -ENOENT; + if (!req) { + pr_info("qid=%d commit_id %llu not found\n", queue->qid, + commit_id); + spin_unlock(&queue->lock); + return err; + } + list_del_init(&req->list); + ring_ent = req->ring_entry; + req->ring_entry = NULL; + + err = fuse_ring_ent_unset_userspace(ring_ent); + if (err != 0) { + pr_info_ratelimited("qid=%d commit_id %llu state %d", + queue->qid, commit_id, ring_ent->state); + spin_unlock(&queue->lock); + return err; + } + + ring_ent->cmd = cmd; + spin_unlock(&queue->lock); + + /* without the queue lock, as other locks are taken */ + fuse_uring_commit(ring_ent, issue_flags); + + /* + * Fetching the next request is absolutely required as queued + * fuse requests would otherwise not get processed - committing + * and fetching is done in one step vs legacy fuse, which has separated + * read (fetch request) and write (commit result). + */ + fuse_uring_next_fuse_req(ring_ent, queue); + return 0; +} + /* * fuse_uring_req_fetch command handling */ @@ -335,6 +783,9 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) return err; } break; + case FUSE_URING_REQ_COMMIT_AND_FETCH: + err = fuse_uring_commit_fetch(cmd, issue_flags, fc); + break; default: err = -EINVAL; pr_devel("Unknown uring command %d", cmd_op); diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 17767e373d31969fe2987fed31c66b5077f209c6..65e8ca9bcb10f11b1b62f2b59cda979da961ebd4 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -20,6 +20,9 @@ enum fuse_ring_req_state { /* The ring entry is waiting for new fuse requests */ FRRS_WAIT, + /* The ring entry got assigned a fuse req */ + FRRS_FUSE_REQ, + /* The ring entry is in or on the way to user space */ FRRS_USERSPACE, }; @@ -72,7 +75,16 @@ struct fuse_ring_queue { * entries in the process of being committed or in the process * to be send to userspace */ + struct list_head ent_w_req_queue; struct list_head ent_commit_queue; + + /* entries in userspace */ + struct list_head ent_in_userspace; + + /* fuse requests waiting for an entry slot */ + struct list_head fuse_req_queue; + + struct fuse_pqueue fpq; }; /** diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 7ecb103af6f0feca99eb8940872c6a5ccf2e5186..a8d578b99a14239c05b4a496a4b3b1396eb768dd 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -7,7 +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) @@ -15,6 +15,8 @@ struct fuse_arg; struct fuse_args; +struct fuse_pqueue; +struct fuse_req; struct fuse_copy_state { int write; @@ -44,6 +46,9 @@ static inline struct fuse_dev *fuse_get_dev(struct file *file) return READ_ONCE(file->private_data); } +unsigned int fuse_req_hash(u64 unique); +struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique); + void fuse_dev_end_requests(struct list_head *head); void fuse_copy_init(struct fuse_copy_state *cs, int write, diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 5e009a3511d3dd4e9c0e8b4f08ebb271831b1236..55cac719ed7355a73546c148f1b2c257fa1b70f7 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -435,6 +435,10 @@ struct fuse_req { /** fuse_mount this request belongs to */ struct fuse_mount *fm; + +#ifdef CONFIG_FUSE_IO_URING + void *ring_entry; +#endif }; struct fuse_iqueue; @@ -1215,6 +1219,11 @@ void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o); */ struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); +/** + * Initialize the fuse processing queue + */ +void fuse_pqueue_init(struct fuse_pqueue *fpq); + /** * Initialize fuse_conn */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index c8f72a50047ac1dfc7e52e9f4e49716a016326ff..b0d44176601f6f7591042d8553596888a7490a85 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -906,7 +906,7 @@ static void fuse_iqueue_init(struct fuse_iqueue *fiq, fiq->priv = priv; } -static void fuse_pqueue_init(struct fuse_pqueue *fpq) +void fuse_pqueue_init(struct fuse_pqueue *fpq) { unsigned int i; From patchwork Thu Nov 21 23:43:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882454 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 BDA3F1CCECC; Thu, 21 Nov 2024 23:44:09 +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=1732232653; cv=fail; b=BYhoTJqyAUpJoC+7oI0yk8SVPL8oS20RtZmWxhf1ryrCymfCCLRWe7OtMumVEX4vQjKNryEC5sj4InNJzBdH2xkN5b1y/8zm7NywHpgEy17CqYlnuni95a9uD3KXzJV12M+udHe/cw48ty7fmrPktVWk0fk29Ngrqud2/Esi+Tc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232653; c=relaxed/simple; bh=qqx868tGyDw5xZZuq9FXzl5HlH5zvSG2W4LzxNADCc4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MwhhKAQm8eaED0NlQPeC3v8CShuPeqq7axH7+dW7erxyDRUUYE5uhBH0iNl3Tr/AUEsf6XoJSDapV3Upj1ts0qVRSoI5FbzIlv2BlMLkVgL7XctSdhM+FYhoj6i85wPHsCdfWnlHBdgESrZYDPoRn5iSi/zHwvBhTMCQ/q8zDxc= 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=WntV1mqh; 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="WntV1mqh" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by mx-outbound-ea22-15.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vbqftvrKgtMinaIPivOgNs/qUD/fR0VefG9YMxxoIIEtfoAQSqDv0m5FYiumBurZgcP831h3jSiBBMPPNdd5TnVIeG5O32iavnrm3WkA69DqXh4eyKc6nZMeT+BvPXrvrp4W+65nfJyeH1epu1PpbLsUS1TEasS/E5fpw2PXPsRB/LlWJI43tR0NHnvtCMxw63qoDAwBNUniIG76VXGdW1+b7hkao25r+7f0ROHrPWfDu6jrrdGHcB3ChCzuRFTMQ4o8mKWTz0kIRRsBZg+3UUEXCzyMIrwup0jiELJPRlR0FQ8xBkJsEDJAKgV/R2mTnMQtmrOpsArj3ifKezEB7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=16RRFb/xAw/dqZWvCEFWiWT9fLGSzu+LZzgJRddshBs=; b=Nq+8G7G459zSwjSlA1SRmFxSK/4z0bNaiOq6aNzEpazferWSVEa9p7AL4gE7cJdsSKayCQVxagXfqP/c1HOjY11IghHJDOrrfjnn0lCEfUQS1ift+cOIXmImhDhg6iYuzhM26oEuH/OTKhduY+P1+KkKDf6+rGIDkP8Ra+27KM+6jrslJt2LU6eLhdSH/ewwZB0lQl2ZSVd1H0gQ/jpcnF9WZ/HE12V69zyVGJtvx2NKq66yFY8RyO15JUP3PqjrIDvE8xUCZAfKV2MQSdca+xRm17zvR+iE2VMPGFFt7keOvEwyvE+Wy/YKB0PtiDh25mY/PFkVMsud7lf2b503xQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=16RRFb/xAw/dqZWvCEFWiWT9fLGSzu+LZzgJRddshBs=; b=WntV1mqh08GdDkqO799j5AzWPJ7eIRPhbJFJXxdHdOfngjcm3MPHK5+cxbapQeLcIMEyeSVGjaCMfUsdr3hjkaT8DGIDWKWN0Mw50GYo215YAIirxwzY+oaMpyz8x3u4F8FEkQ9xzACQ/bScTLo0oq9Cos8LunE6O+Nsh93P3+0= Received: from DM5PR07CA0112.namprd07.prod.outlook.com (2603:10b6:4:ae::41) by CH2PR19MB3943.namprd19.prod.outlook.com (2603:10b6:610:9e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Thu, 21 Nov 2024 23:44:00 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:4:ae:cafe::aa) by DM5PR07CA0112.outlook.office365.com (2603:10b6:4:ae::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:44:00 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id A841D32; Thu, 21 Nov 2024 23:43:59 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:26 +0100 Subject: [PATCH RFC v6 10/16] fuse: {uring} Handle teardown of ring entries Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-10-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=12152; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=qqx868tGyDw5xZZuq9FXzl5HlH5zvSG2W4LzxNADCc4=; b=P24cqy/peBqDraMGIBtJJ2gazVHAfMCsuGBcBU4ThFqNNxvTZkaF7MoKOvvehunLWhn1Nr3ET 8fXD1rkX3BGDUvkoaY/wOK1S98HeYmxlYZN/d3N9ap3iAABZZLWUfuD X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|CH2PR19MB3943:EE_ X-MS-Office365-Filtering-Correlation-Id: 91905fb1-85c9-40b5-740f-08dd0a865fc4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YWN8y06YH24XPHj5fbeMwNNO6BW0DI1?= =?utf-8?q?i7o1OchMrKDviqNtQXRMJ4ufEg+PQEa5oNXbv5rDe/YwaZf7jqm7bEYSJXFyQpUGh?= =?utf-8?q?q+/Sfo/zjjzoHWDyu0IDDRzsuFaxDx5RW6AvBGxunbJ8lulkUoHUeM9MJuvranM2r?= =?utf-8?q?sS76WD5NADNGDX+MlYKF++8wAOBSQBUBAcaq6p+KoblsTSM8QdOAxDuAKH+rOh3hL?= =?utf-8?q?IG7DqV0ub7g+cetjwB+F1LPR7y0jSeGgoe2jIkjm2DSIhqxefrUr5gCALlaCR0OW2?= =?utf-8?q?SeZ/eLNzYICQnLKkKILeU2cb48T2dYis7A36DEz2O2avUzr3j5cIq0Dxs5Wnnpt2R?= =?utf-8?q?P2u3gzbgoM7RaSoaAgtupvjRlmMowZ4hXKUfgskMIu01Rj9LGKcvog3Iks0LbfMAC?= =?utf-8?q?Dek5OU0Gqoto2EB84xvChXY0sbXFZ5xxx5sbfQrAnKfl1jm59LTB9TtSuiDmHPw7R?= =?utf-8?q?mu3IZ5RsxwYJFrR+sJBNRIthCufIfqWvzqLO9HLFZgzD1ZRnV5Ki+jG5vynROHSex?= =?utf-8?q?oyV6Se+RnrwaX8EMtDQ06oKuRFcNcJh/I/3FfbLC+78WuxgOMVFC51SOc4VuSRgBj?= =?utf-8?q?3OESieAhAg+8hc9wy92ncTMYwDiXy4I5pVbR8uqOPntYGm3SkBRM8jE71foOecUQ7?= =?utf-8?q?8WvNel64UH5zg8JuqNf8xyoOrsjiN66xCWuhaN7DqM65NvQ+hcx+j7ezHyHSNMGJg?= =?utf-8?q?ibK14qDLbwUXPc+qKKiw7Xl1FGdQ+GmNWARZgvksHXk7w432L4cDRDJMetNfvwwq9?= =?utf-8?q?W9vDr0IoBDLMYXtP5ZVfTZe3EfMDRo9hzprOWaxwamqvqdWRcaa9G/668Bl/utCJ8?= =?utf-8?q?ggW+E6HiyMIn028wryMG8oA40I1UXga39WGD8HDUDrPtetY4JgpqD1S1gDXSNeIz9?= =?utf-8?q?sc2fHNmUrRCuqiF+K/nj003BfA4DbhNF3dV3iyYwyvYAn5zFmhR2DvT3lmo3imq7t?= =?utf-8?q?NeI1Ji/h4Ucnp/KlO5cAex6+lHzybcw7YduVaT6d4qYRQgXhDd1AylRL0Kb0UF9Ow?= =?utf-8?q?YpJijHjKMcUioY/bONGHwQtmtEm7Ha927c+AQmNHm/EE1xWzEZyIDskX5GsXUlUc4?= =?utf-8?q?c4GC20L3FPruqVZZvpVwca59PTNuoLxaLS02gjt2i/TtYzlRVsUvkiVbD0Fff5/14?= =?utf-8?q?g5lu3aPapBdiMGGkUDaY89PMyeGqCBqW6Pm5vSItmSK/DKzWxD8GLHD0KazWIW7Nk?= =?utf-8?q?B9CrB1XUos1nZ7DBeyqCT+DYeSPEYNaTHQsN2pj2hiAmdPU8p4v3Xv/ELfpn1cVGI?= =?utf-8?q?uiv2u/ieknpyaWTqQJ6drO8g1Y4DOU36IFuxCoNiJm48QjM+ybyCpvaq7T5XDHgVa?= =?utf-8?q?xkpd8KKD5wTClSqF+LzSRAQXfFs/ghPneg=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(376014)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PXq/qsYgEVgIB4kfgClPfg7n4vj3yWrg/j/85Sgkw0i+DUHwCPq2AfBBbvgwUN9GbPTw/X6GdO45RTJspz5wmtNz+wsOVBXEeVrhEwY0rAQE6gNIpMsFIAgg7aKSdZjbvc7FmRmqJFofHLTMzu9PJ/SuFMZfVvunaqTl5mCT6pZdFcmB+PWxMAy1da5vFSi1fRRMHIdbVVvckqpB3U2ZynRHCU5+Pb2Oy+KUBhzUOul5EeFFUVTw55IGLyoLln6bo7ke+pdlSHK4hJMDrGS9dwrbz+Srl0sqcIhD3Ov078m732zdNgIBUsf8bGsggYjcNnFE6lj1shM4IVjQJJxxyiHoPmGbGMSrXeRL4ovkRcUjauQM2tWZo25mbLsjdJ2WbDifqQq/x/SmfPWZBTcVtKnqG0jngW/+D99RFCpLuKuVofUJH4bbF/hLWmNTVkdXcolX/CpSEXg0NvI3p5NYHFdR+9uf44iAryzeXkboljJxhPHJm0Ymc13qyBXhiDWT2Pi9GKt3EHy+IU+rFCiHAyAqgkoKoX+84auCADDZHPt4R4buGtBqhk4yfWYKysMahdcJDqi3VsfUBfv+1zk0XnIob9gbepEIX9G8Jn7Zq7cHjcMMI3XPw9wxWrg9IHZeFFDuhfE5xBHaMnTUmQrBsQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:00.4302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91905fb1-85c9-40b5-740f-08dd0a865fc4 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: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR19MB3943 X-BESS-ID: 1732232644-105647-10640-35209-1 X-BESS-VER: 2019.3_20241120.2021 X-BESS-Apparent-Source-IP: 104.47.57.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaG5saGQGYGUDTJIjE51TIx0T LVONnEyMzU0NDE0NgkySQp0TzN3MTSSKk2FgByvYfaQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan19-44.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 On teardown struct file_operations::uring_cmd requests need to be completed by calling io_uring_cmd_done(). Not completing all ring entries would result in busy io-uring tasks giving warning messages in intervals and unreleased struct file. Additionally the fuse connection and with that the ring can only get released when all io-uring commands are completed. Completion is done with ring entries that are a) in waiting state for new fuse requests - io_uring_cmd_done is needed b) already in userspace - io_uring_cmd_done through teardown is not needed, the request can just get released. If fuse server is still active and commits such a ring entry, fuse_uring_cmd() already checks if the connection is active and then complete the io-uring itself with -ENOTCONN. I.e. special handling is not needed. This scheme is basically represented by the ring entry state FRRS_WAIT and FRRS_USERSPACE. Entries in state: - FRRS_INIT: No action needed, do not contribute to ring->queue_refs yet - All other states: Are currently processed by other tasks, async teardown is needed and it has to wait for the two states above. It could be also solved without an async teardown task, but would require additional if conditions in hot code paths. Also in my personal opinion the code looks cleaner with async teardown. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 8 ++ fs/fuse/dev_uring.c | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 51 ++++++++++++ 3 files changed, 275 insertions(+) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 15dc168fd789bf11f27fae11a732a3dfc60de97d..17a76d0c964f1ecd27dd447504c94646f4ba6b6e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2295,6 +2295,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); } @@ -2306,6 +2312,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 46aab7f7ee0680e84e3a62ae99e664d8b0f85421..19d5d3eafced090a84651b21a9f65cd8b3414435 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -52,6 +52,37 @@ static int fuse_ring_ent_unset_userspace(struct fuse_ring_ent *ent) return 0; } +/* 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(req_list); + + spin_lock(&queue->lock); + list_for_each_entry(req, &queue->fuse_req_queue, list) + clear_bit(FR_PENDING, &req->flags); + list_splice_init(&queue->fuse_req_queue, &req_list); + spin_unlock(&queue->lock); + + /* must not hold queue lock to avoid order issues with fi->lock */ + fuse_dev_end_requests(&req_list); +} + +void fuse_uring_abort_end_requests(struct fuse_ring *ring) +{ + int qid; + struct fuse_ring_queue *queue; + + for (qid = 0; qid < ring->nr_queues; qid++) { + queue = READ_ONCE(ring->queues[qid]); + if (!queue) + continue; + + queue->stopped = true; + fuse_uring_abort_end_queue_requests(queue); + } +} + void fuse_uring_destruct(struct fuse_conn *fc) { struct fuse_ring *ring = fc->ring; @@ -111,9 +142,12 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc) goto out_err; } + init_waitqueue_head(&ring->stop_waitq); + fc->ring = ring; ring->nr_queues = nr_queues; ring->fc = fc; + atomic_set(&ring->queue_refs, 0); spin_unlock(&fc->lock); return ring; @@ -175,6 +209,182 @@ fuse_uring_async_send_to_ring(struct io_uring_cmd *cmd, io_uring_cmd_done(cmd, 0, 0, issue_flags); } +static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) +{ + struct fuse_req *req = ent->fuse_req; + + /* remove entry from fuse_pqueue->processing */ + list_del_init(&req->list); + ent->fuse_req = NULL; + clear_bit(FR_SENT, &req->flags); + req->out.h.error = -ECONNABORTED; + fuse_request_end(req); +} + +/* + * Release a request/entry on connection tear down + */ +static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, + bool need_cmd_done) +{ + struct fuse_ring_queue *queue = ent->queue; + + /* + * fuse_request_end() might take other locks like fi->lock and + * can lead to lock ordering issues + */ + lockdep_assert_not_held(&ent->queue->lock); + + if (need_cmd_done) { + pr_devel("qid=%d sending cmd_done\n", queue->qid); + + io_uring_cmd_done(ent->cmd, -ENOTCONN, 0, + IO_URING_F_UNLOCKED); + } + + if (ent->fuse_req) + fuse_uring_stop_fuse_req_end(ent); + + list_del_init(&ent->list); + kfree(ent); +} + +static void fuse_uring_stop_list_entries(struct list_head *head, + struct fuse_ring_queue *queue, + enum fuse_ring_req_state exp_state) +{ + struct fuse_ring *ring = queue->ring; + struct fuse_ring_ent *ent, *next; + ssize_t queue_refs = SSIZE_MAX; + LIST_HEAD(to_teardown); + + spin_lock(&queue->lock); + list_for_each_entry_safe(ent, next, head, list) { + if (ent->state != exp_state) { + pr_warn("entry teardown qid=%d state=%d expected=%d", + queue->qid, ent->state, exp_state); + continue; + } + + list_move(&ent->list, &to_teardown); + } + spin_unlock(&queue->lock); + + /* no queue lock to avoid lock order issues */ + list_for_each_entry_safe(ent, next, &to_teardown, list) { + bool need_cmd_done = ent->state != FRRS_USERSPACE; + + fuse_uring_entry_teardown(ent, need_cmd_done); + queue_refs = atomic_dec_return(&ring->queue_refs); + + if (WARN_ON_ONCE(queue_refs < 0)) + pr_warn("qid=%d queue_refs=%zd", queue->qid, + queue_refs); + } +} + +static void fuse_uring_teardown_entries(struct fuse_ring_queue *queue) +{ + fuse_uring_stop_list_entries(&queue->ent_in_userspace, queue, + FRRS_USERSPACE); + fuse_uring_stop_list_entries(&queue->ent_avail_queue, queue, FRRS_WAIT); +} + +/* + * Log state debug info + */ +static void fuse_uring_log_ent_state(struct fuse_ring *ring) +{ + int qid; + struct fuse_ring_ent *ent; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = ring->queues[qid]; + + if (!queue) + continue; + + spin_lock(&queue->lock); + /* + * Log entries from the intermediate queue, the other queues + * should be empty + */ + list_for_each_entry(ent, &queue->ent_w_req_queue, list) { + pr_info(" ent-req-queue ring=%p qid=%d ent=%p state=%d\n", + ring, qid, ent, ent->state); + } + list_for_each_entry(ent, &queue->ent_commit_queue, list) { + pr_info(" ent-req-queue ring=%p qid=%d ent=%p state=%d\n", + ring, qid, ent, ent->state); + } + spin_unlock(&queue->lock); + } + ring->stop_debug_log = 1; +} + +static void fuse_uring_async_stop_queues(struct work_struct *work) +{ + int qid; + struct fuse_ring *ring = + container_of(work, struct fuse_ring, async_teardown_work.work); + + /* XXX code dup */ + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = READ_ONCE(ring->queues[qid]); + + if (!queue) + continue; + + fuse_uring_teardown_entries(queue); + } + + /* + * Some ring entries are might be in the middle of IO operations, + * i.e. in process to get handled by file_operations::uring_cmd + * or on the way to userspace - we could handle that with conditions in + * run time code, but easier/cleaner to have an async tear down handler + * If there are still queue references left + */ + if (atomic_read(&ring->queue_refs) > 0) { + if (time_after(jiffies, + ring->teardown_time + FUSE_URING_TEARDOWN_TIMEOUT)) + fuse_uring_log_ent_state(ring); + + schedule_delayed_work(&ring->async_teardown_work, + FUSE_URING_TEARDOWN_INTERVAL); + } else { + wake_up_all(&ring->stop_waitq); + } +} + +/* + * Stop the ring queues + */ +void fuse_uring_stop_queues(struct fuse_ring *ring) +{ + int qid; + + for (qid = 0; qid < ring->nr_queues; qid++) { + struct fuse_ring_queue *queue = READ_ONCE(ring->queues[qid]); + + if (!queue) + continue; + + fuse_uring_teardown_entries(queue); + } + + if (atomic_read(&ring->queue_refs) > 0) { + pr_info("ring=%p scheduling async queue stop\n", ring); + ring->teardown_time = jiffies; + INIT_DELAYED_WORK(&ring->async_teardown_work, + fuse_uring_async_stop_queues); + schedule_delayed_work(&ring->async_teardown_work, + FUSE_URING_TEARDOWN_INTERVAL); + } else { + wake_up_all(&ring->stop_waitq); + } +} + /* * Checks for errors and stores it into the request */ @@ -565,6 +775,9 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags, return err; fpq = queue->fpq; + if (!READ_ONCE(fc->connected) || READ_ONCE(queue->stopped)) + return err; + spin_lock(&queue->lock); /* Find a request based on the unique ID of the fuse request * This should get revised, as it needs a hash calculation and list @@ -732,6 +945,7 @@ static int fuse_uring_fetch(struct io_uring_cmd *cmd, unsigned int issue_flags, if (WARN_ON_ONCE(err != 0)) goto err; + atomic_inc(&ring->queue_refs); _fuse_uring_fetch(ring_ent, cmd, issue_flags); return 0; @@ -758,6 +972,8 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) pr_info_ratelimited("fuse-io-uring is not enabled yet\n"); return err; + pr_devel("%s:%d received: cmd op %d\n", __func__, __LINE__, cmd_op); + err = -EOPNOTSUPP; if (!enable_uring) { pr_info_ratelimited("uring is disabled\n"); diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 65e8ca9bcb10f11b1b62f2b59cda979da961ebd4..e567a20731d76f47b7ebe3f31da4a9348f6d2bc8 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -11,6 +11,9 @@ #ifdef CONFIG_FUSE_IO_URING +#define FUSE_URING_TEARDOWN_TIMEOUT (5 * HZ) +#define FUSE_URING_TEARDOWN_INTERVAL (HZ/20) + enum fuse_ring_req_state { FRRS_INVALID = 0, @@ -85,6 +88,8 @@ struct fuse_ring_queue { struct list_head fuse_req_queue; struct fuse_pqueue fpq; + + bool stopped; }; /** @@ -99,11 +104,50 @@ struct fuse_ring { size_t nr_queues; struct fuse_ring_queue **queues; + /* + * Log ring entry states onces on stop when entries cannot be + * released + */ + unsigned int stop_debug_log : 1; + + wait_queue_head_t stop_waitq; + + /* async tear down */ + struct delayed_work async_teardown_work; + + /* log */ + unsigned long teardown_time; + + atomic_t queue_refs; }; void fuse_uring_destruct(struct fuse_conn *fc); +void fuse_uring_stop_queues(struct fuse_ring *ring); +void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); +static inline void fuse_uring_abort(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + + if (ring == NULL) + return; + + if (atomic_read(&ring->queue_refs) > 0) { + fuse_uring_abort_end_requests(ring); + fuse_uring_stop_queues(ring); + } +} + +static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) +{ + struct fuse_ring *ring = fc->ring; + + if (ring) + wait_event(ring->stop_waitq, + atomic_read(&ring->queue_refs) == 0); +} + #else /* CONFIG_FUSE_IO_URING */ struct fuse_ring; @@ -116,6 +160,13 @@ static inline void fuse_uring_destruct(struct fuse_conn *fc) { } +static inline void fuse_uring_abort(struct fuse_conn *fc) +{ +} + +static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) +{ +} #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ From patchwork Thu Nov 21 23:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882458 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 D4AF41DE887; Thu, 21 Nov 2024 23:44:10 +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=1732232654; cv=fail; b=QMUwJQynC3DIetUubBpKgA+m81vSFFY1ZV6gO37un4GXw5Jg3GF2m/UPZVXLeKDChpN0m2PBu2nWjTi9iCq1t/LWJrhejelwzK9BjgpXHu7wvejeC8VmBQ5QjOyq9SfaKM0jb4uFYSXWLKB2NGR7dr7knQ2QQx1+OMvSDkYS6mE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232654; c=relaxed/simple; bh=GCId+RDUEffzIBUHtzowycYurRMNb0KURktFRP35iLc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BLZF2iJ2YLHbrI+Qh25DbT6ZdeIgn39PyYU5QpA7i34q3tAtc0Wd/dAuiF0AIoMZYtNGH9+CYw39NeRUEpouXw28pDUTT+wZNefdltlY3PbiIQ1J7Lx7i/uFm2raNfaZwAejSbQTFKM9tXp6dKqJvNWMiakD0wrAy4lABNrv/tg= 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=z7mQHW6o; 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="z7mQHW6o" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2043.outbound.protection.outlook.com [104.47.55.43]) by mx-outbound44-164.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tt01KSY2YGpXm4daxCBYmpIa4rPsy6b1REGr4pNTaKqpdo5WqHaQ8gYyf5xbtgcJS9qPNyE56ONzIt5ycZjEqmzbAmcC8/FIWq68Y1bynVCQ5wFwR/3cU4fxLQurRVb9YWoRXnc+4jrqFB8pUgVrEaSRFXSwRix/4/QT6H8XI/2qVCC7OS9kKEtFJxWbmqh72aQQSnLq5HVrzQ90e9JlR2ekSGQV08SHfcgTpd8usitTJ1+uFMVb0Qi60NPYlpmAvqVv4bxnJfnlWhCZAAKUIsny2uOfUT2yn7780XlHmh64GD+iKg4YMNbsQkN2Lex+dc61m8ONvAvwx1cUa8Cz9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WZNXfBou4nGFjf0CyPDiEneLINkxSvP6uiBRQ/+zuGs=; b=ZQdoUC3hKJaUl6Zkh42RmmyZv2KPNxJE7hl+OLJg7VP4cK4EC40byWJ3bcODSRGKAhlyOkLr9+k76rhnCuq1QtaBtkcgQ0gjJMUiBZM7sHMnGWC/BkHkv91WQdhO4VVE2OV75rx/2JdkEk4ShngDiJ7Z9BoOm4AsM7pcp0mjBKJysISVM1lQUif7nPyTOid3+1yhDGIevMrYEPZv6j6ElwfNtZOQdC4ANZB2y+LXicid2ay2+JvuVzWx1X5eFMSPpjma0Y9gDP3KnPb+D+TGUJn3ekDynIsUeLkmwuKwwoBeIIK0+Jvcs5Xykxv6d9VMVzmc3vPqORP7k3RZ1JMWMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=WZNXfBou4nGFjf0CyPDiEneLINkxSvP6uiBRQ/+zuGs=; b=z7mQHW6oAAtzW+q7F6LmhPCQfaYkxgUKWU63bpppnYNdEINLxtwlq18cohQokSOZgT0+13514L1oUU/dQCve0j+ERBLGgxHqv9acRP3ibpUhBYjIQ9CYTEKn5qcwDjZKQDDv0PXNjo53aNFE3pRfHnRi8ZfHgPSyy92eFxlHvc8= Received: from BN9PR03CA0881.namprd03.prod.outlook.com (2603:10b6:408:13c::16) by SA3PR19MB8217.namprd19.prod.outlook.com (2603:10b6:806:39d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Thu, 21 Nov 2024 23:44:02 +0000 Received: from BL02EPF0002992E.namprd02.prod.outlook.com (2603:10b6:408:13c:cafe::18) by BN9PR03CA0881.outlook.office365.com (2603:10b6:408:13c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 BL02EPF0002992E.mail.protection.outlook.com (10.167.249.59) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:44:01 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id A0E342D; Thu, 21 Nov 2024 23:44:00 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:27 +0100 Subject: [PATCH RFC v6 11/16] fuse: {uring} Allow to queue fg requests through io-uring Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-11-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=8742; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=GCId+RDUEffzIBUHtzowycYurRMNb0KURktFRP35iLc=; b=mXsJLneynssq+37jB7noyfuOQLlvdKa0jWBkI0vCzF6X4+o1FUil6qJal4+obTaV5qcr2XBkj xKouZZ08UrFBSEBDJxrc33IqPbhBZ/NkFdAcxS2ow53VhJ2Fwh8+lzb X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992E:EE_|SA3PR19MB8217:EE_ X-MS-Office365-Filtering-Correlation-Id: 0730f57b-87a8-4d3a-c2e4-08dd0a8660ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?r+Yyapxabyh11jG9Wtbu+vlD2hRONMc?= =?utf-8?q?p7/YlWNgmzSoZqvMnz+9yaPd30sXdZDWAE7dQyujy9eNaC1U0n1kKHLggye2C4ZAW?= =?utf-8?q?OvlhTMU4gmOmC+aq4/Suu6SSARuF1WdyqL/B0bZ71BQX9sKKnKZfLhrCgoYWBlkOP?= =?utf-8?q?BkJT4+QIs7qsFk9t0ZtYRfJ23rW0jJt+rpqsUupHugG6eb01yW0h+8+xtYI8Tzzwf?= =?utf-8?q?L+Tf7RnctW6HCniFXQzBwG8Afd/UbPOij/kFe/kYV05rcVfaOCPKkiMguqZ37nLYE?= =?utf-8?q?suYSkRmcRopwyzqm3JT5wOkJcU75O7+K4UthgZRQzlMyRKL1yFH+wncwSVsEzgzcR?= =?utf-8?q?R035Q3xDfwhDF7JLf98PjuYg90h/R8Xnelov+JoIP6XV673iAEPwmvVC6Y+eX5J0p?= =?utf-8?q?uRPbCVLbKiOBY49IntxLwBpKEOIdppfh69+TSqPamwN+sZzE+sngb21FGsXX9ixLk?= =?utf-8?q?OFEzQI6MMlR956ClOyqtuYnUvKvAUqQw0ePUJwKS8opYQeQc6CauS3hDh4RwYLVbO?= =?utf-8?q?4t3uxn/YP0DaMYgpgt1qhaelxg6WEImo/rAHQLywpa79Loocbl+JNf+P66hIq7ZZG?= =?utf-8?q?eVD8bUsMqcEJVB9r52dHYloAuX3GUdkbNOj4zXUurMn4Fgk4mY+p3P9bIGj4Alq2Y?= =?utf-8?q?rckrsoMOOCivEBDVF1xv/6j7OUsEXixTggTS5Fa/dlUoPG8+ZJLXE3ctt8QeLI/nh?= =?utf-8?q?cPcnC+CK5LCDzHsdqt8DYjEzcopPbUAC7JGG75pwgrObWT7Fs9/Ox8pO08Qq//zeM?= =?utf-8?q?RZ54FQUiBNulgFn249rMiA4j9oHhultPRGyK9d50o2JRyOzvymF0f3wjn21rWHPHp?= =?utf-8?q?0Bspt0Ss3QjusIvECH8Kp+rJxf/ZjmLo2G9w6XBwGt3xt3VoK7fCurawE/UKfHtGx?= =?utf-8?q?YUp2tUcCEYSjLn7Whrdl4BolsaYfErRCrzpf7w7vc/ZQDZ0Qua3b2FK1r0jE+15ES?= =?utf-8?q?v5AAutiewEvjO4O5vy9uZ9/xYJHAWJ23rWs409dg+Klr2KL0BSp9hNqZHJiAA0Xbi?= =?utf-8?q?3oBblJ3MNKdc+AcaxBFaYq0/Rys2sT60Fnv8sbSpUbVioNyGsuuCBuoFn903z6KPS?= =?utf-8?q?TEvcyUaOiBoTfaAl/Gk3uzYy72497LNjcfix+i25/WuH2Qrpu/QWeq9sI5WePtqL2?= =?utf-8?q?LQeHDXUSPZGnfxal22lOgrFupA7aAOCxEeI2y81mldMscZuMypNA5XIT7UiqZ2MpJ?= =?utf-8?q?5aw5aBahxj5Tp78k6irAjqxCBV6T5/zRZqkBjtJMvz+b3rbHVa5H+QjhmQFhqiBGe?= =?utf-8?q?VvqwMlNRLfKKGmJAMgFLAx8aGougB95lQcxfq+adzATLuTmgy05DWZQrBWP94mvgx?= =?utf-8?q?FTFjfCUiuMymWPf7rbt7Qm3xfuGrvXlmvQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Q+ZlUWzrUcZLGLSyFye4rgWdQpNme7dOqD/ooMLtS0fBldnAFn6/+CDGM0WhW8RvNVGjmwSOd952Kvi7EiO8dW1xnlQOgvdU8T98aCrXoOFohsVFK38PwuwFIYsQW6QCXNUdjnIBioGurZ4txCDIKH5lO0XU5q7NeOhbpNg2zOriBISTyr11CYjAo8SybkjWtIxfCC4TKBV19kBX1QMC+Qm8CnSSp2X4Qv3Um+K7gaXcIj11IkU/TqLQHSuiiQ61OXKJr4jGt8vswtSw4/wFlHa3Ja/64oXvHJ/e82soMVZYgyZLVk/RWQiBdIE9M5DSyLQDMEx3HyK39hDpOG3iofs1kB3bPHc0QvEeEcyPKfX+4pXsS9dFkubOwHYdYMj4/peTyJmT/xR1iKw/31PWefaSbgwXTgGpi4C6hto6Tecp6AtLjqPMgb6scPhxkXJ3XXMGijCWykhyH8MJ7kUByeT40sD0rs23KwXW8cijhUx0rqRhw+6XpnzJkyNZptn9kWK1ty9YQ8p0oKF23p0yQQ4sDq33a+8EWQ1iclrie/l3/r3VrHbyKKamLuOksbd0ExSnASjKh/6jQM9bD9ZsBk5qs+0MZZQdaOgqIKl7TmTbkEaa0k9vUaGI3BMkGXrIvs1X1zPELHEyPleqdgttZQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:01.9351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0730f57b-87a8-4d3a-c2e4-08dd0a8660ba 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: BL02EPF0002992E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR19MB8217 X-BESS-ID: 1732232645-111428-21133-25879-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.55.43 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhYmJoZAVgZQ0NwwySLVLNEgNS nFwsLUINE80cDEMiXNyMDEwsjA0sBYqTYWAK0oQN9BAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan8-154.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 This prepares queueing and sending foreground requests through io-uring. Signed-off-by: Bernd Schubert --- fs/fuse/dev.c | 5 +- fs/fuse/dev_uring.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 11 ++++ fs/fuse/fuse_dev_i.h | 5 ++ 4 files changed, 178 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 17a76d0c964f1ecd27dd447504c94646f4ba6b6e..ff7fd5c1096e8bb1f3479c2ac353c9a14fbf7ecd 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -237,7 +237,8 @@ __releases(fiq->lock) spin_unlock(&fiq->lock); } -static void fuse_dev_queue_forget(struct fuse_iqueue *fiq, struct fuse_forget_link *forget) +void fuse_dev_queue_forget(struct fuse_iqueue *fiq, + struct fuse_forget_link *forget) { spin_lock(&fiq->lock); if (fiq->connected) { @@ -250,7 +251,7 @@ static void fuse_dev_queue_forget(struct fuse_iqueue *fiq, struct fuse_forget_li } } -static void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) +void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) { spin_lock(&fiq->lock); if (list_empty(&req->intr_entry)) { diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 19d5d3eafced090a84651b21a9f65cd8b3414435..d8653b4fd990000c8de073089416944877b4a3a8 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -21,6 +21,12 @@ MODULE_PARM_DESC(enable_uring, #define FUSE_URING_IOV_SEGS 2 /* header and payload */ +struct fuse_uring_cmd_pdu { + struct fuse_ring_ent *ring_ent; +}; + +const struct fuse_iqueue_ops fuse_io_uring_ops; + /* * Finalize a fuse request, then fetch and send the next entry, if available */ @@ -820,6 +826,31 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags, return 0; } +static bool is_ring_ready(struct fuse_ring *ring, int current_qid) +{ + int qid; + struct fuse_ring_queue *queue; + bool ready = true; + + for (qid = 0; qid < ring->nr_queues && ready; qid++) { + if (current_qid == qid) + continue; + + queue = ring->queues[qid]; + if (!queue) { + ready = false; + break; + } + + spin_lock(&queue->lock); + if (list_empty(&queue->ent_avail_queue)) + ready = false; + spin_unlock(&queue->lock); + } + + return ready; +} + /* * fuse_uring_req_fetch command handling */ @@ -828,11 +859,23 @@ static void _fuse_uring_fetch(struct fuse_ring_ent *ring_ent, unsigned int issue_flags) { struct fuse_ring_queue *queue = ring_ent->queue; + struct fuse_ring *ring = queue->ring; + struct fuse_conn *fc = ring->fc; + struct fuse_iqueue *fiq = &fc->iq; spin_lock(&queue->lock); fuse_uring_ent_avail(ring_ent, queue); ring_ent->cmd = cmd; spin_unlock(&queue->lock); + + if (!ring->ready) { + bool ready = is_ring_ready(ring, queue->qid); + + if (ready) { + WRITE_ONCE(ring->ready, true); + fiq->ops = &fuse_io_uring_ops; + } + } } /* @@ -1013,3 +1056,119 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) return -EIOCBQUEUED; } + +/* + * This prepares and sends the ring request in fuse-uring task context. + * User buffers are not mapped yet - the application does not have permission + * to write to it - this has to be executed in ring task context. + */ +static void +fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + struct fuse_uring_cmd_pdu *pdu = (struct fuse_uring_cmd_pdu *)cmd->pdu; + struct fuse_ring_ent *ring_ent = pdu->ring_ent; + struct fuse_ring_queue *queue = ring_ent->queue; + int err; + + BUILD_BUG_ON(sizeof(pdu) > sizeof(cmd->pdu)); + + err = fuse_uring_prepare_send(ring_ent); + if (err) + goto err; + + io_uring_cmd_done(cmd, 0, 0, issue_flags); + + spin_lock(&queue->lock); + ring_ent->state = FRRS_USERSPACE; + list_move(&ring_ent->list, &queue->ent_in_userspace); + spin_unlock(&queue->lock); + return; +err: + fuse_uring_next_fuse_req(ring_ent, queue); +} + +static struct fuse_ring_queue *fuse_uring_task_to_queue(struct fuse_ring *ring) +{ + unsigned int qid; + struct fuse_ring_queue *queue; + + qid = task_cpu(current); + + if (WARN_ONCE(qid >= ring->nr_queues, + "Core number (%u) exceeds nr ueues (%zu)\n", qid, + ring->nr_queues)) + qid = 0; + + queue = ring->queues[qid]; + if (WARN_ONCE(!queue, "Missing queue for qid %d\n", qid)) + return NULL; + + return queue; +} + +/* queue a fuse request and send it if a ring entry is available */ +void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req) +{ + struct fuse_conn *fc = req->fm->fc; + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + struct fuse_ring_ent *ring_ent = NULL; + int err; + + err = -EINVAL; + queue = fuse_uring_task_to_queue(ring); + if (!queue) + goto err; + + if (req->in.h.opcode != FUSE_NOTIFY_REPLY) + req->in.h.unique = fuse_get_unique(fiq); + spin_lock(&queue->lock); + err = -ENOTCONN; + if (unlikely(queue->stopped)) + goto err_unlock; + + if (!list_empty(&queue->ent_avail_queue)) { + ring_ent = list_first_entry(&queue->ent_avail_queue, + struct fuse_ring_ent, list); + + fuse_uring_add_req_to_ring_ent(ring_ent, req); + } else { + list_add_tail(&req->list, &queue->fuse_req_queue); + } + spin_unlock(&queue->lock); + + if (ring_ent) { + struct io_uring_cmd *cmd = ring_ent->cmd; + struct fuse_uring_cmd_pdu *pdu = + (struct fuse_uring_cmd_pdu *)cmd->pdu; + + err = -EIO; + if (WARN_ON_ONCE(ring_ent->state != FRRS_FUSE_REQ)) + goto err; + + pdu->ring_ent = ring_ent; + io_uring_cmd_complete_in_task(cmd, fuse_uring_send_req_in_task); + } + + return; + +err_unlock: + spin_unlock(&queue->lock); +err: + req->out.h.error = err; + clear_bit(FR_PENDING, &req->flags); + fuse_request_end(req); +} + +const struct fuse_iqueue_ops fuse_io_uring_ops = { + /* should be send over io-uring as enhancement */ + .send_forget = fuse_dev_queue_forget, + + /* + * could be send over io-uring, but interrupts should be rare, + * no need to make the code complex + */ + .send_interrupt = fuse_dev_queue_interrupt, + .send_req = fuse_uring_queue_fuse_req, +}; diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index e567a20731d76f47b7ebe3f31da4a9348f6d2bc8..57aa3ed04447eb832e5a0463f06969a04154b181 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -119,12 +119,15 @@ struct fuse_ring { unsigned long teardown_time; atomic_t queue_refs; + + bool ready; }; void fuse_uring_destruct(struct fuse_conn *fc); void fuse_uring_stop_queues(struct fuse_ring *ring); void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); +void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req); static inline void fuse_uring_abort(struct fuse_conn *fc) { @@ -133,6 +136,8 @@ static inline void fuse_uring_abort(struct fuse_conn *fc) if (ring == NULL) return; + WRITE_ONCE(ring->ready, false); + if (atomic_read(&ring->queue_refs) > 0) { fuse_uring_abort_end_requests(ring); fuse_uring_stop_queues(ring); @@ -148,6 +153,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; @@ -167,6 +177,7 @@ static inline void fuse_uring_abort(struct fuse_conn *fc) static inline void fuse_uring_wait_stopped_queues(struct fuse_conn *fc) { } + #endif /* CONFIG_FUSE_IO_URING */ #endif /* _FS_FUSE_DEV_URING_I_H */ diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index a8d578b99a14239c05b4a496a4b3b1396eb768dd..545aeae93400c6b3ba49c8fc17993a9692665416 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -17,6 +17,8 @@ struct fuse_arg; struct fuse_args; struct fuse_pqueue; struct fuse_req; +struct fuse_iqueue *fiq; +struct fuse_forget_link *forget; struct fuse_copy_state { int write; @@ -58,6 +60,9 @@ int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs, int zeroing); int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, unsigned int nbytes); +void fuse_dev_queue_forget(struct fuse_iqueue *fiq, + struct fuse_forget_link *forget); +void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req); #endif From patchwork Thu Nov 21 23:43:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882470 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 07489AD5A; Fri, 22 Nov 2024 00:16:47 +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=1732234610; cv=fail; b=Ot/Y+0vIOF2DBjjKteOxIqjGeoTbYpxY1QODm0L0v4gz7q5hqLFKv4XXIJc5v4r2OXeDHuv0rU4vwc9IRzj87HELSjuqteAifRMWK0kIfQnd2VfJEUE8xXdxIEskYy9mcdP5LWHmWrNNaPZIhxwytNkYeoW8fToUluk4VUk/hgI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732234610; c=relaxed/simple; bh=4bknGJU3Wtna32FhrLjaYmZZ7ul1Xvbj4NehlIfcX8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WJGQbYB8GFcyZnfhakO+duhMQIcgcpn2UdjfWNAI554VYfS4E6QqV9SkiIHiiJ2K2NIqI3kX59QaIkRxq/v+0P+n+iJ8jxKgfbCoLBtSBd21kdqFM1nmhjufoa9y7lSecd/rnvNBbQUAw+w7nKuyP9dtuZpczbaqux6po3j98II= 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=OPwL+G4u; 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="OPwL+G4u" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2045.outbound.protection.outlook.com [104.47.70.45]) by mx-outbound14-193.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Nov 2024 00:16:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XOH+qbKIw+HkncgJyMpfjOafJDcHl6ZeS73vNNDmgVx/EcpwH4ajSe/bkd0gb3k5C/7hee5H6en/UIX29IWbcQ4UE/VEV5DfYbYXZuF7V750IXRzSIBCbnTJXzGHcqX+qxw2rD3bqE6hcbqBiPmKMzUGHZ0aEQZOrIhxvbPhWZxzRxzD0RTtFmL/mDg/BADJQUZDZscmkt47B2lORSpa2eUOkthdYD8vWFzvU+m2h43cgShBuSJOi03Sz7ndvja0yOm3p9IeeDUAineIPZHCD/ZlCrl5cjXtBKG03XPXXiyCGEhyY/LyxazddxHvl8atuzMDmjWf7A4Ly4JznseR9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AUhMVX+vTQG7wSMt986dWKXMtGIoAEkPHd4+2ghPkgc=; b=qnRkYLDIEcSDjWW7LNzvmdUeZrYscA4cntehzBPf2S9m2gLB5DSHlP0qzF0y8EXIHQB7QEF+swo3183Vr6wi1jbXAJdZ2Fo/QLW1z5fD3Hsq4/mOvUAphbM7ScqI2dbi2cngrSt3n3LbhdF6TH8MXK7aAxjnLJ3aEutXBgo1r5GXr+rLIMta8JPrdWgUYokj6LOGT4nUiCNZnhGQrw/thuBaxFlfQFimUrtacOAurIxmLpg6OdGMUKLG7ucyvKM4Buz8lfIjC8eC7iA1IxNqYcA5VO1krpaQRoUbuvKZN5ovE9Xy0QwDKa6ECL53REm9oNRmsrP3RQye8FkHWZD8Bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=AUhMVX+vTQG7wSMt986dWKXMtGIoAEkPHd4+2ghPkgc=; b=OPwL+G4uOIIaaT+S0MvJSXjiE7FjBEWO3jrCCGrJ6+cdidiJHLmzRDf3EFwxqjF2hgmH33PzXIdOrCMipsB823JPF7qnp608If1iT3CHfnB1T34S/C8VrxKCQCzXTJOPRURlYwSrCR04aOdZFFiEk15h41xkXUXIjJTcCUx+iUI= Received: from MW4PR03CA0132.namprd03.prod.outlook.com (2603:10b6:303:8c::17) by CH3PR19MB8212.namprd19.prod.outlook.com (2603:10b6:610:198::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Thu, 21 Nov 2024 23:44:03 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:8c:cafe::d) by MW4PR03CA0132.outlook.office365.com (2603:10b6:303:8c::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.0 via Frontend Transport; Thu, 21 Nov 2024 23:44:02 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 9906B32; Thu, 21 Nov 2024 23:44:01 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:28 +0100 Subject: [PATCH RFC v6 12/16] 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: <20241122-fuse-uring-for-6-10-rfc4-v6-12-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=8077; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=4bknGJU3Wtna32FhrLjaYmZZ7ul1Xvbj4NehlIfcX8Q=; b=D8x7r9wDttQWb+XKsvOxtPJhnCuhagiyL8RHsNi4O7kmhko/GSn3HzEX3Esp4mcCVT+cmKyRi paU4F2msefwBMOrmobQ07iZdcxTy81NJcCHBVSyDb2ljAIgWCiCTSPE X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|CH3PR19MB8212:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fc038a8-58ad-4723-7a28-08dd0a866118 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rXYqKygPEjnVCMEHKdid2pqIoo7gqI4?= =?utf-8?q?GC1NucRUlWhmfZLkkV+3lGhBCRaUycu7IhVa1jISgeWf1SYTQq6XPFppZ4Es4+UdK?= =?utf-8?q?IdWXhlfyBZqMb1w21tMH0LkCDaZq/SdQ8COznZcGExtrorJr8ib4iLuUr21Dh6CWq?= =?utf-8?q?3a+fsEGlfHafClERB9d9CROHtIJ4vIMwRS70oE7LUeqFJmILa6GQnHJ71O1ltNimo?= =?utf-8?q?Guuz/Ay0DO9w9he/Tj/weHmtI+23CjPk5tJraXPvwTvTazdVhQHIrOOG5uCs1LJa0?= =?utf-8?q?O6UefJMUUXyI/p0oKdR/KolB5w7nhu5Um8/FIm4+6upt/16c3XHDLYvDYXesTV858?= =?utf-8?q?t0+vxodw5BW3vlPi8kG5aGp0t48zNz7jp0ZRNSVetlFIRl6D6SKJmE/q1D2QNBy80?= =?utf-8?q?rP2qnhoPlt6JTeyj+O/Q76Kq4cmwyZNDgNpS1UZfzKtRvql13vX6sS7wByexJ42PF?= =?utf-8?q?w2yMpjWeHDC5ROw7AHhSIccCXFYNXuXcC+QPZCx3U+EXZgADyEAyJczTWtKCM2oI8?= =?utf-8?q?VrYwXmDnaVhKfgNQZWgNVKkFmCB6KfdBI1yUhmiWNEqhBYuE/g1cqajubzKozWM50?= =?utf-8?q?AQ9VJiTrHrKNv4FGEQ9UStLfCZw4rS80CfavTr4J+H43F2WZC19UDSus0su8dlQ/f?= =?utf-8?q?Az/lJIllsomygKt3PZ19oO5LdI0J4XyQx0WeKNAx9ro105fXIzXZw/TaptG+o1UHM?= =?utf-8?q?01LO3eTYeKJqAIUsioHPEo9Ik5r+0ElpsQKZdS73aECupG76+wQLj9Vg5Ub/Sl1eT?= =?utf-8?q?wDA76LO1iTFs8DiUVKxQQ153rFa2825arG7THEUu6ZJrdNUCmMOA54taR96DzwNzj?= =?utf-8?q?MYF6qqQfED67iUCRTU3fLCuTWOUObEEfSuc9bwI/4qoR1f2uoOcSgZW6Ah9RyAqJ1?= =?utf-8?q?d2IjvK1FVFddCahig8Ckk41no2OiSHPLLH+ZDWYrLNqJuGy1j5ds2iBWkB9DSzyJZ?= =?utf-8?q?7JTakEhF2inYUhLNVu4FE8pAbCJapeZ74RzBMDGZ0bGpTnQSFGylI73a7vukxfCcW?= =?utf-8?q?TWgoOgdGHopfP6Vhq1ZAPhfOtcncxprlXBnfwtDLgh6X0TmAj/JcZG60rc0UPM8O/?= =?utf-8?q?z0+nJQeMHBKILNLV7wCeueJMMyKTMKGg/6252372/FtEzFReTVk4YHylmfczKjBkt?= =?utf-8?q?l+AcpwsoqEmieoyaygF7yr7Y4QV3HICQTS+xLn5jyzlk/eyTdTSJv4khK1KCAzHJT?= =?utf-8?q?6cc4PgkP1mUHulPK28xyrUxMjVEUzpod7z4TtHCH2TuuhEz967Bm8vi5Rdx7zWteL?= =?utf-8?q?z/dcs2a/ZhMVJlWAlvjT0dVcPlCXF68W3cwFIq7+Ed+uDzk0QlGZxsiJejzuFiju0?= =?utf-8?q?OqD1bQpJpBBvdfzP/Z5qAMjx5HeCgKzF7w=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Yp6JeGVYL+P0MRKDKmSygj45wrThCOsu1tv2Q9vYnpaCv0qSxaCgfJRDgBSaAgmMMlhHXE+68yMQ7zxCAQhhTsOx961G/gi78KojHiHK3YBRYGxZywRU+sNJ27m3HXn1vjPWgrN2jgten32SckcWBBNOFm6vZ3DavNlfP2n00Ek0MyGvA97Y9NpgKspbPkNlf9+MiMfshB0PA1erd6MATGoFmb2DxoY3eiG1tg69NJG0Y3/jZoWmvM09jCdZVYeZlp76q/x4w1TpVm3j3ja92KGvYxup5TyjZd7pD39ZgKpTALX0F07mca6ICt7suj58BtDe3aT+e7T2xSRNEIyHirgULw7yjE61bpJ5Ua0832KLBa3GhRBPKC19tFgolpqEeUP4y945RxdkXVCHyrDGufLqwuMwMUM9qyIFRzsbyYDtAVS7jsaOo3ZULdtY40hz4DPm5vEeszhdnAws9gxXc8Ld5qliVOjBYq7dwS1jrh5mpjCd1PJ5g5YiIyFr8yGbQn8V0fKmF22GA1NuBef2Tv89yKsEUtOWMz59jhG28ERthnHDQgGv51X9vidQPUSH18B2HPOVaxAXQ/G9FutgOiamM4meJkHjhLNrQAY2vFpRpd5mdd/UlldX3qGKCdD6IS/7BU13n7KZ0EhzTBMyug== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:02.6430 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fc038a8-58ad-4723-7a28-08dd0a866118 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: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR19MB8212 X-OriginatorOrg: ddn.com X-BESS-ID: 1732234605-103777-13372-24003-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.70.45 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVuYWRqZAVgZQMDHN0Dg50dTcyN jQNM3ALCnV0MAkLS3FxCgp2TI5yTBNqTYWAMznbdhBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan9-145.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 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 | 26 ++++++++++++- fs/fuse/dev_uring.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/dev_uring_i.h | 6 +++ fs/fuse/fuse_dev_i.h | 4 +- 4 files changed, 136 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index ff7fd5c1096e8bb1f3479c2ac353c9a14fbf7ecd..dc8fc46efca82d30afb64b6c0e6a361fd951ca33 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -568,7 +568,25 @@ ssize_t __fuse_simple_request(struct mnt_idmap *idmap, return ret; } -static bool fuse_request_queue_background(struct fuse_req *req) +#ifdef CONFIG_FUSE_IO_URING +static bool fuse_request_queue_background_uring(struct fuse_conn *fc, + struct fuse_req *req) +{ + struct fuse_iqueue *fiq = &fc->iq; + + 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); + + return fuse_uring_queue_bq_req(req); +} +#endif + +/* + * @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; @@ -580,6 +598,12 @@ static bool fuse_request_queue_background(struct fuse_req *req) atomic_inc(&fc->num_waiting); } __set_bit(FR_ISREPLY, &req->flags); + +#ifdef CONFIG_FUSE_IO_URING + if (fuse_uring_ready(fc)) + return fuse_request_queue_background_uring(fc, req); +#endif + spin_lock(&fc->bg_lock); if (likely(fc->connected)) { fc->num_background++; diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index d8653b4fd990000c8de073089416944877b4a3a8..36ff1df1633880d66c23b13b425f70c6796c1c2c 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -27,13 +27,55 @@ struct fuse_uring_cmd_pdu { const struct fuse_iqueue_ops fuse_io_uring_ops; +static void fuse_uring_flush_bg(struct fuse_ring_queue *queue) +{ + struct fuse_ring *ring = queue->ring; + struct fuse_conn *fc = ring->fc; + + lockdep_assert_held(&queue->lock); + lockdep_assert_held(&fc->bg_lock); + + /* + * Allow one bg request per queue, ignoring global fc limits. + * This prevents a single queue from consuming all resources and + * eliminates the need for remote queue wake-ups when global + * limits are met but this queue has no more waiting requests. + */ + while ((fc->active_background < fc->max_background || + !queue->active_background) && + (!list_empty(&queue->fuse_req_bg_queue))) { + struct fuse_req *req; + + req = list_first_entry(&queue->fuse_req_bg_queue, + struct fuse_req, list); + fc->active_background++; + queue->active_background++; + + list_move_tail(&req->list, &queue->fuse_req_queue); + } +} + /* * Finalize a fuse request, then fetch and send the next entry, if available */ static void fuse_uring_req_end(struct fuse_ring_ent *ring_ent, bool set_err, int error) { + struct fuse_ring_queue *queue = ring_ent->queue; struct fuse_req *req = ring_ent->fuse_req; + struct fuse_ring *ring = queue->ring; + struct fuse_conn *fc = ring->fc; + + lockdep_assert_not_held(&queue->lock); + spin_lock(&queue->lock); + if (test_bit(FR_BACKGROUND, &req->flags)) { + queue->active_background--; + spin_lock(&fc->bg_lock); + fuse_uring_flush_bg(queue); + spin_unlock(&fc->bg_lock); + } + + spin_unlock(&queue->lock); if (set_err) req->out.h.error = error; @@ -78,6 +120,7 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring) { int qid; struct fuse_ring_queue *queue; + struct fuse_conn *fc = ring->fc; for (qid = 0; qid < ring->nr_queues; qid++) { queue = READ_ONCE(ring->queues[qid]); @@ -85,6 +128,13 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring) continue; queue->stopped = true; + + WARN_ON_ONCE(ring->fc->max_background != UINT_MAX); + spin_lock(&queue->lock); + spin_lock(&fc->bg_lock); + fuse_uring_flush_bg(queue); + spin_unlock(&fc->bg_lock); + spin_unlock(&queue->lock); fuse_uring_abort_end_queue_requests(queue); } } @@ -198,6 +248,7 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, INIT_LIST_HEAD(&queue->ent_w_req_queue); INIT_LIST_HEAD(&queue->ent_in_userspace); INIT_LIST_HEAD(&queue->fuse_req_queue); + INIT_LIST_HEAD(&queue->fuse_req_bg_queue); queue->fpq.processing = pq; fuse_pqueue_init(&queue->fpq); @@ -1161,6 +1212,58 @@ void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req) fuse_request_end(req); } +bool fuse_uring_queue_bq_req(struct fuse_req *req) +{ + struct fuse_conn *fc = req->fm->fc; + struct fuse_ring *ring = fc->ring; + struct fuse_ring_queue *queue; + struct fuse_ring_ent *ring_ent = NULL; + + queue = fuse_uring_task_to_queue(ring); + if (!queue) + return false; + + spin_lock(&queue->lock); + if (unlikely(queue->stopped)) { + spin_unlock(&queue->lock); + return false; + } + + list_add_tail(&req->list, &queue->fuse_req_bg_queue); + + if (!list_empty(&queue->ent_avail_queue)) + ring_ent = list_first_entry(&queue->ent_avail_queue, + struct fuse_ring_ent, list); + + spin_lock(&fc->bg_lock); + fc->num_background++; + if (fc->num_background == fc->max_background) + fc->blocked = 1; + fuse_uring_flush_bg(queue); + spin_unlock(&fc->bg_lock); + + /* + * Due to bg_queue flush limits there might be other bg requests + * in the queue that need to be handled first. Or no further req + * might be available. + */ + req = list_first_entry_or_null(&queue->fuse_req_queue, struct fuse_req, + list); + if (ring_ent && req) { + struct io_uring_cmd *cmd = ring_ent->cmd; + struct fuse_uring_cmd_pdu *pdu = + (struct fuse_uring_cmd_pdu *)cmd->pdu; + + fuse_uring_add_req_to_ring_ent(ring_ent, req); + + pdu->ring_ent = ring_ent; + io_uring_cmd_complete_in_task(cmd, fuse_uring_send_req_in_task); + } + spin_unlock(&queue->lock); + + return true; +} + const struct fuse_iqueue_ops fuse_io_uring_ops = { /* should be send over io-uring as enhancement */ .send_forget = fuse_dev_queue_forget, diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 57aa3ed04447eb832e5a0463f06969a04154b181..8426337361c72a30dca8f6fd9012ea3827160091 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -87,8 +87,13 @@ struct fuse_ring_queue { /* fuse requests waiting for an entry slot */ struct list_head fuse_req_queue; + /* background fuse requests */ + struct list_head fuse_req_bg_queue; + struct fuse_pqueue fpq; + unsigned int active_background; + bool stopped; }; @@ -128,6 +133,7 @@ void fuse_uring_stop_queues(struct fuse_ring *ring); void fuse_uring_abort_end_requests(struct fuse_ring *ring); int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags); void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req); +bool fuse_uring_queue_bq_req(struct fuse_req *req); static inline void fuse_uring_abort(struct fuse_conn *fc) { diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 545aeae93400c6b3ba49c8fc17993a9692665416..853333d6fcd3382286532d03ef3cec8ab4979fe7 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -17,8 +17,8 @@ struct fuse_arg; struct fuse_args; struct fuse_pqueue; struct fuse_req; -struct fuse_iqueue *fiq; -struct fuse_forget_link *forget; +struct fuse_iqueue; +struct fuse_forget_link; struct fuse_copy_state { int write; From patchwork Thu Nov 21 23:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882469 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 CE1635CB8; Fri, 22 Nov 2024 00:16:39 +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=1732234601; cv=fail; b=SYrHVfPydWM/x3RlcbsYZ2K7J3VfEl6H/6skuMiwxj5MZyPaQcSiO4t9S6U/kziOheHEW9I3EKLNWbbYMBeNGzJzGL45TFoTUGqjSEpZet2oHgygYYTvpjjNQsw/VKyx4Ct6oH/NE52YPWhCxbd73xJZPqz/JmYFvdn5cjocWSQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732234601; c=relaxed/simple; bh=9PzkB61bj/XR2Z+Wxlq+/t+fdgKvUzyQ0tG8Huxq6vA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=io8rZ0/ziydIWxgA87SEtSY6Tp+FIfvzufhvDE+wVhIh7tBdrbdSJ498lBPrU3gDHLYvzb/pEOWsUGSWEc7pyohLi6yrmQCocqFdhqhjEjqM1w+Bhc3fkooWkEtG4Rr+NEScMw8c+ris/CzPQrLyJSXTuwHySaSvtnmQ1TTVe4I= 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=vmsJ1Dvn; 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="vmsJ1Dvn" Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by mx-outbound20-210.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Nov 2024 00:16:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yeKf7ZQjfFQJaiV6QNk7H0lDONOzjYngL8OtIX4dDih3O5nCHlEBB79Sz633LT0dwyx57rNV5OTiPK6ej3PLbBcAZBjjlcVLhGJTILjYk3/qQbA414ItXYj4FTqMH2c1Um4+ZXrK6GzN++zmDcw1zhLdO+HNwr+pgPd8J5dMvI/2SOe0OqqGBPT5gfC4CKgMYOlZNfv+FFjgKjW1CeoMT5JjOtBMzn2NKRoAz/eWADRWoZlmVcCfrk0zwcJts4BmHGDNHuw/Ajnka/LnvSe3z2hVgYgsGmjhfANlSqdXZD2owu1pb2lE+SeA52Z7pu8+qhaxxAWSuKfTgTr0JStakw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+K6grFXYQFUPscAqxdj4dBIZiGWdtyrh7ixfQODKKbA=; b=rX7Krq7Lv4FTEMFhlIGKq2BdI5ImD2QTnMq8IqnCkJ0WdVLICeCRZO7KY7lPXIJGLl1spr0g/rbCfwKtO1AqqKTK8i0qDI580WNRHzqiYc/JAG5qdlhChwTZ110pft/LsImICI5C9/v8ss+8UhE9WU2716rRsh/lpVvYkIi+aqEoBsJ5eUtWXq27Bk+wN4wXcf4x0uGUwS0SV8P7Ds9RO8rm+BVBzqAwn99cEO9kNBU9cvr+PXVTnmKWX9MdQmvQOiSL21qAm2s/iwlb4uEpjIVrj+6yZ50YF9Ylt/GprnxNVWnD0JtBjNcKBxWTpICYQFOX4aT890OalxMY5QVtoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=+K6grFXYQFUPscAqxdj4dBIZiGWdtyrh7ixfQODKKbA=; b=vmsJ1DvnKYVXqyfte7VypXoOBHelBdfaMdQ6QFTegNJT8AQdN4XgcpYjQDybwv0lnolbP05kLdR7PTU/PDBJwlPwU4YOtm7ouyY1ptT8CPMxf44LSMcTrdhWuAiZR8YJB0nv8EkWQvugxE5EpF4hkjGsw0oDSX1Ocf0YXoLEzEQ= Received: from BN9P221CA0018.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::35) by PH8PR19MB6858.namprd19.prod.outlook.com (2603:10b6:510:1be::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Thu, 21 Nov 2024 23:44:04 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2603:10b6:408:10a:cafe::b5) by BN9P221CA0018.outlook.office365.com (2603:10b6:408:10a::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 BL02EPF0002992D.mail.protection.outlook.com (10.167.249.58) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:44:03 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 90F5F2D; Thu, 21 Nov 2024 23:44:02 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:29 +0100 Subject: [PATCH RFC v6 13/16] io_uring/cmd: let cmds to know about dying task Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-13-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=1916; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=DJ3dd+IL74OJQCvDusXpPNgQqk5rs1+4ays6c3lVSGQ=; b=cfYGZaden8bc3p9bplsulDzUkb/nlafClLRUtAgHYXOstW+kMnYaW3B3ckBaEZid3o6vFw+HB pZeGJZAaXj3CoAu4FtFbKnt0PDre5w1rUd5LA+eA1YpfmDXJGJpXksn X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|PH8PR19MB6858:EE_ X-MS-Office365-Filtering-Correlation-Id: bdfcc517-1d27-4810-71d6-08dd0a8661bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?zyU4IriX/t1mJZJ76erdPJVgApDLZZh?= =?utf-8?q?898zy3NzPnS3yX/wUuEZ4eQJycPhCqogztc/19TPgAnJgiy9m3kE2S1b0g1gpQcku?= =?utf-8?q?bG0+CSagOgmPmRKgC/ZVCT68Hn/XSoADs9Ls0yU+/3ERno5JQVNsNYDs5T0l4a3vs?= =?utf-8?q?LAfnzZjjfxaT6jzLGgtcsXoGxbFIAuYMvkoLRJ9EfD2wHfd2NWyvm/fdGd/WUIHdb?= =?utf-8?q?6xCXvuaXfvgmx0iYOgDcPvfbbVqSENMUSDy653Ue0PtVK1bh5UHYewOXX3qH91Q5g?= =?utf-8?q?xa8YX9LcOmzfPndKu+uwAybPt3NWxVVOgNtLAS857LBSZk6iyvZefloY07u7HLYgc?= =?utf-8?q?yng5scPt+jivr7e+qJDArdkq5Z0twxpZW25HsDouoKlW1K/b4gRthUbCzorb/4iF7?= =?utf-8?q?pyWCY1BjP9EK3LGS3LfMM4vX6u2XqT/ENFN1CniV9vzTSVns2mlNh6fvfW1IEiKzi?= =?utf-8?q?TYiIrdRN7TVN0/ggaxm3wiS00xPwUzRyswQuT35UGUukld0ZuI9PRP5Th/fRv0Bp/?= =?utf-8?q?ScN6G5PbW1/0dJEGZqGQgDM96sM/vJSPmi3AlfCQAK2M3bJKVKzYtvpXwm0ezjXHD?= =?utf-8?q?8Pk0NIIl7dwLKK4aOKYgUVQjhmwMpaS6yiAhtu2hnt/Ey0sK6TaGqtq/cSpHVVMtu?= =?utf-8?q?dChd4zJvtxop/QExVsPCrYG3sup1ohFHhJ5EIX2ZJSVUSvBvzymxSiCQSaCeGYQCw?= =?utf-8?q?0cTY/wI9VaGhZ455T9sfnoM6OqJYVUcYPnFRo90qgYeWgs6wL8V39JYnsq9MiJE2+?= =?utf-8?q?lFgROLiAK0z/64nbHl13jKRvGtB9Z0HFxCFbLbyIMWPYnjec4T3GbA4wNcI+MGkWp?= =?utf-8?q?veaZXwswUoWwfg4PVikZlO67V2kQNRs0mlMFKyTt2DLYVTB5PUTUOV3BJvALxv2gK?= =?utf-8?q?EdjxpjYn2TB+Tc0rrg4YA5apO4KhFavK7vaSKSKZsevqoccnHBVB6QzFVF/oGHGp+?= =?utf-8?q?+CxNrfsXI/9xrMRRnUbTWs/MaDcRKP0uHnFX3ORWy/0IfRz0BMJ8ST/2pJlWCyCru?= =?utf-8?q?br2P7Z+1/ILMi0pNT/GnuATXL2u9GW3yQC1i567X48Mqcy3FB4a8fLw3DEIK3q5HW?= =?utf-8?q?McBfnRpJiGh+Toc3vH2tSbdhsITsTBeEXQPUMHDrE3zupeMBOeaxd1rNMuZ1y9o5U?= =?utf-8?q?u65AHJTSqyCAuprNMBT/MgxBxI5gQHYQaYL1ki7+stc2QrqKR1hc+guwI/3tdBGLs?= =?utf-8?q?no9JS8/SeFmEUbu1jt60Y9dUqGCr9ZFML7mVUw2NKr7PELYUD/ukLB9OjY+UU2VeR?= =?utf-8?q?m+HW8x36prB3+uPeHzjyjpqlc23eAZVHwPSvzgG5XOO252Aeyk3rva60Pl0sVHJ04?= =?utf-8?q?MmufQLtSnyCI6JaOVt+mhCCEZtBnfj8XUA=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(7416014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0h7QhxvFyGpHRq+0aCXBfmw5DioAEObIVxxGbnwhLZyeFBJnqzsHlM+8wbQ/aVbeOsMoxWWjtbDgx1pF352Y8ma9vpoDpr5iUFLUbBRw8BYjPnIKTHnwCKconaDBrHsYrnvxOsCx+xnE2Nn8Y/Yc6Lt5TigxWOWwDSllJKNGvVn/s64tZAXCd4VASKxwpuWIF74hIHWzvPHLZIQUXJs9rBVsemoVQMqTGUmXXxlSHOxsPmqyc8cDgM+LylsHZeSDm0SJ1+0lDmDYT6F2C7fNaMnCDSTP6H+gpIEMtkWTajDamUBrx7Jl9kTGYxKLu8+hbqAKwWtan4asVzMpuQSe2rhgNgLtq3eKBtXZums68nEDSn1ikEMBJ49snacma/Xur8U/3WIwwG3epl3jr4sDdie5K9vdZKvVwEmFrH8Xz9eyq9ewArGr/9NZad5rUIUQzvpm53NJFDGXFgGNVRmRL9mGkKjegxhNZGXUt6XBjaFYZbTPumdhdBU6bPYeWkpLvLECEmbImD1GrsaKeevRFfhpkfTpzRJ+awJvUb87SlFnCDIpCSPLzESIX03rKwlYH4Q+VcQRgpZcSdUkvVpjz9hktoH/OaVQRLXF98D+TY8eShBerUcwIsIB+FchP9FArNNG6JpX5Z1fuDDcCqXkJA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:03.6642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdfcc517-1d27-4810-71d6-08dd0a8661bb 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: BL02EPF0002992D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB6858 X-OriginatorOrg: ddn.com X-BESS-ID: 1732234598-105330-23902-62646-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.74.46 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaWhuZAVgZQ0MwozdzMNCnROM 0s1dDI3NLEIM3SIsUg1cQ8ycQs0SRZqTYWAP8mqz9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260588 [from cloudscan17-70.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 From: Pavel Begunkov When the taks that submitted a request is dying, a task work for that request might get run by a kernel thread or even worse by a half dismantled task. We can't just cancel the task work without running the callback as the cmd might need to do some clean up, so pass a flag instead. If set, it's not safe to access any task resources and the callback is expected to cancel the cmd ASAP. Signed-off-by: Pavel Begunkov --- include/linux/io_uring_types.h | 1 + io_uring/uring_cmd.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h index 4b9ba523978d203ae23fb4ec9622d6e4e35a5e36..2ee5dc105b58ab48aef347a845509367a8241b9b 100644 --- a/include/linux/io_uring_types.h +++ b/include/linux/io_uring_types.h @@ -37,6 +37,7 @@ enum io_uring_cmd_flags { /* set when uring wants to cancel a previously issued command */ IO_URING_F_CANCEL = (1 << 11), IO_URING_F_COMPAT = (1 << 12), + IO_URING_F_TASK_DEAD = (1 << 13), }; struct io_wq_work_node { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 39c3c816ec7882b9aa26cd45df6ade531379e40f..38b6ccb4e55a1e85d204263272a280d3272557a4 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -119,9 +119,13 @@ EXPORT_SYMBOL_GPL(io_uring_cmd_mark_cancelable); static void io_uring_cmd_work(struct io_kiocb *req, struct io_tw_state *ts) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); + unsigned int flags = IO_URING_F_COMPLETE_DEFER; + + if (req->task->flags & PF_EXITING) + flags |= IO_URING_F_TASK_DEAD; /* task_work executor checks the deffered list completion */ - ioucmd->task_work_cb(ioucmd, IO_URING_F_COMPLETE_DEFER); + ioucmd->task_work_cb(ioucmd, flags); } void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd, From patchwork Thu Nov 21 23:43:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882462 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 A18451DE4FD for ; Thu, 21 Nov 2024 23:44: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=1732232657; cv=fail; b=VziF8PJKnx28esIGt8XzU+OXIxJsDLbmKxFvfBfxFAv6Nma0pZ/qnpD5piVpkDN5JYiEdZUQqfYFArYPV4DDDVOy2qKDagcBnd5LVTzVvqlTcF4TcI2pRJjrarpTqYi+DCC21HGoTxDjVkcfHCFUXmSCAp66jIrcJPzlzyQFVeU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232657; c=relaxed/simple; bh=tie4NxDKix394rRPWJuOycw76UDfRN09D0r3BvuIHOQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IAs+y51/Lfyl/e/to6FmG+a/3BX3I6V2i+wRit33RWoP4VXC4sEzd7sMoDUdiH51+YdZaUfALlMEJ3lJQXb45RYvwpZtIzuEuAW7hsrYwpvRU7pxy0LTXS0r9rCUTTxS0K1mT/urGIxTDWxdfW8vr+dh+CVlSKSN8T2peukBM6I= 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=up+IvFbB; 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="up+IvFbB" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2049.outbound.protection.outlook.com [104.47.58.49]) by mx-outbound11-87.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wrXaI3RCIreWQtNyv9H8T1M5bUBR+O3gr7zckK8bVQGtoJ9httUiYN34UVUanJTEER3Lk12WbYFmGcPBYic4KOtzzc7sl9WG71I2XZcaiS3wZaoGLvn0kn9urQdZCgXwza7AZW+rOmPJG1MO1CgErvXwL7Z/oviF90gSoLSr36B18W3KYFUl8m14vellkUDgVTGS41bR6ZfBWtGCUmLGCZScZaC2L6cx2mOm61SICVDabNjEVsaQAvY9dICCF8NyIt//KPjHjTDdIuAd4h2ChrVxns7H3vZ/nIfWz44nT9kGELRbQByr3bnMuMP+9a+wXsGoj4iBfwHgXaR/otYJ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d0AtFXclGgSjW8xzix/Sf7JMTbM7+vqZyQi1Ti3SUdg=; b=meE3fmIQSjIr8cfeW0+rdW2BcXiJ65OiCyHCiT7/c3oF2/guhlpVVuKsROX6ol9yuswG6u5Na0KC5lGEOY+imCc7gtf7V3pMPobc+ra76Ey43d5o17wOmVCso9sU6aHNeflngXnBhUf22QkC374tGI3IQBl6r9dWQiLlS5MNKc1yPG3frnfVl/jfSxp+uZbKCv8b1YXWyZrKpbqe+rRk7XQWHJpO7mlRAP9uxJ2GhGVygAY3ecrOSx4GHFHqYHWMYID2izYf7rGjjmkFArzGhKPOFseY8CHdhZELcToOrW54HdK4DFlbpmRkzN9kbSZCNMJ3NfCqqp2J2g0H4MIBtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=d0AtFXclGgSjW8xzix/Sf7JMTbM7+vqZyQi1Ti3SUdg=; b=up+IvFbBpUW1rX6x+8v/fxr2VkXWhKDDHzfOgMJeeo1PA8Gn04rdDxuZm4zdOCw6ec8UZHJsZuePenp0OAN8J7GkmB6iPpg/P+s8E21+z+kI+V2wLvjWQk2SPXgK6Vp0F7mFOBrEtl9FyrB+FkFV+uI3Rms6cVaerJdhu296Xug= Received: from BN8PR03CA0034.namprd03.prod.outlook.com (2603:10b6:408:94::47) by PH0PR19MB4822.namprd19.prod.outlook.com (2603:10b6:510:25::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17; Thu, 21 Nov 2024 23:44:04 +0000 Received: from BL02EPF0002992A.namprd02.prod.outlook.com (2603:10b6:408:94:cafe::5c) by BN8PR03CA0034.outlook.office365.com (2603:10b6:408:94::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 BL02EPF0002992A.mail.protection.outlook.com (10.167.249.55) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:44:04 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 8927032; Thu, 21 Nov 2024 23:44:03 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:30 +0100 Subject: [PATCH RFC v6 14/16] fuse: {uring} Handle IO_URING_F_TASK_DEAD Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-14-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=1124; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=tie4NxDKix394rRPWJuOycw76UDfRN09D0r3BvuIHOQ=; b=OnypkaFUeK8VHtC5GUHuUBc3I1jB1gpNXXZ6FGc9Dgo5c4bt2UtHgJG1p199WZ+ic8nY2sDJH nUY+dujSkZuAm3LglFb1nz9ruIetL0VclnKnWB2FZ9+4kWXKLx0+aO+ X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992A:EE_|PH0PR19MB4822:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d9275c8-5462-4c98-7cc7-08dd0a866248 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gseYRHU2preXWW4H+Ym4XoXzxCtiwYB?= =?utf-8?q?SqoAhetrBvaDUc7JcAWH9R3pQz5P8+T68jZys1AHZP25WnIoOGsd5cXJWaQ2dtFH/?= =?utf-8?q?TwPtpfdUxuQwh1OFdnW+/dcvtCdu0xExUSIJ29kLgp/UAy7PTkdIiTVcZxqWNZKJr?= =?utf-8?q?Lkz9aMZsrrrOA17AhmnnwOe6vGlcU5Mmor1q5cstl8WmFtrraqv8ym4q+hfc/U87s?= =?utf-8?q?aXDJRF0wgb2af/LUAiIPFUG0iUG+3rN8e1hv8x0asW+ZZr+jPCwxoqbm/4GAfxNCw?= =?utf-8?q?AppkiLZLedTc32K/4VnsLFzq6OQ0GHeqITuwWcQHcArtLmV696xxvpDKLLxXoP28l?= =?utf-8?q?yaZcH2Q81ko1KO43Qw9Chi/0yXygJL/WlUAujm9hyHuLIX1zKGXJ8cCOHq8ejX/tn?= =?utf-8?q?9tB51yNIj7pXoDYpk05NrDoGfb6XDT9d5mGOA3ph8bMeZ5MpNV8bW1f3wy4zrxORI?= =?utf-8?q?BNhG8vsOpsA9H8HJvNTayShlRR5wlfITsbG9dSOPh/fRzpAw/MeX9LUaaINmMR+KX?= =?utf-8?q?VFyxDtOiy97pdnRx/ON4xzgZ9S3LTvbzH7SSyW5ufCc+0uy38GPlTfzXjFP9RceYs?= =?utf-8?q?Kqqprvg9z+rLRYxSze6P3XeNfhvBt5VEED1/w4Vx58rz0X2Am8ge0PsWH4UzapRSw?= =?utf-8?q?VjscTjv1H//0uwYaFTFrdAm8N3oQIsLkpGQtj2R10xQn5hq//ueyP82W8/IzdIsdO?= =?utf-8?q?7n0ES04Ry8UisrPYYt5j64diJTvD87BC+XA7ojsFZpHP4wysAQR9Jk2RgwDCrexC+?= =?utf-8?q?fixRdGf2yDZZduirM1j4mNYB7b6PzPtqAzAyWdkwfEIDEIIQ7DcsIRRs4jbwDyctt?= =?utf-8?q?o8V+YbPBbqS/snBfRFWLKt9Ih832WPpaOo9OXTKhnNYDc38W+XDtjkiOuJcGD+wRf?= =?utf-8?q?QN3w/8z25co2hqM1MdcLJv1waqZJ2RC+DcsegTZit2d3/QBmTckf3dqMN7b/26mhl?= =?utf-8?q?x/HBSd+9fiiopEwATFW9mx+CMEdjrkPWY6gn+kZ06Y4uaJK2DJleaRMH6F1ULkXty?= =?utf-8?q?QVfMZuPyujsladwyuveHIPMRg8oj3XtnS9hSMAqtqCtZ6ma+QH1wcwefVIlT1U8n7?= =?utf-8?q?uVvoQQuu956fkqltlTWqQSWEyyEUrniMdqja6HVINCf3Bl8uM6+5S/8pdp264SnnS?= =?utf-8?q?HZCvf1kvM3LhNshVm15k8LxVxprPU+g+II+7ireN3w6qj4I6Hhhir2dk9ZedArQZN?= =?utf-8?q?oDudTfQboTUbWvFlIw1y+gcNsrSG3MYwhZZqZLD5pob7qcHrNh9/jTYUe7sgjbqFK?= =?utf-8?q?1vvk3yP6/ql7VRpTYoAAsT6SITr/4TfPIqOo/w2CQUQQx1yRfE1fk9Et4oHtSRLEI?= =?utf-8?q?zXebDhHfGemkT1BGLMHdaLnvnut/Cs2yVQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ytEPAm7OHtYk/Gqrd1yPOpi4d+ZzKvJfzdUfYHxXsC4yl2bb9I4uI3QVF+PpGV8Cd2xHxS3ZD0bCbH/woWjl5okQW1v6EMC2q9KgHwM0Yu2QsF/N2ID8Kwajdk7D7OHydZ7AQVltiKPIBiPBL/NtiWKpdw2MKJWAw2gBrSLi5cRczdGC7SGFJjRH56wox7H0RmKZLke8IuXMYmezvBzu9vDSjH9ccrqwRftzNthIZOw/n5psYvGByyCCXNrudkJZOWz8Ut8ofMP912FcShFkcsPkpmxF78TEXqayniK6U3JfCsDMufw+BTLkGW9WnCFMFdvAgv/wajKLiKRYDNkSdMNF6WGJSckERDzBKBHTJ27o1qAsVbDvdUwyaUJF/x3a+N3ASLhqkfzHVj1xybstLZondYnb/B3NJYEnDGjh6adIjVeCoDycO82iEu41wxCaRZpxo1AdvaDGdi5XR23WBBueA/b4hBIOP9nT124Y7shoxa8p+l/N4GaGEOVcKx7IBdLr3h3J+TfbMmQ7RQckbYvZl0NLuhWMcf7syVACMtTr4SjET4+uW3CUQcxsPl0EnllgpbMI5xtbgnVIpH992EQI87jJw9WY0NdXKogS/b/RMdcq7rsFM3t2ANXfsLryThkLhMD0OinPOkqjj8RIFg== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:04.5885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d9275c8-5462-4c98-7cc7-08dd0a866248 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: BL02EPF0002992A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR19MB4822 X-BESS-ID: 1732232648-102903-22465-23793-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.58.49 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGFqZAVgZQ0CjFLNXYMNnUxM zIKDk52dg4JcnYwMw8zSzJzCLN0tJCqTYWAKE8JYBBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan23-80.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 The ring task is terminating, it not safe to still access its resources. Also no need for further actions. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index 36ff1df1633880d66c23b13b425f70c6796c1c2c..d0f8f0932e1715babebbc715c1846a5052419eb9 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -1124,16 +1124,22 @@ fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, BUILD_BUG_ON(sizeof(pdu) > sizeof(cmd->pdu)); + if (unlikely(issue_flags & IO_URING_F_TASK_DEAD)) { + err = -ECANCELED; + goto terminating; + } + err = fuse_uring_prepare_send(ring_ent); if (err) goto err; - io_uring_cmd_done(cmd, 0, 0, issue_flags); - +terminating: spin_lock(&queue->lock); ring_ent->state = FRRS_USERSPACE; list_move(&ring_ent->list, &queue->ent_in_userspace); spin_unlock(&queue->lock); + io_uring_cmd_done(cmd, err, 0, issue_flags); + return; err: fuse_uring_next_fuse_req(ring_ent, queue); From patchwork Thu Nov 21 23:43:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882463 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 2443E1DE8B9 for ; Thu, 21 Nov 2024 23:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.102 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232658; cv=fail; b=Nthz4ZotGHG9F9oOlHN2oC3QBOfY+FJKGd5IErbsiTIvXQMSqPFHjkDraIB4HIkXt97xWjOtWK+8vsdEkUmofm2RrxBwwgs4KqxV4zr37FGBUkyzurHLE0AXmmGqaHPdCoLy572SON0QdfIFDlgz9uTy+SDv5+xjk8TUklNCqRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232658; c=relaxed/simple; bh=2Luee4LJP7dDyAS7bu0Pq+sCS6Tayg+HsMqk/18uS2c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mQuskk3h/SyjdbyNgRcm3VNrQaDxDn5ZM5sdaZtwtfPFA7Fo8DGB02m6wqTy9SDKQ7d91DtyRKjW/DMaosVerICna+x3DUGxXuzCVsACfgV6XrjuLkMR48noCi/ge/QqXfmDI8Jk4x/+72tqr0QGLtxp5JKwjaeUNHg9+QxO0gk= 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=hiZhILI9; 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="hiZhILI9" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2042.outbound.protection.outlook.com [104.47.58.42]) by mx-outbound16-66.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kV4Nxkog4PEIwhW8uuif0H03eCRnqC5EulijrETzJwhTt7F2hzlHzCRuArOZthnWYKbQ6X57sGKS2Qvmq52PekMWOb8rfXUwmNCDJzP4OcB9QhzvC8WWWBR0TNMVE1BVpRO6ivyPvBnJe7/1+O9AUoCw0HRYlIzKnzZJuy32Wg4+3SfqKN4Lb5HZukzl9yzOKJxeNLoKPkb8KccJ33J8f6pBHGUVVmx/tNtuhAVhDMRIGoC7TDBVhcDLmFC6gInCvhgcseyzpKQ9ZJ5UhN2qk5yWZFeY3wCPmCSsn21cRiiRK3KvB6W+NgBj6U+Wd8KJmhLGHSgpgpD5mMuZedLKoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FC8P0EzozdIp8fFeo4tlulUzBMRxS4NMCTc9gKCnZvk=; b=oU7wX17F5KOEU22IHKgtaFWype8LKHhSS/QG2IhkM1nlR3h8tVmrNxWWdg64c5UmVD/4/rRfU8/0Ow4iSjtzPE1dUmjSjOf3KVsULQGcfUwooFNnGkMaUZGUYTZUUmCE6a1LC9ZnB1f4a/ieOqQ9bueI3AnjoFkggimw8Lw04K0kKSHdV5vsMSQLbpSB+onaiMlTHMC5rmMkfBo42IEUBGzChlcUdE16VrYiq85eyMbT6Xv6A3Dzjw/VBl2jmoBY3T94defwvlDZJ5uhOE73wIuziVeZ/lcUykithxMpkhGqUPfdfpXbyfEM6JnhAAQ6hBEdHKSbLZuPod0boBp5Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=FC8P0EzozdIp8fFeo4tlulUzBMRxS4NMCTc9gKCnZvk=; b=hiZhILI9NLNnaRj28TwVXiYNyFYagRwQqGtKBXarsUEDgP9murEBm9cZC6pjV14WHZ10ok2foqsL0Lx/FYh5KlbETdLgSJdTqgxZbiPcyu/V/dyTOZDvwrAVAddUQZVev9LQEIgUNmwXSKog+pM4YVbrWL1PT5r0tiAvHxhEnn8= Received: from BN9P221CA0029.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::27) by SA1PR19MB7087.namprd19.prod.outlook.com (2603:10b6:806:2b8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Thu, 21 Nov 2024 23:44:06 +0000 Received: from BL02EPF0002992D.namprd02.prod.outlook.com (2603:10b6:408:10a:cafe::9f) by BN9P221CA0029.outlook.office365.com (2603:10b6:408:10a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 BL02EPF0002992D.mail.protection.outlook.com (10.167.249.58) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Thu, 21 Nov 2024 23:44:05 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 812CA2D; Thu, 21 Nov 2024 23:44:04 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:31 +0100 Subject: [PATCH RFC v6 15/16] fuse: {io-uring} Prevent mount point hang on fuse-server termination Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241122-fuse-uring-for-6-10-rfc4-v6-15-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=10060; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=2Luee4LJP7dDyAS7bu0Pq+sCS6Tayg+HsMqk/18uS2c=; b=2VgyTA1IDBmL7v1AnjF44TmcI+9Dwi8cBHujzShH0UbjeSR4PJlvCsqo0yMCW+9AfWhHSz0yI nSZPwwfwaFIBl9fWemVq06CQoGH1pIZhN0oVraKRv8ph723ilUsxlii X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0002992D:EE_|SA1PR19MB7087:EE_ X-MS-Office365-Filtering-Correlation-Id: ec518bcc-920d-4c06-db16-08dd0a8662e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bR21F/e3gVaAlIfKien2MKfzg2ynU5z?= =?utf-8?q?bgUYdwZP83gR0SCKZxvMXb20mZ6xHV62W0anQEyV+3Ynv4+5i6pg0Qor7ixF6odAy?= =?utf-8?q?SN7688zeakuNYJjcdsJA17UBsff3iJZVdWmF56sTuzGXJLH9qhBPLX+BrVA1fQChf?= =?utf-8?q?QJh62Qokj7VdxqQYknHubBVw0xYcvGkg+rAOhhGy5H/BU4tnDZ0Oy6tRQJZkfvnGb?= =?utf-8?q?R5q9WdFXndaEWCZ+MAaG/6XwrprrvXkEyIgPPr8mFO5hnKhJs++qfAPevz1VrMv4W?= =?utf-8?q?SPHdf4N6BvBkQTxiLeHTjVJh/fUke5xIctF/G+2uL/uTMwXv/bMuqaqhfwviK8mQ/?= =?utf-8?q?pPxnPgqBvsOQhob2j0NFiiqR8SFduL70EfpGZPa7mbuNaWmyX+DiLbkRBtxrqwXsC?= =?utf-8?q?B7xXMaKDJN+zquyovQQkmmpzrvSpHjJjW017K9ZIfn/27PF+ReGoHmTJygR8j4m0V?= =?utf-8?q?00PcmpXvlT2xeOACd49C3e6/IswP9zE/XRsXgnPDjz1ebCdKbfj/On9EQ9K4WKOh2?= =?utf-8?q?HsA6WCn8rUDPuS3Dpk9WAzBFuFiCzOcz9yDuc5BINYALvW5pMlQ23FlVlEmsMK+Bb?= =?utf-8?q?6YauVPiKmrgLevd3XZ+j4z8F5ZQz0nRtNEfiRRa3f9ON/haLHANJ1jyJpTZn193pT?= =?utf-8?q?dRnS2mLf/00SoEbkI0AOr6axS6NVxbtt6+TYv/Fhr1o+OANRpD0PfDyto87UYuwZf?= =?utf-8?q?TKEYy9Th1onIrCHGyCC/jEcoA/tamIDgFW+UMLYTpNbR/CiTWaRjVA/0nPLpvZNhf?= =?utf-8?q?ArYm0ZSzlRs1b5oNOSNQtDYTe2xjclWNjf23tXkykcTxB5oyrlycKJGiNLzQ5wHxE?= =?utf-8?q?ggluFR/kSTEmuNrlFjWefoaEnyOh15i+nvzg6T+C93edzOrtLoaEfdok0bHjz/T+u?= =?utf-8?q?ylOll7uHxHNdh1l61IbvY3T73/toOvtEMv+f5mXOGTZGOj3eW39EeFHqycDLNBi4d?= =?utf-8?q?nAzOUXG24TCw1SkKJl840rS1L6N1tIWCjsIazuvAEKzuo4G4F1yA2xjuZ8SqWL/EZ?= =?utf-8?q?e7JsqGho9JpqHwSwtMrUk7VgbwJod5Wmnt7Z8wYzr57jes7g878gAuco3EJMnUI4S?= =?utf-8?q?b1f0EmlOBI+ULLkdwyocDRqYLr9tiZxW2J4+P4u3o+Yy92YAq4RxZiUTekpmQoQ6Z?= =?utf-8?q?mKXsBddu4eay7+jxE9P0HfCvaOvEGLGsUk2ecFXUzndIRoEpGuv9dz+Is6m7+hG8B?= =?utf-8?q?5EsplFJW/WHq3EnDHCDE3t830o/jnO+3xtO63gyqEU0qlrz04GcFjTP15DQw9ukHR?= =?utf-8?q?aQfbjaISyVp70G5c2DUk5xn4ulgzPAtrc0MfcI02rpjR4dxHeCiBIOGpwVfhetnaD?= =?utf-8?q?GOk7bYHkwOpS9tLl39JDhQn9h0DznhwSiw=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FqvvPrhHaNpnJMh6oxaNq9RFqwEuL0q9OjELF7mEnMz+5ypLnpo3GCxuvr9qpwg5q53wKNoo2r1jbpcl/7CXQgMOS3nx8kKJmzjOzxOhEPEvC0sxvanq46hhFqVSVHo5nOp60AbwbahHFtB2pKpATLIejhgfgpNhSQm9ctwrjWz8hoxEvVJ2IDmI87yhzEe49b0QAnAL65jODm6qBpsf0xu25meglrHfGwVQpDnITLTwr0EL3g8xUtgMivhjPaKq4V7+LFotADtICt94mk8Ttm+BrcD9iB0lqECNlsjS1z+ydJ3GAvauWEwKJXHtUx1fbObFHvwqYPKmCAkn81S3Gt5jX564qPCdPIOmqgMSwrFCaxFPF+7I6gqUF9NMYWWtFuLvVeehqTdvjHM6kjJaZixOtMfA5NgqbW1scJa3F5njlO3tlCTh6+cgbSW2FGx/CXEpc4h2JjTneT+RvZ/eshLB0GYHB9GcgGiOpeG5GW41BxVIOpN19wG8g9gfsJEnC17QANwyOTEUKIEH30DpS8RH2rDJ6TvkQF7qe3jSQwsi7FVS/BXfoMoD4xPNeZHUo4Kp24+8FzhGwCjmCuJ9LVRHGFWW/T4DWebG7RX+Sc9cbhAIpYkvbYt8MzXjGa4sfow7bzrEcQ2CHfN3YBot9A== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:05.6329 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec518bcc-920d-4c06-db16-08dd0a8662e7 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: BL02EPF0002992D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR19MB7087 X-BESS-ID: 1732232648-104162-13522-21437-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.58.42 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpbmppZAVgZQ0MzAyMDIJNksNd XQyDgt2dA4xdQyycAoLTHF2NTC0NxYqTYWAOoQU0xBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan14-42.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 When the fuse-server terminates while the fuse-client or kernel still has queued URING_CMDs, these commands retain references to the struct file used by the fuse connection. This prevents fuse_dev_release() from being invoked, resulting in a hung mount point. This patch addresses the issue by making queued URING_CMDs cancelable, allowing fuse_dev_release() to proceed as expected and preventing the mount point from hanging. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 103 ++++++++++++++++++++++++++++++++++++++++---------- fs/fuse/dev_uring_i.h | 12 ++++++ 2 files changed, 94 insertions(+), 21 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index d0f8f0932e1715babebbc715c1846a5052419eb9..b7a6c3946611a9fdecd4996117b45b3081ad6edd 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -23,6 +23,7 @@ MODULE_PARM_DESC(enable_uring, struct fuse_uring_cmd_pdu { struct fuse_ring_ent *ring_ent; + struct fuse_ring_queue *queue; }; const struct fuse_iqueue_ops fuse_io_uring_ops; @@ -221,6 +222,7 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, struct fuse_conn *fc = ring->fc; struct fuse_ring_queue *queue; struct list_head *pq; + struct fuse_ring_ent *ent, *next; queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT); if (!queue) @@ -249,6 +251,12 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring, INIT_LIST_HEAD(&queue->ent_in_userspace); INIT_LIST_HEAD(&queue->fuse_req_queue); INIT_LIST_HEAD(&queue->fuse_req_bg_queue); + INIT_LIST_HEAD(&queue->ent_released); + + list_for_each_entry_safe(ent, next, &queue->ent_released, list) { + list_del_init(&ent->list); + kfree(ent); + } queue->fpq.processing = pq; fuse_pqueue_init(&queue->fpq); @@ -281,8 +289,7 @@ static void fuse_uring_stop_fuse_req_end(struct fuse_ring_ent *ent) /* * Release a request/entry on connection tear down */ -static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, - bool need_cmd_done) +static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent) { struct fuse_ring_queue *queue = ent->queue; @@ -292,7 +299,7 @@ static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, */ lockdep_assert_not_held(&ent->queue->lock); - if (need_cmd_done) { + if (ent->need_cmd_done) { pr_devel("qid=%d sending cmd_done\n", queue->qid); io_uring_cmd_done(ent->cmd, -ENOTCONN, 0, @@ -302,8 +309,16 @@ static void fuse_uring_entry_teardown(struct fuse_ring_ent *ent, if (ent->fuse_req) fuse_uring_stop_fuse_req_end(ent); - list_del_init(&ent->list); - kfree(ent); + /* + * The entry must not be freed immediately, due to access of direct + * pointer access of entries through IO_URING_F_CANCEL - there is a risk + * of race between daemon termination (which triggers IO_URING_F_CANCEL + * and accesses entries without checking the list state first + */ + spin_lock(&queue->lock); + list_move(&ent->list, &queue->ent_released); + ent->state = FRRS_RELEASED; + spin_unlock(&queue->lock); } static void fuse_uring_stop_list_entries(struct list_head *head, @@ -323,15 +338,15 @@ static void fuse_uring_stop_list_entries(struct list_head *head, continue; } + ent->need_cmd_done = ent->state != FRRS_USERSPACE; + ent->state = FRRS_TEARDOWN; list_move(&ent->list, &to_teardown); } spin_unlock(&queue->lock); /* no queue lock to avoid lock order issues */ list_for_each_entry_safe(ent, next, &to_teardown, list) { - bool need_cmd_done = ent->state != FRRS_USERSPACE; - - fuse_uring_entry_teardown(ent, need_cmd_done); + fuse_uring_entry_teardown(ent); queue_refs = atomic_dec_return(&ring->queue_refs); if (WARN_ON_ONCE(queue_refs < 0)) @@ -442,6 +457,49 @@ void fuse_uring_stop_queues(struct fuse_ring *ring) } } +/* + * Handle IO_URING_F_CANCEL, typically should come on daemon termination + */ +static void fuse_uring_cancel(struct io_uring_cmd *cmd, + unsigned int issue_flags, struct fuse_conn *fc) +{ + struct fuse_uring_cmd_pdu *pdu = (struct fuse_uring_cmd_pdu *)cmd->pdu; + struct fuse_ring_queue *queue = pdu->queue; + struct fuse_ring_ent *ent = pdu->ring_ent; + bool need_cmd_done = false; + + /* + * direct access on ent - it must not be destructed as long as + * IO_URING_F_CANCEL might come up + */ + spin_lock(&queue->lock); + if (ent->state == FRRS_WAIT) { + ent->state = FRRS_USERSPACE; + list_move(&ent->list, &queue->ent_in_userspace); + need_cmd_done = true; + } + spin_unlock(&queue->lock); + + if (need_cmd_done) + io_uring_cmd_done(cmd, -ENOTCONN, 0, issue_flags); + + /* + * releasing the last entry should trigger fuse_dev_release() if + * the daemon was terminated + */ +} + +static void fuse_uring_prepare_cancel(struct io_uring_cmd *cmd, int issue_flags, + struct fuse_ring_ent *ring_ent) +{ + struct fuse_uring_cmd_pdu *pdu = (struct fuse_uring_cmd_pdu *)cmd->pdu; + + pdu->ring_ent = ring_ent; + pdu->queue = ring_ent->queue; + + io_uring_cmd_mark_cancelable(cmd, issue_flags); +} + /* * Checks for errors and stores it into the request */ @@ -665,7 +723,8 @@ static int fuse_uring_send_next_to_ring(struct fuse_ring_ent *ring_ent) * 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) + struct fuse_ring_queue *queue, + unsigned int issue_flags) __must_hold(&queue->lock) { struct fuse_ring *ring = queue->ring; @@ -682,6 +741,7 @@ static void fuse_uring_ent_avail(struct fuse_ring_ent *ring_ent, return; } + fuse_uring_prepare_cancel(ring_ent->cmd, issue_flags, ring_ent); list_move(&ring_ent->list, &queue->ent_avail_queue); ring_ent->state = FRRS_WAIT; @@ -789,7 +849,8 @@ static void fuse_uring_commit(struct fuse_ring_ent *ring_ent, * Get the next fuse req and send it */ static void fuse_uring_next_fuse_req(struct fuse_ring_ent *ring_ent, - struct fuse_ring_queue *queue) + struct fuse_ring_queue *queue, + unsigned int issue_flags) { int has_next, err; int prev_state = ring_ent->state; @@ -798,7 +859,7 @@ static void fuse_uring_next_fuse_req(struct fuse_ring_ent *ring_ent, spin_lock(&queue->lock); has_next = fuse_uring_ent_assign_req(ring_ent); if (!has_next) { - fuse_uring_ent_avail(ring_ent, queue); + fuse_uring_ent_avail(ring_ent, queue, issue_flags); spin_unlock(&queue->lock); break; /* no request left */ } @@ -873,7 +934,7 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags, * and fetching is done in one step vs legacy fuse, which has separated * read (fetch request) and write (commit result). */ - fuse_uring_next_fuse_req(ring_ent, queue); + fuse_uring_next_fuse_req(ring_ent, queue, issue_flags); return 0; } @@ -915,7 +976,7 @@ static void _fuse_uring_fetch(struct fuse_ring_ent *ring_ent, struct fuse_iqueue *fiq = &fc->iq; spin_lock(&queue->lock); - fuse_uring_ent_avail(ring_ent, queue); + fuse_uring_ent_avail(ring_ent, queue, issue_flags); ring_ent->cmd = cmd; spin_unlock(&queue->lock); @@ -1085,6 +1146,11 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) if (fc->aborted) return err; + if ((unlikely(issue_flags & IO_URING_F_CANCEL))) { + fuse_uring_cancel(cmd, issue_flags, fc); + return 0; + } + switch (cmd_op) { case FUSE_URING_REQ_FETCH: err = fuse_uring_fetch(cmd, issue_flags, fc); @@ -1142,7 +1208,7 @@ fuse_uring_send_req_in_task(struct io_uring_cmd *cmd, return; err: - fuse_uring_next_fuse_req(ring_ent, queue); + fuse_uring_next_fuse_req(ring_ent, queue, issue_flags); } static struct fuse_ring_queue *fuse_uring_task_to_queue(struct fuse_ring *ring) @@ -1197,14 +1263,11 @@ void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req) if (ring_ent) { struct io_uring_cmd *cmd = ring_ent->cmd; - struct fuse_uring_cmd_pdu *pdu = - (struct fuse_uring_cmd_pdu *)cmd->pdu; - err = -EIO; if (WARN_ON_ONCE(ring_ent->state != FRRS_FUSE_REQ)) goto err; - pdu->ring_ent = ring_ent; + /* pdu already set by preparing IO_URING_F_CANCEL */ io_uring_cmd_complete_in_task(cmd, fuse_uring_send_req_in_task); } @@ -1257,12 +1320,10 @@ bool fuse_uring_queue_bq_req(struct fuse_req *req) list); if (ring_ent && req) { struct io_uring_cmd *cmd = ring_ent->cmd; - struct fuse_uring_cmd_pdu *pdu = - (struct fuse_uring_cmd_pdu *)cmd->pdu; fuse_uring_add_req_to_ring_ent(ring_ent, req); - pdu->ring_ent = ring_ent; + /* pdu already set by preparing IO_URING_F_CANCEL */ io_uring_cmd_complete_in_task(cmd, fuse_uring_send_req_in_task); } spin_unlock(&queue->lock); diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h index 8426337361c72a30dca8f6fd9012ea3827160091..6af7754249623102f48a4c5c924a21b20851925f 100644 --- a/fs/fuse/dev_uring_i.h +++ b/fs/fuse/dev_uring_i.h @@ -28,6 +28,12 @@ enum fuse_ring_req_state { /* The ring entry is in or on the way to user space */ FRRS_USERSPACE, + + /* The ring entry is in teardown */ + FRRS_TEARDOWN, + + /* The ring entry is released, but not freed yet */ + FRRS_RELEASED, }; /** A fuse ring entry, part of the ring queue */ @@ -52,6 +58,9 @@ struct fuse_ring_ent { */ unsigned int state; + /* The entry needs io_uring_cmd_done for teardown */ + unsigned int need_cmd_done; + struct fuse_req *fuse_req; }; @@ -84,6 +93,9 @@ struct fuse_ring_queue { /* entries in userspace */ struct list_head ent_in_userspace; + /* entries that are released */ + struct list_head ent_released; + /* fuse requests waiting for an entry slot */ struct list_head fuse_req_queue; From patchwork Thu Nov 21 23:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13882464 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 B69DF1DF249 for ; Thu, 21 Nov 2024 23:44:16 +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=1732232661; cv=fail; b=o6fPmdvRbe4Kw9I/vZUrfQfQ2fXsunasAMOWb55P2jFaVMJk42ICMVJxOrVpE6ey1Ds5lLPAu20wW+HjzlVPwzC/qwtjbKnIDjNET0Atm+L0RyQTYl1o8HZ2LCfLiLzYNxoDT2zwscuYch7YJRFNDvuNceZR+6RtulRDTsDtBrQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732232661; c=relaxed/simple; bh=RPMoUJAyGbvfklGj9MFjPFXF+FdPkav2oMR/f11YLFA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MmiVgPhzi4BF1sxh4NkOcuB1Gnsx5pcE9/H/K2Qm/mg8pzP7ZdcM47O6nqDOldkWFENMIw4/Ozl5AkHYaLxFVwmmFafygp6aDmEVVcpa+35pgCz9ObIrDti2ZqqmXwKLW/04chPkSv0c0DixjD3Vnf/3M6pnxRvKa1kY5J+dFkg= 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=nZxeJPwX; 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="nZxeJPwX" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by mx-outbound45-46.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Nov 2024 23:44:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kSMoVPatx++FKZciwzaWelFqbn7Yhe0Zd2Q7d5fe2jj8oaAjt1GDM70OgTbwUkhgJLkiNoFn/shUKSXhAFR22v2GYiQU6aKiffPYKiJNa5r8zWoXgxjE1Y1Vq/yHpCmJXDwYjSkg6q2X+TQ3PUU6KL/GthV+rShyv/bWCdGB4V/phzYwHE5tgTl7r3w8vc5Hn7TkPUws1G//8WraDWt/1VT0uyuhvY4tNDbR0R865XQUNVA0ZDeXVGfVOq/9sLGiepNvTDbEoVMaZPPrllfYlHOFynjPF+x9v5YVbMMc4dewHLRSUn+dF6VME9q+OToczSTr0TJGGpFeN9/sCrTOlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bY/bc5cdfc1CLt9Gt+/8H+rAOdd42MJp98Xf5wUpVIs=; b=Na+xPN/bwAQwf7zJIX8WClAGbUc1yAe4YOv3rfGcLOmk071MlTwWCVmqOSKNOTHCMm53Wcyd7btfE67lO7TaPaKtf8k1hQJQPq1oMHzDsEbxcAaxWZmtQml3ezmRV+07J+jT8jGHSUd6gKQ4BrwwW1vfBgWVBZR81w2RJjrpTHii2VXJ/6C7SgZ7JB8gcDdVdKepNUufz8xb+eBelFPVelucYXSzmGciAy5rv1BLUu+Ex6QfWMcpZlRn/eDNm5DULckS6xfylgA0sDpg3nD5+MVY4HRjpxRb4udp9wqQ1yBOjGhfZR8+kcYhe83G7eKf7V+UxJng6HGO7ei7tntVUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=bsbernd.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=bY/bc5cdfc1CLt9Gt+/8H+rAOdd42MJp98Xf5wUpVIs=; b=nZxeJPwXAHbT1mM/ujahLn/0qwztzqSVWd/zZQ4tunN6mLjryGyr7ESQGuTWPf8qAY0viQpDSNJ+mctkEqIY3AvY3/tzMY2W9gmS8FjcH4x7UD9PxcU0dFNwfUHqoiEZTzRecx4Jjw1wKIdLs7o5UDF0h2zuCj5Kfb2YP3njbCY= Received: from MW4PR03CA0006.namprd03.prod.outlook.com (2603:10b6:303:8f::11) by DM3PR19MB8337.namprd19.prod.outlook.com (2603:10b6:0:49::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Thu, 21 Nov 2024 23:44:07 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:8f:cafe::dc) by MW4PR03CA0006.outlook.office365.com (2603:10b6:303:8f::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Thu, 21 Nov 2024 23:44: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 CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.0 via Frontend Transport; Thu, 21 Nov 2024 23:44:06 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 7981832; Thu, 21 Nov 2024 23:44:05 +0000 (UTC) From: Bernd Schubert Date: Fri, 22 Nov 2024 00:43:32 +0100 Subject: [PATCH RFC v6 16/16] fuse: enable 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: <20241122-fuse-uring-for-6-10-rfc4-v6-16-28e6cdd0e914@ddn.com> References: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> In-Reply-To: <20241122-fuse-uring-for-6-10-rfc4-v6-0-28e6cdd0e914@ddn.com> To: Miklos Szeredi Cc: Jens Axboe , Pavel Begunkov , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Joanne Koong , Josef Bacik , Amir Goldstein , Ming Lei , David Wei , bernd@bsbernd.com, Bernd Schubert X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732232629; l=830; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=RPMoUJAyGbvfklGj9MFjPFXF+FdPkav2oMR/f11YLFA=; b=q2nPWX9ypTPCTXtOFudBUgw1AmGc3syBba6f7a9Uqu0X2LEfJkEOKcKZfcAKbx+W/zxD43pPh xHqMux5081QCstx4Cl+wXDYwXQClPkfGAaf0pAdrvw6G7meeVpesriq X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FB:EE_|DM3PR19MB8337:EE_ X-MS-Office365-Filtering-Correlation-Id: f81ff883-d2e9-49ab-4d6a-08dd0a866357 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/f14/iPX1L+hxVZxbalmDPJd+XqRbdW?= =?utf-8?q?BVZfQL1TnyBCaVRTHNDCs591JtzS+oSgW8wpVgQwGqpD2UIFl11Fj8wSy1jGFoqmt?= =?utf-8?q?No5P7tqw7zc/Xtrzjwj2t/jDP2zeR10AESmdH8ib/MYQ9DtDI0NeHvhS/h9cENR4g?= =?utf-8?q?oDDXlZdbo/EBQwn3FXMLC6wGBuGJVkMpyGp/dF+Qhl9jW+LBkE4GUQ2sPLWHHFWob?= =?utf-8?q?58UbDyzLij6jxHFk21p18Wwke3AvAKeahKDwa3WhMwwHtifehSZfE3zi5ehdoC4wh?= =?utf-8?q?tnj6axtNthZ9vIer2vAudIN3juMM5U1eKLWtflqnQsNSk0JhdvI6of3oS7yil2kqc?= =?utf-8?q?XOTxQd/sllL6Vt+BFGNldPIws7m1Ho3YAZMqWSSGrH991ZjzTMqPg+t2mLoRmQue2?= =?utf-8?q?cqxhhJQBqfXMYYIIt7T5bfQJLp+tMacL+vux8qb328xoaFKNs8qJJ6FOSMJr382s2?= =?utf-8?q?v059hh7P2/jNUExQuQmf4IBVXDBMXhGFe4ahtse1R3g3cbpPuqW2pfPVDsHOb/T8q?= =?utf-8?q?he4cNILgsqgA8/Ox4yGwiMlgShZ+GlkdkVuRIbAWp/tPMpnqH/zy4+zsl/BWRKgq2?= =?utf-8?q?meq2rc77HxFsjUIQhJ6X9x/PoSJsUXQY3SaSx2b+9qhYHlL2kGBn5iQp3Wv+n2jVy?= =?utf-8?q?WR4hGSDL+4VM73ESC7sq5CC8NqxBQXhfH304y8IWZ9J0T2w7PH6DRTqQRP6DYacRB?= =?utf-8?q?YaoyFCbqT4N/8UiuYu6/2b4IpXYAyluC/9kTNGcjtJIxbcM1DsK7GIjuzmqZDU9WN?= =?utf-8?q?BkZnLWtQzCDsP6fQa56SGp6dl4HhwPeT9AyOSXnGlnf5IMov+Cr7fqWR1LqEUSpDB?= =?utf-8?q?4d6LQ8iXeooSlx0U5a+Ogz6qnxNTLEj1k1r1lWkn/I/B99sVoPBAJmX2JpyUr2A8N?= =?utf-8?q?iZYER+vFuqqhZc8A4jLazSeBxPuRFTCjoTwPg0iChI3xGK/PBajNkhfE6aUMWufON?= =?utf-8?q?tLznr+IdxMDz85mLlr1QtubIIONF30WkoM8/WdzegivFmCkNQOr/l0PfsiobAramt?= =?utf-8?q?FS7BDLWwQqHEGeq/ELfA4hxcChHudqynHVyjqIYZjY3kdAXY5mikTJ7UGtnzkTsC1?= =?utf-8?q?ybctMBatvNCIf0gLhy+S/Xl/dXkPvWVhqXJHMYA5raXzOo0RE9cfs8dliQkLH+mVY?= =?utf-8?q?znXySYjxRXTCDbAmJnZkZB/jRtEb6rGmQUDhXDMbEpzkjP/ZmGMlol+Kk33VOUH7P?= =?utf-8?q?g+NdCfM2I6E5SAHLL72+K1HazHyB/Tk4rSRiVz+TpQc+EOw6UkNmf5mju0rfYybiJ?= =?utf-8?q?blADsrsgRHfx+gFHb4V/TQ+Ar3w00x2WF7yHQYoSSyy28SXdAfsILlwzFRut4M5h1?= =?utf-8?q?kyzPL5G1AaorEoobNfeJB84WQR2ApiBtAQ=3D=3D?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fA4FTlXbL7KTwMZvgMzvVmhBajv/yVJfZLekhDY3p8ErA8xBgTJel4OkOA5LCpXCkOrU64XAXcbEkhO/H80767X8tZ3n9BtrL4gcrupXGZMCFTlbuqdGZboFgGObJp7AZnVOkFRsvp4k9lee/PF0yt1zDGcROPwbRZL59AAL/qpivj/9CmiI7WOOKc/rVtWFlkCXj4v6ebJoR9voZfukVFr5eZ8BP8MkSwAXvnZkBgdJyC1mUpVX1Cm2JuXQYjt84JAT13t+tfZquXDysHKkQFjbd0UbxmXN56PTmljX1A4p7qAlxKQfUibXOleyDd+v7ODlFMdbqwwSKvlX9yuE3Qnza4GxAhpCFhBxS2RiuJCr6qQKxUnZrl3adRfajb4AoP6iRJV6oNFEI2iiUXjNoTQ/PsVPVLa4YSyURPIfI6oAf6EzeQQ1gxfVBlqKE54cldIBHWKxhlN8ZMl5FY5MPxMUGHxPi6TY2lrE1p4OlMEj9GWCcu2XeKrnQs8N89neYTVsie4SYKwFyBavFB001325mMZiaA724qv6i3f1DSEuQL6sGCyqvYaCzJFXCFuXfxPYmNu+RVifJkZEcW3K+rU9dJ5t1yHrnLDlFToLSv/RgWbFFPrloXMZTIDD2YawWC+zi6CTKTnWzReNWs/VaA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 23:44:06.4102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f81ff883-d2e9-49ab-4d6a-08dd0a866357 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: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR19MB8337 X-BESS-ID: 1732232650-111566-19933-17907-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.57.172 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhYGJkBGBlAsOdHAxCjZ3NAyJd HI3NAixdjA0jApzTjZ1MIk1djI2FKpNhYAOP1GQUAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260587 [from cloudscan17-155.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 All required parts are handled now, fuse-io-uring can be enabled. Signed-off-by: Bernd Schubert --- fs/fuse/dev_uring.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c index b7a6c3946611a9fdecd4996117b45b3081ad6edd..91105b8f674baacbd3b16bede8678686ff2c1896 100644 --- a/fs/fuse/dev_uring.c +++ b/fs/fuse/dev_uring.c @@ -1122,11 +1122,6 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) u32 cmd_op = cmd->cmd_op; int err = 0; - /* Disabled for now, especially as teardown is not implemented yet */ - err = -EOPNOTSUPP; - pr_info_ratelimited("fuse-io-uring is not enabled yet\n"); - return err; - pr_devel("%s:%d received: cmd op %d\n", __func__, __LINE__, cmd_op); err = -EOPNOTSUPP;