qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] rbd: print a clear error message when write bey


From: Josh Durgin
Subject: Re: [Qemu-devel] [PATCH] rbd: print a clear error message when write beyond EOF
Date: Wed, 10 Dec 2014 13:48:12 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

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 <address@hidden>
---
  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]