From: Chengguang Xu <cgxu@mykernel.net>
To: miklos@szeredi.hu, amir73il@gmail.com
Cc: linux-unionfs@vger.kernel.org, Chengguang Xu <cgxu@mykernel.net>
Subject: [PATCH v3] ovl: Sync upper dirty data when sync overlayfs
Date: Tue, 28 Nov 2017 20:39:28 +0800 [thread overview]
Message-ID: <1511872768-12759-1-git-send-email-cgxu@mykernel.net> (raw)
Executes filesystem sync or umount on overlayfs,
dirty data does not be 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 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 f5738e9..736f04d 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -231,6 +231,7 @@ static void ovl_put_super(struct super_block *sb)
kfree(ufs);
}
+/* Sync real dirty inodes in upper filesystem (if it exists) */
static int ovl_sync_fs(struct super_block *sb, int wait)
{
struct ovl_fs *ufs = sb->s_fs_info;
@@ -240,12 +241,9 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
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);
+ 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
next reply other threads:[~2017-11-28 12:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 12:39 Chengguang Xu [this message]
2017-11-28 14:58 ` [PATCH v3] ovl: Sync upper dirty data when sync overlayfs Amir Goldstein
2017-11-29 3:01 ` Chengguang Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511872768-12759-1-git-send-email-cgxu@mykernel.net \
--to=cgxu@mykernel.net \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox