qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF
@ 2014-12-10 15:47 Jun Li
  2014-12-10 21:48 ` Josh Durgin
  0 siblings, 1 reply; 3+ messages in thread
From: Jun Li @ 2014-12-10 15:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, famz, juli, stefanha, josh.durgin, Jun Li

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 <junmuzi@gmail.com>
---
 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);
 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF
  2014-12-10 15:47 [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF Jun Li
@ 2014-12-10 21:48 ` Josh Durgin
  2014-12-11  3:20   ` Jun Li
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Durgin @ 2014-12-10 21:48 UTC (permalink / raw)
  To: Jun Li, qemu-devel; +Cc: kwolf, juli, famz, stefanha

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 <junmuzi@gmail.com>
> ---
>   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.

Josh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF
  2014-12-10 21:48 ` Josh Durgin
@ 2014-12-11  3:20   ` Jun Li
  0 siblings, 0 replies; 3+ messages in thread
From: Jun Li @ 2014-12-11  3:20 UTC (permalink / raw)
  To: Josh Durgin; +Cc: kwolf, juli, famz, qemu-devel, stefanha

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 <junmuzi@gmail.com>
> >---
> >  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-11  3:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 15:47 [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF Jun Li
2014-12-10 21:48 ` Josh Durgin
2014-12-11  3:20   ` Jun Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).