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); }