summaryrefslogtreecommitdiff
path: root/fs/overlayfs/namei.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-06-21 13:46:12 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2017-07-04 23:03:19 +0300
commitcaf70cb2ba5dff85ea90f494a30075af92df13b0 (patch)
treed93982b090f4ff5f56a733e8aec083959f4a567a /fs/overlayfs/namei.c
parent5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c (diff)
downloadlinux-caf70cb2ba5dff85ea90f494a30075af92df13b0.tar.xz
ovl: cleanup orphan index entries
index entry should live only as long as there are upper or lower hardlinks. Cleanup orphan index entries on mount and when dropping the last overlay inode nlink. When about to cleanup or link up to orphan index and the index inode nlink > 1, admit that something went wrong and adjust overlay nlink to index inode nlink - 1 to prevent it from dropping below zero. This could happen when adding lower hardlinks underneath a mounted overlay and then trying to unlink them. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/namei.c')
-rw-r--r--fs/overlayfs/namei.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 2d8b6292fe21..9bc0e580a5b3 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -425,6 +425,11 @@ int ovl_verify_index(struct dentry *index, struct path *lowerstack,
if (err)
goto fail;
+ /* Check if index is orphan and don't warn before cleaning it */
+ if (d_inode(index)->i_nlink == 1 &&
+ ovl_get_nlink(index, origin.dentry, 0) == 0)
+ err = -ENOENT;
+
dput(origin.dentry);
out:
kfree(fh);