All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: no-reply@sashiko.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 09:31:15 +0100	[thread overview]
Message-ID: <c9f695eb-e356-4036-9eca-2d3b7f44d7ac@virtuozzo.com> (raw)
In-Reply-To: <010701a1c47e2aee-6f86a867-6158-4994-9845-2e83ccfdfdee-000000@eu-central-1.amazonses.com>

>> @@ -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?
The leak only happens in a narrow window: the data write to the new cluster
succeeds, but the overwrite of the already allocated L2 page then fails with
ENOSPC. Once the filesystem is really full, the data write fails first 
and its cluster
is freed through FREE_ALLOCATED_CLU, so the leak stops by itself. 
Freeing the
cluster before the request is resubmitted is unsafe, because the failed 
L2 write
may have partially reached the disk, and two guest offsets could then 
share the
cluster. A leaked cluster leaves the image consistent and check reclaims it.
Leaking a few clusters is better than failing the guest write with EIO, 
which is
what happened before this patch.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-10  8:32 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
2026-11-10  8:31     ` Alexander Ivanov [this message]
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=c9f695eb-e356-4036-9eca-2d3b7f44d7ac@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=no-reply@sashiko.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 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.