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 E70FD2356C7; Fri, 20 Jun 2025 09:04:20 +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=1750410261; cv=none; b=BGND4EyahFq8ctY3x5Axh1r6J4HTjL0oW/8hz5dPePgakkcPE9LRl9TsntdUlppgg9Ayc3NrUHd3vXPFQBHa+fSmh6Ztoiw1MVfQJI//uiE1zb0n31ckfTFf+5M3Jm/L50XpZLjzsNlgeAYqqvvtF323yiFrhqqDaMXQZ+02kfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750410261; c=relaxed/simple; bh=JfwprKG8uZHsvhxwFLVHf5jiSoLlDN1ED8eQJcJZHiM=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=JJmlLv2tAXeJnQluvWlMdxVDZcJ0/lDQ71qCrGjC09+YmUEDmvowG2Osls+ksn9V59OMrpVpD6oMWWzPvj59yI+Hix7m/fcLkrsgdhXixPEHYmR4smNvAOV0tY6EljyVMi5d2zuEBpv6FRDMMpMJ5FATPAifv4Vtaam5p8JBw5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cSl8Ul4k; 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="cSl8Ul4k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C6ACC4CEE3; Fri, 20 Jun 2025 09:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750410260; bh=JfwprKG8uZHsvhxwFLVHf5jiSoLlDN1ED8eQJcJZHiM=; h=Subject:To:Cc:From:Date:From; b=cSl8Ul4kybH5EcGQmAoC+gDQaJlinAQb5PhQpkBPBsy4Q7+hpNavE+qXOqXnPea9M 6fTTKfsTr0wo7f/YW0vvvPUP4kw3mpMvaicnu6NxSZHIIlxy4vBhC+nTVpRFdgVQmI n0hhBkDu4e9LNX1ZBkYUS8ZeeBsWwH3sQVUVnIjo= Subject: Patch "ext4: fix calculation of credits for extent tree modification" has been added to the 5.10-stable tree To: dave@stgolabs.net,gregkh@linuxfoundation.org,jack@suse.cz,kdevops@lists.linux.dev,mcgrof@kernel.org,stable@kernel.org,tytso@mit.edu,yi.zhang@huawei.com Cc: From: Date: Fri, 20 Jun 2025 11:03:07 +0200 Message-ID: <2025062007-relieving-brewing-030f@gregkh> Precedence: bulk X-Mailing-List: kdevops@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 ext4: fix calculation of credits for extent tree modification to the 5.10-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: ext4-fix-calculation-of-credits-for-extent-tree-modification.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From 32a93f5bc9b9812fc710f43a4d8a6830f91e4988 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 29 Apr 2025 19:55:36 +0200 Subject: ext4: fix calculation of credits for extent tree modification From: Jan Kara commit 32a93f5bc9b9812fc710f43a4d8a6830f91e4988 upstream. Luis and David are reporting that after running generic/750 test for 90+ hours on 2k ext4 filesystem, they are able to trigger a warning in jbd2_journal_dirty_metadata() complaining that there are not enough credits in the running transaction started in ext4_do_writepages(). Indeed the code in ext4_do_writepages() is racy and the extent tree can change between the time we compute credits necessary for extent tree computation and the time we actually modify the extent tree. Thus it may happen that the number of credits actually needed is higher. Modify ext4_ext_index_trans_blocks() to count with the worst case of maximum tree depth. This can reduce the possible number of writers that can operate in the system in parallel (because the credit estimates now won't fit in one transaction) but for reasonably sized journals this shouldn't really be an issue. So just go with a safe and simple fix. Link: https://lore.kernel.org/all/20250415013641.f2ppw6wov4kn4wq2@offworld Reported-by: Davidlohr Bueso Reported-by: Luis Chamberlain Tested-by: kdevops@lists.linux.dev Signed-off-by: Jan Kara Reviewed-by: Zhang Yi Link: https://patch.msgid.link/20250429175535.23125-2-jack@suse.cz Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/extents.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2367,18 +2367,19 @@ int ext4_ext_calc_credits_for_single_ext int ext4_ext_index_trans_blocks(struct inode *inode, int extents) { int index; - int depth; /* If we are converting the inline data, only one is needed here. */ if (ext4_has_inline_data(inode)) return 1; - depth = ext_depth(inode); - + /* + * Extent tree can change between the time we estimate credits and + * the time we actually modify the tree. Assume the worst case. + */ if (extents <= 1) - index = depth * 2; + index = EXT4_MAX_EXTENT_DEPTH * 2; else - index = depth * 3; + index = EXT4_MAX_EXTENT_DEPTH * 3; return index; } Patches currently in stable-queue which might be from jack@suse.cz are queue-5.10/ext4-inline-fix-len-overflow-in-ext4_prepare_inline_data.patch queue-5.10/ext4-fix-calculation-of-credits-for-extent-tree-modification.patch queue-5.10/jbd2-fix-data-race-and-null-ptr-deref-in-jbd2_journal_dirty_metadata.patch queue-5.10/ext4-ensure-i_size-is-smaller-than-maxbytes.patch queue-5.10/ext4-factor-out-ext4_get_maxbytes.patch