Thank you for your detailed reply.
Now, I am modifying the code to change the reading and writing processes, 
My purpose is that after it send the writing requestion and the writing 
requestion 
is not come back, then it send the reading requestion. 
I think this way will be more reading and writing pressure than before. 

I don't know why in mirror_iteration, each iteration send the number of data is 
continuous dirty data, the maximum is the size of free_buffer(default is 10M),
I think the way will reduce the performance of IO,because the mirror will wait 
long 
time to send next reading requestion. I think each iteration send the number of 
data
should base on the granularity ,we can set the granularity  is 1M. This way may 
be 
let the reading  and writing is parallel. 




zhang min

From: Stefan Hajnoczi
Date: 2014-01-14 13:57
To: Fam Zheng
CC: rudy...@163.com; rudy.zhangmin; qemu-devel
Subject: Re: [Qemu-devel] Question about drive mirror
On Tue, Jan 14, 2014 at 09:41:41AM +0800, Fam Zheng wrote:
> On Mon, 01/13 23:44, rudy...@163.com wrote:
> > I tested the capability of drive mirror, I found the IO is low. Then I read 
> > the code, 
> > The code mirror_run() will call mirror_iteration() to read the size of 
> > buffer data  
> > from source storage, when the read callback ,and then in 
> > mirror_read_complete () 
> > write the data to the target storage, It is serial. 

And it also uses throttling to avoid impacting the guest too much.  It's
considered a background job, i.e. not trying to saturate storage
bandwidth.

That said, improving performance while keeping I/O isolated from higher
priority guest I/O can be good.

> > Now, I hope when it is writing the data to target storage ,we can send the 
> > request 
> > of reading data from source storage. Because of  using  coroutine to do it 
> > ,there is 
> > some troubles to achieve it. why not use Multi-thread? 
> > Some one can give me some idea?

It can be parallelized by splitting the code into two separate loops:

A reader coroutine that reads data from the source device and places
buffers in a queue.

A writer coroutine that takes buffers from the queue and writes data to
the target device.

(In fact there could be multiple readers and writers.)

Stefan

Reply via email to