From: Vivek Goyal <vgoyal@xxxxxxxxxx> When user chose the option of copying up a file when mmap(MAP_SHARED) happens, then do full copy up and not just metacopy. Signed-off-by: Vivek Goyal <vgoyal@xxxxxxxxxx> Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx> Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx> --- fs/overlayfs/copy_up.c | 5 +++++ fs/overlayfs/file.c | 2 +- fs/overlayfs/overlayfs.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 8c05e9ad9782..c31f198bed99 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -867,6 +867,11 @@ int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags) return err; } +int ovl_copy_up_with_data(struct dentry *dentry) +{ + return ovl_copy_up_flags(dentry, O_WRONLY); +} + int ovl_copy_up(struct dentry *dentry) { return ovl_copy_up_flags(dentry, 0); diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index c7738ef492c8..953295774471 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -296,7 +296,7 @@ static int ovl_pre_mmap(struct file *file, unsigned long prot, * later. */ if ((flag & MAP_SHARED) && ovl_copy_up_shared(file_inode(file)->i_sb)) - err = ovl_copy_up(file_dentry(file)); + err = ovl_copy_up_with_data(file_dentry(file)); return err; } diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 24f1d0e8a178..93c84929d422 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -414,6 +414,7 @@ extern const struct file_operations ovl_file_operations; /* copy_up.c */ int ovl_copy_up(struct dentry *dentry); +int ovl_copy_up_with_data(struct dentry *dentry); int ovl_copy_up_flags(struct dentry *dentry, int flags); int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); int ovl_copy_xattr(struct dentry *old, struct dentry *new); -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html