From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30AAA1F585A; Mon, 5 May 2025 09:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746436727; cv=none; b=hrZ/iP8x/8X1I8Tazy0iYUoHSM7cqUSRwzLvfoG9UlnthE60qwgZ1HjhFkuMcIH4xL4AYbyJVHVz7sznYMxTolDX4/HxHyGqS2sTGXGxmzkfBWOBFPzSHUXuqxQ8UU7fQf+WxmA3L82hVk/8KFMhzjkMie4mH2xVUcnkbqJ3Oas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746436727; c=relaxed/simple; bh=5TYYSv89Vjac3SfNIhTlbtwX8atTXZ2JBuE5FV4V34s=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=mL3OYoISas+zK6K11tWS2I6TEEOdxDHy54R725PXTtoEQlaPPYaXn8VX+WnWSD5W8iI9TNQCywEhJrpr/EtYyhVKAsrelFkKBxwGf98lwncOmf4ZrFJkXHmw4Ffqzzwx8ytP1AWsMypOAUKo9Vo43LrshWiG8M76CmWd8Mkx3ME= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S4GKTVRM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="S4GKTVRM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BCAC4CEEF; Mon, 5 May 2025 09:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746436726; bh=5TYYSv89Vjac3SfNIhTlbtwX8atTXZ2JBuE5FV4V34s=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=S4GKTVRMue/liA+1ME4hQN/Ed4HWunwvFTYIZimmxG0x6/WC3Ianyf7G3vvXPnrEE zi1VQq9JGVSubSX5JZtR1ffrVlZgByPokEpbgyAToAe2ldD0x8uTmacKkIgNmb9WD/ EI7U1QZxuFkDCiCrpDMKEcS60uZrnM6DTqIZM+Bw= Subject: Patch "xfs: fix xfs_bmap_add_extent_delay_real for partial conversions" has been added to the 6.1-stable tree To: catherine.hoang@oracle.com,chandan.babu@oracle.com,chandanbabu@kernel.org,djwong@kernel.org,gregkh@linuxfoundation.org,hch@lst.de,leah.rumancik@gmail.com,xfs-stable@lists.linux.dev Cc: From: Date: Mon, 05 May 2025 11:18:24 +0200 In-Reply-To: <20250430212704.2905795-3-leah.rumancik@gmail.com> Message-ID: <2025050524-esophagus-exemption-e9e8@gregkh> Precedence: bulk X-Mailing-List: xfs-stable@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled xfs: fix xfs_bmap_add_extent_delay_real for partial conversions to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-fix-xfs_bmap_add_extent_delay_real-for-partial-conversions.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-139229-greg=kroah.com@vger.kernel.org Wed Apr 30 23:31:35 2025 From: Leah Rumancik Date: Wed, 30 Apr 2025 14:26:49 -0700 Subject: xfs: fix xfs_bmap_add_extent_delay_real for partial conversions To: stable@vger.kernel.org Cc: xfs-stable@lists.linux.dev, chandan.babu@oracle.com, catherine.hoang@oracle.com, djwong@kernel.org, Christoph Hellwig , Chandan Babu R , Leah Rumancik Message-ID: <20250430212704.2905795-3-leah.rumancik@gmail.com> From: Christoph Hellwig [ Upstream commit d69bee6a35d3c5e4873b9e164dd1a9711351a97c ] xfs_bmap_add_extent_delay_real takes parts or all of a delalloc extent and converts them to a real extent. It is written to deal with any potential overlap of the to be converted range with the delalloc extent, but it turns out that currently only converting the entire extents, or a part starting at the beginning is actually exercised, as the only caller always tries to convert the entire delalloc extent, and either succeeds or at least progresses partially from the start. If it only converts a tiny part of a delalloc extent, the indirect block calculation for the new delalloc extent (da_new) might be equivalent to that of the existing delalloc extent (da_old). If this extent conversion now requires allocating an indirect block that gets accounted into da_new, leading to the assert that da_new must be smaller or equal to da_new unless we split the extent to trigger. Except for the assert that case is actually handled by just trying to allocate more space, as that already handled for the split case (which currently can't be reached at all), so just reusing it should be fine. Except that without dipping into the reserved block pool that would make it a bit too easy to trigger a fs shutdown due to ENOSPC. So in addition to adjusting the assert, also dip into the reserved block pool. Note that I could only reproduce the assert with a change to only convert the actually asked range instead of the full delalloc extent from xfs_bmapi_write. Signed-off-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Leah Rumancik Acked-by: "Darrick J. Wong" Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_bmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1530,6 +1530,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: @@ -1559,6 +1560,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: @@ -1592,6 +1594,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: @@ -1624,6 +1627,7 @@ xfs_bmap_add_extent_delay_real( goto done; } } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: @@ -1661,6 +1665,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING: @@ -1748,6 +1753,7 @@ xfs_bmap_add_extent_delay_real( xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); xfs_iext_next(ifp, &bma->icur); xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); + ASSERT(da_new <= da_old); break; case BMAP_RIGHT_FILLING: @@ -1795,6 +1801,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_blockcount = temp; xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); xfs_iext_next(ifp, &bma->icur); + ASSERT(da_new <= da_old); break; case 0: @@ -1915,11 +1922,9 @@ xfs_bmap_add_extent_delay_real( } /* adjust for changes in reserved delayed indirect blocks */ - if (da_new != da_old) { - ASSERT(state == 0 || da_new < da_old); + if (da_new != da_old) error = xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), - false); - } + true); xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); done: Patches currently in stable-queue which might be from leah.rumancik@gmail.com are queue-6.1/xfs-revert-commit-44af6c7e59b12.patch queue-6.1/xfs-make-the-seq-argument-to-xfs_bmapi_convert_delalloc-optional.patch queue-6.1/xfs-check-opcode-and-iovec-count-match-in-xlog_recover_attri_commit_pass2.patch queue-6.1/xfs-allow-symlinks-with-short-remote-targets.patch queue-6.1/xfs-match-lock-mode-in-xfs_buffered_write_iomap_begin.patch queue-6.1/xfs-require-xfs_sb_feat_incompat_log_xattrs-for-attr-log-intent-item-recovery.patch queue-6.1/xfs-allow-unlinked-symlinks-and-dirs-with-zero-size.patch queue-6.1/xfs-restrict-when-we-try-to-align-cow-fork-delalloc-to-cowextsz-hints.patch queue-6.1/xfs-fix-xfs_bmap_add_extent_delay_real-for-partial-conversions.patch queue-6.1/xfs-validate-recovered-name-buffers-when-recovering-xattr-items.patch queue-6.1/xfs-make-xfs_bmapi_convert_delalloc-to-allocate-the-target-offset.patch queue-6.1/xfs-convert-delayed-extents-to-unwritten-when-zeroing-post-eof-blocks.patch queue-6.1/xfs-fix-freeing-speculative-preallocations-for-preallocated-files.patch queue-6.1/xfs-make-sure-sb_fdblocks-is-non-negative.patch queue-6.1/xfs-remove-a-racy-if_bytes-check-in-xfs_reflink_end_cow_extent.patch queue-6.1/xfs-fix-error-returns-from-xfs_bmapi_write.patch