2000-11-30 01:16:59

by Dunlap, Randy

[permalink] [raw]
Subject: usbdevfs mount 2x, umount 1x

[I reported this a couple of months back. Got no
feedback on it. If it's just a DDT (don't do that)
or a user error, please say so.]

Summary: After I mount usbdevfs 2 times, and umount it
1 time, the usbcore module use count prevents it from
being rmmod-ed.

This is test12-pre2.


1. Start by loading usbcore and uhci modules:

[root@dragon rdunlap]# lsmod
Module Size Used by
uhci 18848 0 (unused)
usbcore 50656 0 [uhci]

and the /proc/bus/usb mount point is empty:

[rdunlap@dragon rdunlap]$ ls -l /proc/bus/usb
total 0

2. I enter "mount usb", which uses this entry
from /etc/fstab:
usb /proc/bus/usb usbdevfs defaults,user 0 0

'mount' then tells me (usb line extracted):

usb on /proc/bus/usb type usbdevfs (rw,noexec,nosuid,nodev)

and 'lsmod' tells me:

[root@dragon rdunlap]# lsmod
Module Size Used by
uhci 18848 0 (unused)
usbcore 50656 1 [uhci]

3. Some time passes. I mount usbdevfs again, by entering:

[root@dragon rdunlap]# mount -t usbdevfs usbdevfs /proc/bus/usb

'lsmod' now tells me:

[root@dragon rdunlap]# lsmod
Module Size Used by
uhci 18848 0 (unused)
usbcore 50656 2 [uhci]

and 'mount' tells me:

usb on /proc/bus/usb type usbdevfs (rw,noexec,nosuid,nodev)
usbdevfs on /proc/bus/usb type usbdevfs (rw)

4. I 'umount usbdevfs'. Now 'lsmod' tells me:

[root@dragon rdunlap]# umount usbdevfs
[root@dragon rdunlap]# lsmod
Module Size Used by
uhci 18848 0 (unused)
usbcore 50656 1 [uhci]

and 'mount' shows no usb or usbdevfs entries listed.

Now I rmmod uhci and 'lsmod' tells me:

[root@dragon rdunlap]# rmmod uhci
[root@dragon rdunlap]# lsmod
Module Size Used by
usbcore 50656 1

and I can't rmmod usbcore. The /proc/bus/usb mount
point is still populated and the 'drivers' file
contains correct data:

[rdunlap@dragon rdunlap]$ ls -l /proc/bus/usb
total 0
-r--r--r-- 1 root root 0 Nov 29 16:17 devices
-r--r--r-- 1 root root 0 Nov 29 16:17 drivers

[rdunlap@dragon rdunlap]$ cat /proc/bus/usb/drivers
hub
usbdevfs
[rdunlap@dragon rdunlap]$


So is this just a case of root being able to shoot self
in foot or a proc-fs or module counter problem?

Notes:
1. Reversing the order of steps 3 and 4 gives the
same results.
2. Changing the device name in
'mount -t usbdevfs usbdevfs /proc/bus/usb' to be
'mount -t usbdevfs usbfs /proc/bus/usb' gives the
same results (when followed by 'umount usbfs').

Thanks,
~Randy
--
_______________________________________________
|randy.dunlap_at_intel.com 503-677-5408|
|NOTE: Any views presented here are mine alone|
|& may not represent the views of my employer.|
-----------------------------------------------


2000-11-30 01:23:50

by Alexander Viro

[permalink] [raw]
Subject: Re: usbdevfs mount 2x, umount 1x



On Wed, 29 Nov 2000, Randy Dunlap wrote:

> [I reported this a couple of months back. Got no
> feedback on it. If it's just a DDT (don't do that)
> or a user error, please say so.]
>
> Summary: After I mount usbdevfs 2 times, and umount it
> 1 time, the usbcore module use count prevents it from
> being rmmod-ed.

So umount it twice. And yes, it's "don't do it, then". Every mount()
increments the use count. Every umount() decrements it. You want it
to become 0. Draw your conclusions...

2000-11-30 02:52:03

by Dunlap, Randy

