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 2C14AC83F21 for ; Tue, 15 Jul 2025 14:19:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3ACE6B00A4; Tue, 15 Jul 2025 10:19:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C129A6B00A5; Tue, 15 Jul 2025 10:19:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4FB36B00A6; Tue, 15 Jul 2025 10:19:57 -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 A17C26B00A4 for ; Tue, 15 Jul 2025 10:19:57 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 02F2580508 for ; Tue, 15 Jul 2025 14:19:56 +0000 (UTC) X-FDA: 83666708034.26.6B1BDB7 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf09.hostedemail.com (Postfix) with ESMTP id 53AA8140005 for ; Tue, 15 Jul 2025 14:19:55 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tkXbgtRc; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.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=1752589195; 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=qb3c0nWVzrSyQkeFY64zBYkZaSZJbCsGnbpLPZirssA=; b=GANoCDmbjgwJExa6bQecdmPJF6k6iyOkhepDInuKmTqogvbrxTTIE6d1EqsEpun8V+uXaH Oxmna6bBPxDXknlOf8aMY1bVkOBTka4Gb8H74cQ7o9Nf3M5dqGWuiC6Bt6rCcANQ4UAP9D A5TcM66oyJvZJtyHXcN5QywhCkcPrHs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752589195; a=rsa-sha256; cv=none; b=Xax08a9pjDWKqsyL/Eg/BLYFZjkVM2bq5LlRCRq0mf0aAX4JZB7P7X90Ss9v375GA+ZN3Y K2PhhmQakAcvOs2n2HFTlauNVIT1ouUQr3baqqcSr/t+awSbTEqFW4mZTRrfHsYKLMAYNc IkBv9TSFXQd6YbS5YpWSkO7oUy0CQ3s= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tkXbgtRc; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.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 B244461456; Tue, 15 Jul 2025 14:19:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F651C4CEE3; Tue, 15 Jul 2025 14:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752589194; bh=qZ+LC3FTqFJ27mtCLEBJ1uKtZR3TIsj7xDBbTuuliR0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tkXbgtRclBrdKKwGxvl2fyRNA7ZDXaoB+JpC8gJMJZ0co1wjgMD3t/uVkWC0Z1Lwg m+ituiGN8QClgVE6taDhix9JV2m8tLPwxtfhu0DC0tKszE3FMBnAeaHlAW/09f5f1P XFkBEcXhrDjsZJp1yzuZMmJOUynwZwxNXZ6fQFfzn5178LruEEQ5CKonDtpweRdVYy 4Ruu/VLP37alTWyoVwm5XdzPeTa0s1Zh6JNfeM3JX2/lUhXZifcvKlGdDdS6le+kGY +H/L3kvidQDgy+eAHZbWehwEP84xsXp4GVZ6PI3QVFgRzLPGi5BSnS0MpCrPKoumJA QDhs46ChF6lyg== Date: Tue, 15 Jul 2025 07:19:53 -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: <20250715141953.GM2672029@frogsfrogsfrogs> References: <20250714204122.349582-1-bfoster@redhat.com> <20250714204122.349582-6-bfoster@redhat.com> <20250715052811.GQ2672049@frogsfrogsfrogs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: nus9ryhm78qpc5bbtuhzrs814zpywoym X-Rspamd-Queue-Id: 53AA8140005 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1752589195-280410 X-HE-Meta: U2FsdGVkX1+5AYEdUJkiH6YIYBLy4PVupB/Nt4wThVmLgxNUiZ8Db/hSWyWbBdMMXZz3Hezw/EgEZQKmd/MGIwNEqJMIwwD43AF1zJgm8ow+pb2vHtAH76/VuB170fhgQNP4kX6grx56a7UwA2wsqbm3rDkgtqH4BnjS2qF8dbL5Hp1ZDImG+UCiy6x8+HlC7YESeaLULO61JqrXIawaex8qcS51g4kKnNX8Ld4dDcOCSkza4tI0AdUBxMRmPrsrYMj6LkI6IelTJVHAaba02mJcnZGfGFXhPl+3WnYrZxnvzMG7gKRPCLjoDV6VOjmfEr8A+VN+m+5OGZFSYRUaFf8bOjOtc/a6aAKz8e3U3tAK+qnWQrNqL5D/hxx+EJczo+GZhIC7sbWMSaZumhMYD8joiWu62aog+G/Xwndh9qwS7Ee4GEeoSJiYT7GTQ7O5xkyht5AALYixeSs63cR/teJaeFY1hhFJCB1IUVOPVNekNaBHv1OrpdeBw7E2qgaqjTzjpdh+4r2HB00fHbcr2k8luRMq1CcyUUXWVFI8HYIYKKG9Jbo/eK9NiJ007kywTPblMbhL+ZOxiRzvqtVXT0HkLUmGDnjvFjFkVlvtufATGR5C/gUtp+epEJLLhkCTwALbI5Ds0Da3QqYNifTsYYl9Zy9kr3YTwx6eTB3krAb3shOPQ2FXVD7CfN/KfrBodQ2qCxhCyjx0f15wNPLy46sV3XxSMTftKTkeQqxCD0Jj1kMFaDTbSEZul3oHamj0dHVQZ1dkrUyUlIjyC0DaCoKippvAcniZsX/zIKWagpzCgNzBsau+mVojFCzCOanMLuMYVJ+h6FqOjBnUGVnMp+xEG6iPdVKmXvf8qcllRzeETaFPAHg6PCL7G0k15Sgb3YZs2tzaBch/v0BOk17BRBLXvwJicXeFTcgshvUtnnfCpfm4dG7seo2Ovtgm5/MRH1SM05bChALy7iKJVGh coLOmOJN YIWCrhNFHdzgrKWg6QoKC+ULJ7rmY4CThe5Va4aqwgbJMFG4v9wZmEOjAqrMU8oAQQSMMYxmkpyAVsTLeRzQEEWLrRs4+Ypf2iimQYFNEtM2YE4ilvoHA7vtwfpRTciAkTNPawJjvH8C0hbk9zWlofmC7FHgQT9gkRvoNhbJFSym6sLglCy5NLuk5ewNs3V9eZGRRUKdhIKVoMY2b1OSC/87UWMQCvhItWjwsPVJlrXtL2HGHazCwAfnoI7VmMbYIqJU0uOMgAqpe2u6HXHK1ic/Ve3htB6ebPJVvET/T7dhv6vw= 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 Tue, Jul 15, 2025 at 08:35:51AM -0400, Brian Foster wrote: > On Mon, Jul 14, 2025 at 10:28:11PM -0700, Darrick J. Wong wrote: > > 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. > > > > Hmm.. not that I'm aware of..? Please elaborate if there's a case you're > suspicious of because I could have certainly got my wires crossed. I don't have a specific case in mind. I saw the conversion function and thought "well, what IF the return value from iomap_fill_dirty_folios isn't aligned to a fsblock?" and then went around trying to prove that isn't possible. :) > My thinking is that end_fsb reflects the first fsb beyond the target > range. I.e., it's calculated and used as such in xfs_iomap_end_fsb() and > the various xfs_trim_extent() calls throughout the rest of the function. So I think we're fine here. --D > Brian > > > 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 > > > > > > > > > >