diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 7c7092aaf9b4..e0bb217c01e2 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -19,6 +19,7 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) { int err; + bool full_copy_up = false; struct dentry *upperdentry; const struct cred *old_cred; @@ -36,9 +37,15 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) err = -ETXTBSY; if (atomic_read(&realinode->i_writecount) < 0) goto out_drop_write; + + /* Truncate should trigger data copy up as well */ + full_copy_up = true; } - err = ovl_copy_up(dentry); + if (!full_copy_up) + err = ovl_copy_up(dentry); + else + err = ovl_copy_up_with_data(dentry); if (!err) { struct inode *winode = NULL;