Skip to content

Commit

Permalink
Linux: sync mapped data on umount
Browse files Browse the repository at this point in the history
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 in zfs_preumount.

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information
snajpa committed Nov 28, 2024
1 parent 0ffa6f3 commit 7a376ea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 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,25 @@ 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);
for (zp = list_head(&zfsvfs->z_all_znodes); zp;
zp = list_next(&zfsvfs->z_all_znodes, zp)) {
if (zp->z_sa_hdl)
filemap_write_and_wait(ZTOI(zp)->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 7a376ea

Please sign in to comment.