From patchwork Mon Sep 18 15:03:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390085 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 D4ED2CD37B0 for ; Mon, 18 Sep 2023 16:43:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjIRQnq (ORCPT ); Mon, 18 Sep 2023 12:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbjIRQn3 (ORCPT ); Mon, 18 Sep 2023 12:43:29 -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 2666849F3 for ; Mon, 18 Sep 2023 09:41:43 -0700 (PDT) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by mx-outbound12-77.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:41:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVjfyTBmtFGfIFqex/9WrqsRUvNa6su+hlabbJbRAZLH/JZLRwdjNiFv7DaS3p/GhTBLBSIAu1syh/IBwwRoE4wevA0SPyz2f0yQf8Hlidfse7ghw8uj7zTvpgpRp7Y0etYzXg3fDz/WyCFuFQO39C2jjzTpCR4un03Z7b+AL0xjaucgZIkfxmnIext8feWoX9Uw6NeimSts4aCcd5UxYlPOfDza4si6XNfIz9ue9zw5mnHFIiNHPvU7IplXD8REAw06OFNAwKPRreFqi4ZriIXN/H25yfTAEfgBtOc0g+4f0DHsxhWDsN6cayJvhg/5GeTYDKeeItgdaB5LISmmkQ== 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=wg2ljla5orAeTdEHr64acKFkNCGFrfBOpyLOyqLafwQ=; b=cIo0w3HBawqag0K+7APoYD7Ab55/bZ9mdZ8mXYSD4C1iyfeCrmJrswSqSx6lyMwM+mtwzIgEYVd8KhMVnlzLMy1CkcofFGnWC7DdO7cSxDa4Ovdl7njBGcCkCs6ScAGdr7X4dZtivRzvP5BiyeKB1AtWZSlZ3bS+SHUls/R4PRoA+5I73do9YDyzgQ9RPSdCNwd+0qiwl4YDAjKOl3kBjNVGXXWWSGsX5AyL4UYDRqYKF/sVeUwgnOkhzbADKIMkMPtUCwk8JCsi3ph6jUnqkGSIZ+Q5t3I+NRHQL43Opbl40pzAJ//f3AHpebr+8pRocfZED+L9EjMp5RJLnQFEBw== 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=wg2ljla5orAeTdEHr64acKFkNCGFrfBOpyLOyqLafwQ=; b=JuRcB/wzLMRNzIA2RCJd9acsd+5wr30DudpkstlBspOHZZ0qbB1xDJU+Mk+lxJvyglJryDaGFOmZhXol5zLBjkpZJbIX5MW+rrEouejoezZFb1zdiftRTayoZs0rfP0zeIDDk08F+EqtplpeWICXZnk1b6O1yo8JKdQrchO1PEQ= Received: from MW4PR03CA0073.namprd03.prod.outlook.com (2603:10b6:303:b6::18) by LV2PR19MB5863.namprd19.prod.outlook.com (2603:10b6:408:173::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.23; Mon, 18 Sep 2023 15:03:19 +0000 Received: from MW2NAM04FT067.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b6:cafe::f3) by MW4PR03CA0073.outlook.office365.com (2603:10b6:303:b6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:17 +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 MW2NAM04FT067.mail.protection.outlook.com (10.13.31.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:17 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 760FA20C684C; Mon, 18 Sep 2023 09:04:22 -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 , Miklos Szeredi Subject: [PATCH v4 01/10] fuse: direct IO can use the write-through code path Date: Mon, 18 Sep 2023 17:03:04 +0200 Message-Id: <20230918150313.3845114-2-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT067:EE_|LV2PR19MB5863:EE_ X-MS-Office365-Filtering-Correlation-Id: f79e517c-58b6-442a-9ba9-08dbb85863c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b+lGyFx3+AS4gUsdf5RAsEKwkPIl5ZZAcaJEnz61Sy6XI07YF7VeBUGAaP+/j6suVrBsSMyoqwuJf31enWiqEf4dOs16zFOxhYN07wRfZee25bZ3QjuzQtn/rleTJGCcvT0ZaDReiJh3exAeAIapcR2JMWuzC6YB1dn5tPH+aMSFRgP5BE1d8g9eqb7mTc6qTUlIMYC6D7tNf/UVCdU9n5CfPzzkQldG73MrK7OEHy8eqeeDlN2726yvaxsMSrSuZNT7Ttxh/cEhhznyEwjgMsa/0hnKpb0DESgdEiKbN7KG26xyApaOM7oX9PSDe+Mmwk2kfL9PQPi9rjH3R4xPEpttep8znyzgLYYrNJzMuvA6pBs1iBKbCQwSMiWfHG5kbCAHn3oULj4JrAZYqUe6EHyuE3FnUkKf9iCgmxhRhQzRKmEJc0TQBPtOTFUNBSa645EFeN7+sdJPLjH2kk2srR9okgIuz8ksgAGf4PS17v/3/xggBjVehPNWSYjxG2vqzBgrsmK9ueU3Zn5Bn0I3rTwLgTRUenU3HtcAYdOt/yjfjZlwp4Qbn6/GmsFFp+VmgIeAUnMWpdQgWYKBeMxNMv/VPeocdDGXOdoTX7p+3fYVzu4V6hs1Tpi/lYbswK88XGAQ/S9Ud3M/Dlz+h7qy6AWt6+HRPHkzzHjFoJbWITLRBhMGbe2eb02IC/iRNew0fWfv77MKSsmRTE7OEwb+WqvyKwcjWfGZ0PNi2F5XONPFxquGAMZU34zm6/XLrwdN 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)(346002)(396003)(39850400004)(136003)(451199024)(186009)(82310400011)(1800799009)(36840700001)(46966006)(40480700001)(5660300002)(86362001)(54906003)(316002)(41300700001)(70206006)(70586007)(6666004)(478600001)(6916009)(8936002)(2616005)(8676002)(356005)(26005)(81166007)(82740400003)(2906002)(36860700001)(6266002)(36756003)(4744005)(336012)(47076005)(1076003)(4326008)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 35eqZrkdh333YA8u+aoub0FhjXCmkqu1sLx9XcjoiHHjf0RpnATut4OqF8vuBWLJZM2fs+8i4faT2KtJ4p98JIO7nQizB9loqXHcuhafvW/qBEF/kFXdYpz6u01LrbRj+TIpJF2+ln2FARS4T5cwBC6/oLXUwpaph6g6++orbXVkrCFS/b9uTkh9q9uBmhmZkrp7ujX35LLpwqTW3WnR47laqsEVgzCCyAt4ZAowwXR5wn3HRLE89kdBxFn2+9SWRiM3JYmfnculokaQ0rM7k+XIPwUEBINAwa2Ras7ZsG8nbOV/T8+ekxywENvV6d57bJE664CkMk00KKj/7cStVPNUOgEcJfU4pSD18IyKUN4hJyzXBV/fUyKn+jF6j3tOU+8OeN2+iDUwJbK+F4JOXMzsoTboFpd7Uvm/WEJGYvdvzxuJdrV/CvFXkgLEzkwZt6R4tsP0w/Cv41ILx9IOMocNh+0jduHwsTtFWtWvnTydSAJ0ekiOo87SURYKrhZCekP5P2XhpCKQYOl2m1Pht9noBZWjDP9DfLABBSJxFMUNSOnRoz2FsyO6ZY72n4xF5pTKGAHhxy/E+ITUwOR8uJelWSe4fnQ5fvcoU0mLEQRQGC9sSQnauqCdYtbKw1ezmT2KnhRbGy9MnjF0R61l04PngO99ujOaUClkY6OkP6w/M983va09BBjPgPNnUint9NpMa187njI417l/73ZR765QzbdDAV7s1loNqjUlaYdUWwpM+xf7s6w+n5Fxhr9uyQkLEoYyVOahWpaUENCzGG1Hq16pRVAI3nIGEcvvszSDAkKu/zdhCGxu3sBeBzmcour65fJyvGkwQ+pNjia53LUWMZvXSAFEMMIdO2l+MVkRgq2Ak7NxmAuETc3lC6txAbgUJEs5RtLq/SMlpLZithWP3CpuZU9ZUYjEbmhpbUo= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:17.2843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f79e517c-58b6-442a-9ba9-08dbb85863c8 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: MW2NAM04FT067.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR19MB5863 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055301-103149-24549-2297-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.66.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmBkBGBlAsKc0y1dw4JTnZwN TANNkiOdnUKNnIwszI1Dw5zSzR0FCpNhYA6dbNskAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan15-142.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 Mon Sep 18 15:03:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390083 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 99CD3CD13D2 for ; Mon, 18 Sep 2023 16:42:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230489AbjIRQm6 (ORCPT ); Mon, 18 Sep 2023 12:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjIRQmr (ORCPT ); Mon, 18 Sep 2023 12:42:47 -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 DE82C3590 for ; Mon, 18 Sep 2023 09:40:42 -0700 (PDT) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx-outbound42-104.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:40:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EQ4h/15mqtvm8CD1W1I+1nXRFzKOq6OLkAGl1QrFkzhhzwYlGGgEZxGdB5wJRwIFUFz1569OfEeql5fXz/fTMxcF8Wx/tls+6+U6bzvmxtHKNzMsIsvl+CqBLp2hZ2htFSu2WMgkkBEGuTfAZcUndsFskmprixm0QRWLomKCOzQq+bElwtq5LVr/e9MhFO8Requ3kcYzAqXexKzviLVmOIHFwLC0DV/r8rZhbbx1EHJzNvQxJJix605ue4iWf4xCSsusg3X/FMBu+K0IGljnmAlc9HtL56HSXvonRARIuDTTfveFi6fWpOXIrnhKE66MqWahVHr/WKNqCwwXIANmCg== 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=6KlFA2/6mVNJqCpuPCFywORxSQ7YOxHpVOILpYvjhlQ=; b=a4yNDPrjtzhSFDDsyBYifOTA0aC+PTrFQ8HY6cX08hy7Da+Z72KqTFZqX0YVb7zmuCmUIJ0EM5fyyrniizGpBI1HFXiLpXR+P9N3zloITTVUYu68jE5eCLtcn5UylobU1fIAVyLzVDPYaKq/SuzVrSaBxVj9p97mFHGzoaXSwO6jtTOPo0/UeYuYt4BplHu6lwD8+cHUaKEjD2lyWTCliYoXASbc+0iKKK/uuUIO1zbVcMwsk+RiXcFG4rGD4zJNrpeIvlTGec8LbskFfCAHGMCJDd8u+NqvqVMoIZB2cAD4qmNr7pM8CUNZrFcin6BvksyDKabuhQd919nLsNK60g== 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=6KlFA2/6mVNJqCpuPCFywORxSQ7YOxHpVOILpYvjhlQ=; b=dQdh3IvVkvwJxYM3+X978YgnPqq/77w2SCywbgKzR2Pa98OQpViOo+VCaWJALJfxDdO6qnm0iVNaAHVUL1+hEDmYOA/wjsHlsZ3ITCRk23gEWpH64/89DQt18DRJModrRE25KEnP4OCcTIHVdZA/BBIZ6LwZ+t0CvVs7Wwe0pLU= Received: from BN9PR03CA0420.namprd03.prod.outlook.com (2603:10b6:408:111::35) by PH8PR19MB6925.namprd19.prod.outlook.com (2603:10b6:510:22f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.22; Mon, 18 Sep 2023 15:03:18 +0000 Received: from BN8NAM04FT008.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:111:cafe::e) by BN9PR03CA0420.outlook.office365.com (2603:10b6:408:111::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 15:03:18 +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 BN8NAM04FT008.mail.protection.outlook.com (10.13.161.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:18 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 7105720C684E; Mon, 18 Sep 2023 09:04:23 -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 v4 02/10] fuse: Create helper function if DIO write needs exclusive lock Date: Mon, 18 Sep 2023 17:03:05 +0200 Message-Id: <20230918150313.3845114-3-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT008:EE_|PH8PR19MB6925:EE_ X-MS-Office365-Filtering-Correlation-Id: 1349b460-62a5-4603-95eb-08dbb858647f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aycFWN3nxTKlEVpgXB/yrqlTdmUfJ6qGF16FZ2CXStwsVO+YriMS1ZSeQthB+AhoVVdqw90hhSFriXLyzOzGLItPoJEneeAtKAdWueMWYxVY/YmJ62MVs8mBK7XrIP1TZGcpKa32in+5SDp95AXMe53MMdFEJIu0MPkLayf7EGpU9BOa0FNu7gRn2x7FTJNl+cPfmW08ToFEg7MnBMrjZj1WuDtFkjdIDsRUmMeYCqct/r02OrECWMT7V+VEAy8tnlBPvVRb2SIGYkWFsUTp9xzp6YMn//E9pjFru/jLmSoCz8vboZq2fr07Ks/J+YlqFEyDjKTF8IPmXWyQgJ1EShXdIAX1CtBiSx3jMehAoHo65SiJx72EpX1di6sY44p4TFrzBn68X3KOrD5lZHnaGsNGnkUzSnxaXc8SI5Hi7IQ19Kz/WOMcVeJRi8xKpnfCMhNqEkiZS6g5f32AgE5bdtJZ6OOmjO3NMepSovOrGcPgFXLyGSfnMX6hzjX0L1jlmTtxzblETHOyrwTzrizHOc2wTlsMvOYr+w6FKmGo3N6l0qil3quiJjvcoGVdOgYTOzIaQE25TJdCE3tGNVYL9gR9zOyfJ3OR/1VLfCLsOcuDSKCTg5ntP1xEebNk+t0vZsAtyMjgsl1PTyJQ3Eyh3xNEGGV3lopqPxUJa0V/mGIGnvsFyAaSQT9FTK6yRmHy2YhTnKOCNEh2dgNkqLwHwOjSy1e+ztHy9Ietcsn9Tojqz4v3PyunDm7RP/3FG6zw 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)(136003)(376002)(396003)(346002)(39850400004)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(83380400001)(5660300002)(4326008)(6666004)(82740400003)(356005)(40480700001)(36756003)(86362001)(81166007)(36860700001)(2616005)(26005)(1076003)(2906002)(6266002)(336012)(478600001)(41300700001)(47076005)(8676002)(6916009)(8936002)(70206006)(70586007)(316002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9mTq+SxNPdxeDElJOw03b/KY3E3NSaEjYSSyj8+f8TDGkzyL3D0qnu8Sr3IUGJuepzLcBRG+lgikbtIx4DRw8FV+Ue1RWH0t2K+6U2ZGU0R4WovCzREBT0fybnUJE2W1iHlcUVI3PS1NetAn/T9n6x6uBXFodMbHI8wHUy1f4ZKLZ82RkZJNDJoOuRQ7dep/nf9FSLzBBR8CLn80jdTHf/X/ivzTZkTs1QaRwLXb7gfYi/dLOQ/Db5XL+sDleZYi6ylUkDWC/sgrKTalNNGMFln2dSnTRNubxrmCwf1qGviyiR4es2UD3pMyUuFt6gODs92pDzW6NDTsIAfEkgSH7UEAObo7ai0Z//gQu5NWU0101DPinKSF5XOP/oQpmfZQdoZkXV9y3Lc84c8q8UWmAVfrsJzJPg6e04rOHY2xGoF3rpx35aXtJp0rtehuLyAffdDbHQPrIJg2DRoRDb2Z7SYPnVRG4WZczvjTD3jfCLQpwcHFt699BTh8FH5D+iByMf5xmkWBzVL58CqhXfX3ek072+xeOt4qzjSYBdMRWU6QfcHsvXVF4m6lFsq9sZGhTZ+3OdFo9ZXrVKgg5XN9AksOMwLjR8mtVVMBOdOARRnewZJurQhfFo3I0YDjRVGeV9YkV7el13QxkitJCNJXFBBP3sB+ZiiIgW3gdQhlRq1PXSiYjmdTa9q7p8q41nD5MrmNzmbtYjtixzvgXZCmlYcirhzKD4FEiOw4lhxYGYnbjWnY6MNtrK5mZINqHaSklshw53DBc1gXajMpoSwRsmu2d0g1cqqLFugE75tBiLuQX7GT4oyUPkfx8+8470/2SVGxrpQvbGmZTq3dkpWcnkS5wzsW5W4KmJ723MWNKFN+pC07kJrWDBdzBjI5qnfsWsdltf1h3qIgo2BT4KjN/w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:18.4366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1349b460-62a5-4603-95eb-08dbb858647f 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: BN8NAM04FT008.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB6925 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055240-110856-31778-765-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.66.47 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkaWJkZAVgZQMC0tMSXRNMncLM nAwtzUMMUgydDEMCnN0DwtxdTMLClJqTYWAMHOp/FBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan18-58.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 | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b1b9f2b9a37d..7606cf376ec3 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1298,6 +1298,38 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) return res; } +static bool fuse_io_past_eof(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 for 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; + + /* server side has to advise that it supports parallel dio writes */ + if (!(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES)) + return true; + + /* append will need to know the eventual eof - always needs an + * exclusive lock + */ + if (iocb->ki_flags & IOCB_APPEND) + return true; + + /* parallel dio beyond eof is at least for now not supported */ + if (fuse_io_past_eof(iocb, from)) + return true; + + return false; +} + static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -1557,25 +1589,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 @@ -1591,7 +1610,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) /* 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)) { + if (fuse_io_past_eof(iocb, from)) { inode_unlock_shared(inode); inode_lock(inode); exclusive_lock = true; From patchwork Mon Sep 18 15:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390082 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 7CBD9C46CA1 for ; Mon, 18 Sep 2023 16:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjIRQmE (ORCPT ); Mon, 18 Sep 2023 12:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjIRQly (ORCPT ); Mon, 18 Sep 2023 12:41:54 -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 7EF685B8D for ; Mon, 18 Sep 2023 09:40:15 -0700 (PDT) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by mx-outbound11-163.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:40:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJ48ypbTgXk5yIR8HsMAVCbgShW19N0ngJg1NrsLWHLsKW9UwNIjahvVApRKCMNTUbY2J2M81ZFzmUG74JWOEbp2veDFt8/HPaLswYrAwBW+Oy0wgzmTww2B/eVpJDc9zsgLhsEB8ccacE7Xg1IMXfBRGZNIwopplbq9vH/QZKIMWso+LQ+KTBVQTqzG5e6c+f4OnR2nZ+WUK1KBqwtjTfOqLH3F94M7rYdnapSb2D9iIGR1ZL35zL0tsz5wAmFLdcTZOS+Ooz5ZwSP+M3QMzMnwZVogeGFREJa7GsDsd0nZizbzobb5BcuX3BwieAp5NeXq1tCVlxVZeLosN/r6ww== 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=vEKxj1woarFZs4hVj0u89yjWwOVMVli+PwRDZv79UGI=; b=IPcFEYTIr/h6b1WMNBHu3lmdm3jjPhZoKWTVqeOdaqohDOJsftPUmlM53TP4BLGxArCJGLwUjvbl24+zOf6fsEXe6Vtl/xkSxSkqOUWeQvu2o6DtfDB55uAdWSPD9KaiJIq/oS21dJu6oZtQzOe/9CZZt3lsokXg0YWDlcayX9z+4bg+OcaYXsumXQkZh5xxe4BaBuwYljz0ZGxHk3dv69DBX5/QuDwZMdXiwZ9JS5zIUXlQ3gXV6VwkX/gKOya+KmsQQWgRZRPRAXvDQENaPzBMCa7OQfRrGxH47WCgYqpu3865OyVyZvD6CqOAoKu4BiZ4ie1OclC77V5sMXFBmw== 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=vEKxj1woarFZs4hVj0u89yjWwOVMVli+PwRDZv79UGI=; b=qFyYX2YOPLiM0+vp89ZcloxOyL5gIUuP93t6vkic1qZ+mue5knIGWA46mB3MCLMsMZPHNH2/WXNPmh6gLs0OffK7jr56Ei5e4iOCMwzcE53159Y813fUr1ynXoKIU6gvP9g1Pf1qZAe1lAxp6ILT3FpKWe9qwGYO0csZR0CT5tw= Received: from SJ0PR13CA0240.namprd13.prod.outlook.com (2603:10b6:a03:2c1::35) by SN7PR19MB6758.namprd19.prod.outlook.com (2603:10b6:806:265::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 15:03:19 +0000 Received: from MW2NAM04FT012.eop-NAM04.prod.protection.outlook.com (2603:10b6:a03:2c1:cafe::67) by SJ0PR13CA0240.outlook.office365.com (2603:10b6:a03:2c1::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:19 +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 MW2NAM04FT012.mail.protection.outlook.com (10.13.31.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 15:03:19 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 6A6EA20C6850; Mon, 18 Sep 2023 09:04:24 -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 v4 03/10] fuse: prepare support for shared lock for DIO writes Date: Mon, 18 Sep 2023 17:03:06 +0200 Message-Id: <20230918150313.3845114-4-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT012:EE_|SN7PR19MB6758:EE_ X-MS-Office365-Filtering-Correlation-Id: 68c350d4-26a1-4aa4-b91d-08dbb85864e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OmO6zeyjSvBrMIpHwe76cnhBAGf5qccRSI4a6ny71EeNt/r77xeOym0xrKZ8kvm1ISQFFUU47nxhn1IDksxWG+/YmbngNlHTLjtqkAPuiPFJIqMjlARj+MWULDogj8+g2tOniZS0EsP8oHS5qFuMU5NE5RG2GCQ7+EPyiIbDbANbmLZsEPGjSTm70LMF1p+Bc+XpXxSbFFk1ju08hd+epG80xs6uhtTuOGgXTWrIh5+8qgJhnXNxm+IHK3TTUKOrdDiad/LDBmVbPX6Mw/qEdjdQmv/rtvL9m9ExQRGm+C2KZy0ibsOZgu7JV5Pakvk0qY34XqC6KFLP4CFy8ymesQc3H+gKqH4EacxhX443ipDDCl9XhTwLGJrEpbSsP+MA6T+5xaExu9iwiOyTzh5YoEI1OY3JvWk7xPZgvYsvIiPsx+y5l/NEKS0SCUT+EF5/z9LoMV296bt/qMNzOnOOTKr4pzH6S42fqAUhQijJ3Gl550hkLZrkUcrhjN08eYIm7eYMk+3BjLKRxu56rlQ64YrPyIdrnQl2twF+gTI8MW2yEms6XhYrM+uMGck1/WgsTdpO6sLkUqqFVyb82GNEct0LOHE11vUVyou/3gDDE3c6cQNCojJvWhwg2qivY6nG37pEqlVWOu9s9sMFC3O4V3db6OqtFu9NbO5tZpHp0FDZvVRE+dmnnZcakGN8uJIeqO/pGLEQvKC8crKvY8T8lgoA1iekDXZhkb7t72ae7mSI6WAZWsT1B7AtHAf+wSF9 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)(346002)(39850400004)(396003)(376002)(136003)(82310400011)(1800799009)(451199024)(186009)(46966006)(36840700001)(356005)(81166007)(82740400003)(36756003)(40480700001)(86362001)(478600001)(70586007)(70206006)(54906003)(6916009)(2906002)(6666004)(8676002)(8936002)(4326008)(5660300002)(41300700001)(316002)(47076005)(36860700001)(336012)(6266002)(2616005)(83380400001)(1076003)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2RCuP3HSRHhbkB8JX07A8aCRDyL6/KG1UJcLCErtiEPRMAY1nxn/nryRqXyzNLW4dFmRvfWthF1psanbkhlpFbSb8DBTsHORrWT1Daiv6HUob1LmptCOc9eW47dvKIjG1pXmYanMxQYxNUVYDB3qKKgtCOvNOv8l1fU8KTYmqK6onoZY/ZLRyZFxb5v792mgEPzBTvNwHKv4wb3mVqsPtL47hEvk6ApIWFncHssOpnPlow7izgp6+Ti39ZDkyG/gpfosdBr4kRvgbwkImpc3aRGPRzyf/pxLy8xNn5kxREM7LsX9eH5bBA4MGVmLnC8gXiX6RaGGMxvTYYlsX2ll9TIdi++rwQwuTpVUONPsAWRNmaWUdGcCeg+3bo6SNQiNNGW+Y8sBCBwvBX1/Jpxt4WsWQ12eI9tA1dU2gvwp+Vlzhaq+Tb3U55jo67qrO38SQnheaDt/gdSUfLtzzDC78j/Ht/udjXLF6eqX1RdErjKU8vZC9xDfHIJsIOimLl0peO7KmRS+VXWvc3xgkMM0Pz5DDydeFNkIeehSAxnCdCBhghI7tP2P2Smh5H3zYboK8b17vc+srKRt38w/gV+o5Ek94QWVJWEla1jJhKwSYReXaEfRv7dkJ8+BhMQ48pW39HIUzXUzDI+AO/oBfGN//ZxU/ivcwYF+BEoVL0zFCahE62oD506beoqmVaHwa9JRxnpyTx0jISkzDHfcTb5jXkBad+D81q37hjm9yJKm6xTu3HeWR4SUcM6HQRpW5pCSx+RKz/4AA83r1pRPXtSFNz/Zm7oY0gUhNXxMapC8cNreqt9Bab3iUu64soyjrF17pIlE2wqUXkrHTinfFDzIZYYG3Ewgq7IDk3P7YhjbQwMDZC/ctxuppLABA/KOALtUWaI4tBc/fleBYGqoZW37rA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:19.1816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68c350d4-26a1-4aa4-b91d-08dbb85864e7 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: MW2NAM04FT012.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR19MB6758 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055214-102979-23088-2255-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.74.44 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsaGhuZAVgZQ0Ng81dLEIM3CLM Uy2SzZwiLV1CTFJNHcyCjVzNgoMdVQqTYWALbZZWRBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan10-134.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 Take a shared lock in fuse_cache_write_iter. This was already done for FOPEN_DIRECT_IO in commit 153524053bbb ("fuse: allow non-extending parallel direct writes on the same file") but so far missing for plain O_DIRECT. Server side needs to set FOPEN_PARALLEL_DIRECT_WRITES in order to signal that it supports parallel dio writes. From style point of view another goto target is introduced, although the existing writethrough target would be sufficient. This is just done to make the code easier to read. In this commit the exclusive lock still enforced by an '|| 1'. For readability this will be solved in a follow up commit. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 7606cf376ec3..76922a6a0962 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1313,6 +1313,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; + /* the shared lock is about direct IO only */ + if (!(iocb->ki_flags & IOCB_DIRECT)) + return true; + /* server side has to advise that it supports parallel dio writes */ if (!(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES)) return true; @@ -1338,6 +1342,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) || 1; if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1356,7 +1361,20 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) } writethrough: - inode_lock(inode); +relock: + if (excl_lock) + inode_lock(inode); + else { + inode_lock_shared(inode); + if (fuse_io_past_eof(iocb, from)) { + /* file extending writes will trigger i_size_write, + * exclusive lock is needed + */ + inode_unlock_shared(inode); + excl_lock = true; + goto relock; + } + } err = generic_write_checks(iocb, from); if (err <= 0) @@ -1374,13 +1392,24 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) written = generic_file_direct_write(iocb, from); if (written < 0 || !iov_iter_count(from)) goto out; + + if (!excl_lock) { + /* fallback to page IO needs the exclusive lock */ + inode_unlock_shared(inode); + excl_lock = true; + goto relock; + } + written = direct_write_fallback(iocb, from, written, fuse_perform_write(iocb, from)); } else { 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 Mon Sep 18 15:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390118 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 6151DCD37B0 for ; Mon, 18 Sep 2023 16:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbjIRQ4J (ORCPT ); Mon, 18 Sep 2023 12:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbjIRQz6 (ORCPT ); Mon, 18 Sep 2023 12:55:58 -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 AD105CCD; Mon, 18 Sep 2023 09:44:00 -0700 (PDT) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx-outbound44-224.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:43:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0UHv2atXxualH+iz/FIIwLJ4TlmFTj9oxuLMhGIjUNj0xYRJt+rCdRmdDH2VHo/OMavZA0VEn4n3EaNtW1FnNrvw8P/fLPFQknJkBGZ0fE+LFflPqOCgw1qUfvLMmlsy5wPzdC99P7uY+v9ZIDdBLpmzmtUvxx4CdOshtdbGaNYozzllKdsF5+Wr/fBqctustoMw7tgvcJeMDid/UrWl58Bi8oy4pIs2BFtde5RMgWPjk97EFRNf49C/gFLA2AUJN3P9RqIGLQqqIvJBnGmKj48GNJDcpw9Sen7zvP6ZBE1RIes3sjNhhp2j333L/UGqdxaNEuPxUFl3vcGDHz+ww== 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=YnexB5ObDrCBd2UjCzBCuAxh3eUROHhCyafkaz30oJE=; b=XtDb4NfgweM7qGaVzNEph2Uljm3xs+uZ410HRXR/Y+PD7LOAJBg1pvoMsdN8lNyxkGUvQL9wwKQst7lpvXemFWnW7F2lUpOZHHtiU4Hm2iiwcbf7jIFXa++AOxll6UbSA1nU5pN5YRw39mi623R95Gor8uCyrRkmRp13qhdm14osD4So+yY00bR7swrJHcWpqZgHGIteeJX6qUmtA2C/YqUiaz4XGVvBOnwhX3LcyV90RqA1wAVTyfVWA6llzJXRFK9o0U6WCaKd0PAaw6la+4Ny7SWf5RMWtMGJYLD8GI+4bz9dYahWH+Jj0qdvsVpJQbwWy9LWNWjNeJWJW7b+WA== 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=YnexB5ObDrCBd2UjCzBCuAxh3eUROHhCyafkaz30oJE=; b=nwYNNgYpPdS9j6SnrlEp4eGsaEsFaWVvlUhkPtHCx0iESeHpoCuRhE9XthMgOcFFg1z5ByXkuUtW3z6THwRQsf4xushfOPKtqBchaYhIsC/KBTxjCLfjQ42Yq5zBEksrOKvuH2fB2fbBZw1S7oytp9TPQZIkMIefJAdNiAZfJ5c= Received: from MW4PR03CA0111.namprd03.prod.outlook.com (2603:10b6:303:b7::26) by DM4PR19MB5835.namprd19.prod.outlook.com (2603:10b6:8:66::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 15:03:20 +0000 Received: from MW2NAM04FT056.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b7:cafe::32) by MW4PR03CA0111.outlook.office365.com (2603:10b6:303:b7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 15:03:20 +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 MW2NAM04FT056.mail.protection.outlook.com (10.13.30.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:20 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 6500720C684B; Mon, 18 Sep 2023 09:04:25 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , linux-btrfs@vger.kernel.org, Alexander Viro , Christian Brauner , Christoph Hellwig Subject: [PATCH v4 04/10] fs: Add and export file_needs_remove_privs Date: Mon, 18 Sep 2023 17:03:07 +0200 Message-Id: <20230918150313.3845114-5-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT056:EE_|DM4PR19MB5835:EE_ X-MS-Office365-Filtering-Correlation-Id: ecdddd77-28e5-4bfd-4721-08dbb8586586 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f3drmnCselvCjcCLjr3v3prn+mGKWfhb2Ek/trhk1mUtvs5dru6dkBGUffNcSnJ+RcpqrWYjb1ynX293FoGal2GI/+ovA/K2wLkt3Dm9aXrQXzhCmmjRK4hNhOowPdgzjS1lv6vKhYKTz10YKNKlNp2top0vpWjH4AmdrFiC8QtzyqQVXx4hAYWDocL0/XYN90ub/PtXPQVyWfD55icZsEEk905DNCfZZaoIMLFTKz9dpkzt4qQPG82GoMKRAaZ5GkocjlO0mTFeCUWGi1kkPNSml2C/ZyDiSjNL1wqxMYa6N2odctPBPI+jMXPusrJfwAFxO3OP2/LxCypy77eqGgSXR/ZfJokcbt/puO+G8fI/9tEi9uEanr7qytNh/gkY344PHHqNJwlYz4IHW/qxc0u3EPS1uq68sZ4rnf+PdlRRUMajwIxm8zcF2fA+sP3l2+3raQAMvBFpbX0X26uOJAkkx3HLt1GGYNgkdCYC+pN3rIMoP3z75Z1fpFQOKrzc1zAf6tb3hZyap8/lLXPkf3SLn4vcWrDzdDhY4h0CxIsP1/ZRRR3OdLa3rDaGBSEaK4+SL/MGzohrmjuw5avh+NNzEZqedKpJ2mZK/m3RDxvsBCXjLz5q8eHQzAs8QILMpgjuMVHeemwncsn9e5i2ol93ObggoBCADzfcWrjeepmETVFT93aZsNKP6/tCSmv0Pn5kHspOx5SHGkatVh2jlbFKwUyxGlTngejpBo2e65YBIhaPDWjjtXksB1a6e/Le 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)(136003)(376002)(346002)(1800799009)(186009)(82310400011)(451199024)(46966006)(36840700001)(356005)(81166007)(26005)(82740400003)(2616005)(8936002)(1076003)(4326008)(8676002)(83380400001)(36860700001)(2906002)(36756003)(47076005)(336012)(6266002)(40480700001)(5660300002)(86362001)(478600001)(6666004)(6916009)(316002)(54906003)(70586007)(70206006)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /Tu8TLSI8J40LXYcEGKvs79yCr+O5SBiR29url4OMb1/7s1e6dWVbSSNiqbln2FMyApJHdOkPlMwYYoCTyGEhyvU1QUF5zktRLwsQz5Wgu8rcXtCEDdc21V74NeD1D8xiX03mUorvF8prE8Px1gQXkvDJ1ZrCnP7MKO1/dYOiT+BAANpQ1f2lEZF2P4XfzlQv+ev8wQWsjjfkBAW21YDQKw1e7bkgVyNBWX4us3YTu9FI7B0xxfXSRbNumByyMiXiD/IKhHHCpx+iK1KY6XZB2hD1a/xM4Eg4M6CnSzQeRCY1F62t3aMExfJErtaxdw4+bOPvKJw+JTkRoEDt0l+hUQRxGft3dQvhxPXccGqzQhIcPRRIQP49VY1avE0ue7B91c6Cz3OOYiAu1riw49v3lKoEHo9A9rEuZOb0Ga4r+heujjUQlew+wJvmtMKOHP/nDhOuaMn+zn9U2XFFjufTmeh7EKgKpvltKeJmJnNQlaVNAKRxC4zgdXSPtnobvm8mCVVCKmE3D4rLAhkvBLNL7Mz/X8MuYYNJ9EKOfQYWe89T3Hu1ij09jRZzKx608j8ATlF2p7s9hNiPw++61fiQEson8v+0RXEFOWscuaO0A299HbpFb5C1wTjRAKaOfm0CC6g/u0554BfBTzKlCyQZdRpqaADG2goadaz1H6sCMl8Ctr/ZOhqL1iTRknCnOtLXZZ/65cX7RUAtBPanic6pddx/hl8aU35qNnDRNtrWHNFosAhGWSrTEqchgMMdnvxZeSBNNQdtl/XTc72Zmhz9azHTuJtnvNCEOFhrW4+ogNZHfqHAp9gzZCgf8xi9TO9Y1PZac9d/8FO5zxLqLH4miTYMRIWruZlbE08ouDnCAf/KbPznGi8iqI0hFagGZH/ps7TA/rB73LUsAD3L8KixdPXhesyfyM1Wx4X2bcK5sMzp5SNelhzfMI44G3w+DK7p2efPo1ZzgPbX3rXyf7m0PN6xQd7vHs4hDBM5HEJmag= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:20.2207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecdddd77-28e5-4bfd-4721-08dbb8586586 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: MW2NAM04FT056.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB5835 X-BESS-ID: 1695055438-111488-12353-4715-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.59.173 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVobm5iZAVgZQ0MI02SwlKTHZzN wk1cDcIiUxxcA0zSwtNdnUONUkzdxMqTYWAGRHAMNBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan17-98.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 cannot rely on S_NOSEC as local block device file systems. In order to still being able to parallel direct IO writes, it is going to use the new and exported function file_needs_remove_privs() in an upcoming commit. Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-btrfs@vger.kernel.org Cc: Alexander Viro Cc: Christian Brauner Cc: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/inode.c | 8 ++++++++ include/linux/fs.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 67611a360031..9b05db602e41 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2013,6 +2013,14 @@ int dentry_needs_remove_privs(struct mnt_idmap *idmap, return mask; } +int file_needs_remove_privs(struct file *file) +{ + struct dentry *dentry = file_dentry(file); + + return dentry_needs_remove_privs(file_mnt_idmap(file), dentry); +} +EXPORT_SYMBOL_GPL(file_needs_remove_privs); + static int __remove_privs(struct mnt_idmap *idmap, struct dentry *dentry, int kill) { diff --git a/include/linux/fs.h b/include/linux/fs.h index 562f2623c9c9..f7b45722bb6f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2721,6 +2721,7 @@ extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int setattr_should_drop_suidgid(struct mnt_idmap *, struct inode *); +int file_needs_remove_privs(struct file *file); extern int file_remove_privs(struct file *); int setattr_should_drop_sgid(struct mnt_idmap *idmap, const struct inode *inode); From patchwork Mon Sep 18 15:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390081 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 26255C46CA1 for ; Mon, 18 Sep 2023 16:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjIRQlD (ORCPT ); Mon, 18 Sep 2023 12:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjIRQkr (ORCPT ); Mon, 18 Sep 2023 12:40:47 -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 981FDE69 for ; Mon, 18 Sep 2023 09:36:57 -0700 (PDT) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by mx-outbound9-230.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:36:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PvMeNJ68vTNNF0U8P/AvStPZzPrB+Yqw7saTIHlBjbKh/8JoPECAFWJ+W7TGZhLUCBQW8Czbg5Dge1p0ldn/P3I0nChKiVkcJuZmdNF/tK9sEBPvtc5OLe4G9aTQ/sNh3P65v6kVeJnW42UhH5sOtowBizuk3B67EBi2jOG02nF2Neu94i9GL/QeuydZAytkhf2mRoyADk0YfFaYK6yikAJ714mwliPb+PFPosARvFGwe6c3slKmBWyws+9td0U8me0PkNdVHXamxv0rKixALnuNlos1iBgIjj1gusmeZSR6rmw54Y8IRxQl6Wb1YHa+PQYxj+PENKXTX+B5SEH+FQ== 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=P2obs+iuM3XFh3K6/EWoiEgSzIAz2WXPWrrDT/U7eVc=; b=NEwaH600clbIBzBdtYnjAVXGAY8B0JX+2Psu1xjzgB8t59cvLnQhQZKbYJRMLD1MNX784llO96g0urG38AuMhEENRpm/ti0IZQA1Hu83YyGRrN+w4tV05OZ8JPGdk9Wo037GiJ3fL/qBwfVW2SPrCeyF7CAH6OCWwv+/r/iRsPoxIdQuv+LYzvctVpe1wAhZZUkBK8krQLIm8nSS5KG8kL5FtLXcN3EoFOKcqPXqN2OkpSovHqjMuGU8r6Vo+hdcBsIey674tGAkDS69qAhcyAI1nST5+2FOy1V851zwWF1CTZo1VvXd/3qTVd1vAmpfdPrDtTBsssJapK7X8buVlA== 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=P2obs+iuM3XFh3K6/EWoiEgSzIAz2WXPWrrDT/U7eVc=; b=FJNogLQjjjiC0N/pUsdqnqcfBjqWry9t6ruXlkbkNBkjxV6Oz0BBYlFDNjtAl+ODGgFU9vYUSvnhj/7hV9+GSb2coYMCxexqmgAlt0riL8zxbKz4GjXoyd836c3Dt0ps8czF6ATZrKLFgXHI3Diwu1TjVIdDDfed81gyetjv7vo= Received: from DS7PR03CA0156.namprd03.prod.outlook.com (2603:10b6:5:3b2::11) by SA1PR19MB4845.namprd19.prod.outlook.com (2603:10b6:806:187::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 15:03:21 +0000 Received: from DM6NAM04FT014.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::17) by DS7PR03CA0156.outlook.office365.com (2603:10b6:5:3b2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:21 +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 DM6NAM04FT014.mail.protection.outlook.com (10.13.159.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:21 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 6010320C684D; Mon, 18 Sep 2023 09:04:26 -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 , Christoph Hellwig Subject: [PATCH v4 05/10] fuse: enable shared lock for O_DIRECT / handle privilege drop Date: Mon, 18 Sep 2023 17:03:08 +0200 Message-Id: <20230918150313.3845114-6-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT014:EE_|SA1PR19MB4845:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e45832d-2f1e-42fe-d11e-08dbb8586605 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wbiOx9zB/23s7GChEknpe/KkaWAT3QNlnsBwn5zfCOEKCNQzqMm00kgOipGg7uA4C6Z/lPwQc5CcF76aUmn7u1lzQGePIBMw+AnodlCxGVwnW2U2GZYlxih03G+RZGxCNQUjk08+KEPbJcZwDVpBikcZ0n40farQWqyi9K8pTNM+kank3EPXqC6J5s6+AmzWWQKNytyjvFr7qVQd4nUDbgwxjMldpADSpy8MqQaDm7BZvhHVe/Nm3FOoSjbg2Qd6naVfkyvD6FO6zPvURB+JdAe9yL4HYFQiqXzm4FZ1mznUOGjxQNRtY9ZjpCi5ld9zbTHx1nQUA9XaxkVPq+shdy+0XnejCjzt2uzfJVbUTLKMMTS9SW20/C8z/im/tAazF+SOYi/ThRldgXmgRmhTdE/4jkSC+yQA3SR+D6nQbicqC+Kf33yMQE6DeHRV85VcUOvCiyo6nkXbj3JcmPo50HoihgDlAx7cYMiutRsS57r9UARJb0FnIl0dig0L/53v1eUgd80zjZR1M2kHMsBBRlkfrDDezs1Q6iBrzyXda941AItJXRlpknAg+B6arBB1KQ3ufieMSQarOLJDl39Vq2U6BEMhs0x1ONB83+XBaGRzlEQam2dQyaxlumSIH6V8K+A2usHGbTOpEEIztQOgMo2m/oOHVBXq/yc2w0vTX5cWWoeYopdm7ROdSG2gl/hpbnW46knBY2qRt/nn4I9TutTvNBGjypsDnAd5mpvVIXzsDvS04vRcIL/HGGOIRTLm 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)(376002)(346002)(396003)(136003)(1800799009)(186009)(451199024)(82310400011)(36840700001)(46966006)(336012)(6266002)(36756003)(83380400001)(356005)(81166007)(40480700001)(47076005)(2906002)(82740400003)(36860700001)(41300700001)(2616005)(54906003)(70206006)(70586007)(6916009)(316002)(86362001)(26005)(478600001)(6666004)(5660300002)(8676002)(4326008)(8936002)(1076003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7RpesSNj/oJpXl8a6mSvIl4Gtwr9bYA+wkvXOJWVqVYeJQ+4uifuYhtS85sW64GVvpmIlvM20o7cp/+2/BKyZt3rnW4ANbQ4f7l5gBHR7Khn6co2T+E8gsOVOF6cExlELWjFquwAZgJjISDIZ1lzUlP3KtFKMfS+Qjlekn1musRY7Y8b5vheQOQ/i+EcBjRVTRdqa9ZPvG+3MKi6gEwXIwg5phfyKsjBGcvO/i/dXZ1kcoYsY3XGVft+OKhCPyOi2rYGfdzHSzarlA7J633L8jHPB3+i06u0YGbr0JSjtOo9E3t4s1JXtNG+Jqsy/LgZJGJQvSSv2k38KcqWrZj1iS6s8kmIl2EbfFNLJj5rhUgYoGSQc4MSu039uwT2txH4rUYLWpzMWuodLRmfKikay+6FplnPDLyLCafp892JIBVl+wAALz3RQ5DuSyNEcOjcp7khx867x4MtS/LUTJ32UXvWS+ezOzZ3R14jOOZXVRoGeQholRB4bcyLyfwN+oStJGXEg41tlGuB5E6NhOO51yiUBzKzaBxMVf8LEibsxusHawlsUvyzrl8wYs4QGcDoHWDVwATIybDGXzRTeBI5dbbj6CbmRoWLTemeEsf8+hhNe7rCKJwfh8Ze1gX/C+yo4U9tUPxi//p03fVZs3mezi6WH0/AAyXOihHiNvnzUMwO6WUZzi1xcwoQmCZLl6mKvQZWNAFbUXfXYg9/LhKo3dVVFVW9pLjlMOSpMWhKC0CxoPoGdxLY/ZQ4vw7PeIcnm5XE/Z/FQqA2TF1RkMu87zEZslWyjnq61eoBHUOmfVGT6fmJr0W8VVmnOeSWP0JmWrD7suk5NUS68OaxoYSUI5tXCNkPZv9Lh0FhvjO0zUXL+EfJh0WT1wZFt4fHoqs5CzyNZpSheXanrJ4Sniq/QeIEuldkRQ+4MIox+V99GzQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:21.0566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e45832d-2f1e-42fe-d11e-08dbb8586605 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: DM6NAM04FT014.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR19MB4845 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055015-102534-27434-2714-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.73.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkYWFkZAVgZQ0MLQzNAgxdDQ0C zJwjIlLS3R0tDCwMzE2NIoxcjCJNlQqTYWAAfz/y5BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan9-71.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 This eventually enabled a shared lock for O_DIRECT writes in fuse_cache_write_iter. Missing was to check if privileges need to be dropped - if so, this needs to be done with a exclusive lock. file_needs_remove_privs and file_remove_privs are both sending an getxattr call, assumption is that this is rare - should not have a performance impact. fuse_dio_wr_exclusive_lock() is not using file_needs_remove_privs, as it needs to be called again while lock is hold - it would result in a typical double call into file_needs_remove_privs, with the expensive xattr retrieval. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 76922a6a0962..feafab9b467f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1308,7 +1308,8 @@ static bool fuse_io_past_eof(struct kiocb *iocb, struct iov_iter *iter) /* * @return true if an exclusive lock for direct IO writes is needed */ -static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from) +static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from, + struct inode *inode) { struct file *file = iocb->ki_filp; struct fuse_file *ff = file->private_data; @@ -1342,7 +1343,8 @@ 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) || 1; + bool excl_lock = fuse_dio_wr_exclusive_lock(iocb, from, inode); + int remove_privs = 1; if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1380,9 +1382,20 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) if (err <= 0) goto out; - err = file_remove_privs(file); - if (err) - goto out; + if (!excl_lock) { + remove_privs = file_needs_remove_privs(file); + if (remove_privs) { + inode_unlock_shared(inode); + excl_lock = true; + goto relock; + } + } + + if (remove_privs) { + err = file_remove_privs(file); + if (err) + goto out; + } err = file_update_time(file); if (err) @@ -1623,7 +1636,7 @@ 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); + bool exclusive_lock = fuse_dio_wr_exclusive_lock(iocb, from, inode); /* * Take exclusive lock if From patchwork Mon Sep 18 15:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390097 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 C4FBCCD37B0 for ; Mon, 18 Sep 2023 16:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjIRQqV (ORCPT ); Mon, 18 Sep 2023 12:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbjIRQqK (ORCPT ); Mon, 18 Sep 2023 12:46:10 -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 BD4901700 for ; Mon, 18 Sep 2023 09:37:35 -0700 (PDT) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by mx-outbound44-224.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:37:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gMZRhSK4Ouo2g7Cqd8u+WCgJiBS3N+CqyAAgi87lT1ikqpbHBs8H/jv3Kuw6SLoxsETrRR5sqOrPS4BhgmhXy8LyK99hca4IidtH/1tvMfbaoRtn9UY33WOZywXEqSTowUGVf+6fS6MWw2YySLxWVRX8Nqs5lUmPfpuvtIZ7uCvFE/LeYcNlfrrQGA6E4ubiiLIPDkkOFTeYG9zxem7zIYxurO2zKFgOeaQ+Rz9I2Wx8z6bA2MrDnhp6hVVF9jfQuyZ89oYRMY3aCgRtHjH+mzrz3bsSmEGpbPPi8sCFHkImhVLGX+9HnzXgYrlT8psjSw2A74BnEE2DlEn0gqm3VA== 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=FCjih8zmLU1iFGL3c+pkvvttp3d7Zz1XoHjg4ZylUkM=; b=DlW3bmy54gAXCNLvX2MedRSv7pwaWB/ea3sq08XU49iWSmG7gy+xxlZPfZQGRnosfq3Izw5fThA93YKyXqwjVtoAtZyv5GzGhwnzprL8tOrxROYmrJmp/9vSNzArS9l6Ixl0a73oYJ744at/Kc8KAsEuwUfBtej20hlBG8zOxmPrGU4vHYSPVUPGVYGx8AJdVsITky0wZMvUwRbtogQB7ZA4zd7xhqja/R4mzuh1CsNsJgPi0pNYq1xVPK+nFw1KFjHTrrQkoU/xeSYPQcpFoGWuLN5LGvqGCN7/Jif7D1zU+3JnX+ww7IMWrVGxFnmubMvGJ/nhFvi0Jotw/1Q/nQ== 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=FCjih8zmLU1iFGL3c+pkvvttp3d7Zz1XoHjg4ZylUkM=; b=PSjEyIjNJ6Hr1YIlfCwjGZSN8V2uZlsCcyxarhP8BBI5GkC5WJdr7ACII1tRWfyIpvU1abBUQB4WO7YsVvLkwMZTV9VymxspTkX1ZrkU+wnFyAYva04xmvv21uYbF+UJwvnWUo9RLKRsovYSYqv3Hg/awMSLe+MMQV6A/PCM1bk= Received: from MW4PR04CA0353.namprd04.prod.outlook.com (2603:10b6:303:8a::28) by BLAPR19MB4388.namprd19.prod.outlook.com (2603:10b6:208:299::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 15:03:22 +0000 Received: from MW2NAM04FT020.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:8a:cafe::9) by MW4PR04CA0353.outlook.office365.com (2603:10b6:303:8a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:22 +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 MW2NAM04FT020.mail.protection.outlook.com (10.13.31.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:22 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 5922120C684B; Mon, 18 Sep 2023 09:04:27 -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 v4 06/10] fuse: Rename fuse_direct_io Date: Mon, 18 Sep 2023 17:03:09 +0200 Message-Id: <20230918150313.3845114-7-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT020:EE_|BLAPR19MB4388:EE_ X-MS-Office365-Filtering-Correlation-Id: c12c24ba-6371-4fa1-fdc1-08dbb85866aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tAXeoIkJnIN8JtHIlwW04yLWiHZqrPgmwNywWg/io91aJgMH/Ox4v3qqPbs/xcH0Sxl17x73XgD3+IG9XY/pyR1fh+ecwY+Y4CBNVl5cUMefxFScNB0cnGN124lOk6jMQ6yCsTaKcnDsigAxnoxeeiGaYhVOyb9mk6V1TU7FtLtgzVpN2QV/c/+0j8xxrSsVDns617ZQSJmwcw/Z7Gb5MkFvMPjYF6nYK/hqSUvMtQ6I5LSzaP4I5w00tf4cR+x8uVtbmKRtM+kWgTes4NbrfghgCVpzLzgRJf5OgyXjCajRrQm5FHiTkFTgZamN/CJZh0ybbnVKC1rGAztH+sc2/cYHoKB9W3MB1BCA3avVz855xbHXUuL4FiDjZP1zUm4GHXzGWwwCF8YR6HXFv2vOZLyf0jYdMBvsf6DVQRDaRQXonlK08VWJcZIR0HBqI7/lcqb9CIuLD70iv0SDFUERCXPgN7kvUFHzdMAn3t1w0eDT4EPPX6g/k7J7POWhNKJjuaT9FdX6G3xIu4fzQgQ90yPjh8tpUTzQ+M1QJeh7rBB4rjW6rjunI6hjNovtblq6vrF9LVNlmO5evk1/w3plaTEFqSqVAXgrHwLqFupBt/bD+sgctDBbdE2ybPYGisgO+5UISfB5FQgWL8UcItjkk0VARam/K5mIXiy7cQSr2ypJCoy2+j4m+ITbFKKrWcPGFt3r027baaA5qEf2DuRntpv9DP/pT+7JxRjvtPZQxWE= 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)(39850400004)(376002)(136003)(1800799009)(186009)(82310400011)(451199024)(46966006)(36840700001)(6666004)(478600001)(81166007)(356005)(8936002)(4326008)(82740400003)(8676002)(6266002)(336012)(86362001)(26005)(1076003)(5660300002)(70206006)(70586007)(54906003)(6916009)(47076005)(83380400001)(41300700001)(36860700001)(316002)(2616005)(2906002)(36756003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OJB8D/sfrNZypE9UV5ldKNduf9MV127WOejzJXbSh0szaI4YGHpcMIH1tkw0AvWEPRSEULvnGQ2ejvjW4ZtLtXRbF8tKGR5tjf9+lSpNKH/GQeyeNar5bMKoF74vJg79nx2eo0lcbLwXyUGN2V0Mrn10kSIv73aZERCwvcMo/tHngAv12xeFUxviy6whzbXFD0GE1/EMVXWI4vH6lqtE8AqIOQqXBqG6M3V2iWFe70F+9FQrPZ8lQ/nIgd5dG/fnWosF8WEvU8fqMgKkUQCZSkrzs78OG2Ji86jI8XW/4yY1gzrH8BsgMFz543QFuUI+M1b5LY0pczKKAjwktNZQw8TSLPckc0kqbjh1zonXg7wwY/R5CnuNn3sV+n17SM1Dv4v3paEGEhTgtVOB61GtmDQEQOXccZyF9nz6QzicusnX5cAPIocyRsvaPPws0SjArk/0VZGmWDyVXRL8c3LY7HStWlTC/jl+cO4kOnaXoLjAuMvAsQ02VGJalXEmvQUz9xXaBuM5ZVwfZIne24JvucphCuIapt1pWQZ6Hzsq9DsD4fz4gEgHGvihTNjEhpSwW27G402BKIFtNwYsTj44gd0jctNy7vLlmClCCKGyUUuLnjaY+G2KEjRj4jed/9cd2ysK02KkheXX4wqd+kdaBnFtYmvA515pB8XKFSd+fYDoTjUSvelKeAnk/kmr0QJtcWol/1FYk3cXHJfJsYneY8jmM9qx/uE/NcDbt77oVbgcGQCH0StIxhWjoHhD6/w8MVc9N07Sg8YALrlToVhGR82f9E9tDKlnGawXBJa0k38DL/1SHNNkY4gOx7YjNQzuVfqLQY5TgOcGlez/k7qRRjVKHzJinslAU+ZGzTsWStY3NN7CbM1Ix7zZIR+nIWJg4c64ys6kXbwtnqscuP4ZhQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:22.1234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c12c24ba-6371-4fa1-fdc1-08dbb85866aa 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: MW2NAM04FT020.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR19MB4388 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055054-111488-12353-3941-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.70.103 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmBsZAVgZQ0MjYMinV3CzVND nJwjTZLDXJIDnVOM3cNCXRMik50dhcqTYWAFkQDYhBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan16-7.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just to avoid confusion with fuse_direct_IO. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/cuse.c | 5 ++--- fs/fuse/dax.c | 2 +- fs/fuse/file.c | 14 +++++++------- fs/fuse/fuse_i.h | 8 ++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index 91e89e68177e..c267ae9dcba6 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c @@ -96,7 +96,7 @@ static ssize_t cuse_read_iter(struct kiocb *kiocb, struct iov_iter *to) struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(kiocb); loff_t pos = 0; - return fuse_direct_io(&io, to, &pos, FUSE_DIO_CUSE); + return fuse_send_dio(&io, to, &pos, FUSE_DIO_CUSE); } static ssize_t cuse_write_iter(struct kiocb *kiocb, struct iov_iter *from) @@ -107,8 +107,7 @@ static ssize_t cuse_write_iter(struct kiocb *kiocb, struct iov_iter *from) * No locking or generic_write_checks(), the server is * responsible for locking and sanity checks. */ - return fuse_direct_io(&io, from, &pos, - FUSE_DIO_WRITE | FUSE_DIO_CUSE); + return fuse_send_dio(&io, from, &pos, FUSE_DIO_WRITE | FUSE_DIO_CUSE); } static int cuse_open(struct inode *inode, struct file *file) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 8e74f278a3f6..423e40ab3e31 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -731,7 +731,7 @@ static ssize_t fuse_dax_direct_write(struct kiocb *iocb, struct iov_iter *from) struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); ssize_t ret; - ret = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE); + ret = fuse_send_dio(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE); fuse_write_update_attr(inode, iocb->ki_pos, ret); return ret; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index feafab9b467f..24fa6cab836f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1496,8 +1496,8 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, return ret < 0 ? ret : 0; } -ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, - loff_t *ppos, int flags) +ssize_t fuse_send_dio(struct fuse_io_priv *io, struct iov_iter *iter, + loff_t *ppos, int flags) { int write = flags & FUSE_DIO_WRITE; int cuse = flags & FUSE_DIO_CUSE; @@ -1598,7 +1598,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, return res > 0 ? res : err; } -EXPORT_SYMBOL_GPL(fuse_direct_io); +EXPORT_SYMBOL_GPL(fuse_send_dio); static ssize_t __fuse_direct_read(struct fuse_io_priv *io, struct iov_iter *iter, @@ -1607,7 +1607,7 @@ static ssize_t __fuse_direct_read(struct fuse_io_priv *io, ssize_t res; struct inode *inode = file_inode(io->iocb->ki_filp); - res = fuse_direct_io(io, iter, ppos, 0); + res = fuse_send_dio(io, iter, ppos, 0); fuse_invalidate_atime(inode); @@ -1664,8 +1664,8 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) 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); + res = fuse_send_dio(&io, from, &iocb->ki_pos, + FUSE_DIO_WRITE); fuse_write_update_attr(inode, iocb->ki_pos, res); } } @@ -3001,7 +3001,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) } if (iov_iter_rw(iter) == WRITE) { - ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE); + ret = fuse_send_dio(io, iter, &pos, FUSE_DIO_WRITE); fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); } else { ret = __fuse_direct_read(io, iter, &pos); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index bf0b85d0b95c..05c5cae59bad 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1247,17 +1247,17 @@ int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct file *file, bool isdir); /** - * fuse_direct_io() flags + * fuse_send_dio() flags */ /** If set, it is WRITE; otherwise - READ */ #define FUSE_DIO_WRITE (1 << 0) -/** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */ +/** CUSE pass fuse_send_dio() a file which f_mapping->host is not from FUSE */ #define FUSE_DIO_CUSE (1 << 1) -ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, - loff_t *ppos, int flags); +ssize_t fuse_send_dio(struct fuse_io_priv *io, struct iov_iter *iter, + loff_t *ppos, int flags); long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, unsigned int flags); long fuse_ioctl_common(struct file *file, unsigned int cmd, From patchwork Mon Sep 18 15:03:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390113 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 58A66C46CA1 for ; Mon, 18 Sep 2023 16:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbjIRQyG (ORCPT ); Mon, 18 Sep 2023 12:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbjIRQyE (ORCPT ); Mon, 18 Sep 2023 12:54:04 -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 436F4128 for ; Mon, 18 Sep 2023 09:53:57 -0700 (PDT) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by mx-outbound9-117.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:53:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EEdyA2O6QEiSuSm43eMtl3UXz9hsiXFwbjzqLLpF+9RHz/fiqT3pDutBHaFcePoBoItmhjU8BAq0jLSTahwDISnr9hSF6BrLqUeHyZabDjdJYWW2BPmkiohwB3x59CCNqfiKntCIz6nuQF1Mevmkoojkh6dWMM8UdTQe1B3tnxnvtNnsNjg7SgvZHIp9+aTeoNxuANtyiFFroRnWHxSn0eoRbU8RnrmW25OXHP6lbbUHEABhCfXH4aZjqL2HllDCCwoiunL3umCAl6/oqCODEZM6J21MNc676zVYk/GzbbfH0sRZWzRrl1kjY/WWaRhfuVd73gNjTIWYp0uWpvpRQw== 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=ge6XpbZjGAZ/FC54p/fIVR76iEJ73DSuwsQnMYh8XPQ=; b=iT+wZ0Nvj1sPtcn4ab934rP/aUPvAdwkbEgDR3rfiZcmsG/vNHklh58+l851Fnvch678N1KO9XGFd/rVL+D7AM1gG5wE5GvNSJpSvvjOd/3BodKSnnxQ2ysquPoj1r6OS3Mk+kLdbd1rBFZwmB2Cc7ZybiUF0y45qiBP0QWmH5c0rW0y1l9hbu8JTlWkC87ngSwD3jBIW8WCBDZTF9Jp5mBbl4kl/TpUeEfvriWVqK64Q9Fvz2tBKzzc1uJU1MCKFot3M4og3i+0IxJv9KaixL8yiWNmEeDC0Zp5xxORaRTYa+rUWFbfGd6kbHSdaavs2QLlvCZRlXuNpcjRXg5lBA== 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=ge6XpbZjGAZ/FC54p/fIVR76iEJ73DSuwsQnMYh8XPQ=; b=O7hZgxpnSlnrpxnR3bcWdcL2+4gEKhIbed6Pcu7WBYTjhoXu3nb0xhOmDIQls2p3urMajiQru/1BLxnX1lWLC658g4xN0ofpUPLQUBI/NXvKUbq77NyupMvSD7y/aYsQ2ELvKpKOcbqgjncr3wi4ud0W/aPp8iEhAeVtkbVbO0k= Received: from DS7PR03CA0163.namprd03.prod.outlook.com (2603:10b6:5:3b2::18) by SJ2PR19MB7559.namprd19.prod.outlook.com (2603:10b6:a03:4c7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.23; Mon, 18 Sep 2023 15:03:23 +0000 Received: from DM6NAM04FT032.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::d8) by DS7PR03CA0163.outlook.office365.com (2603:10b6:5:3b2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:23 +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 DM6NAM04FT032.mail.protection.outlook.com (10.13.159.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 15:03:23 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 5464520C684C; Mon, 18 Sep 2023 09:04:28 -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 v4 07/10] fuse: Remove fuse_direct_write_iter code path / use IOCB_DIRECT Date: Mon, 18 Sep 2023 17:03:10 +0200 Message-Id: <20230918150313.3845114-8-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT032:EE_|SJ2PR19MB7559:EE_ X-MS-Office365-Filtering-Correlation-Id: cacc6e19-0d79-4291-14f8-08dbb858673d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UCfpSanZ8I9LmL5GJWEuil+hgvLZqSceEaEHDJ/vHyn6n3ZubronvXsl2P2+1jAQt5Bul/FDGKrZ2ihs4TMRWZXSCtgyJWjw4M93+TbG+Nxzk9aYGSidX9xjsocDbO/TMeJCtsP+GMCGVCtZqZPnHrJtwlcPxdP+KQtzhgZbyBEG9IEj9aQeYwXiZleGy73b9nKDPU3eMbYXH7I5Cgh0/VP+xL4yYgflqgX/n46XCmrsIiSOpKDQmMZ1FuRsk89FTjuZJ7kBeLGD3brEs+Nob7YwP3ylQNRcFskHh7MKIppW2HQ4H0fKbs8s7Vv4xwGCsVUDbf9OGN7mxPB6Aq3nqcV2OqNDCMchuXAPFWbK+xhRISXWo4tShVFB/veHnFOAn6pQxED+f2oNneZpHog4aeeVkkt1/wX5l5oGlfCWaeHdLPaOGosMZIpr4krZLyQX4BXPcgkQY/U/gHX5zbeGriny6oXSx8m6LW7aFuXvi/pPQKJa9BWCMdTcoOsSTmjc2LJxkrUj3lrGnb1m4HuGvbi13lP+w+JsiMORabbVkQdIg5og3STyDwVlXQJHriZskUab4Abjbrb16VzWk5h1VY6sjVhVm3eqVmVyav4ElQqHcPtF79031De48OO7yf5RtupbvMzo11V8zb+OQ9vYKJlleHP3J3Epdi225JtRNtGPORjueUIQdjv2tnVG1ICFkS3nHx5D6UGjyVZepMXjYh3cZnrTQXmjEvASqKBQRiqU3uxNbMcJmmyf4YVT4CEV 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)(136003)(346002)(39850400004)(451199024)(82310400011)(1800799009)(186009)(36840700001)(46966006)(54906003)(36756003)(40480700001)(5660300002)(6266002)(2616005)(336012)(1076003)(26005)(2906002)(86362001)(4326008)(8676002)(8936002)(6916009)(41300700001)(47076005)(316002)(356005)(36860700001)(70586007)(70206006)(82740400003)(81166007)(478600001)(6666004)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1tBX42Z4/DGWy16D2uVRo3YrtHzkvOvZPC5xENNNG5BizavdfnPLunefwQfVJT09tcwJhRDvWseSEyhUmZrsJLYBNgV9HIReDsdLS5l+PCaiAFlVni4XZcTdHVdNeI2fIHqcDq+go3/2YelcBZbFkh8X00RGoQVuIU4yI4ynCW1QCAf5tOcSFjipdH52Lxb6043t7GT8AAQIe2C3s3Ei/cdlt8RFcJlsZn6/UQiHjswYMVfu4ZMMYL3FC9m46h9gnrjCu+g2QQx/ouDQPOBLb16HoUGIcT30cyTdZ2TfcivdTu6IsLGCFSmgtTkOxhl9qW6GghvKqtef7kIrQG9u94D1Tw5l1HCI2UFLVnvzHblrGLhmptdhVz7qh6+7A27tVKB2jyvDK7VZmp/MhpXXsk2arQXPLuNVjC/cM9wPbJlQ8sGS0dEmgLQOoq62RWJ6xTio9zeVm78Kn5M8kjUDV3GB+qF0TEM0ZfyOjvaYjnXkEM7kpNqZ5tf99D5N8bHXmKUv2XV7LR2AuQw1nYjhr1jRrvqkCDGh1mU+fqyomeJ/FG0qwlDF5yJBpscblDdEOgmTRvFBts3wlhpQzqT9GPRph0+8ruSwRPVxbbq7yOqIJwd7fC+Ym4XTiDIq6Raitsl6a2vzakvHvZWePd9gJYOCuRAlF/rq2WuDInwPfvwfolzncBozJKWmoEEd8Xf3KEq+QVkFW03MdrM0gYrCX0NUx2NPNL1wK3XdEkvlKAmFrwuTqj8p+LRxN6YIkrWA05bMc7BX9hV6mUxS7IjixPXvOjEdCK8NFAA6khcxHtniz14FKW4e9bg7z6onYLg4inbQ6OSPikYz7/QUd0eWL2yZjqzIPd8Vl0mCIWtjocMNuPOXED3vH0IFp7xiO8z8HkpxtDQfz/VWzlOJtpjlXw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:23.0965 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cacc6e19-0d79-4291-14f8-08dbb858673d 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: DM6NAM04FT032.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR19MB7559 X-OriginatorOrg: ddn.com X-BESS-ID: 1695056036-102421-25882-781-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.56.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmFuZAVgZQMNXSKNEoKTnNwM DIxNLYwjQxLcXc3MzS0MQwxTLR0MRMqTYWAG47c/hBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan23-8.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. Before it was using for FOPEN_DIRECT_IO 1) async (!is_sync_kiocb(iocb)) && IOCB_DIRECT fuse_file_write_iter fuse_direct_write_iter fuse_direct_IO fuse_send_dio 2) sync (is_sync_kiocb(iocb)) or IOCB_DIRECT not being set fuse_file_write_iter fuse_direct_write_iter fuse_send_dio 3) FOPEN_DIRECT_IO not set Same as the consolidates path below The new consolidated code path is always fuse_file_write_iter fuse_cache_write_iter generic_file_write_iter __generic_file_write_iter generic_file_direct_write mapping->a_ops->direct_IO / fuse_direct_IO fuse_send_dio So in general for FOPEN_DIRECT_IO the code path gets longer. Additionally fuse_direct_IO does an allocation of struct fuse_io_priv - might be a bit slower in micro benchmarks. Also, the IOCB_DIRECT information gets lost (as we now set it outselves). But then IOCB_DIRECT is directly related to O_DIRECT set in struct file::f_flags. An additional change is for condition 2 above, which might will now do async IO on the condition ff->fm->fc->async_dio. Given that async IO for FOPEN_DIRECT_IO was especially introduced in commit 'commit 23c94e1cdcbf ("fuse: Switch to using async direct IO for FOPEN_DIRECT_IO")' it should not matter. Especially as fuse_direct_IO is blocking for is_sync_kiocb(), at worst it has another slight overhead. Advantage is the removal of code paths and conditions and it is now also possible to remove FOPEN_DIRECT_IO conditions in fuse_send_dio (in a later patch). Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 58 +++++++------------------------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 24fa6cab836f..a5285a9e36e3 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1052,6 +1052,10 @@ static void fuse_write_args_fill(struct fuse_io_args *ia, struct fuse_file *ff, args->out_args[0].value = &ia->write.out; } +/** + * Note: iocb->ki_flags & IOCB_DIRECT cannot be trusted here, + * it might be set when FOPEN_DIRECT_IO is used. + */ static unsigned int fuse_write_flags(struct kiocb *iocb) { unsigned int flags = iocb->ki_filp->f_flags; @@ -1631,52 +1635,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, inode); - - /* - * 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_io_past_eof(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_send_dio(&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; @@ -1707,10 +1665,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 Mon Sep 18 15:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390119 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 7A6A2CD37B0 for ; Mon, 18 Sep 2023 16:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbjIRQ4T (ORCPT ); Mon, 18 Sep 2023 12:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbjIRQ4B (ORCPT ); Mon, 18 Sep 2023 12:56:01 -0400 Received: from outbound-ip141b.ess.barracuda.com (outbound-ip141b.ess.barracuda.com [209.222.82.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F5EE5A for ; Mon, 18 Sep 2023 09:43:32 -0700 (PDT) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) 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); Mon, 18 Sep 2023 16:43:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EyenPZlEE+HCQMfnzbm+rITXqJlhO8lKsdK3kHZR/eNT8gWJAUDY0Z20dAC3a04amznNDshTqKzZEDtc3yWoaPGA/2aAf46jAOkeh8A7x8pQtk80iZ0Mga/ra7Tb4XqPXwTIg+Zflpatxc3TLw4I6CNy8hHfvF/E/WPdfjXOnlXaUx8TvO8ubvsg7Cx8fI2jmHkCSJRrRJ17JOVyAJWgXYTTY3xlTtOwqtsN1NKKHCV/TotJbfloqCe+pWDJvnSUtAa7sdcWn+AgfHbzap8FeVJ3y2Tb0OTi1bgxvj2SGWaFjvDmtClyUMOjEH6CXYJYSJZZ2r+3+fZNdqDjiF1cag== 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=+kr+5XWP6rtPbZpsJ4rBY5cifpLtBZj/socajKTfQ48=; b=TmlMFb5dv/KREjGhbY72Hnr5pTMhhjcF+0r5GqTkg437LNvOUxq+DhoGlAH323efGvkRq9oytm+DHu0exZLY9WtPNAkNdulViFXc8wE4JZHouVaBuVYCcI0cYPpb6hMgWbsGP73GNctGcS5qQihi+qVqtPasM9jPIcCtxoq+31wOi1U49Yxg1aDgtpV3uFDksjxwq8OIJ2xyCW73+ojj8ncdxg4D38g13TcbNybRSRNwCo1t8v+suOpYsKBmOLUN+yVWx5lF93R2/cHi5uyCOBEue2xNpKhXUKyiJfiqMy034z2YJ4plgLOB1js9UstRwvTpCJNBfDzGjkFYWRZpnw== 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=+kr+5XWP6rtPbZpsJ4rBY5cifpLtBZj/socajKTfQ48=; b=xgR/hhRVdy2g0AM67hAe0CYWnxlml1IBgJqpa7LGrP2ikFwmVx7D2brdzcriPwS7x5JB3rIFkpq7V4RhVmx99eVKO0F4frJydRGduloHvXkL7H/50rPAOGaIIQJsNIysLXjym8X2eZqISHf+NKC0XhRH+5ds7LaL1Cr/u0iyCEc= Received: from MW4PR03CA0115.namprd03.prod.outlook.com (2603:10b6:303:b7::30) by IA1PR19MB6276.namprd19.prod.outlook.com (2603:10b6:208:3e8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31; Mon, 18 Sep 2023 15:03:24 +0000 Received: from MW2NAM04FT038.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b7:cafe::3e) by MW4PR03CA0115.outlook.office365.com (2603:10b6:303:b7::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 15:03:24 +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 MW2NAM04FT038.mail.protection.outlook.com (10.13.31.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:24 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 4E70420C684B; Mon, 18 Sep 2023 09:04:29 -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 , Miklos Szeredi Subject: [PATCH v4 08/10] fuse: Remove page flush/invaliation in fuse_direct_io Date: Mon, 18 Sep 2023 17:03:11 +0200 Message-Id: <20230918150313.3845114-9-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT038:EE_|IA1PR19MB6276:EE_ X-MS-Office365-Filtering-Correlation-Id: d4a8aad9-d956-4e6d-de86-08dbb85867d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RmFBXQD/623p4zuSc01GorUZAdtSjq3A6UCiOs1Gww6Dr7o6D6Lvyq4DiT/I9umJj0LYJXGzQGW+BW+u+EukV7t0x2Qu+3AzCKo2h18D6xdk39/8EnC4KTwEIFRI2hnVeETvIdarzuA5gxVYwlTfbYb2glQDZfHWKyusW5RFAqj13qbGysI9P+x00zQY/EBVUkpRwiz4nZS0f9adFqoCQ1aaSQUbm37qIiZgGyY49yNhUdg8xFEF3uPOeJ7YiY50pBOgpvbqJd7ZFZJAmj3a7zwmv88bYu6U9N16g3CA5p5E1w/FIxKm4QuzU8AGT5xQoZBn+u3AREQj7ZXIvfLOQ/MsguiZOjTRUsZCQFcRdtsyWpBDRZna++x48zB9uyPMng6waMO1O7SsvROOU+eDNAMUAOGY8ORovjA8glK2CPJxb+h/WaRNBaUJ4d/zpMH+H50eTlR8zd6o4uSeD8BMKJFEtsESs9mkZGF7nNm/JDD8pSV4uaaP0MBQqadSGT1xDU+t3CSLarawbiL5/Um7EyJs5OZTSWge4EhvomlK7/iPIRPVcifToWjZQf8dySaP0CyjdqkXh7qFCkvKS3nzf4+MUmkDPnlw4sDpAzwgwsSjLJpps3a1dfq6pYgbckIxVd2SqRZQBZF4aLX0iK4cLIiQgnBQla/kSn6FIafKsuNpomdj1WV+O3eueek3mYS4uFqKF+qKaDOPNuc2m2VLcdB8AxNjqjb4+2e3OZ/Bi2g8YjEheXREX7KepliprqMl 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)(136003)(396003)(376002)(346002)(39850400004)(451199024)(82310400011)(1800799009)(186009)(36840700001)(46966006)(70586007)(4326008)(8936002)(70206006)(8676002)(41300700001)(6916009)(54906003)(316002)(5660300002)(86362001)(40480700001)(2906002)(83380400001)(36756003)(6666004)(1076003)(2616005)(47076005)(36860700001)(26005)(356005)(6266002)(478600001)(81166007)(336012)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rXETSGwyyo8ygs5pPd0iNUrKnmnYcy/rVDNiAizvTYrm7vvndqIjs3AfVCFJ9+VC/7kz1O/ikzz8bW5jfoVkA06ci8xJcsr9d0M9AcT+8Xx5GN1JByg8r6/d7BSG80qDLpOuIhJv4Uvp7c2XS1D/1eZB/3waKucgGEFwuqjtYKq3dFjZWm5QDPTpjaNoJ7PQqjOVGA6/ckn1/un/KdCrmEDU80n4hFIdJIE0CILZjJgDNRTaIKRbXuYk+lNCAH0UpVXDDRglmledzh6u9IFzepIemwo7Ujrm+vgE11Wa4h8tSi+Yx0nuQcsgsuGxE5k4obf5MN6oXJFblzy8VCGce91ajZB7o0cWN5JHvuMXvLBFeLd9e4cG92wd6s273lyIcwAgtxIGilwt+Ic/UadBALRXYHlOVzwcTjRDOvs0iVKX2vYVmvaOgVNiCxib4pTkbDskx7sBj9+u6UWr3FNaHFdHRMSQyLCQWUNbyREK42XXYzxr6zqJTz9+i8Sb+PY5WTc/Z1TiMcP1xfwtW9pEfJxv/Xzgw9imGf6Cz+ssAwd++8iN3YuQRfwvLHNOmzdU9iStXcp4cO1mjFkXDxTHeFOUWxHKmjnHFlyTEUpQxKXbKMIXyFl77OOuZLZqCNgbRY1GTZpLjQ2nj+WswapZ1ekPdSH8qQ126kY885J+E4DLu9UQB52CQjR9TeonM9564BK3ekyRmSoA+1P2gM4+3gsetBIMT3dDJVbK2boqI0J+AFry1A7qzqaXDk2pfLZMKJsL7KSAGy6w2kxjzvXRnWHFCy8nbrhySL4azR/Z+kk/l3rrQmoLRkAhHU/CedCUYw3EpLlkAU3ngKFSJjQT7XKfoF06uWhJ0aXEpaE9DslPPOU/vpcwJw6UwrZSUMz4RNs+YpCRSd4eKkMDx3euUZMfm86zUeOOw+t5V8LhWOk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:24.1109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4a8aad9-d956-4e6d-de86-08dbb85867d7 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: MW2NAM04FT038.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6276 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055411-111953-32470-3941-1 X-BESS-VER: 2019.3_20230913.1605 X-BESS-Apparent-Source-IP: 104.47.58.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmJsZAVgZQMMk8xdzSMsU8xc DCKM00yczC3MwsxTgpFSiQZmlmbqxUGwsAsTvJ8UEAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan8-128.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 a5285a9e36e3..a996368cd38b 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1519,20 +1519,11 @@ ssize_t fuse_send_dio(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); @@ -1541,14 +1532,6 @@ ssize_t fuse_send_dio(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; From patchwork Mon Sep 18 15:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390112 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 9949BC46CA1 for ; Mon, 18 Sep 2023 16:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbjIRQvn (ORCPT ); Mon, 18 Sep 2023 12:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjIRQvl (ORCPT ); Mon, 18 Sep 2023 12:51:41 -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 CE6ED94 for ; Mon, 18 Sep 2023 09:51:35 -0700 (PDT) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) 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); Mon, 18 Sep 2023 16:51:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g71+Dpy6MD5Nh49Fzfvp4g1hYc2Jsoh+nV5371G9xgm6KXkuOBqa2IHuA2oE1T67QMwzCUQT4E0EXzxw5WQ7+5692cYYKGwdE1xszVNnFnZ+Fl9Uxl6C3SLqa9481Bxmfq8leyb7lfHe7yi8R85OBY0xBLxQVmlK/a+oYmD3paGw10WSMLwOgZdgylnSF4gLxwyE8VzXWG0k9ABlvn42Ef6u6yIVBZ1zpFQGSCkd+DVn9IQJ0LEDR039mPrknsxmcfArjprrR5V6PE5chSTn45yWJK0WKFcljGzJt8xVL5vKG8K5zA6koj/uOc0N50sP46PzQo4JoPnz42GY/3MRCA== 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=Y30ZpdTbDkzt6+XgLEJhqMtpIQFbxnZjnrZPlUB969Q=; b=IfcEJ3jKHGb6SsAReu9Td7IlWbmZ9fHtIJDhiGNEvT1Q+jrZZXAPBtJprKlueWWNQFVLflIJmdvJ/DHjadGTugBycHN7Wr/H8kryRJFNlSMKQciHmrfLVT8N+4SG0KBLt/ldXPIVZSKMImAXnrp7UrfmKSgs4uSdldmH/uxFuy7mdo8L/qeUAAVKlpdPCz9yJ5yak3lsnD0Ae70oDv5PtwUdW5mLHZvcbCkSGnpLX/6Y/b+iWKLAKB94072ZpGw5j56OD9GLRAKPZ7DyVVwtR7xblTV0iSTsGUV+iQ6UWglKohLYuEOw6UfniJ9GlOn6Fdni6yxP6GCVc6mg3QF9/g== 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=Y30ZpdTbDkzt6+XgLEJhqMtpIQFbxnZjnrZPlUB969Q=; b=Y/+XdLk7e3T20I0tBByriEmRjjcvHpyD/ld9wiRNyDfcm5ftkUYlnsKhG24q3gWJ2QJR7X6QMdVB4YOY1063XOZ3ahBGVuOg7q1PFbEzzRoWTt6XBmu55JmVgop/0EtUkzqw1m67XnKbraXd98Z6mJz0s9Kvk6BZRZF8ZGhGWZE= Received: from BN9P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::12) by LV2PR19MB6126.namprd19.prod.outlook.com (2603:10b6:408:17d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 15:03:25 +0000 Received: from BN8NAM04FT030.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:10c:cafe::e5) by BN9P222CA0007.outlook.office365.com (2603:10b6:408:10c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 15:03:25 +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 BN8NAM04FT030.mail.protection.outlook.com (10.13.161.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 15:03:25 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 58B0E20C684C; Mon, 18 Sep 2023 09:04:30 -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 v4 09/10] fuse: Use the existing inode fuse_cache_write_iter Date: Mon, 18 Sep 2023 17:03:12 +0200 Message-Id: <20230918150313.3845114-10-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT030:EE_|LV2PR19MB6126:EE_ X-MS-Office365-Filtering-Correlation-Id: 9eecafd2-e7df-42d3-4b53-08dbb858688c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /84LUhBdqge2aFLQOzXW9tC+xgru1Gi4v/JhtN1/qdmHv+H7VDKMe02pMFVrWgOLOy1HazsRK28S07X1w1H/k2TOzlKSAwhzq3mhZ9TnnCeDSN1138hmyV3YrZym/rJB7fksxvvktAZUXFjCgCzWbfKg4faBpu0W15ra/pKea8sePN3g7x/KuvGD+Ffm3AKAUnIDyR8QI68P72zCUjTL8duex1D7RVCa0+ZLPbBBPm/eJjmJ5RsC+fhz/ByTo3/xq90oom87fyNUhmvtL75mpmcpIcBl3xX+B2rPnPsaRVt2gNc4S7mkF/hWGy3cMAkaMbU5Dq0O/QJFeKYLgZQmp9PhCupNkQcfFdE3q3zHbbSnlRnwdJtDST49WI2lWJQm1eugREocmrHGKsZxDlCbppxwboxy4yjaEI8n/PenHBF/6HCAG9A0Fb7MsXDLEmYZZ24BeEbWByLtvJ+ZUHXifjhOFCxjIQeF/YyIU6fp4UENy98zO5feYyf0BPE/NoqhRQoCFOl/+uq8ctjxa7op5maTuf2vqe8dMyCS7yUC3MSGwpGxadhz2s+QCzNmURPUYpnYQW9qEOMoCWgIoElG2v7oJvztvi8lKQRAppPjhaqRRxWUgnXL2Y7zV/9SH+sRDm7aChXFJvvPAWr+dYZ42SQNCUUi2kKJ3PCPL/1sCGOonwj2fs1TahMvEoqx/gG5qTRwO4zDOXoCW6lOTbCXB2v896/FuzxhUSE5HgsxWf4LYG/l1ok2UnV4o5YaYdD0 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)(396003)(136003)(376002)(186009)(451199024)(82310400011)(1800799009)(46966006)(36840700001)(36756003)(40480700001)(336012)(6266002)(1076003)(2616005)(26005)(2906002)(4744005)(5660300002)(86362001)(4326008)(8676002)(8936002)(6916009)(82740400003)(47076005)(316002)(81166007)(356005)(41300700001)(36860700001)(70206006)(70586007)(54906003)(478600001)(6666004)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3sKjiVDHylnsdJtIEImQ8wTgOascysBrkimnT4TVkQ9jGg8uKzMObGzJi1NBBgLL8O9tGpOG3cXTp0lqbZaMESeAIemdEjb5USvA/O38opeJPKM71LrdbZnr5RW6PcGW13UYYlc5qVmxzigX1n9asLjoWgobKgvUnD8rQ4mwtlMDUvUVrkgQWx8kg1TUPgPDeJTNBM48bIOUvCOX5OZ//Qik0zHyfxfRNhOx3t/3sVRq9YWcPnlc0TFtsg3o4/+jI4jzmdouipy3FLku+GW9zxyOjnxHDjf+4raCsXVANzy0C/Fc0yAhz4yqZ5JUEv56grbTL1dYDKzEm8GQKnmq/+4TOaQqfey8E51bjeUm+ZQfcd7RHpgdJwlitO7hH5x77WXEVKstz8UvOy7pnqGDv/2SMKRiiDmIn9QxjjJO06KjlmNR2ElLOP9qVW7K+0oubSWjyEKiLPvdVr7st88I8sluQIFHqeX6qwBEsOhvuetQxJBUzmIkKExX/cLfRGODaH7o2Gw8M04jRgig4LlfSf/MJmnq9UQk613OlwCNTSEeR0cDhMabV+XuM9ctZa3J7n1cUQFklMVlQiGJcmo0wzkYKeBcLxk3Cr2eBnvyRvZ2NiYophsSAnZ9PQLAwi3DJSw+csuEO5eGznWQo9rcOSVCDKUdXTVsTZwtWI7clYy+8c5NWUtub/zrWZDIQ0qdyPA0dt7jBdLNOGgHh7KZXPGHBEmog1s/h5HV9/+4gy3PrgTDhD46YdgR59fiGK9iXLzeyYjWNTvnJtZF3Zj9QGH74TYvJZCHt96HUeQDmySu4iYlGnl2LvU/Im6gxAGczL/Zojs7gkPnsDivBRIKYHHTwExWKTxus6kLDyqAq8NvheQQNEBy5SMmfUfTEs4HfuLcmU9YUXX3jxYIzj1A0w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:25.2308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9eecafd2-e7df-42d3-4b53-08dbb858688c 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: BN8NAM04FT030.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR19MB6126 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055894-111953-32472-4867-1 X-BESS-VER: 2019.3_20230913.1605 X-BESS-Apparent-Source-IP: 104.47.74.41 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpaWRkBGBlDMzCDNwsA4zTzFLD nFLMks2cIg1TI5LSXFyNDAIC05yVSpNhYAafKvrEAAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan17-192.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 makes the code slightly smaller, I guess the compiler would havve optimized that out already. The other is file_inode(file), but I'm not sure if there is any risk that they might differ. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- 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 a996368cd38b..23fd1c4a1de7 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1352,7 +1352,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ - err = fuse_update_attributes(mapping->host, file, + err = fuse_update_attributes(inode, file, STATX_SIZE | STATX_MODE); if (err) return err; From patchwork Mon Sep 18 15:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13390098 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 6D043C46CA1 for ; Mon, 18 Sep 2023 16:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbjIRQqe (ORCPT ); Mon, 18 Sep 2023 12:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbjIRQqS (ORCPT ); Mon, 18 Sep 2023 12:46:18 -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 C6C061B1 for ; Mon, 18 Sep 2023 09:39:24 -0700 (PDT) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by mx-outbound47-161.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Sep 2023 16:39:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CzLnwYlYA0bc8avhTtOLGwiXQUS03CLq4X/6QjvCLoqgT/t1kjpKqo3YhCJE+xGa1jFX1GEd8Op1plgL4YRB2dZNwvHW+/Ps20WS+vZKBg81N9V1Ir368SSDDeyEPi5MbmrsJhCWP6tZ9rSy5v2ms3RJyJDILCdzx7xvtZxr6J9d0BB2emhgo/V77U/RVeHocg+GBjrX+Gv/cJ1+iNEWNzXGRDdRGeWGlwTKuOv9cLB3wIbfpf3q31LK9O7lSlN2RBwOKpiLzEU+UvLmWSKD3kXzADKsAW3nB9WbOAwLIahUHMQhm96hTFQFAHzikAfkhKyjT3aZrKXmQRDBpcMJ1w== 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=mjZuvpI15TFd1/LM9T6DCgPLlMbShmb02g+85+dAgZ4=; b=AQi8WRHUTjDZ8PtzGSn8ORSTVRmWU/2IQ72VjMOn7rN/ww96JYmyiWTypg5k6QW3W+37v03nIY7yZ+ajWnJHuICm9LbIQTyocLm77dP41I3O0ljyqMQYkhIW0jE+j7zRMOQVvBhxN+tDhNEQslbompUvCm+jtMtVvPTXWLfU8lGFVOR2jr04JvFK65oqIcTjC7E8fgfV/+qjEk907X04y391UlMhGYet4hnUuVh4VW6bN0wNG/bNDwbgYkKIlqncuCsf9TnlKT2SC1ZgdrRcYqT4WGcPyiIvXEKNIY++IQVmSzwcZWVuNIXELHYPxsT3xYY37pMrffbhH4jB+a62Ww== 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=mjZuvpI15TFd1/LM9T6DCgPLlMbShmb02g+85+dAgZ4=; b=NwauvEWbwJ3HGZL7CpVbU9zM3GKStsgZPjFvFgRbOtb6SXMHUFJG9RM50HIUtezmifbOjx/K4+YamRijNOI+iYxsdoP60P7DVdISYGjaNSOPr2NG081GbtunKOeKwEPrLQ5POO591bVHlZVpIKFVfdBf9QX47dhKCiLCsZ00o+A= Received: from BN9PR03CA0981.namprd03.prod.outlook.com (2603:10b6:408:109::26) by BL1PR19MB5793.namprd19.prod.outlook.com (2603:10b6:208:394::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 15:03:28 +0000 Received: from BN8NAM04FT025.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:109:cafe::ea) by BN9PR03CA0981.outlook.office365.com (2603:10b6:408:109::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24 via Frontend Transport; Mon, 18 Sep 2023 15:03:26 +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 BN8NAM04FT025.mail.protection.outlook.com (10.13.161.0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.15 via Frontend Transport; Mon, 18 Sep 2023 15:03:26 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 52FFB20C684D; Mon, 18 Sep 2023 09:04:31 -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 v4 10/10] [RFC] fuse: No privilege removal when FOPEN_DIRECT_IO is set Date: Mon, 18 Sep 2023 17:03:13 +0200 Message-Id: <20230918150313.3845114-11-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918150313.3845114-1-bschubert@ddn.com> References: <20230918150313.3845114-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT025:EE_|BL1PR19MB5793:EE_ X-MS-Office365-Filtering-Correlation-Id: 1601bf84-6e99-489f-4f70-08dbb858693c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G7595c3Z2ITObD0sN+P7WOpQ9Cmz7q4knX+EoO710gKr9C3/lbsr38PSTEwVKnGbrSO13TOuHqMAjPQ3X9TX2dnm6+i2WMusc1ixo5A/wGDE5n9hMBUWsrkV1/ozoBC1Bh85I81iK6XY2ZmF2S5HeXRU53zoEYOm0gkolPzq0Nk5I/NXRQCbwgahh9L1u0aLoEsfMtTgJ+X4bh2yBQ0kzPRLCgOrgXo3umzE6CoXtcBvVNYJ3koxSms9dbjrIUCfuaSIRcyK7r1Jt2iFMI9am3fqLGNZHEHVxplTiLoMz1CgpHN2JV9C2Es9nEAgRG7xsbUFZYhpsDKlkllIx0uRI1emkDOPbj2PbKptdRJLTfeA6PFU5D5LpOoRu+0mzgOi+laY0i8OyvYkYobRFTpc8kXEp8U5NlRXZ2yLgLLAEQjHnZEU8tCmvOcfE/mWSY88PkdDQ5hbehTOW159kRTBr12+yU1+rcWUFxHxEdFVv8wrBbQmCyEUvR2VUXI/4sTPeQd/pNiOd4icnPScCDoavByGJjt3QMwBu4awZKb6c3w5MXln4/Wwzq6rYM7CprF2jh508i5isSsSllYO83Ce5FISLMCGLSKjWlWcjNiC6kab1b0GZbmDtkKHlpkFDk/de58N1O0pGpuI7DPKAYk0VW5KSFgTsgC9GKX411MJ81sDLumiDSbL8tZfX0gMLrcTffWb4COLGmpT/mpTK1jmThBlcLEvGczbbPoBMwMfWrNAs+JzRKcBG53oV6O0sdxn 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)(136003)(346002)(396003)(376002)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(356005)(81166007)(26005)(82740400003)(2616005)(8936002)(1076003)(4326008)(8676002)(83380400001)(36860700001)(2906002)(36756003)(47076005)(336012)(6266002)(40480700001)(5660300002)(86362001)(478600001)(6666004)(6916009)(316002)(54906003)(70586007)(70206006)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: RuJ68A0qpYZPUg2nfES0G91qforWhXL7GB668PBcB7ZxEs3Vd2d3VYaAu5chrlnaZntj1/4NsCLH6Xn5c6IG4+tIWNPl116opRUoxBLZX6JNJVD/J4FkOReaaTH4U5bwrdZqXWykuSIDTKVjXeo5Yg7nxvnk5UlhGY2IHJL/JV6MB2IXkXn8BdcRq8+0D+QhTbA+yiHJOQ85iyN5XSiz3TYmT78lrELojodWwRE2XoMxselvHRELItOyyI4/8W4USPlo7XBYqd3aDenRJkvQn6v3kG9dEmPFP/8OJK/pUC9glyw2wwQL6VEr1/S4Ob+Jb2tvtdBQV+Gks5qLvt64/IBaSdmuxEKH/L/eZ5t0eLEvqh3geIhZuMqhAZ/tYdW3YT1Mit6FDb42ip8U3jWtclK/wIbYBgtd5WOIOcP6+pXxmytflm/jr3mPnBdouyWEYXEUUPjTAadDhM/+uKQNuWOqGOZd3uauJS8xYo/gh9+3UXFQ4IOttUTdc6q3d4inX3OJShYzieRef0x5EuCLfSdD9byxhLvT27Fer1wFwPdoOlLlmuFe1hjqOCOAOULTpcvmnOg32gYtpio66qOxmxvcZTmbJNAU7XEc1b2gxh4FviyLFMaajjjJdxrDKD0HdPSROhd8QhkV2PfBtiHEy9OHRD0ctJ8BFP5O+c+v2LBHJMAuiY9srF7VBC34scYVTE1Xa8xXzVxDDQOlejYoUneTzuwYmQLa7XaW5J7gLcNpRrUmLe9j7qVgBtGEpAi1XbB758cBm1Yeto0mvhD/lVHKlUI1cgLxIFq8pBSk3N8I08yssik95bw+Rx3hTWWph+Nlt4xo636/JHMvqeJzTvVGB+bHq8enT8nKtTLg0jNY/x+cgyE6tuWa1xEQ7d12Z3ZReG5iBg6d//oDF6cYhw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 15:03:26.3843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1601bf84-6e99-489f-4f70-08dbb858693c 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: BN8NAM04FT025.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB5793 X-OriginatorOrg: ddn.com X-BESS-ID: 1695055163-112193-10835-1579-1 X-BESS-VER: 2019.1_20230913.1749 X-BESS-Apparent-Source-IP: 104.47.57.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmZpZAVgZQ0NTS3NzQyMLAIj XJKMk81SgtxcLEwsAsKdUiKdkszSBFqTYWAKActPxBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250915 [from cloudscan22-72.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 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Traditionally this was not done for FOPEN_DIRECT_IO and adding it might have a performance impact. The better solution would be probably to have a xattr cache. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 23fd1c4a1de7..91cd25c0c177 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1342,13 +1342,16 @@ static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; + struct fuse_file *ff = file->private_data; struct address_space *mapping = file->f_mapping; ssize_t written = 0; 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, inode); - int remove_privs = 1; + + /* traditionally FOPEN_DIRECT_IO does not do remove privileges */ + int remove_privs = ff->open_flags & FOPEN_DIRECT_IO ? 0 : 1; if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1386,7 +1389,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) if (err <= 0) goto out; - if (!excl_lock) { + if (!excl_lock && remove_privs) { remove_privs = file_needs_remove_privs(file); if (remove_privs) { inode_unlock_shared(inode);