mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
txg: generalise txg_wait_synced_sig() to txg_wait_synced_flags() (#17284)
txg_wait_synced_sig() is "wait for txg, unless a signal arrives". We expect that future development will require similar "wait unless X" behaviour. This generalises the API as txg_wait_synced_flags(), where the provided flags describe the events that should cause the call to return. Instead of a boolean, the return is now an error code, which the caller can use to know which event caused the call to return. The existing call to txg_wait_synced_sig() is now txg_wait_synced_flags(TXG_WAIT_SIGNAL). Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <robn@despairlabs.com> Reviewed-by: Allan Jude <allan@klarasystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org>
This commit is contained in:
+20
-3
@@ -66,6 +66,20 @@ typedef struct txg_list {
|
||||
txg_node_t *tl_head[TXG_SIZE];
|
||||
} txg_list_t;
|
||||
|
||||
/*
|
||||
* Wait flags for txg_wait_synced_flags(). By default (TXG_WAIT_NONE), it will
|
||||
* wait until the wanted txg is reached, or block forever. Additional flags
|
||||
* indicate other conditions that the caller is interested in, that will cause
|
||||
* the wait to break and return an error code describing the condition.
|
||||
*/
|
||||
typedef enum {
|
||||
/* No special flags. Guaranteed to block forever or return 0 */
|
||||
TXG_WAIT_NONE = 0,
|
||||
|
||||
/* If a signal arrives while waiting, abort and return EINTR */
|
||||
TXG_WAIT_SIGNAL = (1 << 0),
|
||||
} txg_wait_flag_t;
|
||||
|
||||
struct dsl_pool;
|
||||
|
||||
extern void txg_init(struct dsl_pool *dp, uint64_t txg);
|
||||
@@ -86,13 +100,16 @@ extern void txg_kick(struct dsl_pool *dp, uint64_t txg);
|
||||
* Try to make this happen as soon as possible (eg. kick off any
|
||||
* necessary syncs immediately). If txg==0, wait for the currently open
|
||||
* txg to finish syncing.
|
||||
* See txg_wait_flag_t above for a description of how the flags affect the wait.
|
||||
*/
|
||||
extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg);
|
||||
extern int txg_wait_synced_flags(struct dsl_pool *dp, uint64_t txg,
|
||||
txg_wait_flag_t flags);
|
||||
|
||||
/*
|
||||
* Wait as above. Returns true if the thread was signaled while waiting.
|
||||
* Traditional form of txg_wait_synced_flags, waits forever.
|
||||
* Shorthand for VERIFY0(txg_wait_synced_flags(dp, TXG_WAIT_NONE))
|
||||
*/
|
||||
extern boolean_t txg_wait_synced_sig(struct dsl_pool *dp, uint64_t txg);
|
||||
extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg);
|
||||
|
||||
/*
|
||||
* Wait until the given transaction group, or one after it, is
|
||||
|
||||
Reference in New Issue
Block a user