From: sashiko-bot@kernel.org
To: "Peng Yu" <yupeng0921@gmail.com>,
"Alasdair Kergon" <agk@redhat.com>,
"Mike Snitzer" <snitzer@kernel.org>,
"Mikulas Patocka" <mpatocka@redhat.com>,
"Benjamin Marzinski" <bmarzins@redhat.com>
Cc: "Joe Thornber" <ejt@redhat.com>, dm-devel@lists.linux.dev
Subject: Re: [PATCH v2 2/2] dm thin: add wait_for_commit pool feature
Date: Tue, 01 Dec 2026 07:52:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-242797@kernel.org> (raw)
In-Reply-To: <20261201072532.68398-3-yupeng0921@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dm thin: unreachable aborted-changes check in
complete_discard_mapping()
--
commit 6186cc8a4374967ef907958ccb4e31311f078113
Author: Peng Yu <yupeng0921@gmail.com>
dm thin: add wait_for_commit pool feature
This commit adds the wait_for_commit pool feature so that writes and
discards on thin devices with uncommitted metadata changes only complete
after the metadata transaction is committed.
> diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
> index e695fc356c4dc..6485c19506e4d 100644
> --- a/drivers/md/dm-thin.c
> +++ b/drivers/md/dm-thin.c
[ ... ]
> @@ -1065,6 +1085,40 @@ static void process_prepared_discard_success(struct dm_thin_new_mapping *m)
> free_discard_mapping(m);
> }
>
> +/*
> + * The metadata work of the discard is done. With the wait_for_commit
> + * feature the discard is completed, and its cell released, only after the
> + * commit: until then no other IO to the range may see the discard.
> + */
> +static void complete_discard_mapping(struct dm_thin_new_mapping *m)
> +{
> + struct thin_c *tc = m->tc;
> + struct pool *pool = tc->pool;
> +
> + if (!pool->pf.wait_for_commit ||
> + !dm_thin_changed_this_transaction(tc->td)) {
> + process_prepared_discard_success(m);
> + return;
> + }
> +
> + /*
> + * As for a FUA write: fail the discard if earlier changes to the
> + * metadata could not be committed.
> + */
> + if (dm_thin_aborted_changes(tc->td)) {
> + process_prepared_discard_fail(m);
> + return;
> + }
[Severity: Medium]
Can dm_thin_aborted_changes(tc->td) ever be reached here when true, or do
discards instead complete with success after an aborted transaction?
td->aborted_with_changes is only set by dm_pool_abort_metadata() via
metadata_operation_failed() -> abort_transaction(), which immediately
switches the pool to PM_READ_ONLY:
drivers/md/dm-thin.c:set_pool_mode() {
...
case PM_OUT_OF_METADATA_SPACE:
case PM_READ_ONLY:
dm_pool_metadata_read_only(pool->pmd);
pool->process_bio = process_bio_read_only;
pool->process_discard = process_bio_success;
pool->process_cell = process_cell_read_only;
pool->process_discard_cell = process_cell_success;
pool->process_prepared_mapping = process_prepared_mapping_fail;
pool->process_prepared_discard = process_prepared_discard_success;
...
}
Because complete_discard_mapping() is only called after
dm_thin_remove_range() or dm_pool_dec_data_range() succeeds, and both fail
once the metadata block manager is marked read-only, this check is dead
code. Meanwhile, any discards processed in PM_READ_ONLY or
PM_OUT_OF_METADATA_SPACE mode are completed with BLK_STS_OK by
process_bio_success(), process_cell_success(), and
process_prepared_discard_success(), even when wait_for_commit is enabled
and their mapping removals were never committed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201072532.68398-1-yupeng0921@gmail.com?part=2
next prev parent reply other threads:[~2026-12-01 7:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 7:25 [PATCH v2 0/2] dm thin: complete writes only after the metadata commit Peng Yu
2026-12-01 7:25 ` [PATCH v2 1/2] dm thin metadata: keep the changed flags until the commit succeeds Peng Yu
2026-12-01 7:25 ` [PATCH v2 2/2] dm thin: add wait_for_commit pool feature Peng Yu
2026-12-01 7:52 ` sashiko-bot [this message]
2026-12-02 2:40 ` peng yu
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-242797@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=ejt@redhat.com \
--cc=mpatocka@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=snitzer@kernel.org \
--cc=yupeng0921@gmail.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.