Bug 147254

Summary: shutdown results in "Device or resource busy" from umount2 and "device is busy" messages from umount when a filesystem is mounted on top of another filesystem.
Product: [Fedora] Fedora Reporter: James Hunt <jamesodhunt>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: gajownik, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 8.08-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-04-15 20:07:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 136451    

Description James Hunt 2005-02-05 08:52:33 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041111 Firefox/1.0

Description of problem:
If you create any filesystems that are mounted below a directory other
than the root directory, Fedora will barf on shutdown. For example,
if I create and mount filesystems "/hello" and "/hello/world",
shutdown gives a message like this:

------------------------------------
umount2: Device or resource busy
umount: /hello: device is busy
umount2: Device or resource busy
umount: /hello: device is busy
------------------------------------


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

How reproducible:
Always

Steps to Reproduce:
1. mount a filesystem as "/hello".
2. mount a filesystem as "/hello/world".
3. run, "shutdown -h now".
4. watch the console.
    

Actual Results:  
------------------------------------
umount2: Device or resource busy
umount: /hello: device is busy
umount2: Device or resource busy
umount: /hello: device is busy
------------------------------------

There is then a delay until the machine forcibly reboots. As such,
this bug is causing an unnecessary performance problem.

Expected Results:  I would expect no output and no errors from the
umount commands.

Additional info:

The problem appears to lie in "/etc/init.d/halt" line 201:

------------------------------------
# Try all file systems other than root and RAM disks, one last time.
mount |  awk '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc )/ { print $3 }'
| \
  while read line; do
    umount -f $line
done
------------------------------------
This code is incorrect since it does not reverse the order of the
mounts as returned by the "mount" command. As such, if I have these
two filesystems mounted:

/hello
/hello/world

The code will fail to unmount "/hello" (since "/hello/world" is still
mounted), but will succeed in unmounting "/hello/world".

The fix is to reverse sort the output:

------------------------------------
# Try all file systems other than root and RAM disks, one last time.
mount |  awk '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc )/ { print $3 }'
| sort -r \
  while read line; do
    umount -f $line
done
------------------------------------

Comment 1 Bill Nottingham 2005-04-15 20:07:16 UTC
Added in 8.08-1.