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 A8D10C5AE59 for ; Thu, 5 Jun 2025 17:30:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F9956B00BF; Thu, 5 Jun 2025 13:30:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A98F6B00C2; Thu, 5 Jun 2025 13:30:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64B5B6B00C1; Thu, 5 Jun 2025 13:30:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3AC466B00BE for ; Thu, 5 Jun 2025 13:30:37 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E9218141102 for ; Thu, 5 Jun 2025 17:30:36 +0000 (UTC) X-FDA: 83522036472.29.FF808E5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 3396B180017 for ; Thu, 5 Jun 2025 17:30:35 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J75WvmEb; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749144635; 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=g1X2OSHk59+93ubkPLy5LJPQ/+O7r13j0K4bt+a8Izc=; b=bcT677gNIFm2iMSGbsIiaH+LgpOdQM5iGm7IM3aGB18Lwqw5EYOZIeozol0/Qccao5X3fY daLHQOFkJHf0CLMtZ6aInuT9ugWTRwrWozv9LXUA14JKAqrJ78BOfGcb0PHmU4/mDcab6p tEd76Nvw8wXDNe3L83vTmXQvTpEtxxY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749144635; a=rsa-sha256; cv=none; b=cfeGz5KoPqmo7SKCysqZfhVdA9SNOi3XWHfzRJ5Aa9bvbH1+K1q7oBWRipy6/fyP/KFTmy eIPq2ZJGEIIgdC6EFRD5q9LUcTz6hqttizeR1K5BvVEAzArLZ9nE4rOQ7RUregpLN3TgfP y6Vp15vIZ1TxhEDItruIyLFOz+q8+j4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J75WvmEb; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749144634; 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=g1X2OSHk59+93ubkPLy5LJPQ/+O7r13j0K4bt+a8Izc=; b=J75WvmEbAX2FAewOZsq0KPlD4+qsMyJ5YXRGIKEXiZHADQZyfyY/Rqm7pOxYPknVjthJPg urp56XC+24Ljo1H0nzr1VDD9kCb+CvBW1MXo4nPylM4di6NPBqdJVXbaXcAwiTnCxOdnAK kgsQCFYu1sALKKiLjOXzxPUmVwOmNvk= Received: from mx-prod-mc-08.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-310-aPbX9zfLMtqgH4L7AM2ybA-1; Thu, 05 Jun 2025 13:30:33 -0400 X-MC-Unique: aPbX9zfLMtqgH4L7AM2ybA-1 X-Mimecast-MFC-AGG-ID: aPbX9zfLMtqgH4L7AM2ybA_1749144632 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4981B1801BEE; Thu, 5 Jun 2025 17:30:32 +0000 (UTC) Received: from bfoster.redhat.com (unknown [10.22.88.123]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 726B330002C0; Thu, 5 Jun 2025 17:30:31 +0000 (UTC) From: Brian Foster To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/7] xfs: always trim mapping to requested range for zero range Date: Thu, 5 Jun 2025 13:33:54 -0400 Message-ID: <20250605173357.579720-5-bfoster@redhat.com> In-Reply-To: <20250605173357.579720-1-bfoster@redhat.com> References: <20250605173357.579720-1-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3396B180017 X-Stat-Signature: cpt4kdo8etgb78tyi9c7pt4eq3tm79rz X-Rspam-User: X-HE-Tag: 1749144635-144699 X-HE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1GB2fPSx7ILSnE/Dmiu1rfcEEy5nnyrCNo7QeahBNV1N5E2cvdb/RLLNKQ+H5yja4PSFV3dvAc7tReunob0GK2k2dC0iwKUIx9Mo/CqMsKi8Lm30XrK/7YQ+pm0Nl5vWFMlb0kapbYY0TlVsGhOQI8oSwaPxL6H5xfyvq+36FjUF162CPV1DFdWPDJiw+xNTh1KMUjTxmfNg6wUYUUcvqOooaGcDPIAdNwUsNVB6w2RU+YxO6nuqU4WPhDVACPTeKXF6i0UJsUI++QQtCM= 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: Refactor and tweak the IOMAP_ZERO logic in preparation to support filling the folio batch for unwritten mappings. Drop the superfluous imap offset check since the hole case has already been filtered out. Split the the delalloc case handling into a sub-branch, and always trim the imap to the requested offset/count so it can be more easily used to bound the range to lookup in pagecache. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index ff05e6b1b0bb..b5cf5bc6308d 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1756,21 +1756,20 @@ xfs_buffered_write_iomap_begin( } /* - * For zeroing, trim a delalloc extent that extends beyond the EOF - * block. If it starts beyond the EOF block, convert it to an + * For zeroing, trim extents that extend beyond the EOF block. If a + * delalloc extent starts beyond the EOF block, convert it to an * unwritten extent. */ - if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && - isnullstartblock(imap.br_startblock)) { + if (flags & IOMAP_ZERO) { xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); - if (offset_fsb >= eof_fsb) + if (isnullstartblock(imap.br_startblock) && + offset_fsb >= eof_fsb) goto convert_delay; - if (end_fsb > eof_fsb) { + if (offset_fsb < eof_fsb && end_fsb > eof_fsb) end_fsb = eof_fsb; - xfs_trim_extent(&imap, offset_fsb, - end_fsb - offset_fsb); - } + + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); } /* -- 2.49.0