kernel_optimize_test/fs/overlayfs
zhangyi (F) 07f6fff148 ovl: fix rmdir problem on non-merge dir with origin xattr
An "origin && non-merge" upper dir may have leftover whiteouts that
were created in past mount. overlayfs does no clear this dir when we
delete it, which may lead to rmdir fail or temp file left in workdir.

Simple reproducer:
  mkdir lower upper work merge
  mkdir -p lower/dir
  touch lower/dir/a
  mount -t overlay overlay -olowerdir=lower,upperdir=upper,\
    workdir=work merge
  rm merge/dir/a
  umount merge
  rm -rf lower/*
  touch lower/dir  (*)
  mount -t overlay overlay -olowerdir=lower,upperdir=upper,\
    workdir=work merge
  rm -rf merge/dir

Syslog dump:
  overlayfs: cleanup of 'work/#7' failed (-39)

(*): if we do not create the regular file, the result is different:
  rm: cannot remove "dir/": Directory not empty

This patch adds a check for the case of non-merge dir that may contain
whiteouts, and calls ovl_check_empty_dir() to check and clear whiteouts
from upper dir when an empty dir is being deleted.

[amir: split patch from ovl_check_empty_dir() cleanup
       rename ovl_is_origin() to ovl_may_have_whiteouts()
       check OVL_WHITEOUTS flag instead of checking origin xattr]

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2017-11-09 10:23:27 +01:00
..
copy_up.c ovl: no direct iteration for dir with origin xattr 2017-11-09 10:23:26 +01:00
dir.c ovl: fix rmdir problem on non-merge dir with origin xattr 2017-11-09 10:23:27 +01:00
inode.c ovl: no direct iteration for dir with origin xattr 2017-11-09 10:23:26 +01:00
Kconfig ovl: introduce the inodes index dir feature 2017-07-04 22:03:17 +02:00
Makefile ovl: split super.c 2016-12-16 11:02:56 +01:00
namei.c ovl: do not cleanup unsupported index entries 2017-10-24 16:06:17 +02:00
overlayfs.h ovl: no direct iteration for dir with origin xattr 2017-11-09 10:23:26 +01:00
ovl_entry.h ovl: fix regression caused by exclusive upper/work dir protection 2017-10-05 15:53:18 +02:00
readdir.c ovl: simplify ovl_check_empty_and_clear() 2017-11-09 10:23:27 +01:00
super.c ovl: no direct iteration for dir with origin xattr 2017-11-09 10:23:26 +01:00
util.c ovl: no direct iteration for dir with origin xattr 2017-11-09 10:23:26 +01:00