Commit e593b2bf authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

ovl: properly implement sync_filesystem()

overlayfs syncs all inode pages on sync_filesystem(), but it also
needs to call s_op->sync_fs() of upper fs for metadata sync.

This fixes correctness of syncfs(2) as demonstrated by following
xfs specific test:

xfs_sync_stats()
{
	echo $1
	echo -n "xfs_log_force = "
	grep log /proc/fs/xfs/stat  | awk '{ print $5 }'
}

xfs_sync_stats "before touch"
touch x
xfs_sync_stats "after touch"
xfs_io -c syncfs .
xfs_sync_stats "after syncfs"
xfs_io -c fsync x
xfs_sync_stats "after fsync"
xfs_io -c fsync x
xfs_sync_stats "after fsync #2"

When this test is run in overlay mount over xfs, log force
count does not increase with syncfs command.
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 01ad3eb8
...@@ -160,6 +160,25 @@ static void ovl_put_super(struct super_block *sb) ...@@ -160,6 +160,25 @@ static void ovl_put_super(struct super_block *sb)
kfree(ufs); kfree(ufs);
} }
static int ovl_sync_fs(struct super_block *sb, int wait)
{
struct ovl_fs *ufs = sb->s_fs_info;
struct super_block *upper_sb;
int ret;
if (!ufs->upper_mnt)
return 0;
upper_sb = ufs->upper_mnt->mnt_sb;
if (!upper_sb->s_op->sync_fs)
return 0;
/* real inodes have already been synced by sync_filesystem(ovl_sb) */
down_read(&upper_sb->s_umount);
ret = upper_sb->s_op->sync_fs(upper_sb, wait);
up_read(&upper_sb->s_umount);
return ret;
}
/** /**
* ovl_statfs * ovl_statfs
* @sb: The overlayfs super block * @sb: The overlayfs super block
...@@ -222,6 +241,7 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data) ...@@ -222,6 +241,7 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data)
static const struct super_operations ovl_super_operations = { static const struct super_operations ovl_super_operations = {
.put_super = ovl_put_super, .put_super = ovl_put_super,
.sync_fs = ovl_sync_fs,
.statfs = ovl_statfs, .statfs = ovl_statfs,
.show_options = ovl_show_options, .show_options = ovl_show_options,
.remount_fs = ovl_remount, .remount_fs = ovl_remount,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment