summaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/copy_up.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-06-20 15:35:14 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2017-07-04 22:03:19 +0200
commit5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c (patch)
treed3764780b95675c7d834ae4ba0d3d834bb9fc6e9 /fs/overlayfs/copy_up.c
parent59be09712ab98a3060f13e31343c7abb9bc4583d (diff)
downloadlinux-5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c.tar.gz
linux-5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c.tar.bz2
linux-5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c.zip
ovl: persistent overlay inode nlink for indexed inodes
With inodes index enabled, an overlay inode nlink counts the union of upper and non-covered lower hardlinks. During the lifetime of a non-pure upper inode, the following nlink modifying operations can happen: 1. Lower hardlink copy up 2. Upper hardlink created, unlinked or renamed over 3. Lower hardlink whiteout or renamed over For the first, copy up case, the union nlink does not change, whether the operation succeeds or fails, but the upper inode nlink may change. Therefore, before copy up, we store the union nlink value relative to the lower inode nlink in the index inode xattr trusted.overlay.nlink. For the second, upper hardlink case, the union nlink should be incremented or decremented IFF the operation succeeds, aligned with nlink change of the upper inode. Therefore, before link/unlink/rename, we store the union nlink value relative to the upper inode nlink in the index inode. For the last, lower cover up case, we simplify things by preceding the whiteout or cover up with copy up. This makes sure that there is an index upper inode where the nlink xattr can be stored before the copied up upper entry is unlink. Return the overlay inode nlinks for indexed upper inodes on stat(2). Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/copy_up.c')
-rw-r--r--fs/overlayfs/copy_up.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 9f5a47338e59..f193976560de 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -323,6 +323,10 @@ static int ovl_link_up(struct dentry *parent, struct dentry *dentry)
struct dentry *upperdir = ovl_dentry_upper(parent);
struct inode *udir = d_inode(upperdir);
+ err = ovl_set_nlink_lower(dentry);
+ if (err)
+ return err;
+
inode_lock_nested(udir, I_MUTEX_PARENT);
upper = lookup_one_len(dentry->d_name.name, upperdir,
dentry->d_name.len);
@@ -335,6 +339,7 @@ static int ovl_link_up(struct dentry *parent, struct dentry *dentry)
ovl_dentry_set_upper_alias(dentry);
}
inode_unlock(udir);
+ ovl_set_nlink_upper(dentry);
return err;
}