[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/14] block: add new BlockDriver handler: bdrv_cancel_in_flight
From: |
Eric Blake |
Subject: |
[PULL 05/14] block: add new BlockDriver handler: bdrv_cancel_in_flight |
Date: |
Fri, 12 Feb 2021 14:16:10 -0600 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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>
---
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 0a9f2c187cdb..2f2698074e30 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 22a2789d3516..88e411193981 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 b0435ed6707c..ca2dca30070e 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.30.1
- [PULL 00/14] NBD patches through 2021-02-12, Eric Blake, 2021/02/12
- [PULL 01/14] qemu-nbd: Use SOMAXCONN for socket listen() backlog, Eric Blake, 2021/02/12
- [PULL 04/14] io: error_prepend() in qio_channel_readv_full_all() causes segfault, Eric Blake, 2021/02/12
- [PULL 02/14] qemu-nbd: Permit --shared=0 for unlimited clients, Eric Blake, 2021/02/12
- [PULL 03/14] iotests/210: Fix reference output, Eric Blake, 2021/02/12
- [PULL 05/14] block: add new BlockDriver handler: bdrv_cancel_in_flight,
Eric Blake <=
- [PULL 07/14] block/raw-format: implement .bdrv_cancel_in_flight handler, Eric Blake, 2021/02/12
- [PULL 08/14] job: add .cancel handler for the driver, Eric Blake, 2021/02/12
- [PULL 06/14] block/nbd: implement .bdrv_cancel_in_flight, Eric Blake, 2021/02/12
- [PULL 09/14] block/mirror: implement .cancel job handler, Eric Blake, 2021/02/12
- [PULL 13/14] block/backup: implement .cancel job handler, Eric Blake, 2021/02/12
- [PULL 14/14] iotests/264: add backup-cancel test-case, Eric Blake, 2021/02/12
- [PULL 11/14] iotests.py: qemu_nbd_popen: remove pid file after use, Eric Blake, 2021/02/12
- [PULL 12/14] iotests/264: add mirror-cancel test-case, Eric Blake, 2021/02/12
- [PULL 10/14] iotests/264: move to python unittest, Eric Blake, 2021/02/12
- Re: [PULL 00/14] NBD patches through 2021-02-12, Peter Maydell, 2021/02/13