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 v2 1/3] dm persistent data: put back the reference a failed shadow dropped
Date: Tue, 24 Nov 2026 12:35:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-231146@kernel.org> (raw)
In-Reply-To: <20261124122601.436965-2-den@openvz.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dm persistent data: leaked new block in __shadow_block() on
error
--
commit 03aa675fd4998658022986a6e963e9c3d3429569
Author: Denis V. Lunev <den@openvz.org>
dm persistent data: put back the reference a failed shadow dropped
This commit restores the original block's reference count via
dm_sm_inc_block() when __shadow_block() fails to read the original block
or write-lock the new block.
> diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
> index 7401add01d12e..cf203ebb5110e 100644
> --- a/drivers/md/persistent-data/dm-transaction-manager.c
> +++ b/drivers/md/persistent-data/dm-transaction-manager.c
> @@ -303,7 +303,7 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
>
> r = dm_bm_read_lock(tm->bm, orig, v, &orig_block);
> if (r < 0)
> - return r;
> + goto out_put_orig;
>
> /*
> * It would be tempting to use dm_bm_unlock_move here, but some
> @@ -315,13 +315,18 @@ 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_put_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_put_orig:
> + /* The caller goes on using orig when the shadow fails. */
> + dm_sm_inc_block(tm->sm, orig);
> return r;
> }
[Severity: Medium]
Does this leak the newly allocated block new in the space map when
__shadow_block() fails?
__shadow_block() allocates new via dm_sm_new_block(tm->sm, &new) with a
reference count of 1 before decrementing orig:
drivers/md/persistent-data/dm-transaction-manager.c:__shadow_block() {
r = dm_sm_new_block(tm->sm, &new);
if (r < 0)
return r;
r = dm_sm_dec_block(tm->sm, orig);
if (r < 0)
return r;
...
}
Unlike dm_tm_new_block(), which calls dm_sm_dec_block(tm->sm, new_block)
on failure, neither out_put_orig nor the dm_sm_dec_block(tm->sm, orig)
error path releases new. Once the target recovers from the transient
failure and commits a later transaction, new remains permanently allocated
in the on-disk space map with nothing referencing it.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124122601.436965-1-den@openvz.org?part=1
next prev parent reply other threads:[~2026-11-24 12:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 12:25 [PATCH v2 0/3] dm era: a metadata device that never comes back Denis V. Lunev
2026-11-24 12:25 ` [PATCH v2 1/3] dm persistent data: put back the reference a failed shadow dropped Denis V. Lunev
2026-11-24 12:35 ` sashiko-bot [this message]
2026-11-24 12:26 ` [PATCH v2 2/3] dm era: refuse metadata rpcs once the target is suspended Denis V. Lunev
2026-11-24 12:26 ` [PATCH v2 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-231146@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.