cleandir: Fix ESTALE errors from parallel removals.
authorbdrewery <bdrewery@FreeBSD.org>
Tue, 25 Jul 2017 00:12:48 +0000 (00:12 +0000)
committerbdrewery <bdrewery@FreeBSD.org>
Tue, 25 Jul 2017 00:12:48 +0000 (00:12 +0000)
commit9628714bcbe1c15cde393acc201d816dc8d1becc
tree4618e3f96c9a875fde60a1ae2b200ae720960244
parentb3242cc7cf0b7bb8e68c15416f289d3aa1670a62
cleandir: Fix ESTALE errors from parallel removals.

This fixes 'make cleandir' to use the same ordering as 'make cleanobj'.
Meaning that SUBDIR will be recursed before the current directory is
handled.  This avoids an 'rm -rf /usr/obj/usr/src/lib/libc' while
a child 'rm -rf /usr/obj/usr/src/lib/libc/tests' is being ran next,
or even removing the current directory and then recursing into a child
and using the 'missing OBJDIR' logic to remove files rather than the
directory.

The most ideal ordering here would be for 'cleanobj' and 'cleandir' to
simply remove the .OBJDIR and then not recurse at all.  This is only
safe if it is guaranteed that all children directories have no orphaned
files in their source checkout and are only using obj directories.  This
is usually safe from the top-level build targets and when using
WITH_AUTO_OBJ.  Improving the build for those cases is coming.

Reported by: cperciva, scottl
X-MFC-With: r321427
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
share/mk/bsd.obj.mk