@@ -841,8 +841,8 @@ zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
841841 * zpp = zp ;
842842 }
843843
844- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
845- zil_commit (zilog , 0 );
844+ if (error == 0 && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
845+ error = zil_commit (zilog , 0 );
846846
847847 zfs_exit (zfsvfs , FTAG );
848848 return (error );
@@ -1203,8 +1203,8 @@ zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
12031203 zfs_zrele_async (xzp );
12041204 }
12051205
1206- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1207- zil_commit (zilog , 0 );
1206+ if (error == 0 && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1207+ error = zil_commit (zilog , 0 );
12081208
12091209 zfs_exit (zfsvfs , FTAG );
12101210 return (error );
@@ -1392,14 +1392,15 @@ zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp,
13921392
13931393 zfs_dirent_unlock (dl );
13941394
1395- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1396- zil_commit (zilog , 0 );
1397-
13981395 if (error != 0 ) {
13991396 zrele (zp );
14001397 } else {
14011398 zfs_znode_update_vfs (dzp );
14021399 zfs_znode_update_vfs (zp );
1400+
1401+ if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1402+ error = zil_commit (zilog , 0 );
1403+
14031404 }
14041405 zfs_exit (zfsvfs , FTAG );
14051406 return (error );
@@ -1528,8 +1529,8 @@ zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr,
15281529 zfs_znode_update_vfs (zp );
15291530 zrele (zp );
15301531
1531- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1532- zil_commit (zilog , 0 );
1532+ if (error == 0 && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
1533+ error = zil_commit (zilog , 0 );
15331534
15341535 zfs_exit (zfsvfs , FTAG );
15351536 return (error );
@@ -2630,8 +2631,8 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
26302631 }
26312632
26322633out2 :
2633- if (os -> os_sync == ZFS_SYNC_ALWAYS )
2634- zil_commit (zilog , 0 );
2634+ if (err == 0 && os -> os_sync == ZFS_SYNC_ALWAYS )
2635+ err = zil_commit (zilog , 0 );
26352636
26362637out3 :
26372638 kmem_free (xattr_bulk , sizeof (sa_bulk_attr_t ) * bulks );
@@ -3235,8 +3236,8 @@ zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp, char *tnm,
32353236 zfs_dirent_unlock (sdl );
32363237 zfs_dirent_unlock (tdl );
32373238
3238- if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3239- zil_commit (zilog , 0 );
3239+ if (error == 0 && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3240+ error = zil_commit (zilog , 0 );
32403241
32413242 zfs_exit (zfsvfs , FTAG );
32423243 return (error );
@@ -3436,7 +3437,7 @@ zfs_symlink(znode_t *dzp, char *name, vattr_t *vap, char *link,
34363437 * zpp = zp ;
34373438
34383439 if (zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3439- zil_commit (zilog , 0 );
3440+ error = zil_commit (zilog , 0 );
34403441 } else {
34413442 zrele (zp );
34423443 }
@@ -3670,18 +3671,20 @@ zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr,
36703671
36713672 zfs_dirent_unlock (dl );
36723673
3673- if (!is_tmpfile && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3674- zil_commit (zilog , 0 );
3675-
3676- if (is_tmpfile && zfsvfs -> z_os -> os_sync != ZFS_SYNC_DISABLED ) {
3677- txg_wait_flag_t wait_flags =
3678- spa_get_failmode (dmu_objset_spa (zfsvfs -> z_os )) ==
3679- ZIO_FAILURE_MODE_CONTINUE ? TXG_WAIT_SUSPEND : 0 ;
3680- error = txg_wait_synced_flags (dmu_objset_pool (zfsvfs -> z_os ),
3681- txg , wait_flags );
3682- if (error != 0 ) {
3683- ASSERT3U (error , = = , ESHUTDOWN );
3684- error = SET_ERROR (EIO );
3674+ if (error == 0 ) {
3675+ if (!is_tmpfile && zfsvfs -> z_os -> os_sync == ZFS_SYNC_ALWAYS )
3676+ error = zil_commit (zilog , 0 );
3677+
3678+ if (is_tmpfile && zfsvfs -> z_os -> os_sync != ZFS_SYNC_DISABLED ) {
3679+ txg_wait_flag_t wait_flags =
3680+ spa_get_failmode (dmu_objset_spa (zfsvfs -> z_os )) ==
3681+ ZIO_FAILURE_MODE_CONTINUE ? TXG_WAIT_SUSPEND : 0 ;
3682+ error = txg_wait_synced_flags (
3683+ dmu_objset_pool (zfsvfs -> z_os ), txg , wait_flags );
3684+ if (error != 0 ) {
3685+ ASSERT3U (error , = = , ESHUTDOWN );
3686+ error = SET_ERROR (EIO );
3687+ }
36853688 }
36863689 }
36873690
@@ -3939,8 +3942,13 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
39393942
39403943 zfs_rangelock_exit (lr );
39413944
3942- if (need_commit )
3943- zil_commit (zfsvfs -> z_log , zp -> z_id );
3945+ if (need_commit ) {
3946+ err = zil_commit (zfsvfs -> z_log , zp -> z_id );
3947+ if (err != 0 ) {
3948+ zfs_exit (zfsvfs , FTAG );
3949+ return (err );
3950+ }
3951+ }
39443952
39453953 dataset_kstats_update_write_kstats (& zfsvfs -> z_kstat , pglen );
39463954
0 commit comments