zil_suspend: fix cookie leak if ZIL crashes during wait

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17622
This commit is contained in:
Rob Norris 2025-08-12 12:51:44 +10:00 committed by Brian Behlendorf
parent 7c9adc6858
commit 531568f438

View File

@ -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);
}
/*