[permalink] [raw]
Subject: RE: usbdevfs mount 2x, umount 1x

> > > So umount it twice.
> > I don't see a way to umount it twice or I would have done that.
> > Is there a way?
>
> Erm... Say umount one more time? If _that_ doesn't work - we've got a
> bug, either in umount(2) or in umount(8). Strace would be welcome.

Or I'm using an old version of umount (from RH 5.2) ?
I'll check on that and the strace.

~Randy

2000-11-30 02:52:22

by Dunlap, Randy

[permalink] [raw]
Subject: RE: usbdevfs mount 2x, umount 1x

> From: Alexander Viro [mailto:[email protected]]
>
> On Wed, 29 Nov 2000, Randy Dunlap wrote:
>
> > [I reported this a couple of months back. Got no
> > feedback on it. If it's just a DDT (don't do that)
> > or a user error, please say so.]
> >
> > Summary: After I mount usbdevfs 2 times, and umount it
> > 1 time, the usbcore module use count prevents it from
> > being rmmod-ed.
>
> So umount it twice.
I don't see a way to umount it twice or I would have done that.
Is there a way?

> And yes, it's "don't do it, then".
OK.

> Every mount() increments the use count.
Got that.

> Every umount() decrements it. You want it
> to become 0. Draw your conclusions...
Looks to me like umount unmounted it 2 times and decremented
the use count by 1.

I don't see a way for me to rmmod usbcore. As it is,
I have to reboot the system (or just DDT).

Thanks,
~Randy

2000-11-30 02:52:37

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: usbdevfs mount 2x, umount 1x

On Wed, Nov 29, 2000 at 04:47:27PM -0800, Randy Dunlap wrote:
>
> Summary: After I mount usbdevfs 2 times, and umount it
> 1 time, the usbcore module use count prevents it from
> being rmmod-ed.

> [root@dragon rdunlap]# lsmod
> usbcore 50656 2 [uhci]

> and 'mount' shows no usb or usbdevfs entries listed.

Are there usbdevfs entries in /proc/mount? Maybe 'umount' removes
too many entries from /etc/mtab...

MfG, JBG

--
Fehler eingestehen, Gr??e zeigen: Nehmt die Rechtschreibreform zur?ck!!!
/* Jan-Benedict Glaw <[email protected]> -- +49-177-5601720 */
keyID=0x8399E1BB fingerprint=250D 3BCF 7127 0D8C A444 A961 1DBD 5E75 8399 E1BB
"insmod vi.o and there we go..." (Alexander Viro on linux-kernel)


Attachments:
(No filename) (731.00 B)
(No filename) (240.00 B)
Download all attachments

2000-11-30 02:52:40

by Alexander Viro

[permalink] [raw]
Subject: RE: usbdevfs mount 2x, umount 1x



On Wed, 29 Nov 2000, Dunlap, Randy wrote:

> > From: Alexander Viro [mailto:[email protected]]
> >
> > On Wed, 29 Nov 2000, Randy Dunlap wrote:
> >
> > > [I reported this a couple of months back. Got no
> > > feedback on it. If it's just a DDT (don't do that)
> > > or a user error, please say so.]
> > >
> > > Summary: After I mount usbdevfs 2 times, and umount it
> > > 1 time, the usbcore module use count prevents it from
> > > being rmmod-ed.
> >
> > So umount it twice.
> I don't see a way to umount it twice or I would have done that.
> Is there a way?

Erm... Say umount one more time? If _that_ doesn't work - we've got a
bug, either in umount(2) or in umount(8). Strace would be welcome.

2000-11-30 23:39:16

by Dunlap, Randy

[permalink] [raw]
Subject: RE: usbdevfs mount 2x, umount 1x

> From: Jan-Benedict Glaw [mailto:[email protected]]
>
> On Wed, Nov 29, 2000 at 04:47:27PM -0800, Randy Dunlap wrote:
> >
> > Summary: After I mount usbdevfs 2 times, and umount it
> > 1 time, the usbcore module use count prevents it from
> > being rmmod-ed.
>
> > [root@dragon rdunlap]# lsmod
> > usbcore 50656 2 [uhci]
>
> > and 'mount' shows no usb or usbdevfs entries listed.
>
> Are there usbdevfs entries in /proc/mount? Maybe 'umount' removes
> too many entries from /etc/mtab...

