rbd: print a clear error message when write beyond EOF
PATCH 1/1 rbd: print a clear error message when write beyond EOF
Currently, as rbd driver do not support dynamic growth when write beyond EOF, so just print a clear error message.
--- block/rbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
block/rbd.c +14 -0
@@ -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 ); }
Signature · 1 line
1.9.3
Quoted 24 lines · 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 <[email protected]>--- block/rbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)block/rbd.c +7
-0@@ -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);
block/rbd.c static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs, · line 712
Quoted 10 lines
block/rbd.c +7
-0+ +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
Quoted 32 lines · Josh Durgin
Quoted 31 lines · 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 <[email protected]>--- block/rbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)block/rbd.c +14
-0@@ -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,
Quoted 9 lines
block/rbd.c static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs, · line 712
Quoted 3 lines
block/rbd.c +0
-0RBD_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