Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp564242rwr; Thu, 4 May 2023 07:01:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5W0CRdn3YVwKb/2g8ss7sjlIqV8g/d0Sm/bkMHMcc6zlrzwqZjl4Yi4G4cC0SsHLeUhAQp X-Received: by 2002:a17:90a:2b45:b0:23f:83de:7e4a with SMTP id y5-20020a17090a2b4500b0023f83de7e4amr2161758pjc.7.1683208869549; Thu, 04 May 2023 07:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683208869; cv=none; d=google.com; s=arc-20160816; b=n05SrVhM26hnj8GPN/AH4APfQ32M787cNDuKde8Vlp2MWAERj9VAwOP7CC0+2gY7j5 t5KGYuBHuJ3Wjb+PoW6dMe/1gYbMF8eG7rmOME80XE5rTAWEclH1287GKCW2F+ECfoxD nsFaZ5ewZS3P+tOysfAmyuRDtx1qufbU+jrLkPOyyPROnDmwY6LdS7raP3t9I8Mpw2/u +j6Jb/J+9NKlKj9XnB3S1uN9I6L9Qh9maXueeDfa/IOrs1HkcvJA5BJbbUJvivCof7J4 L42qu0r67mHSFpFg4IsOPYh+WNVEEvP1s8/6771WbTCAbbLASZlnXRJSQQ9O6NUI3Zme 2rGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Ujqdxg84KzJof0UErD+NJvf1ePaMuz+ykB/lN6IGGZM=; b=lao6adIFrb6C8k6k0F8KjKJ6VwqPC/ivcqhi710nE0OSZPoaL2PBrrUQ54SxQfajX0 njngceo2RHsH94hdisIKj2j4m9zaZTMt49MM+u0plYhANmAOBjio1hheRYuNl394vT5J NXb88Z1V8xC4/fbtHPimlbdwi+l38xWwaYmoerGRcJgD8ZQsDZqBFR48bHBih8gMwwBS YWuJUAPBu/ZlpezpjIOSK/IozRwi3eJaoD2KCkgwMd4hUecWUKyT3eiJvmfGNG1XRWSb GneuIBLURNgvnbBkwr/+AMug0Tu4bwaM8Dcob0C8UEOUSikLrTwaTvMyVJvzZ2OQjMYw rmRw== ARC-Authentication-Results: i=1; mx.google.com; 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 y2-20020a17090a6c8200b0024e0d0ebda1si3949991pjj.75.2023.05.04.07.00.53; Thu, 04 May 2023 07:01:09 -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; 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 S231219AbjEDNzV (ORCPT + 99 others); Thu, 4 May 2023 09:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjEDNzU (ORCPT ); Thu, 4 May 2023 09:55:20 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2477D9F; Thu, 4 May 2023 06:55:19 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id A7D4368AA6; Thu, 4 May 2023 15:55:15 +0200 (CEST) Date: Thu, 4 May 2023 15:55:15 +0200 From: Christoph Hellwig To: Ilya Dryomov Cc: Christoph Hellwig , Jan Kara , Johannes Thumshirn , Jens Axboe , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: always respect QUEUE_FLAG_STABLE_WRITES on the block device Message-ID: <20230504135515.GA17048@lst.de> References: <20230504105624.9789-1-idryomov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230504105624.9789-1-idryomov@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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-kernel@vger.kernel.org On Thu, May 04, 2023 at 12:56:24PM +0200, Ilya Dryomov wrote: > Commit 1cb039f3dc16 ("bdi: replace BDI_CAP_STABLE_WRITES with a queue > and a sb flag") introduced a regression for the raw block device use > case. Capturing QUEUE_FLAG_STABLE_WRITES flag in set_bdev_super() has > the effect of respecting it only when there is a filesystem mounted on > top of the block device. If a filesystem is not mounted, block devices > that do integrity checking return sporadic checksum errors. With "If a file system is not mounted" you want to say "when accessing a block device directly" here, right? The two are not exclusive.. > Additionally, this commit made the corresponding sysfs knob writeable > for debugging purposes. However, because QUEUE_FLAG_STABLE_WRITES flag > is captured when the filesystem is mounted and isn't consulted after > that anywhere outside of swap code, changing it doesn't take immediate > effect even though dumping the knob shows the new value. With no way > to dump SB_I_STABLE_WRITES flag, this is needlessly confusing. But very much intentional. s_bdev often is not the only device in a file system, and we should never reference if from core helpers. So I think we should go with something like this: diff --git a/mm/page-writeback.c b/mm/page-writeback.c index db794399900734..aa36cc2a4530c1 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -3129,7 +3129,11 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); */ void folio_wait_stable(struct folio *folio) { - if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) + struct inode *inode = folio_inode(folio); + struct super_block *sb = inode->i_sb; + + if ((sb->s_iflags & SB_I_STABLE_WRITES) || + (sb_is_blkdev_sb(sb) && bdev_stable_writes(I_BDEV(inode)))) folio_wait_writeback(folio); } EXPORT_SYMBOL_GPL(folio_wait_stable);