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 19511C83F1D for ; Tue, 15 Jul 2025 05:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5C106B007B; Tue, 15 Jul 2025 01:34:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0D486B0088; Tue, 15 Jul 2025 01:34:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9233D6B0089; Tue, 15 Jul 2025 01:34:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 81D116B007B for ; Tue, 15 Jul 2025 01:34:21 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 066621D9AAF for ; Tue, 15 Jul 2025 05:34:21 +0000 (UTC) X-FDA: 83665383522.10.B5979B2 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf03.hostedemail.com (Postfix) with ESMTP id 5ECD020002 for ; Tue, 15 Jul 2025 05:34:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P3tw4+WE; spf=pass (imf03.hostedemail.com: domain of djwong@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752557659; 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=ljuQ3yCds5CE7WEttaUD+LIAQR+wzeNEVDY/5GZp6lg=; b=WZHqUHqzupOkyu77H3nsaDY01++MmnHK0Ahr5VTraQOzGDGb194q9AD0lgvXTj3k5891SA JurN1xYhmprer6VsWcZVSkya30CfbB0m+Nia5rflhJw/MiRod3cRlw2AA1R/FuHtvnT6i5 rSrzpVorgLINFj5u2U4JZ+X6Y3NHxME= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P3tw4+WE; spf=pass (imf03.hostedemail.com: domain of djwong@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752557659; a=rsa-sha256; cv=none; b=Nx6e/ujunkGs/moHJlJIqE/pTjXE50YtUBIYO03REbzxDcC16YBuxwzjhm/UQKwqNPzDX7 Z2V9aNhKuKRCPVKcVwCo2/z3f01R++Dv0mpIXT1AQCoGSGqoQ5rwuo9rAeDKVGp+4K5HVb xRRKwzHZGZC1MBFm/XIdHq2xa/XjQyU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A0684A4F5C6; Tue, 15 Jul 2025 05:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42DD8C4CEE3; Tue, 15 Jul 2025 05:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752557658; bh=3qxVG0brYicTYe0lEhYy/WteBjTnpFcuTkkfe4/FAME=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P3tw4+WEW7mZG6qa1HvRa+XiDutd2ozlssmYfWFVFD+adFjYsLESvm+8fznAG0/rf lQCREgloSLNcKGT6c60PvZ3H+n2h0N8akKnkZsJHXfBbeWR5DYtEQsdipU3jp3PUq7 pbrX1Aj7VSsBlewO1/JKMwvoUTokBn4rWpYQtot1XNlS2/6CqJpWGjShirwB6AaLLj gI0kja6BIf6KRHbvw1gxMc8EVN7gE93d2P4mNtIIUPiOjsIvAr4AWp8BkedlnhaPEb teBh9buC3YVYTUWMhHiJDfjne0UaDJTacP6Ojcfhy0JcJqZTxsfWINdXoOriZq3q0V 3sZ0ldlhQLHKg== Date: Mon, 14 Jul 2025 22:34:17 -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 6/7] iomap: remove old partial eof zeroing optimization Message-ID: <20250715053417.GR2672049@frogsfrogsfrogs> References: <20250714204122.349582-1-bfoster@redhat.com> <20250714204122.349582-7-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250714204122.349582-7-bfoster@redhat.com> X-Stat-Signature: azkss944xzqki7eiw6c6s1jba4chukzt X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5ECD020002 X-Rspam-User: X-HE-Tag: 1752557659-34204 X-HE-Meta: U2FsdGVkX1+58bqhj6LX+HruFUgWfRY75nn80a2dHYg1FRva2ejdYWHvq0tu+/RAvFzVj2S+Tmx5DAfWC/ZWmgdnMaahaNC3k0+xcXJmdyp7BCg+aPehBTb1nyJsJ4qMVYLkMYNvn90F15XTm5ctNRNupNx09CWRshUobUV+If0E2Kh4cixxGMY9Dn6HOsZBXSGrC74T5tmZQUPDj06UyOp7N+Swr/EyVGU6yyU8vjUDJQ7QaYn5S4sNGZ3iTeH7vqJVoTvT2Tgj4mY/19pqau4ov5mV3Y1+JewSdTCzb9965HNVEI/Sx2b/3YxZLjdGv1W3VwP2xm5EPAUeWnZRl8+hBat/Zb2Toxk61eS5TM7iy/CvpOQdkbwSumIL6OYJusGl4JSwakT88GFQQyIpDIq1P61ZHqF0b56raeeiRbSZFkO4VfpkzMoS+pZztfQ+KtVAXq3y5ctxpx9IbpVUIsPO6bDqAPh4dxjKfVkx7c3yi5ZvKTy8ofk7vmYrNtktkWClB2o2g+Xujd7d1d5+RDpj8iEPQtkfERuir9ClI8fh/dvb8VzoG4On+UeYzc8xoNVP/uECAE9ETEHi+MblQ3g6O7pEBvO0VBT0+L5UzZPAN6oq01TfPD3rWvrzVCrVgLxsRHq+Zkp6vuZksVUTGE2kcaFq2AlTFA54nv82JYFteLBSqH8o1MPbMQ3KtqYvcMP82EApITMd52hZnqS2hZmQ1RWUSv/xCK+TuNgaxTSlU3WHM6BToyWvKalvAQFcHI9cxDj6lu7IVywjCkQ6pIMFg+0iio81zewPQZQjG2a7B8EuDwIqyJ+eTx9P0kyO++52+vrO/GXPM0ACTZcsQs95HmPCCUNu7StMU80V5r0hMWyiR4zT0h3c8vYTOxctcwmf3fJELB/7B8nqoBvmpGfGr86XJzOXBiLyAuK72hu3nGhIcp4vZd92KNRl8nnTdnspQReIjWfd9aexkQb MerDzF8u rKgV1H69v/0Dsnjno000RUwUXUfwh0AKMB3Qam2MwAk0v/syl8lpHAznciYYvuo7BRnHd9JIt8VatnJhX2E76fTgkQ2gg0TK8JfyUQ114ICMJqq9w2/6qRCBjwVxv6yzmAwmKUB2Rn25i5sojegnAvMZ/LgRanDNwGJbtxq96h4CTAsY2FpwDDwh7efauxgbpzBC60pap/FBZF0ZLht0j7/iMdf/9XY+w04Bb2ADJXCMtDwg4kL4opwnyYo2wo0AbdU6Nt878cdsZdmI= 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:21PM -0400, Brian Foster wrote: > iomap_zero_range() optimizes the partial eof block zeroing use case > by force zeroing if the mapping is dirty. This is to avoid frequent > flushing on file extending workloads, which hurts performance. > > Now that the folio batch mechanism provides a more generic solution > and is used by the only real zero range user (XFS), this isolated > optimization is no longer needed. Remove the unnecessary code and > let callers use the folio batch or fall back to flushing by default. > > Signed-off-by: Brian Foster > Reviewed-by: Christoph Hellwig Heh, I was staring at this last Friday chasing fuse+iomap bugs in fallocate zerorange and straining to remember what this does. Is this chunk still needed if the ->iomap_begin implementation doesn't (or forgets to) grab the folio batch for iomap? My bug turned out to be a bug in my fuse+iomap design -- with the way iomap_zero_range does things, you have to flush+unmap, punch the range and zero the range. If you punch and realloc the range and *then* try to zero the range, the new unwritten extents cause iomap to miss dirty pages that fuse should've unmapped. Ooops. --D > --- > fs/iomap/buffered-io.c | 24 ------------------------ > 1 file changed, 24 deletions(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 194e3cc0857f..d2bbed692c06 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -1484,33 +1484,9 @@ iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, > .private = private, > }; > struct address_space *mapping = inode->i_mapping; > - unsigned int blocksize = i_blocksize(inode); > - unsigned int off = pos & (blocksize - 1); > - loff_t plen = min_t(loff_t, len, blocksize - off); > int ret; > bool range_dirty; > > - /* > - * Zero range can skip mappings that are zero on disk so long as > - * pagecache is clean. If pagecache was dirty prior to zero range, the > - * mapping converts on writeback completion and so must be zeroed. > - * > - * The simplest way to deal with this across a range is to flush > - * pagecache and process the updated mappings. To avoid excessive > - * flushing on partial eof zeroing, special case it to zero the > - * unaligned start portion if already dirty in pagecache. > - */ > - if (!iter.fbatch && off && > - filemap_range_needs_writeback(mapping, pos, pos + plen - 1)) { > - iter.len = plen; > - while ((ret = iomap_iter(&iter, ops)) > 0) > - iter.status = iomap_zero_iter(&iter, did_zero); > - > - iter.len = len - (iter.pos - pos); > - if (ret || !iter.len) > - return ret; > - } > - > /* > * To avoid an unconditional flush, check pagecache state and only flush > * if dirty and the fs returns a mapping that might convert on > -- > 2.50.0 > >