From patchwork Wed Aug 16 14:33: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: 13355313 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 26B41C04E69 for ; Wed, 16 Aug 2023 14:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343648AbjHPOd7 (ORCPT ); Wed, 16 Aug 2023 10:33:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343653AbjHPOdv (ORCPT ); Wed, 16 Aug 2023 10:33:51 -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 8BD3C271E for ; Wed, 16 Aug 2023 07:33:43 -0700 (PDT) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by mx-outbound10-189.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NU1NWYkNaiPO/5CaWQxhEZy0tCKgZmaXMa2/cFWi3dg/g7Jlpx/GAmsCaurkT5nAM6HMEFB83qv8WGB2tp0xR4/K3FBm9p5f9O0Anhs1+RefTgIr8TlNsYIhDbin4hjzyEtDdyqkHT+YC0M1jkq0P7A1II2XmaPjbLIuUr1Bq4g3jHD9lgNT/bGgWZtva/hbM7RMaJKEPq4V8jdt69Xv23L8ipeTKHgupUW1YV4tnebrFmJm7kmEPGXGK7akJmtWb2n9klg9PA/Uux95DouASlQJP9a5301pYQwlhaHbbTcIepmAxjk9O0visGrDeRzBPhup4PGEtjYHIINTnM50ug== 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=6RyHP8MWUcfxnqGv2FS0zugv49b85MMPFbsW99XNlig=; b=UrVYRXdKLighCoAgsSDij/7lVYs76H4rs0+EhyP3yEWSfaTMdzaw1BA+cnUovV/NwhP4kJIwxEbUiRPRVTA/h1qH6lA511ehoy8LaLjcUPx26GzALyhpRhJ/Qx7IPKTKpNaUfItrOSVPFpvRyaByvgt4Bpr1d80xFpzbpekFyNsVhGVsIfQD/SbD7Fj3Q6CWURUFkc91gn+lW9Z648Lv4++HpTHWRg+SM6qv2RMBtER6BzAMdSijq9GvbSAJ0439WRNcljuw1yQUzaxlQTo2VP9ukcrFqVRo6KQPe8Zyi/y4I8psX0h79b9BWUo9er3CT9DZ/Swu7C+glLqbVCnOGQ== 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=6RyHP8MWUcfxnqGv2FS0zugv49b85MMPFbsW99XNlig=; b=yNywD1TaLxbqyIgAch4DG0aS+1oBVi8rW10dDoF8ndrDTkf45QIgI9mMn4+NtZgst+V6ISSXmqsCojdnbqXcK9LDsC6fxjPQToJfxtJ+OL5jvh5hPbawg1L/7XGDXkiKB0AukNh4iDKArqXFxN9RDGK/LiUk0sYDFMaT5ZS9Yek= Received: from MW4PR02CA0008.namprd02.prod.outlook.com (2603:10b6:303:16d::27) by DM4PR19MB7191.namprd19.prod.outlook.com (2603:10b6:8:111::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:33:24 +0000 Received: from MW2NAM04FT039.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:16d:cafe::36) by MW4PR02CA0008.outlook.office365.com (2603:10b6:303:16d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 14:33: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 MW2NAM04FT039.mail.protection.outlook.com (10.13.30.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Wed, 16 Aug 2023 14:33:24 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 4F51D20C684B; Wed, 16 Aug 2023 08:34:30 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Bernd Schubert , Miklos Szeredi , Dharmendra Singh Subject: [PATCH 1/6] fuse: rename fuse_create_open Date: Wed, 16 Aug 2023 16:33:08 +0200 Message-Id: <20230816143313.2591328-2-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT039:EE_|DM4PR19MB7191:EE_ X-MS-Office365-Filtering-Correlation-Id: f9987b7b-c8cb-407e-f5a7-08db9e65bf83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5xH9fP0pjgIso3x2xlF8q1asnhwzaa1b3+GuyNkxT4LsEm+DG9OeeEpX38zsvaMeKoJNhEaEIuumYY9c/d/3rWbATeCuxZJWMrTie+XK43Xox7hFX5F8tCk8kAAx7lS36Fw0WiXb/hA1JDnVnWnUDbbSWpKiY/njCj3cEjRlbBF8EJC2TVIIcxDwp/6Ipoz4CXgAWr0FTxkF9bNQJ0kOdJ+T93eox80vb1qksEJeICXAuaSmlsSGkx8GgpuQtDjaSyU443bdVpyyly5TY/mztCadG+FJUHWyIJ79EKylIVT1MWn9Eli5DcZlCKRv4cF4OXN8b3qjhvyRVl7BtiBb0xpNBqVk1eH5a5gR7WSBuZIMOgZRQtjIFHl3Q9Z9qd7KsL0IEyldDLMqPS/RiTinY++8jvh3ESj4ysjebz7KK3NfhQdBUOyP3zUoVGIXvqiNJkHiCGLO/z37kq2Y+0XsDfUfiLBdtAIj6TPG4+dVC2NUgBTNgL+iyzhfUriTsssmlnE3gMy7q4Gi3e0B6t2CLYFl/SBdBlHaHhUT+JIphzyJMYXnNFBzm6HtpqhCaOclkmaKl8B77slOV/NI5GMULqijRl84GeP8SM6b86oetroqJqpuhqaV9hRI3MwXmc/8rlMUewRRd0FV871wtqSq145NVVOH6M6XR5xJoosuyFI8t1CFVE9te0wc150VKRRlGoELIoFRXcQWlKJaR2WHbTDZ+5/v8tAxD6qqK8RyN6y7Q12JmsJ4yQf+s/dIjr4w X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5sE1VrAbbNd/9F+xYkO9ZLq3iApp+LuZ5xs9PArSYZa9JsBSXiVlTJZ8qpw3ts0jXa8HGdCWA0cCuRrYxmcejArcHnsNdVDDP4W+XVcoo5esBvAmZC/JvrPmH09prSpl8p2ENfL7ubq5WZUMWbksMrA4hxdfafoy5weLAXoQybZlo+z3nlaX3p3uTsMSe/tG37VqgqXfwMthxggmUZl+w+1XCgHbSeY7qks9kvDnMWZrtP3BcB5KyZsyj0KUHwbFG8hNaLO1g5gDdaVvs/FrIK8Ot2BC6/qg6PFUYsyNce3kitaFZz9yN7pDDBF6zyFgdjuYwN1xgKJAww4RpOvyxcRKie+fi02Pv9aF2dNbQB4KGndPBXwntfZgtb9xO2RQdd8XrQdv07M+t/ZI1SO5G9u4NLy79noQsSwXIAhn2k37uyJ6Scc8ExZvG0ytpXvognrO3MZYCgfH6oqQYA7z9Lqv4HYWV/J3DlZxWXaZ48LxPPxsC9jWWiSdZjCt3i92PTkbfVCLVQ9CFaFBqMvqAiAXLtJNfiZHOrlxL1VngN95XEJs0BW3uspTafDKXPEz3uGDUxShzgFizR42ws9gXyojdywrHko+igMXWBpTCnjeI5f6wkqBf7DDAoPssYb8gVrk0+3cw2c4JWqw7u19Dbl8RORNoHqPSU0ObzqdevXXnGwtRUWzZ4Y/KkJCSncfCwUAugl2fgslRMcPHWriFf63ghaXDLSM/VFwQ1bu7VfnwUaLBQDmYitfIWvGY0Kpkq5/FJUDD4T8wohwigUrIaxARx9wbShvHHHot5HHBsqNRcyELk6v3K+ApFB8I7EvTkACgT4L+UvfSdt8ZxLKqAKVjwlvf1TGRCG5XKnM8d6JmbJj5U8Ie606Jsubw4HdJ3AvC5MBTUPXXGokBvsZYjde8ZGuPQl/5QmwqVTeLEs= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:24.4257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9987b7b-c8cb-407e-f5a7-08db9e65bf83 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: MW2NAM04FT039.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB7191 X-BESS-ID: 1692196408-102749-1080-1092-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.70.102 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoamxpZAVgZQMC0pOTXR0MI4Nc 08JSXZxNDSPNkiNdHIwCLJ0sDQLNVEqTYWAO12wolBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan17-27.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 Just preparation work for atomic open. Signed-off-by: Bernd Schubert Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org --- fs/fuse/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 35bc174f9ba2..6ffc573de470 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -613,7 +613,7 @@ static void free_ext_value(struct fuse_args *args) * If the filesystem doesn't support this, then fall back to separate * 'mknod' + 'open' requests. */ -static int fuse_create_open(struct inode *dir, struct dentry *entry, +static int _fuse_create_open(struct inode *dir, struct dentry *entry, struct file *file, unsigned int flags, umode_t mode, u32 opcode) { @@ -753,7 +753,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, if (fc->no_create) goto mknod; - err = fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE); + err = _fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE); if (err == -ENOSYS) { fc->no_create = 1; goto mknod; @@ -879,7 +879,7 @@ static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir, if (fc->no_tmpfile) return -EOPNOTSUPP; - err = fuse_create_open(dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE); + err = _fuse_create_open(dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE); if (err == -ENOSYS) { fc->no_tmpfile = 1; err = -EOPNOTSUPP; From patchwork Wed Aug 16 14:33: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: 13355318 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 B7043C04FE0 for ; Wed, 16 Aug 2023 14:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343665AbjHPOeb (ORCPT ); Wed, 16 Aug 2023 10:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343697AbjHPOeX (ORCPT ); Wed, 16 Aug 2023 10:34:23 -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 70AC5268F for ; Wed, 16 Aug 2023 07:33:55 -0700 (PDT) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by mx-outbound9-97.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mcsWE20DtXGZCxjOaxRK1hUtrxPYmIyxGmTy8SfvF7xUsWSubLUECNXrv11FJOT8nMFZmdSMP/8axdPGuNp276r/r6wTZNeuKyGR+xEJzbyUL+XlxERN6yIKnjpoXb+GWBf2deEK3fM4l3/eY4XCUAriRV3Sb/aRx88XEWV/owTbPSPnMQPvaOcJZ/Rq5N13tdw6I8pKrfNuCoi8WU/U25S+L002nlSfrNGkmygZSrpTdqFzN1hyoYo/FRu1tra2eFw7b2IcZ2x1AuFUygbgJdSADOCgw7rjzQ+sKh5mTaerfpOJu56E38X/SknOn+05B9X1anPmL2MOVjdOtau3Aw== 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=RkcdZm7FcRAp6BhZPL25pKiwNBnwJedyk4R7xzK96LI=; b=mJ91Th76jXmZG9u1Zc5bYOccELSFeFmVe1P7bNuW0G8ZIFVw5JGzfdJNExIJ+bym7FRpb8xumM63lXcfjeCC3ZGAMM1MbuxU+0hh4Eqj5qEv0zvAvqI+ekrKXmEC2Y4vNAF/TGpNQVUJ2DxMfJpBjNTxgeDZpHx4y7JpacgDUzS4s6MdOJDzYsC7IRKVbcRfn5zlKrZYd2LD4LmHo4cAhwb4tgshgyGbzSEmPItHVt7dgqNCJ+MyAvRgHxFv/a9bLmB9mGYzPnx1Lp0dlP8k0GAM++ELsK97wcYsHakLUVNpvM9N93vvQXUBKStaWH3cMOD5SSQg47xMVF1KXGH3SA== 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=RkcdZm7FcRAp6BhZPL25pKiwNBnwJedyk4R7xzK96LI=; b=Adi1yvTNug3NUQIn93LBPMHyeJHY2jaAOC1Yjd4vapyKF8+fROl4kOA+BMtC7y4MqVB8xsbwSOKAtBp4vYOIWZAwvxsWxNn07v5d9pb8lfIBmLAPXn3pcG9uoPwQKwrGBB5GQJXvEsIKgHfaYK3Gc+zkY38Et9CVWxqE/Zp3BT0= Received: from BN8PR04CA0066.namprd04.prod.outlook.com (2603:10b6:408:d4::40) by IA1PR19MB6203.namprd19.prod.outlook.com (2603:10b6:208:3ed::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Wed, 16 Aug 2023 14:33:27 +0000 Received: from BN8NAM04FT043.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:d4:cafe::77) by BN8PR04CA0066.outlook.office365.com (2603:10b6:408:d4::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 14:33:27 +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 BN8NAM04FT043.mail.protection.outlook.com (10.13.160.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Wed, 16 Aug 2023 14:33:26 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id A915820C684B; Wed, 16 Aug 2023 08:34:32 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Bernd Schubert , Dharmendra Singh , Horst Birthelmer , Miklos Szeredi , Christian Brauner , Al Viro Subject: [PATCH 2/6] fuse: introduce atomic open Date: Wed, 16 Aug 2023 16:33:09 +0200 Message-Id: <20230816143313.2591328-3-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT043:EE_|IA1PR19MB6203:EE_ X-MS-Office365-Filtering-Correlation-Id: abc74367-cd16-4e80-f37b-08db9e65c113 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mvn8vqUzuI+htgUOUPsr6zyZQRMFRcK6aa9cQiOsTaUyJcHpuhZmcnmUbBQKSpf8kiFq/pQX8SHt+4z8GK3m5+gHsAMSTu39Ji0tV3ZznWUqejh0TqNBBTIfAcSgUv5niiAbycH62PUukMtc4xDCDgFWD5ynersG/iRCb8566DiPhVifPJX8NhUL8bAKoSUvrGxqlPBtqdHP4BjTkuI2PNlQJFcR6ulSZZOmMZmPQMpU6eu1x2D2Yiqc9iLDjHSelZDuIxNQfNblmg+iMdfpYS93vzrQP+VtVzr8otabzPfH+bnPKLyQVwiYD8dGbPv/0KnVZNvuuiBglPXMwqooecyNiJCQOeYQLYUQc7vJI5SEipxUyK8I2uecEaxUXlstToM1Bxr9sOUZvSph/tFhXGT5jkznZ8mA3S4XC/kxW+Swem3zclws+Nl2xNXBevVgJTqxYxNNKyMNs2NqbvfyTKngIqBchCY2xFmPwjNP8sgBmWwmdBG7aWvBMltE1TF7ghcC+OPNXl3YseAWBClWerVWwbJDO8MJHnbw8L//pAXtI6mxiRf06crFZjxcp2HXoKpLJyEVbPab9MQJUKpYowYOom13rj7dy97iIwZZou31Cl5gbXWJowFy812hfIty7v1ub1NOAHdmnS4LLRpR7SVYN+ZLB4ST2PuU7TfbJUDcW/Ei6XgKTj9iJ3/1Jg6A8aCY8owNxtRiymAGJL9VvnqUGRig2UOPVCUR7vSKhf8OXCFjlVLSTe89ajyvDtX/ X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Nr7eVop94/JNEGGeQYZm4yLD3aBniE6aHDTDfkdv1SB7NHggg0lGmLfS7r4aEPI9W4J8v0111D/Uqc7m0qF/PGJ0o4ssfdniXDXcqfOUvefRn8SpbnwFOh1/ypUHqN47QKa2Jd0S7P9Qh5aYzQPH7TM8LQmXiKGni/v3RW/hsr0krBHHOntb+cn0CUl3xPHfthsLW+rPSWgTEn8XilgPfjzitzKE2mFvqD+nKyD7YL9+fkFC2y1RvuMoWVwBLmOhn1DizOdvynuPXNKS1SdAPANhIQZT0eL528eEHxUng2MKrA+w6/+93PN7cA52GOuA33ix4t9rzhyU4D2JDEhOe0SROGpvc3eHc14WC5Ihq4YIHrbKpiqYzCzCg400LAXmz4q8YB/v5lTrJdJifM4eDFVzVRoDAcs2/ZoX8HnokUH6lJZ0Cpi0xjxRgfkQVRjTSgmxWzScJtXNJozTESMWiPQWif8Vme1pDOO8hnRBxrN82HK9XJO5nTOUh/m6MCtHpIzxZOU2GVoG8RsTQ0cHS2CxQO8k77/iEyTvVXNht0ajfyoGpGIE2LCEUdQqNDKvVs0H6kKfsajPjBtlSYXh1azTFSGY39d6b54tVnbzld6x7j8ioHcXwveUlBoz0ejifdj86j4vsdAL3yiLjPCz/PvzyRkRvtvmlOy0mg5Wj5IaFpL6V3eg4sYjRF4OKRBzbFaK/F0yakKe4kkK57lbJAbcxdwTcIJRtJBFfcyvuYSbrEuqe+mLGb63PyZoaZINpXZm57vx1zPZ0e0VWjLcqtP4ml/MWLIV2eXNMYAe3T0EZ3tuoWgP1h8Q9MbSWCqdJzasHUicM0ioRLt5S4vBd+v9l/nAcEaj3jFYLPmFDdGpmczhyRhFC8TpRo3MDTvEO8fVzTGpUZObxXoph0JMl5KFD2db1ZhniTAt+K6SndET+Z+laJ70VyuxbKIvAy/i2xq21Bo8m5PK0uhFUeZL67gwcJ+SS7O3ZvK8Yx6Kwi2Vx+0KF70lUcsTgq+8p3W8 X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:26.9690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: abc74367-cd16-4e80-f37b-08db9e65c113 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: BN8NAM04FT043.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6203 X-BESS-ID: 1692196410-102401-12607-11504-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.51.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVhbmZiZAVgZQ0NzM3DLZyCwx1T jVNMXA2CjFyMTAOCXRPMXIzMzQ3MxQqTYWAJdaPbNBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan18-236.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Dharmendra Singh This adds full atomic open support, to avoid lookup before open/create. If the implementation (fuse server/daemon) does not support atomic open it falls back to non-atomic open. Co-developed-by: Bernd Schubert Signed-off-by: Dharmendra Singh Signed-off-by: Horst Birthelmer Signed-off-by: Bernd Schubert Cc: Miklos Szeredi Cc: Christian Brauner Cc: Al Viro Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org --- fs/fuse/dir.c | 222 +++++++++++++++++++++++++++++++++++++- fs/fuse/fuse_i.h | 3 + include/uapi/linux/fuse.h | 3 + 3 files changed, 226 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 6ffc573de470..bb68d911fd80 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -380,7 +380,6 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name if (name->len > FUSE_NAME_MAX) goto out; - forget = fuse_alloc_forget(); err = -ENOMEM; if (!forget) @@ -724,7 +723,7 @@ static int _fuse_create_open(struct inode *dir, struct dentry *entry, static int fuse_mknod(struct mnt_idmap *, struct inode *, struct dentry *, umode_t, dev_t); -static int fuse_atomic_open(struct inode *dir, struct dentry *entry, +static int fuse_create_open(struct inode *dir, struct dentry *entry, struct file *file, unsigned flags, umode_t mode) { @@ -770,6 +769,225 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, return finish_no_open(file, res); } +static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, + struct file *file, unsigned flags, + umode_t mode) +{ + int err; + struct inode *inode; + struct fuse_mount *fm = get_fuse_mount(dir); + struct fuse_conn *fc = fm->fc; + FUSE_ARGS(args); + struct fuse_forget_link *forget; + struct fuse_create_in inarg; + struct fuse_open_out outopen; + struct fuse_entry_out outentry; + struct fuse_inode *fi; + struct fuse_file *ff; + struct dentry *switched_entry = NULL, *alias = NULL; + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); + + /* Expect a negative dentry */ + if (unlikely(d_inode(entry))) + goto fallback; + + /* Userspace expects S_IFREG in create mode */ + if ((flags & O_CREAT) && (mode & S_IFMT) != S_IFREG) + goto fallback; + + forget = fuse_alloc_forget(); + err = -ENOMEM; + if (!forget) + goto out_err; + + err = -ENOMEM; + ff = fuse_file_alloc(fm); + if (!ff) + goto out_put_forget_req; + + if (!fc->dont_mask) + mode &= ~current_umask(); + + flags &= ~O_NOCTTY; + memset(&inarg, 0, sizeof(inarg)); + memset(&outentry, 0, sizeof(outentry)); + inarg.flags = flags; + inarg.mode = mode; + inarg.umask = current_umask(); + + if (fc->handle_killpriv_v2 && (flags & O_TRUNC) && + !(flags & O_EXCL) && !capable(CAP_FSETID)) { + inarg.open_flags |= FUSE_OPEN_KILL_SUIDGID; + } + + args.opcode = FUSE_OPEN_ATOMIC; + args.nodeid = get_node_id(dir); + args.in_numargs = 2; + args.in_args[0].size = sizeof(inarg); + args.in_args[0].value = &inarg; + args.in_args[1].size = entry->d_name.len + 1; + args.in_args[1].value = entry->d_name.name; + args.out_numargs = 2; + args.out_args[0].size = sizeof(outentry); + args.out_args[0].value = &outentry; + args.out_args[1].size = sizeof(outopen); + args.out_args[1].value = &outopen; + + if (flags & O_CREAT) { + err = get_create_ext(&args, dir, entry, mode); + if (err) + goto out_free_ff; + } + + err = fuse_simple_request(fm, &args); + free_ext_value(&args); + if (err == -ENOSYS) { + fc->no_open_atomic = 1; + fuse_file_free(ff); + kfree(forget); + goto fallback; + } + + if (!err && !outentry.nodeid) + err = -ENOENT; + + if (err) + goto out_free_ff; + + err = -EIO; + if (invalid_nodeid(outentry.nodeid) || fuse_invalid_attr(&outentry.attr)) + goto out_free_ff; + + ff->fh = outopen.fh; + ff->nodeid = outentry.nodeid; + ff->open_flags = outopen.open_flags; + inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, + &outentry.attr, entry_attr_timeout(&outentry), 0); + if (!inode) { + flags &= ~(O_CREAT | O_EXCL | O_TRUNC); + fuse_sync_release(NULL, ff, flags); + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); + err = -ENOMEM; + goto out_err; + } + + /* prevent racing/parallel lookup on a negative hashed */ + if (!(flags & O_CREAT) && !d_in_lookup(entry)) { + d_drop(entry); + switched_entry = d_alloc_parallel(entry->d_parent, + &entry->d_name, &wq); + if (IS_ERR(switched_entry)) { + err = PTR_ERR(switched_entry); + goto out_free_ff; + } + + if (unlikely(!d_in_lookup(switched_entry))) { + /* fall back */ + dput(switched_entry); + switched_entry = NULL; + goto free_and_fallback; + } + + entry = switched_entry; + } + + /* modified version of _nfs4_open_and_get_state - nfs does not open + * dirs, fuse doe + * nfs has additional d_really_is_negative condition, which does not + * make sense as long as only negative dentries come into this function, + * see BUG_ON above and missing revalidate patch - but needed if + * we are going to handle revalidate + */ + if (d_really_is_negative(entry)) { + d_drop(entry); + alias = d_exact_alias(entry, inode); + if (!alias) { + alias = d_splice_alias(inode, entry); + if (IS_ERR(alias)) { + /* + * Close the file in user space, but do not unlink it, + * if it was created - with network file systems other + * clients might have already accessed it. + */ + fi = get_fuse_inode(inode); + fuse_sync_release(fi, ff, flags); + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); + err = PTR_ERR(alias); + goto out_err; + } + } + + if (alias) + entry = alias; + } + + fuse_change_entry_timeout(entry, &outentry); + + /* File was indeed created */ + if (outopen.open_flags & FOPEN_FILE_CREATED) { + if (!(flags & O_CREAT)) { + pr_debug("Server side bug, FOPEN_FILE_CREATED set " + "without O_CREAT, ignoring."); + } else { + /* This should be always set when the file is created */ + fuse_dir_changed(dir); + file->f_mode |= FMODE_CREATED; + } + } + + if (S_ISDIR(mode)) + ff->open_flags &= ~FOPEN_DIRECT_IO; + err = finish_open(file, entry, generic_file_open); + if (err) { + fi = get_fuse_inode(inode); + fuse_sync_release(fi, ff, flags); + } else { + file->private_data = ff; + fuse_finish_open(inode, file); + } + + kfree(forget); + + if (switched_entry) { + d_lookup_done(switched_entry); + dput(switched_entry); + } + + dput(alias); + + return err; + +out_free_ff: + fuse_file_free(ff); +out_put_forget_req: + kfree(forget); +out_err: + if (switched_entry) { + d_lookup_done(switched_entry); + dput(switched_entry); + } + + return err; + +free_and_fallback: + fuse_file_free(ff); + kfree(forget); +fallback: + return fuse_create_open(dir, entry, file, flags, mode); +} + +static int fuse_atomic_open(struct inode *dir, struct dentry *entry, + struct file *file, unsigned int flags, + umode_t mode) +{ + struct fuse_conn *fc = get_fuse_conn(dir); + + if (fc->no_open_atomic) + return fuse_create_open(dir, entry, file, flags, mode); + else + return _fuse_atomic_open(dir, entry, file, flags, mode); +} + /* * Code shared between mknod, mkdir, symlink and link */ diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 9b7fc7d3c7f1..4e2ebcc28912 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -672,6 +672,9 @@ struct fuse_conn { /** Is open/release not implemented by fs? */ unsigned no_open:1; + /** Is open atomic not impelmented by fs? */ + unsigned no_open_atomic:1; + /** Is opendir/releasedir not implemented by fs? */ unsigned no_opendir:1; diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 1b9d0dfae72d..ee36263c0f3a 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -314,6 +314,7 @@ struct fuse_file_lock { * FOPEN_STREAM: the file is stream-like (no file position at all) * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE) * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode + * FOPEN_FILE_CREATED: the file was indeed created */ #define FOPEN_DIRECT_IO (1 << 0) #define FOPEN_KEEP_CACHE (1 << 1) @@ -322,6 +323,7 @@ struct fuse_file_lock { #define FOPEN_STREAM (1 << 4) #define FOPEN_NOFLUSH (1 << 5) #define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6) +#define FOPEN_FILE_CREATED (1 << 7) /** * INIT request/reply flags @@ -572,6 +574,7 @@ enum fuse_opcode { FUSE_REMOVEMAPPING = 49, FUSE_SYNCFS = 50, FUSE_TMPFILE = 51, + FUSE_OPEN_ATOMIC = 52, /* CUSE specific operations */ CUSE_INIT = 4096, From patchwork Wed Aug 16 14:33: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: 13355315 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 96313C04FDF for ; Wed, 16 Aug 2023 14:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343658AbjHPOe3 (ORCPT ); Wed, 16 Aug 2023 10:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343681AbjHPOeM (ORCPT ); Wed, 16 Aug 2023 10:34:12 -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 520402712 for ; Wed, 16 Aug 2023 07:33:54 -0700 (PDT) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2175.outbound.protection.outlook.com [104.47.73.175]) by mx-outbound14-182.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zrcdr2l8LyBS+t5PpXsJcEyG5cjfTGC8PZ3GW7mYR2QMsIGUsrU6fI0kj4jO6dcnFRstigADElcknDJUMA7rF7O/Z76X5N32Afk/BQ8dTxW5m5Aht0WA8d9khTgNTCTQRJcpu/vcTWM+fZxPJr+JYhSLtneZQrYKFhV0fQz6glp5ZcOFVdC1wKAZdze8JDCNbMISvauvPG7zUrslfjM1+qYcuvmQGTB21enIZLQ2tG/xmf/gFl3gS0z5+7z2k609yWZFoCaDvn+LC7FefvCjCfJgm61LwevY3BdAg3rPRisfnFm8J8CG2s+KKIK/MjQXWf0/Ihm5n+JqI6CCZqUILA== 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=3xs9ob3NEsMhQYyWRri+W4H0xC1LssKGJIOnEZa2Ans=; b=ZWZwp7Z+cGZE/4XY04z6fAo4pmgURpTNMGrSlgn92B8JGFmGoeEeEPyopV6587Bvs0wRbkdU6ENaNBnccn/ek0z3jVLQQ1Lm4ACEg4ayuS7z6bVCjDlYmhaXqR8zQJnJ0qA40nuQLMXQnFb3BxaK2K/wygrBx5in5qGXK1xa7CgQY370w6LFX/SU3vzRFR3Kbw+He0BdToonsaSlwrgNiQZ3xAys3ZWm8vbKAhGYh3lFKAtuouTwHiPAyZ4F7Q/xLTrEqPw58yUZdYNYUXd2py+jpBDAJksPBZnyVPoopVABEGbreY7sk6K5oK5ETEVVgvJoHzC/xpPCly8Mo0aWjw== 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=3xs9ob3NEsMhQYyWRri+W4H0xC1LssKGJIOnEZa2Ans=; b=ztxeI2HvSgy13Co/tbOdH0OOMgUN47uVMsdqlyxLMEZ+KvC/z+DetM6QiQcATxDD3QDmrBdXWGnXaY7A1XF5gybR1huyIfX2CUDHQ4ZYkkeEw/Mih94fq2q2YIWHchnM1dLGHmRpxcP1gFrSbSFXIouZ5lgPTex7JG+kQsu4BNI= Received: from BYAPR21CA0019.namprd21.prod.outlook.com (2603:10b6:a03:114::29) by CY5PR19MB6220.namprd19.prod.outlook.com (2603:10b6:930:27::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:33:29 +0000 Received: from MW2NAM04FT025.eop-NAM04.prod.protection.outlook.com (2603:10b6:a03:114:cafe::be) by BYAPR21CA0019.outlook.office365.com (2603:10b6:a03:114::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.5 via Frontend Transport; Wed, 16 Aug 2023 14:33:29 +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 MW2NAM04FT025.mail.protection.outlook.com (10.13.31.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Wed, 16 Aug 2023 14:33:28 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id AB32120C684B; Wed, 16 Aug 2023 08:34:34 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Miklos Szeredi , Bernd Schubert , Christian Brauner , Al Viro , Dharmendra Singh Subject: [PATCH 3/6] [RFC] Allow atomic_open() on positive dentry Date: Wed, 16 Aug 2023 16:33:10 +0200 Message-Id: <20230816143313.2591328-4-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT025:EE_|CY5PR19MB6220:EE_ X-MS-Office365-Filtering-Correlation-Id: c7107119-3306-486c-817e-08db9e65c21a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WyQMjfzh067XKbhzFiTugIkAQVZ8F1iqjx5+wo8B3ecqO2qjcuBmGjJTrycrfVry4oEPoFoTAhPAOk2YC/8l+zrIiSc2DD52OoBsEBddX9nlNwMuDP0iaC0zkfW+CzBdSZ18ojrsPJzo1Az4HM42sKKv8XA1Y7dUn47P15wGHhAnyk4m7AgZvbOUCYOUfBab4jf4QdpEBackoxZlQ3th7Smfwy0Yy1Hk6BIru0nl2b33rkdNpURoySKc3ZHqgY2bhUvX1M/tCfv3pXSWdHsj6ocGYwWNN4xlf7rQsQwGETFpYi6R0BoWar4pxgfsSOQrlfjf2wjBmDDZJ4JjYbG3LAgc3BLPbv+5y0EM2WqiESvB6C1X252x/Pleb8VbFu2qbdr0l0iZH7ZnkwW1gs1lTGcfZMtE4+SB2WF6we6rPSN2XjWnedIm6f3iYltFuk2WyePKImIsySOBlkxgIqjkmQQF00ekOfrb2uribsVt1E0EitfBZVb1lRNL5wXhobP2kgX7aQZWanscwozBo3Psr2dWpcWrAQTKlkwCQ02HtosJHpaaJuVvLdtSIk+edcUmS6ZiHTI01Ltt+qrdLnex9GjxZz+D6hwUtp6hQ24a4wTung1OgfW3pXQKyoHZKVhPJc/hrHE2MfH1ZCrGBKp+7CB84zCxk9ypFPE3AGk/gAF0PkuBjfMQBX1rE/nXKfkmpIicpruZQFqcil52Y4NQHuq2ns42uaSdGB1TRGMbUyzP7W8+e4TMV6cSSc4pA9lB X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: k+ZwH8WwMpqiBkJ3T873PsFrINdOk1dccBGhYcW9GsMMp0s3i2tgeGTIHxhicfWlnxUAs7QRqn2ow78TLnt+gdsOtHzAbLAJTt+8oNWywTsKKDUVzeFoUKXbrcbA/Sxp7IyyYDxmTGxqz3fmMKz9yp2VYONzuHY1/03aNJyUkni6n7Yz4UAwbaJFcJbiKZQjDOrHluo7CqQz46oWang33saFQ8Dbi4QfUw3P202AlRDKUkBOHU2tyQPUlMyBwf/7ZZf7JQreyEEeQHpm56dpnWgEqcv2B3Ofqo3B00YWHXu3yN/ypVOekEa1jiwM0krBv5QB0FpzCsuOUx2wgMwevjHSaGl+lLGH8ODaQGMzr/p+qoCg4vGCddzm5/wZd02BvorE+vhnULiYBF6mBAkcAVIvM6FNzoMSuq4knhYIrbhCkYHLsybi6uFuSolvfGX0tlfG5tq9Iayq8iSBC2xO66P3A56sC1UZSWFG7dLqEPdnoWy8R5Vuj3zuFG6ejtWk3IpIk4Ww9VZGi/wF+GHhbvgiuQfNWSZMyBBnyP3cz5yodgxoLQCbioIOLtL09ulK+a2v5pNMRKHWRJ1fGk9uU4ITcOTyZeEILXfH8iNAZDAHf7pKGekVEqYZ4E0AXgMyVJZ8ARXMBCnCwhWwRRsD5SwuunHa8Rb3YbDvwnKsh/80Ryn5uwrEZGIwYzl8Fp2pFhPQww0rdy4vLg1qODWypUHnKetjMZTx0I1cgpVHWzLfzn+JT7OvA9ez9SsSQTAFhi1ljUeRu/3EE59348YmM9hJXbc7VHVlOXMM7XOMRZZKUuqY5NtnpTJo607PFpf0Ha9f6a6NED/QvBhe0r1YdGS0vSxMoUXP/LAoSPG/ALidEoXpU2My9QDiDOKaiP3bzu3/T0o+xutxjJFIXdR0Auc/5IhJUeCAyh0jqxg+prvVBjg0DaH3ELSvwoOMPvyobtWFY1fydz9RkCITIu/WrCmc9NhAVpjFmnJKSTEeH6cGnAmaNlWn0uMmrlPggM6D X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:28.7522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7107119-3306-486c-817e-08db9e65c21a 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: MW2NAM04FT025.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR19MB6220 X-BESS-ID: 1692196413-103766-26829-915-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.73.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYGphZAVgZQMNHA0NLS1NQsLc XUNMUiOdXQIinZMNkg2SA12cg01ThFqTYWANhWW1FBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan11-117.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 From: Miklos Szeredi atomic_open() will do an open-by-name or create-and-open depending on the flags. If file was created, then the old positive dentry is obviously stale, so it will be invalidated and a new one will be allocated. If not created, then check whether it's the same inode (same as in ->d_revalidate()) and if not, invalidate & allocate new dentry. Changes (v7 global series) from Miklos initial patch (by Bernd): - LOOKUP_ATOMIC_REVALIDATE was added and is set for revalidate calls into the file system when revalidate by atomic open is supported - this is to avoid that ->d_revalidate() would skip revalidate and set DCACHE_ATOMIC_OPEN, although vfs does not supported it in the given code path (for example when LOOKUP_RCU is set)). - Support atomic-open-revalidate in lookup_fast() - allow atomic open for positive dentries without O_CREAT being set. Changes (v8 global series) - Introduce enum for d_revalidate return values - LOOKUP_ATOMIC_REVALIDATE is removed again - DCACHE_ATOMIC_OPEN flag is replaced by D_REVALIDATE_ATOMIC return value Co-developed-by: Bernd Schubert Signed-off-by: Miklos Szeredi Signed-off-by: Bernd Schubert Cc: Christian Brauner Cc: Al Viro Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org --- fs/namei.c | 25 +++++++++++++++++++------ include/linux/namei.h | 6 ++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index e4fe0879ae55..8381ec7645f5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -858,7 +858,7 @@ static inline int d_revalidate(struct dentry *dentry, unsigned int flags) if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) return dentry->d_op->d_revalidate(dentry, flags); else - return 1; + return D_REVALIDATE_VALID; } /** @@ -1611,10 +1611,11 @@ struct dentry *lookup_one_qstr_excl(const struct qstr *name, } EXPORT_SYMBOL(lookup_one_qstr_excl); -static struct dentry *lookup_fast(struct nameidata *nd) +static struct dentry *lookup_fast(struct nameidata *nd, int *atomic_revalidate) { struct dentry *dentry, *parent = nd->path.dentry; int status = 1; + *atomic_revalidate = 0; /* * Rename seqlock is not required here because in the off chance @@ -1656,6 +1657,10 @@ static struct dentry *lookup_fast(struct nameidata *nd) dput(dentry); return ERR_PTR(status); } + + if (status == D_REVALIDATE_ATOMIC) + *atomic_revalidate = 1; + return dentry; } @@ -1981,6 +1986,7 @@ static const char *handle_dots(struct nameidata *nd, int type) static const char *walk_component(struct nameidata *nd, int flags) { struct dentry *dentry; + int atomic_revalidate; /* * "." and ".." are special - ".." especially so because it has * to be able to know about the current root directory and @@ -1991,7 +1997,7 @@ static const char *walk_component(struct nameidata *nd, int flags) put_link(nd); return handle_dots(nd, nd->last_type); } - dentry = lookup_fast(nd); + dentry = lookup_fast(nd, &atomic_revalidate); if (IS_ERR(dentry)) return ERR_CAST(dentry); if (unlikely(!dentry)) { @@ -1999,6 +2005,9 @@ static const char *walk_component(struct nameidata *nd, int flags) if (IS_ERR(dentry)) return ERR_CAST(dentry); } + + WARN_ON(atomic_revalidate); + if (!(flags & WALK_MORE) && nd->depth) put_link(nd); return step_into(nd, flags, dentry); @@ -3430,7 +3439,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, dput(dentry); dentry = NULL; } - if (dentry->d_inode) { + if (dentry->d_inode && error != D_REVALIDATE_ATOMIC) { /* Cached positive dentry: will open in f_op->open */ return dentry; } @@ -3523,15 +3532,19 @@ static const char *open_last_lookups(struct nameidata *nd, } if (!(open_flag & O_CREAT)) { + int atomic_revalidate; if (nd->last.name[nd->last.len]) nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; /* we _can_ be in RCU mode here */ - dentry = lookup_fast(nd); + dentry = lookup_fast(nd, &atomic_revalidate); if (IS_ERR(dentry)) return ERR_CAST(dentry); + if (dentry && unlikely(atomic_revalidate)) { + dput(dentry); + dentry = NULL; + } if (likely(dentry)) goto finish_lookup; - BUG_ON(nd->flags & LOOKUP_RCU); } else { /* create side of things */ diff --git a/include/linux/namei.h b/include/linux/namei.h index 1463cbda4888..675fd6c88201 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -47,6 +47,12 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT}; /* LOOKUP_* flags which do scope-related checks based on the dirfd. */ #define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT) +enum { + D_REVALIDATE_INVALID = 0, + D_REVALIDATE_VALID = 1, + D_REVALIDATE_ATOMIC = 2, /* Not allowed with LOOKUP_RCU */ +}; + extern int path_pts(struct path *path); extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty); From patchwork Wed Aug 16 14:33: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: 13355316 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 67AF4C41513 for ; Wed, 16 Aug 2023 14:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343655AbjHPOe3 (ORCPT ); Wed, 16 Aug 2023 10:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343675AbjHPOeK (ORCPT ); Wed, 16 Aug 2023 10:34: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 58CEF2715 for ; Wed, 16 Aug 2023 07:33:54 -0700 (PDT) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by mx-outbound10-11.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LA8/ns7u4T0c08E9VInPqS0DtTS4Y1PAOkDz8BcqSWxFqaoUEOzc04YhDdtZKaFCcDexEJIOTuQFZbDNpW1hCl1g//9iMSsUMjeI3W4JqNbZUqDAI7TUhpVTruy39BwZhtTJZ3bUoVpart1qb02BFMf4lSvyE2xhq+DeSiWirljYsNVX9gjdFA5CcPUUFEQ8zXsE48VxQA4BIJlG6qR7S3IYKF6jV1J3qvNP9TUWvRYn+Xodh5Rq9RrmQmS3LfxFR/nkxLAXF2GMR0IscZfN7bPcfWbQ4RTJdHm6tqQuEm4Dw4AB7ayHnW3jrP3xKCagvUQ9rBBv8Nt1wSRq1/0AbQ== 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=sViZTQPtLMzKO0no/8MkkD59+kLqtQUdq5qBlCKaXvo=; b=XIdupKgCPP1AI8KKfJXhBSWRZfvwksHXdugEE0+Z+fVULHojT6d8eAvlvY1MgdgGG74UxLeb4y3KSqVOHWF/2bMptdcCllSqhjWqz0+D+jTSmSbMCLCpF2nfrdM4rvysdumKRTIxbuaPCeyK8J8yE6vuE4QfZHOjVOvz+HXpBPsprGo9Z5VGBhPhEPf1mpHxDDP81VE7NMFzlX7iVsitkK7apn4+M2oIGeD6uwzlbmtscDYsRxCKG/M4AMpRYTY46SBVCFbk2tRH4uhZ0BYB4Kw34CX8/n6Y+rrUOl0WWl3+sYXKub9XJOAKbOim05JN+jrBGyNr1Ki2K9DjCjvMaQ== 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=sViZTQPtLMzKO0no/8MkkD59+kLqtQUdq5qBlCKaXvo=; b=mSsDAf0KcPqIWQaQT7Tic3mdY4XZxlxw9r7FyrSjHKLhQD20S/7T8mWeXs/I36w8DWoEZ3rasupVPIf5oT1weAnA9tbIeJmxyaRYA6+7nv7DJZ5c8L9lZZVnyZWkg3cfReusiW1Q7CXaiR3yJBhXUPYkjQtWPXqYegtm/V6P9gk= Received: from DM6PR03CA0052.namprd03.prod.outlook.com (2603:10b6:5:100::29) by PH8PR19MB6812.namprd19.prod.outlook.com (2603:10b6:510:1bf::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Wed, 16 Aug 2023 14:33:31 +0000 Received: from DM6NAM04FT006.eop-NAM04.prod.protection.outlook.com (2603:10b6:5:100:cafe::8e) by DM6PR03CA0052.outlook.office365.com (2603:10b6:5:100::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 14:33:31 +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.6699.17 via Frontend Transport; Wed, 16 Aug 2023 14:33:31 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id D07F420C684B; Wed, 16 Aug 2023 08:34:36 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Bernd Schubert , Dharmendra Singh , Horst Birthelmer , Miklos Szeredi , Christian Brauner , Al Viro Subject: [PATCH 4/6] fuse: Revalidate positive entries in fuse_atomic_open Date: Wed, 16 Aug 2023 16:33:11 +0200 Message-Id: <20230816143313.2591328-5-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM04FT006:EE_|PH8PR19MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: bde91da7-eec1-4a5b-812f-08db9e65c370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8NXQU9U0xdZESdZaqZ5f890paddp0jVTCnVMR203gytVoR0YHdf1C00gyRfOlQhnqMHP7GymgFWCzWZvkYf2WBk/30AAJZu5KSJMmtlQj2De6HA+eXceZaoArfaHc5kcDF9/+uBxQ0oam7shbbTPzTuhYD8zhSElfdCtpiCADPgDlApN7/tLFXREZUPhE8zCEgEPNnDf9BsDjiabrKcd4B0YJiLxHBTBmjfSo0zQvQDkq4u/3jSBjJzA/Qwt7cAysYpr6ER9s8qmZpheuEHFP3VJ4xbbAUOVEoC4lVL4a3znkqOuiwpZWwgXNtjq2dGc1yMlNiY2wJiL7q23UaYV1Oa3x4605rBlc9mAkOsSCipt4qas0VvZ2TQcYz504ZzlRHnGwTrhyUfpCkqL1hmmqxLcMu6od/7N30+/PK8LAkHUwNii6+ubCD/2/s4PYOHMbKpOX/1B1vA2OIopY4qAUhOTp0z1K3hhm+fjqwALd2kZcxT5JOxfEcQCrSKgVWvG/X0PZ6l+UsXisDL6ulMbW8feVd00dAvZWj8PPbO3JL3qGaWan6KIuaFXCTPAQC6i7tuFwM48d6cuhlDuWfHYwNq73NTKTG+aCud8H7OVT0qUJ+9M6cjqQGtwiCWnr3lVulbJcedPYueaDtOj5e2+LxZTox3g8FFXopy8kATYG9sgvCtMaS94NrBsdaN7LAOJanoQB9toBJMpeyvbCeUDcYM1c+8YAmV9najmub2GMAxTBKWXpfduuYVraw5NNz75g9xmcY73+ZIHAnyJCoJ4QvJMQuI0mcb3sv/W9RA/28k= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(21314003)(36900700001)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LegsrYyskpUNKTlthwq8iqtDwxvksqvBjELMMmgMOro2ueVV77wblstYjOiAPArfiEDHJ8xI0JriMsXhIy8ay/NlnMNQS+WozR1KIHbKCiQ0Mn3tDQO3FGRSVHNy13iNN6vYjU0iBjtCwxVPrU0uQHs29GfJsa3W9saQpaRHl3SQxq1soKzf9cuWLB0a6VLgdOlYKAWu2mlq4ZZ4SvuAQsPPebmhCyb7lux4mgpe9o6jVLdXQiQF80v2S0kqvCHbVZNrrJNbd+0STd6nsX4F8biObdeFllwmpYCWQJNEqTpJ53w7Q7mLgsft/n47FNrBe8znb89s49edyy1Yor+CtYy/718k+9HqLEIbVz5o3DQv4o5fMg6tg5ZRDu37G/WSGpOwG8Qb3H05OudYuzD4m82nQ829UDFYG1V9OCAsvbY6L+Vlgvws3loq48d95+8jXUgDyTGnBb072H4s0sGqckGD1/Eao110+3NvkXLUIb297IgsTkpzYL+wRuUguXWTum7l4wEu+JTcj/tW8CzxT6h/Zu0nVCKHDfK/iNS42gA0G/Oq2uwE7SbhMajacPJv1WATkBtT2allJmSBZOyIIsrFoDLEelwyIAUS/b8tusHhXhiIVZ1GmeFYPuBXCSNSoLYGbqqVLEnNL7iPLis5hB7RH8zTLkLmh24ZegAvYUtWLlWrVmNoY32+fZOwdzMhSWliTJqSK8O6lIO4oyEE2dr6x30MV7cfITCVwKYDWMqHZTc569yFLgLhjFuHXfnWL4ewN5hwWM3ahcKCOANbw2cCgb9x6MM0JDCoOlSiOASpMwnrgrrTaWbCp6x3OXmqwf/EZtuH3Le5QkNVZo3ViB82ug9jmvLy7dNhUkX+ZrxMEfNAMeNsfrSINrus94CdvcWXRCet/BfyXYIDsJSME0sS/KReau9ua6ENLw8+C/HsvrzALXMsf/Am7y9e7R2R/B426ytK88E54oF+vJ1e0eLJ6eQGwtCvmpj9LUQ5T1ElS3qrqvgedkyBBV8d4gNs X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:31.0091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bde91da7-eec1-4a5b-812f-08db9e65c370 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: PH8PR19MB6812 X-BESS-ID: 1692196415-102571-12363-1283-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.55.174 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVpYmluZAVgZQ0DzJ2NTIMCUlzT Q10dIoxdIyxdjSwDAtyTgpLcXUwMRQqTYWABrkHwZBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan20-0.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 From: Dharmendra Singh This makes use of the vfs changes and fuse_dentry_revalidate() can now skip revalidate, if the fuse implementation has atomic_open support, which will has to do the dentry revalidation. Skipping revalidate is only possible when we absolutely know that the implementation supports atomic_open, so another bit had to be added to struct fuse_conn, which is set when atomic_open was successful. Once struct fuse_conn has the positive 'has_open_atomic' fuse_dentry_revalidate() might set DCACHE_ATOMIC_OPEN. vfs use that flag to use atomic_open. If the file was newly created, the previous positive dentry is invalidated and a new dentry and inode are allocated and linked (d_splice_alias). If file was not created, we revalidate the inode. If inode is stale, current inode is marked as bad. And new inode is allocated and linked to new dentry(old dentry invalidated). In case of inode attributes differing with fresh attr, we allocate new dentry and hook current inode to it and open the file. For negative dentry, FS just allocate new inode and hook it onto passed entry from VFS and open the file. Co-developed-by: Bernd Schubert Signed-off-by: Dharmendra Singh Signed-off-by: Horst Birthelmer Signed-off-by: Bernd Schubert Cc: Miklos Szeredi Cc: Christian Brauner Cc: Al Viro Cc: Dharmendra Singh Cc: linux-fsdevel@vger.kernel.org --- fs/fuse/dir.c | 204 ++++++++++++++++++++++++++++++++++++++++------- fs/fuse/fuse_i.h | 3 + 2 files changed, 177 insertions(+), 30 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index bb68d911fd80..701f9c51cdb1 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -230,6 +230,19 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) fm = get_fuse_mount(inode); + /* If open atomic is supported by FUSE then use this opportunity + * to avoid this lookup and combine lookup + open into a single call. + * + * Note: Fuse detects open atomic implementation automatically. + * Therefore first few call would go into open atomic code path + * , detects that open atomic is implemented or not by setting + * fc->no_open_atomic. In case open atomic is not implemented, + * calls fall back to non-atomic open. + */ + if (fm->fc->has_open_atomic && flags & LOOKUP_OPEN) { + ret = D_REVALIDATE_ATOMIC; + goto out; + } forget = fuse_alloc_forget(); ret = -ENOMEM; if (!forget) @@ -280,12 +293,12 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) dput(parent); } } - ret = 1; + ret = D_REVALIDATE_VALID; out: return ret; invalid: - ret = 0; + ret = D_REVALIDATE_INVALID; goto out; } @@ -769,12 +782,84 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, return finish_no_open(file, res); } +/** + * Revalidate inode hooked into dentry against freshly acquired + * attributes. If inode is stale then allocate new dentry and + * hook it onto fresh inode. + */ +static struct dentry * +fuse_atomic_open_revalidate(struct fuse_conn *fc, struct dentry *entry, + struct inode *inode, int switched, + struct fuse_entry_out *outentry, + wait_queue_head_t *wq, int *alloc_inode) +{ + u64 attr_version; + struct dentry *prev = entry; + + if (outentry->nodeid != get_node_id(inode) || + (bool) IS_AUTOMOUNT(inode) != + (bool) (outentry->attr.flags & FUSE_ATTR_SUBMOUNT)) { + *alloc_inode = 1; + } else if (fuse_stale_inode(inode, outentry->generation, + &outentry->attr)) { + fuse_make_bad(inode); + *alloc_inode = 1; + } + + if (*alloc_inode) { + struct dentry *new = NULL; + + if (!switched && !d_in_lookup(entry)) { + d_drop(entry); + new = d_alloc_parallel(entry->d_parent, &entry->d_name, + wq); + if (IS_ERR(new)) + return new; + + if (unlikely(!d_in_lookup(new))) { + dput(new); + new = ERR_PTR(-EIO); + return new; + } + } + + fuse_invalidate_entry(entry); + + entry = new; + } else if (!*alloc_inode) { + attr_version = fuse_get_attr_version(fc); + forget_all_cached_acls(inode); + fuse_change_attributes(inode, &outentry->attr, + entry_attr_timeout(outentry), + attr_version); + } + + if (prev == entry) { + /* nothing changed, atomic-open on the server side + * had increased the lookup count - do the same here + */ + struct fuse_inode *fi = get_fuse_inode(inode); + + spin_lock(&fi->lock); + fi->nlookup++; + spin_unlock(&fi->lock); + } + + return entry; +} + +/** + * Does 'lookup + create + open' or 'lookup + open' atomically. + * @entry might be positive as well, therefore inode is re-validated. + * Positive dentry is invalidated in case inode attributes differ or + * we encountered error. + */ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, struct file *file, unsigned flags, umode_t mode) { int err; - struct inode *inode; + struct inode *inode = d_inode(entry); struct fuse_mount *fm = get_fuse_mount(dir); struct fuse_conn *fc = fm->fc; FUSE_ARGS(args); @@ -786,10 +871,7 @@ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, struct fuse_file *ff; struct dentry *switched_entry = NULL, *alias = NULL; DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); - - /* Expect a negative dentry */ - if (unlikely(d_inode(entry))) - goto fallback; + int alloc_inode = 0; /* Userspace expects S_IFREG in create mode */ if ((flags & O_CREAT) && (mode & S_IFMT) != S_IFREG) @@ -841,37 +923,57 @@ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, err = fuse_simple_request(fm, &args); free_ext_value(&args); - if (err == -ENOSYS) { - fc->no_open_atomic = 1; - fuse_file_free(ff); - kfree(forget); - goto fallback; - } if (!err && !outentry.nodeid) err = -ENOENT; - if (err) - goto out_free_ff; + if (err) { + if (err == -ENOSYS) { + fc->no_open_atomic = 1; + + /* Might come up if userspace tricks us and would + * return -ENOSYS for OPEN_ATOMIC after it was + * aready working + */ + if (unlikely(fc->has_open_atomic == 1)) { + pr_info("fuse server/daemon bug, atomic open " + "got -ENOSYS although it was already " + "succeeding before."); + } + + /* This should better never happen, revalidate + * is missing for this entry*/ + if (d_really_is_positive(entry)) { + WARN_ON(1); + err = -EIO; + goto out_free_ff; + } + + fuse_file_free(ff); + kfree(forget); + goto fallback; + } else { + if (d_really_is_positive(entry)) { + if (err != -EINTR && err != -ENOMEM) + fuse_invalidate_entry(entry); + } + + goto out_free_ff; + } + } + + if (!err && !fc->has_open_atomic) { + /* Only set this flag when atomic open did not return an error, + * so that we are absolutely sure it is implemented. + */ + fc->has_open_atomic = 1; + } err = -EIO; if (invalid_nodeid(outentry.nodeid) || fuse_invalid_attr(&outentry.attr)) goto out_free_ff; - ff->fh = outopen.fh; - ff->nodeid = outentry.nodeid; - ff->open_flags = outopen.open_flags; - inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, - &outentry.attr, entry_attr_timeout(&outentry), 0); - if (!inode) { - flags &= ~(O_CREAT | O_EXCL | O_TRUNC); - fuse_sync_release(NULL, ff, flags); - fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); - err = -ENOMEM; - goto out_err; - } - - /* prevent racing/parallel lookup on a negative hashed */ + /* prevent racing/parallel lookup */ if (!(flags & O_CREAT) && !d_in_lookup(entry)) { d_drop(entry); switched_entry = d_alloc_parallel(entry->d_parent, @@ -885,10 +987,52 @@ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, /* fall back */ dput(switched_entry); switched_entry = NULL; - goto free_and_fallback; + + if (!inode) { + goto free_and_fallback; + } else { + /* XXX can this happen at all and is there a + * better way to handle it? + */ + err = -EIO; + goto out_free_ff; + } + } + } + + if (inode) { + struct dentry *new; + + err = -ESTALE; + new = fuse_atomic_open_revalidate(fm->fc, entry, inode, + !!switched_entry, + &outentry, &wq, &alloc_inode); + if (IS_ERR(new)) { + err = PTR_ERR(new); + goto out_free_ff; } + if (new != entry && new != NULL) + switched_entry = new; + } + + if (switched_entry) entry = switched_entry; + + ff->fh = outopen.fh; + ff->nodeid = outentry.nodeid; + ff->open_flags = outopen.open_flags; + + if (!inode || alloc_inode) { + inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, + &outentry.attr, entry_attr_timeout(&outentry), 0); + if (!inode) { + flags &= ~(O_CREAT | O_EXCL | O_TRUNC); + fuse_sync_release(NULL, ff, flags); + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); + err = -ENOMEM; + goto out_err; + } } /* modified version of _nfs4_open_and_get_state - nfs does not open diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 4e2ebcc28912..6a35f109d214 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -675,6 +675,9 @@ struct fuse_conn { /** Is open atomic not impelmented by fs? */ unsigned no_open_atomic:1; + /** Is open atomic is proven to be implemented by fs? */ + unsigned has_open_atomic:1; + /** Is opendir/releasedir not implemented by fs? */ unsigned no_opendir:1; From patchwork Wed Aug 16 14:33: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: 13355314 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 3D483C04A6A for ; Wed, 16 Aug 2023 14:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343641AbjHPOd6 (ORCPT ); Wed, 16 Aug 2023 10:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343655AbjHPOdw (ORCPT ); Wed, 16 Aug 2023 10:33:52 -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 2080F2715 for ; Wed, 16 Aug 2023 07:33:49 -0700 (PDT) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by mx-outbound23-26.us-east-2b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N2fQlHdZ3o8r7UMXpaHyQdwfTl64Zl0u5C4GJZTs8by9fIwej+s09YUXVPtyHM2hDsNW0qWHHHkd3JJnSqxUdcjxLklmzWv8AO3w+o9ukF+oaZtWsqAW9P0H9aG1oGU+2aycPCRcmZ60OF+Ghyur7TTuZjg64irsr3amom9Q8QXJBLXyYVP1aYL1RpzzpF76dtyrQx6qn95qAPH9l8BaxFhaoGHnqlFkwroMFANqMX6qv2MznOisTKtxEzLMcglHxsT11UcVbochPSivt4/r7l4U6KrLgufGGi/7GFhZo04oS2P89H9XedbUOnFnczs8I6kA0o9WhKf6kcd4IuRJbg== 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=C8d7QWZ9q4hFSPtKrPBOE8C/BNLm9ePBJPg4vd5q698=; b=j6pJLPrr/BvMap+NkkchonINLqr8mCqSn1LcDO+3ROOJ+RjMZR0z78V+kdQ9Q+Fy/joL5aoJ6hhL9kfOBxzjaVF3jVmqcOBKKUnGg6agaBk5VpD73Km7dA8SrLAy07BzFVXUm9OKi4WqgOLqtHAiPhS/3aVUopjcCKpeKuXwTI0IzX7GKBpPKCsY5WwrBVTXmzKhmvIOwa0hpvSFktm2ovveOZmgleUvEUQyXOXlYYI0YUp5wu3BxL4BYwFlOx88TjBj6x6fHfSYnrOpQH3QfZP/LUr9+HWwM0blPwrjQYdu3OfULVLjxfC7Yv3luqwpXJxRixWBcUlwCR6xMJicpg== 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=C8d7QWZ9q4hFSPtKrPBOE8C/BNLm9ePBJPg4vd5q698=; b=Q2MWUqMnRzOhgk3IUWJu8rnTfwdDpC/F1ko4/9bW+6MaKChnrHJqcD/46KyuI8mdnlk6dBbUmnS9TwyC7fVyT0EwExhqwz31OvcjWt7x3trSxIAX65xBYRramX1X+pMF7g99te2sxlXEwjv07NpnT+z91QjnMMyL4WiVyG8/Hho= Received: from MW4PR03CA0271.namprd03.prod.outlook.com (2603:10b6:303:b5::6) by MN2PR19MB4078.namprd19.prod.outlook.com (2603:10b6:208:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Wed, 16 Aug 2023 14:33:33 +0000 Received: from MW2NAM04FT050.eop-NAM04.prod.protection.outlook.com (2603:10b6:303:b5:cafe::cd) by MW4PR03CA0271.outlook.office365.com (2603:10b6:303:b5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 14:33:33 +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 MW2NAM04FT050.mail.protection.outlook.com (10.13.30.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Wed, 16 Aug 2023 14:33:33 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 3747120C684B; Wed, 16 Aug 2023 08:34:39 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Bernd Schubert , Miklos Szeredi , Dharmendra Singh , Horst Birthelmer Subject: [PATCH 5/6] fuse: revalidate Set DCACHE_ATOMIC_OPEN for cached dentries Date: Wed, 16 Aug 2023 16:33:12 +0200 Message-Id: <20230816143313.2591328-6-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM04FT050:EE_|MN2PR19MB4078:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ecebe9a-3bb5-4d7c-70c8-08db9e65c4d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zKJMAYsxnkGsiNLNyWjS50ticD7SLuGJZnJxVignB/0OtODZPmt5VLtADOfaYe3+fbFpJUKroEfLAfTRiCD0wsTnOLLdTE3eFHWVzAD8KmJjI9JziFdxLGEdq5IRHmrRZ4cG2jW/k05POJQqL7MPADtovCd0YCQG5gycldpyQyS5RHoC8USBbKSMVN7NURQ5qFLK374oQ18/jiJtUiavIU5L6ueKOsP4k2knNmHxcS7g6TbJ8CNRGhvEW5lsX6j9zevfLhOYxDS8xw0vVTk2EresgijzwsK8cSFTrqomjfUFnHfIjTfNk01I7g8MjN5Bx2uSIC2JyJwQbhxNCQddZDLBbQAVQKVsQJGSAl0k9Gi9BnM2+rvtuo52AYNmU3RrKFWiAEZW7ewZEhRw+UOlekkwn+GUeF5kLgiHecTJS3FJASfxcI6GQl5u1atTArpOLYSuRn66QnjZX0Txg2Pno8v0zlWBJsCgmbzTmzjyr+Wmq9CW8hGYr2v6DqXqodN7KSbkPrj9AAW+1KvlSH7pr39xVqwsAug7VCgntsBJGfWeNhPBITox1leCMIIKokw8yWWj8dSLNJq98ZfSdaBc3ZExesCf+9lY+Ub8y71uEybIjhdfxSYZWKuQvaMrbJpehaUFFKRCL1h0P5S1Iz0QlqbpzPgB3lRldOPdoM8959uZw626BheeGwQ3GQXR/UyznYkXw+XNrHlx8r41MQTbcMgDNQ14s0O2ZJYAg7O7808= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DIedd2or4aJSDArRks6GfPzy+0H6ewriFLDm9nzdFU/DkarLFegQeKhZPijfdg2Gmba//vXNZbTSOwiFdDQXvJt/xKtqi+CLxdDgYlVXFBSLK7nDZWffeg6ya/2bQhKsMIZyyQAXOIiAscbuuTRi6E3juMF9U0vpNR4iPHEDvp7A4XwcV6pL26/j+NoBFrzIVMJMo6aKyNeNW8nKfdxeVrEgH4yNFN5t3UZy6cFItt0bbYpfkV5ng1/J5foOjz40He5wzGNXadxslSUZKyyhBL4OWkR7IasGRjaJBxcNs90j0RR9wXh1FcVar79iKsM3ZPC/qMaE7SyRSgWgJA2oPV69u/qE4kKvlYOdsDLF7e9QK6Ir9MXSThbNyeas3mWn3N7AFnZ8ykEYelBf+v1hqyQ7j7qbHJxxI+bLflePL2MN/iaoOp8oDLO3pQLUW8O1tDinvjrOfdP3yIr4a+i5K3YCzOwpzCpwwWJu5OGy7EFVXcQHIVtWIp7qg8Sj0CrDuUCr01zJk96xiSyv15DQX5wQ79DMDtn9BI0LQ7bd7LtBBQyZHGBN9RAaE8Iyjw7m3dzyoCVTYCa1Pb2R9nSo6uluCBe02XcAvQkK2qSA0QxWbJTLdbY5XbNKMVIBiHJwrY28aLouAIDJY5kC3t4KuQ+QxPDxUC5Fq41M+7ehfPUix+ttVKoaFDA0vToXh5Wl9RqBfaLzpBNSeiHuD8HWe/8Ad8CIN6ymVhnCulc2IfgoUoNxoAFoFsl0h+OgFbnMO6Lg/x30RAGhJW7/bO7k8cz95ADfOQSVckDpZiRn+HuCfbLcrj0d/arcn8HwMuQzpfdYq15nGK4+JAIKwZlvrtH3NYkhBT4Nx56bZigCBYyC8WA2uu5bkRcArfQYuiAcyj1MmrP09GNn4heMAzYult94UWBuzzhQPy0YwRgz1dw= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:33.3065 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ecebe9a-3bb5-4d7c-70c8-08db9e65c4d1 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: MW2NAM04FT050.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR19MB4078 X-BESS-ID: 1692196417-105914-26282-1155-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.59.170 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYmBmZAVgZQ0NTA1MLQzMjUOM nSwsgyMckgxdjSLMXY2NjUNNky2cxEqTYWAEuluThBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan22-15.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 Cached dentries do not get revalidate, but open will result in open + getattr, but we want one call only. libfuse logs (passthrough_hp): Unpatched: ---------- unique: 22, opcode: OPEN (14), nodeid: 140698229673544, insize: 48, pid: 3434 unique: 22, success, outsize: 32 unique: 24, opcode: GETATTR (3), nodeid: 140698229673544, insize: 56, pid: 3434 unique: 24, success, outsize: 120 unique: 26, opcode: FLUSH (25), nodeid: 140698229673544, insize: 64, pid: 3434 unique: 26, success, outsize: 16 unique: 28, opcode: RELEASE (18), nodeid: 140698229673544, insize: 64, pid: 0 unique: 28, success, outsize: 16 Patched: ---------- unique: 20, opcode: OPEN_ATOMIC (52), nodeid: 1, insize: 63, pid: 3397 unique: 20, success, outsize: 160 unique: 22, opcode: FLUSH (25), nodeid: 140024188243528, insize: 64, pid: 3397 unique: 22, success, outsize: 16 unique: 24, opcode: RELEASE (18), nodeid: 140024188243528, insize: 64, pid: 0 unique: 24, success, outsize: 16 Signed-off-by: Bernd Schubert Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: Horst Birthelmer Cc: linux-fsdevel@vger.kernel.org --- fs/fuse/dir.c | 52 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 701f9c51cdb1..1e5e2d46df8a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -193,6 +193,22 @@ static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args, args->out_args[0].value = outarg; } +/* + * If open atomic is supported by FUSE then use this opportunity + * to avoid this lookup and combine lookup + open into a single call. + */ +static int fuse_dentry_do_atomic_revalidate(struct dentry *entry, + unsigned int flags, + struct fuse_conn *fc) +{ + int ret = 0; + + if (flags & LOOKUP_OPEN && fc->has_open_atomic) + ret = D_REVALIDATE_ATOMIC; + + return ret; +} + /* * Check whether the dentry is still valid * @@ -230,19 +246,10 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) fm = get_fuse_mount(inode); - /* If open atomic is supported by FUSE then use this opportunity - * to avoid this lookup and combine lookup + open into a single call. - * - * Note: Fuse detects open atomic implementation automatically. - * Therefore first few call would go into open atomic code path - * , detects that open atomic is implemented or not by setting - * fc->no_open_atomic. In case open atomic is not implemented, - * calls fall back to non-atomic open. - */ - if (fm->fc->has_open_atomic && flags & LOOKUP_OPEN) { - ret = D_REVALIDATE_ATOMIC; + ret = fuse_dentry_do_atomic_revalidate(entry, flags, fm->fc); + if (ret) goto out; - } + forget = fuse_alloc_forget(); ret = -ENOMEM; if (!forget) @@ -285,6 +292,16 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) } else if (inode) { fi = get_fuse_inode(inode); if (flags & LOOKUP_RCU) { + fm = get_fuse_mount(inode); + if (fm->fc->has_open_atomic) { + /* Atomic open is preferred, as it does entry + * revalidate and attribute refresh, but + * DCACHE_ATOMIC_OPEN cannot be set in RCU mode + */ + if (flags & LOOKUP_OPEN) + return -ECHILD; + } + if (test_bit(FUSE_I_INIT_RDPLUS, &fi->state)) return -ECHILD; } else if (test_and_clear_bit(FUSE_I_INIT_RDPLUS, &fi->state)) { @@ -292,6 +309,14 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) fuse_advise_use_readdirplus(d_inode(parent)); dput(parent); } + + /* revalidate is skipped, but we still want atomic open to + * update attributes during open + */ + fm = get_fuse_mount(inode); + ret = fuse_dentry_do_atomic_revalidate(entry, flags, fm->fc); + if (ret) + goto out; } ret = D_REVALIDATE_VALID; out: @@ -935,11 +960,10 @@ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, * return -ENOSYS for OPEN_ATOMIC after it was * aready working */ - if (unlikely(fc->has_open_atomic == 1)) { + if (unlikely(fc->has_open_atomic == 1)) pr_info("fuse server/daemon bug, atomic open " "got -ENOSYS although it was already " "succeeding before."); - } /* This should better never happen, revalidate * is missing for this entry*/ From patchwork Wed Aug 16 14:33: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: 13355312 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 15D61C001B0 for ; Wed, 16 Aug 2023 14:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343640AbjHPOd5 (ORCPT ); Wed, 16 Aug 2023 10:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343656AbjHPOdy (ORCPT ); Wed, 16 Aug 2023 10:33: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 ABC5E268F for ; Wed, 16 Aug 2023 07:33:51 -0700 (PDT) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by mx-outbound41-168.us-east-2c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Aug 2023 14:33:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fQrLI77GyTel6/UYFUC69XL+bk2M+VEzkGHFjNvInb8iDzUjhRWEDgm4oGkSfal34iQ9OuPTrXNYwC4tB3dn1dGt7TCl5/BoAHHLPZb2IwHPyVxaRFQkRxh0TmPdbtsn0QFwp3KTuy13HkR3PtX0SVNsSjFFuSLcoLeAE+DIBhXg6KdtfLJc/JRbOohgCZiyfIPIz5bM9CqQ7IOR2W07+k/UOBp54X5wpQU6y/nH6NSz9deUoEYmbNPeT9wHug/DKpBAsls9LhuRzP34AJ6FZtqca6277jPK8dHlkXjHvspb95wAcxgt+QgPCUtEdxPiNAD4Gl2ADN4FvhI5NGaTBQ== 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=h1PvKXaoLLzu0ch8xYAiNWO8488RBn4vXZ2rlru6maQ=; b=TV3MHVEflNdZPwioUAxEnL5XPislRL7v09Xz0VdqQ8RMAlsZ+DixESOHELXSUyADtv948qspvRALwBT3Likyezy6KNHaCS9quc04ICyhCnsU/B2M1jR4olAATjMPmcHRUnq+tlVAY9KEIyDOYhP/1nLznJobEWRWpTwkin/s2AecNACw0bWuyGRBV34RwpVA4Mg6MJZqoUSJZwywfMcA+KHqnEzCbEbGJGhUefmXqSVivhK4VnEWK4wOvgGv7mM5tWpECgwYIhp8DnMp838vGE0jRxdzsW85al0/5mvbqKfEs5ide3V0sh5iknBewrx26u6wt30IblgEwqhG1yX6sQ== 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=h1PvKXaoLLzu0ch8xYAiNWO8488RBn4vXZ2rlru6maQ=; b=X6hqkyTpsN/pfGrTVEb/KJuadrVULWUH9iBO6dH/U9exxwNRofQnwPcNjPOJebtnf4LNjxcC2kTyIFY33gY+lRTkS0gWEY7/EikEHXIvRSJiJbBqHj2/ywMdpOmRpxLj1f9w2RrMF+yDQ5r4XIiEU2+AMLMAu8xcD3FkpHcJhxk= Received: from BN9PR03CA0108.namprd03.prod.outlook.com (2603:10b6:408:fd::23) by MW3PR19MB4185.namprd19.prod.outlook.com (2603:10b6:303:4d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:33:35 +0000 Received: from BN8NAM04FT024.eop-NAM04.prod.protection.outlook.com (2603:10b6:408:fd:cafe::38) by BN9PR03CA0108.outlook.office365.com (2603:10b6:408:fd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 14:33:34 +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 BN8NAM04FT024.mail.protection.outlook.com (10.13.160.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Wed, 16 Aug 2023 14:33:34 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mx01.datadirectnet.com (Postfix) with ESMTP id 3227620C684D; Wed, 16 Aug 2023 08:34:40 -0600 (MDT) From: Bernd Schubert To: linux-fsdevel@vger.kernel.org Cc: bernd.schubert@fastmail.fm, fuse-devel@lists.sourceforge.net, Bernd Schubert , Miklos Szeredi , Dharmendra Singh , Horst Birthelmer Subject: [PATCH 6/6] fuse: Avoid code duplication in atomic open Date: Wed, 16 Aug 2023 16:33:13 +0200 Message-Id: <20230816143313.2591328-7-bschubert@ddn.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143313.2591328-1-bschubert@ddn.com> References: <20230816143313.2591328-1-bschubert@ddn.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM04FT024:EE_|MW3PR19MB4185:EE_ X-MS-Office365-Filtering-Correlation-Id: f64ec496-d676-442c-c143-08db9e65c58d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7rbNSVM4TBw8luo2tzLeO2Ej/nwKlkkci1ljYR1ii1nASIc7KSHVLUop07KvAvz4UKg4U4gKEzi/1FnlE2KoOdQMVdYlvD88An+pFWm1oKQvHu+SimVb15h8mSmnO95SZmsITc0XDL4hmBbr1g8cQ4pTEbBgTWEtmliHpkkJ3QyyDow/QEcEM76tPCG11be2/Ebmu7sB42dccYOKYIlZKyuHcyFayVq7iRJr7UIvzHUQ626WHF56A+ByEHJ0wZv7t4PbMwA280jBZZ+sNC/rjNhGj7L7i9Ye4ubsDdv+YIewM9V/sbnp3V3GPimwF1nSdGWjGWKep5x3WFZwrjVepXLtAq6CLGmy9cylCyFpibu1wZunpw3XTjFV3/OeCmNqAg/4tLDf64Y8vVS58gcBT/sHDZJOJcRkxsNQRA4rMA7XPKvvH332EbQseu0/fQas9GbQM7693jsNDcMYtsxiGV7VblQfxKIUb2sI+z6hHLHp2IQlG5EXaPvXATkuBYNLSxe1h2sJhBx/pEseJUefbKyuisKrZPRcDxRSMKCa423pOGRi0CpH0Rj2+X3DKslzH0x43j1GT69kLdRw10U7lo7Lj0hYUd6fDwEoyjtmxHC7fApP5kbzL574RvB4889niYt3gt2iHndah4Hud+qDp6UTz3PmswxNCqSKi3KkX/umxW+mYF4EcnAsV1RCuS1KslUqRK5RoACxgmjCMmz7vA62Ekasf4HTv2hmtqtH8MqCBWHCqIPVOeSHQPTj+QaZZlKP/4Vx/tp02qHX4M/dfA== X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mx01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(346002)(376002)(136003)(39850400004)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(316002)(54906003)(356005)(82740400003)(6916009)(81166007)(70586007)(70206006)(36860700001)(41300700001)(5660300002)(47076005)(8676002)(4326008)(8936002)(2906002)(83380400001)(26005)(40480700001)(478600001)(336012)(6266002)(86362001)(36756003)(6666004)(1076003)(2616005)(21314003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: szakY/JTCa6BERv2d9kKRyTlybBUGXq4hwnLnDIHCT40Awk9GuDahAtMhVsVICvzeV1rHy0griwzx/SRc8MZmOLeE3T2QvLoCE56Qlrl9z8Q1UP83RMIPlXvoS2JtmDjFysf9xETET6FuvP4aObUI5E3t3qluR5lzwlna66c5ZnQbk0lt6jkG5UkCOjrNyVD/1/dxNRti/iziOvMzZ7vMQlYMNieFsNxsGU4klGERIROVuy83wp0cSOWcF7bd54Tm9c9qk6lI0ocQUlf3iMX2l3age0ahzkJ1MCMj+DoBE3ToiyDPL11WI3jklPb8IA7QBYspEhYwrDOgj/26kTbk1RcbCLp8QPfVOxMcJqqqvF2L7D1f5B56NozSsh4MtIgDSQPW9FlYpAt2bVp6XxmnCI2AptcbS66RV1YX8r4+C7pF8LraEFYGJDkI6RJ6T5xinCwK1OwQxsPFGoQpUNi9kB/5qCjgQ+Q4U1/IEJ0BRyczwZ+kFBNX7Y+pDmuWqurxv1bn+/T3oTiXChhOzZ8WL6V9cjeEjtcEdyz3ukNrPEQn8qNNRkXlCv/Omxux22gWwcg8bgzbgubTrjz9/kOWISjxFkOPndCUMXfTUZ/GE2TW8ci4hPioQetAed7NGSj5AJmE2IbrQlTmfQiVb7hyhpnoLzmEUND73YtuhpxdWyk8H90pVazntsqTp3CIg3cngWIzgxbtW7UMFezL6lFRHolrOY1SqrKT3f112NQrCYEjfe9ekY09negOoU17y8m0RMu+s+k+ueR4gS3A7VgcHffEBakrTsQALVZPRVL1Orrty1NUGvY6YW53fDMF3yVjkecd945edVEa63UBgB8jT/NEdfDyWTJ7SPJ6j7JUVjY5DqvpSMZKI7e8sotN8XeuZXATYO51prF3iFc9fy1b52u/Fovnlc1ghfL0bk4ZV8= X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:33:34.4781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f64ec496-d676-442c-c143-08db9e65c58d 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: BN8NAM04FT024.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR19MB4185 X-BESS-ID: 1692196418-110664-12321-11894-1 X-BESS-VER: 2019.1_20230807.1901 X-BESS-Apparent-Source-IP: 104.47.55.100 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVkbmxiZAVgZQ0NjEzDw12cjM3C DRIDU50TzZwsIsNSnJ2CjZKNkwOTVFqTYWABeFzRtBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.250184 [from cloudscan19-178.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 The same code was used in fuse_atomic_open_revalidate() _fuse_atomic_open(). (If preferred, this could be merged into the main fuse atomic revalidate patch). Or adding the function could be moved up in the series. Signed-off-by: Bernd Schubert Cc: Miklos Szeredi Cc: Dharmendra Singh Cc: Horst Birthelmer Cc: linux-fsdevel@vger.kernel.org --- fs/fuse/dir.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 1e5e2d46df8a..e69dafc89222 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -807,6 +807,25 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, return finish_no_open(file, res); } +static struct dentry *fuse_atomic_open_alloc_dentry(struct dentry *entry, + wait_queue_head_t *wq) +{ + struct dentry *new; + + d_drop(entry); + new = d_alloc_parallel(entry->d_parent, &entry->d_name, + wq); + if (IS_ERR(new)) + return new; + + /* XXX Can this happen at all and there a way to handle it? */ + if (unlikely(!d_in_lookup(new))) { + dput(new); + new = ERR_PTR(-EIO); + } + return new; +} + /** * Revalidate inode hooked into dentry against freshly acquired * attributes. If inode is stale then allocate new dentry and @@ -835,17 +854,9 @@ fuse_atomic_open_revalidate(struct fuse_conn *fc, struct dentry *entry, struct dentry *new = NULL; if (!switched && !d_in_lookup(entry)) { - d_drop(entry); - new = d_alloc_parallel(entry->d_parent, &entry->d_name, - wq); + new = fuse_atomic_open_alloc_dentry(entry, wq); if (IS_ERR(new)) return new; - - if (unlikely(!d_in_lookup(new))) { - dput(new); - new = ERR_PTR(-EIO); - return new; - } } fuse_invalidate_entry(entry); @@ -999,26 +1010,13 @@ static int _fuse_atomic_open(struct inode *dir, struct dentry *entry, /* prevent racing/parallel lookup */ if (!(flags & O_CREAT) && !d_in_lookup(entry)) { - d_drop(entry); - switched_entry = d_alloc_parallel(entry->d_parent, - &entry->d_name, &wq); + switched_entry = fuse_atomic_open_alloc_dentry(entry, &wq); if (IS_ERR(switched_entry)) { - err = PTR_ERR(switched_entry); - goto out_free_ff; - } - - if (unlikely(!d_in_lookup(switched_entry))) { - /* fall back */ - dput(switched_entry); - switched_entry = NULL; - if (!inode) { goto free_and_fallback; } else { - /* XXX can this happen at all and is there a - * better way to handle it? - */ - err = -EIO; + /* XXX Is there a better way to handle it? */ + err = PTR_ERR(switched_entry); goto out_free_ff; } }