From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwwJU-0004eu-88 for qemu-devel@nongnu.org; Fri, 05 Dec 2014 12:05:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwwJP-00069v-FE for qemu-devel@nongnu.org; Fri, 05 Dec 2014 12:05:04 -0500 Message-ID: <5481E5A5.5040505@redhat.com> Date: Fri, 05 Dec 2014 18:04:37 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1417796112-15141-1-git-send-email-ming.lei@canonical.com> <5481E566.8070108@redhat.com> In-Reply-To: <5481E566.8070108@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block: fix big write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , Ming Lei , qemu-devel@nongnu.org, Stefan Hajnoczi , Kevin Wolf Cc: Ming Lei , qemu-stable@nongnu.org On 05/12/2014 18:03, Max Reitz wrote: > On 2014-12-05 at 17:15, Ming Lei wrote: >> From: Ming Lei >> >> QEMU block should have supported to read/write at most >> 0x7fffff * 512 bytes, unfortunately INT_MAX is used to check >> bytes in both bdrv_co_do_writev() and bdrv_check_byte_request(), >> so cause write failure if nr_sectors is equal or more >> than 0x400000. >> >> There are still other INT_MAX usages in block.c, and they might >> need to change to UINT_MAX too in future, but at least >> this patch's change can make SCSI WRITE SAME 16 workable. >> >> Cc: qemu-stable@nongnu.org >> Signed-off-by: Ming Lei >> --- >> block.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/block.c b/block.c >> index a612594..ddc18c2 100644 >> --- a/block.c >> +++ b/block.c >> @@ -2607,7 +2607,7 @@ static int >> bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, >> { >> int64_t len; >> - if (size > INT_MAX) { >> + if (size > UINT_MAX) { >> return -EIO; >> } >> @@ -3420,7 +3420,7 @@ static int coroutine_fn >> bdrv_co_do_writev(BlockDriverState *bs, >> int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, >> BdrvRequestFlags flags) >> { >> - if (nb_sectors < 0 || nb_sectors > (INT_MAX >> BDRV_SECTOR_BITS)) { >> + if (nb_sectors < 0 || nb_sectors > (UINT_MAX >> BDRV_SECTOR_BITS)) { >> return -EINVAL; >> } >> > > This is intentional so a byte length can be stored in an integer. This > is a pretty bad design decision, but we have to live with it until we > really fix the block layer regarding the type lengths are stored in. No problem, let's fix SCSI (the correct way, which is not the patch posted so far :)). Paolo