[Devel] [PATCH VZ9] dm-qcow2: allow specifying depth to merge intermediate images
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Wed Sep 17 13:59:34 MSK 2025
On 9/17/25 07:53, Pavel Tikhomirov wrote:
>> @@ -152,25 +151,35 @@ static int qcow2_break_l1cow(struct qcow2_target
>> *tgt)
>> static void set_backward_merge_in_process(struct qcow2_target *tgt,
>> struct qcow2 *qcow2, bool set)
>> {
>> + struct qcow2 *top = tgt->top;
>> LIST_HEAD(list);
>> + /*
>> + * There are no writes if it is not the top qcow2 image.
>> + * so we do not need to stop and flush requests when setting
>> + */
>> + if (qcow2 != top && set) {
>> + qcow2->backward_merge_in_process = set;
>> + return;
>> + }
>> +
>
> Below hunks in this function feel excess to me. Why replace s/qcow2/top/
> where qcow2 == top was just explicitly checked?
I just didn't like to set pause_submitting_qios on non-top delta as it
is completely pointless. But maybe you are right.
>
> In that light, I would've removed top variable all together and used
> "qcow2 != tgt->top" directly, to simplify the code.
>
>> /*
>> * To avoid race between allocations and COWS
>> * we completely stop queueing qios and wait
>> * for pending qios. Lock is for visability.
>> */
>> - spin_lock_irq(&qcow2->deferred_lock);
>> - qcow2->pause_submitting_qios = true;
>> - spin_unlock_irq(&qcow2->deferred_lock);
>> + spin_lock_irq(&top->deferred_lock);
>> + top->pause_submitting_qios = true;
>> + spin_unlock_irq(&top->deferred_lock);
>> qcow2_inflight_ref_switch(tgt);
>> /* queue is stopped */
>> - spin_lock_irq(&qcow2->deferred_lock);
>> + spin_lock_irq(&top->deferred_lock);
>> WARN_ON_ONCE(qcow2->backward_merge_in_process == set);
>> qcow2->backward_merge_in_process = set;
>> - qcow2->pause_submitting_qios = false;
>> - list_splice_init(&qcow2->paused_qios, &list);
>> - spin_unlock_irq(&qcow2->deferred_lock);
>> + top->pause_submitting_qios = false;
>> + list_splice_init(&top->paused_qios, &list);
>> + spin_unlock_irq(&top->deferred_lock);
>> qcow2_submit_embedded_qios(tgt, &list);
>> }
More information about the Devel
mailing list