PROGS: Fix ESTALE errors on NFS while cleaning in directories with PROGS.

- Only recurse on cleanobj/cleandir if there is no .OBJDIR being used.
  If we don't recurse then bsd.obj.mk will just rm -rf the OBJDIR dir.
- When recursing on cleanobj/cleandir don't remove dependfiles/dirs
  redundantly from the child and main processes.  Meaning '.depend', and
  'tags', and '.depend.*' will now only be removed from the main
  process.
- Stop recursing on 'cleandepend' since the main process can handle
  removing all files via the default glob patterns in CLEANDEPENDFILES.
- This reverts r288201, by readding recursion on 'cleanobj', due to
  r291635 changing how bsd.subdir.mk handles recursion.

This is primarily targeting ESTALE NFS errors from rm(1) during a
buildworld but is also a performance optimization as both issues fixed
were redundant anyway.

Reported by:	cperciva, scottl
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Bryan Drewery 2017-07-24 17:54:03 +00:00
parent 2ae976822c
commit 1335398624
2 changed files with 12 additions and 2 deletions

View File

@ -157,6 +157,7 @@ whereobj:
@echo ${.OBJDIR}
.endif
# Same check in bsd.progs.mk
.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/)
cleanobj:
-rm -rf ${CANONICALOBJDIR}

View File

@ -116,7 +116,16 @@ ${_PROGS_COMMON_OBJS}: .NOMETA
.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
# tell progs.mk we might want to install things
PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
PROGS_TARGETS+= checkdpadd clean depend install
# Only handle removing depend files from the main process.
_PROG_MK.cleandir= CLEANDEPENDFILES= CLEANDEPENDDIRS=
_PROG_MK.cleanobj= CLEANDEPENDFILES= CLEANDEPENDDIRS=
# Only recurse on these if there is no objdir, meaning a normal
# 'clean' gets ran via the target defined in bsd.obj.mk.
# Same check from cleanobj: in bsd.obj.mk
.if ${CANONICALOBJDIR} == ${.CURDIR} || !exists(${CANONICALOBJDIR}/)
PROGS_TARGETS+= cleandir cleanobj
.endif
# Ensure common objects are built before recursing.
.if !empty(_PROGS_COMMON_OBJS)
@ -142,7 +151,7 @@ $p.$t: .PHONY .MAKE
(cd ${.CURDIR} && \
DEPENDFILE=.depend.$p \
NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
PROG=$p ${x.$p} ${@:E})
${_PROG_MK.${t}} PROG=$p ${x.$p} ${@:E})
.endfor
.endfor