From 531568f43811147d059d73616707a957691245a0 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 12 Aug 2025 12:51:44 +1000 Subject: [PATCH] zil_suspend: fix cookie leak if ZIL crashes during wait Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Closes #17622 --- module/zfs/zil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/module/zfs/zil.c b/module/zfs/zil.c index ab71552a2..975586833 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -4485,16 +4485,16 @@ zil_suspend(const char *osname, void **cookiep) cv_wait(&zilog->zl_cv_suspend, &zilog->zl_lock); mutex_exit(&zilog->zl_lock); - if (cookiep == NULL) + if (zilog->zl_restart_txg > 0) { + /* ZIL crashed while we were waiting. */ + zil_resume(os); + error = SET_ERROR(EBUSY); + } else if (cookiep == NULL) zil_resume(os); else *cookiep = os; - if (zilog->zl_restart_txg > 0) - /* ZIL crashed while we were waiting. */ - return (SET_ERROR(EBUSY)); - - return (0); + return (error); } /*