From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2x0h-0000JU-4S for qemu-devel@nongnu.org; Tue, 14 Jan 2014 00:58:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2x0Y-0008Bd-MT for qemu-devel@nongnu.org; Tue, 14 Jan 2014 00:57:59 -0500 Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]:38032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2x0Y-0008BV-F8 for qemu-devel@nongnu.org; Tue, 14 Jan 2014 00:57:50 -0500 Received: by mail-ea0-f170.google.com with SMTP id k10so3724894eaj.1 for ; Mon, 13 Jan 2014 21:57:49 -0800 (PST) Date: Tue, 14 Jan 2014 13:57:36 +0800 From: Stefan Hajnoczi Message-ID: <20140114055736.GD14979@stefanha-thinkpad.redhat.com> References: <2014011323440947092624@163.com> <20140114014141.GA1377@T430.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140114014141.GA1377@T430.nay.redhat.com> Subject: Re: [Qemu-devel] Question about drive mirror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: "rudyfly@163.com" , "rudy.zhangmin" , qemu-devel On Tue, Jan 14, 2014 at 09:41:41AM +0800, Fam Zheng wrote: > On Mon, 01/13 23:44, rudyfly@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