diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index ded8bfeb193ebde911676444174a6ea35a0540c7..a2a65120c9d04dbc0d4c5dd0de5baa1c133b8ad5 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -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);