Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp942994rwb; Thu, 1 Dec 2022 10:12:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Obdb1+8vudHEQ2qN4VIjZeiDMHoJe10fwLEoRosOKmPdzKiE2uyDs2hmlof9fNAXU6xCV X-Received: by 2002:a17:906:1b46:b0:7be:e794:a406 with SMTP id p6-20020a1709061b4600b007bee794a406mr19926092ejg.503.1669918376944; Thu, 01 Dec 2022 10:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669918376; cv=none; d=google.com; s=arc-20160816; b=dbsmdUEq1ii520txVaGFJsTZBRfh9xQfs5TjWr12nN//QXLMIB0W8UlnjdARchd6Sq KdWfx6Nyg9nlSHeVihQsxLskw6sjjBcrPkZOcWg5FHfnZXUbNpkeDpdNSecPEGtU9K4Y l8jjKfflS4tLtbKuHt0JyHMfa03tKtOg2U5l/MyQDvkSTK/M6yKDGRkpYs8tpcQBe04e V7B1Gi42yM7ct0xlr5Qst74B/WDS6Jd9WgdKoduF3z1m4epBpehHfULVEFJHUwPqeILQ GYLoRG9cj2wjXalPnNiWqR1EC7WhcZ5ddkAa/I3mTLmK9mGIhhTv+xqzQnoQahYiaf3N meeA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+zmVq6FIgm1N+PBpIIwnONX7Od2TKKR0G3ALNNt9PAE=; b=ad8aCYhdKQIt/A5c2anAK5q2tyD4sXT7qNrjr5KU7vLsHjV+IMT5ZfkWP1/Kp7df/i BFn0Iv1dYLi+V59naiSHsxzPtxpTTqFsXNs9BcoeK8dPqyt3L3b0uviR/u1zFSjEzMJK 3yKaFSiQmSkEtFvyYzoPSfReMJw1P+Q4KKO8TzkWcKTt5o0cJH3p8L3Fw/waxLQbYa0S 1UL0UkKjmQs4+wZSzsq6kBbInDrM2z70gUstzNSz5K5SueqjDej3f69w5/ajkdaFtoWR lX5cInYw07wWU5JcfLUA2bTwksLMZFsFbTFg88mles+DpXUTdWACH/oIY53ixJvobRsh ExsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OOA2D5xU; 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 z6-20020a05640235c600b0046aeca41c55si4770430edc.212.2022.12.01.10.12.27; Thu, 01 Dec 2022 10:12:56 -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=OOA2D5xU; 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 S229965AbiLASLI (ORCPT + 99 others); Thu, 1 Dec 2022 13:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbiLASLH (ORCPT ); Thu, 1 Dec 2022 13:11:07 -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 E7CECB7DD2 for ; Thu, 1 Dec 2022 10:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669918209; 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: in-reply-to:in-reply-to:references:references; bh=+zmVq6FIgm1N+PBpIIwnONX7Od2TKKR0G3ALNNt9PAE=; b=OOA2D5xUT/PL9ngZVRK/HvWtaE+2fyCCHZxDcVvulmSJa04aaVeJ2JRJd9JDgfEIr0fHtf GZ9N2P2zj5b3HA6dmrjaC1KS2Yhk1pakvQuZs1Syi5qJ1jryaD4R5S2iVJEphV7O5mPqLy Zj4xG6584Xk5C0Jq0nsthNMjrhUKX2g= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-9b7bgpcqPtqM8sAqTbLd_w-1; Thu, 01 Dec 2022 13:10:03 -0500 X-MC-Unique: 9b7bgpcqPtqM8sAqTbLd_w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE2A529AA2FD; Thu, 1 Dec 2022 18:10:00 +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 6D21EC15BB4; Thu, 1 Dec 2022 18:09:58 +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 v2 0/3] Turn iomap_page_ops into iomap_folio_ops Date: Thu, 1 Dec 2022 19:09:54 +0100 Message-Id: <20221201180957.1268079-1-agruenba@redhat.com> In-Reply-To: <20221201160619.1247788-1-agruenba@redhat.com> References: <20221201160619.1247788-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=unavailable 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 Hi again, [Same thing, but with the patches split correctly this time.] 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