From patchwork Tue Aug 29 16:11: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: 13369197 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 634BCC83F12 for ; Tue, 29 Aug 2023 16:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237280AbjH2QM1 (ORCPT ); Tue, 29 Aug 2023 12:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237489AbjH2QMJ (ORCPT ); Tue, 29 Aug 2023 12:12:09 -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 21E18CE8 for ; Tue, 29 Aug 2023 09:12:00 -0700 (PDT) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx-outbound14-88.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWj1W2MajOBUzlkvrKD83VlLEe0NSOT2PhNZ/ziz1siM833IO22hjflW+VCataDfCDSsfqUyJhcwJ2fU6pzDeop5Devm0GwLNdu7OKjg9BifX2PP3WlamvVMQHvDO20LY2gbBg5D4yJ0h4eUZ3RcB3K/1HmguhZx/pqUVcAb2G5FoyqUR/g50TdHlG5+N4n+z3e9bMc4xdQV1D7YAm8H6Z8WYDRstGvt90KrOxl++z9xTmyivdodSi5ptDzAiDhZRhy7dXwfOwtcXzIg0dHo8Ye1BXc+//b/i2WmHYVHaAHTZdLtwNywZ9LfeqskoS1Jnuy5p3f8A6LOkZX/W7X6+Q== 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=Y/koRFjM0q3aKnlyOnced7TnF1VnK4OwMLWmnsKY4CCSgyf9T0V0EhQFGKVc4B+9/+o5dpod++luruVUnvjSJ+iAGY+xxPpY7KigjInkaQjNImufFNI0k6sesddDbqUPPERNM2Pm2ckQ8UAkdxlqcKqIcXoFNbENVtWb+7Cs5HsxljuQ8/MnhrL9FPwXnH3BkKEaFio9Bh4qQCHiHxw+Elg8BYrWYUBhGPaTK5XGCkI245IUNdYsTmICtHeIJnOG96Li7gKc4aCgsCrQ5k4Zj5RN1rdSdbDihsuw2MuxHJZRyRgTFnP7zRR52oKFYcuzV5NHsMYUjIgJgUq7v6kriQ== 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=smVP/5L8xVlAfr4H4Oh71fRwYu8UveBNOOHH2ih8YN09FGvcPuJyhBbpJQqVqsZcYn3xz+mcEJF7W3ynYVmIk4U+t9/jCTYydUArnwTUJfHpY58y6IWOEtv8l9BkFsLC0pJDTKODM7wRL1hzehea/H5CtPtP5C35EU7qiaFJRec= Received: from DM6PR07CA0063.namprd07.prod.outlook.com (2603:10b6:5:74::40) by MN2PR19MB4128.namprd19.prod.outlook.com (2603:10b6:208:1e1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 16:11:23 +0000 Received: from DM6NAM04FT006.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:74:cafe::1a) by DM6PR07CA0063.outlook.office365.com (2603:10b6:5:74::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11: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 DM6NAM04FT006.mail.protection.outlook.com (10.13.158.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11:23 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 0117220C684C; Tue, 29 Aug 2023 10:12: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 , Miklos Szeredi Subject: [PATCH 1/6] fuse: direct IO can use the write-through code path Date: Tue, 29 Aug 2023 18:11:11 +0200 Message-Id: <20230829161116.2914040-2-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT006:EE_|MN2PR19MB4128:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ef55158-3bb7-4ed4-1030-08dba8aa96f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZVdmN0/ewPr0EFiSBG94WwS2FwZ982Svxk8rPyNGvjjfyN+VC++m4uI+zU9jpIpqXpjCi6CAQJui3IXeOtqbAhPlryn7/wVJeIL8ca/UK92ycByRogrS2A2IajcGYBDfd77CetVHEWHKFrmCePT0BukdpMXPnCEO9fLl3eIukovVsn11Z6Reo/jkOEitMLVV3xPx7FiyVySTr89rRjgv+ikxj/Q0b664GkbgiujPjJGQ/ljl+mhtM6nNnidc/ZkV3+jpzCm+w5mks4aDjiEC76kgY3ov6i02sDHgToc8vfPl0mKe0d6DvFhOU3S9eK0s6bZLYQjc5G25tcnKCiTmCGktGV7e+vSFTMOFZa/DPtKOSoJUtWrP43xTFwnpxXV4m8BBpIGDDdZJPyOQ/PEsAJNJMGy9VWvZ6OgOqRUqScCxaDbvkUR55HREonBlRzZqGXJqp5qvPfRyMvPouhCUy5QEZIcqqlIEbA5VPBTH4geWq8DsF43hT0aIZutsXXFcutqo3DGq2G7pi4hxlmpi5zuvaYqK+jWC8ft/EagIXypxyO071JejmLDbKZwiLPyPxOZ4/f/NQqdEICLya9mTZcR9l3/Lr8ofXHF4PjKVCCRE4gXq2x/U9Qvbaw83ZYOgog8c+jutK8sV+Ba8yhMXOEDBoT5pWUaoHv+jglMtyQgMA/80Rh+fxVSXrBQM+xkR+yYJacZtAvzq6k8IBHFGwH66/4jAsviuakFYB4uoKsMJGCQszG67h03erIni4ZVP 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)(1800799009)(186009)(82310400011)(451199024)(36840700001)(46966006)(81166007)(356005)(82740400003)(8936002)(6666004)(70586007)(70206006)(478600001)(54906003)(6916009)(316002)(41300700001)(36756003)(26005)(8676002)(5660300002)(1076003)(83380400001)(4744005)(2616005)(86362001)(47076005)(2906002)(36860700001)(40480700001)(336012)(6266002)(4326008)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: naHdJT3II/afXTJJxrTBXD91JnRb8vb7T5FAvsSO4fNXPzvdXUyOuOQZcOpxeXTumJm9mHFHQ/zX+MYv5jEN9AF7nbyz+pDlfcpSXtREbLxge2pocZOtNkHggryfAFhodxdS+LYJS+XhAqRZC3bbroWdatRK0ygtVyp6UMzI3G8iZZyVGKddQ6d57w61/KWzFmx6DR12CsDy72gjBcOB3LadRp1SpPVDchsvFZLpLURnYTomtYKQD5rXQax3v6NkWHQ/iRr3svL1mVrQgYzFHUFNWStsWSKjf3jCSzmV+6O1vryHuLhJcbGcQFe9owgM1GNXRpTPlfKSskF2SuIDbjCAt64Sml1e/7JzCEy09H5KKSIVjnALpQSi9o3u7YuCptoWfuCuArLFIWEg1YouOAg6xvMnEeYYA5j+yEj4KIHSYuObOMqhnkXO0NB1R3wiJ7NQjLTjpU07Gec00jh787mXgH4+GBtc3pMtt1kSH28JszIWnWZ4bfnFZSA49dwJAi38SuPBzcZv/02IBo0lV9KI8FHSTj1I0AGFSb3j9j12J489A4uCWiHsBknwHLeM8qnWvAXryN2tCzqMAK3hsZ7wtg/6AU5b7YjEVmC2QvroC2LsPI7kU8du92Dy8rwxDHSw9PnTzmBfkVL5+kPQg7KkuhvNCMuWQ39MmkGdp5H2/dx9VKND1RPMWSBxXf/2dwClqxNBEHvTkMZjnC9NuiJ+KJf+RsuTO1j32gaBVYfQ8lCFVH480HMRIFNvmJ5ljnKxiJbUDyXN/TEE2iIDVKc4w6C/zD+KJL2s9Hwv3G99f+sA2k0szcOlpxCQA2mU/RlcU7Q6qtBBh9kl7asXWTvgQ1H+6FmwOt8GiFUDFUYC3G4E0Pv0EzFKYZb2tKZJX+Iya1JlDvzcGeYj91m536ku5LVy0RA51JhpI77bpqE= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:23.2628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ef55158-3bb7-4ed4-1030-08dba8aa96f2 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: DM6NAM04FT006.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR19MB4128 X-BESS-ID: 1693325486-103672-9596-613-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.58.168 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.250471 [from cloudscan22-13.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 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 Tue Aug 29 16:11: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: 13369194 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 9FF8BC83F12 for ; Tue, 29 Aug 2023 16:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237290AbjH2QLw (ORCPT ); Tue, 29 Aug 2023 12:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237402AbjH2QLk (ORCPT ); Tue, 29 Aug 2023 12:11:40 -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 5EA8B1A6 for ; Tue, 29 Aug 2023 09:11:31 -0700 (PDT) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by mx-outbound9-87.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BfP9u7/fUWSuyvaRIskGLgO3C0jW2K5d9akU74G4UnEEAsCs5ydsXRkqyR5T6qLWs4DAETi/oWkJ/f8Z56LykFYlSa3WnO6cP9LlScMV65fBqgwrLrE+Uy5HJuIc2+7AIBJavcgp517NryJTqvLvGZm9SNXCk2aZJ4mrbRDyRmlt+oMHl0WPqH+53BlCo7O3GVLJcgvRaBQoLuTH55RjrjNWv2+n2e8ZFqjPDhb52fFQwJWYNhJUYI4VNiaF41+/pPkEdC6Yu0u4iUXJEzBhfML/euLWASPW9P9oUaRrstPgyVkroGkuzwqf6wGoNBwSpPuZVj4HLXDMqPqkxhJ5ZQ== 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=N73J14S6iVjrMo69kd8oOZfM3yutZXQ05yQBAuFv9Vg=; b=Qz0AQqQQJfe+yoNKv2ZGlzyu8Jzw2lZgS3uCZL/w8nT1BhWXE2DmJpOPAKMQ44thExrO6WjjvyYkIcAg7bV2I9ezRj6oVy1ULdmvSpeH7p56i8iz1wMh3NVaxPttV3urJ1JqesTTA5PvFiLRR/NwzYkRUjZjddTLNlHm3uVQ5RspEi7C7YI24wMTHnQQ5tBrcje9/a86lqNLmYcaphwlkt3nVBPrOAYWw8nqckiiM2nTmePGIMldrbDh7qNVRAsdPUM9pVNW7BKFG4S3/HvMWBlvD+jFUjyqEhJS1JRIbazec0eHfOi4CmFcdFaeOAVJN0xevbrh1U54k6wRmD0toQ== 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=N73J14S6iVjrMo69kd8oOZfM3yutZXQ05yQBAuFv9Vg=; b=pcH+uk2QLcS07REu00w6u9sZNvEcsDN8eboV4LqewoO0AQsoZ3jqF2ACD/VFzIQWZ60EfDcJDnyxquDay/khcbBZpmnZE9AW4AKffxkXqKkoW3i3HBo36Lmr9paBhNkXKPKi1yMW+dFPWpmfV9djnU2tffdHC6mYNwTnmvsBSUE= Received: from DM6PR06CA0040.namprd06.prod.outlook.com (2603:10b6:5:54::17) by MW4PR19MB6823.namprd19.prod.outlook.com (2603:10b6:303:207::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 16:11:23 +0000 Received: from DM6NAM04FT019.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:54:cafe::49) by DM6PR06CA0040.outlook.office365.com (2603:10b6:5:54::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11: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 DM6NAM04FT019.mail.protection.outlook.com (10.13.158.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11:23 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 583ED20C684B; Tue, 29 Aug 2023 10:12: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 Subject: [PATCH 2/6] fuse: Create helper function if DIO write needs exclusive lock Date: Tue, 29 Aug 2023 18:11:12 +0200 Message-Id: <20230829161116.2914040-3-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT019:EE_|MW4PR19MB6823:EE_ X-MS-Office365-Filtering-Correlation-Id: 290ffa24-bb5d-4572-db0f-08dba8aa971d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XxzVWZpldVWO9Z4C+7yVKB5czX2DJTw8FDA+g9vWvndJZkm1Qmc6t/GTDe0TDtrAFqcBNitgjBeOoGECbLAOyjOTmIc1rgMzJlGcFWNdJU60KQ3tiK3tRfP9VEtizxr7ub6vUIz93A5SgxlPdPsw/rlQay2imOWrV1qEgqAYR+TN+9v3zKzXZf/UF/+G8z0iX3QH8wlimLjiXbV6Q9ljgW25sBozhq9npX/mG13GfxZoxnRe+gcOW79AL9PqtoREdZ9+zidv05Tk8sygECgNR6rzan3COkfJPneEMTxWNdYDsQu45FAm9gVnSgdyG0D85L7/GCMN712Glq2fodxUZ5NK9VsfB6Hq/vcjt340L+x5L8HY/BztNA2i1SrSFuKlYjY629iAgbgaGb2HlSi/nnQuImbDtpeX1azK6JBZhahQ4BJHINAk+Low4Yj6FzJUgHwoiFSEFy+dv/aivTxdM9Pe69Gme4rba1WmM+4D6EoFHtJrjK9tobJ9GsHe/djpE0mMAiTOmLnoYyIVGOAhEGh1XJ24kpmROLIlyOLDRV0+pt+TCFktat8ODMPW772gDCcTbEfy9dJ7SIDgq3PaSMhpGJF3V+T/eY9Wknp9QFOKOioZNmWJynowVRjvUCet0yWJrawfb8mz3r+w3oi0UgH0qNjLYbn0LfWjsPCC/uXyvrY/5D0RiSZKS7iISQrCSwU5tUiFV7pVpVDv4jyjyGaHdnJ4xxxKGZ6e5nFUKQ8tMY4ikQ7lwqbB4Njyp2MT 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)(136003)(376002)(396003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(6666004)(40480700001)(82740400003)(86362001)(6266002)(36756003)(1076003)(26005)(2616005)(336012)(83380400001)(316002)(6916009)(36860700001)(5660300002)(70586007)(70206006)(54906003)(41300700001)(47076005)(81166007)(2906002)(478600001)(356005)(8936002)(8676002)(4326008)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JKOE2Mszv4hdnRt825bidQxSB5JtJz5UOzA+DlZHmllpT+rFp284OXHihM0H4U4Qq+tA2MajDH/zaJ7iomPNQJCss6uUI0M6J45LDeUglc+n9rnZRgOOdW2XcDbJQPHfTI1gYJf79yLBDp5Nd9fxNPw/ArSLJJ4T5Yt+yy/4E0C7APy5QwABm3iwAC+ncLVsAK5tKJcWEfL+/nnCrCLyKqvh3PeAC7OiC0Gb8QGXOKOdOujcBvCNii1z6VM6V4vxVieN0+om0QMCduzQGqz5KMhOC68+jPBo4VJErJoBrABvDv3vQvA2WfAOmNHl+sxE9D/v0Uen/kUXkyi7a2J01OB/2hQHcXLWet9/1CPtB/xQ3Vi4mgkcbumM/4AJOrCK4lLwMzpm+mu7byI/R/rjQ+CVAUh9ho9rrypLTQWwXtf4OwiF75is4gplJYRz38P7B03JxlImgVz9I1ufrNIA9msIyd9Z7G4bME7hvikhU2kyvbt9v2Hb2nbu1OmKLtUGn6z5PeUSmoNEa9HMHQ+xuD+0BrTrpUjpmY58YOg9mzKguxw9s/8oDyUxPWS4hBnCp7y9gUpTyeWVhUxpfAlmDtiRvkHsgC+Viu4U5VDLK5L0+qYew9XMDkUdr0J0Z3plz02KDqrPlS8L5SdfZapa8Cycw3g69jKzF14PbAasS1WMRHloB8+0Y7Id184SoZ3oFkoPjCmNYjyrKmB8ULHAaY9BdbdIRkjsNrYBl/e0EQJUfe1snWZ/CwOJbWwCem8GxJG1XN9Nqr2pOtpE6at2Je32EM0fbAaMQ5JtVGAPuNa+JlervyPObnYOzTzs9qhBZ9XiULaukHSpct4XZjJMzDVSzvNIi9USib08JdyS/NxGfn8trM2vJLj2mPzRJakvA8p953dLJMN+fNUKJif26w== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:23.5498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 290ffa24-bb5d-4572-db0f-08dba8aa971d 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: DM6NAM04FT019.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR19MB6823 X-BESS-ID: 1693325487-102391-23029-27-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.56.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkaWxsZAVgZQMMXQxMg82czA0M LANNXAxCI1ydjYNNUwKSnZLDXZKMVSqTYWAO9Jj8BBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250471 [from cloudscan22-221.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 | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b1b9f2b9a37d..6b8b9512c336 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1298,6 +1298,37 @@ 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 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 false; + + /* append will need to know the eventual eof - always needs a lock */ + if (iocb->ki_flags & IOCB_APPEND) + return false; + + /* parallel dio beyond eof is at least for now not supported */ + if (fuse_io_past_eof(iocb, from)) + return false; + + return true; +} + static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -1557,25 +1588,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 +1609,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 Tue Aug 29 16:11: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: 13369196 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 E0FACC6FA8F for ; Tue, 29 Aug 2023 16:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236351AbjH2QM1 (ORCPT ); Tue, 29 Aug 2023 12:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237488AbjH2QMI (ORCPT ); Tue, 29 Aug 2023 12:12:08 -0400 Received: from outbound-ip179b.ess.barracuda.com (outbound-ip179b.ess.barracuda.com [209.222.82.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 956A21AD for ; Tue, 29 Aug 2023 09:12:00 -0700 (PDT) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by mx-outbound44-243.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PIGv2EA08fvo1dHzNvedzXWgH9eN4NJnse+PAtRPDrlAMTrVLutuC0OajS7ph+BYvterityZ/SZrAWQ683RX1CHRfkxccDOJ1+peKbUypLVbZ/j5Vt6FFoPn9toZrrGlAWup4T7ZhKP+P1aTW/H1N7SPA8xRzP2tEP7q8yNw7V/krRmDhP8S3ufwQGv2IA4Z8mHiHznXLcCTZMsW6vw23ut9YsHoSUFXBQ8+c9ylcT9fyifOD9Der05M5IqMc0sqJGlTzdYU0bC+SD643OUYigQElYuFK/rzKw2rWdy130nRRGDwAbWYpQ4btYI9WnC4wVRGgoE+117gjnWIRfScSQ== 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=F7nlRd4WNOPai7CgEpPPc0U8w+BE8B10HSW/FGqzcCs=; b=aZXT8EuBUN+k20dz+S3CXMyGWThnZJakvuve4HvUjYPD/gdD7MeaCWfhu4aJMLg3h3bIGFFZUEY6vfJguxz+EGcjymRwVpofCnZomBRi5tVxjZGP1ZNonXuhjH4fiY5XGhcBaHdtlmsoHLn97QKHv5QeL1ZR0aGK2iDMLA5wUk7saipaQTxl3oDbAr1qN6mQIPoO2l1JEmPqWegNUXNDKP45zU0I/Olv/QoZ5az5p+SbEw3xe9CayXODVdTZr8y+JUHRE+yGT3ia1vEzpbPNOuBp8ZRfr5gXVchDAq/zqtOCZscHev3oWe7c3MCAnErOHfWcexOt1PhTg082Uy+FUw== 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=F7nlRd4WNOPai7CgEpPPc0U8w+BE8B10HSW/FGqzcCs=; b=vsmZtL7mrw+U+sDeVPNoHjxbGsqJSvmUoqLDrLxqFmAeVlrVD44qQTpBcLjDs9pct4pr/iBa36t6ZjY8Z2b5tDIcKOoAVJMhv5cbH5ZJvLhe0GHFJgdo8x7B3glP6elzZ3GJ9kSH3RyOkoX9SipHV5iHKjXShZgKBuyYp0YvGPo= Received: from BN1PR13CA0029.namprd13.prod.outlook.com (2603:10b6:408:e2::34) by MN0PR19MB6067.namprd19.prod.outlook.com (2603:10b6:208:382::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Tue, 29 Aug 2023 16:11:25 +0000 Received: from BN8NAM04FT010.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:e2:cafe::39) by BN1PR13CA0029.outlook.office365.com (2603:10b6:408:e2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11: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 BN8NAM04FT010.mail.protection.outlook.com (10.13.161.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11:24 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 52E0020C684C; Tue, 29 Aug 2023 10:12: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 3/6] fuse: Allow parallel direct writes for O_DIRECT Date: Tue, 29 Aug 2023 18:11:13 +0200 Message-Id: <20230829161116.2914040-4-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT010:EE_|MN0PR19MB6067:EE_ X-MS-Office365-Filtering-Correlation-Id: e2b7e7fd-81e5-4f3c-dc56-08dba8aa97f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RTuYeqLTQ2NbcTzMDvuTkL48VRbesCibxSyyX+WssR1g8XcR2M4hVzI6NgoQXFS0vNw+ytVgGQBw2XHFu4lPo4OMor5KcdZBXcErvI4v/n0HwzrpQ+PrULnKigxrhFq6iCi8R/NqsuY/xWxrImnHmoH+zxtxTVC3e7tkh3JieOVgsiBtImge+Vui/NMtnODBR5p5KlmbpBAC5Q1jA07vYoL5dDqLnc4ROIhamdMyXeZ0+QS8Eotli1IGI82VQzn8gdH2L3GuZTbJr/f33eJNk6UbA/ok+ECEzDKm9KIrtcmsjLAAK7uXxu/Tj+P7gaY7BOiT60iHSGXjMXdK3Jo7A4aRd5yF4MhwFsIiRV/1bsTfo9wFyqO4Gpy1zLltzqatCdL2wtZdVFzLFRti+Emk+AZ1+CrFIKZm9LX01/wsgv1jZ4m6THbarrWCIrb/mK/4/ETICWQp+G2/NY8/lyxrSAwhyy5WvKoQO8wsAD7OK7OHNSPIei3wpazVKOGI8lDkJIIzxDn0bjlTUk5LFIMd3c2JNt9L87dPLVmpy8f9x0dkXVoxg4PGuB8WsVGSuD5iJ4ZoVTJNfQVKZus6Znez5+Ci+8Z9WKxr63pfkLvMRpgFOvEN5Yti7elr2iWUApustsd3YdprExQ/sUsqsAk0QHbPbF+bSSin53i5DdvncxijktDPt0mOs1sgJsRPxk/uH436Bsm5CUVjHTtMaFm0xBGGutq3rpdG8k4K07lJoUy7f1DZ3sl79Sc5UP6Owj1W 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)(346002)(376002)(39850400004)(396003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(36860700001)(41300700001)(26005)(356005)(81166007)(82740400003)(6666004)(86362001)(83380400001)(478600001)(47076005)(6266002)(2616005)(336012)(1076003)(40480700001)(70206006)(70586007)(54906003)(2906002)(6916009)(36756003)(316002)(5660300002)(4326008)(8676002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eGU6z/Qx1IXj0YFKXtaP5RDlfaMQrnPKJPvxwcfJxtnHvIDGD0Yt+Y6dm9SMVd4sv1a5wwl8I9PEkzQ3PCKLyI1FMtAy0AB9tQ0s9KVBk1HRsvhSmnwfd49Vp2mLXoE0DkQrN/OtVMnupfeLke+LpTUF/HZa4Ujf/50aZcY79bwJr3/cUGz5FuR9lu52+68fh3ScsY6tiboma4kiN6SYeG5ZqgkfihLIufaIof7Kp2iQA3VJb3P1EhjYs/mO+ksqrnA50s4iQ1qJ7I7pJPtYn66k94Ndygn8idacCoXFbQBHGX+hfjNKqZ1GNQrEwJrB/VvO++aykl2u5HNBoQpyx3uXjuyPPypk/afhfFouLnI+QiXL4/A1exZjI51CNgha4SUUpQwrMG3YxIpx2ZQSYnF1FUmOo1m4hBJiyypsFN+LIyuXJsejgdeEXSBTUIImMT0DLClKH47yvKD/vmlRUdCqTmM1WzHH4dswafv7k08b0LMXEXFjXQRjUXrjGDlhbEPGDJaWzDMbJwE50TWRTauqQ0B0ape78l0xnhCphlHVTJRmTy8kHCJzXspmVDnrH8dgJ+FBz/BKEfq30zkkAHYyQ8c9VK2Po21N8V+dRReBWBoaZg7TJXy0+e9rhjE61/XW4sGoUHCY1qblSaQw/OHS6YT3s6a2Oojyh0NQzHChle61HczNRAWgzxz5rtK+VHDyMeA2a7/0/wTGDp7RN20Vq/kzLCroI4ueizTm19HcFwYmbDMRJtCqRAG6yXF1oyoVRdwPlkTKT5nhP81ZrOU18SJqTdUoCHMC1TleMNdQcSED8zjj7gV3YSnK4ykA9XfOq5Td+OZBCX6NOnxhYRzeubV+ktlYA6PQSSnl5yQRsIx3g5Pb9xJgVbtVUc37apzxHW9CGLzKdmdI3htU4w== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:24.8767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2b7e7fd-81e5-4f3c-dc56-08dba8aa97f1 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: BN8NAM04FT010.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR19MB6067 X-BESS-ID: 1693325487-111507-24138-750-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.56.44 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkamppZAVgZQMC3VwNg02cwyLT HJ0sjMwMIs2cTc0tTQ0MjIwsDS2NxUqTYWAMc2cCNBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250471 [from cloudscan8-212.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. Cc: Hao Xu Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Bernd Schubert --- fs/fuse/file.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 6b8b9512c336..a6b99bc80fe7 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1314,6 +1314,10 @@ static bool fuse_dio_wr_exclusive_lock(struct kiocb *iocb, struct iov_iter *from struct file *file = iocb->ki_filp; struct fuse_file *ff = file->private_data; + /* this function is about direct IO only */ + if (!(iocb->ki_flags & IOCB_DIRECT)) + return false; + /* server side has to advise that it supports parallel dio writes */ if (!(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES)) return false; @@ -1337,6 +1341,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = mapping->host; ssize_t err; struct fuse_conn *fc = get_fuse_conn(inode); + bool excl_lock = fuse_dio_wr_exclusive_lock(iocb, from); if (fc->writeback_cache && !(iocb->ki_flags & IOCB_DIRECT)) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1355,7 +1360,10 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) } writethrough: - inode_lock(inode); + if (excl_lock) + inode_lock(inode); + else + inode_lock_shared(inode); err = generic_write_checks(iocb, from); if (err <= 0) @@ -1370,6 +1378,9 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; if (iocb->ki_flags & IOCB_DIRECT) { + /* file extending writes will trigger i_size_write - exclusive + * lock is needed + */ written = generic_file_direct_write(iocb, from); if (written < 0 || !iov_iter_count(from)) goto out; @@ -1379,7 +1390,10 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) written = fuse_perform_write(iocb, from); } out: - inode_unlock(inode); + if (excl_lock) + inode_unlock(inode); + else + inode_unlock_shared(inode); if (written > 0) written = generic_write_sync(iocb, written); From patchwork Tue Aug 29 16:11:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13369195 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 B859BC6FA8F for ; Tue, 29 Aug 2023 16:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237411AbjH2QLx (ORCPT ); Tue, 29 Aug 2023 12:11:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237418AbjH2QLq (ORCPT ); Tue, 29 Aug 2023 12:11:46 -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 6CFE01BD for ; Tue, 29 Aug 2023 09:11:35 -0700 (PDT) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by mx-outbound47-9.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vn3ahbIGn4XGoTI3uWBVk1pUccG0d9UHFnlkOIxXTjBILS766JSAQm6jsbx1hPef901RT/iNUW6IJ98ZtdrMafsS1yioe1m5pC10950Y04sDqd4ons7HaYk5Nl95HAxDEYlyiu8ls1EEoBkOS47k9LNUhMnfJEh5e3DfwFIBa1eahfVAzQpXq1h1KTUmUCPDnuW5DEVi8IlL5FcUkyjFrE4zpZuc72w14zbmIXCWFHKtsjD2YqXFImMJRnN35z3TMxf4fsVNpCy7lnVgEMf2Dx+Xl4TCWvRtV7CRAY9mndMBTQI+eMEZiXcEe4rLPj7NIpmYarwdBjgauJNxwjGyMw== 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=wuM4tKUjd5s+yfzROImPt5Hy+IOVlM2RyzqipRv/UBI=; b=Beeywe4Vz/UXNDjS5GFOWuCP5nMdZQoL5wXF5TymMvHIyvfWG8oftlYxjpvCm8ZaWkPvi/yVke1b9C+w1jFbBkzDxGepbt3LEYdHLa6JTvAhNvWRfLKZ2GC9xV8VXODuVwXsE1Tr5vGihL974KZicB/3+diNEhVThEfUK3AA1R4jZfJt9sNmFYqjdEikHjRGCU+dL9olU6SXgdj0JO8QinHWK5bsu5y59B2g8UUKyeZ0VG4u/h//HlPbIyT4tznYFsMc6yGZqWKcgrpnU3Ck2X7aaodiDoxy9xW350+nRuT6TbnjzWTFWYyIkYORMkph8SSzmw+b2wy6ql0WXT2HPA== 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=wuM4tKUjd5s+yfzROImPt5Hy+IOVlM2RyzqipRv/UBI=; b=PFvEwv99jVmdov4d/g09FrT3RbU0OSF20NP7pzvlRD4zbfCHImwiV0U0Bw8yTJ/7R8M558bLo4/QePne42sE55MtLKcyKHV4Ie8GMYqiGL1BY+43QHdCpkB5GkWW2Z8CiMS4ZSRN5HQlKGyyXAbauUnRmwy2gnjcUIOhf5wcP+8= Received: from DS7PR03CA0149.namprd03.prod.outlook.com (2603:10b6:5:3b4::34) by LV2PR19MB5742.namprd19.prod.outlook.com (2603:10b6:408:17a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Tue, 29 Aug 2023 16:11:26 +0000 Received: from DM6NAM04FT028.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::5) by DS7PR03CA0149.outlook.office365.com (2603:10b6:5:3b4::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11: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 DM6NAM04FT028.mail.protection.outlook.com (10.13.159.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11:25 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 4E4C520C684B; Tue, 29 Aug 2023 10:12: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 4/6] fuse: Rename fuse_direct_io Date: Tue, 29 Aug 2023 18:11:14 +0200 Message-Id: <20230829161116.2914040-5-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT028:EE_|LV2PR19MB5742:EE_ X-MS-Office365-Filtering-Correlation-Id: a8edb295-9df1-4a76-db94-08dba8aa984d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YZoZz53HpP6/rL3pg7bDB36BjIeAjTbVwjpknsWgl5wCC7tD3SJRe5pBXWW9UnZz7vwp9AGKMuPLmue0eFhOcntT131Upj+jd3Go+oaTC8CFnmcpqwl5icXfvVQ8CVf5mtbDcn53UUmwjFOkLeTRbBrBjIcN9E5kHSnazVAuEFQ7+yTBtDXALdlzbzGRRpOh9w256juarsw2zH010Tkbc3n33iQ8sEeOa2TpHKQ9ZdXk9H/NlA1/yvX9SRmWuItzQBiQPDMYZndpehCJ4sEeo3rkFvRWunH0DkwZzWoHt8U6n+dHoNubn1HWKtiS7RjLyhHTPsBwDemrH1YjICITGEIKRzEYbKbjdRXkkNB1dDCSpLMC7n1n4+3SE/Yq8bHfZHYe8dOfZ3mmiKFhfhW7124bfBhndXCfgJ998SDgqA9dl4jAOkZW6acvwBNsOrXIJJZ12APcUZoWJotA1BjMcAhnVs+opzcOvFscTa/wwky6Ow17hbLXL1o768Bdf68vzAyziGf+3e8gBBSJKMJRh6Cnd492UhwN9buRHHXBm6e53MNKVp4n4mEFyFo0QsY9ySXyQPBE2fc1VeQ/XAtL1VtHGRGAOsQuDIYifqcEurFBX0bdPI5keBgr/y+t77MKmGZ0f9j+nrFyxmHNI+fiQggxdH4jc71fEuE0VCeQH69F4/oN0MQ+F9zPb6O2O1NnH/B8O+PFW3FKz6I2660mKnnb4X/TnBlWS7u7PcrEX94= 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)(136003)(396003)(39850400004)(376002)(451199024)(186009)(1800799009)(82310400011)(36840700001)(46966006)(6666004)(2616005)(1076003)(40480700001)(86362001)(5660300002)(2906002)(36756003)(41300700001)(8936002)(70586007)(70206006)(4326008)(54906003)(8676002)(316002)(6916009)(356005)(82740400003)(478600001)(83380400001)(47076005)(36860700001)(81166007)(26005)(336012)(6266002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: F01O5I2JgwxwLdfJhDrbJQOV0Tu7B/4Uyar5tKMH2lNvhvoBIaJaYMgKp9SizeVZHnHAko5IusZSE6ZJFJueoxGXjaDlQQsgAcZ/0KrSoXwdoa/v8ZGCmejGhQK+71mqEwxQZ2mQSGc1xQc5nptn1lqsXfY0ooglTDzo/iVhkAFbSuESlqy4tYOa0ytopBjq/2J6t9Gnst1vWwGPzr5kQ8az2ePYWwmzxwnZmg6+BQWh58vUvuWcKMO8DxUdYyBoHsSrO6XKal4YZiPEO3sE2fV65KAafcfegBMwIB0TIcYqsGW717c0+tOQJfcP7jCIvSK9IYJhDJ2tKqia5up+FmHOCLCXvj3OHjqlGcSVjBPvMRcR/IMZJfrOrJPmCyaoPQHRKFxSCuKu36G+AhIwY2zVOndviAcmInyKpComrXsSMzGVO2r3lJkIqaIIEDivPt4uhtmwfgufJw0+HKmjx6oHdK6gDweEpgRdipUIPNqxCJUCcRHQ7342QGnniNjgr7cQM0PbTBJ0dzWEJKr8ny2xV3TrimGtJJhJw9cv5Ht2G4WMpAeVd9mSY7Kk5sIG/i/WW6m8CTycctOBEs1INcMNdhSI8Er9b+gtgswoG6mBumnyLxhMjvrQPOOTtBIAn6Snr2QdPQ4JSItXTrQleG2AsHqMAiD4+iLG5qhFGt6AZmK1mfx7JBbcTm7vo3yCuh0VGczh2imS69QjcEzoYVSGUIDIdTKxocx+B6qBO2nmD/+PvhyH2uCVsN96DjItmugpsibdb/8TOu1PiyBxsnuxq+urV9J3N1Hf/zOxzG/1bhGqD9K5o7jNIPAlx2jDvcZUKclitkM2i9lPN9V3Tp8YLjvX+BSg+u+N/1d1bA1hdltwmxKDarPvere7RRP3iWsKvGbchRD6+KWabu4RBQ== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:25.5422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8edb295-9df1-4a76-db94-08dba8aa984d 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: DM6NAM04FT028.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR19MB5742 X-BESS-ID: 1693325488-112041-11132-321-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.70.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmBsZAVgZQMM3ExMAoxczM1N DEPC3VEIgsElMtk8xMTQzMDS3NE5VqYwFT5zfqQQAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250471 [from cloudscan17-1.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 a6b99bc80fe7..f9d21804d313 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1467,8 +1467,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; @@ -1569,7 +1569,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, @@ -1578,7 +1578,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); @@ -1635,8 +1635,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); } } @@ -2972,7 +2972,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 Tue Aug 29 16:11:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13369205 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 C0492C83F12 for ; Tue, 29 Aug 2023 16:13:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237326AbjH2QM6 (ORCPT ); Tue, 29 Aug 2023 12:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237444AbjH2QMp (ORCPT ); Tue, 29 Aug 2023 12:12:45 -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 B081A1A6 for ; Tue, 29 Aug 2023 09:12:07 -0700 (PDT) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2107.outbound.protection.outlook.com [104.47.55.107]) by mx-outbound17-154.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I5Kc9p2Qe0CxE8fYob4Gg7nvjl+2t7C7gDlB/wU557byMHfWVd+Zz4H8kL0996zS+sVs9+HQ84c7Sb+xbsnrJ40IdVya6Z8Wt7mk+hgh6VGyBlkn5nhlh0deoznVj7B/EiKy35eFHnEPIWGd8CAfZzIFwPqb5fUoanDHsbEG4UHScYPWYHTIrrI9iHx947Rs1SUvj/SH0DD+bs3pHClG5IIMYqhtMtAGXiB7KsF7XO+gcRhbMYp7+k2PAWl77XGVxj8LHKewJb8W+sU3X+RrfczIhQtELN51L7unVqZbd7Nydz4V6yQe6vKm41UEiJIdjjOAyY2KOKg7RQcx9Z8aIw== 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=pg7YH6UttqfeJMxCpLoLYjoxRfR3isuHHZV9AEi8C5c=; b=XAkzG6+/xkVCNktNt+nF36G50mnb4WCSNswTF1Kys4Ai4Qarup1PEkZ/Roaai47NcZZy9XjBPU6hcjKzPDk0znRjlvMTY6NLjuuAqP73QyNic3+PZVxNSxXqWDZbd8kL+yqZrr8j7N2ZozK9BvVOwv9pGxb2wBKPpOQJqx9KHWvM8Q2qFYs+GCnMrukt+Wiu6flQ/RgWypuCkpgGqE+zFi+rnVkbv0aJbxjj6Rgh4MpP8doELlj+xew87qfaAJsi2eBr4vmv3+UBRvV904LZ9CqseqUTZuIUhGNIizT7Lgww/zIqYpA1CsrvJdre/w4LDMlZ/uS+2Adw6u69tsn8EA== 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=pg7YH6UttqfeJMxCpLoLYjoxRfR3isuHHZV9AEi8C5c=; b=XcU2hI3f7yE6Vb3FY26jEY41PFdyckS4dovNvBoXccCWMI5uOnMoPlb1mSgC58El02TNVMoWVs6AAVvMQtvgxQ+bGqz1ngICF98soda2t2bkj8ZL56qh7j5+c1KGWJAcwCvwSTq8JyQZX/KQaIaFO9XuZeRjSxlQXTxXU6yLTms= Received: from DS7PR03CA0198.namprd03.prod.outlook.com (2603:10b6:5:3b6::23) by DM4PR19MB7899.namprd19.prod.outlook.com (2603:10b6:8:188::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Tue, 29 Aug 2023 16:11:26 +0000 Received: from DM6NAM04FT037.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::8d) by DS7PR03CA0198.outlook.office365.com (2603:10b6:5:3b6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36 via Frontend Transport; Tue, 29 Aug 2023 16:11: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 DM6NAM04FT037.mail.protection.outlook.com (10.13.158.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 16:11:26 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 48E8920C684C; Tue, 29 Aug 2023 10:12:32 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com, Bernd Schubert , Hao Xu Subject: [PATCH 5/6] fuse: Remove fuse_direct_write_iter code path / use IOCB_DIRECT Date: Tue, 29 Aug 2023 18:11:15 +0200 Message-Id: <20230829161116.2914040-6-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT037:EE_|DM4PR19MB7899:EE_ X-MS-Office365-Filtering-Correlation-Id: 74521d06-0882-4f1d-f32e-08dba8aa98e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dJkSsPmx94LJHxtDhYoDuRO87XOhFLqdpge+FSEDZF8o4H6EjZT/4q9hFQnriZ63InvY9z59QGbEESiqKwIhaEGQEetZ+6OZadiHiLUOBv3VhN87ePxZt0byeI7r80UMFDUgfQvWpuHsuZulOiyg/uVrUIVO614dqGe68lnnhqtxfYYAkswbA0LXkldL/QAYvWfQpFuexMAIFTLO+okSDY3i5ZZjNH1b15WWfr7KFOgcqnHfrLY61uJuwDwzO9W52pSYcKFAd+PK9N0IE+IccoEorfxHlo7xd+1vhjaeu6mIBIdyHgtTwKqVDHvltb/VaUvpDYLe3SC2rjaLBen0jh6axNxJM0j4cslFfya0DimGXiFZ7zhJYtLgq1FsgVtG2kC/kT3vHvGclluSK6OPkYBrxr70Efo9gCELGKLjpOtXwJTWbJqz5Q/iD+1GDQHOQgGBAzLFAPKLDhqixQoDxEo8FOo3Zzq01zrrOjxOnkjhM3HhonFb27d0iq43SUF/OZREGYlynFrki0eXB36V71S3d5PHEmqdu9IyciJZxFsvEvbIsNe90al5JsI3KjmIIEaeWcz1nZcpoQG5Mjiv/By2EDaF/WYjFAD1axxKS3/FKLs5IX1KrGdvytIEEzcl4d2wPeZDdc3GPzrTfnLBdt62M9shuIZXeNWPv08i9jpmAAdzg6Ma9iLuepbUF4bn7f+1Uny46ztcwQ4zGWjvM3hB5NmARGhcpMXiGIbhiTg5vGaTXG3NM3DrGAHCkxJp 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)(346002)(376002)(39850400004)(396003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(36860700001)(41300700001)(26005)(356005)(81166007)(82740400003)(6666004)(86362001)(83380400001)(478600001)(47076005)(6266002)(2616005)(336012)(1076003)(40480700001)(70206006)(70586007)(54906003)(2906002)(6916009)(36756003)(316002)(5660300002)(4326008)(8676002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: N+laJ+8GyHvp9osKUI9Ep5iL3n5oV2StAnj9PCVY50HwiLju1EuMX70J2Ehuk+51KurG72t5SjoqwETYA8oSn81TUxYY/5ZKx9w+bb6Cy4d3rJZGel04tcF8Ebr07MuCZf/cG4p2eMxpk4VbbSX1w3WRVgGQ1XwpCi3pPEH0HwUjX2p58fwBGUCRvguC+Igggv14RfF6r2GwfyA3L/m3+W0KHD+c8HD7wAge4cek3YEYi14++qbv6l6uYDtMuuo7grl3dFyKyyitTN6+qP/M800zu/itq3l5BRzRoEmjqUkuuuBj+QjctITnvsEYWkrwT4hqR1Ti7Silykor22QUciLPoSZFh/HX/SlfxL8cJDK4M7GVrCXpqd9DSHKjsCJ2zQGh0Yc5Lj+KsAub3ynZ/KEE1/mYR4UwOGab/T3nLjGQ57xkgRq6X0ex/8BGdq5dZ6FfBhCIAHQ9WasulqcoktHLbysnxwTcZJhGFPgAQuainC6SGXn25mWi/vGyq4/n7Y9KIjwSDHcL/gSbT+s8bMEh+z6JomflhcmfubwpvnyASsU/Uo46+4/QD2XK6kye7LcGSCG7ey5DSJG9jcO/a+uma752hW1QzCA4ISWoU76td7pGzBcz0urH7Zk5ff+oXYfoAmwjS3SZ28mMuv+thJWL47guz0htO49d8vuw41xup0dtwF+VXF5dsxVjbhl1PQHaA2KNSgBKlVmXOsitS7y3gzy3M8mvYHiTj+R5++9N/wpERHhyd1csI28tv48NSzndMcaKBHEcY+wtxnqK83S7KaH0RQ03vdzEYiJVA1yNBGNRF05Mf/z/lGcBKJRws39lXLCSzPWuQPW+uadHUsfKyH3T2w5lYN9alWNQf01/IxotFTYV2TTvDyzaDZTw0JHoAVV91xU9toE2AGrvXA== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:26.5520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74521d06-0882-4f1d-f32e-08dba8aa98e7 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: DM6NAM04FT037.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB7899 X-BESS-ID: 1693325492-104506-21430-533-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.55.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibGloZAVgZQ0NDIJDEpxczYMt UwzdzQzNwy1Swp2cTANNEo0cQ00cRMqTYWAEoXh9pBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250471 [from cloudscan14-41.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 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 --- fs/fuse/file.c | 54 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f9d21804d313..0b3363eec435 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1602,52 +1602,6 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to) return res; } -static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - struct inode *inode = file_inode(iocb->ki_filp); - struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); - ssize_t res; - bool exclusive_lock = fuse_dio_wr_exclusive_lock(iocb, from); - - /* - * Take exclusive lock if - * - Parallel direct writes are disabled - a user space decision - * - Parallel direct writes are enabled and i_size is being extended. - * This might not be needed at all, but needs further investigation. - */ - if (exclusive_lock) - inode_lock(inode); - else { - inode_lock_shared(inode); - - /* A race with truncate might have come up as the decision for - * the lock type was done without holding the lock, check again. - */ - if (fuse_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; @@ -1678,10 +1632,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 Tue Aug 29 16:11:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13369207 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 E52A1C6FA8F for ; Tue, 29 Aug 2023 16:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237412AbjH2QNa (ORCPT ); Tue, 29 Aug 2023 12:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237404AbjH2QND (ORCPT ); Tue, 29 Aug 2023 12:13:03 -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 4BCA11AE for ; Tue, 29 Aug 2023 09:13:00 -0700 (PDT) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by mx-outbound44-32.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Aug 2023 16:11:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEwE0gGgH0QYYzgRQZP1s0GZVh2wjQqIGX9jq1ANjJnS6vDI8St3Rl9p8d4rxHUCoYdnnW6CRsFNupGa9ROSIc8+H7NQHKQKomu7SsxDAe8gJD23ERjAtR3YhO5j5ao94WVtv8+6dwUpEelvFTDCbUZ+0upTRiio/qo2SDrYZzeVM3fJ8EwJrFjbVmydb3CbEmIPd1yR3xmoP7xW0pdvbmcNRNQJG9Xovtu7CFqhvKw/5w1Nu7K96NEVnQcVAYr39/Ds4RhKEkzajMDl57nrBevdS2hOyKw57Z7P0+4agml9H5BWGKRddl3ls1E/WXjxbO7rXx8M/WzFJfs5s9K0pg== 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=hnFnqblQNb6xaJe6S57L+6vKMeHDy13WBB0V8qVycpM=; b=KSROWHip7OI4gQwe7Z+K4M5hBLqubeLjFrjbUskhOG1eyBB8VYmS8YBGjcDgsUSGHix9TySbX2BOv4AScm/Lnx+PTLY4YBoc4QG/a+6FcjqsC9AJHPqv4gtjGCJx6EwVkw7eZxGht+VIhyriujLwDyq2OWPQ2LUEkIZsdR1+7iiMmRt94AE/prGk6zw+6ZdDacy7m2GkvAkO9bQx9YlXD+MxSnW+rYMW2zVRrpkguIYT/irX25tAedORvQzGMdQ6+kwCzpKgU2ROdur4qVzeg0hrFiLZx13s6EFfqBp2rb+vd/8vY970NCAQZbYt5iljJqG4ABQYLqzJ06uJEWzbvw== 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=hnFnqblQNb6xaJe6S57L+6vKMeHDy13WBB0V8qVycpM=; b=v0Cold77loY3wVypYm6KIiY0mLyb095KTyBdivj40l2y5iC7aBhLZXHbLjFF2ZfXtFLZgfiGQRPna0F6uP3cB6pkbcNg2XmaZ+cARZ9swlAEamqbT5lADziaVmC6KHlCb3nj4/XnIlwrZ+SuJ0MzTuPy0gpvW1h7r3qmI4MdHxg= Received: from BN0PR07CA0026.namprd07.prod.outlook.com (2603:10b6:408:141::26) by DM6PR19MB4214.namprd19.prod.outlook.com (2603:10b6:5:2b9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 16:11:28 +0000 Received: from BN8NAM04FT064.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:141:cafe::54) by BN0PR07CA0026.outlook.office365.com (2603:10b6:408:141::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36 via Frontend Transport; Tue, 29 Aug 2023 16:11:28 +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 BN8NAM04FT064.mail.protection.outlook.com (10.13.160.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.16 via Frontend Transport; Tue, 29 Aug 2023 16:11:27 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 4453320C684B; Tue, 29 Aug 2023 10:12:33 -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 6/6] fuse: Remove page flush/invaliation in fuse_direct_io Date: Tue, 29 Aug 2023 18:11:16 +0200 Message-Id: <20230829161116.2914040-7-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829161116.2914040-1-bschubert@ddn.com> References: <20230829161116.2914040-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT064:EE_|DM6PR19MB4214:EE_ X-MS-Office365-Filtering-Correlation-Id: e429ebcf-db7e-42c3-8982-08dba8aa99b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lUFUvcASuWYQb+dHxk06peeGq4QMOk4E+TxqAHcLd4y+yaQsYwJ3Zcudhox9s7Qy7S1ca7/1URTo41VvKRTcIDrw7FYKSNT8A7AFwCM8/v50/tOHqgocGTumBwED031DKd2nxojMNBGmAP2FhebXe4XdUBT7KbXS2pwIIOCcTDZCg+pJg/ti9wY25YVgqMY4Qd+iCTFM7v9U+kSbuYRlvMXSXch6t+1GbHLckzAhI6KBsG7BM7W0arJP+bXGQChdwaDWIpzW6KHiWmafDER8kIV6jeBTq9FU1Gi5OE6fWQkE88vmDbKu/DQ9xObSohLiSUmS74DxQnY3YIAN9V0FwqwyfYbeC38TsHXkz1bzTg2hA4ZMCDUZH792vkZA3rWqzGst+fAxJT3DEQPbGfW67TbctxeBP6UPCGRI1L3c2PtB+/0d3vw+o7DTqLWRskAe7B+E6oBlphn6LjLuHYwbykGVXb/12PuTS+E/zHT5HM+7S1REqCZ2FhXWElzVI6zDERogKm2wcOWEr1nZPtxVigUZ+D2G+nQjH1dcWAS8zkVTJMNOcxEIBruokTQ0gJvsTBEnXhex6MC6pAHJ1ebaj2UXHtNIS1cH1B0kajemA+T3qdrjIZbrgf9/S/visT9zz0YIIzAcJn6T4QzB3nug04T3qrUQ/iC/cG0k4u7mBB2TzjLERFH7NgmwrsFJ1utuzQgHVcobqBx1ChS8nIYwWp8PLAjkHVMMFpAzGosQcoDGecrUVsRrQGC3ObbYqyQv 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)(136003)(346002)(39850400004)(396003)(82310400011)(1800799009)(451199024)(186009)(46966006)(36840700001)(316002)(6916009)(41300700001)(4326008)(6266002)(336012)(2906002)(83380400001)(47076005)(86362001)(2616005)(36756003)(26005)(5660300002)(1076003)(8676002)(40480700001)(36860700001)(8936002)(6666004)(81166007)(356005)(82740400003)(54906003)(70206006)(70586007)(478600001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: oMPSj5LLy6ovBq8R+B0EUhfFJML0zhiPWU+1ravAJAn72hlAA5pmzW85i32V+9rvn7CB4SMbFlnN3LMy88tnUOIoy/c4u1vl8SPwdfdncp/3J0mvQ+UdzIu4zhd3R1GuwReRpmBCa0lH7yb3X7Yx+nI/B7saYBE6EzuQvhK6OvgBJp1I0MjnSB9Y3JsQfiZQn418G4fjsr4mmjYGUzDJGOL9X4b209nrDJEd6ef9X2rixi3tq5F5l83KkcbvaQDjt65jZ2x5P9NBApTjoReM5yPSuCIiHPBNAIJhQUEfzsEj6TANkwvcAWWWp+sxEywclHvpeAdKcOOu5/cGOp3QbieFl219W9oXGCppmkOsL7VI8ln4LzDFcZQrttPYBFzv2DgiaT/BoWT29UEvgPE2g5H38fj1Y12JxhhvsYa3tPrt1EvH4jY4wKNIZUfKFBVyOr8n5bZ9+qI7YxC8xKGn+Opzt0nxtAgBSoUHTHiQmurLufDKQeqxTNJ0iAwAyEP7bHZsApn5HU3OoOBPkBLLyI4btKyo21VRk/xGzg31a8+7n4fgL4aFwTwurXrPHnH6+IEvh2amk7FZPMkWM2sT4ZatLJlVXwx3h1tBVLTQMOuYPTvrmc71+0Y7Y4g3aqnTZZIEvj6v7Dimw77XK1L6KgWZfzs/zDgvDhOTDDtMN1ZivTUofrxQQ/Tj5NeKurwvGXfWRMVeDOr/+LX9Prb6CzDfSMd9wHzrEgu15xjfK/dR1bJS8HVMEUu7WxHHjemXX7SY3pXT6f3ItzJ1I7ic24G2mRnNwh1dcC54XvXyUBxIC2eE2eRyjGX7Nr0ll8HMVa+xmtEeqgw0QQNeM5hnWdDWNhvRSbvHUGCHdU5065lR3SI875gVCP3jAiuP9Ufenvix4VI0CwgvMOH6wNlzX/I+TYc08daepu9G9QsMUAE= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 16:11:27.8147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e429ebcf-db7e-42c3-8982-08dba8aa99b4 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: BN8NAM04FT064.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR19MB4214 X-BESS-ID: 1693325492-111296-11308-681-1 X-BESS-VER: 2019.1_20230822.1529 X-BESS-Apparent-Source-IP: 104.47.57.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmJsZAVgZQ0CjNxNAiMTE5MT nN0NTMPMnAyDwxzcTMzDzRwMAs2SxNqTYWAGuKARVBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250471 [from cloudscan17-236.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 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 0b3363eec435..eaafa3fb0e0c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1486,20 +1486,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); @@ -1508,14 +1499,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;