txg_wait_synced_flags: add TXG_WAIT_SUSPEND flag to not wait if pool suspended

This allows a caller to request a wait for txg sync, with an appropriate
error return if the pool is suspended or becomes suspended during the
wait.

To support this, txg_wait_kick() is added to signal the sync condvar,
which wakes up the waiters, causing them to loop and reconsider their
wait conditions again. zio_suspend() now calls this to trigger the break
if the pool suspends while waiting.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17355
This commit is contained in:
Rob Norris
2025-02-24 13:56:08 +11:00
committed by Brian Behlendorf
parent 8487945034
commit 468d22d60c
3 changed files with 31 additions and 1 deletions
+9
View File
@@ -25,6 +25,7 @@
*/
/*
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
* Copyright (c) 2025, Klara, Inc.
*/
#ifndef _SYS_TXG_H
@@ -78,6 +79,9 @@ typedef enum {
/* If a signal arrives while waiting, abort and return EINTR */
TXG_WAIT_SIGNAL = (1 << 0),
/* If the pool suspends while waiting, abort and return ESHUTDOWN. */
TXG_WAIT_SUSPEND = (1 << 1),
} txg_wait_flag_t;
struct dsl_pool;
@@ -111,6 +115,11 @@ extern int txg_wait_synced_flags(struct dsl_pool *dp, uint64_t txg,
*/
extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg);
/*
* Wake all threads waiting in txg_wait_synced_flags() so they can reevaluate.
*/
extern void txg_wait_kick(struct dsl_pool *dp);
/*
* Wait until the given transaction group, or one after it, is
* the open transaction group. Try to make this happen as soon