Yes, that's how it looks to me also, so maybe it's not a kernel
problem. Thanks for the tip.

Here's more info, including the strace that Al Viro asked for.
I also made sure that I'm using mount & umount version 2.10o.
Please let me know if you need anything else.

~Randy


1. Start with empty slate: no modules, no usb mounts:

[root@localhost rdunlap]# lsmod
Module Size Used by

[root@localhost rdunlap]# mount
/dev/hdc5 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdc1 on /boot type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hdc7 on /home type ext2 (rw)
/dev/hdc6 on /usr type ext2 (rw)

[root@localhost rdunlap]# cat /proc/mounts
/dev/root / ext2 rw 0 0
/proc /proc proc rw 0 0
/dev/hdc1 /boot ext2 rw 0 0
none /dev/pts devpts rw 0 0
/dev/hdc7 /home ext2 rw 0 0
/dev/hdc6 /usr ext2 rw 0 0

2. insmod usbcore and mount 'usb':

[root@localhost rdunlap]# insmod usbcore
Using /lib/modules/2.4.0-test11/kernel/drivers/usb/usbcore.o

[root@localhost rdunlap]# cat /etc/fstab
/dev/hdc5 / ext2 defaults 1 1
/dev/hdc1 /boot ext2 defaults 1 2
none /dev/pts devpts mode=0620 0 0
/dev/hdc7 /home ext2 defaults 1 2
/dev/cdrom /mnt/cdrom auto user,noauto,nosuid,exec,nodev,ro 0 0
/dev/fd0 /mnt/floppy auto sync,user,noauto,nosuid,nodev 0 0
none /proc proc defaults 0 0
usb /proc/bus/usb usbdevfs defaults,user 0 0
/dev/hdc6 /usr ext2 defaults 1 2
/dev/hdc2 swap swap defaults 0 0

[root@localhost rdunlap]# mount usb

3. This gives us:

[root@localhost rdunlap]# lsmod
Module Size Used by
usbcore 52224 1

[root@localhost rdunlap]# mount
/dev/hdc5 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdc1 on /boot type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hdc7 on /home type ext2 (rw)
/dev/hdc6 on /usr type ext2 (rw)
usb on /proc/bus/usb type usbdevfs (rw,noexec,nosuid,nodev)

[root@localhost rdunlap]# cat /proc/mounts
/dev/root / ext2 rw 0 0
/proc /proc proc rw 0 0
/dev/hdc1 /boot ext2 rw 0 0
none /dev/pts devpts rw 0 0
/dev/hdc7 /home ext2 rw 0 0
/dev/hdc6 /usr ext2 rw 0 0
usb /proc/bus/usb usbdevfs rw,noexec,nosuid,nodev 0 0

4. A second mount (slightly different 'device' name = "usbfs") gives:

[root@localhost rdunlap]# mount -t usbdevfs usbfs /proc/bus/usb

[root@localhost rdunlap]# lsmod
Module Size Used by
usbcore 52224 2

[root@localhost rdunlap]# mount
/dev/hdc5 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdc1 on /boot type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hdc7 on /home type ext2 (rw)
/dev/hdc6 on /usr type ext2 (rw)
usb on /proc/bus/usb type usbdevfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbdevfs (rw)

[root@localhost rdunlap]# cat /proc/mounts
/dev/root / ext2 rw 0 0
/proc /proc proc rw 0 0
/dev/hdc1 /boot ext2 rw 0 0
none /dev/pts devpts rw 0 0
/dev/hdc7 /home ext2 rw 0 0
/dev/hdc6 /usr ext2 rw 0 0
usb /proc/bus/usb usbdevfs rw,noexec,nosuid,nodev 0 0
usbfs /proc/bus/usb usbdevfs rw 0 0

5. [root@localhost rdunlap]# strace -xv -o umount.st2 umount usb

gives (strace output at end):

