Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2103178rdh; Tue, 26 Sep 2023 12:30:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHjraEpwiKcq49sbuVjmI1RcI60ReNaOzkrDZsmtn3P/zJ0NTOpQ62v0/BPYZ/H03bHu/d X-Received: by 2002:a05:6358:2929:b0:143:21e8:11f2 with SMTP id y41-20020a056358292900b0014321e811f2mr39604rwb.11.1695756608143; Tue, 26 Sep 2023 12:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695756608; cv=none; d=google.com; s=arc-20160816; b=JGQgxapWVYU+MAnmr0Qs9XYKOCzcicXHblowgV0id2tROEU3TKkennRCd9rTcNBUmU DZJsFE/0sSApHlmRotPDVEiM3WTZAemx+6T9bZE89G32akDC6/JwTYg8WEKe4G8B+mGH 0PfYQftEQz1zXAndp8wJHIvtsuo4hUbYnAf6VT4id1urJf+8o554EBsR63hqlATCuliT BXC2vR1I3R09kfa9+k20yEZzrtHJYguuTdVfTRyJTNX6BP/SwHLHkCkZ6lEV6nPnOwfJ CtlQTuHwkWyp0YC9oh6Jgar9FgaK1UnxXy+8DGjpiGHbzA/eDeC05pEdDqkJlyY/LcoI GZRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:references :in-reply-to:mime-version:dkim-signature; bh=+T1kiw5Evo1WrVqxLy5w/b1X7UOVJo+3cJZz1bjJVZI=; fh=h0oLqIyvr9E5rIjILmCbzMWKw4UymhYoKBlPnUg6xD4=; b=HypHHYCEvu9EqvZFbHO5nkd44LQb+MnNjo6f/hYb1LoFvL3b2XTlTan2ZWePigPhr+ 0cZjKCGKattgJjdbtpCx0jvSx9rQ75DWjMvyybbjX1fTWc82oB8frQE9hJBGUh2BN+g5 VjYQgHEXyqhyagPox68NinrJoekh59DNd4MumSMTbOR3PGDIjZs8e80W3TQqQYJt4Kxb cHr9rnDrXqRDpcq1wYd7L7dYaB/HUoCa/6Nzbw3zo0x9+9kb1q4tGBFNhEfqBMUeJNMb 2mrYP0Av85UAy06x0v59sCSe/paCNaQ1SMlAxsfIIIMX/sw6RUQXhBSib8i6GQ2taZgn FkJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fNkeYkip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q16-20020a656850000000b0056b4065299esi13532109pgt.621.2023.09.26.12.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 12:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fNkeYkip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5D6578028FCD; Tue, 26 Sep 2023 07:07:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbjIZOHr (ORCPT + 99 others); Tue, 26 Sep 2023 10:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjIZOHq (ORCPT ); Tue, 26 Sep 2023 10:07:46 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6995FC; Tue, 26 Sep 2023 07:07:39 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6c4cbab83aaso4171120a34.1; Tue, 26 Sep 2023 07:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695737259; x=1696342059; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+T1kiw5Evo1WrVqxLy5w/b1X7UOVJo+3cJZz1bjJVZI=; b=fNkeYkipkcuEUOrNPEarYHLFUmxBmTK/DlOUgvye6CKKkikj514kJZf1E+clSL74Zg S7wrA9TdsaHVlUJ4ehk8L+krmdPZ0yeS3uARnFp2JYW586cmN1sIdKntCLR/4SmBHA07 w5qXXyHUCoi0vAGkzbb/zz5LPtXySJIWnpQwMqvOylPfwjaS9LOUkARiTxqVZbkKhnTI tdrZ462VPGC6xGxLAVP9HQ9y9a/a4PTrEuNU7n/NIsJ1C45I3snU7528uSCtaw7ENE74 O3dfa837wdMCmKGuKCWsld8ThLHCJzHK2Y1sCxRqOm+zYbBsjFmjdWUYHVRVKO69eVAp 85VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695737259; x=1696342059; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+T1kiw5Evo1WrVqxLy5w/b1X7UOVJo+3cJZz1bjJVZI=; b=tLxFDzLOL1uCl3FnmWXK/asU3QVeQ0QmbP/iEcBV4yKMsGHS+KJtCV7f1AQJBTeBjF w8MHO1THmr/6UuvHcy4M/Nz4uRxNqfL0GueGGhPnhMo2uFiquznWNzMnFZU0xcxzwh4J VnexchO36UCMyUiPQmCqFkbtXvbbV3Yu5SBadrnIzzyhC5sUpPg8gELsf+u/vH4kreay k6nNhcE/XKoi+NJLdyoklT2PZNbcLJOvNRUJSPl4cMOW8TYBjPfu0gq+fK/f2l+zSt8K KqKvrBY+XsydL1Imxbs1UqLiCJk6+s3jb+zQFusEwj2iEnStJ61JKKL1Di31V6zueBnV HdGg== X-Gm-Message-State: AOJu0YzwvWbeOoDrdL9cIZ5/6mLJfdPxr/Als5KnTlYFvjgo5fE6Yfx4 R81JGyTHrAyqHKK2YBHlu8WaScplmXLOrFpuRa4/Dlda X-Received: by 2002:a9d:4b12:0:b0:6bd:c7c3:aac2 with SMTP id q18-20020a9d4b12000000b006bdc7c3aac2mr10313264otf.18.1695737259119; Tue, 26 Sep 2023 07:07:39 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5d4a:0:b0:4f0:1250:dd51 with HTTP; Tue, 26 Sep 2023 07:07:38 -0700 (PDT) In-Reply-To: <20230926-anforderungen-obgleich-47e465f0bd47@brauner> References: <20230925205545.4135472-1-mjguzik@gmail.com> <20230926-anforderungen-obgleich-47e465f0bd47@brauner> From: Mateusz Guzik Date: Tue, 26 Sep 2023 16:07:38 +0200 Message-ID: Subject: Re: [PATCH] vfs: shave work on failed file open To: Christian Brauner Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 07:07:44 -0700 (PDT) On 9/26/23, Christian Brauner wrote: >> +void fput_badopen(struct file *file) >> +{ >> + if (unlikely(file->f_mode & (FMODE_BACKING | FMODE_OPENED))) { >> + fput(file); >> + return; >> + } >> + >> + if (WARN_ON(atomic_long_read(&file->f_count) != 1)) { >> + fput(file); >> + return; >> + } >> + >> + /* zero out the ref count to appease possible asserts */ >> + atomic_long_set(&file->f_count, 0); > > Afaict this could just be: > > if (WARN_ON_ONCE(atomic_long_cmpxchg(&file->f_count, 1, 0) != 1)) { > This would bring back one of the atomics, but I'm not going to die on this hill. If you insist on this change I'm going to have tweak some comments and bench again. >> + file_free_badopen(file); >> +} >> +EXPORT_SYMBOL(fput_badopen); > > Should definitely not be exported and only be available to core vfs > code. So this should go into fs/internal.h. > Ok -- Mateusz Guzik