Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19582838rwd; Wed, 28 Jun 2023 11:09:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ow67OQ6x9Mm3DxacSvAyKr7WTP4PfBUccjQvQ83R4BZblHpygY387Tn/JZrl0tSuOIo64 X-Received: by 2002:aa7:d51a:0:b0:51a:4451:564d with SMTP id y26-20020aa7d51a000000b0051a4451564dmr2200377edq.18.1687975741557; Wed, 28 Jun 2023 11:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687975741; cv=none; d=google.com; s=arc-20160816; b=hLinpAKhGJ58xP4dS6tbKWUnOYpCeyuWG+4zJWfb2azsQ36EV3lDX6PFjkn6HYdazh YwweT/atxLkaI8ffPEA8Fd9Veaaqj/PONzRIBau5eQgK0Kkm1rPI2SzNGMqSw3oQ6lO9 GCq0MjGHLh5N7rJnN7ERk5B9LMPmPLMe03UqDq6wfOUb7v5IXJLWvz73ZDAwa0xyJ3vH oPa0jMCe9ohf05aRD2mJTjBFgGD3ac9B4wCaEuVJn6E9u0IFvzuU9cxTbAt2rUnflarH ifo5xd4+n875Dxhrn0vOdq2iM9YMaArmk5dzmwY/aJvfiRROm3YMUwuFF3v3z9/A6Va+ ERQQ== 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:dkim-signature:date; bh=VRH/yiaIBt1BGCK3wtECdRcCU9jSpluW9EcBNgvsUZU=; fh=/s47CaCEDhlW7/xNltsO0ZLgxGiv87pyxqiGY+c1ycs=; b=A/dNHx1iOz5PvS4yziVm4gtE8DWqRBDyRupVyXC99D5TNT136tjDrG++8REvgoGrRO a/9nMVUHJRENLFfbTgDEDXFN5d/QYTM40XA3RqAGg/JBTpPrOJ+FFRHsSYdeHI7Dwlyc 1iWxoms0VBTyK6gBu/L6dlmyQjEuTTL+E7crLzCdeNkPwlWTdWue2234aozciIX/A+mq AtuQxwrqylVSPl5NQN/NIpkq7kRrDNO98cECM5AlFIm2u8gSCG0nzXh9PPC+LXOS5UAr Wj+oGLcgtxCNXvvXFKPA/O2mGRiB4C7urMdCVfQobfRQDqQTPHj8Jrz6Jq7SfK0LFCNs yxHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MNqyMbbn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020aa7de0f000000b0051dd4c0b740si392177edv.66.2023.06.28.11.08.35; Wed, 28 Jun 2023 11:09:01 -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=@linux.dev header.s=key1 header.b=MNqyMbbn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbjF1Ryv (ORCPT + 99 others); Wed, 28 Jun 2023 13:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbjF1Ry3 (ORCPT ); Wed, 28 Jun 2023 13:54:29 -0400 Received: from out-26.mta1.migadu.com (out-26.mta1.migadu.com [IPv6:2001:41d0:203:375::1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F196C26AB for ; Wed, 28 Jun 2023 10:54:27 -0700 (PDT) Date: Wed, 28 Jun 2023 13:54:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687974866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VRH/yiaIBt1BGCK3wtECdRcCU9jSpluW9EcBNgvsUZU=; b=MNqyMbbnZiCc0I0Xram44Jla0y7J5h8Xng6BNCps9hB5HnKKtOt8PaTwzbl02cGEuytao1 fvIE5RX5Srmla/V6Oji1qfcWNYSvjHLfnM1Ymsl88LaXSIrrh6ixRrXYOj2DhnShnWI8fN mImGAj5Z79IRah4+01pAZv1KBAjHnWE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Jens Axboe Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, Christoph Hellwig Subject: Re: [GIT PULL] bcachefs Message-ID: <20230628175421.funhhfbx5kdvhclx@moria.home.lan> References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, Jun 28, 2023 at 08:58:45AM -0600, 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... > > >>>> For io_uring specifically, it may make sense to wait on the fallback > >>>> work. The below patch does this, and should fix the issue. But I'm not > >>>> fully convinced that this is really needed, as I do think this can > >>>> happen without io_uring as well. It just doesn't right now as the test > >>>> does buffered IO, and aio will be fully sync with buffered IO. That > >>>> means there's either no gap where aio will hit it without O_DIRECT, or > >>>> it's just small enough that it hasn't been hit. > >>> > >>> I just tried your patch and I still have generic/388 failing - it > >>> might've taken a bit longer to pop this time. > >> > >> Yep see the same here. Didn't have time to look into it after sending > >> that email today, just took a quick stab at writing a reproducer and > >> ended up crashing bcachefs: > > > > You must have hit an error before we finished initializing the > > filesystem, the list head never got initialized. Patch for that will be > > in the testing branch momentarily. > > I'll pull that in. In testing just now, I hit a few more leaks: > > unreferenced object 0xffff0000e55cf200 (size 128): > comm "mount", pid 723, jiffies 4294899134 (age 85.868s) > hex dump (first 32 bytes): > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [<000000001d69062c>] slab_post_alloc_hook.isra.0+0xb4/0xbc > [<00000000c503def2>] __kmem_cache_alloc_node+0xd0/0x178 > [<00000000cde48528>] __kmalloc+0xac/0xd4 > [<000000006cb9446a>] kmalloc_array.constprop.0+0x18/0x20 > [<000000008341b32c>] bch2_fs_alloc+0x73c/0xbcc Can you faddr2line this? I just did a bunch of kmemleak testing and didn't see it. > unreferenced object 0xffff0000e55cf480 (size 128): > comm "mount", pid 723, jiffies 4294899134 (age 85.868s) > hex dump (first 32 bytes): > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [<000000001d69062c>] slab_post_alloc_hook.isra.0+0xb4/0xbc > [<00000000c503def2>] __kmem_cache_alloc_node+0xd0/0x178 > [<00000000cde48528>] __kmalloc+0xac/0xd4 > [<0000000097f806f1>] __prealloc_shrinker+0x3c/0x60 > [<000000008ff20762>] register_shrinker+0x14/0x34 > [<000000003d050c32>] bch2_fs_btree_key_cache_init+0x88/0x90 > [<00000000d9f351c0>] bch2_fs_alloc+0x7c0/0xbcc > [<000000003b8339fd>] bch2_fs_open+0x19c/0x430 > [<00000000aef40a23>] bch2_mount+0x194/0x45c > [<0000000005e49357>] legacy_get_tree+0x2c/0x54 > [<00000000f5813622>] vfs_get_tree+0x28/0xd4 > [<00000000ea6972ec>] path_mount+0x5d0/0x6c8 > [<00000000468ec307>] do_mount+0x80/0xa4 > [<00000000ea5d305d>] __arm64_sys_mount+0x150/0x168 > [<00000000da6d98cb>] invoke_syscall.constprop.0+0x70/0xb8 > [<000000008f20c487>] do_el0_svc+0xbc/0xf0 This one is actually a bug in unregister_shrinker(), I have a patch I'll have to send to Andrew.