[root@localhost rdunlap]# lsmod
Module Size Used by
usbcore 52224 1

[root@localhost rdunlap]# mount
/dev/hdc5 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdc1 on /boot type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hdc7 on /home type ext2 (rw)
/dev/hdc6 on /usr type ext2 (rw)
<<<<<<<<<<<<<<<<< no usb here >>>>>>>>>>>>>>>>>>>>>>

[root@localhost rdunlap]# cat /proc/mounts
/dev/root / ext2 rw 0 0
/proc /proc proc rw 0 0
/dev/hdc1 /boot ext2 rw 0 0
none /dev/pts devpts rw 0 0
/dev/hdc7 /home ext2 rw 0 0
/dev/hdc6 /usr ext2 rw 0 0
usb /proc/bus/usb usbdevfs rw,noexec,nosuid,nodev 0 0 <---------

6. Trying to umount the remaining usb mount:

[root@localhost rdunlap]# umount usb
umount: usb: not found

[root@localhost rdunlap]# umount /proc/bus/usb

[root@localhost rdunlap]# mount
/dev/hdc5 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdc1 on /boot type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hdc7 on /home type ext2 (rw)
/dev/hdc6 on /usr type ext2 (rw)

[root@localhost rdunlap]# cat /proc/mounts
/dev/root / ext2 rw 0 0
/proc /proc proc rw 0 0
/dev/hdc1 /boot ext2 rw 0 0
none /dev/pts devpts rw 0 0
/dev/hdc7 /home ext2 rw 0 0
/dev/hdc6 /usr ext2 rw 0 0

~~~~~~~~~~~~~~~~~~~~~~ strace of umount usb ~~~~~~~~~~~~~~~~~~~~~~

execve("/bin/umount", ["umount", "usb"], [/* 40 vars */]) = 0
brk(0) = 0x8050d98
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40013000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 5), st_ino=160174, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=64,
st_size=29498, st_atime=2000/11/30-14:33:00, st_mtime=2000/11/21-13:05:44,
st_ctime=2000/11/21-13:05:44}) = 0
old_mmap(NULL, 29498, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40014000
close(4) = 0
open("/lib/libc.so.6", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 5), st_ino=96012, st_mode=S_IFREG|0755,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=1832,
st_size=931348, st_atime=2000/11/30-14:33:00, st_mtime=2000/05/05-12:06:20,
st_ctime=2000/11/16-09:33:30}) = 0
read(4, "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00"..., 4096)
= 4096
old_mmap(NULL, 945852, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0x4001c000
mprotect(0x400fb000, 32444, PROT_NONE) = 0
old_mmap(0x400fb000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 4,
0xde000) = 0x400fb000
old_mmap(0x40100000, 11964, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40100000
close(4) = 0
munmap(0x40014000, 29498) = 0
getpid() = 2860
brk(0) = 0x8050d98
brk(0x8050dd0) = 0x8050dd0
brk(0x8051000) = 0x8051000
open("/usr/share/locale/locale.alias", O_RDONLY) = 4
fstat64(4, {st_dev=makedev(22, 6), st_ino=80004, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=2265,
st_atime=2000/11/30-14:32:13, st_mtime=2000/05/05-12:03:36,
st_ctime=2000/11/16-09:33:32}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40014000
read(4, "# Locale name alias data base.\n#"..., 4096) = 2265
brk(0x8052000) = 0x8052000
read(4, "", 4096) = 0
close(4) = 0
munmap(0x40014000, 4096) = 0
open("/usr/share/i18n/locale.alias", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/share/locale/en/LC_MESSAGES", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368270, st_mode=S_IFDIR|0755,
st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=4096,
st_atime=2000/11/30-04:02:07, st_mtime=2000/11/16-09:43:20,
st_ctime=2000/11/16-09:43:20}) = 0
close(4) = 0
open("/usr/share/locale/en/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368271, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=44,
st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 44, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40014000
close(4) = 0
open("/usr/share/locale/en/LC_MONETARY", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368272, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=93,
st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 93, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40015000
close(4) = 0
open("/usr/share/locale/en/LC_COLLATE", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368268, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=64,
st_size=29970, st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 29970, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40103000
close(4) = 0
open("/usr/share/locale/en/LC_TIME", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368274, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=508,
st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 508, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40016000
close(4) = 0
open("/usr/share/locale/en/LC_NUMERIC", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368273, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=27,
st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 27, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40017000
close(4) = 0
open("/usr/share/locale/en/LC_CTYPE", O_RDONLY) = 4
fstat(4, {st_dev=makedev(22, 6), st_ino=368269, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=184,
st_size=87756, st_atime=2000/11/30-14:32:13, st_mtime=2000/05/03-12:40:18,
st_ctime=2000/11/16-09:37:34}) = 0
old_mmap(NULL, 87756, PROT_READ, MAP_PRIVATE, 4, 0) = 0x4010b000
close(4) = 0
getuid() = 0
geteuid() = 0
brk(0x8054000) = 0x8054000
getcwd("/home/rdunlap", 4094) = 14
readlink("/home/rdunlap/usb", 0xbfffe8d4, 4095) = -1 ENOENT (No such file or
directory)
open("/etc/mtab", O_RDONLY) = 4
fstat64(4, {st_dev=makedev(22, 5), st_ino=160368, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=258,
st_atime=2000/11/30-14:29:56, st_mtime=2000/11/30-14:28:43,
st_ctime=2000/11/30-14:28:43}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40018000
read(4, "/dev/hdc5 / ext2 rw 0 0\nnone /pr"..., 4096) = 258
read(4, "", 4096) = 0
close(4) = 0
munmap(0x40018000, 4096) = 0
oldumount("/proc/bus/usb") = 0
lstat("/etc/mtab", {st_dev=makedev(22, 5), st_ino=160368,
st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096,
st_blocks=8, st_size=258, st_atime=2000/11/30-14:33:00,
st_mtime=2000/11/30-14:28:43, st_ctime=2000/11/30-14:28:43}) = 0
open("/etc/mtab", O_RDWR|O_CREAT, 0644) = 4
close(4) = 0
rt_sigaction(SIGHUP, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGINT, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGILL, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGTRAP, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGABRT, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGBUS, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGFPE, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGKILL, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = -1 EINVAL
(Invalid argument)
rt_sigaction(SIGUSR1, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGUSR2, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGPIPE, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGALRM, {0x804b100, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGTERM, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGSTKFLT, {0x804b0d0, ~[], 0x4000000}, NULL, 8) = 0
getpid() = 2860
open("/etc/mtab~2860", O_WRONLY|O_CREAT, 0) = 4
close(4) = 0
link("/etc/mtab~2860", "/etc/mtab~") = 0
unlink("/etc/mtab~2860") = 0
open("/etc/mtab~", O_WRONLY) = 4
fcntl(4, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
close(4) = 0
open("/etc/mtab", O_RDONLY) = 4
open("/etc/mtab.tmp", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 5
fstat64(4, {st_dev=makedev(22, 5), st_ino=160368, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=258,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:28:43,
st_ctime=2000/11/30-14:28:43}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40018000
read(4, "/dev/hdc5 / ext2 rw 0 0\nnone /pr"..., 4096) = 258
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=0,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40019000
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=0,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 0, [0], SEEK_SET) = 0
write(5, "/dev/hdc5 / ext2 rw 0 0\n", 24) = 24
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=24,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 24, [24], SEEK_SET) = 0
write(5, "none /proc proc rw 0 0\n", 23) = 23
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=47,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 47, [47], SEEK_SET) = 0
write(5, "/dev/hdc1 /boot ext2 rw 0 0\n", 28) = 28
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=75,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 75, [75], SEEK_SET) = 0
write(5, "none /dev/pts devpts rw,mode=062"..., 38) = 38
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=113,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 113, [113], SEEK_SET) = 0
write(5, "/dev/hdc7 /home ext2 rw 0 0\n", 28) = 28
fstat64(5, {st_dev=makedev(22, 5), st_ino=160367, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=141,
st_atime=2000/11/30-14:33:00, st_mtime=2000/11/30-14:33:00,
st_ctime=2000/11/30-14:33:00}) = 0
_llseek(5, 141, [141], SEEK_SET) = 0
read(4, "", 4096) = 0
close(4) = 0
munmap(0x40018000, 4096) = 0
fchmod(5, 0644) = 0
write(5, "/dev/hdc6 /usr ext2 rw 0 0\n", 27) = 27
close(5) = 0
munmap(0x40019000, 4096) = 0
rename("/etc/mtab.tmp", "/etc/mtab") = 0
unlink("/etc/mtab~") = 0
_exit(0) = ?

2000-12-02 06:54:53

by Alexander Viro

[permalink] [raw]
Subject: RE: usbdevfs mount 2x, umount 1x



On Thu, 30 Nov 2000, Dunlap, Randy wrote:

> Yes, that's how it looks to me also, so maybe it's not a kernel
> problem. Thanks for the tip.
>
> Here's more info, including the strace that Al Viro asked for.
> I also made sure that I'm using mount & umount version 2.10o.
> Please let me know if you need anything else.

Bug in umount(8) - it (a) is overagressive in pruning the stuff from
/etc/mtab and (b) doesn't even look into /proc/mounts. I bet that
the second time it didn't even call umount(2) - kernel is of no help
here, after all it's not psychic...

The final test: try to do the first umount with -n. If that helps (i.e if
the second umount does the right thing in that case) - that's it,
kernel side is OK. -n tells umount(8) to leave /etc/mtab untouched.
Note: it's _not_ a workaround. umount(8) is doing the wrong thing when
it purges all entries and that needs to be fixed. However, if
umount -n <mountpoint2>;umount <mountpoint1> works we have a proof that
the kernel side is OK and fixing umount(8) will solve the whole problem.

2000-12-02 21:34:50

by Andries E. Brouwer

[permalink] [raw]
Subject: Re: usbdevfs mount 2x, umount 1x


Just noticed a nonsense thread on mount/umount, entirely about
trivialities, but people are studying strace output as if
there is something here that is not well-understood.

I missed the start of this thread but just retrieved it
from a friendly archive.


Randy Dunlap wrote on 29 Nov 2000 16:47:27

: % mount usb /proc/bus/usb -t usbdevfs
: % mount usbdevfs /proc/bus/usb -t usbdevfs
: % umount usbdevfs
:
: and I can't rmmod usbcore.

Of course not, you undid one mount but not the other
so usb is still in use. You need one more umount.


Alexander Viro wrote:

: So umount it twice.

Indeed.


Randy Dunlap wrote:

: I don't see a way to umount it twice or I would have done that.
: Is there a way?

Yes, of course. You just say

% umount /proc/bus/usb


Alexander Viro wrote:

: Erm... Say umount one more time?

Indeed.


Randy Dunlap wrote:

: Looks to me like umount unmounted it 2 times
: I don't see a way for me to rmmod usbcore.
: As it is, I have to reboot the system (or just DDT).

No, umount just does a single umount.
You have to call it once more and all is fine.


Alexander Viro wrote:

: Bug in umount(8). I bet that the second time
: it didn't even call umount(2)

But there is no evidence at all that Randy ever called
umount a second time. Umount just works correctly and
as expected, as far as the kernel interface is concerned.
I do not think there is a bug in the sense that umount(2)
is not called.

Something else is the question of what should happen with
/etc/mtab. Until now umount(8) has happily done an umount
even without any entry in /etc/mtab. After all, there is
no reason to suppose that the /etc/mtab contents is up-to-date.
Indeed, /etc/mtab is just a random file without intrinsic meaning.
This also means that the number of umount calls (one) need not
equal the number of lines removed from /etc/mtab (zero, one, more).
Now that things have changed, umount should probably not try to
remove more than one line. I just changed umount.

Andries


[PS - Possibly part of the confusion is that in the good old
days "umount dev" and "umount dir" were equivalent.
They no longer are, you must always say "umount dir".
Of course umount(8) is friendly enough to convert your
"umount dev" into "umount dir", but can do that only when
/etc/mtab still has a "dev dir type .." line.]