Control: tags -1 patch On Fri, Mar 08, 2019 at 09:45:51PM +0000, Pierre Ynard wrote: > > I looked into this issue a bit more, and it looks like all I needed > > to do is remove the /var/run/network/mountnfs lock directory to get > > it working again. Either there was a bad version sometime that didn't > > clean it up or something crashed or killed it before it could remove > > the directory, but it seems to work fine now. > > Interesting choice to lock using mkdir, considering that a stray > /var/run/network/mountnfs lock would never get removed by bootclean.sh > because it's a directory. I'm going to assume that's what happened then.
I imagine that it is leftover from the time when /usr/bin/flock might not be available in early boot (if /usr was on NFS). > Nowadays /run is a tmpfs so that issue is mostly moot. > > I suppose we could still improve that locking or make sure stray locks > are properly removed before mountnfs operations are started. I have cleaned up the lockdir handling a bit (use /run directly and register the cleanup handler immediately) and added the lockdir to clean_all (do I have the find operator precedence right?). Patches attached. I would be grateful for review, sanity checks and actual testing. Thanks Mark commit a6ef76068affc3421ee03599aca5480348a7e8df Author: Mark Hindley <m...@hindley.org.uk> Date: Thu Feb 13 20:36:11 2025 +0000 if-up.d/mountnfs: refactor to use /run and minimise time before registering lockdir cleanup handler. diff --git a/debian/src/initscripts/etc/network/if-up.d/mountnfs b/debian/src/initscripts/etc/network/if-up.d/mountnfs index 9b1f47f2..f428da61 100644 --- a/debian/src/initscripts/etc/network/if-up.d/mountnfs +++ b/debian/src/initscripts/etc/network/if-up.d/mountnfs @@ -157,28 +157,25 @@ if [ no != "$ASYNCMOUNTNFS" ]; then [ "$ADDRFAM" = "inet" ] || [ "$ADDRFAM" = "inet6" ] || exit 0 - # Lock around this otherwise insanity may occur - mkdir /var/run/network 2>/dev/null || true - # Wait until all auto interfaces are up before attempting to mount # network file systems. exit_unless_last_interface - if mkdir /var/run/network/mountnfs 2>/dev/null ; then - : + on_exit() { + # Clean up lock when script exits, even if interrupted + rm -rf /run/network/mountnfs 2>/dev/null || exit 0 + } + # Lock around this otherwise insanity may occur + mkdir /run/network 2>/dev/null || true + if mkdir /run/network/mountnfs 2>/dev/null ; then + trap on_exit EXIT # Enable cleanup handler else - msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting" + msg="if-up.d/mountnfs[$IFACE]: lock /run/network/mountnfs exists, not mounting" log_failure_msg "$msg" # Log if /usr/ is mounted [ -x /usr/bin/logger ] && /usr/bin/logger -t "if-up.d/mountnfs[$IFACE]" "$msg" exit 0 fi - - on_exit() { - # Clean up lock when script exits, even if it is interrupted - rmdir /var/run/network/mountnfs 2>/dev/null || exit 0 - } - trap on_exit EXIT # Enable emergency handler do_start elif [ yes = "$FROMINITD" ] ; then do_start commit c09ff84210e7d991fc9e5c99a0ae7a6680083dc6 Author: Mark Hindley <m...@hindley.org.uk> Date: Thu Feb 13 20:38:58 2025 +0000 Ensure stray /run/network/mountnfs lockdir is also cleaned. Closes: #608862 diff --git a/debian/src/initscripts/lib/init/bootclean.sh b/debian/src/initscripts/lib/init/bootclean.sh index 03a593e2..605adefb 100644 --- a/debian/src/initscripts/lib/init/bootclean.sh +++ b/debian/src/initscripts/lib/init/bootclean.sh @@ -179,7 +179,7 @@ clean_all() log_begin_msg "Cleaning up temporary files..." ES=0 clean_tmp || ES=1 - clean /run "! -xtype d ! -name utmp ! -name innd.pid" || ES=1 + clean /run "( -path /run/network/mountnfs -o ! -xtype d ! -name utmp ! -name innd.pid )" || ES=1 clean /run/lock "! -type d" || ES=1 clean /run/shm "! -type d" || ES=1 log_end_msg $ES