Skip to content

Commit

Permalink
ovl: sync dirty data when remounting to ro mode
Browse files Browse the repository at this point in the history
sync_filesystem() does not sync dirty data for readonly filesystem during
umount, so before changing to readonly filesystem we should sync dirty data
for data integrity.

Signed-off-by: Chengguang Xu <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
cgxu519 authored and Miklos Szeredi committed May 13, 2020
1 parent c21c839 commit 399c109
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,20 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
static int ovl_remount(struct super_block *sb, int *flags, char *data)
{
struct ovl_fs *ofs = sb->s_fs_info;
struct super_block *upper_sb;
int ret = 0;

if (!(*flags & SB_RDONLY) && ovl_force_readonly(ofs))
return -EROFS;

return 0;
if (*flags & SB_RDONLY && !sb_rdonly(sb)) {
upper_sb = ofs->upper_mnt->mnt_sb;
down_read(&upper_sb->s_umount);
ret = sync_filesystem(upper_sb);
up_read(&upper_sb->s_umount);
}

return ret;
}

static const struct super_operations ovl_super_operations = {
Expand Down

0 comments on commit 399c109

Please sign in to comment.