Received: from eggs.gnu.org ([208.118.235.92]:41733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF6Ge-0001CU-IQ for qemu-devel@nongnu.org; Mon, 11 Mar 2013 13:12:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF6GW-0005Jz-Pj for qemu-devel@nongnu.org; Mon, 11 Mar 2013 13:12:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF6GW-0005Ja-I9 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 13:12:00 -0400 Date: Mon, 11 Mar 2013 18:11:55 +0100 From: Stefan Hajnoczi Message-ID: <20130311171155.GA12538@stefanha-thinkpad.redhat.com> References: <1362867748-30528-1-git-send-email-stefanha@redhat.com> <24E144B8C0207547AD09C467A8259F7557B300E4@lisa.maurer-it.com> <24E144B8C0207547AD09C467A8259F7557B30310@lisa.maurer-it.com> <24E144B8C0207547AD09C467A8259F7557B30D69@lisa.maurer-it.com> <20130311142734.GA7611@stefanha-thinkpad.redhat.com> <24E144B8C0207547AD09C467A8259F7557B3135B@lisa.maurer-it.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24E144B8C0207547AD09C467A8259F7557B3135B@lisa.maurer-it.com> Subject: Re: [Qemu-devel] [RFC 0/8] block: Live backup prototype List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dietmar Maurer Cc: Kevin Wolf , Stefan Hajnoczi , "qemu-devel@nongnu.org" , Markus Armbruster On Mon, Mar 11, 2013 at 03:00:38PM +0000, Dietmar Maurer wrote: > > > I can see space reduction up to 4% using this feature. Considering the > > > fact that it comes at no cost, it would be stupid to remove it. > > > > Okay, looks like it's useful but not a huge win. > > > > In the NBD approach pipelining writes (or discards) ought to make 4 KB zero > > blocks usable without overhead. > > But you need to re-asemble 64KB block from that - I guess that is the difficult part here? That's not hard. It can be added to the RFC code I posted. Here is an outline. Say there is a 64 KB block with 2 zero regions: 0123456789abcdef XXXXzzXXXXXzXXXX X - populated 4 KB block z - zero 4 KB block Send 3 writes: NBD_CMD_WRITE from=0 length=16 KB ... NBD_CMD_WRITE from=24 KB length=20 KB ... NBD_CMD_WRITE from=48 KB length=16 KB ... The NBD server can pack this back into an extent's blockinfo: def add_cluster(cluster, blockinfo, blocks): ...the code to add a cluster to the current extent... def prepare_for_blockinfo_update(cluster): # We're still filling in the same cluster, all is fine if cur_cluster == cluster: return # Flush out last cluster, which is now complete add_cluster(cur_cluster, cur_blockinfo, cur_blocks) # Prepare to work on a new cluster cur_cluster = cluster cur_blockinfo = dev_id << 32 | cluster cur_blocks = [] def write(from, size, data): cluster = from / VMA_CLUSTER_SIZE prepare_for_blockinfo_update(cluster) cur_blockinfo |= build_blockinfo_mask(from, size) # bit manipulation cur_blocks.append(data) In other words, the NBD server assembles the writes into a blockinfo and list of blocks. Stefan