Skip to content

Commit

Permalink
ovl: fsync after copy-up
Browse files Browse the repository at this point in the history
Make sure the copied up file hits the disk before renaming to the final
destination.  If this is not done then the copy-up may corrupt the data in
the file in case of a crash.

Signed-off-by: Miklos Szeredi <[email protected]>
Cc: <[email protected]>
  • Loading branch information
Miklos Szeredi committed Oct 31, 2016
1 parent b93d4a0 commit 641089c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/overlayfs/copy_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len)
len -= bytes;
}

if (!error)
error = vfs_fsync(new_file, 0);
fput(new_file);
out_fput:
fput(old_file);
Expand Down

0 comments on commit 641089c

Please sign in to comment.