Received: from eggs.gnu.org ([2001:4830:134:3::10]:58659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaDVW-0006rn-SV for qemu-devel@nongnu.org; Mon, 23 Mar 2015 21:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YaDVT-0001oA-MP for qemu-devel@nongnu.org; Mon, 23 Mar 2015 21:19:50 -0400 Date: Tue, 24 Mar 2015 09:19:42 +0800 From: Fam Zheng Message-ID: <20150324011942.GC3955@ad.nay.redhat.com> References: <1427085970-23823-1-git-send-email-famz@redhat.com> <1427085970-23823-2-git-send-email-famz@redhat.com> <20150323141443.GJ9268@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150323141443.GJ9268@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] block: Fix unaligned zero write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-stable@nongnu.org On Mon, 03/23 14:14, Stefan Hajnoczi wrote: > On Mon, Mar 23, 2015 at 12:46:09PM +0800, Fam Zheng wrote: > > @@ -3435,6 +3446,10 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, > > bytes = ROUND_UP(bytes, align); > > } > > > > + if (use_local_qiov) { > > + /* Local buffer may have non-zero data. */ > > + flags &= ~BDRV_REQ_ZERO_WRITE; > > + } > > ret = bdrv_aligned_pwritev(bs, &req, offset, bytes, > > use_local_qiov ? &local_qiov : qiov, > > flags); > > @@ -3475,14 +3490,32 @@ int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, > > BdrvRequestFlags flags) > > { > > + int ret; > > + > > trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors, flags); > > > > - if (!(bs->open_flags & BDRV_O_UNMAP)) { > > - flags &= ~BDRV_REQ_MAY_UNMAP; > > - } > > Why is it okay to drop this when the request is aligned? It's not. I will restore it. > > > + if (bdrv_req_is_aligned(bs, sector_num << BDRV_SECTOR_BITS, > > + nb_sectors << BDRV_SECTOR_BITS)) { > > + ret = bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL, > > + BDRV_REQ_ZERO_WRITE | flags); > > + } else {