From patchwork Fri Aug 23 20:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13775931 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 C2D9FC5321E for ; Fri, 23 Aug 2024 20:08:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42CEA6B0249; Fri, 23 Aug 2024 16:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DCF26B024B; Fri, 23 Aug 2024 16:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A42B800C8; Fri, 23 Aug 2024 16:08:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0AC626B0249 for ; Fri, 23 Aug 2024 16:08:46 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C6824A148F for ; Fri, 23 Aug 2024 20:08:45 +0000 (UTC) X-FDA: 82484598210.23.F88C125 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 1187C4000C for ; Fri, 23 Aug 2024 20:08:43 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="HxUThJl/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724443657; a=rsa-sha256; cv=none; b=zjPkPv5py3YLLsJxYbrtVegmfnyMCieWhuJ5Knl/WNt/BAEjcu3SW5y/tlNoqomelutQ4A XpaAVbYPksbwz1UMPjzANWLbRQ8u6hQ0u7XkPTKZZYyWAkjAMzfmg5mAEPcWwhwT5Elepv R6VdNsf/ILikhxGIus86srg9hsowJ8I= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="HxUThJl/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724443657; 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=RGA+JSA2V14ATaPgBBckAPvuIzNuSHMAH2nz3txsJbBSeAkCNcwH5GgjaX1FRHPQhm5z5s iJWqSCDCAMVI+RJKCViTSAkuBpgpnbQnaI8TRBZwp74i2SEe64YjQuFp1n20FXuLmkUN+Z aApJb3ApLTy+Q20MwrB+HRFx6jTa4Xk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724443723; 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=HxUThJl/Fc/eYIKa+/Q9mjLsAcsWxBP/O0vNZwY3Kllu6/BWQsbPx94sf6x04CMsYCLav2 f19w17YLyTdgsMtVB9jwSi8D+HRkQrh0Wbg5oaAfYh/vZLe0tdD77P3K7qJ/J+bI2iexzU 3i8F4umS5Xf3uQstWegsIzrAm1Z4Ymc= Received: from mx-prod-mc-04.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-459-Djwg1nHIPVOepKsh7DLV1g-1; Fri, 23 Aug 2024 16:08:37 -0400 X-MC-Unique: Djwg1nHIPVOepKsh7DLV1g-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A790219560A2; Fri, 23 Aug 2024 20:08:34 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7292D3001FE5; Fri, 23 Aug 2024 20:08:29 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French Cc: David Howells , Pankaj Raghav , Paulo Alcantara , 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/9] mm: Fix missing folio invalidation calls during truncation Date: Fri, 23 Aug 2024 21:08:09 +0100 Message-ID: <20240823200819.532106-2-dhowells@redhat.com> In-Reply-To: <20240823200819.532106-1-dhowells@redhat.com> References: <20240823200819.532106-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1187C4000C X-Stat-Signature: m6p56kpp3rsddtyxhbucoay1pxqkwmkb X-Rspam-User: X-HE-Tag: 1724443723-160753 X-HE-Meta: U2FsdGVkX19SeX8jH9rLppjS4WFJUQYluot8Ww+Ee5uAA+E+VTbZaNpIyr4qFKZFifcefoFK+hbbe/zXgZWhMi9dxd50RNPYM3KWv612xLqSxq3cUPCvHk7HszhNeFw25vV8405h2FawwoiZJxdgtt7C6ksUt3kH7aqm5wO4ynh5JFx0QHi3c42ktzSSu/OChQsEj7f/l01MS9CTHkIInV5yiNC/5e14EVUoG5ymLDPx9yed08jGb55hguaP63vQfv/FX7aBi31McuTTwsf5zzZ5lr+xVO/XfXpSp5cL2QFXf1/CCFJxtp2WJuSaGyVF3OQmntY2fvW3EXgIKYWk1Ssow5E5iIu0gaD9VemOP/fW+81CDd3Zq4gxl1wgH5iZCCIIBsx9Kk1SmIDFfmk0Mi1IfEJ1M1PbRimb6v+MB0++6KQGw/I/2Lqzg+41tQPQe2LMIPaJUv9LesVfsRXv+vNKjOdvZvGGdHcw5/u5TUcqVakUE3FS4ZeHYK0b9I5TYsxGpNtxe77oHWkL7clQWS6ZizaIiB2duZLRZ7SJObY03J0Z0NcIUMwTe9pqm5phyBXvaANECY5H+g/884QXHNksCBiXkliiQng30ZSHtk2K9WizOUN7oCBqnc6yNop+S4JfOznHSWWoCBeE2AyxaGcaOF8/0nOES8KYNp5n6EOc61ACSTRJZUAxw0/1ELB4J1H895A0m40wBMhkUibsC+Tuxx56NyfkVE5Ncfm8FNKaXMybgZvcKPowAHk/7EQnfZOmmkdCPo4cN4dOKTT7KxW0Nw1sitdT1SEyA6DiHKqBQW2Mip8i3VRhWPojk5wq/6r/1An9giDXjN7IOYtoP5ui7UMfkKWCAIMfDQf3NKbweaUedeo5QfQIvlBWsMu4jhNy+ueCqwBZGjeeApvpMCFNZ/LkHE174tagMV6r+fgiB6FoByzmfGVKHf9mDaa0ZNgBFw8KtPBx8lJ0QxX x1Qm2VJn j03oaNWL2vb7DvJccTTUZo90Wv6n+MHN0fswHUouPkYdVjBljF8XIJ+2PSR3YT5qZxZdnjAY9TGEGvqBWjt2LhshUI7wyZQMpbQLim7o9Kub5aRjng2NB5Njn1kid4qh3+7MpFib4koL/i5n9T0ZbCqLYWoDLMtcjcUnmAQB34wAM8vOXcPx0rO5z/aPwnJuO1j1QSvbWBKglU0PgaTEolC+0AnYM2Ph9AnjiRZcWa3reN3xVSLwF/s/kX4FE1Fywupi2B3O5LOPk/b0rnNHlIfPX2C+2NAAdF5N7V5X8tiS5cqvQOR+qNf3XBOLtzH1rlBur2uDn56l1xnK3DND/0yrWmgB3fJ1Wu7kHbPL6ugw4iF3uN2MISK2j0Q9JUhOegGnKw3b6FZdN6ut8jrn7AZ1oPr7fTApGxI5cFmCdwHoYII/mT2w+3vW3ewwPQYvntSuyEhdk26tiVLSW0mMrneQ7p5/6VhX7j8p5xiIGMbbooUxCAiJfzBezcQw10zjshThMNyfn3meV80D+hssPw4xtPd3u7sRz9AcTP0Ga+zRZ6jvb4+TrwlUJjX8+dBb1hpTAsRJIKLbHQWTHic9PvyCWTlzphiom6k052B86P6+j5d0C2epzGtVVMg== 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] Reviewed-by: Matthew Wilcox (Oracle) --- 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;