Bug 703399

Summary: umount race condition
Product: [Fedora] Fedora Reporter: Albert Strasheim <fullung>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 15CC: esandeen, fullung, gansalmon, itamar, jonathan, kernel-maint, kzak, lczerner, madhu.chinakonda
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-09 12:40:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
mount script none

Description Albert Strasheim 2011-05-10 09:28:05 UTC
Created attachment 497978 [details]
mount script

Description of problem:

Doing multiple umounts in parallel of a bunch of ext4 file systems causes
umount to return "not mounted" for some file systems, even if /etc/mtab is a
symlink to /proc/mounts.

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

kernel-2.6.38.4-20.fc15.x86_64

How reproducible:

Always

Steps to Reproduce:
1. boot with loop.max_loop=256
2. sudo ./testext4.py
3. cat /proc/mounts | grep /dev/loop | cut -d " " -f 1 | perl -ne 's/^/sudo
umount /; s/$/&/; print' | sh -x

Actual results:

A few of the umounts fail with "not mounted". If you check /proc/mounts, the
file systems are in fact mounted and another attempt to umount them succeeds.

I am running on a machine with 24 cores.

Comment 1 Lukáš Czerner 2011-05-10 09:41:10 UTC
The problem happens here at fs/namespace.c in umount syscall:

        retval = -EINVAL;
        if (path.dentry != path.mnt->mnt_root)
                goto dput_and_out;

I'll look more closely at why this is happening.

-Lukas

Comment 2 Chuck Ebbert 2011-05-10 12:06:00 UTC
Please don't copy kernel maintainers - we already get copies of all bugzilla mail.

Comment 3 Lukáš Czerner 2011-05-10 12:18:34 UTC
Btw, this fails on upstream kernel as well. Also it fails only if you are trying to umount it using the device, not mount point.

This works without any problems (for me):

1. boot with loop.max_loop=256
2. sudo ./testext4.py
3. cat /proc/mounts | grep /dev/loop | cut -d " " -f 2 | perl -ne 's/^/sudo
umount /; s/$/&/; print' | sh -x

-Lukas

Comment 4 Eric Sandeen 2011-05-10 16:05:06 UTC
I think that this is not ext4-specific either, correct?

thanks,
-Eric

Comment 5 Albert Strasheim 2011-05-10 16:09:34 UTC
Yes, I reproduced the same behavior with XFS.

Comment 6 Lukáš Czerner 2011-05-10 16:16:17 UTC
(In reply to comment #4)
> I think that this is not ext4-specific either, correct?
> 

Oh, I am sorry I have not made it clear, no it is not ext4 specific.

-Lukas

Comment 7 Eric Sandeen 2011-05-10 16:21:04 UTC
That's fine, I thought so, just wanted to be sure.

Thanks!
-Eric

Comment 8 Albert Strasheim 2011-07-19 10:57:51 UTC
Any news on this one?

Comment 9 Lukáš Czerner 2011-08-09 12:08:22 UTC
Karel Zak should have better insight into the problem. Assigning to him.

Comment 10 Karel Zak 2011-08-09 12:40:30 UTC
Few notes:

- in Fedora 15 is mtab symlink to /proc/mounts (!)

- umount(8) should be called with directory name rather than device name (see umount(8) man page), umount by device name is bad idea for many reasons...

- it was never supported to umount by loopdev name on systems with regular mtab
  (note that we're talking about loopdevs created by mount -o loop)
  
In the regular mtab is the backing file instead of the device name. The translation from the device to the backing file is possible on kernel >= 2.6.37 where kernel exports the loopdev information in sysfs. 

This is reason why this feature is not implemented yet. (Anyway this feature is *unnecessary* on systems where mtab is symlink to /proc/mounts.)

I'll add this as a feature request to the util-linux upstream TODO file.

You have to update your scripts to use directory names, for example:

  for x in $(findmnt -r -o MAJ:MIN,TARGET | awk '/7:/ { print $2 }'); do 
    sudo umount $x;
  done
 
Closing...