Skip to content

Commit

Permalink
ovl: don't set origin on broken lower hardlink
Browse files Browse the repository at this point in the history
When copying up a file that has multiple hard links we need to break any
association with the origin file.  This makes copy-up be essentially an
atomic replace.

The new file has nothing to do with the old one (except having the same
data and metadata initially), so don't set the overlay.origin attribute.

We can relax this in the future when we are able to index upper object by
origin.

Signed-off-by: Miklos Szeredi <[email protected]>
Fixes: 3a1e819 ("ovl: store file handle of lower inode on copy up")
  • Loading branch information
Miklos Szeredi committed Jun 28, 2017
1 parent e85f82f commit fbaf94e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/overlayfs/copy_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,15 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
/*
* Store identifier of lower inode in upper inode xattr to
* allow lookup of the copy up origin inode.
*
* Don't set origin when we are breaking the association with a lower
* hard link.
*/
err = ovl_set_origin(dentry, lowerpath->dentry, temp);
if (err)
goto out_cleanup;
if (S_ISDIR(stat->mode) || stat->nlink == 1) {
err = ovl_set_origin(dentry, lowerpath->dentry, temp);
if (err)
goto out_cleanup;
}

upper = lookup_one_len(dentry->d_name.name, upperdir,
dentry->d_name.len);
Expand Down

0 comments on commit fbaf94e

Please sign in to comment.