Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp670867rwr; Thu, 4 May 2023 08:10:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XXLj2JhHm4Zh9ivWkL/ThdFh/CM7NjJK5tTuF4qn3C1irAyvJE0weoHJvY8597sQezjJ2 X-Received: by 2002:a5d:8d8a:0:b0:71c:9858:1792 with SMTP id b10-20020a5d8d8a000000b0071c98581792mr15756009ioj.13.1683213019997; Thu, 04 May 2023 08:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683213019; cv=none; d=google.com; s=arc-20160816; b=bcy0LKWpcG8yP5+1xhF+WG/dgw4Q5/Jiq4gimt6+Ersqy0NnoEtNg476lXvmN9Mos+ flbEaVrRlwMyig7dbvvOGKgDsY0j0hM8zIl46kp+CWdarS9+173mWKewjWtWC6DSRP2L n00xIbo9O5+OUUTzZ2cGrTbLCju5RmSxvfCPJGskUpUj+pMeUvi9sWBG1Ov75tkTNeBb L0H3Yy1+SEIX/8IFcyR+UqceMm5f/IkOYUpLXYGFBGkQpD+Yy+ITM7Dm5UbpbA0hiWaF Taz/CJ6MFQl/nBs8odHDPECqNmVPsgdHMuWHnrtVAHkVL0ybMNHfJBiV9VmKn+z6rRCc WYJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9WFS1x47blclBXskP77nCF58D51Rpg9+wJAmzlYQmRk=; b=jVPD0IEV575b6TUF4a56cRFjc2mEMGeogUH5r6iA//yWCgHbxxTYP5JgNpofi9cUE4 HaUVHgGkkCbTjUQd8zD+dBYvMF+nnNJy+nwXtxSOB35ix2GZPSmGYn/HwaSgQnSge5eJ JBmsm2hBv8R1YKVXQThknf4J+FwkXuX3uGjyQmIds1dVKUIi6CkQnjYawptE9Z8PBFSE LLF7MTBhQKCbIOqHyATcy98/niKzGjZUJAVuee55L06CTQazZdT3HTGQh6MD6zoPd2k8 KYPvQjbOp0c5WLeRa15HxEoUeCa2rrldaRWhmegIFQGQW+L9j3ApXaWbASZ3p9UOUlOU LUaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=iOENyJgH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 16-20020a5d9c50000000b00763627c82fdsi22999380iof.65.2023.05.04.08.09.57; Thu, 04 May 2023 08:10:19 -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=@gmail.com header.s=20221208 header.b=iOENyJgH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbjEDPH0 (ORCPT + 99 others); Thu, 4 May 2023 11:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbjEDPHZ (ORCPT ); Thu, 4 May 2023 11:07:25 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1394110D8; Thu, 4 May 2023 08:07:24 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so18305342a12.0; Thu, 04 May 2023 08:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683212842; x=1685804842; 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=9WFS1x47blclBXskP77nCF58D51Rpg9+wJAmzlYQmRk=; b=iOENyJgHIcqMP2+ca+2v80DT2ibR3iO9OVec9sAfKp7iLNAEq9mujvSiuMFX0BeHxf FXeeGNJEllsKwvy5a7JoPvL5PkZDu7W3NmC/C+73rZwfW4xKcrl2OUlXbzgVBx9jb5s5 3zmGR16y/wilEY8jd7r7+vccxMYIjQq9Gr8pKGIXxn+nE11U6nj5XCsdwj97PPQkmqYt F8RnwS5MsdoCAwdzSCN2vL5FoakB8av51upu1FZinjJDEwDrPYO0+Wzm/oJWGSjScrVQ QptWn+fjuB0LzpTlL4bdxjJ9Vm9todUZ0BCPONAUOiMTsuJBDn82A34/N137dRuh+b6F Mawg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683212842; x=1685804842; 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=9WFS1x47blclBXskP77nCF58D51Rpg9+wJAmzlYQmRk=; b=fZ65Y5OEbsFJMwzGVqWwsyFY5M/I5F/dQ4DT2AktfFu3BVmH6M2+Kt2jp0cUNMbXY7 /2xl/maGhb49/Yyjm2le/6V3eFLxr7L+HPdlSvdx8Z014j6AtkoX4vJN6ZWbQ3VJOb/5 62ZC6BqxwGcKdX6DoYNQbbTUDTG8Z3AW7bcfmeB2I4unBbGYFnXzeg43uuqjlK1N2hiq 8aCmBzt9gUVv65R4RU11hObHnm+D6Vuou6PQSE1uNTxCpDEPifgMtdrA3UP9TZZOcJ/v fHTDZ7U16h6BHegsn3H43G+UI0BUNWT6GRlPj94edLiQw31yfCsHbI85SkW+vk+ADlJP 2kDw== X-Gm-Message-State: AC+VfDxxiqgA0PxKKrRqpuMUaLLCVRadcrhrHmy6WY3PrCT9CdYI6K+i oaf3OQ2OPS9pH9ovj8oUaTtQcUZ5dIK76Kg8q5U= X-Received: by 2002:a17:906:9746:b0:960:ddba:e5bf with SMTP id o6-20020a170906974600b00960ddbae5bfmr5322943ejy.0.1683212842404; Thu, 04 May 2023 08:07:22 -0700 (PDT) MIME-Version: 1.0 References: <20230504105624.9789-1-idryomov@gmail.com> <20230504135515.GA17048@lst.de> In-Reply-To: From: Ilya Dryomov Date: Thu, 4 May 2023 17:07:10 +0200 Message-ID: Subject: Re: [PATCH] mm: always respect QUEUE_FLAG_STABLE_WRITES on the block device To: Matthew Wilcox 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 4, 2023 at 4:16=E2=80=AFPM Matthew Wilcox = wrote: > > On Thu, May 04, 2023 at 03:55:15PM +0200, 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() ha= s > > > the effect of respecting it only when there is a filesystem mounted o= n > > > top of the block device. If a filesystem is not mounted, block devic= es > > > 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 fl= ag > > > is captured when the filesystem is mounted and isn't consulted after > > > that anywhere outside of swap code, changing it doesn't take immediat= e > > > 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); > > } > > EXPORT_SYMBOL_GPL(folio_wait_stable); > > I hate both of these patches ;-) What we should do is add > AS_STABLE_WRITES, have the appropriate places call > mapping_set_stable_writes() and then folio_wait_stable() becomes > > if (mapping_test_stable_writes(folio->mapping)) > folio_wait_writeback(folio); > > and we remove all the dereferences (mapping->host->i_sb->s_iflags, plus > whatever else is going on there) Hi Matthew, We would still need something resembling Christoph's suggestion for 5.10 and 5.15 (at least). Since this fixes a regression, would you support merging the "ugly" version to facilitate backports or would you rather see the AS/mapping-based refactor first? Thanks, Ilya