From: no-reply@sashiko.virtuozzo.com
To: andrey.zhadchenko@virtuozzo.com,
Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v9 09/10] dm-qcow2: flag the image for check after a reverted L1/L2 writeback
Date: Wed, 28 Oct 2026 15:19:30 +0000 [thread overview]
Message-ID: <010701a183184cc2-36f3ab2b-1d9f-4720-9419-033e3d93b05c-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261028150645.3222391-10-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dm-qcow2: revert_l_entries_update() skips spin_lock() on the WARN continue path
--
commit 088bd04e227a501d72562ed2321e2ca2f75e3df0
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
dm-qcow2: flag the image for check after a reverted L1/L2 writeback
This patch adds an MD_LX_REVERTED page status that is set when an L1/L2
writeback fails and the page is reverted. The flag is cleared on the next
successful writeback. On md writeback flush, a page that is still marked
sets a new lx_writeback_error flag. That flag is reported by get_errors and
included in qcow2_wants_check().
Link: https://virtuozzo.atlassian.net/browse/VSTOR-148171
> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
> --- a/drivers/md/dm-qcow2-map.c
> +++ b/drivers/md/dm-qcow2-map.c
[ ... ]
> @@ -1362,6 +1362,7 @@ static void revert_l_entries_update(struct qcow2 *qcow2, struct wb_desc *wbd)
> if (cleared)
> continue; /* no cluster was allocated */
>
> + wbd->md->status |= MD_LX_REVERTED;
> spin_unlock(&qcow2->md_pages_lock);
> pos &= ~LX_REFCOUNT_EXACTLY_ONE;
>
[Severity: Medium]
Can the lock be left unheld on the WARN path in this loop?
The loop body in revert_l_entries_update() continues like this after the
quoted lines:
ret = qcow2_handle_r1r2_maps(qcow2, pos, NULL, &r1, &r2, false);
if (WARN_ON_ONCE(ret <= 0))
continue;
mark_cluster_unused(qcow2, r2.md, r2.index_in_page, pos);
spin_lock(&qcow2->md_pages_lock);
The lock is dropped just above, but the continue skips the closing
spin_lock(). The next iteration then reads wbd->md->page, calls
set_u64_to_be_page(), and executes the new store to wbd->md->status
without md_pages_lock. It may also reach spin_unlock() a second time on a
lock that is not held.
The caller does not expect this:
complete_wbd() {
spin_lock_irqsave(&qcow2->md_pages_lock, flags);
revert_l_entries_update(qcow2, wbd);
clear_writeback_status(qcow2, wbd->md, wbd->ret,
&wait_list, &end_list);
spin_unlock_irqrestore(&qcow2->md_pages_lock, flags);
...
}
If the lock is not re-acquired, clear_writeback_status() and
spin_unlock_irqrestore() run on a lock that is no longer owned. That can
corrupt the spinlock and IRQ state, and it races with other users of
md_pages_lock.
qcow2_handle_r1r2_maps() can return a value <= 0 in several cases. It
returns -ENOENT when the R1 entry is zero, and -EIO on an invalid R1 entry
or when the refcount sanity check fails (entry > 1 with no snapshots). It
returns 0 when an R1/R2 page is not cached.
The comment says R1/R2 "should be cached", but I could not show that none
of these returns can happen. For example, a failed md read or a failed
relocate_refcount_table() can erase a cached page.
The unlock/relock imbalance is not new, but this patch adds an
unlocked-path store to md->status in the same loop. The later patch in the
series, "dm-qcow2: truncate unused tail of image on suspend", does not
change this handling.
Could the WARN path re-take md_pages_lock before continuing, or could the
loop be restructured so the lock state is the same on every path?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261028150645.3222391-1-alexander.ivanov@virtuozzo.com?part=9
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-28 15:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:06 [Devel] [PATCH hci-8.1 v9 00/10] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 01/10] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-10-28 15:12 ` no-reply
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 02/10] dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages Alexander Ivanov
2026-10-28 15:10 ` no-reply
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 03/10] dm-qcow2: extend the file for a new refblock in allocate_cluster() Alexander Ivanov
2026-10-28 15:11 ` no-reply
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 04/10] dm-qcow2: complete wbd before ending the data qio Alexander Ivanov
2026-10-28 15:14 ` no-reply
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 05/10] dm-qcow2: flush lower metadata before clearing its dirty bit on merge failure Alexander Ivanov
2026-10-28 15:14 ` no-reply
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 06/10] dm-qcow2: keep the dirty bit of an image that needs check Alexander Ivanov
2026-10-28 15:16 ` no-reply
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 07/10] dm-qcow2: fix md page cleanup on failed reftable relocation Alexander Ivanov
2026-10-28 15:16 ` no-reply
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 08/10] dm-qcow2: flag the image for check if reftable relocation fails late Alexander Ivanov
2026-10-28 15:17 ` no-reply
2026-10-29 7:18 ` Alexander Ivanov
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 09/10] dm-qcow2: flag the image for check after a reverted L1/L2 writeback Alexander Ivanov
2026-10-28 15:19 ` no-reply [this message]
2026-10-29 7:27 ` Alexander Ivanov
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-28 15:06 ` [Devel] [PATCH hci-8.1 v9 10/10] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-28 15:21 ` no-reply
2026-11-03 17:50 ` Konstantin Khorenko
2026-10-29 10:55 ` [Devel] [PATCH hci-8.1 v9 00/10] " Andrey Zhadchenko
2026-11-03 17:50 ` Konstantin Khorenko
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=010701a183184cc2-36f3ab2b-1d9f-4720-9419-033e3d93b05c-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
/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.