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

Alexandre DERUMIER aderumier at odiso.com
Wed Oct 1 17:55:03 CEST 2014


Maybe it could be possible to retrieve the "synced" property without event,
with some hack ? (through classic qmp query)


static void coroutine_fn mirror_run(void *opaque)
{
    MirrorBlockJob *s = opaque;
    BlockDriverState *bs = s->common.bs;
    int64_t sector_num, end, sectors_per_chunk, length;
    uint64_t last_pause_ns;
    BlockDriverInfo bdi;
    char backing_filename[1024];
    int ret = 0;
    int n;

    if (block_job_is_cancelled(&s->common)) {
        goto immediate_exit;
    }

    s->common.len = bdrv_getlength(bs);
    if (s->common.len < 0) {
        ret = s->common.len;
        goto immediate_exit;
    } else if (s->common.len == 0) {
        /* Report BLOCK_JOB_READY and wait for complete. */
        block_job_event_ready(&s->common);
        s->synced = true;
        while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
            block_job_yield(&s->common);
        }
        s->common.cancelled = false;
        goto immediate_exit;
    }



Currently, we send block-job-complete,

when 

my $stats = vm_mon_cmd($vmid, "query-block-jobs");
last if ($stat->{len} == $stat->{offset});

maybe it's not enough, 

something like $stats->{synced} could be better.


----- 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 
_______________________________________________ 
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