From patchwork Tue Aug 20 23:20:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13770635 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 90887C5320E for ; Tue, 20 Aug 2024 23:21:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AC766B0089; Tue, 20 Aug 2024 19:21:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10C4D6B008A; Tue, 20 Aug 2024 19:21:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEFA06B008C; Tue, 20 Aug 2024 19:21:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CCA6E6B0089 for ; Tue, 20 Aug 2024 19:21:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8BB90C063D for ; Tue, 20 Aug 2024 23:21:28 +0000 (UTC) X-FDA: 82474197456.21.E6F236A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id D75891C0019 for ; Tue, 20 Aug 2024 23:21:26 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="RfIOKBY/"; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724196024; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=i1WfTcBSz40dFfs4YPek5T5SHQcjJbpn4yprFOLb05E=; b=fFDOizg5M2d/iyx6+nWghrbmICncRkpgNYnxMbxL/t4r5Ca0X9bcR1MnEmIjJC/LbUeJc8 laQxYckc3m3j2kSl063te6SNujWJ92kSuti7uk/k8Zek07XsegcI9tzlRmhWlavq6TxkQT ZcX9ECRsvGccd6zF7aexG6QP7OqlTSo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="RfIOKBY/"; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724196024; a=rsa-sha256; cv=none; b=XU6x5r0/2HGF5DusK4usL55CU/qIrElzBN27Cpkg46G+G6VLLFwezlaTvpy1wb/wEdbmxM IzXXh+s7s5lQ9o2kWI5XS8AQBTHlzrWczAsXyVx7beiafvd7s4I0qqD/sS9wjiJKVlhqse i5Vs1hxF0L9YvK3snuyEX4czrHVslaM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724196086; 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=i1WfTcBSz40dFfs4YPek5T5SHQcjJbpn4yprFOLb05E=; b=RfIOKBY/8ZzBMJnIXQ3D8Y5GdiHSvmGOv7+clK9buSUMyufLHdNkGVc/bx3UijrYweIoIp c393GPuztF6AW3TU3L2NKwFeZyTLQBQlpp3scaHCEbvvoovHJLUK1yv2l2YiOKKriEVUYs /CBzFyZhPgumYXbQEf6ybxRXFCQb2MM= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-qlsSCgy2P9econK9DfSahQ-1; Tue, 20 Aug 2024 19:21:23 -0400 X-MC-Unique: qlsSCgy2P9econK9DfSahQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EBEED1955D48; Tue, 20 Aug 2024 23:21:19 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A1AE1955E8C; Tue, 20 Aug 2024 23:21:14 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Pankaj Raghav , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Marc Dionne Subject: [PATCH 1/4] mm: Fix missing folio invalidation calls during truncation Date: Wed, 21 Aug 2024 00:20:55 +0100 Message-ID: <20240820232105.3792638-2-dhowells@redhat.com> In-Reply-To: <20240820232105.3792638-1-dhowells@redhat.com> References: <20240820232105.3792638-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MI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gNu2b2K6JQgGyaLmuosTWxxIwKDewt0GaNwCr9Bg2 o/v+2efJ S/VNlTzAvSrHzy368HWfsjlsFFO4+J0BhaPVojiGYZoRxXrkGFzYqZIGWlSTBLlTIiAR3Qse1geAdfzXbtW27tIjbVNQyCSrO9rMATHzdTFnXemG1Teb7EAXgLyLT39YX+IKMSRaXxMqZ4Ui3Mt5ocPhISPjMK49tNyjjEiuQjJE11qG5a0baSI4Xy/fOZwWsC9sn2PTFyMFdopstb+MhBUebYG7VqdD98i/rLfm83NM8hMCNuOWR+ahee5PbPPtbkKegfwLLE7FTdZUkWtDtx0dKrBfvRvH72nYhiQxXn6LQ89Co2fVnBBcAvmVYO+lpnyElxYvvoUpXl2AismPJJKPKtn5saYAOr9WGeKhN/x7KbpwXt0NErg+qSw4Z5D7h+TI/+LQi8tX6puNXL8DTuIco3Tp6CARm1/4s7qyDIZThLYZU7wqtaJC4YzykCmlAuz2e5+7NE/KdOOxBmCgyRuJZvmbstTqlQCEbMqcXWuBp91V/1bWhjJb8WerEU+u9/YhVYFxBDdzKvnIQnyq2J3IRXTiKlCwhQu6J7izDFpIWN3JlVFS+1NkWwzDK0Czq6Hl+L52f5xfg1agibva+eMbRJosUVZSP8PkBOxr1pTti3vg2T8Ci4jX9fg== 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: List-Subscribe: List-Unsubscribe: When AS_RELEASE_ALWAYS is set on a mapping, the ->release_folio() and ->invalidate_folio() calls should be invoked even if PG_private and PG_private_2 aren't set. This is used by netfslib to keep track of the point above which reads can be skipped in favour of just zeroing pagecache locally. There are a couple of places in truncation in which invalidation is only called when folio_has_private() is true. Fix these to check folio_needs_release() instead. Without this, the generic/075 and generic/112 xfstests (both fsx-based tests) fail with minimum folio size patches applied[1]. Fixes: b4fa966f03b7 ("mm, netfs, fscache: stop read optimisation when folio removed from pagecache") Signed-off-by: David Howells cc: Matthew Wilcox (Oracle) cc: Pankaj Raghav cc: Jeff Layton cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: netfs@lists.linux.dev cc: linux-mm@kvack.org cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20240815090849.972355-1-kernel@pankajraghav.com/ [1] --- mm/truncate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index 4d61fbdd4b2f..0668cd340a46 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -157,7 +157,7 @@ static void truncate_cleanup_folio(struct folio *folio) if (folio_mapped(folio)) unmap_mapping_folio(folio); - if (folio_has_private(folio)) + if (folio_needs_release(folio)) folio_invalidate(folio, 0, folio_size(folio)); /* @@ -219,7 +219,7 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end) if (!mapping_inaccessible(folio->mapping)) folio_zero_range(folio, offset, length); - if (folio_has_private(folio)) + if (folio_needs_release(folio)) folio_invalidate(folio, offset, length); if (!folio_test_large(folio)) return true;