OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
	andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v12 10/12] dm-qcow2: retry R1/R2 writeback that failed with ENOSPC
Date: Tue, 10 Nov 2026 08:06:05 +0000	[thread overview]
Message-ID: <010701a1c47e2aee-6f86a867-6158-4994-9845-2e83ccfdfdee-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261110075140.1475607-11-alexander.ivanov@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dm-qcow2: ENOSPC retry of failed L1/L2 writeback leaks a data cluster per retry
--

commit 647503fd94be077d5a1fad60c25b0ae7127ab8cf
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>

dm-qcow2: retry R1/R2 writeback that failed with ENOSPC

This commit redirties an R1/R2 metadata page whose writeback failed with
-ENOSPC, so the slow writeback timer retries it. It also passes the errno
of a failed metadata write through complete_metadata_writeback() instead of
turning it into -EIO. As a result, a data request that depends on a failed
L1/L2 write can now end with BLK_STS_NOSPC and be delayed and resubmitted.

> 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

[ ... ]

> @@ -3869,9 +3871,9 @@ static int complete_metadata_writeback(struct qcow2 *qcow2)
>  		md = qio->ext->md;
>  		qvec = qio->data;
>  		ret = qio->ret;
> -		if (unlikely(ret != PAGE_SIZE))
> +		if (unlikely(ret >= 0 && ret != PAGE_SIZE))
>  			ret = -EIO;
> -		else
> +		else if (ret == PAGE_SIZE)
>  			ret = fsync_ret;
>  
>  		do_md_page_write_complete(ret, qcow2, md);

[Severity: Medium]
Can this change make the cluster leak repeat? With the errno now passed
through, a failed L2 write ends up as -ENOSPC instead of -EIO:

complete_metadata_writeback()
  do_md_page_write_complete(-ENOSPC, ...)
    wbd->ret = ret
    complete_wbd()
      list_for_each_entry(qio, &end_list, link) {
          if (qio->ext)
              qio->ext->cleanup_mask &= ~FREE_ALLOCATED_CLU;
      }
  end_qios(&end_list, errno_to_blk_status(ret))
    qrq_endio()
      if (unlikely(bi_status == BLK_STS_NOSPC)) {
          if (qcow2_try_delay_enospc(tgt, qrq, qio))
              return;
      }

complete_wbd() deliberately does not free the newly allocated data cluster
when an L1/L2 writeback fails. Before this patch the request ended once with
-EIO and was not retried, so this leak happened at most once per request.

Now qrq_endio() delays the request and resubmits it. Each resubmission
allocates a new cluster. If the L2 write fails with -ENOSPC again, that
cluster is leaked as well, and this repeats for as long as ENOSPC persists.
The leaked clusters stay counted in the refcounts, and the image file keeps
growing on an underlying filesystem that is already full.

The commit message acknowledges this ("a request whose L2 write keeps failing
with ENOSPC leaks one data cluster on every resubmission, until the space is
back"), but the patch does not bound or fix it. Could the cluster be freed
(or the leak otherwise limited) before the request is resubmitted on
BLK_STS_NOSPC?

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261110075140.1475607-1-alexander.ivanov@virtuozzo.com?part=10

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

  reply	other threads:[~2026-11-10  8:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  7:51 [Devel] [PATCH hci-8.1 v12 00/12] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 01/12] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-11-10  7:55   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 02/12] dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages Alexander Ivanov
2026-11-10  7:55   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 03/12] dm-qcow2: extend the file for a new refblock in allocate_cluster() Alexander Ivanov
2026-11-10  7:56   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 04/12] dm-qcow2: complete wbd before ending the data qio Alexander Ivanov
2026-11-10  7:58   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 05/12] dm-qcow2: flush lower md before clearing dirty bit on merge failure Alexander Ivanov
2026-11-10  7:58   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 06/12] dm-qcow2: keep the dirty bit of an image that needs check Alexander Ivanov
2026-11-10  7:59   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 07/12] dm-qcow2: flag the image for check if reftable relocation fails late Alexander Ivanov
2026-11-10  8:00   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 08/12] dm-qcow2: fail the L2 table allocation request on L1 writeback error Alexander Ivanov
2026-11-10  8:01   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 09/12] dm-qcow2: leak clusters allocated for a failed L1/L2 writeback Alexander Ivanov
2026-11-10  8:04   ` no-reply
2026-11-10  8:25     ` Alexander Ivanov
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 10/12] dm-qcow2: retry R1/R2 writeback that failed with ENOSPC Alexander Ivanov
2026-11-10  8:06   ` no-reply [this message]
2026-11-10  8:31     ` Alexander Ivanov
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 11/12] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-11-10  8:07   ` no-reply
2026-11-10  7:51 ` [Devel] [PATCH hci-8.1 v12 12/12] dm-qcow2: fix WARN in qrq_endio() on flush failing with ENOSPC Alexander Ivanov
2026-11-10  8:07   ` no-reply
2026-11-10  8:35     ` Alexander Ivanov
2026-11-10 11:42 ` [Devel] [PATCH hci-8.1 v12 00/12] dm-qcow2: truncate unused tail of image on suspend Konstantin Khorenko
2026-11-10 11:43 ` 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=010701a1c47e2aee-6f86a867-6158-4994-9845-2e83ccfdfdee-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox