From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YstYk-0003kP-2N for qemu-devel@nongnu.org; Thu, 14 May 2015 09:52:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YstYj-0006BG-6H for qemu-devel@nongnu.org; Thu, 14 May 2015 09:52:21 -0400 Date: Thu, 14 May 2015 21:52:08 +0800 From: Fam Zheng Message-ID: <20150514135208.GC22867@ad.nay.redhat.com> References: <1431431315-32079-1-git-send-email-famz@redhat.com> <1431431315-32079-2-git-send-email-famz@redhat.com> <55547956.1050701@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55547956.1050701@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 1/6] mirror: Do zero write on target if sectors not allocated List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , wangxiaolong@ucloud.cn On Thu, 05/14 12:30, Paolo Bonzini wrote: > > > On 12/05/2015 13:48, Fam Zheng wrote: > > + if (!bdrv_is_allocated_above(source, NULL, sector_num, > > + nb_sectors, &pnum)) { > > + op->nb_sectors = pnum; > > + if (s->source_may_unmap) { > > Can you avoid this check by introducing bdrv_get_block_status_above? Then: > > - if BDRV_ZERO, you use bdrv_aio_write_zeroes > > - if BDRV_ALLOCATED, you use bdrv_aio_readv > > - else you use bdrv_aio_discard OK, that's better. > > > + /* > > + * Source unallocated sectors have zero data. We can't discard > > + * target even if s->target_may_unmap, because the discard > > + * granularity may be different. > > + */ > > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > > + s->target_may_unmap ? BDRV_REQ_MAY_UNMAP : 0, > > You can set the flag unconditionally. But it's probably better to make > this a drive-mirror argument instead of checking the target's > BlockDriverInfo. OK, I'll add a flag. Fam