Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1912604rdh; Tue, 26 Sep 2023 07:13:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGYjGfeyjJcDqiRKjuPxuRAk8iTGUqzjg/MkdUmfZjLYizGbC8YCi6qs2t2EcZKdjRnlm2 X-Received: by 2002:a05:6358:e4a9:b0:143:864e:f969 with SMTP id by41-20020a056358e4a900b00143864ef969mr11575008rwb.6.1695737615717; Tue, 26 Sep 2023 07:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695737615; cv=none; d=google.com; s=arc-20160816; b=h2+i3Q2RztL/o6zIigC/A9RiCmMLKf3RcOO7QonVBb1ieEyeHsR9KAHuVPlfLF39vx zFhmDXq2uP6XnO7vsVDZKBMX24f9ykpSRtwej5Paz8BRtJHnT+WElSPDWny5QMXOJ3k6 TUmuTXakJmSz00VD9Z5bPPe3WH22lKh49AB2MYZSW/lWjtfLLKDYjDbXbJQCJc9l2lUv GCGjwsMTwEq4GFgo4d29/EtgI2xsd/s3PpagreokpdODkqRQAkw7tpqnKg89OL0KIPkX BPuVf3zcDs/btp8GAFoqV2ja9uGM5NrHl8yvHFvwFnmEOLW7ZtqC45Z6N8Xl0RDiHtVE M/pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HvQAJS0VeTMu/8KEraPAf06qN9ei2HpjSQ18pqofias=; fh=55jKks3UKtL1Xdvq/yaDSdtDhEEMQ1A6VM/L1bKzdJ8=; b=r8nTuDNasi7fTQfvkkeWpT3m6nY+DNWLVYyDTaNEPJepECnQzgoCnprAVHsbvIoO2g rGscsvVed7uVHXv8AxOWl6FNnwFuu9oKN2opEKA3VC0VidFBUNl6a7k3N9TSm2vIJKSk KAkduLXOFnrv8xjblRE16M5siSRUGUACNKflDYWLIoZfcts+8aqT/oJriE5ejfK6QnqG YOoRM+jMI5DvSN9Sfx4E09nbxkrjuMcuOatMtGVtyyhqwfJ9XcMldWGkuY2gBvDW/pyy 4f09uFOnyj5IVVbN9GwoQy73vv/SKB95gDrewKYEm8mI7jwoXG1iasVf3NBRRtv8jGZH 8AOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqmITccg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v186-20020a6389c3000000b00577646e2b5bsi12969570pgd.652.2023.09.26.07.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 07:13:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqmITccg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7BA048021292; Tue, 26 Sep 2023 07:02:02 -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 S234916AbjIZOCC (ORCPT + 99 others); Tue, 26 Sep 2023 10:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234917AbjIZOCB (ORCPT ); Tue, 26 Sep 2023 10:02:01 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 216B5120; Tue, 26 Sep 2023 07:01:55 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83BC7C433C7; Tue, 26 Sep 2023 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695736914; bh=svPGZCzPrSPMIeqadaHU756x3Z6kwGm0cfJhav3gYAQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GqmITccg9BeZvQhB71nuMArmjEXMuGP5dgFXPWuMYMSfUA/wSBwx/848wK+iWMiyB Uqx+EqeRr5dxO2Xp0XWuQR1+a+mkWGcvpE6Sq8xBSRZoxHXpad0+fZKS6LclgoajzT NmKDzaWNL+bwoJ/nJbpexqeqAoAsjTmrLkgUSFmcd+/WiLgRVimKdd8+Ig6VYS8dX7 D/yvK4x4N1ZXDDhVBLqYxUKmo6ZcVteMZxQK9ywjlVeTNqL4pgUJh1sfGOTXXtFAZy sain2+iY/KMKdIxmJ5PAr4qrFa5M216efSqu7dWDRi/53I/5b7NfJ7txBYGweWpDly XvRPj2nows71g== Date: Tue, 26 Sep 2023 16:01:50 +0200 From: Christian Brauner To: Mateusz Guzik Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org Subject: Re: [PATCH] vfs: shave work on failed file open Message-ID: <20230926-anforderungen-obgleich-47e465f0bd47@brauner> References: <20230925205545.4135472-1-mjguzik@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230925205545.4135472-1-mjguzik@gmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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:02:02 -0700 (PDT) > +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)) { > + 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.