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 BC13B3A9862 for ; Tue, 12 May 2026 14:10:58 +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=1778595058; cv=none; b=X+bL2p/sHoNezR38et5nkRitpDWXTjeIXJjRVhsbhwUhnFP088lFpf6tEnlqMcPtlamNFbjG83WMlBoUCaAUX5FoyibgfD218K+8zZe5at9tguO4BC1wg8FCNokPQtdNpH2ZC9AiCquOHlq7ddkZ+2LvnqfS/hrSQqZa5ZMFV44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778595058; c=relaxed/simple; bh=9BpbGT+JYEB8zd/tH5eeXSnP3kxyuw2iRKYRjxhKXpg=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=cd1jbixz7vKaSZcHna78XKv/tMo50Mavdrmh9drjtFSbLDDDZcOG6YMn/yDYZGHLGuWcR1XZ2bH++5Y3YNOfqXhCG7dh3idfmbh/+YZsFOG5wEKuTiFl0CLLdoz9UC9NsX3Jqc11NU3dVH2+3zxd4QoxV5c0xl+ifVwX8yRNw4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hK1kgJd+; 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="hK1kgJd+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED6FDC2BCB0; Tue, 12 May 2026 14:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778595058; bh=9BpbGT+JYEB8zd/tH5eeXSnP3kxyuw2iRKYRjxhKXpg=; h=Subject:To:Cc:From:Date:From; b=hK1kgJd+Wl3ckKXGOqR+g3mhyj/6HOeHK074rvq5yyJQBj15Txt6jaiIQqzpfGw20 bc0XcXSF2pU6PYy3QtHPuM5vsW3RyMBMtGUC/L+R3Oh7IoQi3TsTIaU/Nl4oqoq7JJ JeyO1FUKvvwMUBZl6/rTa7LRk+AxUFxLrsO/QZdU= Subject: FAILED: patch "[PATCH] dm-thin: fix metadata refcount underflow" failed to apply to 5.10-stable tree To: mpatocka@redhat.com Cc: From: Date: Tue, 12 May 2026 16:11:03 +0200 Message-ID: <2026051203-outbreak-showgirl-7530@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 09a65adc7d8bbfce06392cb6d375468e2728ead5 # git commit -s git send-email --to '' --in-reply-to '2026051203-outbreak-showgirl-7530@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 09a65adc7d8bbfce06392cb6d375468e2728ead5 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Mon, 20 Apr 2026 19:56:44 +0200 Subject: [PATCH] dm-thin: fix metadata refcount underflow There's a bug in dm-thin in the function rebalance_children. If the internal btree node has one entry, the code tries to copy all btree entries from the node's child to the node itself and then decrement the child's reference count. If the child node is shared (it has reference count > 1), we won't free it, so there would be two pointers to each of the grandchildren nodes. But the reference counts of the grandchildren is not increased, thus the reference count doesn't match the number of pointers that point to the grandchildren. This results in "device mapper: space map common: unable to decrement block" errors. Fix this bug by incrementing reference counts on the grandchildren if the btree node is shared. Signed-off-by: Mikulas Patocka Fixes: 3241b1d3e0aa ("dm: add persistent data library") Cc: stable@vger.kernel.org diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c index 942cd47eb52d..aeec5b9a1dd5 100644 --- a/drivers/md/persistent-data/dm-btree-remove.c +++ b/drivers/md/persistent-data/dm-btree-remove.c @@ -490,12 +490,20 @@ static int rebalance_children(struct shadow_spine *s, if (le32_to_cpu(n->header.nr_entries) == 1) { struct dm_block *child; + int is_shared; dm_block_t b = value64(n, 0); + r = dm_tm_block_is_shared(info->tm, b, &is_shared); + if (r) + return r; + r = dm_tm_read_lock(info->tm, b, &btree_node_validator, &child); if (r) return r; + if (is_shared) + inc_children(info->tm, dm_block_data(child), vt); + memcpy(n, dm_block_data(child), dm_bm_block_size(dm_tm_get_bm(info->tm)));