Skip to content

Commit

Permalink
Linux: sync mapped data on umount
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Snajdr <[email protected]>
  • Loading branch information
snajpa committed Nov 28, 2024
1 parent 0ffa6f3 commit d53602d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,9 +1546,24 @@ void
zfs_preumount(struct super_block *sb)
{
zfsvfs_t *zfsvfs = sb->s_fs_info;
znode_t *zp;

/* zfsvfs is NULL when zfs_domount fails during mount */
if (zfsvfs) {
/*
* Since we have to disable zpl_prune_sb when umounting,
* because the shrinker gets freed before zpl_kill_sb is
* ever called, the umount might be unable to sync open files.
*
* Let's do it here.
*/
mutex_enter(&zfsvfs->z_znodes_lock);
list_for_each_entry(zp, &zfsvfs->z_all_znodes, z_link_node) {
if (zp->z_sa_hdl)
filemap_write_and_wait(zp->z_vnode->i_mapping);
}
mutex_exit(&zfsvfs->z_znodes_lock);

zfs_unlinked_drain_stop_wait(zfsvfs);
zfsctl_destroy(sb->s_fs_info);
/*
Expand Down

0 comments on commit d53602d

Please sign in to comment.