OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>,
	khorenko@virtuozzo.com, alexander.ivanov@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v3 1/8] dm-qcow2: repeat md page lookup if it was inserted in parallel
Date: Fri, 13 Nov 2026 11:22:08 +0000	[thread overview]
Message-ID: <010701a1d4a4bbcc-e444eaba-129d-42bd-9ff8-4ad705659441-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261113111126.793039-2-andrey.zhadchenko@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dm-qcow2: message and comment misdescribe -EIO on second lookup
  miss
--

commit ac0961cf11bb91c58bc95e6d03ca39499fd6547e
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>

dm-qcow2: repeat md page lookup if it was inserted in parallel

This teaches __handle_md_page() to repeat the md page lookup once when submit_read_md_page() returns -EEXIST. -EEXIST means qcow2_llseek_hole() and the main kwork raced to insert the same md page.

> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
> index 32373114580e..58b95d7a955c 100644
> --- a/drivers/md/dm-qcow2-map.c
> +++ b/drivers/md/dm-qcow2-map.c
> @@ -1676,20 +1676,33 @@ static int submit_read_md_page(struct qcow2 *qcow2, struct qio **qio,
>  /*
>   * This may be called with @qio == NULL, in case of we are
>   * interesting in searching cached in memory md only.
> - * This is aimed to be called not only from main kwork
> - * for L1/L2 pages, so all callers looking for L1/L2
> - * must care about submit_read_md_page() may return EEXIST.
> + *
> + * submit_read_md_page() drops md_pages_lock, so the page may be
> + * inserted in parallel. Then it is looked up once more. It is not
> + * found again only if its read failed in the meantime, and then
> + * @qio fails too.
>   */
>  static int __handle_md_page(struct qcow2 *qcow2, u64 page_id,
>  			    struct qio **qio, struct md_page **ret_md)
>  {
> +	bool retried = false;
>  	struct md_page *md;
> +	int ret;
>  
>  	lockdep_assert_held(&qcow2->md_pages_lock);
> +again:
>  	md = qcow2_md_page_find_or_postpone(qcow2, page_id, qio);
>  	if (!md) {
> -		if (qio && *qio)
> -			return submit_read_md_page(qcow2, qio, page_id);
> +		if (qio && *qio) {
> +			ret = submit_read_md_page(qcow2, qio, page_id);
> +			if (unlikely(ret == -EEXIST)) {
> +				if (retried)
> +					return -EIO;
> +				retried = true;
> +				goto again;
> +			}
> +			return ret;
> +		}
>  		return 0;
>  	}
>  

[Severity: Low]
This isn't a bug, but does the code match what the comment and commit message say about a second lookup miss?

They say the second lookup misses only if the read failed and erased the page, and that the qio then fails with -EIO. The code does something else. After the retry lookup misses with *qio still set, it calls submit_read_md_page() again. That call allocates and inserts a fresh md page, queues the qio on it and issues a new read. So the qio is retried, not failed.

-EIO is returned only when the second submit_read_md_page() also returns -EEXIST, which means two insert races in a row. Could the comment and commit message describe that instead? Alternatively, the retry path could fail the qio directly when the second lookup misses.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261113111126.793039-1-andrey.zhadchenko@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-13 11:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 11:11 [Devel] [PATCH hci-8.1 v3 0/8] dm-qcow2: per-qio fast path Andrey Zhadchenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 1/8] dm-qcow2: repeat md page lookup if it was inserted in parallel Andrey Zhadchenko
2026-11-13 11:22   ` no-reply [this message]
2026-11-13 19:48   ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 2/8] dm-qcow2: prepare process_one_qio() for fastpath Andrey Zhadchenko
2026-11-13 11:26   ` no-reply
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 3/8] dm-qcow2: count fast path writes in parse_metadata() Andrey Zhadchenko
2026-11-13 11:27   ` no-reply
2026-11-13 19:48   ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 4/8] dm-qcow2: add per-qio work infrastructure Andrey Zhadchenko
2026-11-13 11:30   ` no-reply
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 5/8] dm-qcow2: implement per-qio fast processing Andrey Zhadchenko
2026-11-13 11:31   ` no-reply
2026-11-13 19:48   ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 6/8] dm-qcow2: add fast_path module parameter Andrey Zhadchenko
2026-11-13 11:31   ` no-reply
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 7/8] dm-qcow2: process fast path qios in per-cpu batches on a workqueue Andrey Zhadchenko
2026-11-13 11:33   ` no-reply
2026-11-13 19:48   ` Konstantin Khorenko
2026-11-13 11:11 ` [Devel] [PATCH hci-8.1 v3 8/8] dm-qcow2: declare DM_TARGET_NOWAIT Andrey Zhadchenko
2026-11-13 11:33   ` no-reply
2026-11-13 19:48 ` [Devel] [PATCH hci-8.1 v3 0/8] dm-qcow2: per-qio fast path 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=010701a1d4a4bbcc-e444eaba-129d-42bd-9ff8-4ad705659441-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 \
    --cc=khorenko@virtuozzo.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