From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13CDDC7EE23 for ; Thu, 4 May 2023 15:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 213486B0075; Thu, 4 May 2023 11:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C1996B0078; Thu, 4 May 2023 11:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D8326B007B; Thu, 4 May 2023 11:03:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by kanga.kvack.org (Postfix) with ESMTP id C90F86B0075 for ; Thu, 4 May 2023 11:03:52 -0400 (EDT) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-965cc5170bdso15742366b.2 for ; Thu, 04 May 2023 08:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683212632; x=1685804632; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PZPwucIW5GqDao1eoawq4R9XIujOBKLVJb6Au+5ZDSc=; b=gMEnOLVhFevCkTaFlzLDRn9DF2WZ755pRUNhY+AQ3DVxSPSeHj3FKAHKoLHcEX9u51 npPKzWX1r3ElINBDxyLofVS37AKuZgSA6P77vFZSjLiEOGOUZ9fGPFBRGUcRTDXBe5ex kjKs9i5zQvyy96wdlgTg2cgU3egROci/oom5qnaScJavK92TfjiK1bsEYn79zr8nBu64 PJj8dAYaFLE3LtxEleo2p++bg5zr3kCnTx4u3/YcQRlYMG9IeOD2RXsgpjklKs+uTXXk aMgLrwfdU/j1PPMHV/cKKvchslR3O6D3g7+fQiIB+M5hNGgnMvUujt3nIF6CmbKGF4gJ ZB/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683212632; x=1685804632; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PZPwucIW5GqDao1eoawq4R9XIujOBKLVJb6Au+5ZDSc=; b=M2noEAmvjMJ8uqK+oN8OJsXRLP/aywbuSFB9aV3goTiEDBA5YTiVw6orspYkCn6bxS oWohACWUSbeaGZ8QMrl0fYCcQdv58TiU5WOZRHR3CTvJhx5zW70Lf3/kwWRkBhkOllyq nisRNJTa9WBbXvaV9soHmtDJOIk0Iphzn6Lc32073EKNQCiisfv8Z389QyK1slPGq8Qj G2kMvrP+25AfGf9+XJMsWkcvzo6mWkm3gk0FJpgNk7uwyv2UNvMM1RAjeCi92L3kfI7O hsC0r3Tl4v4SoMrcpistXOW6mf9T1If7HuykL9b96P8buPkmeDdQIY85jqeQDd0YspKk FztQ== X-Gm-Message-State: AC+VfDwVsuasfosaarGzyOkmiPZHZwDfZaIqMqij7LfW7BhYrpq6lIOV paGG739IuxEGRt5YP3PySxpDTwKUK+NQ475T5tQ= X-Google-Smtp-Source: ACHHUZ6+pFPSVk8eLdnfGAvJL57sEpRld3od1iv76xPflK+h+u0BJpwACepLkSUNo9C5c6y1Hgi4AkoWAVSpfuLaeSQ= X-Received: by 2002:a17:907:60d3:b0:956:f4f8:23b6 with SMTP id hv19-20020a17090760d300b00956f4f823b6mr8070180ejc.43.1683212631746; Thu, 04 May 2023 08:03:51 -0700 (PDT) MIME-Version: 1.0 References: <20230504105624.9789-1-idryomov@gmail.com> <20230504135515.GA17048@lst.de> In-Reply-To: <20230504135515.GA17048@lst.de> From: Ilya Dryomov Date: Thu, 4 May 2023 17:03:39 +0200 Message-ID: Subject: Re: [PATCH] mm: always respect QUEUE_FLAG_STABLE_WRITES on the block device To: Christoph Hellwig Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 4, 2023 at 3:55=E2=80=AFPM Christoph Hellwig wrote= : > > 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.. Hi Christoph, Right, I meant to say "when accessing a block device directly". > > > 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 =3D folio_inode(folio); > + struct super_block *sb =3D 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); Heh, this is almost exactly what I came up with initially (|| arms were swapped in that version), but decided to improve upon after noticing the writeable thing. Thanks, Ilya