Received: from eggs.gnu.org ([2001:4830:134:3::10]:39199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnlsX-0006KJ-5I for qemu-devel@nongnu.org; Mon, 10 Nov 2014 05:07:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnlsR-0002xB-0D for qemu-devel@nongnu.org; Mon, 10 Nov 2014 05:07:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnlsQ-0002wE-Of for qemu-devel@nongnu.org; Mon, 10 Nov 2014 05:07:14 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAAA7D36022922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 10 Nov 2014 05:07:14 -0500 From: Markus Armbruster References: <1415603264-21497-1-git-send-email-famz@redhat.com> <87h9y7316p.fsf@blackfin.pond.sub.org> <20141110090210.GA2588@fam-t430.nay.redhat.com> Date: Mon, 10 Nov 2014 11:07:11 +0100 In-Reply-To: <20141110090210.GA2588@fam-t430.nay.redhat.com> (Fam Zheng's message of "Mon, 10 Nov 2014 17:02:10 +0800") Message-ID: <87oasfv06o.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] block: Fix max nb_sectors in bdrv_make_zero List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Fam Zheng writes: > On Mon, 11/10 09:33, Markus Armbruster wrote: >> Fam Zheng writes: >> >> > In bdrv_rw_co we report -EINVAL for nb_sectors > INT_MAX / >> > BDRV_SECTOR_SIZE, so a caller shouldn't exceed it. > > I noticed this while testing unmap / zero write with scsi_debug: > > # dd if=/dev/zero of=/tmp/a bs=1M count=32 > # modprobe scsi_debug dev_size_mb=1024 lbpu=1 > # qemu-img convert -t none /tmp/a /dev/sde > qemu-img: error writing zeroes at sector 0: Invalid argument > >> >> It's not obvious to me why we do that there. iovec member iov_len is >> size_t, not int. > > Deeper in the call stack we use int bytes everywhere: > > static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, > int64_t offset, unsigned int bytes, QEMUIOVector *qiov, > BdrvRequestFlags flags); > static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, > int64_t offset, unsigned int bytes, QEMUIOVector *qiov, > BdrvRequestFlags flags); > > static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs, > BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, > int64_t align, QEMUIOVector *qiov, int flags) > > So this is a easier way to fix the specific bug :) Okay, that's enough for my R-by. Aside: using bytes makes sense, using int not so much. Reviewed-by: Markus Armbruster [...]