zfs_sync: return error when pool suspends

If the pool is suspended, we'll just block in zil_commit(). If the
system is shutting down, blocking wouldn't help anyone. So, we should
keep this test for now, but at least return an error for anyone who is
actually interested.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17420
This commit is contained in:
Rob Norris 2025-06-04 15:15:27 +10:00 committed by Brian Behlendorf
parent 52352dd748
commit e3f5e317e0

View File

@ -279,12 +279,13 @@ zfs_sync(struct super_block *sb, int wait, cred_t *cr)
return (err); return (err);
/* /*
* If the system is shutting down, then skip any * If the pool is suspended, just return an error. This is to help
* filesystems which may exist on a suspended pool. * with shutting down with pools suspended, as we don't want to block
* in that case.
*/ */
if (spa_suspended(zfsvfs->z_os->os_spa)) { if (spa_suspended(zfsvfs->z_os->os_spa)) {
zfs_exit(zfsvfs, FTAG); zfs_exit(zfsvfs, FTAG);
return (0); return (SET_ERROR(EIO));
} }
zil_commit(zfsvfs->z_log, 0); zil_commit(zfsvfs->z_log, 0);