diff mbox

[v2] rbd: print a clear error message when write beyond EOF

Message ID 1418279107-10339-1-git-send-email-junmuzi@gmail.com
State New
Headers show

Commit Message

lijun Dec. 11, 2014, 6:25 a.m. UTC
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>
---
v2:
Just use rbd_aio_write to realize error detection.
---
 block/rbd.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kevin Wolf Dec. 11, 2014, 9:12 a.m. UTC | #1
Am 11.12.2014 um 07:25 hat Jun Li geschrieben:
> 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>
> ---
> v2:
> Just use rbd_aio_write to realize error detection.
> ---
>  block/rbd.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 5b5a64a..710ee3e 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -661,6 +661,10 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
>      }
>  
>      if (r < 0) {
> +        if (r == -EINVAL && cmd == RBD_AIO_WRITE) {
> +            fprintf(stderr, "Image formats that grow on demand "
> +                            "are not supported on rbd.\n");
> +        }
>          goto failed_completion;
>      }

You can't fill up the log with messages like that. In general, if you
use fprintf() in a function whose call can be triggered by the guest,
you're doing it wrong.

What needs to be done is to check at open time whether the configuration
works. Max has sent a series to that end a while ago, not sure what its
status is. I think it ended up depending on some blockdev work.

Kevin
Max Reitz Dec. 11, 2014, 9:13 a.m. UTC | #2
On 2014-12-11 at 10:12, Kevin Wolf wrote:
> Am 11.12.2014 um 07:25 hat Jun Li geschrieben:
>> 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>
>> ---
>> v2:
>> Just use rbd_aio_write to realize error detection.
>> ---
>>   block/rbd.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/block/rbd.c b/block/rbd.c
>> index 5b5a64a..710ee3e 100644
>> --- a/block/rbd.c
>> +++ b/block/rbd.c
>> @@ -661,6 +661,10 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
>>       }
>>   
>>       if (r < 0) {
>> +        if (r == -EINVAL && cmd == RBD_AIO_WRITE) {
>> +            fprintf(stderr, "Image formats that grow on demand "
>> +                            "are not supported on rbd.\n");
>> +        }
>>           goto failed_completion;
>>       }
> You can't fill up the log with messages like that. In general, if you
> use fprintf() in a function whose call can be triggered by the guest,
> you're doing it wrong.
>
> What needs to be done is to check at open time whether the configuration
> works. Max has sent a series to that end a while ago, not sure what its
> status is. I think it ended up depending on some blockdev work.

Yes, the status is that we need to remove "growable" from the BDS first.

Max
lijun Dec. 11, 2014, 9:54 a.m. UTC | #3
Jun Li
2014-12-11 下午5:13于 "Max Reitz" <mreitz@redhat.com>写道:
>
> On 2014-12-11 at 10:12, Kevin Wolf wrote:
>>
>> Am 11.12.2014 um 07:25 hat Jun Li geschrieben:
>>>
>>> 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>
>>> ---
>>> v2:
>>> Just use rbd_aio_write to realize error detection.
>>> ---
>>>   block/rbd.c | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/block/rbd.c b/block/rbd.c
>>> index 5b5a64a..710ee3e 100644
>>> --- a/block/rbd.c
>>> +++ b/block/rbd.c
>>> @@ -661,6 +661,10 @@ static BlockAIOCB *rbd_start_aio(BlockDriverState
*bs,
>>>       }
>>>         if (r < 0) {
>>> +        if (r == -EINVAL && cmd == RBD_AIO_WRITE) {
>>> +            fprintf(stderr, "Image formats that grow on demand "
>>> +                            "are not supported on rbd.\n");
>>> +        }
>>>           goto failed_completion;
>>>       }
>>
>> You can't fill up the log with messages like that. In general, if you
>> use fprintf() in a function whose call can be triggered by the guest,
>> you're doing it wrong.
>>
>> What needs to be done is to check at open time whether the configuration
>> works. Max has sent a series to that end a while ago, not sure what its
>> status is. I think it ended up depending on some blockdev work.
>
>
> Yes, the status is that we need to remove "growable" from the BDS first.
>

Hi, which serial do you mean? Could you give a link? Thx.

Jun Li
Max Reitz Dec. 11, 2014, 9:58 a.m. UTC | #4
On 2014-12-11 at 10:54, jun muzi wrote:
>
> Jun Li
> 2014-12-11 下午5:13于 "Max Reitz" <mreitz@redhat.com 
> <mailto:mreitz@redhat.com>>写道:
> >
> > On 2014-12-11 at 10:12, Kevin Wolf wrote:
> >>
> >> Am 11.12.2014 um 07:25 hat Jun Li geschrieben:
> >>>
> >>> 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 <mailto:junmuzi@gmail.com>>
> >>> ---
> >>> v2:
> >>> Just use rbd_aio_write to realize error detection.
> >>> ---
> >>>   block/rbd.c | 4 ++++
> >>>   1 file changed, 4 insertions(+)
> >>>
> >>> diff --git a/block/rbd.c b/block/rbd.c
> >>> index 5b5a64a..710ee3e 100644
> >>> --- a/block/rbd.c
> >>> +++ b/block/rbd.c
> >>> @@ -661,6 +661,10 @@ static BlockAIOCB 
> *rbd_start_aio(BlockDriverState *bs,
> >>>       }
> >>>         if (r < 0) {
> >>> +        if (r == -EINVAL && cmd == RBD_AIO_WRITE) {
> >>> +            fprintf(stderr, "Image formats that grow on demand "
> >>> +                            "are not supported on rbd.\n");
> >>> +        }
> >>>           goto failed_completion;
> >>>       }
> >>
> >> You can't fill up the log with messages like that. In general, if you
> >> use fprintf() in a function whose call can be triggered by the guest,
> >> you're doing it wrong.
> >>
> >> What needs to be done is to check at open time whether the 
> configuration
> >> works. Max has sent a series to that end a while ago, not sure what its
> >> status is. I think it ended up depending on some blockdev work.
> >
> >
> > Yes, the status is that we need to remove "growable" from the BDS first.
> >
>
> Hi, which serial do you mean? Could you give a link? Thx.
>

Hi, here it is: 
http://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg02088.html

Max
diff mbox

Patch

diff --git a/block/rbd.c b/block/rbd.c
index 5b5a64a..710ee3e 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -661,6 +661,10 @@  static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
     }
 
     if (r < 0) {
+        if (r == -EINVAL && cmd == RBD_AIO_WRITE) {
+            fprintf(stderr, "Image formats that grow on demand "
+                            "are not supported on rbd.\n");
+        }
         goto failed_completion;
     }