summaryrefslogtreecommitdiffstats
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@mykernel.net>2020-04-22 12:28:43 +0800
committerMiklos Szeredi <mszeredi@redhat.com>2020-05-13 11:11:24 +0200
commit399c109d357a7e217cf7ef551e7e234439c68c15 (patch)
tree6947c756bd5dc797715cba6d75af5c6b610f3512 /fs/overlayfs
parentc21c839b8448dd4b1e37ffc1bde928f57d34c0db (diff)
downloadlinux-399c109d357a7e217cf7ef551e7e234439c68c15.tar.bz2
ovl: sync dirty data when remounting to ro mode
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 <cgxu519@mykernel.net> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/super.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index a88a7badf444..60dfb27bc12b 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -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 = {