Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20030718rwd; Wed, 28 Jun 2023 18:47:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+w7KyLDX7AkGdVy7Y5ZrHGRvjZHt4V5iyH+LjmMfadStCyR78Wx+wEo8PxZX2VmLUeec5 X-Received: by 2002:a05:6a20:1606:b0:129:b86a:2a83 with SMTP id l6-20020a056a20160600b00129b86a2a83mr8749017pzj.53.1688003277057; Wed, 28 Jun 2023 18:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688003277; cv=none; d=google.com; s=arc-20160816; b=ivSJz2VzcyoGUVooZunvVKzvpaTyWTwjC9k1gx9SVEdTQ7Y7yRQpbQ/b8OkV4ODG1W yoNbFk6qOb4+b8htdUfhNG/QPy0s169rj57KhhlV2wvvltfLpif0OItRS45heZuQllRr ltfw4wXEVg1iDjMR/Qm+0Zk/lDx1PVZcglFGo3LXLBtp/dvrshyw5aQG5O6iz5F73nMR p5GG3OhoZwN9xtKeRScKuGSfP45lVFfWDxmhWkminB3snMqGELBRL3yYLa8Ky15v+jvm +ktgPabj5vaalLK1TLlZnfAwg3G/826KoL9cWdKZolNj+VwkGoLWq6msX0tHT6cSlARB o6fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=D8kLyZ1+w+5+PCjKyBOmPVGH/ZOinGE085j6jsL1WTU=; fh=GlLie4/BvyG9HFmLRy3ceDcVH12sYJwMavTUwn1HIzg=; b=AXv+iCJ6SZbxSm4kJMpnT2LMqTHJf6x9CTeLOomOZ/c7HQWrG6fAm/yUVw8G4FnOIh 7wCITlPOGzjqWJfGYdUnPVwSRAnmW+NVV6u5Mg2BXbcnacdr9FELjqMRC000+00Byjlz KaBncxYfdDEJYMLcmAWI166mTwlnqi0p3o0VKFCb+6ZQdmuAaFpy6fiZ7412bXAZmq1n TFQKK7g9U5cHJOQ2OX/fEiNCzQ7hUmFJFKQGTX1F5Ht7nmsfR6FslO06lLqXGqv/b4wV BWON9bJqL61wOTa+ce5kFnflW+yaN49ZTw3arw3zXJ1S2o2EEs9xlYBQ8G4pW1bwWB6R tAPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=OZRopHdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a056a00191400b0065296ab4747si9662422pfi.193.2023.06.28.18.47.42; Wed, 28 Jun 2023 18:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=OZRopHdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231645AbjF2B3j (ORCPT + 99 others); Wed, 28 Jun 2023 21:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjF2B3h (ORCPT ); Wed, 28 Jun 2023 21:29:37 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6156226AD for ; Wed, 28 Jun 2023 18:29:36 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1b7f42e1dbaso301435ad.0 for ; Wed, 28 Jun 2023 18:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1688002176; x=1690594176; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=D8kLyZ1+w+5+PCjKyBOmPVGH/ZOinGE085j6jsL1WTU=; b=OZRopHdDUGPBQex3VPOlm/NmRjnCf90aWLNF9FSzQgprXQqF2vLpUGtXSyS6juF1EX 8GdGGkQzy5f6kZFKCRW3XFREFplpsOpIG7rBEv7p+uYbxd/mgAa81jyFHRszAa5ZPTwy IDX53XBLApVkMACsjBJ2wWanBrwM8gmTYc6tmXA9S7ASqTr8J/NE9XpER6JAcqZdK6SI 1DklFSNWshW8L4+baZzhVriukVMVrSWXSi10WBjf6/OFPWKAEfr4J3gXVbyrdY2jH+zL oXh80huBzrcQequtrlXlTsRGosL+TYZTo/XH4cFNpSGZn1xk5n+3vcZAe9bl7nYfGAoE L9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688002176; x=1690594176; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=D8kLyZ1+w+5+PCjKyBOmPVGH/ZOinGE085j6jsL1WTU=; b=actLVgLBotXiumZf5sqaoscb+W5hqqxr+QFJxgpF32dET14Fz8WaHt3f37x31lLfIk n6I2Q1KMiuySfZfs07o2r8AsNbNMPHocD8b8HIMzfy+c1n8/7I393q6UtdekufCO6APN k7tHwovGhtJYsqrL3QPdgwnlTP5mxwCUq9UtL1RaCU7xw8YbugdYFmo4aMrMJHPtqLlu hzAeZdw6wTkqz6TnqsjdEIgcSw6I6cArRgGWIa8YphZkGqtksJMy8WECUCnSIdJJPu6Q nv+83Bie0o/AQt+aCh8o7JzqXQsLCuTdwANpMhgIVoine9PfCnjcjjzq7RafTcMSOroM dbOw== X-Gm-Message-State: AC+VfDxyhGqE5FYbNYXZGRoYdwXI15i7PebJw3hRThjS78i8DMw60IPs 8r8Gdpt1ejnvCkMK7g4VAArZPg== X-Received: by 2002:a17:903:3303:b0:1b8:1591:9f81 with SMTP id jk3-20020a170903330300b001b815919f81mr7969622plb.4.1688002175762; Wed, 28 Jun 2023 18:29:35 -0700 (PDT) Received: from [192.168.1.136] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id w23-20020a1709027b9700b001a6d4ea7301sm8211541pll.251.2023.06.28.18.29.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jun 2023 18:29:34 -0700 (PDT) Message-ID: Date: Wed, 28 Jun 2023 19:29:33 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [GIT PULL] bcachefs Content-Language: en-US To: Kent Overstreet Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, Christoph Hellwig , Christian Brauner , Al Viro References: <20230628040114.oz46icbsjpa4egpp@moria.home.lan> <4b863e62-4406-53e4-f96a-f4d1daf098ab@kernel.dk> <20230628175204.oeek4nnqx7ltlqmg@moria.home.lan> <2e635579-37ba-ddfc-a2ab-e6c080ab4971@kernel.dk> <20230628221342.4j3gr3zscnsu366p@moria.home.lan> <20230628225514.n3xtlgmjkgapgnrd@moria.home.lan> <1e2134f1-f48b-1459-a38e-eac9597cd64a@kernel.dk> <20230628235018.ttvtzpfe42fri4yq@moria.home.lan> From: Jens Axboe In-Reply-To: <20230628235018.ttvtzpfe42fri4yq@moria.home.lan> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On 6/28/23 5:50?PM, Kent Overstreet wrote: > On Wed, Jun 28, 2023 at 05:14:09PM -0600, Jens Axboe wrote: >> On 6/28/23 4:55?PM, Kent Overstreet wrote: >>>> But it's not aio (or io_uring or whatever), it's simply the fact that >>>> doing an fput() from an exiting task (for example) will end up being >>>> done async. And hence waiting for task exits is NOT enough to ensure >>>> that all file references have been released. >>>> >>>> Since there are a variety of other reasons why a mount may be pinned and >>>> fail to umount, perhaps it's worth considering that changing this >>>> behavior won't buy us that much. Especially since it's been around for >>>> more than 10 years: >>> >>> Because it seems that before io_uring the race was quite a bit harder to >>> hit - I only started seeing it when things started switching over to >>> io_uring. generic/388 used to pass reliably for me (pre backpointers), >>> now it doesn't. >> >> I literally just pasted a script that hits it in one second with aio. So >> maybe generic/388 doesn't hit it as easily, but it's surely TRIVIAL to >> hit with aio. As demonstrated. The io_uring is not hard to bring into >> parity on that front, here's one I posted earlier today for 6.5: >> >> https://lore.kernel.org/io-uring/20230628170953.952923-4-axboe@kernel.dk/ >> >> Doesn't change the fact that you can easily hit this with io_uring or >> aio, and probably more things too (didn't look any further). Is it a >> realistic thing outside of funky tests? Probably not really, or at least >> if those guys hit it they'd probably have the work-around hack in place >> in their script already. >> >> But the fact is that it's been around for a decade. It's somehow a lot >> easier to hit with bcachefs than XFS, which may just be because the >> former has a bunch of workers and this may be deferring the delayed fput >> work more. Just hand waving. > > Not sure what you're arguing here...? > > We've had a long standing bug, it's recently become much easier to hit > (for multiple reasons); we seem to be in agreement on all that. All I'm > saying is that the existence of that bug previously is not reason to fix > it now. Not really arguing, just stating that it's not a huge problem as it's not something that real world would tend to do and probably why we saw it in a test case instead. >>>> then we'd probably want to move that deferred fput list to the >>>> task_struct and ensure that it gets run if the task exits rather than >>>> have a global deferred list. Currently we have: >>>> >>>> >>>> 1) If kthread or in interrupt >>>> 1a) add to global fput list >>>> 2) task_work_add if not. If that fails, goto 1a. >>>> >>>> which would then become: >>>> >>>> 1) If kthread or in interrupt >>>> 1a) add to global fput list >>>> 2) task_work_add if not. If that fails, we know task is existing. add to >>>> per-task defer list to be run at a convenient time before task has >>>> exited. >>> >>> no, it becomes: >>> if we're running in a user task, or if we're doing an operation on >>> behalf of a user task, add to the user task's deferred list: otherwise >>> add to global deferred list. >> >> And how would the "on behalf of a user task" work in terms of being >> in_interrupt()? > > I don't see any relation to in_interrupt? Just saying that you'd now need the task passed in. > We'd have to add a version of fput() that takes an additional > task_struct argument, and plumb that through the aio code - kioctx > lifetime is tied to mm_struct, not task_struct, so we'd have to add a > ref to the task_struct to kiocb. > > Which would probably be a good thing tbh, it'd let us e.g. account cpu > time back to the original task when kiocb completion has to run out of a > workqueue. Might also introduce some funky dependencies. Probably not an issue it tied to the aio_kiocb. If you go ahead with that, just make sure you keep the task referencing out of the fput variant for users that don't need that. -- Jens Axboe