From mboxrd@z Thu Jan 1 00:00:00 1970 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 6C2DFC5B552 for ; Thu, 5 Jun 2025 17:30:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA2316B00AB; Thu, 5 Jun 2025 13:30:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B52736B00BC; Thu, 5 Jun 2025 13:30:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8F7E6B00BD; Thu, 5 Jun 2025 13:30:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 70DD26B00AB for ; Thu, 5 Jun 2025 13:30:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 11A9F1211A9 for ; Thu, 5 Jun 2025 17:30:35 +0000 (UTC) X-FDA: 83522036430.26.8CE01C4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 3916540019 for ; Thu, 5 Jun 2025 17:30:32 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K0E8xWDP; spf=pass (imf17.hostedemail.com: domain of bfoster@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749144633; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=EoX7XR7J0u5HTsNSFCTHL4yND2pXpga4e+oQ9c14p10=; b=DcolDxcvXJA5oFHrM/ZUrS+98wl6RV64FI8Fi7zy2S8n/Tx/p+3ubgANGaq5m5qjpS6i8Z wCqu4PbFlRzlxeO/0IdjghZkO4i6RZYqi3LalNneJUuAggzgk3Q4c4GAUkAj0XylqUWmFY GeFfPHGgh52sV23R2N1xQKSo5ZkXxpo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K0E8xWDP; spf=pass (imf17.hostedemail.com: domain of bfoster@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749144633; a=rsa-sha256; cv=none; b=IadeQHLku3Jl30XLaRCxyLJa9nuqJ+uDwhotu73/pSa0G6oPSXuqKXhtfzTSuqYZV1qLA9 t1O8DMraAmQObMxRsMmfJKr6nutLWbpKLE0hMRC7G8r9pIuQxxCQyfzVFfF1AK7PXdpXOG pV7NPFa1MYJjqT/FtfQlITNAdobzueQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749144632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EoX7XR7J0u5HTsNSFCTHL4yND2pXpga4e+oQ9c14p10=; b=K0E8xWDPhxZVoeyPISAPwAsVh8l88GMO+hv+4/sqyJWkHu3U5LdfnZi5xyzV1I9ntMqTvA zJAIfQcvLhNbx3bD46yGixNbgBFpeE97c6+w2t77dOuC55f5DG2FskmKXKHvNj5ylEajnL 3TdjoolPJCmMb6RP3WNT2DmAnEv6X60= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-FEWLSOEYN529DZZ8DpnCFg-1; Thu, 05 Jun 2025 13:30:29 -0400 X-MC-Unique: FEWLSOEYN529DZZ8DpnCFg-1 X-Mimecast-MFC-AGG-ID: FEWLSOEYN529DZZ8DpnCFg_1749144628 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B40C1800378; Thu, 5 Jun 2025 17:30:28 +0000 (UTC) Received: from bfoster.redhat.com (unknown [10.22.88.123]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3036130002C0; Thu, 5 Jun 2025 17:30:27 +0000 (UTC) From: Brian Foster To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 0/7] iomap: zero range folio batch support Date: Thu, 5 Jun 2025 13:33:50 -0400 Message-ID: <20250605173357.579720-1-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3916540019 X-Stat-Signature: 6sswoi1a6s91seeuu8ig98i6cn7aysyo X-Rspam-User: X-HE-Tag: 1749144632-934623 X-HE-Meta: U2FsdGVkX197e3ptNCVUXrCh6HdymmqEiZq3kOlXqYIwDiuxFlqtaJzNiODWfCt5G6Ew3IDUOvKuvO6CQYW4iPS+OT328N0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67nTG8FBbPuf8S5tqtCFmBqIwzdF41mOtry29cBZBu2nLLKBPxO8iq4+8gwAoYZ84clUW11ds0NnbKpIZ0500Pd/A9LMyLld19DYKFZ/U7bJdeOtQwYr/90d/GnSChfFQAwmsr8TAaMQb5J4cAtrGLrY88WxF8fTJqaMQ8V+kjnawx3ykiZrLmYXm+L6w9 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: Hi all, Here's a first real v1 of folio batch support for iomap. This initially only targets zero range, the use case being zeroing of dirty folios over unwritten mappings. There is potential to support other operations in the future: iomap seek data/hole has similar raciness issues as zero range, the prospect of using this for buffered write has been raised for granular locking purposes, etc. The one major caveat with this zero range implementation is that it doesn't look at iomap_folio_state to determine whether to zero a sub-folio portion of the folio. Instead it just relies on whether the folio was dirty or not. This means that spurious zeroing of unwritten ranges is possible if a folio is dirty but the target range includes a subrange that is not. The reasoning is that this is essentially a complexity tradeoff. The current use cases for iomap_zero_range() are limited mostly to partial block zeroing scenarios. It's relatively harmless to zero an unwritten block (i.e. not a correctness issue), and this is something that filesystems have done in the past without much notice or issue. The advantage is less code and this makes it a little easier to use a filemap lookup function for the batch rather than open coding more logic in iomap. That said, this can probably be enhanced to look at ifs in the future if the use case expands and/or other operations justify it. WRT testing, I've tested with and without a local hack to redirect fallocate zero range calls to iomap_zero_range() in XFS. This helps test beyond the partial block/folio use case, i.e. to cover boundary conditions like full folio batch handling, etc. I recently added patch 7 in spirit of that, which turns this logic into an XFS errortag. Further comments on that are inline with patch 7. Thoughts, reviews, flames appreciated. Brian v1: - Dropped most prep patches from previous version (merged separately). - Reworked dirty folio lookup to use find_get_entry() loop (new patch for filemap helper). - Misc. bug fixes, code cleanups, comments, etc. - Added (RFC) prospective patch for wider zero range test coverage. RFCv2: https://lore.kernel.org/linux-fsdevel/20241213150528.1003662-1-bfoster@redhat.com/ - Port onto incremental advance, drop patch 1 from RFCv1. - Moved batch into iomap_iter, dynamically allocate and drop flag. - Tweak XFS patch to always trim zero range on EOF boundary. RFCv1: https://lore.kernel.org/linux-fsdevel/20241119154656.774395-1-bfoster@redhat.com/ Brian Foster (7): iomap: move pos+len BUG_ON() to after folio lookup filemap: add helper to look up dirty folios in a range iomap: optional zero range dirty folio processing xfs: always trim mapping to requested range for zero range xfs: fill dirty folios on zero range of unwritten mappings iomap: remove old partial eof zeroing optimization xfs: error tag to force zeroing on debug kernels fs/iomap/buffered-io.c | 103 ++++++++++++++++++++++++----------- fs/iomap/iter.c | 6 ++ fs/xfs/libxfs/xfs_errortag.h | 4 +- fs/xfs/xfs_error.c | 3 + fs/xfs/xfs_file.c | 21 +++++-- fs/xfs/xfs_iomap.c | 38 ++++++++++--- include/linux/iomap.h | 4 ++ include/linux/pagemap.h | 2 + mm/filemap.c | 42 ++++++++++++++ 9 files changed, 176 insertions(+), 47 deletions(-) -- 2.49.0