Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1742932pxp; Thu, 17 Mar 2022 16:05:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5/2FdlH5PHEs/j3kUMpqk54vy13lpxyRNGlBfOIWtLU7rlZON0Eowef0Ra4WWrnrI3MOq X-Received: by 2002:a05:6402:42d4:b0:416:5cac:a9a0 with SMTP id i20-20020a05640242d400b004165caca9a0mr7040163edc.86.1647558329736; Thu, 17 Mar 2022 16:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647558329; cv=none; d=google.com; s=arc-20160816; b=dch4VFe25BPFHv7xDbQc6Cs7AmAjQwv96bgmGKG0Of48johgXK9d5MKV1ur8ikV/0J xoWuJMaxEGozYoVCimCjyUS7dmpOuh0AinCECrafz+DRKUbSAnEYpWD93ntDL4m1YkMd Ua5IACPFQBuj1emG3SssuqiCmOFfrNRcDumljcEeeqJBKMtnrOm1WI0Tn3tEIvPYLxTL qB7VFuAhxsLpTNNV1NsxkwXV5DWz9hrjz5R+b3g/jlvkjV+k0/XHPA5OCdtsmbscgno/ EjgbHiuSQpa1MyxuWqg2tHVqO1ZH2eYp0UnesDHeTZhRo3V5s3vfUacQ9BJNCtNUGIXi tAOA== 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:date; bh=YcLGF3hzjRHl17QYUUdj2m1wWRl4g8D/v4WH9bGsTOA=; b=XRH9rGQSi/WobWIPaoUAA11Ld80hoFu0BKnstKeH0h5NcKM5+eq4Dw6+xs4Oc2SHKq Np7AOP7UzdPMc+1zuERSLcWwW5XMe2WIwhBHYpf9YKdUyTPi47i6AY3zkDB2R3u7C9dj ZgHNpGSpfl82xa3yg5VWuGT1Ns89O4OUZYUNa6+ENqmK+9uniIQlXPZhEdIUfV3be5tj gNZk/8IObW5jmFvQ+jFWmXg84rZCkHht8R2V41rBzDblJCwK2CwP841YC3jsPMrH08Cm EMux4E64S974kHt1YBKpjM46zj3R51j4hfp0VZOX/G8ytq2OEN7jYmi4UIP2NLqhv3Ft xBfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 w29-20020a50d79d000000b00418c2b5bf03si2197863edi.485.2022.03.17.16.04.57; Thu, 17 Mar 2022 16:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbiCQWxi (ORCPT + 99 others); Thu, 17 Mar 2022 18:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiCQWxi (ORCPT ); Thu, 17 Mar 2022 18:53:38 -0400 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 131B32B4A70; Thu, 17 Mar 2022 15:52:21 -0700 (PDT) Received: from dread.disaster.area (pa49-186-150-27.pa.vic.optusnet.com.au [49.186.150.27]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id A7519533CEA; Fri, 18 Mar 2022 09:52:18 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1nUyye-006iPy-EW; Fri, 18 Mar 2022 09:52:16 +1100 Date: Fri, 18 Mar 2022 09:52:16 +1100 From: Dave Chinner To: Matthew Wilcox Cc: Linus Torvalds , Brian Foster , Linux-MM , linux-fsdevel , linux-xfs , Hugh Dickins , Namjae Jeon , Ashish Sangwan , Theodore Ts'o , Jan Kara , linux-ext4@vger.kernel.org Subject: Re: writeback completion soft lockup BUG in folio_wake_bit() Message-ID: <20220317225216.GB1544202@dread.disaster.area> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=VuxAv86n c=1 sm=1 tr=0 ts=6233bba4 a=sPqof0Mm7fxWrhYUF33ZaQ==:117 a=sPqof0Mm7fxWrhYUF33ZaQ==:17 a=kj9zAlcOel0A:10 a=o8Y5sQTvuykA:10 a=JfrnYn6hAAAA:8 a=7-415B0cAAAA:8 a=7svFRl-LX0UtnufVsbMA:9 a=CjuIK1q_8ugA:10 a=1CNFftbPRP8L7MoqJWF3:22 a=biEYGPWJfzWAr4FL6Ov7:22 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE,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-ext4@vger.kernel.org On Thu, Mar 17, 2022 at 09:16:20PM +0000, Matthew Wilcox wrote: > On Thu, Mar 17, 2022 at 12:26:35PM -0700, Linus Torvalds wrote: > > On Thu, Mar 17, 2022 at 8:04 AM Matthew Wilcox wrote: > > > > > > So how about we do something like this: > > > > > > - Make folio_start_writeback() and set_page_writeback() return void, > > > fixing up AFS and NFS. > > > - Add a folio_wait_start_writeback() to use in the VFS > > > - Remove the calls to set_page_writeback() in the filesystems > > > > That sounds lovely, but it does worry me a bit. Not just the odd > > 'keepwrite' thing, but also the whole ordering between the folio bit > > and the tagging bits. Does the ordering possibly matter? > > I wouldn't change the ordering of setting the xarray bits and the > writeback flag; they'd just be set a little earlier. It'd all be done > while the page was still locked. But you're right, there's lots of > subtle interactions here. > > > That whole "xyz_writeback_keepwrite()" thing seems odd. It's used in > > only one place (the folio version isn't used at all): > > > > ext4_writepage(): > > > > ext4_walk_page_buffers() fails: > > redirty_page_for_writepage(wbc, page); > > keep_towrite = true; > > ext4_bio_write_page(). > > > > which just looks odd. Why does it even try to continue to do the > > writepage when the page buffer thing has failed? > > > > In the regular write path (ie ext4_write_begin()), a > > ext4_walk_page_buffers() failure is fatal or causes a retry). Why is > > ext4_writepage() any different? Particularly since it wants to keep > > the page dirty, then trying to do the writeback just seems wrong. > > > > So this code is all a bit odd, I suspect there are decades of "people > > continued to do what they historically did" changes, and it is all > > worrisome. > > I found the commit: 1c8349a17137 ("ext4: fix data integrity sync in > ordered mode"). Fortunately, we have a documented test for this, > generic/127, so we'll know if we've broken it. Looks like a footgun. ext4 needs the keepwrite stuff for block size < page size, in the case where a page has both written and delalloc/unwritten buffers on it. In that case ext4_writepage tries to write just the written blocks and leave the dealloc/unwritten buffers alone because it can't do allocation in ->writepage context. I say footgun, because the nested ->writepage call that needs keepwrite comes a from journal stop context in the high level ->writepages context that is doing allocation that will allow the entire page to be written. i.e. it seems a bit silly to be triggering partial page writeback that skips delalloc/unwritten extents, but then needs special awareness of higher level IO that is in progress that is currently doing the allocation that will allow all the delalloc/unwritten extents on the page to also be written back... Cheers, Dave. -- Dave Chinner david@fromorbit.com