diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-06-24 17:13:10 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-06-28 09:20:26 +0200 |
commit | d616b224745b2c522f965cf8de7da17b553b959a (patch) | |
tree | df5c6f5b8e13823d4c202782eec90c93b55997a6 /include/block/block_int.h | |
parent | 5dae8e5fb803f53fadc116cefe353953b938cbe1 (diff) |
block: add bdrv_add_before_write_notifier()
The bdrv_add_before_write_notifier() function installs a callback that
is invoked before a write request is processed. This will be used to
implement copy-on-write point-in-time snapshots where we need to copy
out old data before overwriting it.
Note that BdrvTrackedRequest is moved to block_int.h since it is passed
to .notify() functions.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include/block/block_int.h')
-rw-r--r-- | include/block/block_int.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/block/block_int.h b/include/block/block_int.h index ba52247c1a..2d009556b0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -59,7 +59,16 @@ #define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts" #define BLOCK_OPT_ADAPTER_TYPE "adapter_type" -typedef struct BdrvTrackedRequest BdrvTrackedRequest; +typedef struct BdrvTrackedRequest { + BlockDriverState *bs; + int64_t sector_num; + int nb_sectors; + bool is_write; + QLIST_ENTRY(BdrvTrackedRequest) list; + Coroutine *co; /* owner, used for deadlock detection */ + CoQueue wait_queue; /* coroutines blocked on this request */ +} BdrvTrackedRequest; + typedef struct BlockIOLimit { int64_t bps[3]; @@ -248,6 +257,9 @@ struct BlockDriverState { NotifierList close_notifiers; + /* Callback before write request is processed */ + NotifierWithReturnList before_write_notifiers; + /* number of in-flight copy-on-read requests */ unsigned int copy_on_read_in_flight; @@ -299,6 +311,15 @@ void bdrv_set_io_limits(BlockDriverState *bs, BlockIOLimit *io_limits); /** + * bdrv_add_before_write_notifier: + * + * Register a callback that is invoked before write requests are processed but + * after any throttling or waiting for overlapping requests. + */ +void bdrv_add_before_write_notifier(BlockDriverState *bs, + NotifierWithReturn *notifier); + +/** * bdrv_get_aio_context: * * Returns: the currently bound #AioContext |