diff mbox

[2/2] ovl: properly implement sync_filesystem()

Message ID 1484828008-27507-3-git-send-email-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amir Goldstein Jan. 19, 2017, 12:13 p.m. UTC
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 should fix correctness of syncfs(2) and fsfreeze(8).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/super.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Christoph Hellwig Jan. 24, 2017, 5:14 p.m. UTC | #1
s/sync_filesystem()/->sync_fs/ in the subject?

Otherwise this looks fine to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Amir Goldstein Jan. 25, 2017, 5:51 p.m. UTC | #2
On Tue, Jan 24, 2017 at 7:14 PM, Christoph Hellwig <hch@infradead.org> wrote:
> s/sync_filesystem()/->sync_fs/ in the subject?
>

Sure. Thanks.

Just waiting for feedback from Miklos before I decide if I re-post
with or without
 overlay freeze support.

> Otherwise this looks fine to me:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 0f8a9c8..5dc1d42 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -160,6 +160,25 @@  static void ovl_put_super(struct super_block *sb)
 	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;
+}
+
 static int ovl_freeze(struct super_block *sb)
 {
 	struct ovl_fs *ufs = sb->s_fs_info;
@@ -236,6 +255,7 @@  static int ovl_remount(struct super_block *sb, int *flags, char *data)
 
 static const struct super_operations ovl_super_operations = {
 	.put_super	= ovl_put_super,
+	.sync_fs	= ovl_sync_fs,
 	.freeze_fs	= ovl_freeze,
 	.unfreeze_fs	= ovl_unfreeze,
 	.statfs		= ovl_statfs,