[pve-devel] possible problem with drive-mirror and block-job-completed

Alexandre DERUMIER aderumier at odiso.com
Wed Oct 1 16:32:04 CEST 2014


to be more exact, the event is BLOCK_JOB_READY


qapi/block-core.json

##
# @block-job-complete:
#
# Manually trigger completion of an active background block operation.  This
# is supported for drive mirroring, where it also switches the device to
# write to the target path only.  The ability to complete is signaled with
# a BLOCK_JOB_READY event.
#
# This command completes an active background block operation synchronously.
# The ordering of this command's return with the BLOCK_JOB_COMPLETED event
# is not defined.  Note that if an I/O error occurs during the processing of
# this command: 1) the command itself will fail; 2) the error will be processed
# according to the rerror/werror arguments that were specified when starting
# the operation.
#
# A cancelled or paused job cannot be completed.
#
# @device: the device name
#                          
# Returns: Nothing on success
#          If no background operation is active on this device, DeviceNotActive
#
# Since: 1.3
##


##
# @BLOCK_JOB_READY
#
# Emitted when a block job is ready to complete
#
# @type: job type
#
# @device: device name
#
# @len: maximum progress value
#
# @offset: current progress value. On success this is equal to len.
#          On failure this is less than len
#
# @speed: rate limit, bytes per second
#
# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR
# event
#
# Since: 1.3
##
{ 'event': 'BLOCK_JOB_READY',
  'data': { 'type'  : 'BlockJobType',
            'device': 'str',
            'len'   : 'int',
            'offset': 'int',
            'speed' : 'int' } }



Note that we have a workaround in QemuServer.pm, pausing the vm.

But we don't use it actually ($maxwait is not defined)
I dont remember exactly why we don't use it



               last if ($stat->{len} == $stat->{offset});
                if ($old_len == $stat->{offset}) {

                    if ($maxwait && $count > $maxwait) {
                    # if writes to disk occurs the disk needs to be freezed
                    # to be able to complete the migration
                        vm_suspend($vmid,1);
                        $count = 0;
                        $frozen = 1;
                    } else {
                        $count++ unless $frozen;
                    }
                } elsif ($frozen) {
                    vm_resume($vmid,1);
                    $count = 0;
                }
                $old_len = $stat->{offset};
                sleep 1;
            }




----- Mail original ----- 

De: "Alexandre DERUMIER" <aderumier at odiso.com> 
À: pve-devel at pve.proxmox.com 
Envoyé: Mercredi 1 Octobre 2014 16:09:40 
Objet: [pve-devel] possible problem with drive-mirror and block-job-completed 

Hi, 
Bug report here: 

http://forum.proxmox.com/threads/19733-storage-migration-virtio-failed?p=101317#post101317 

Rbd -> rbd drive mirror. 




Currently, we are using qmp block-job-complete just after drive-mirror, 

but block-job-complete need to be sure that drives are correctly sync 

static void mirror_complete(BlockJob *job, Error **errp) 
{ 
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); 
Error *local_err = NULL; 
int ret; 

ret = bdrv_open_backing_file(s->target, NULL, &local_err); 
if (ret < 0) { 
error_propagate(errp, local_err); 
return; 
} 
if (!s->synced) { 

------------------------> HANG HERE <-------------------------------- 

error_set(errp, QERR_BLOCK_JOB_NOT_READY, job->bs->device_name); 
return; 
} 

/* check the target bs is not blocked and block all operations on it */ 
if (s->replaces) { 
s->to_replace = check_to_replace_node(s->replaces, &local_err); 
if (!s->to_replace) { 
error_propagate(errp, local_err); 
return; 
} 

error_setg(&s->replace_blocker, 
"block device is in use by block-job-complete"); 
bdrv_op_block_all(s->to_replace, s->replace_blocker); 
bdrv_ref(s->to_replace); 
} 

s->should_complete = true; 
block_job_resume(job); 
} 


>From qemu doc: 

a event is sent when disk are sync 
" 
* MIRROR_STATE_CHANGE: new event, triggered every time the 
block-job-complete becomes available/unavailable. Contains the device 
name (like device: 'ide0-hd0'), and the state (synced: true/false). 
" 

So, the good way is to get the event and do the block-job-complete when we receive it. 



Now, I really don't known how to implemented event manage that with current proxmox code. 
_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 



More information about the pve-devel mailing list