All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] ovl: Sync upper dirty data when sync overlayfs
@ 2017-11-29  2:01 Chengguang Xu
  2017-12-07 10:19 ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2017-11-29  2:01 UTC (permalink / raw)
  To: miklos, amir73il; +Cc: linux-unionfs, Chengguang Xu

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>
---
Changes since v3:
-Rebase onto overlayfs-next tree.

Changes since v2:
-Fix checkpatch warning.

Changes since v1:
-Call __sync_filesystem() instead of directly calling low level
 syncing functions.

 fs/overlayfs/super.c | 6 ++----
 fs/sync.c            | 3 ++-
 include/linux/fs.h   | 1 +
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index be03578..6173ca9 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -244,6 +244,7 @@ static void ovl_put_super(struct super_block *sb)
 	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)
 {
 	struct ovl_fs *ofs = sb->s_fs_info;
@@ -253,12 +254,9 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
 	if (!ofs->upper_mnt)
 		return 0;
 	upper_sb = ofs->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);
+	ret = __sync_filesystem(upper_sb, wait);
 	up_read(&upper_sb->s_umount);
 	return ret;
 }
diff --git a/fs/sync.c b/fs/sync.c
index 83ac79a..76c913e 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -28,7 +28,7 @@
  * wait == 1 case since in that case write_inode() functions do
  * sync_dirty_buffer() and thus effectively write one block at a time.
  */
-static int __sync_filesystem(struct super_block *sb, int wait)
+int __sync_filesystem(struct super_block *sb, int wait)
 {
 	if (wait)
 		sync_inodes_sb(sb);
@@ -39,6 +39,7 @@ static int __sync_filesystem(struct super_block *sb, int wait)
 		sb->s_op->sync_fs(sb, wait);
 	return __sync_blockdev(sb->s_bdev, wait);
 }
+EXPORT_SYMBOL(__sync_filesystem);
 
 /*
  * Write out and wait upon all dirty data associated with this
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 885266a..99c2dd40 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2463,6 +2463,7 @@ static inline bool sb_is_blkdev_sb(struct super_block *sb)
 	return false;
 }
 #endif
+extern int __sync_filesystem(struct super_block *sb, int wait);
 extern int sync_filesystem(struct super_block *);
 extern const struct file_operations def_blk_fops;
 extern const struct file_operations def_chr_fops;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] ovl: Sync upper dirty data when sync overlayfs
  2017-11-29  2:01 [PATCH v4] ovl: Sync upper dirty data when sync overlayfs Chengguang Xu
@ 2017-12-07 10:19 ` Miklos Szeredi
  2017-12-07 11:03   ` Amir Goldstein
  2017-12-08  0:32   ` Chengguang Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Miklos Szeredi @ 2017-12-07 10:19 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: Amir Goldstein, linux-unionfs

On Wed, Nov 29, 2017 at 3:01 AM, Chengguang Xu <cgxu@mykernel.net> wrote:
> 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.

Do we really need to export __sync_filesystem()?

Just skipping wait == 0 and calling sync_filesystem() for wait == 1
should be equivalent.

Fixed up patch queued.  Let me know if I missed something...

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] ovl: Sync upper dirty data when sync overlayfs
  2017-12-07 10:19 ` Miklos Szeredi
@ 2017-12-07 11:03   ` Amir Goldstein
  2017-12-08  0:32   ` Chengguang Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2017-12-07 11:03 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Chengguang Xu, linux-unionfs

On Thu, Dec 7, 2017 at 12:19 PM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> On Wed, Nov 29, 2017 at 3:01 AM, Chengguang Xu <cgxu@mykernel.net> wrote:
>> 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.
>
> Do we really need to export __sync_filesystem()?
>
> Just skipping wait == 0 and calling sync_filesystem() for wait == 1
> should be equivalent.
>
> Fixed up patch queued.  Let me know if I missed something...
>

Looks right to me.
There is even a bonus - emergency_sync() will invoke a single
__sync_filesystem(sb, 0) underlying fs regardless of the number of
mounted overlayfs.

Amir.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] ovl: Sync upper dirty data when sync overlayfs
  2017-12-07 10:19 ` Miklos Szeredi
  2017-12-07 11:03   ` Amir Goldstein
@ 2017-12-08  0:32   ` Chengguang Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Chengguang Xu @ 2017-12-08  0:32 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Amir Goldstein, linux-unionfs


> 在 2017年12月7日,下午6:19,Miklos Szeredi <miklos@szeredi.hu> 写道:
> 
> On Wed, Nov 29, 2017 at 3:01 AM, Chengguang Xu <cgxu@mykernel.net> wrote:
>> 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.
> 
> Do we really need to export __sync_filesystem()?
> 
> Just skipping wait == 0 and calling sync_filesystem() for wait == 1
> should be equivalent.
> 
> Fixed up patch queued.  Let me know if I missed something…

Looks good to me.


Thanks,
Chengguang.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-08  0:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29  2:01 [PATCH v4] ovl: Sync upper dirty data when sync overlayfs Chengguang Xu
2017-12-07 10:19 ` Miklos Szeredi
2017-12-07 11:03   ` Amir Goldstein
2017-12-08  0:32   ` Chengguang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.