From: "Denis V. Lunev" <den@openvz.org>
To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
dm-devel@lists.linux.dev
Cc: bmarzins@redhat.com, thornber@redhat.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
den@openvz.org
Subject: [PATCH v3 1/3] dm persistent data: put back the reference a failed shadow dropped
Date: Mon, 30 Nov 2026 19:27:01 +0100 [thread overview]
Message-ID: <20261130182704.2728591-2-den@openvz.org> (raw)
In-Reply-To: <20261130182704.2728591-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
__shadow_block() drops the original block's reference before it reads
the block, and every error return after that leaves the caller pointing
at a block the space map has given away. The block allocated for the
copy is lost on those same paths.
metadata_ll_commit() shows what the dropped reference costs. It stores
the new block in ll->bitmap_root only when the shadow succeeds, so a
failed read leaves the space map's index root at a block whose count
has already reached zero. Every commit after that shadows the same
block, fails to decrement it, and fails:
device-mapper: space map common: unable to decrement block
device-mapper: era: metadata_commit: pre commit failed
The metadata never recovers. dm-era reports "era Error" and fails the
writes it was tracking, which takes the workload's filesystem
read-only. A read of a metadata block can fail for a transient reason,
and one failure is enough to get here.
Take the reference back where the shadow fails and release the copy's
block, the way dm_tm_new_block() above already does.
The decrement of the original stays where it was. Moving it past the
copy would hold the copy's write lock across dm_sm_dec_block(), which
starts by shadowing a bitmap block of its own and so takes two more
locks, and the targets size their dm-bufio reserve for the peak
without them: commit 490ae017f54e ("dm thin metadata:
THIN_MAX_CONCURRENT_LOCKS should be 6") set thin's budget to exactly
what rebalance3() reaches today.
Fixes: 3241b1d3e0aa ("dm: add persistent data library")
Cc: stable@vger.kernel.org
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
drivers/md/persistent-data/dm-transaction-manager.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
index 7401add01d12..90d0a95d940c 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.c
+++ b/drivers/md/persistent-data/dm-transaction-manager.c
@@ -299,11 +299,11 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
r = dm_sm_dec_block(tm->sm, orig);
if (r < 0)
- return r;
+ goto out_free_new;
r = dm_bm_read_lock(tm->bm, orig, v, &orig_block);
if (r < 0)
- return r;
+ goto out_inc_orig;
/*
* It would be tempting to use dm_bm_unlock_move here, but some
@@ -315,13 +315,20 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
r = dm_bm_write_lock_zero(tm->bm, new, v, result);
if (r) {
dm_bm_unlock(orig_block);
- return r;
+ goto out_inc_orig;
}
memcpy(dm_block_data(*result), dm_block_data(orig_block),
dm_bm_block_size(tm->bm));
dm_bm_unlock(orig_block);
+ return 0;
+
+out_inc_orig:
+ /* The caller goes on using orig when the shadow fails. */
+ dm_sm_inc_block(tm->sm, orig);
+out_free_new:
+ dm_sm_dec_block(tm->sm, new);
return r;
}
--
2.55.0
next prev parent reply other threads:[~2026-11-30 18:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 18:27 [PATCH v3 0/3] dm era: a metadata device that never comes back Denis V. Lunev
2026-11-30 18:27 ` Denis V. Lunev [this message]
2026-11-30 18:27 ` [PATCH v3 2/3] dm era: refuse metadata rpcs once the target is suspended Denis V. Lunev
2026-11-30 18:27 ` [PATCH v3 3/3] dm era: construct the target suspended Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130182704.2728591-2-den@openvz.org \
--to=den@openvz.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=stable@vger.kernel.org \
--cc=thornber@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®