OSDN Git Service

block: add new BlockDriver handler: bdrv_cancel_in_flight
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 5 Feb 2021 16:37:11 +0000 (19:37 +0300)
committerEric Blake <eblake@redhat.com>
Fri, 12 Feb 2021 15:45:18 +0000 (09:45 -0600)
It will be used to stop retrying NBD requests on mirror cancel.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210205163720.887197-2-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/io.c
include/block/block.h
include/block/block_int.h

index b0435ed..ca2dca3 100644 (file)
@@ -3460,3 +3460,14 @@ out:
 
     return ret;
 }
+
+void bdrv_cancel_in_flight(BlockDriverState *bs)
+{
+    if (!bs || !bs->drv) {
+        return;
+    }
+
+    if (bs->drv->bdrv_cancel_in_flight) {
+        bs->drv->bdrv_cancel_in_flight(bs);
+    }
+}
index 0a9f2c1..2f26980 100644 (file)
@@ -849,4 +849,7 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
                                     BdrvChild *dst, int64_t dst_offset,
                                     int64_t bytes, BdrvRequestFlags read_flags,
                                     BdrvRequestFlags write_flags);
+
+void bdrv_cancel_in_flight(BlockDriverState *bs);
+
 #endif
index 22a2789..88e4111 100644 (file)
@@ -353,6 +353,15 @@ struct BlockDriver {
         int64_t *map, BlockDriverState **file);
 
     /*
+     * This informs the driver that we are no longer interested in the result
+     * of in-flight requests, so don't waste the time if possible.
+     *
+     * One example usage is to avoid waiting for an nbd target node reconnect
+     * timeout during job-cancel.
+     */
+    void (*bdrv_cancel_in_flight)(BlockDriverState *bs);
+
+    /*
      * Invalidate any cached meta-data.
      */
     void coroutine_fn (*bdrv_co_invalidate_cache)(BlockDriverState *bs,