Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2875123rdh; Wed, 27 Sep 2023 16:01:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIIsYyiymHQdXUHMh9h7NVIXJb6X/mgTXovYqYhePg8puhAIXujeEuw25k6G71vTTnxXjX X-Received: by 2002:a05:6358:920f:b0:139:b4c0:94d with SMTP id d15-20020a056358920f00b00139b4c0094dmr3529310rwb.12.1695855688169; Wed, 27 Sep 2023 16:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695855688; cv=none; d=google.com; s=arc-20160816; b=SGXO1vc7a3NrC6r0/hubm+6VwfYHlxuHDMtd6jhRG8ehBG4gU90HjRuQ1W2ULPloZJ apCYg+ikWzeibqg4Tdt5gBeE2H5aLJSKNftHWUURoo3796GYihh4geSlMJihp1d1Ll3V nr1ZARbej6HNFy3y6SR9vCMZE5mVh0IgsnJ8W4T2OWqO8R1UycQijPlsSVvEDmDNnCCg qjfS7f+8Xw0KYke9zqviKRzUJiM8nGDjlSdf3CyN0T+PKcXQk2mr/Im88ymCMNrxtB/O 9T5m6fkk072BXjramdR/kqoZTon8i7FbB5Ft6b6ukswi063NEoDmzCylZKOhq4+st4ZK ToVQ== 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:in-reply-to :references:mime-version:dkim-signature; bh=XVfo3IwQ/RTkqzINk2Et8vGqwK+wAQzTwLtlllfdR+g=; fh=lxFYggT1XyLo5s9/4Zhs8TGbKyFlHfx31t9brAFAwPg=; b=yWxvudlSSL4KlHr5b8Rl+Xl0hqXQK2GjSiFTaoIe9kIl6LT/+si3JPY35ykL8DX80Z /bzNTlOcTJOqVO7/UoDcmc1YFUoUFRkJXKNE3eyMEtJrSLx9OfjZNP0Fw0a/3SgzenMq k7IfG+vDkc5JXZrGPW7o5d9DalYyayETaqzhZpjBLanpM5yiJfp3XMjBvbr0HWp7wAI4 wHtznf7uqnekPV7/G7uvPspDAzLAUkx7w7BViVXcGZ/fwPMSwbrOj3gopN8EaVr8MS4d nmfhAAPOWK+ifgU24/VE27ED73RLu50AvlFlCKBb+2Lm9aua8pIl9aiQftCcXL47rztm OJWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="N4q5i4/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id m9-20020a056a00080900b0068fba6a7375si18179060pfk.321.2023.09.27.16.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 16:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="N4q5i4/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DAD28801B826; Wed, 27 Sep 2023 10:48:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229460AbjI0Rsm (ORCPT + 99 others); Wed, 27 Sep 2023 13:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjI0Rsl (ORCPT ); Wed, 27 Sep 2023 13:48:41 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56796A1 for ; Wed, 27 Sep 2023 10:48:40 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso1498394866b.1 for ; Wed, 27 Sep 2023 10:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1695836918; x=1696441718; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XVfo3IwQ/RTkqzINk2Et8vGqwK+wAQzTwLtlllfdR+g=; b=N4q5i4/4mytt4AGIf/kpdNYizlCS0wOnWt3ZXUUCSDLPyMmOLkOsgOamSLvjVQushv WOmN/OMFQC64v8ip4jK+Rat3KElRJQ2npWRqIgi16djwTm0S8XY8hvodh6kOrzwFrfWy 7XulAZpjs82oeapYPxXakZuiq8/yqSUulwFBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695836918; x=1696441718; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XVfo3IwQ/RTkqzINk2Et8vGqwK+wAQzTwLtlllfdR+g=; b=AGHALXaRsv6R9YeIl99bwXToAPMkmaMbW84iiq0GwHLO5KTxukjFpvAN8qCBc8aOc6 mpuf6Ls2+4mLkhVMLSFwlk08A2eQrda3NPDURhZH53Zo19vObtf4ndJfvynlT7cm32pl VCfRNxevG7orhIUSBJcoPjSjBpRe+smUGFup7Sr7ho/q5AI2TyzIaGbXaOBgO8G/bkkb JW+skHwULunZfFH/dSWRcgTmByrOfM+4SuwnqWPPfdmGX2yuv7D0XUv2UWBKN5obH0ae yO0e7yX6vSV+dbHIwn4nMlXK2pMh0Loj1ciAd7LXtaoqCJwN1lQOWJ4UQORkj8IZavDh nXLQ== X-Gm-Message-State: AOJu0Yyyb3b75p6yumt5fBpIR21+MJV1/OtOG7226+8DtIrKF+USPj5T 3QCuKZ1X3gEqtiYiFIVhc7sKVQlYKkKEPGtPDSmAoA== X-Received: by 2002:a17:907:6d11:b0:9ae:6a08:6f53 with SMTP id sa17-20020a1709076d1100b009ae6a086f53mr3130854ejc.63.1695836918509; Wed, 27 Sep 2023 10:48:38 -0700 (PDT) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id w12-20020a17090652cc00b0099364d9f0e6sm9592163ejn.117.2023.09.27.10.48.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Sep 2023 10:48:37 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5310a63cf7bso13744825a12.1 for ; Wed, 27 Sep 2023 10:48:37 -0700 (PDT) X-Received: by 2002:aa7:c406:0:b0:52e:9eff:1e5f with SMTP id j6-20020aa7c406000000b0052e9eff1e5fmr2377804edq.15.1695836917305; Wed, 27 Sep 2023 10:48:37 -0700 (PDT) MIME-Version: 1.0 References: <20230926162228.68666-1-mjguzik@gmail.com> <20230927-kosmetik-babypuppen-75bee530b9f0@brauner> In-Reply-To: <20230927-kosmetik-babypuppen-75bee530b9f0@brauner> From: Linus Torvalds Date: Wed, 27 Sep 2023 10:48:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] vfs: shave work on failed file open To: Christian Brauner Cc: Mateusz Guzik , viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Content-Type: multipart/mixed; boundary="0000000000000dc77506065acdeb" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:48:54 -0700 (PDT) --0000000000000dc77506065acdeb Content-Type: text/plain; charset="UTF-8" On Wed, 27 Sept 2023 at 07:10, Christian Brauner wrote: > > No need to resend I can massage this well enough in-tree. Hmm. Please do, but here's some more food for thought for at least the commit message. Because there's more than the "__fput_sync()" issue at hand, we have another delayed thing that this patch ends up short-circuiting, which wasn't obvious from the original description. I'm talking about the fact that our existing "file_free()" ends up doing the actual release with call_rcu(&f->f_rcuhead, file_free_rcu); and the patch under discussion avoids that part too. And I actually like that it avoids it, I just think it should be mentioned explicitly, because it wasn't obvious to me until I actually looked at the old __fput() path. Particularly since it means that the f_creds are free'd synchronously now. I do think that's fine, although I forget what path it was that required that rcu-delayed cred freeing. Worth mentioning, and maybe worth thinking about. However, when I *did* look at it, it strikes me that we could do this differently. Something like this (ENTIRELY UNTESTED) patch, which just moves this logic into fput() itself. Again: ENTIRELY UNTESTED, and I might easily have screwed up. But it looks simpler and more straightforward to me. But again: that may be because I missed something. Linus --0000000000000dc77506065acdeb Content-Type: text/x-patch; charset="US-ASCII"; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ln21i4ht0 IGZzL2ZpbGVfdGFibGUuYyB8IDIyICsrKysrKysrKysrKysrKysrKysrKysKIDEgZmlsZSBjaGFu Z2VkLCAyMiBpbnNlcnRpb25zKCspCgpkaWZmIC0tZ2l0IGEvZnMvZmlsZV90YWJsZS5jIGIvZnMv ZmlsZV90YWJsZS5jCmluZGV4IGVlMjFiM2RhOWQwOC4uNGZiODdhMDM4MmQ5IDEwMDY0NAotLS0g YS9mcy9maWxlX3RhYmxlLmMKKysrIGIvZnMvZmlsZV90YWJsZS5jCkBAIC00MzAsMTEgKzQzM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