Skip to content

Commit af93006

Browse files
robnbehlendorf
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #17420
1 parent 2df54b1 commit af93006

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

module/os/linux/zfs/zfs_vfsops.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ zfs_sync(struct super_block *sb, int wait, cred_t *cr)
265265
{
266266
(void) cr;
267267
zfsvfs_t *zfsvfs = sb->s_fs_info;
268+
ASSERT3P(zfsvfs, !=, NULL);
268269

269270
/*
270271
* 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)
273274
if (!wait)
274275
return (0);
275276

276-
if (zfsvfs != NULL) {
277-
/*
278-
* Sync a specific filesystem.
279-
*/
280-
dsl_pool_t *dp;
281-
int error;
282-
283-
if ((error = zfs_enter(zfsvfs, FTAG)) != 0)
284-
return (error);
285-
dp = dmu_objset_pool(zfsvfs->z_os);
286-
287-
/*
288-
* If the system is shutting down, then skip any
289-
* filesystems which may exist on a suspended pool.
290-
*/
291-
if (spa_suspended(dp->dp_spa)) {
292-
zfs_exit(zfsvfs, FTAG);
293-
return (0);
294-
}
295-
296-
if (zfsvfs->z_log != NULL)
297-
zil_commit(zfsvfs->z_log, 0);
277+
int err = zfs_enter(zfsvfs, FTAG);
278+
if (err != 0)
279+
return (err);
298280

281+
/*
282+
* If the system is shutting down, then skip any
283+
* filesystems which may exist on a suspended pool.
284+
*/
285+
if (spa_suspended(zfsvfs->z_os->os_spa)) {
299286
zfs_exit(zfsvfs, FTAG);
300-
} else {
301-
/*
302-
* Sync all ZFS filesystems. This is what happens when you
303-
* run sync(1). Unlike other filesystems, ZFS honors the
304-
* request by waiting for all pools to commit all dirty data.
305-
*/
306-
spa_sync_allpools();
287+
return (0);
307288
}
308289

290+
zil_commit(zfsvfs->z_log, 0);
291+
zfs_exit(zfsvfs, FTAG);
292+
309293
return (0);
310294
}
311295

0 commit comments

Comments
 (0)