Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18916503rwd; Wed, 28 Jun 2023 02:26:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Dj3CzJx5HH4YLKo/goVg+p0po8MvbmUQFGu+77l2oCw1QBxN1gYkU4Iyg8AlhlaRDUd4o X-Received: by 2002:a17:907:2683:b0:957:1df0:9cbf with SMTP id bn3-20020a170907268300b009571df09cbfmr25513198ejc.19.1687944371898; Wed, 28 Jun 2023 02:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687944371; cv=none; d=google.com; s=arc-20160816; b=x2ihsY11JSdoc1kNUixIdOjdXanfgc2doe376f4O7ByopmpcpKoHFVYCezmuB25ud8 drQubkUl513t9GPBWYDxjC5eVDrEysUKcAxaZbPfuEUuILV1WmVUBZhPz5Ip7PJcDyas Q8rR48BZVWc8GA0EJp6SQBZr8vH6kuGkCebiNqEp6ZIK6Ebew76VeBjypR6jG2yXEgz0 thy9uUchCPm9YOWAtxNF5T2tFN2fb2lk+Dvajl44FTu/WyqcxA/Hj42lB4KQ2f0778wf a524QoP+kBKNLLWDCSlEXG3cMQffT/4jk+6h6L49oHTAc7lhhOPmvuubPfB9YIG29ZJV JMhg== 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=3MLw7YcFyHXR1rN5vXFnw1a8aCPs+A9s2/LGEzLo8qM=; fh=/s47CaCEDhlW7/xNltsO0ZLgxGiv87pyxqiGY+c1ycs=; b=yC6ovs4e62ADhLIO+gYbZ2z4+Qclscmf6IrJSyN99XnTLRzW9+x5HHUv3XCZkrgiYb sPtVrGGMRZHF83aE87yufxFMEI5HfvfjIK138e90UM4euHY9u2zQecLp6pwP+iaU+7jq oXjHDrT6nls154+A9v5L/6PNfM2fXyMhlgHtNxkVIRAEezazaaTY+GnJ++Qqn6ex1u0t HOE2ojHNloRqZGwmY4U/tV8jcD+fhkBtW3iPyYQyTIiHeEQSWj3ASWSeObVJZbku0wyV GAZUcZFymLcGNKPG+uYlSTZm1PlUArZwA0yFi8SR0NR07X54cCfiNAY09/JnPMozRdDG CCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aj6TIes7; 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 f9-20020a170906138900b00991df467babsi2875345ejc.221.2023.06.28.02.25.47; Wed, 28 Jun 2023 02:26:11 -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=aj6TIes7; 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 S232700AbjF1IGQ (ORCPT + 99 others); Wed, 28 Jun 2023 04:06:16 -0400 Received: from out-11.mta0.migadu.com ([91.218.175.11]:33301 "EHLO out-11.mta0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbjF1H7f (ORCPT ); Wed, 28 Jun 2023 03:59:35 -0400 Date: Wed, 28 Jun 2023 00:01:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687924878; 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=3MLw7YcFyHXR1rN5vXFnw1a8aCPs+A9s2/LGEzLo8qM=; b=aj6TIes7oOUyqpykYgyoMBDptalfUM0KTr/OPLio/mbmnynZwD8KXLCDn3MRznzt7sygDX 8EIv/2H4MHtchcfITbpjvVtcZZWgjp75sSBSIkI2n989zgtnTcO/7yz86m60ocjM6j2y+a Bc8yv9wy54HOUpQ3+APVfZYcFyI0vYU= 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: <20230628040114.oz46icbsjpa4egpp@moria.home.lan> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >> 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 wonder if there might be a better way of solving this though? For aio, > > when a process is exiting we just synchronously tear down the ioctx, > > including waiting for outstanding iocbs. > > aio is pretty trivial, because the only async it supports is O_DIRECT > on regular files which always completes in finite time. io_uring has to > cancel etc, so we need to do a lot more. ahh yes, buffered IO would complicate things > But the concept of my patch should be fine, but I think we must be > missing a case. Which is why I started writing a small reproducer > instead. I'll pick it up again tomorrow and see what is going on here. Ok. Soon as you've got a patch I'll throw it at my CI, or I can point my CI at your branch if you have one.