ovl: cleanup orphan index entries
authorAmir Goldstein <amir73il@gmail.com>
Wed, 21 Jun 2017 10:46:12 +0000 (13:46 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 4 Jul 2017 20:03:19 +0000 (22:03 +0200)
commitcaf70cb2ba5dff85ea90f494a30075af92df13b0
treed93982b090f4ff5f56a733e8aec083959f4a567a
parent5f8415d6b87ecb4ebf1bbd02c538694ebb7fb57c
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>
fs/overlayfs/inode.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h
fs/overlayfs/super.c
fs/overlayfs/util.c