]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/overlayfs/inode.c
ovl: respect FIEMAP_FLAG_SYNC flag
[linux.git] / fs / overlayfs / inode.c
index 7c7092aaf9b40912120b5f0c3ba8a642265a04e3..5014749fd4b45d346f9c3d4f13495814437cf3d2 100644 (file)
@@ -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;
 
@@ -460,6 +467,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                return -EOPNOTSUPP;
 
        old_cred = ovl_override_creds(inode->i_sb);
+
+       if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC)
+               filemap_write_and_wait(realinode->i_mapping);
+
        err = realinode->i_op->fiemap(realinode, fieinfo, start, len);
        revert_creds(old_cred);