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.
Unified · Split
| @@ -392,10 +392,15 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir, · 391 unmodified lines | |||
| 392 | /* | 392 | /* |
| 393 | * Store identifier of lower inode in upper inode xattr to | 393 | * Store identifier of lower inode in upper inode xattr to |
| 394 | * allow lookup of the copy up origin inode. | 394 | * allow lookup of the copy up origin inode. |
| 395 | * | ||
| 396 | * Don't set origin when we are breaking the association with a lower | ||
| 397 | * hard link. | ||
| 395 | */ | 398 | */ |
| 396 | err = ovl_set_origin(dentry, lowerpath->dentry, temp); | 399 | if (S_ISDIR(stat->mode) || stat->nlink == 1) { |
| 397 | if (err) | 400 | err = ovl_set_origin(dentry, lowerpath->dentry, temp); |
| 398 | goto out_cleanup; | 401 | if (err) |
| 402 | goto out_cleanup; | ||
| 403 | } | ||
| 399 | 404 | ||
| 400 | upper = lookup_one_len(dentry->d_name.name, upperdir, | 405 | upper = lookup_one_len(dentry->d_name.name, upperdir, |
| 401 | dentry->d_name.len); | 406 | dentry->d_name.len); |