ovl: Sync upper dirty data when syncing overlayfs
When executing filesystem sync or umount on overlayfs,
dirty data does not get synced as expected on upper filesystem.
This patch fixes sync filesystem method to keep data consistency
for overlayfs.
Signed-off-by: Chengguang Xu <cgxu@mykernel.net>
Fixes: e593b2bf51
("ovl: properly implement sync_filesystem()")
Cc: <stable@vger.kernel.org> #4.11
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Родитель
b02a16e641
Коммит
e8d4bfe3a7
|
@ -252,6 +252,7 @@ static void ovl_put_super(struct super_block *sb)
|
||||||
ovl_free_fs(ofs);
|
ovl_free_fs(ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sync real dirty inodes in upper filesystem (if it exists) */
|
||||||
static int ovl_sync_fs(struct super_block *sb, int wait)
|
static int ovl_sync_fs(struct super_block *sb, int wait)
|
||||||
{
|
{
|
||||||
struct ovl_fs *ofs = sb->s_fs_info;
|
struct ovl_fs *ofs = sb->s_fs_info;
|
||||||
|
@ -260,14 +261,24 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
|
||||||
|
|
||||||
if (!ofs->upper_mnt)
|
if (!ofs->upper_mnt)
|
||||||
return 0;
|
return 0;
|
||||||
upper_sb = ofs->upper_mnt->mnt_sb;
|
|
||||||
if (!upper_sb->s_op->sync_fs)
|
/*
|
||||||
|
* If this is a sync(2) call or an emergency sync, all the super blocks
|
||||||
|
* will be iterated, including upper_sb, so no need to do anything.
|
||||||
|
*
|
||||||
|
* If this is a syncfs(2) call, then we do need to call
|
||||||
|
* sync_filesystem() on upper_sb, but enough if we do it when being
|
||||||
|
* called with wait == 1.
|
||||||
|
*/
|
||||||
|
if (!wait)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* real inodes have already been synced by sync_filesystem(ovl_sb) */
|
upper_sb = ofs->upper_mnt->mnt_sb;
|
||||||
|
|
||||||
down_read(&upper_sb->s_umount);
|
down_read(&upper_sb->s_umount);
|
||||||
ret = upper_sb->s_op->sync_fs(upper_sb, wait);
|
ret = sync_filesystem(upper_sb);
|
||||||
up_read(&upper_sb->s_umount);
|
up_read(&upper_sb->s_umount);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче