Bug 703399 - umount race condition
Summary: umount race condition
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 15
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-05-10 09:28 UTC by Albert Strasheim
Modified: 2011-08-09 12:40 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-09 12:40:30 UTC
Type: ---


Attachments (Terms of Use)
mount script (1.50 KB, text/plain)
2011-05-10 09:28 UTC, Albert Strasheim
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Linux Kernel 32312 0 None None None Never
Red Hat Bugzilla 683836 0 unspecified CLOSED ext4 crash and umount race condition 2021-02-22 00:41:40 UTC

Internal Links: 683836

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...


Note You need to log in before you can comment on or make changes to this bug.