Bug 718739

Summary: /etc/init.d/halt:__umount_loop() skips autofs, breaking halt and reboot
Product: [Fedora] Fedora Reporter: Frank van Maarseveen <frankvm>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14CC: iarlyy, jonathan, k.georgiou, notting, plautrba, rvokal, vpavlin
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-20 10:11:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Frank van Maarseveen 2011-07-04 13:19:58 UTC
Description of problem:

The "halt" and "reboot" commands fail to umount a remaining autofs
mount which could not be umounted at the time autofs was stopped
by initscripts. When autofs is configured to mount a tree (e.g. in a
/etc/auto.net setup) then submounts are done on top of an autofs mount for
that same mountpoint. So, not only the remaining mounts via autofs but
also internal autofs mounts need to be umounted. Unfortunately the shell
function __umount_loop() in /etc/init.d/halt skips autofs. Fix is to not
make an exception there for autofs.

An optimized /etc/auto.net script (a program map) uses bind mounts
when the local host is involved. Example output of such a script with
'localhost' as argument:

        /       :/ \
        /home   :/home \

command sequence to trigger issue:

	cd /net/localhost/home
	sleep 123456 >foo &	# keep it in use
	cd
	reboot			# as root

/proc/mounts after stopping autofs manually looks as follows (edited to
clarify a bit):

	/dev/sda1 / ext4 ...
	/dev/sda2 /home ext4 ...
	...
	/dev/sda1 /net/localhost ext4 ...
	/etc/auto.net /net/localhost/home autofs ...
	/dev/sda2 /net/localhost/home ext4 ...

Halt and reboot will end up executing __umount_loop() and thus:

	fuser -k -m /net/localhost >/dev/null

because /net/localhost cannot be umounted (in use by autofs submount).
Now because fuser doesn't understand bind mounts above fuser command
will kill every process on the system including initscripts.
Removing the autofs exception in /etc/init.d/halt fixes the problem.

Version-Release number of selected component (if applicable):

	9.20.0-1.fc14.1

How reproducible:

	very well

Steps to Reproduce:

	See above
  
Actual results:

	initscript (fuser actually) prints:

		crcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcrcr

	with an occasional 'e' in between and reboot/halt stops forever with
	filesystems still mounted r/w.

Expected results:

	reboot/halt

Additional info:

	initscripts and its use of fuser is broken w.r.t. bind
	mounts. killing all processes which have files open or a current
	working directory beneath some path is easy (e.g. in python
	by reading /proc) and could replace fuser.

Comment 1 Bill Nottingham 2011-07-05 18:46:13 UTC
This is 'fixed' in F-15 and later by not using this code, and using systemd. Obviously that doesn't really help Fedora 14, though.