From d9446415020b922979177260eb7676dc27142fd0 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 4 Jun 2025 13:25:39 +1000 Subject: [PATCH] zfs_sync: remove support for impossible scenarios The superblock pointer will always be set, as will z_log, so remove code supporting cases that can't occur (on Linux at least). Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Paul Dagnelie Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Closes #17420 --- module/os/linux/zfs/zfs_vfsops.c | 42 ++++++++++---------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index ca75080d5..f760bdb4f 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -265,6 +265,7 @@ zfs_sync(struct super_block *sb, int wait, cred_t *cr) { (void) cr; zfsvfs_t *zfsvfs = sb->s_fs_info; + ASSERT3P(zfsvfs, !=, NULL); /* * Semantically, the only requirement is that the sync be initiated. @@ -273,39 +274,22 @@ zfs_sync(struct super_block *sb, int wait, cred_t *cr) if (!wait) return (0); - if (zfsvfs != NULL) { - /* - * Sync a specific filesystem. - */ - dsl_pool_t *dp; - int error; - - if ((error = zfs_enter(zfsvfs, FTAG)) != 0) - return (error); - dp = dmu_objset_pool(zfsvfs->z_os); - - /* - * If the system is shutting down, then skip any - * filesystems which may exist on a suspended pool. - */ - if (spa_suspended(dp->dp_spa)) { - zfs_exit(zfsvfs, FTAG); - return (0); - } - - if (zfsvfs->z_log != NULL) - zil_commit(zfsvfs->z_log, 0); + int err = zfs_enter(zfsvfs, FTAG); + if (err != 0) + return (err); + /* + * If the system is shutting down, then skip any + * filesystems which may exist on a suspended pool. + */ + if (spa_suspended(zfsvfs->z_os->os_spa)) { zfs_exit(zfsvfs, FTAG); - } else { - /* - * Sync all ZFS filesystems. This is what happens when you - * run sync(1). Unlike other filesystems, ZFS honors the - * request by waiting for all pools to commit all dirty data. - */ - spa_sync_allpools(); + return (0); } + zil_commit(zfsvfs->z_log, 0); + zfs_exit(zfsvfs, FTAG); + return (0); }