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 612F1C83F1A for ; Mon, 14 Jul 2025 20:37:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F20156B00B0; Mon, 14 Jul 2025 16:37:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA99A6B00B1; Mon, 14 Jul 2025 16:37:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D23B36B00B2; Mon, 14 Jul 2025 16:37:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AFD786B00B0 for ; Mon, 14 Jul 2025 16:37:56 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 35C501602EE for ; Mon, 14 Jul 2025 20:37:56 +0000 (UTC) X-FDA: 83664031752.11.C8C1208 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 9EDDD40008 for ; Mon, 14 Jul 2025 20:37:54 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPGC2U1R; spf=pass (imf11.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=1752525474; 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:in-reply-to:references:references:dkim-signature; bh=EoLl78NjtbcPKGKYfvQLO/bLwzmKprkMHLPe27UjLrc=; b=Z24eR12fV5xUGYgX7AebBS9FeUyntND6B9HpGTSyT2FfXdFsbrO8xWMR3N3izMV+yBwMht Vzp+TkPypRyZbGS0kqYj2bv+o+6R494K3KgPn9JmNhf1HAhQBm5HVi/feTdbzvuo/0PUMj /uD9GnlWAh4x8wmrdrac3ZApH9iIN3A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752525474; a=rsa-sha256; cv=none; b=uG5znz3Ote90MgJs8KGUbwdXV/pQ4lpzM1MlCtqXaiXq3DItcRIvGpqhWk8kmUtBWnBBMW gjbp1xkEWBrNClffYpsIZGeMlLhU+cYbxmmhn3ITIWPfNsAMHF39O3BOr5QbteqW26Y1+1 c3Jz+VpVAogBMv1LdUPJEy1z/QNjxoc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPGC2U1R; spf=pass (imf11.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752525474; 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: in-reply-to:in-reply-to:references:references; bh=EoLl78NjtbcPKGKYfvQLO/bLwzmKprkMHLPe27UjLrc=; b=PPGC2U1RH8++5ywDi2TDzNzPb1QpEmrBl30+B3Kp+X3U7Ukycf05064WIdr/GkinN6pMp+ AeM+KulTIKoabnCSZE6anPtG0I0Qm+IWHEP66IrPN3Ua/UqBBVHYEONwoEiHxuZfD9uH93 kafDjpREpBUME0UVFb2sNJz9Tafqn9s= 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-639-6vO7CUcOPBCGtBxnOl-2Ow-1; Mon, 14 Jul 2025 16:37:51 -0400 X-MC-Unique: 6vO7CUcOPBCGtBxnOl-2Ow-1 X-Mimecast-MFC-AGG-ID: 6vO7CUcOPBCGtBxnOl-2Ow_1752525470 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E05D18011FB; Mon, 14 Jul 2025 20:37:50 +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 1979B19560A3; Mon, 14 Jul 2025 20:37:48 +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 5/7] xfs: fill dirty folios on zero range of unwritten mappings Date: Mon, 14 Jul 2025 16:41:20 -0400 Message-ID: <20250714204122.349582-6-bfoster@redhat.com> In-Reply-To: <20250714204122.349582-1-bfoster@redhat.com> References: <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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9EDDD40008 X-Stat-Signature: 96kd7oruzsgm6qi9spjubq7dgq51n6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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: Use the iomap folio batch mechanism to select folios to zero on zero range of unwritten mappings. Trim the resulting mapping if the batch is filled (unlikely for current use cases) to distinguish between a range to skip and one that requires another iteration due to a full batch. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index b5cf5bc6308d..63054f7ead0e 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1691,6 +1691,8 @@ xfs_buffered_write_iomap_begin( struct iomap *iomap, struct iomap *srcmap) { + struct iomap_iter *iter = container_of(iomap, struct iomap_iter, + iomap); struct xfs_inode *ip = XFS_I(inode); struct xfs_mount *mp = ip->i_mount; xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); @@ -1762,6 +1764,7 @@ xfs_buffered_write_iomap_begin( */ if (flags & IOMAP_ZERO) { xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); + u64 end; if (isnullstartblock(imap.br_startblock) && offset_fsb >= eof_fsb) @@ -1769,6 +1772,26 @@ xfs_buffered_write_iomap_begin( if (offset_fsb < eof_fsb && end_fsb > eof_fsb) end_fsb = eof_fsb; + /* + * Look up dirty folios for unwritten mappings within EOF. + * Providing this bypasses the flush iomap uses to trigger + * extent conversion when unwritten mappings have dirty + * pagecache in need of zeroing. + * + * Trim the mapping to the end pos of the lookup, which in turn + * was trimmed to the end of the batch if it became full before + * the end of the mapping. + */ + if (imap.br_state == XFS_EXT_UNWRITTEN && + offset_fsb < eof_fsb) { + loff_t len = min(count, + XFS_FSB_TO_B(mp, imap.br_blockcount)); + + end = iomap_fill_dirty_folios(iter, offset, len); + end_fsb = min_t(xfs_fileoff_t, end_fsb, + XFS_B_TO_FSB(mp, end)); + } + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); } -- 2.50.0