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 324E9C83F1D for ; Tue, 15 Jul 2025 05:28:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFD746B007B; Tue, 15 Jul 2025 01:28:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAEC06B0089; Tue, 15 Jul 2025 01:28:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEB526B008A; Tue, 15 Jul 2025 01:28:15 -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 9A00A6B007B for ; Tue, 15 Jul 2025 01:28:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0B97680213 for ; Tue, 15 Jul 2025 05:28:15 +0000 (UTC) X-FDA: 83665368150.17.01ED5AA Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf13.hostedemail.com (Postfix) with ESMTP id A181620002 for ; Tue, 15 Jul 2025 05:28:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iD8TyC3g; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of djwong@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752557293; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Kv+ccbbWzyUMT+RB4ANGF4BhYYB1D0y4eewryFet678=; b=FNESQMxQCThaXqmtD5ub3Y7N2nw4/0UC1wXQKYA0ICWvHQrAaOUdvwJxwKl93devWPgXjs vSrJusZAwXB/H4uBnwnzW07rV2cdvoIeCLrlr2BeKjiuR03sihXTgR6YMZsoXlLJ3hW4pi atFsx5D8OOsv3lYEN7Df19RPhyqGqPg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752557293; a=rsa-sha256; cv=none; b=gwmrmfXR40bqcCI7HTg/Jjg7PW3wJCPnCZh9P2EkObvGaNp52Vddx2dHTl8T2Ao33n7nxX XIcdZncVjatkFzVz9GUjBvXRU9Nn0LIcjqtHO2p1guMXBrTeTDKd5Y1bD2WmRZV5oWnoFL firieei1mH6ck4nqL6dXdQ3tLTMSGD0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iD8TyC3g; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of djwong@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=djwong@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id B3AB061139; Tue, 15 Jul 2025 05:28:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DDC4C4CEE3; Tue, 15 Jul 2025 05:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752557292; bh=Fg4QHr5nbV2aZx8L9EV+fyurQsVPPodPUNC6K6KJdww=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iD8TyC3gHnSdkmAy9IfybIXXI0dow7Pq8ChIFnatGKhnh/uzI26ZfpMiz+Ga9dRYo 6rDLSQb9lXESjWAg/nI7u0b+eddc1yI5EVAjEmqsjwuQZvYYaYTs9uOs97ggyAoiPd kjvXx+HAt0mX275WGu4XsUjZq50BZco/FoZqpy7pCbTxCBvs9iYh3KeEXZY0dGMcr3 Xe7sZkD5RmJpz9Q0yJBBw+TBRUt1Se2wj8WUt2+1uN8If7El01mjTq5YB6uXhnCiby o97ZgmgYiJMaDtPHPCrPEXTSZJqeexmGYKSwq+JSvo04riK0WcQuadp10+MjUQiZ/V sWQ7VEptyZFZw== Date: Mon, 14 Jul 2025 22:28:11 -0700 From: "Darrick J. Wong" To: Brian Foster Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, willy@infradead.org Subject: Re: [PATCH v3 5/7] xfs: fill dirty folios on zero range of unwritten mappings Message-ID: <20250715052811.GQ2672049@frogsfrogsfrogs> References: <20250714204122.349582-1-bfoster@redhat.com> <20250714204122.349582-6-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250714204122.349582-6-bfoster@redhat.com> X-Rspamd-Queue-Id: A181620002 X-Stat-Signature: ij59noj1syh8e3tui49j7o8e1gms7gts X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1752557293-211906 X-HE-Meta: U2FsdGVkX1/poqd+8NHygkXYnMcxD644yi+fDgxGrbc2MOvzoKqA0ejQRdtH+D+4ybo44nIs2TQmAXuheQaI2Lkl80FMF3xTmls+A8Tbbn+Ymud2QDy9lUAx0w4fZY6hg5Ogm37zteSLUN1WFylirqyXBRbS0/ygxMUvvqTEMgpd9SaUpxzBKLBc7mGMk/xUJ3d4GWVHPFlJISQMlSIsaAHuTKPFTcXzD5sxcCJXLTncystg8QcxeMi4SnLmNGwO2DNfXJxekI2TvcDw6rN+n3Xk8unZAWNb0WgoP5NaFAQEo73SSXDKcQlrPpGMExplhwPAOSQRft1KD9BLPl+tmZSUFS8SefNi7C0DWH2Q+8HEWrxqPUZigDbAail2t2bT8pc6UXw+aCrXyDjnhXc1qSlGRbfcOO4C8JgRWXHdW8Wfo8iti5ff4cARXDeUym7DLGGZUWLAdw7mDTEMvvbvuo1AEmQuTxJYju5AkPN+XXlkV3FE61srq7XTCXrKIpYuAAwx9BmeFOO93lGWWiH7llymVUCLyS15jC+waDYtul6bDodjaiVFjtttUzBqoaXuqXFddT+7ieGD4w4E3y8PWDAfkxw+En1i4q0KhowPbvMpU4Ab7zmxy5Du20vqdF72RkC814+ckWPL4ejXRN66/GoueRXlRA1UNGwIs9kZ3F5vK84FY052F+zsk78ULqMvioDUcuoD5ZWVJdAt9UumLTiw2HL7Yp8D3iW4RumnTWJaiwVPveqrdOy+s+iebQo1FmInIqtW1/5u4lXvoPkDjMrWIN8sQvVKIwd7eeH6hdvvt3w5zFZpRvoOgoXEHR6AbHCmBMnqDGsXiWaJubX1f/80RZcK4bNqY8cPiGDuJQFbhQUxCZ78AOxM7wJYaeCWCH/z6eJ0IiREIZNPxkO6OzNL0Vvkm/hbHRo/iT9K3vM= 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: On Mon, Jul 14, 2025 at 04:41:20PM -0400, Brian Foster wrote: > 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)); Hrmm. XFS_B_TO_FSB and not _FSBT? Can the rounding up behavior result in a missed byte range? I think the answer is no because @end should be aligned to a folio boundary, and folios can't be smaller than an fsblock. If the answer to the second question is indeed "no" then I think this is ok and Reviewed-by: "Darrick J. Wong" --D > + } > + > xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); > } > > -- > 2.50.0 > >