diff mbox series

[03/11] block/raw-format: implement .bdrv_cancel_in_flight handler

Message ID 20201118180433.11931-4-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series mirror: cancel nbd reconnect | expand

Commit Message

Vladimir Sementsov-Ogievskiy Nov. 18, 2020, 6:04 p.m. UTC
We are going to cancel in-flight requests on mirror nbd target on job
cancel. Still nbd is often used not directly but as raw-format child.
So, add pass-through handler here.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/raw-format.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Eric Blake Jan. 20, 2021, 11:15 p.m. UTC | #1
On 11/18/20 12:04 PM, Vladimir Sementsov-Ogievskiy wrote:
> We are going to cancel in-flight requests on mirror nbd target on job
> cancel. Still nbd is often used not directly but as raw-format child.
> So, add pass-through handler here.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/raw-format.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Should all filters do this automatically (or rather, should the block
layer do this automatically for all filters)?  But I understand that it
does NOT make sense for format drivers in general (cancelling a guest
request may still require metadata updates), where raw-format is the
exception, so doing it in raw-format instead of the block layer makes sense.


>  BlockDriver bdrv_raw = {
>      .format_name          = "raw",
>      .instance_size        = sizeof(BDRVRawState),
> @@ -608,6 +613,7 @@ BlockDriver bdrv_raw = {
>      .bdrv_has_zero_init   = &raw_has_zero_init,
>      .strong_runtime_opts  = raw_strong_runtime_opts,
>      .mutable_opts         = mutable_opts,
> +    .bdrv_cancel_in_flight = raw_cancel_in_flight,

A demonstration of why I don't like aligning the =.  But it's merely
cosmetic, so doesn't affect:

Reviewed-by: Eric Blake <eblake@redhat.com>
Vladimir Sementsov-Ogievskiy Jan. 21, 2021, 7:08 p.m. UTC | #2
21.01.2021 02:15, Eric Blake wrote:
> On 11/18/20 12:04 PM, Vladimir Sementsov-Ogievskiy wrote:
>> We are going to cancel in-flight requests on mirror nbd target on job
>> cancel. Still nbd is often used not directly but as raw-format child.
>> So, add pass-through handler here.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   block/raw-format.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
> 
> Should all filters do this automatically (or rather, should the block
> layer do this automatically for all filters)?  But I understand that it
> does NOT make sense for format drivers in general (cancelling a guest
> request may still require metadata updates), where raw-format is the
> exception, so doing it in raw-format instead of the block layer makes sense.
> 

Hmm.. probably not for backup_top filter. But of course OK for throttling

> 
>>   BlockDriver bdrv_raw = {
>>       .format_name          = "raw",
>>       .instance_size        = sizeof(BDRVRawState),
>> @@ -608,6 +613,7 @@ BlockDriver bdrv_raw = {
>>       .bdrv_has_zero_init   = &raw_has_zero_init,
>>       .strong_runtime_opts  = raw_strong_runtime_opts,
>>       .mutable_opts         = mutable_opts,
>> +    .bdrv_cancel_in_flight = raw_cancel_in_flight,
> 
> A demonstration of why I don't like aligning the =.  But it's merely
> cosmetic, so doesn't affect:
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
diff mbox series

Patch

diff --git a/block/raw-format.c b/block/raw-format.c
index 42ec50802b..7717578ed6 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -575,6 +575,11 @@  static const char *const raw_strong_runtime_opts[] = {
     NULL
 };
 
+static void raw_cancel_in_flight(BlockDriverState *bs)
+{
+    bdrv_cancel_in_flight(bs->file->bs);
+}
+
 BlockDriver bdrv_raw = {
     .format_name          = "raw",
     .instance_size        = sizeof(BDRVRawState),
@@ -608,6 +613,7 @@  BlockDriver bdrv_raw = {
     .bdrv_has_zero_init   = &raw_has_zero_init,
     .strong_runtime_opts  = raw_strong_runtime_opts,
     .mutable_opts         = mutable_opts,
+    .bdrv_cancel_in_flight = raw_cancel_in_flight,
 };
 
 static void bdrv_raw_init(void)