From: sashiko-bot@kernel.org
To: "Denis V. Lunev" <den@openvz.org>,
agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
dm-devel@lists.linux.dev
Cc: bmarzins@redhat.com, thornber@redhat.com
Subject: Re: [PATCH 1/3] dm persistent data: drop the original block only once it is copied
Date: Wed, 18 Nov 2026 11:25:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-220821@kernel.org> (raw)
In-Reply-To: <20261118110239.2910290-2-den@openvz.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] dm persistent data: __shadow_block() exceeds max concurrent
locks
- [Medium] dm persistent data: space map block leak on error in
__shadow_block()
--
commit f51a9340a7ed4ff57bea163d1f75e930e3c7038c
Author: Denis V. Lunev <den@openvz.org>
dm persistent data: drop the original block only once it is copied
This commit moves the dm_sm_dec_block() call in __shadow_block() after
the original block is read, copied into the newly allocated block, and
unlocked.
> diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
> index 7401add01d12e..159aac9da07ae 100644
> --- a/drivers/md/persistent-data/dm-transaction-manager.c
> +++ b/drivers/md/persistent-data/dm-transaction-manager.c
> @@ -297,10 +297,6 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
> if (r < 0)
> return r;
>
> - r = dm_sm_dec_block(tm->sm, orig);
> - if (r < 0)
> - return r;
> -
> r = dm_bm_read_lock(tm->bm, orig, v, &orig_block);
> if (r < 0)
> return r;
> @@ -322,7 +318,14 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
> dm_bm_block_size(tm->bm));
>
> dm_bm_unlock(orig_block);
> - return r;
> +
> + r = dm_sm_dec_block(tm->sm, orig);
> + if (r < 0) {
> + dm_bm_unlock(*result);
> + return r;
> + }
> +
> + return 0;
> }
[Severity: High]
Can calling dm_sm_dec_block() while *result is still write-locked exceed
the maximum concurrent block locks reserved by dm-bufio and deadlock under
memory pressure?
Previously, __shadow_block() ran in three sequential phases that each held
at most two locks internally: dm_sm_new_block(), dm_sm_dec_block(), and
dm_bm_read_lock(orig) + dm_bm_write_lock_zero(new). Commit 490ae017f54e
("dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6") sized
THIN_MAX_CONCURRENT_LOCKS to 6 for rebalance3(), which holds 4 locks (2 in
the shadow spine plus left and center children) when init_child() calls
dm_tm_shadow_block() for the right child (4 + 2 = 6).
With dm_sm_dec_block(tm->sm, orig) moved after dm_bm_write_lock_zero(),
*result is already held when dm_sm_dec_block() runs. When
smm->recursion_count is 0 and orig's bitmap block has not been shadowed yet
in the current transaction, sm_metadata_dec_blocks() -> sm_ll_dec() ->
__sm_ll_dec() -> shadow_bitmap() recursively enters __shadow_block() for
the bitmap block and takes dm_bm_read_lock() and dm_bm_write_lock_zero().
That brings the peak lock count to caller_locks + 3, reaching 7 concurrent
locks in rebalance3() (exceeding THIN_MAX_CONCURRENT_LOCKS = 6) and 6 in
rebalance2() (exceeding ERA_MAX_CONCURRENT_LOCKS = 5,
CACHE_MAX_CONCURRENT_LOCKS = 5, and DM_CLONE_MAX_CONCURRENT_LOCKS = 5).
When dm-bufio falls back to its reserved_buffers pool under memory
pressure, a single metadata thread holding all reserved buffers cannot
evict its own held buffers and blocks forever in
__alloc_buffer_wait_no_callback() -> __wait_for_free_buffer().
[Severity: Medium]
Does __shadow_block() also leak the newly allocated block new in the space
map when dm_bm_read_lock(), dm_bm_write_lock_zero(), or dm_sm_dec_block()
fails?
At the start of __shadow_block(), dm_sm_new_block(tm->sm, &new) allocates
new with a reference count of 1. If a transient read error in
dm_bm_read_lock() (or a failure in dm_bm_write_lock_zero() or
dm_sm_dec_block(tm->sm, orig)) aborts the shadow and a subsequent commit
succeeds, new is never released with dm_sm_dec_block(tm->sm, new) (unlike
dm_tm_new_block() right above, which decrements new_block on error) and
remains permanently allocated in the space map with no metadata pointing to
it. On the dm_sm_dec_block(tm->sm, orig) failure path,
dm_bm_unlock(*result) also marks the buffer for new dirty in dm-bufio.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118110239.2910290-1-den@openvz.org?part=1
next prev parent reply other threads:[~2026-11-18 11:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 11:02 [PATCH 0/3] dm era: a metadata device that never comes back Denis V. Lunev
2026-11-18 11:02 ` [PATCH 1/3] dm persistent data: drop the original block only once it is copied Denis V. Lunev
2026-11-18 11:25 ` sashiko-bot [this message]
2026-11-18 11:02 ` [PATCH 2/3] dm era: refuse metadata rpcs once the target is suspended Denis V. Lunev
2026-11-18 11:02 ` [PATCH 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=sashiko-outbox-220821@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=den@openvz.org \
--cc=dm-devel@lists.linux.dev \
--cc=mpatocka@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=snitzer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.