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 CA020C83F1A for ; Mon, 14 Jul 2025 20:37:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 449DC6B009E; Mon, 14 Jul 2025 16:37:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FAE66B009F; Mon, 14 Jul 2025 16:37:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E91F6B00AB; Mon, 14 Jul 2025 16:37:50 -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 1ACC06B009E for ; Mon, 14 Jul 2025 16:37:50 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C71E71D95B3 for ; Mon, 14 Jul 2025 20:37:49 +0000 (UTC) X-FDA: 83664031458.23.F87B571 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 14502120003 for ; Mon, 14 Jul 2025 20:37:47 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GzpGoV8g; spf=pass (imf29.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.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=1752525468; 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=trJ6g1WWyOPJeGz5HdfWeO4sEcYlcpzvrMPenqjlHKs=; b=sZ4pQZTD1kNy/i2uE8dtPyXwOwm75uy0MtgFuWW6nQ3zMbcazLuLW2jcw3nQjlO1/yXCo0 Ud/S1HcXO0CKxy1i3g0TbzuppG5+cx9jLeVMsaknj3RS1qPJaVt5Gyq5aG+YM+WScJg77c JVRDHfKD9OIAZWlsqBCCbVTSOiF01u8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GzpGoV8g; spf=pass (imf29.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.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=1752525468; a=rsa-sha256; cv=none; b=LjKYVCZYiVQ4oGOm+wFl1xI8ZmgiRtHZ8R3gahu3+kWELC6+pYlUxWgjgX1eZKwUzzCVDT fZZRVTzy40OQSDTmJYypmQBMZxobJsTw1JBxGX34VM/Zob53QJTO6PCRm+yCvXTgDehuVS biethuAUoUNO9wmLDwX+6nz8ysWcVIY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752525467; 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=trJ6g1WWyOPJeGz5HdfWeO4sEcYlcpzvrMPenqjlHKs=; b=GzpGoV8gYxkaw4Pubjwwks2PnDZzh2V0YQZZJAE/i68znqVKi0yRgTM7APTWRFyrC2cwE2 NRsbs1FN8P9jpXB4UBQLEJAx8d6sl5RRNstvduY5hPRNp+TT6/0nneqbKUkoZUxFmC6fU1 Ux2wmOArWTMSKI78vo8qysWxX5xrbI8= Received: from mx-prod-mc-01.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-554-RT4CSNFSMESwR0FQXDYLZQ-1; Mon, 14 Jul 2025 16:37:43 -0400 X-MC-Unique: RT4CSNFSMESwR0FQXDYLZQ-1 X-Mimecast-MFC-AGG-ID: RT4CSNFSMESwR0FQXDYLZQ_1752525462 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CBC941956094; Mon, 14 Jul 2025 20:37:41 +0000 (UTC) Received: from bfoster.redhat.com (unknown [10.22.64.43]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 15BF919560B2; Mon, 14 Jul 2025 20:37:38 +0000 (UTC) From: Brian Foster To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, djwong@kernel.org, willy@infradead.org Subject: [PATCH v3 0/7] iomap: zero range folio batch support Date: Mon, 14 Jul 2025 16:41:15 -0400 Message-ID: <20250714204122.349582-1-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Stat-Signature: 8bdu57uhc3eto6senadt9inba43nwwnz X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 14502120003 X-Rspam-User: X-HE-Tag: 1752525467-63511 X-HE-Meta: U2FsdGVkX198qY3+NOZlqRUyG64PgShmBe0toKvz9OpiGHrhssMyhgI9csO7HEgy44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ISx1Fpe/ubYsVqtHSHuRCzKAGxo63WskX0Cc3DSUiUn+CeaKX6ddS/gzgAOwGBsNGtrTEunMmW0Z+xMJbgB9J2swNpeb/adES1aPbBUZU8QCCdGVm1xF8vog7tnCb4SVyZuYdmJC677hpafxDVhxYUJCQisYBpntsjITmjQ5K7Xz7s9nuMkz+LaDhSwDCE 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, Quick update.. This series was held up by testing work on my end. I don't have the custom test to go along with patch 7 yet, but hch was asking for updates, I have vacation looming, and realistically I wasn't going to get to that beforehand. So I'm posting v2 without the additional test and reviewers can decide if/how to proceed in the meantime. Either way, I'll pick up where this leaves off. Zero range is still obviously functionally testable. We just don't yet have the enhanced coverage I was hoping for via the errortag knobs. There are also a couple small fstests failures related to to tests that explicitly expect unwritten extents in cases where this now decides to perform zeroing (generic/009, xfs/242). I don't consider these functional regressions, but the tests need to be fixed up to accommodate behavior. Again, I'll get back to this stuff either way, it's just going to be a couple weeks or so at least at this point. Thanks. Brian --- Original cover letter --- 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 v3: - Update commit log description in patch 2. - Improve comments in patch 7. v2: https://lore.kernel.org/linux-fsdevel/20250714132059.288129-1-bfoster@redhat.com/ - Move filemap patch to top. Add some comments and drop export. - Drop unnecessary BUG_ON()s from iomap_write_begin() instead of moving. - Added folio mapping check to batch codepath, improved comments. v1: https://lore.kernel.org/linux-fsdevel/20250605173357.579720-1-bfoster@redhat.com/ - 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): filemap: add helper to look up dirty folios in a range iomap: remove pos+len BUG_ON() to after folio lookup 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 | 116 +++++++++++++++++++++++++---------- fs/iomap/iter.c | 6 ++ fs/xfs/libxfs/xfs_errortag.h | 4 +- fs/xfs/xfs_error.c | 3 + fs/xfs/xfs_file.c | 26 ++++++-- fs/xfs/xfs_iomap.c | 38 +++++++++--- include/linux/iomap.h | 4 ++ include/linux/pagemap.h | 2 + mm/filemap.c | 58 ++++++++++++++++++ 9 files changed, 210 insertions(+), 47 deletions(-) -- 2.50.0