Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp787805rwb; Thu, 1 Dec 2022 08:21:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BwTZ9eV3gh6JqI5oSeTGIIm+VyS/7nubByH/SrBOwN+M924Eud6WPXk9SRunu4qCqZHv6 X-Received: by 2002:aa7:db91:0:b0:458:bd09:1b20 with SMTP id u17-20020aa7db91000000b00458bd091b20mr61475646edt.176.1669911704818; Thu, 01 Dec 2022 08:21:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669911704; cv=none; d=google.com; s=arc-20160816; b=GUWNWiGqh4sBfJKDq9Gb43XZ8WjIN3aimDsDP7shR5dsLpu1adqmTh1xuk4T9f8Lch ayaoPHlf4vHBs4tEIiqhAZDNxE0Y9T4OI0yWw9Axs2fGEp6uwf7j9EQAu6FwctWAAwPG ddvjVmv+by0KkvSjFRvZo6KouCVe0EGSqr3jthLC33hhOK98/W+qaOL8HRWdaTJw0R1w 2o58/XX0H/pqi+A+FUWy/WneWwnZPan4Pwfb3ao04odTdN0lEeiXLAp6YvaDiKa3Qh1r y0YqVuHAHBgk9ruxV9Ru09bmKF8+GwsVj5h4p0Z0jjSq/NExxjqiGHpD2wa+BCA0kUdI J66g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PamKx232vfxvsaWPi1/5x3ys13CWorTpvsS3jNFLNq0=; b=WndwrfsIIrZBogDmsuQhNtPA53sD1WD90Mb2RFwpepKQrsslX/auZvHvam/bjLmeTc T2BH4+yb1X4CbeC7RswaDnCh1Ulb7SoGbUATX4mmSLV3yRIT6R26bqlbIeWqALKMNhYM h8wBA6sUnwI0PGLVnE6BnVEXdaebiJTCpPlLHOXr+Uo4BECkO0aDgHYNyTvXlr4AWWng vOsjihdVndt3583h3a4ifYiC5O/REZh7o7EIKQzk6mGEMZF7RRcaPiTsgB9yFS7VpGqL g4C9cBIRkNBobseASrgC5rjCYWNZ3rj3VVgTMUg0PZozsjyQXG25eAuEy2ClPr2iee39 yp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GvvFhYia; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg12-20020a170907970c00b007413b206b16si4141307ejc.843.2022.12.01.08.21.21; Thu, 01 Dec 2022 08:21:44 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GvvFhYia; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbiLAQHm (ORCPT + 99 others); Thu, 1 Dec 2022 11:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230132AbiLAQHa (ORCPT ); Thu, 1 Dec 2022 11:07:30 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63568B5DBA for ; Thu, 1 Dec 2022 08:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669910791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PamKx232vfxvsaWPi1/5x3ys13CWorTpvsS3jNFLNq0=; b=GvvFhYiar2tbpdIO9iL0OHcZNAYY+zJO/P3C/3pW4d9vWNPGjMSHC4LMBAsVERwKAfT8AE d4XofQTH6uMZO0qt30Sm13zqChpkdpNgSIufDnfC1OgtXvFDolFQ2ZY85aBBA1tZmpsjk2 IxUs1Iyv2Xv5kNosqFFjm6YbeYqk0sM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-377-4kkp5bLeOxOLIRlBDC_4bg-1; Thu, 01 Dec 2022 11:06:23 -0500 X-MC-Unique: 4kkp5bLeOxOLIRlBDC_4bg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A233858F13; Thu, 1 Dec 2022 16:06:22 +0000 (UTC) Received: from pasta.redhat.com (ovpn-192-141.brq.redhat.com [10.40.192.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DE53111E3FA; Thu, 1 Dec 2022 16:06:19 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , "Darrick J . Wong" , Alexander Viro , Matthew Wilcox Cc: Andreas Gruenbacher , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com Subject: [RFC 0/3] Turn iomap_page_ops into iomap_folio_ops Date: Thu, 1 Dec 2022 17:06:16 +0100 Message-Id: <20221201160619.1247788-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Hello, we're seeing a race between journaled data writes and the shrinker on gfs2. What's happening is that gfs2_iomap_page_done() is called after the page has been unlocked, so try_to_free_buffers() can come in and free the buffers while gfs2_iomap_page_done() is trying to add them to the transaction. Not good. This is a proposal to change iomap_page_ops so that page_prepare() prepares the write and grabs the locked page, and page_done() unlocks and puts that page again. While at it, this also converts the hooks from pages to folios. To move the pagecache_isize_extended() call in iomap_write_end() out of the way, a new folio_may_straddle_isize() helper is introduced that takes a locked folio. That is then used when the inode size is updated, before the folio is unlocked. I've also converted the other applicable folio_may_straddle_isize() users, namely generic_write_end(), ext4_write_end(), and ext4_journalled_write_end(). Any thoughts? Thanks, Andreas Andreas Gruenbacher (3): fs: Add folio_may_straddle_isize helper iomap: Turn iomap_page_ops into iomap_folio_ops gfs2: Fix race between shrinker and gfs2_iomap_folio_done fs/buffer.c | 5 ++--- fs/ext4/inode.c | 13 +++++------ fs/gfs2/bmap.c | 39 +++++++++++++++++++++++--------- fs/iomap/buffered-io.c | 51 +++++++++++++++++++++--------------------- include/linux/iomap.h | 24 ++++++++++---------- include/linux/mm.h | 2 ++ mm/truncate.c | 34 ++++++++++++++++++++++++++++ 7 files changed, 110 insertions(+), 58 deletions(-) -- 2.38.1