Received: from eggs.gnu.org ([2001:4830:134:3::10]:33891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya383-0002aV-DC for qemu-devel@nongnu.org; Mon, 23 Mar 2015 10:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya37x-0000H8-LT for qemu-devel@nongnu.org; Mon, 23 Mar 2015 10:14:55 -0400 Date: Mon, 23 Mar 2015 14:14:43 +0000 From: Stefan Hajnoczi Message-ID: <20150323141443.GJ9268@stefanha-thinkpad.redhat.com> References: <1427085970-23823-1-git-send-email-famz@redhat.com> <1427085970-23823-2-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="va4/JQ6j8/8uipEp" Content-Disposition: inline In-Reply-To: <1427085970-23823-2-git-send-email-famz@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: Fam Zheng Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-stable@nongnu.org --va4/JQ6j8/8uipEp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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(BlockDr= iverState *bs, > bytes =3D ROUND_UP(bytes, align); > } > =20 > + if (use_local_qiov) { > + /* Local buffer may have non-zero data. */ > + flags &=3D ~BDRV_REQ_ZERO_WRITE; > + } > ret =3D 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(BlockDriver= State *bs, > int64_t sector_num, int nb_sectors, > BdrvRequestFlags flags) > { > + int ret; > + > trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors, flags); > =20 > - if (!(bs->open_flags & BDRV_O_UNMAP)) { > - flags &=3D ~BDRV_REQ_MAY_UNMAP; > - } Why is it okay to drop this when the request is aligned? > + if (bdrv_req_is_aligned(bs, sector_num << BDRV_SECTOR_BITS, > + nb_sectors << BDRV_SECTOR_BITS)) { > + ret =3D bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL, > + BDRV_REQ_ZERO_WRITE | flags); > + } else { --va4/JQ6j8/8uipEp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVEB/TAAoJEJykq7OBq3PINNYIAKq1UwalnoCyAhqpOcAEEIkI 5NoCyEG+UDDlESFsc7mfS9ZxLqw7kHoM3Lol8Ys1FgYm8/hyBa8dRIAauhvtznOG 6wJHzIZhm4zcLLq654X4vnfxzR6wWYYJrBfYoSQnBUay2QlYDuNoQjIzyQZBTn76 y547TvszYAv//r2Dthxu74MLdPdKnbxt7tXSF1Vg1Ry0o6gXCNQjVIfc1iwQceiq 1C488lsILE9a4Ow0PFNA5oQqP9iEOx38eeGflxO6WHOIFsJCmykOiN2Uwd2Zb/mI YR7/wyONd4NJIii60KC8w98T4NOPV7Pl4Z1zCKl2NfsHQFXLAYYk56GbiaJAzh8= =OByb -----END PGP SIGNATURE----- --va4/JQ6j8/8uipEp--