[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 01/10] block: add new BlockDriver handler: bdrv_cancel_in_flig
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 01/10] block: add new BlockDriver handler: bdrv_cancel_in_flight |
Date: |
Fri, 5 Feb 2021 19:37:11 +0300 |
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>
---
include/block/block.h | 3 +++
include/block/block_int.h | 9 +++++++++
block/io.c | 11 +++++++++++
3 files changed, 23 insertions(+)
diff --git a/include/block/block.h b/include/block/block.h
index 0a9f2c187c..2f2698074e 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -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
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 22a2789d35..88e4111939 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -352,6 +352,15 @@ struct BlockDriver {
bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
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.
*/
diff --git a/block/io.c b/block/io.c
index b0435ed670..ca2dca3007 100644
--- a/block/io.c
+++ b/block/io.c
@@ -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);
+ }
+}
--
2.29.2
- [PATCH v2 00/10] mirror: cancel nbd reconnect, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 01/10] block: add new BlockDriver handler: bdrv_cancel_in_flight,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v2 02/10] block/nbd: implement .bdrv_cancel_in_flight, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 10/10] iotests/264: add backup-cancel test-case, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 04/10] job: add .cancel handler for the driver, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 05/10] block/mirror: implement .cancel job handler, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 06/10] iotests/264: move to python unittest, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 03/10] block/raw-format: implement .bdrv_cancel_in_flight handler, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 08/10] iotests/264: add mirror-cancel test-case, Vladimir Sementsov-Ogievskiy, 2021/02/05
- [PATCH v2 07/10] iotests.py: qemu_nbd_popen: remove pid file after use, Vladimir Sementsov-Ogievskiy, 2021/02/05