From patchwork Thu Aug 24 15:05:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13364332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A353AC71153 for ; Thu, 24 Aug 2023 15:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241870AbjHXPH6 (ORCPT ); Thu, 24 Aug 2023 11:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242125AbjHXPHv (ORCPT ); Thu, 24 Aug 2023 11:07:51 -0400 Received: from outbound-ip7b.ess.barracuda.com (outbound-ip7b.ess.barracuda.com [209.222.82.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8AAFD for ; Thu, 24 Aug 2023 08:07:47 -0700 (PDT) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx-outbound45-241.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Aug 2023 15:06:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EaOOTLALiEGXCnYNodz6nZv9s6vu3yco1SZ38tdt+r11uSLDhmw0u5B8j6lNUZjWA+9wQ0MDZ7j+4kYOt5CUueIKN7Hi9CHyUWnNkoFhfcGvkfLcgcRGBKjD0r5blm19Ym1yQy6EqcYw185qLxQb8o7XhevOKO2iEc04nxTFF9bLXSJRmQ/gP/fqZQIsYbek4bGEETUCQ0I8zKr65og9h7NEUief9jGonp0BoEzHyBPFho0ZPipr7c+j5jSSl2wCUU725zu+owqBwksidxBF4vxuN/7xONGLOVy8AY5qtQMxIzX4pPvXUAuJeBEHv8Y8CrQQecCA1hT6pniLxoeIyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vbmTh1TjOZTBwTZXPnUI73gUmgVaABp/k2TUSx+hja0=; b=jUIOZAXy5n+3nXRkVktBx8jyT28RBbQrcDVQvC8CHtbPCuFumZ3HQtT/oBCCHLrTgTLlOfwPzOce3XO/ioJeDr5oJd9oo/7zgBDRjFV2NBO8dJHGEXh/qD+FoyedzJTB5BoMwlkigVggVIGmfae/fGCqC18gCYHmcoM89Su6oAIJ3S+EZt8EIx2jOmXrklgJgrebPDcUoEaJp8bkeO0GKudnlqDkV9cFtfA4x+lwYs8G1gVWGd3Q150RfcFGgLAMyJm9Bxif1mv6dTw2m3GeUFUwFK5hgaaMtHTEkFMW/FxwyTar2yMXHDo4SjJGHfLRocpSKt4ElRMDIyn7e1cozg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none 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=vbmTh1TjOZTBwTZXPnUI73gUmgVaABp/k2TUSx+hja0=; b=Wr8Eb8gFeh2vh84klKB9i6zGTmwpaZHoya0pCL4/pfRCzLbSyonL8nEttIJUsAMNooZ6Z+Z7l07v+Ga8wM63eEqyqYYrPQjKWV9DuqqBarebOqC53NvZCay8uuZXHYKnQHo2i52BSNxMJufyoaouGftErnh0j+nofnGBkv/e9O4= Received: from MW4PR03CA0227.namprd03.prod.outlook.com (2603:10b6:303:b9::22) by MN6PR19MB7866.namprd19.prod.outlook.com (2603:10b6:208:470::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 15:06:06 +0000 Received: from MW2NAM04FT059.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b9:cafe::81) by MW4PR03CA0227.outlook.office365.com (2603:10b6:303:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 15:06: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-mx01.datadirectnet.com; pr=C Received: from uww-mx01.datadirectnet.com (50.222.100.11) by MW2NAM04FT059.mail.protection.outlook.com (10.13.30.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 15:06:06 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 51FA820C684B; Thu, 24 Aug 2023 09:07:12 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 1/5] fuse: direct IO can use the write-through code path Date: Thu, 24 Aug 2023 17:05:29 +0200 Message-Id: <20230824150533.2788317-2-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150533.2788317-1-bschubert@ddn.com> References: <20230824150533.2788317-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT059:EE_|MN6PR19MB7866:EE_ X-MS-Office365-Filtering-Correlation-Id: 10f3bbeb-599a-443a-c62e-08dba4b3a44a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nWM1gck2Yt8iLqUzmlNZhKEHGIykYbjX+AE6b9DZ3dXBHICMCfSZmLMqNERxYIUTdRO4NUsyNMPujwb76fBraVGvf6CL6UIpXYbsT/8iVmpEd1egiYsKalt0FJYWpRWDJNvnocnM6e2J0ID0JTYrE2Y3jVT7zqRCujpxj1uRANqQ/zI0gPQs15fgc8NogtNAcnXV0HujmsS51axGJd7rOx8f8gXlcGgUk7MYYtIpQYQqiITA/fMfWMI0VAv8r2izrYYy6TMxhMp+J26G847khb5sCuiq2DhfX8BRX6ZuYmAJ6eaRJroqMrAnQR+1owroJrrsLEfeVVxhQQWP7FhPpWcMY1oETMhzkF+BKbh8bqoVWC5EM1+GaqYW+w2zclH6tTfDplk+ouVDl6T1bxkkzYUKreEXVxgzpQ7B79p9QQZK9JGg6i/i0LaJq4eHz5gEPvJ4V6qbb40CkQvFRYHqbXD+/1B2Kw8iukJjm8nwZlraym51npA+sBrJJ/0HtN8z43TeC0PAMKT8fgU0burDrUfjq0Rc9gR+EnGbEK8B0lBIlOwiW6IShoLWxsHqcZsV1hVI5kzStfBwYDkFUllnT90OT+e2QOPe75yUnX4d4HkQJln1LW81B/9Hs/nxFsT90FIMXgJclVjfeTwhJfwuxQbxdh9/slyql9+ktJSQJupYeEi7K3kmJQJ0fYj5WmGCzuJTzpKF0EwTxJsJFMUV6Dk3cp5N8KueEDzktQjdeOpz3xZszfRLuY//MlQ690ts X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39850400004)(376002)(346002)(136003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(1076003)(2616005)(5660300002)(8936002)(4326008)(8676002)(6266002)(336012)(47076005)(36756003)(4744005)(83380400001)(36860700001)(26005)(40480700001)(82740400003)(356005)(6666004)(81166007)(70206006)(70586007)(54906003)(6916009)(316002)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JgioNlo85nOYrlexRhA3QPro5xIZzzmQBjod9yq1YdNei7n799ahnsJSaWUc+Yn3NDh2urZfOHrzC5TMptpuqjWizT6kgHyxX1yKt6xT/fkJqyDEL+r1246BnEKBvhpPcovfC1JKxQGQxShDLG4Jgs4AH8cIQs2tHngry58wH9DxjvX9zV75i/RU5/9eyUyDwUkIlp67Jmlp3n+d2Qy5PCt2yUGlYk8P0AAVpjXmP4Y9c6Fr9GXtxqL/5GBj4a1ZZ03sELoi4G7UqzCTDZbYZIsYGm+r7PGSuw6nyCiVNSBh7lE5qneMCGSF8CNCkKGm+TyMnDIxSMXBTKjUO5rqbb8Sy2DkxRPKCLY+MZEfqwzp0ASRoVbddoqa5WOqhKR29df1Cbt0oKwWCo17CGGz7hYohYfpcp+b7XDjVBO/3B+LD4G+xIaIBd+mDu3sGtPafOdMjUH4w8GCamHzKoFLbbG8lwbgwKG1P85K+mHMI6FU0eC4X/ZDXnlddsk1x18X1QshjcPR7bRJ0On9bTupMqOqW745MY6dd5CjB5arzffX+TIlxhKhwmE0y+vTFkrI3GyrIo5mLXgHEP0cjarddtHQmbcp06SRO5JznnADWeB1zjvmEFYG2Ci8BdAG0j0gA2UYwln+dRTf+/ISykgRsPySkxBEeQI3tzaNgp5rvsX1oOgIiTuRUrAgcZ9QD7NJXzrKHWdVM4TCi9IBO++URY2vRsSd3slgg9768zLZ84YcP1GHx+nEFuku3scXlUVxfPuhG4PXPCjsCDrBrr9B6RBCBe9kcFkTyyq+h1bsZaWoNH/nyER+zHkJEkxTdYe1/z6GFpIq4XgOxYovGHGfNiucR0h/M54Dw96yaNYqbsqTMrFIyZJAaYgjfnIsi3ILb7/eLcKSW6fo1IdS1oFc6Q== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 15:06:06.4741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10f3bbeb-599a-443a-c62e-08dba4b3a44a 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-mx01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM04FT059.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR19MB7866 X-BESS-ID: 1692889576-111761-6161-149-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.58.101 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhaWxkBGBlDMzMDCyMDANDHZ3D QpMSnNzNzMwjzV0jLZPMU4Lc0gyVCpNhYA2S+ZwEAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250361 [from cloudscan11-221.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Direct IO does not benefit from write back cache and it also avoides another direct IO write code path. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Signed-off-by: Bernd Schubert Acked-by: Miklos Szeredi --- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1cdb6327511e..b1b9f2b9a37d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1307,7 +1307,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) ssize_t err; struct fuse_conn *fc = get_fuse_conn(inode); - if (fc->writeback_cache) { + if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ err = fuse_update_attributes(mapping->host, file, STATX_SIZE | STATX_MODE); From patchwork Thu Aug 24 15:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13364329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42030C3DA6F for ; Thu, 24 Aug 2023 15:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239575AbjHXPGy (ORCPT ); Thu, 24 Aug 2023 11:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242106AbjHXPGf (ORCPT ); Thu, 24 Aug 2023 11:06:35 -0400 Received: from outbound-ip7a.ess.barracuda.com (outbound-ip7a.ess.barracuda.com [209.222.82.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145591BD4 for ; Thu, 24 Aug 2023 08:06:28 -0700 (PDT) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx-outbound15-198.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Aug 2023 15:06:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTOVrrlLwPK9A3jn1wffusTnPaoNOLTxPDhwRgUBEFrgUYhaWl+kwog0yNwKpPeOpZIf1NrVPnGmsACwiDMoPCFw2xrV+Tn3Z0IDZsYZhDHe4KeDpRAjZJM/9aDzw+dlbAcPHf4wtVISG5HCb8LnykM6XPgxeLmQsYvmGaKKkE7nXLObLqO/5MEwjzWT4Y1ph+j1tyV2XCNSb//Si1HXJDuqBdTJS0t9zGVuIJRfa3bWZnI1VaRGIrhad57QayQi7vA+8lirY/7sv0xz4U1rc7Af7LdwocE2z2O6kT2ACMAPSrcOEg8/ot7WK+Gj7YlU9azUDeJiddDyhROIIPfOtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Nzjgxlalg0V8lqWSz1bKqRHpdj4spdXbYosbLVk3/G0=; b=MuzVhJADaZrfgC+RrbO54j1G9SiqxVLFXgGAxypMl9a2LQJkxnnq5KHnKwyqDBvhwytKzpX6VAyp2Y1ghK/7nnELHB4dAOIxGre8ZwX0006WGCRlTSl/TEgTu/Klzk/CtVd+f2u2kTk7SSgPnsuJJ03lWLZNqQTUX2Z86XixC2joH852PRGHeF36kNOFbkmhJZouasEyPi9w+ABc9tFlQIeghwXq+9Kf/QEvcGQaNHeod++n1yeAGE8DW0sEG5LQiJoJR46VJg98QJr/c5Z9PnGhO7zq+rboQZEAsy0Af0yJa7G1lxMWNzqSXLEjmBo/9Js6y+H3VJ2vi24/kh9oqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none 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=Nzjgxlalg0V8lqWSz1bKqRHpdj4spdXbYosbLVk3/G0=; b=NxvtX7W43tHZDht/1qBBTn7kvC0dGJbKMSSNhM7/K96Mb9tbUXyPA24lKQD7XNkIKxSSD4tJCIBvMhFyVtbKyUXoAMhN9mwWgLnDC+/4rO+xrbnYUcrk1E3IGC4d7CVu+yBOnNZqxUXpNNnoIM+fwhawkoUE3OwrxnpMBNWTU90= Received: from MW4PR03CA0186.namprd03.prod.outlook.com (2603:10b6:303:b8::11) by DM4PR19MB6075.namprd19.prod.outlook.com (2603:10b6:8:6e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 15:06:08 +0000 Received: from MW2NAM04FT064.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b8:cafe::4b) by MW4PR03CA0186.outlook.office365.com (2603:10b6:303:b8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 15:06:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mx01.datadirectnet.com; pr=C Received: from uww-mx01.datadirectnet.com (50.222.100.11) by MW2NAM04FT064.mail.protection.outlook.com (10.13.30.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 15:06:08 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id EAB7620C684B; Thu, 24 Aug 2023 09:07:13 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 2/5] fuse: Create helper function if DIO write needs exclusive lock Date: Thu, 24 Aug 2023 17:05:30 +0200 Message-Id: <20230824150533.2788317-3-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150533.2788317-1-bschubert@ddn.com> References: <20230824150533.2788317-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT064:EE_|DM4PR19MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 9937868c-d90f-45a9-1c24-08dba4b3a544 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ry9i0kr5NzrsdCqzHVk1tgZpCUldrvb/otBQG04xK1rbkDoKH0MjbDtBuXkuhH0lHR/IZcQL9VBpyLhLQwoispa8oyCmVSuacx8qu3Dh8hD1fGxkGwEZIgAk8x4vWFNCoD0h6u4NfZOV5qohK2ULyBW8Bkij0ZjYZMSbbn0lO66DoLQWb2WhVaa9l7iDlEGOG4YDV/X7fKAEpZus4EieUdi0TQQOr+0kf8kXq6egSMESLM2s74RmZ9Ajxd5I6ib9diRlj7YxgbRaBjn2s+3Egkh/ygxAa2pv5kF1Y0bXZJDVgJfZlGIq8paEiRDUQwDkHKVneENlj6gtbG7IZp7ted9v2tRMfPJmALaP3bElBIAlxbZe2yQR13FZWx2l324zbR1etgqFusp0uYAf7heGOpvQllQFC616fsjufFOB6ovzv9V6jU+HlWymCF+GCWr6trv5lth3rUcdTVvnkIZRYevI20pfVBg3mcAv73TwAFZy6Ild1VkUPAnGpjAebpWwq/bmY+xdsz6TcK0xe/+LbU/kvGIeBst4Av5RJQc5mM1I5ZhlOqd7L1id/5J7AK1boi5a2NjnXnWmGYmmo0BU4Sxksbz0pz1VOZhw2JeCuRu/pHMnjGIRdVE+zOehsNTjPuEka8RZYYkiA9Nmy9f71xHycuM+ukFGCILOdjzN+GdnBJKqSrw22C7EM7vrxmC6jcp1Fqx+QZQ5Ayvz1lKmui13Z6UurH/E+gPliAtiBsV20QO+DHYrf19vuAHWXQv0 X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(396003)(39850400004)(136003)(346002)(82310400011)(186009)(1800799009)(451199024)(46966006)(36840700001)(1076003)(2616005)(5660300002)(4326008)(8676002)(8936002)(6266002)(336012)(47076005)(36756003)(83380400001)(36860700001)(26005)(40480700001)(82740400003)(356005)(6666004)(81166007)(70586007)(70206006)(54906003)(6916009)(316002)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: jRHmjdvJTzqJQTz69d0aOAJhqbpuDJTg0vo+tan+dqqP9eLA3sqzMuR7Z0vyS+NYKDz1nYm1EfKSdZ28ehweChN9rtWel+RMtTlps739QaDqrfV8HjteKhzNNL8xYr9EZSNx92iCWoO/VSsVpWPDOaC5TMCJcgWaPgmihdLhYC6PABebWFU+66KK4eamxktACq4HY8lzxbUU5oUQPecdRJhx6bTDNolq3DMAjEKYgC1VINZ9mdHmddTi6ZUANF0orqZPheKV58ThKhGJIfuP6fYJy3TY9zdZZeYvnSfCrANlzUYy8iae3MZonAR/UjPNTWmapTd8kJSH45nwmQnpNtpLzW7yjt23AwAb98T34vh7y4ii57IgFHgTbEJ5zpKEDMGt0ZBO80UM4qWWTSjUnI8utSpHX6a3jBY4+T4X6blTaiJRSq2Qk9ujlseaDJVFSLTsHixhIL9LtJL2h00OUIFuGQzYUmRT+wtcQhG3nD8RRwy9Ecwvt7A98TDKgIJHP8tjvqvxCw8rrivlMHl17sTiSs/vS9KgjStgrzR3IVOmlumg5DqoCPpN5fQ+Wuu8DuyDhDvsZZzS52CnhubYiZbWAD8RGcDoRts+0rxPdH2sKkd7Y2hk/Ysgn0vspXGjhXrKLxX6/47Arg76GLApZ4E2RbtIcxVkZH0n5ObEjTATD1wKDuk7Sq1dLdwNoGGhUgc4K17X5eRRux1zswNnw4nHl1WY2b672rnQpP+3DCAL7NIZ2rLuOiJv6AF6FTw/oejoEk2Ln+Et7ULKae/xqPb8iaIaohJqFF1kvVwZu9Ky7YSDElFPiI2Tk3XRUvSQn/CHFnLy6MPOhJ9aaJcoLpWNsKqdOAiB2dkgQDwJSeV4/95zmjkP/RJeEmB43T6LP1WyLIufcU26UYpGXHZ9qw== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 15:06:08.1081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9937868c-d90f-45a9-1c24-08dba4b3a544 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-mx01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM04FT064.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB6075 X-BESS-ID: 1692889583-104038-25174-37-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.58.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkZGpmZAVgZQ0MjEODHNwjI11T TV3Mg4KTklzdw0KdXUPDkpJSU1zdxQqTYWABcGkEBBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250361 [from cloudscan18-232.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is just a preparation to avoid code duplication in the next commit. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b1b9f2b9a37d..a16f9b6888de 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1298,6 +1298,27 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) return res; } +static bool fuse_direct_write_extending_i_size(struct kiocb *iocb, + struct iov_iter *iter) +{ + struct inode *inode = file_inode(iocb->ki_filp); + + return iocb->ki_pos + iov_iter_count(iter) > i_size_read(inode); +} + +/* + * @return true if an exclusive lock direct IO writes is needed + */ +static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from) +{ + struct file *file = iocb->ki_filp; + struct fuse_file *ff = file->private_data; + + return !(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES) || + iocb->ki_flags & IOCB_APPEND || + fuse_direct_write_extending_i_size(iocb, from); +} + static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -1557,25 +1578,12 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to) return res; } -static bool fuse_direct_write_extending_i_size(struct kiocb *iocb, - struct iov_iter *iter) -{ - struct inode *inode = file_inode(iocb->ki_filp); - - return iocb->ki_pos + iov_iter_count(iter) > i_size_read(inode); -} - static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct inode *inode = file_inode(iocb->ki_filp); - struct file *file = iocb->ki_filp; - struct fuse_file *ff = file->private_data; struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); ssize_t res; - bool exclusive_lock = - !(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES) || - iocb->ki_flags & IOCB_APPEND || - fuse_direct_write_extending_i_size(iocb, from); + bool exclusive_lock = fuse_dio_wr_exclusive_lock(iocb, from); /* * Take exclusive lock if From patchwork Thu Aug 24 15:05:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13364333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DE42C6FA8F for ; Thu, 24 Aug 2023 15:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242038AbjHXPJD (ORCPT ); Thu, 24 Aug 2023 11:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242040AbjHXPIc (ORCPT ); Thu, 24 Aug 2023 11:08:32 -0400 Received: from outbound-ip7b.ess.barracuda.com (outbound-ip7b.ess.barracuda.com [209.222.82.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE1A1711 for ; Thu, 24 Aug 2023 08:08:27 -0700 (PDT) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2045.outbound.protection.outlook.com [104.47.51.45]) by mx-outbound43-111.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Aug 2023 15:06:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D6izq3ZZ0st4jOdxcylg4+FqLBcZXsthKc6tOg3d5gCjh+k7KetlnyzBx+fqIC00Q4ZJoL89yaarUSN4XA6YHjTHfO5gpLwPe3SqXJvVi1SAh+KwVYNrs531IZAOwvCX59xyVib7/3TyXZWSE9FjChC7Hjbz8YmVHsqCwwQupC1JQJk6Zx3ZeLsLvOaqlUwMxKZzRdaTLpc6M80IvUfwSVjmDtQ1H23UXHHR0pMTi5gMuMCWb63rCJU2zbZ8Fqp6LsG6G1CpS+tWgDfTFTEYpaMXLlvuiX4kPNzbA6j5WSIWJJg182NnZ/NxjdLJdIToKivtWOiRfkCT48eEfkhLWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3wJ9BHb5XuUtUwN+eDjU1EfspJns/pdiPyjsZxIQFSI=; b=HPjaW0gIyJWH/GbEstd4S+kGvFDJN+cwnBXSkWJRwXHFLYTYaonmEexmITJF53cgJtk8RNm1yKS0OPaSPRtpoMC+2gb7kDmWmd0VveXpYqX/bhFezYwtg5RxWa9POt0UhCpzIosNTO4K1j2M+wyr+HaATWzfLmrk6n8tyg6KhWX6p4yvNQPYy+BBE4CxAy1bQWyN/O7HrDq1m5CzMsVaK4/kBgd18jfuj+VhbcxKlif0m8hwEAlpjeYRiUVHRhG28VTRVoSzgAnNmVxmUmcjlnikozDHacTTS0rI3GtNHA7kiV8XJ5jUcTiiVdu7QB7ldeDj1Ouk0FTSmt0Eykv7+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none 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=3wJ9BHb5XuUtUwN+eDjU1EfspJns/pdiPyjsZxIQFSI=; b=Atp5ZCVq3Y1trIsa9Ro50Wn9N3Ub6kHrb9uo/sfbw+AR9juUY9pqNdRckY5W1/68kaizRziwLagtFs3ToNtOA5nmuJwoLQC749R/tmKOjHC+xOxkZT41zsGsobomfYHHKFvDavqmzU1holSb6E1v/kC00a94dka9AAQ7PdtQRYA= Received: from DS7PR03CA0328.namprd03.prod.outlook.com (2603:10b6:8:2b::30) by DM4PR19MB6051.namprd19.prod.outlook.com (2603:10b6:8:6e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 15:06:09 +0000 Received: from DM6NAM04FT009.eop-NAM04.prod.protection.outlook.com (2603:10b6:8:2b:cafe::50) by DS7PR03CA0328.outlook.office365.com (2603:10b6:8:2b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 15:06:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mx01.datadirectnet.com; pr=C Received: from uww-mx01.datadirectnet.com (50.222.100.11) by DM6NAM04FT009.mail.protection.outlook.com (10.13.158.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 15:06:09 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 949BB20C684B; Thu, 24 Aug 2023 09:07:15 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 3/5] fuse: Allow parallel direct writes for O_DIRECT Date: Thu, 24 Aug 2023 17:05:31 +0200 Message-Id: <20230824150533.2788317-4-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150533.2788317-1-bschubert@ddn.com> References: <20230824150533.2788317-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT009:EE_|DM4PR19MB6051:EE_ X-MS-Office365-Filtering-Correlation-Id: 0646dc12-a338-4b29-966c-08dba4b3a633 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KGezAZ46XssM+RGDrD6+ZHr+RVkm/2mytXmE907/pvc5M9E5snRrI/2VS+GFUl8EPIQqwydWhzXgrmZgwsYd0YJ5+6oNg7BlisjLeYQ0etZk8yjSsbiJv6KWKOvAnQ5I/swi3KHAHwDWCReB5bLiOSwGwhnwXvaUqU0WnWJ+C45F5DWa2uJNuWLHf/xJM9lf/GFplDRpEx5z5mgNCx2PQB9N1vsilOjL1a4OjUEewKClJdtQvj/Wi2lIKeWWV7E0nxgxUkRblkgMGZOoyim/8htrwFbt/h+evhDyvkb9XxA42bz0cmGZzfXC7XUDtW4cDQshFpMIUm7TdGtmpvGwfkbXfky0/4tcsQVC/rEgeCI4C9KuXnQ5GKa+DQ5uc5F/2y2XMlufEXThJMXXAErW7/Pl7xI9lGu/5up8Herjusx7nxGkvaXnlT/4We8VTUpu/Mod2XA/vmZO7IUYZRKu0V6Bu1LA31hZZPVcRFTKtB4MWxcPe9bWWoRAdO45sjOjmu/1rt/deS+AH8MTMSvAIY6xZPC9x8UWQwngNFSBLH6VhjNKSHSt7tNCbukKJq8QiNiht1vsnbv/cKGwbfa5509GmXXy5rNMRdOdGUmhWFlpr0W+5+JM3xt5yPlFb6/fVqTLVgz6si84TDdAU4ZPdaW6qnV/m4iCBw7gV11MKYxgbz9cvk2JHkFkIcraNC+v2UXNWwMQATl9BzV8oOPqhWWf+KQmAPfPkNA8O80aEl00fkpVPfnYTlv7+Fd4l5pf X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39850400004)(376002)(346002)(136003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(1076003)(2616005)(5660300002)(8936002)(4326008)(8676002)(6266002)(336012)(47076005)(36756003)(83380400001)(36860700001)(26005)(40480700001)(82740400003)(356005)(6666004)(81166007)(70206006)(70586007)(54906003)(6916009)(316002)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: et83gDw1xhP+eoQIeSFi9GTfGRDDBrkuE7hVlrTmG6nwfOlhbS0JagT1+0Rnv95k4IkEYxSE6cJt/wsFYasI32p6bC5+LFWhr00FiletvHXGFXBpiFNjrWCi8X5UDPmNo32UTU6JUX4wwiGbFUJqo8OY+Yp3TkN3fWgdAfISGq9E8sN9WEN+G1NgDcTxZ4a5Yd6xp2GYqEHpxSsJxOgCMFiaqeE3H5mnMDGagJStgoTjpO0rF6lCIdJosX5nLKndMWoIOQdYfAO4nW0gYAvfAgfx3k1Hxj53nMLjTO32ctKSZzgU+Dp3GxOsmLpFqEyd4WzeZNVfzMpeC5jrrpQQrDEA62yz57V8TBnC2RW2ChxAqdL+vW1DnpQlQzsafLYI3DigxqVDZPoxL9h1IcKXgaVT1pI6cHoW4oFu04ZV3aHM1HzC9/RvZhB9aszBtoObjlpYzaRBfO4v6I/+h7m0pqfwGHMh4qzqGR7wsfWApWdf8NE+6FESYHTVOmHZ5rq9bSGzMu7Re6KHusu70/v/jPxvZHEhJZ6ySoGirNQqrIggU99Ov2DoTblSYXpY4eDZc/0+1wAnNEV8H4sXb/rclxn0SVqRmoJiR7IHJT741ya2cZJhnhiZP1KMNyeFpeRSCsQKDIBVxUDxTAzQSSh0q+zP72KdbPr1moH/tNFIc+hf9gaAcwc7TbeoXTqW4KrqTIWoBraUPPnFv5JC17MGPKO92THRk2CS+uywrDOT1yngwG8X1e9KF1rm2Rdmy/7F5WCXtVDqvw41HYrplMI3YWSWQgFDscKpwGbeOG6+XjoBPylgraKXJNtA/OF2MEGG/pms7MYzgwrD8Ec5W+JDYfXpvAJL5Cqz9r0/hctOagI2+wiLUKCGVkf3lnJQMkisD9qPxCeOwh4pP3+3rjb65A== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 15:06:09.6619 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0646dc12-a338-4b29-966c-08dba4b3a633 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-mx01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM04FT009.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB6051 X-BESS-ID: 1692889597-111119-20297-58-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.51.45 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYmpiZAVgZQ0CLJJDXZItUkyS DNKDnJIikx2STZ2NzQyDQ1MdnC0jRFqTYWAEwR1G9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250361 [from cloudscan23-219.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Take a shared lock in fuse_cache_write_iter. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a16f9b6888de..905ce3bb0047 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1314,9 +1314,10 @@ static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from struct file *file = iocb->ki_filp; struct fuse_file *ff = file->private_data; - return !(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES) || - iocb->ki_flags & IOCB_APPEND || - fuse_direct_write_extending_i_size(iocb, from); + return ((!(iocb->ki_flags & IOCB_DIRECT)) || + (!(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES)) || + iocb->ki_flags & IOCB_APPEND || + fuse_direct_write_extending_i_size(iocb, from)); } static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) @@ -1327,6 +1328,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = mapping->host; ssize_t err; struct fuse_conn *fc = get_fuse_conn(inode); + bool excl_lock = fuse_dio_wr_exclusive_lock(iocb, from); if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1345,7 +1347,10 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) } writethrough: - inode_lock(inode); + if (excl_lock) + inode_lock(inode); + else + inode_lock_shared(inode); err = generic_write_checks(iocb, from); if (err <= 0) @@ -1360,6 +1365,9 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; if (iocb->ki_flags & IOCB_DIRECT) { + /* file extending writes will trigger i_size_write - exclusive + * lock is needed + */ written = generic_file_direct_write(iocb, from); if (written < 0 || !iov_iter_count(from)) goto out; @@ -1369,7 +1377,10 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) written = fuse_perform_write(iocb, from); } out: - inode_unlock(inode); + if (excl_lock) + inode_unlock(inode); + else + inode_unlock_shared(inode); if (written > 0) written = generic_write_sync(iocb, written); From patchwork Thu Aug 24 15:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13364330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87657C7EE2C for ; Thu, 24 Aug 2023 15:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240834AbjHXPH0 (ORCPT ); Thu, 24 Aug 2023 11:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242118AbjHXPHK (ORCPT ); Thu, 24 Aug 2023 11:07:10 -0400 Received: from outbound-ip7b.ess.barracuda.com (outbound-ip7b.ess.barracuda.com [209.222.82.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5E719A6 for ; Thu, 24 Aug 2023 08:07:05 -0700 (PDT) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by mx-outbound-ea17-82.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Aug 2023 15:06:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oJggNZ4NmoKtFzsLayq5FEcW82w1QNL2YxLuk+52oBdaRzXQVDLTfA8a4vxMQRbDqkhv22eUNxCEbaCyKKybIRnONk2cyaC9sYpT6vIot6n3SpUNOmCnR1nIhhFgI6PyouvyFlWjvea7VnU1RDLy2aNTf2/B8WcaKI3OYWyp1x4yxiqBBmryCO6EyFaK95Ypvq8zuNsj5mCChciIX5YD9KsEKrn+OXSg8tRXz0Jl6dBg5bZ9ps1VwcGmJ40gerJwtNWFGR2+8UScKC2TZny65HaOQyWUZyFjsYI0mhwjlDgmhL5ZCGrvzvTt3OXg6Xrx0DB9rIfUkshcWnii+qd9cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5lTNrwulir3onAf7S/QafsprHuIPEf1SiXXrxq2zNTw=; b=P+XT8sp9IhvYJ/g069tdiZaECq5RcSk/rAkAGCBTjkGQHJL6hQlaUUEC3DnEkcu8//S15d4pmSqAzqknHPVFsgS3T44WwnN407a2G3d1YStNYuD9LfqAGUaavW8u++yxWqih4npTbG4gc/H75WNmWEecRvL4yWpAJ89D2qqN18AfORpvXMlioAPgUplSrD96uA/uYGp/5Eh98ekbwlF7mbBgtCUdwOmh3oT3ZWuGtQnJo29UXzZRceldY7OBCGb9Yo2CMS7hLtOlAopQuEbTHIqb+mNqM7VAqw2UVX56283U+hRuqBGJ+7Pwka8NfBZiUgAC5dKVYqTyRWxgGUtZKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none 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=5lTNrwulir3onAf7S/QafsprHuIPEf1SiXXrxq2zNTw=; b=b3YS+G8yjz94yUOEWtbL2+TUcQrI3H7JBZaRWa+odsZozCM3p8NAcVd9XR/Ectx60d22uVyp15Bix06HYbObc0AWI4CaxwcLx2gS7HWOQ8AyDtbkUZmvFbghu5CLgrWG/VU3WjbmMwvtFAOiQ4SJAiX3sJ5LrgTIbIt9TnFHg0U= Received: from DM6PR06CA0041.namprd06.prod.outlook.com (2603:10b6:5:54::18) by SA1PR19MB7157.namprd19.prod.outlook.com (2603:10b6:806:2ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 15:06:12 +0000 Received: from DM6NAM04FT008.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:54:cafe::cf) by DM6PR06CA0041.outlook.office365.com (2603:10b6:5:54::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 15:06:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mx01.datadirectnet.com; pr=C Received: from uww-mx01.datadirectnet.com (50.222.100.11) by DM6NAM04FT008.mail.protection.outlook.com (10.13.158.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 15:06:11 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 8368220C684B; Thu, 24 Aug 2023 09:07:17 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 4/5] [RFC] fuse: Set and use IOCB_DIRECT when FOPEN_DIRECT_IO is set Date: Thu, 24 Aug 2023 17:05:32 +0200 Message-Id: <20230824150533.2788317-5-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150533.2788317-1-bschubert@ddn.com> References: <20230824150533.2788317-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT008:EE_|SA1PR19MB7157:EE_ X-MS-Office365-Filtering-Correlation-Id: b75a8b3e-4712-49e5-193b-08dba4b3a761 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O/3u2vOExTHiMvdniEBvOg+XjgItYipYpyMEH2ckTbuFcP9fzji7ssr6ipTcSWkU05mr/7mZHOEl24agUJPRdVNGGLw+Rj1I63Wz7y4k9VcDfgzkLuoPac4O0ImVBUz5QsDOSXocIcz9SLJyupHc8MO/K1/y00pHujq096ZGSWv1cuuOcIzvMjY1u7Y361SHugiuyK9J3ntvBDxXKn1ZuYJcaKTI5sgnj0lPJeHEgHcnTCv3M1+0or/AZ2MLZymMal359p5nVsWz3YEDiQ0YdlV9cBT0L/fxGf61nGJircYiowoWM3Rg8gHOc6c8XFk5okq4tNPS8meJdEDoK+PpklXYqZdWyuwgT5nmDpvMEO55Xcq5Om0e5jsMN8l8tC7fQUGIZrkTxySdBmF5fBRUkami85FceVXFm2IovYv2l/vaRK/J5rgAQM6zLWgl0H5HbRrsC1k8tfiPT2NmVBapPP15j+GPjFAT/dCW0zJ64op5CN7vSHsuVOAUNn6aP7pPbHkvAD4O64V1k6uyYjlNFyBQH1LkI1i8fiifTbRxBxgZu8z+cF1nkWGioBi/KXCEh9LlC41Hsb/qP3iHcgUmVHGwWEj5aTzZ6fEn1EdNQADLdT9Pf8bVIpbBlPSg1GXPYNJWVQCPQbj70QE1mfb/8uVcb6XD5nikt7cVzjhv3pu/rtCME/5P8dGFHc7ddU5i3MK2LvsxA48mARlOjz776d9vl8msSN9Kg/flL1gvum4iMyBoIUDiAq2fBx3vTY7B X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(2616005)(8936002)(4326008)(8676002)(83380400001)(5660300002)(1076003)(336012)(6266002)(36756003)(36860700001)(47076005)(40480700001)(26005)(82740400003)(6666004)(81166007)(70206006)(70586007)(54906003)(6916009)(316002)(478600001)(356005)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OHb11QDoik0ZbznC6niWOInHiG2dfa4Nr85dSJumUbifBvpoo2FOzfdRTXe441d+Z2O6nEQ2JNawC3b0QV1U/TfpxTsh5KnKjO9kjjw1qshzDbZHRteLcH/uA0UBZrG8O+JphCpKb4xwXEtBs3XFk5W6JhkKF4HmSDFqWlCLPNRW+xpOjNyEI9KUsfYIWKYSyvGbmO8aH4sspnRWeLPXAbkudvYC0VeOuEH3PvtEz6L8RTDbFIGu621OcZ58kehHuwiTZixy4H0m/42bshhecPzKtR14DAQmNfi+tvCeiFZW97L7AuToNP4waFzlCsOcc7MPw6PK/NJiBapopH8IEeBc/k04o0htSPIzbfOZt9y0TNnr/VIa80qKaYuExDo5QlkL+gsJFIB418YRP81tYTDlNdSOdHQUVKSsFnROOMBAMvVwxSdlpiAsubd0EHAJJPlJPlAmxh7K2+54alG3DGgZF9i7GRx4Qdfs77J1NtpkKcOOqtQQrj73l2DCNos2Lu09N3vuEzpfjgrB0KeFjfpHU5r3I7fJUJIJlQH0GiAgoxHKqU75kIJNC+RGr6zHCjVyb4vh/m8ZSzk6W9LD7CLDTEyRGunA1Kh+iId5ihMgY/y0RKh9kb95vgEcksjPoCeQ6Zbh520J5gbyobGgskTr0aVbvKmhnbROXpqOl63PCqk16/FdfqiNab5xbGwVb125fWu5pDcL8PXh4966qPEtff6Jt27bEsWj6TLgpqtKRYScFUXz2V7Sm3clDpQnfrTyX02cfOxvh81rPgk2GQ/dJHwKendD17H0f99YOwySd9/zdPVoYflLQiZdrZTxo8NWI5GFofBeDQx/r+rAsDVea5WlhXvNjYCWUZ81qOr2ZTLKe/jJwa3Meco5nLwzBIomgiGvOU1M+PEj+19dBQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 15:06:11.6535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b75a8b3e-4712-49e5-193b-08dba4b3a761 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-mx01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM04FT008.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR19MB7157 X-BESS-ID: 1692889583-104434-4698-9397-1 X-BESS-VER: 2019.3_20230821.1520 X-BESS-Apparent-Source-IP: 104.47.55.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYWRiZAVgZQ0NTCINEy2cgsNT XNxMjUzMg40dDIwNgkOdnU3DDFyMhAqTYWAG0nvuxBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250361 [from cloudscan19-64.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org fuse_direct_write_iter is basically duplicating what is already in fuse_cache_write_iter/generic_file_direct_write. That can be avoided by setting IOCB_DIRECT in fuse_file_write_iter, after that fuse_cache_write_iter can be used for the FOPEN_DIRECT_IO code path and fuse_direct_write_iter can be removed. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 54 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 905ce3bb0047..09277a54b711 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1589,52 +1589,6 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to) return res; } -static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - struct inode *inode = file_inode(iocb->ki_filp); - struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); - ssize_t res; - bool exclusive_lock = fuse_dio_wr_exclusive_lock(iocb, from); - - /* - * Take exclusive lock if - * - Parallel direct writes are disabled - a user space decision - * - Parallel direct writes are enabled and i_size is being extended. - * This might not be needed at all, but needs further investigation. - */ - if (exclusive_lock) - inode_lock(inode); - else { - inode_lock_shared(inode); - - /* A race with truncate might have come up as the decision for - * the lock type was done without holding the lock, check again. - */ - if (fuse_direct_write_extending_i_size(iocb, from)) { - inode_unlock_shared(inode); - inode_lock(inode); - exclusive_lock = true; - } - } - - res = generic_write_checks(iocb, from); - if (res > 0) { - if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) { - res = fuse_direct_IO(iocb, from); - } else { - res = fuse_direct_io(&io, from, &iocb->ki_pos, - FUSE_DIO_WRITE); - fuse_write_update_attr(inode, iocb->ki_pos, res); - } - } - if (exclusive_lock) - inode_unlock(inode); - else - inode_unlock_shared(inode); - - return res; -} - static ssize_t fuse_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *file = iocb->ki_filp; @@ -1665,10 +1619,10 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (FUSE_IS_DAX(inode)) return fuse_dax_write_iter(iocb, from); - if (!(ff->open_flags & FOPEN_DIRECT_IO)) - return fuse_cache_write_iter(iocb, from); - else - return fuse_direct_write_iter(iocb, from); + if (ff->open_flags & FOPEN_DIRECT_IO) + iocb->ki_flags |= IOCB_DIRECT; + + return fuse_cache_write_iter(iocb, from); } static void fuse_writepage_free(struct fuse_writepage_args *wpa) From patchwork Thu Aug 24 15:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13364331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E3A1C71153 for ; Thu, 24 Aug 2023 15:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241802AbjHXPH1 (ORCPT ); Thu, 24 Aug 2023 11:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242180AbjHXPHW (ORCPT ); Thu, 24 Aug 2023 11:07:22 -0400 Received: from outbound-ip7a.ess.barracuda.com (outbound-ip7a.ess.barracuda.com [209.222.82.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 440F719AE for ; Thu, 24 Aug 2023 08:07:19 -0700 (PDT) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by mx-outbound14-35.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Aug 2023 15:06:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aXGaumhoLlXwbhBL9svK58/brtU4rJ3sBeM4nJvg53DSG15rpTeuKevgReQoWAz9HT8t0W5plgDSNPkEBz4uOQtDzNqiptlnTL7Fgy05ieTIc7sYlfrrRfLiFtcPk7mQ7LU+hKaKyfDgk8IA0WfWc8jhO6eV6FsRAtiVz1sVufVXYawyCswXqipBnY1REiXjvn+vmDC91DPKbulWaKQLKm9Er9XgYYgeD+qDJoFEUS90r2ptPgmB4HwPjsgbFqk1TJqk5VKEKSCIwgoOCTUlXb0+oaqZlWEDOI8qAsc4ylbgYQEvPo13XZIgomD1hU0z7eF9cG3mo+Py/ogGPLv6KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=loPxHHoeDSw1VswjjPQ6bXiarWKNztryADqfMWHphjU=; b=od7vtTIo8jDY/ag5I23kGtcLiHxwcc187/UWTNzydOAUjjsC0QEsIN7Xh+kTbRCxwP9aU1bpqeuG4BMbXAFXrZJ/ZQ4u709eeC9CM4K6l3IDC3Mz+jBJzB+rseSOUha4SAY9c5E5thHBzOyCJx6SgPXro0g22K3XY6OCReKOQVrTf3P6mY5gtQB0vA4T9EITfLa+B7pmi7IeEN3vP2eUdzY/u6fZY3GKcXisEt7btBXmvf3A34HlDx/fxUWg7m3dxoaM/wb6/y5J8npYfrFnth326gILp4YTMYHiaVsVpFGm/kMLk524QTrb7GWTm4lwwbvLx99IoTFvG+N1tp9wdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none 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=loPxHHoeDSw1VswjjPQ6bXiarWKNztryADqfMWHphjU=; b=guEZPcvkgJUTLUpvXF0rDDPvwBq8kWRESqKMGbhuT09hyrpTS8ENOODKbhLbc99m+9kS8DNCOxStCst6aMC4tx39zxKTWdU8DxDn35Z8yWbG2Xn1NcoTcKCTZyGc0HymBoc8KE0qP1/GihNt0GWyahUFjbW55llbxel6Q+oWdTQ= Received: from BY3PR03CA0027.namprd03.prod.outlook.com (2603:10b6:a03:39a::32) by BLAPR19MB4401.namprd19.prod.outlook.com (2603:10b6:208:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 15:06:16 +0000 Received: from MW2NAM04FT065.eop-NAM04.prod.protection.outlook.com (2603:10b6:a03:39a:cafe::d4) by BY3PR03CA0027.outlook.office365.com (2603:10b6:a03:39a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.26 via Frontend Transport; Thu, 24 Aug 2023 15:06:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mx01.datadirectnet.com; pr=C Received: from uww-mx01.datadirectnet.com (50.222.100.11) by MW2NAM04FT065.mail.protection.outlook.com (10.13.30.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Thu, 24 Aug 2023 15:06:15 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 388CC20C684B; Thu, 24 Aug 2023 09:07:21 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 5/5] fuse: Remove page flush/invaliation in fuse_direct_io Date: Thu, 24 Aug 2023 17:05:33 +0200 Message-Id: <20230824150533.2788317-6-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150533.2788317-1-bschubert@ddn.com> References: <20230824150533.2788317-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT065:EE_|BLAPR19MB4401:EE_ X-MS-Office365-Filtering-Correlation-Id: 12b685d0-8829-4d1f-199f-08dba4b3a99f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GkqL0qAqXAInSv/tS82c52nxNj7VEXMB8OM8m+MFVF077O7p53Bv6qsF6EvjSX1e0dYVzgdhkD9szNk4wyQ9wTi4Jp/pcGr1+36tRqcexUt4NpadP8juQIC0ce0KKltoKt2O+OdIJoLOCXeUWuucc3KS5DW2xcmEBncZKQLbnpTI8D1WFIzDATAcCE7L+LoznpvbjSAn4AtHTs0lvajX+OLNhvhjvNzcTYzsUtilmGWzwf/Sf6mIkDflpT9w+8kqe044ne7sKrPTBdw2y2X3nGqd/4YW/VdBL93tEFOAmJ4a2p8x2MyO3Kn7dyc7KpMXb9HOAsPqORFHRnpGcHRDVj48i3xMfkPf/OEfg2zkg7aDj7/dW9hnFtKWUtKJCJuY7dTceLoaMKilvflb/oxHTOYWOwA/SHhx8hWdbHbSsuNyKhOjffbt5k4oSl1RuIHu/NSgsquUY+wrGWvGOCUwik0TFhdCWSmBSmmkO8ogZH//Cci3965LWQhVR1oTNzxrY5TTTDM4XXjoeD/AFiWZr731WV/EgczeaJzMrYmWJLj3LcuzNy8uReioNc3VGTGEWjD8uF1s3xEv50eRTjuomETiGe1a6FdauzYDGDoApt9RgL24CjBxHIQ+gUjdEeCJPOqUffDeF7Q9t/up+eVf2g027ieLEaYCl/OcnI6CTINhLwlRStKWBTq/4mZnnXc2M7ivQSl3yWCfvbfHdns36y7I4ADNmIKEVJnBcE8nUEJoKdqZnQb550HE9JbRvvB2 X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39850400004)(346002)(376002)(396003)(136003)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(1076003)(2616005)(5660300002)(8676002)(8936002)(4326008)(6266002)(336012)(47076005)(36756003)(83380400001)(36860700001)(26005)(82740400003)(356005)(6666004)(81166007)(70206006)(70586007)(54906003)(6916009)(40480700001)(316002)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: K0SQRUhSh2D9yp8B7C8cW11LNVB4z/1XOmeE1OYZWjwDzitbbKK2MheZHF0BJkzSBAG7ILbdycPrQeNTSY5eon6uRDKMxXzhXdnxdeklJVSbyVEgIRGJRK1r4nGddIAaYFdGfUVy6ozPiGiTtA96yO6SKF0bP1aawulctx4/F6kyO+ZwM+UBrsDIlpJsj/kaojpBtfdGVBj8VXmgdmGDZXJVfFOm3JBcRJ1/h2q99VCN7b4tGoVrruYqUPr5XgKAo7gVttwXaXAPAESl1bViCrjnKHeAcs970SgHNC/+ldkuYi58svgfRadeoqZKWD+Mw9z2VPuYt7VViKf/p//oKbsst7M1kN0d8rA385WpQXxmAUtrS73ngWdiOVxpcBzJ3hataUYhguHxT7GFS6SZhHBDqPd3TDglxRZcKfLeob/aR8VMDfydGUMm+HiF6ALX5AJmzkUwjxSYimUlG/YK8nhqFLXlCtt6FzTTyiO9/3jRm4kZjXvDcG4+mj4XgV7QpplhSJnnSY9NFr1DyE+CSpkqJ7fEMagke04lNoxR9+IqCZcuGFibbF5l5FbT2t5p44RoiVuWF7N8LWqFsE8rfsoKeoyUD3YrcfBU2pUCfCW/xhwJnVXsSE+5J7s1kmFtmea0j0QLilj/UJ/jUG4kv2OY5qA3Se+07L0gnlAD0cJyGgzBeLd9E8p6J9WYE0jLFOksQQEMcwnaYRokJ+xBb0+RccEBBDzAQDnwyfrIf06NvSo6Bdiy5lnhU7E0Eup2jLxcJGGi1tdJVEF3oVrhdZXdk56mrrMK4J3G2DdPje6aQcGMaaUEOMSuMN2kEPJRRy1n1ctwUTgtwnVH7Q/+lg3J1UR3Hk6xl56MfkoHcowrWFBRKGWWdjISCUMyD9olS2Q6Qv2HPQ4K6n1TvICExg== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 15:06:15.3997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12b685d0-8829-4d1f-199f-08dba4b3a99f 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-mx01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM04FT065.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR19MB4401 X-BESS-ID: 1692889585-103619-12461-29759-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.59.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamlhZAVgZQMNEgydjU0NLU2C TRKDXV0sDCMM3QxMjY1MjQ3NzUzNBcqTYWACnK1rxBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250361 [from cloudscan14-107.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Page flush and invalidation in fuse_direct_io can when FOPEN_DIRECT_IO is set can be removed, as the code path is now always via generic_file_direct_write, which already does it. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert Acked-by: Miklos Szeredi --- fs/fuse/file.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 09277a54b711..eab105ef4640 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1473,20 +1473,11 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, int err = 0; struct fuse_io_args *ia; unsigned int max_pages; - bool fopen_direct_io = ff->open_flags & FOPEN_DIRECT_IO; - max_pages = iov_iter_npages(iter, fc->max_pages); ia = fuse_io_alloc(io, max_pages); if (!ia) return -ENOMEM; - if (fopen_direct_io && fc->direct_io_relax) { - res = filemap_write_and_wait_range(mapping, pos, pos + count - 1); - if (res) { - fuse_io_free(ia); - return res; - } - } if (!cuse && fuse_range_is_writeback(inode, idx_from, idx_to)) { if (!write) inode_lock(inode); @@ -1495,14 +1486,6 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, inode_unlock(inode); } - if (fopen_direct_io && write) { - res = invalidate_inode_pages2_range(mapping, idx_from, idx_to); - if (res) { - fuse_io_free(ia); - return res; - } - } - io->should_dirty = !write && user_backed_iter(iter); while (count) { ssize_t nres;