[RFC PATCH] ovl: fsync parent directory in copy-up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Calling fsync for parent directory in copy-up to
ensure the change get synced.

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxxxxxxx>
---
 fs/overlayfs/copy_up.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index e040970408d4..52ca915f04a3 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -944,6 +944,7 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 {
 	int err;
 	DEFINE_DELAYED_CALL(done);
+	struct file *parent_file = NULL;
 	struct path parentpath;
 	struct ovl_copy_up_ctx ctx = {
 		.parent = parent,
@@ -972,6 +973,12 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 				  AT_STATX_SYNC_AS_STAT);
 		if (err)
 			return err;
+
+		parent_file = ovl_path_open(&parentpath, O_WRONLY);
+		if (IS_ERR(parent_file)) {
+			err = PTR_ERR(parent_file);
+			return err;
+		}
 	}
 
 	/* maybe truncate regular file. this has no effect on dirs */
@@ -998,6 +1005,14 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
 			err = ovl_copy_up_meta_inode_data(&ctx);
 		ovl_copy_up_end(dentry);
 	}
+
+	if (!err) {
+		if (parent_file) {
+			vfs_fsync(parent_file, 0);
+			fput(parent_file);
+		}
+	}
+
 	do_delayed_call(&done);
 
 	return err;
-- 
2.27.0






[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux