On Mon, Jun 19, 2017 at 10:59 AM, Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > On Mon, Jun 19, 2017 at 6:00 AM, zhangyi (F) <yi.zhang@xxxxxxxxxx> wrote: >> There is another problem about impure upper dir which have left >> whiteout files(the first one is whiteout exposure). If an >> "impure && not merged" upper dir have left whiteout files >> (last mount created), ovl cannot clear this dir when we >> removing it, which may lead to rmdir fail or temp file left >> in workdir. >> >> 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 are not creat this file, the result is different: >> rm: cannot remove "dir/": Directory not empty >> >> This patch add impure flag on parent dir in ovl_remove_and_whiteout() >> to indicate the dir is impure, and then check and clean it when >> removing this dir. > > I still don't like adding the impure flag because of a whiteout. > Impure dir means it contains a copied up object. In fact a valid (but > probably not worthwhile) optimizition would be to remove the impure > flag on removal of the last copied up object. > > What's wrong with testing for (origin || merge) to see if we need to > check for whiteouts? > Fine by me. Yi, Please note that you cannot use the test OVL_TYPE_ORIGIN(type) in ovl_dir_is_real(), because that flag is only set when the lower dentry is found by lookup. Instead, you should explicitly check for existence of OVL_XATTR_ORIGIN. Note that even ovl_get_origin_fh() is too strict, because it discards empty (unkown) origin, but for your use case, unknown origin is also candidate to contain whiteouts. Amir. -- To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html