Skip to content

Commit e5e3ac5

Browse files
committed
Linux: syncfs(2) should sync all cached files
While debugging problem with data not being synced on umount, we've noticed that even syncfs(2) doesn't help to get the data written out. It is because it doesn't actually sync any of the live znodes. Signed-off-by: Pavel Snajdr <[email protected]>
1 parent 0ffa6f3 commit e5e3ac5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

module/os/linux/zfs/zpl_super.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,23 @@ zpl_sync_fs(struct super_block *sb, int wait)
109109
{
110110
fstrans_cookie_t cookie;
111111
cred_t *cr = CRED();
112+
znode_t *zp;
113+
zfsvfs_t *zfsvfs = sb->s_fs_info;
112114
int error;
113115

114116
crhold(cr);
115117
cookie = spl_fstrans_mark();
116-
error = -zfs_sync(sb, wait, cr);
118+
mutex_enter(&zfsvfs->z_znodes_lock);
119+
for (zp = list_head(&zfsvfs->z_all_znodes); zp;
120+
zp = list_next(&zfsvfs->z_all_znodes, zp)) {
121+
if (zp->z_sa_hdl)
122+
error = -zfs_fsync(zp, wait, cr);
123+
if (error != 0)
124+
break;
125+
}
126+
mutex_exit(&zfsvfs->z_znodes_lock);
127+
if (error == 0)
128+
error = -zfs_sync(sb, wait, cr);
117129
spl_fstrans_unmark(cookie);
118130
crfree(cr);
119131
ASSERT3S(error, <=, 0);

0 commit comments

Comments
 (0)