From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyuJR-0006VA-T8 for qemu-devel@nongnu.org; Wed, 10 Dec 2014 22:21:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyuJI-0004AD-OA for qemu-devel@nongnu.org; Wed, 10 Dec 2014 22:21:09 -0500 Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:40232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyuJI-00049i-Gn for qemu-devel@nongnu.org; Wed, 10 Dec 2014 22:21:00 -0500 Received: by mail-pd0-f170.google.com with SMTP id v10so4075250pde.15 for ; Wed, 10 Dec 2014 19:20:59 -0800 (PST) Date: Thu, 11 Dec 2014 11:20:51 +0800 From: Jun Li Message-ID: <20141211032051.GA3100@localhost.localdomain> References: <1418226457-22239-1-git-send-email-junmuzi@gmail.com> <5488BF9C.7080402@inktank.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5488BF9C.7080402@inktank.com> Subject: Re: [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Josh Durgin Cc: kwolf@redhat.com, juli@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Wed, 12/10 13:48, Josh Durgin wrote: > On 12/10/2014 07:47 AM, Jun Li wrote: > >Currently, as rbd driver do not support dynamic growth when write beyond EOF, > >so just print a clear error message. > > > >Signed-off-by: Jun Li > >--- > > block/rbd.c | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > >diff --git a/block/rbd.c b/block/rbd.c > >index 5b5a64a..65b01f0 100644 > >--- a/block/rbd.c > >+++ b/block/rbd.c > >@@ -693,6 +693,20 @@ static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs, > > BlockCompletionFunc *cb, > > void *opaque) > > { > >+ BDRVRBDState *s = bs->opaque; > >+ uint64_t total_size; > >+ int64_t off, size; > >+ > >+ off = sector_num * BDRV_SECTOR_SIZE; > >+ size = nb_sectors * BDRV_SECTOR_SIZE; > >+ rbd_get_size(s->image, &total_size); > >+ > >+ if (off + size > total_size) { > >+ fprintf(stdout, "Image formats that grow on demand" > >+ "are not supported on rbd.\n"); > >+ return NULL; > >+ } > >+ > > return rbd_start_aio(bs, sector_num, qiov, nb_sectors, cb, opaque, > > RBD_AIO_WRITE); > > } > > > > This is one of the checks librbd does itself, so we could just look for > an EINVAL from rbd_aio_{read,write,discard} in rbd_start_aio() > to avoid duplicating the check. An out of bounds i/o is the only way > EINVAL can be returned from these functions in librbd. > Ok, thx. Seems just need to look for an EINVAL from rbd_aio_write is ok. No need to detect for rbd_aio_{read,discard,flush_wrapper}. I will submit a new version. Regards, Jun Li