Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19513058rwd; Wed, 28 Jun 2023 10:13:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WSgAddue9Q1iw6tLueked0gxCU+C2OnlilMWX0UQVcfPoMug+MbG6XGUEf/Vqo0NE7xxa X-Received: by 2002:a17:902:b108:b0:1b0:6541:91c2 with SMTP id q8-20020a170902b10800b001b0654191c2mr9064308plr.63.1687972437104; Wed, 28 Jun 2023 10:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687972437; cv=none; d=google.com; s=arc-20160816; b=w0bZzXlJFszBHaH1MEgZqCodFpSDMyl8kgAyBvZYs8TD4SIl96T8O41Gk/SrtXlfO2 iZmWMwKL7Gwl8TL1hgmPZi0TIeHPwq2oZglfgvpbqLi6yMd96KFtYzcYfSc2warNQa7/ Eh+hEZTOjOOtI6s8iNCLitQ0JBYGPwHesd9IsWmaHuWfHUhrn/szamahEJi3FK+6Kz5p wzicUGAWM3fjm1yr8VYJD6Va+GRX4DbWOSASAFxA+zYs1pPTQ4JGW614rc+9QNsiHba1 yLZShpcHJBgL1lvEUcCbsQsiPdpaw0ghdRjIiMuBJeXq097Grs27YCaK4dgBHtu6eTLM 7UNg== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=OppdXy0w3Vc+UjmlsI4lMkBExnAWB4DyrS+PHEKoceA=; fh=PI/1SKw/LOrVb3HiIMxFEhlLWI70yqT6Cc8h2Cs0I+k=; b=XRqaUucjlDEBhe5SW0Tn6Hi2z0T4YGEPSkw1AWGsRHjId6vc0QcVqLSK9tqBc1RH/K nY2fK7VWr0/8l/lWtgaeRp9HgLF6qLvvDalGqbroEx2pY5xoNEQAz6LEc4joKfuLxoPt //cBZ7bXqWmZYuIBeMCd5rOhWrg1sPTtqo/yqzCU691dv26L6Iz4v0sdzD99RLKSpYj2 zPglfZSI9UY10ZXmGHldRJ2cRMFlw2hjKO4tUtR+4xCzEfE42CseTJ5HQfdILkTpgsaL LFitgvraAzaJN49TddHhpqJjd2oFzfFBi3FrTuH5ZoTNszt/Bffc1IVvN3jZNagzIKcf 20hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=kNjUcJWz; 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 n10-20020a1709026a8a00b001b11168bdddsi6047545plk.520.2023.06.28.10.13.42; Wed, 28 Jun 2023 10:13: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=kNjUcJWz; 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 S231969AbjF1Q5K (ORCPT + 99 others); Wed, 28 Jun 2023 12:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbjF1Q5I (ORCPT ); Wed, 28 Jun 2023 12:57:08 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D6B7170F for ; Wed, 28 Jun 2023 09:57:04 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-34577a22c7cso5245575ab.0 for ; Wed, 28 Jun 2023 09:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1687971423; x=1690563423; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=OppdXy0w3Vc+UjmlsI4lMkBExnAWB4DyrS+PHEKoceA=; b=kNjUcJWz6/3eNA0QHbffaSQ/2PJIrvcsm/+xdC+zVxYPWoP7EO/wyCrxhXal295cRr sDydonv+8x9QeXkEb3XBXcfrldsTqBCIeDH7NZ3Yek6Pd/05n4rP4sv55/fzzJef2inv RALnk5sSbYIBXBtpDby7kzoNfIrKBoGSFpG+hyHVIdWWjXH6rsdLS9ESAVomK5KTX35J pxnTiTEw6UW1o6pSi3/dA3gJ/gD3pQZDE6mhN3fNtGrWFrpok0wyr398iMXxTIj9J1JC iDbJaXhoMIgSDW3IOHoqNJqg0TMS9w3UU8R3QOSRkrY56/kL4DUZG1geNfwaL0as6//K xMjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687971423; x=1690563423; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OppdXy0w3Vc+UjmlsI4lMkBExnAWB4DyrS+PHEKoceA=; b=SAUUrAtpeBv4YCUesCX30h1ThYD6zFjaW1xSYjtg3/Ju4ntgJ9nXtt1lSwMiTJDZSE LNWHybk9lct6onvOCAG3aZWGmI++cZVUA8c/h44uxLdUD4M2WYvvgdbAC63yJTqcVk50 C67nCDtCPyV5QFcnXyhi+uFwfvLcJJZuCBs9Pe17ukLbxIGkPJHOpuP4Kz0G8Z11SkP3 KciKr3XYX/hFQSqsoxmoW6lnzk+c6lrqlp/ASmu85atJUdby9N7rL08Zz43qikD2mZAu ewe3Yoo22E4bZwt/FjFNEzD+3N76fSBvTfnhN0yWMvv3lpf2nAXslFqRRPJMwYNkvJEn Ueqg== X-Gm-Message-State: AC+VfDz4Qbz1w6EoLUqvUQvRoiftjwzeT5dWl3NuVBoigKn41HSIbX9a AjTsndMCXbN1xz28y7nY5oiFfTzqe/Do8X3PpFY= X-Received: by 2002:a6b:3b06:0:b0:780:cde6:3e22 with SMTP id i6-20020a6b3b06000000b00780cde63e22mr17644062ioa.0.1687971423454; Wed, 28 Jun 2023 09:57:03 -0700 (PDT) Received: from [192.168.1.94] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id dq34-20020a0566384d2200b0042566919376sm3173364jab.30.2023.06.28.09.57.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jun 2023 09:57:02 -0700 (PDT) Message-ID: <4b863e62-4406-53e4-f96a-f4d1daf098ab@kernel.dk> Date: Wed, 28 Jun 2023 10:57:02 -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 From: Jens Axboe 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 References: <20230626214656.hcp4puionmtoloat@moria.home.lan> <20230627000635.43azxbkd2uf3tu6b@moria.home.lan> <91e9064b-84e3-1712-0395-b017c7c4a964@kernel.dk> <20230627020525.2vqnt2pxhtgiddyv@moria.home.lan> <23922545-917a-06bd-ec92-ff6aa66118e2@kernel.dk> <20230627201524.ool73bps2lre2tsz@moria.home.lan> <20230628040114.oz46icbsjpa4egpp@moria.home.lan> In-Reply-To: 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 8:58?AM, Jens Axboe wrote: > On 6/27/23 10:01?PM, Kent Overstreet wrote: >> On Tue, Jun 27, 2023 at 09:16:31PM -0600, Jens Axboe wrote: >>> On 6/27/23 2:15?PM, Kent Overstreet wrote: >>>>> to ktest/tests/xfstests/ and run it with -bcachefs, otherwise it kept >>>>> failing because it assumed it was XFS. >>>>> >>>>> I suspected this was just a timing issue, and it looks like that's >>>>> exactly what it is. Looking at the test case, it'll randomly kill -9 >>>>> fsstress, and if that happens while we have io_uring IO pending, then we >>>>> process completions inline (for a PF_EXITING current). This means they >>>>> get pushed to fallback work, which runs out of line. If we hit that case >>>>> AND the timing is such that it hasn't been processed yet, we'll still be >>>>> holding a file reference under the mount point and umount will -EBUSY >>>>> fail. >>>>> >>>>> As far as I can tell, this can happen with aio as well, it's just harder >>>>> to hit. If the fput happens while the task is exiting, then fput will >>>>> end up being delayed through a workqueue as well. The test case assumes >>>>> that once it's reaped the exit of the killed task that all files are >>>>> released, which isn't necessarily true if they are done out-of-line. >>>> >>>> Yeah, I traced it through to the delayed fput code as well. >>>> >>>> I'm not sure delayed fput is responsible here; what I learned when I was >>>> tracking this down has mostly fell out of my brain, so take anything I >>>> say with a large grain of salt. But I believe I tested with delayed_fput >>>> completely disabled, and found another thing in io_uring with the same >>>> effect as delayed_fput that wasn't being flushed. >>> >>> I'm not saying it's delayed_fput(), I'm saying it's the delayed putting >>> io_uring can end up doing. But yes, delayed_fput() is another candidate. >> >> Sorry - was just working through my recollections/initial thought >> process out loud > > No worries, it might actually be a combination and this is why my > io_uring side patch didn't fully resolve it. Wrote a simple reproducer > and it seems to reliably trigger it, but is fixed with an flush of the > delayed fput list on mount -EBUSY return. Still digging... I discussed this with Christian offline. I have a patch that is pretty simple, but it does mean that you'd wait for delayed fput flush off umount. Which seems kind of iffy. I think we need to back up a bit and consider if the kill && umount really is sane. If you kill a task that has open files, then any fput from that task will end up being delayed. This means that the umount may very well fail. It'd be handy if we could have umount wait for that to finish, but I'm not at all confident this is a sane solution for all cases. And as discussed, we have no way to even identify which files we'd need to flush out of the delayed list. Maybe the test case just needs fixing? Christian suggested lazy/detach umount and wait for sb release. There's an fsnotify hook for that, fsnotify_sb_delete(). Obviously this is a bit more involved, but seems to me that this would be the way to make it more reliable when killing of tasks with open files are involved. -- Jens Axboe