Menu

#27 fuser -m <device> works incorrectly after lazy umount

closed
nobody
None
5
2012-09-18
2009-01-29
Kari Hautio
No

fuser -m <device> fails to detect open files on a filesystem that has been lazily unmounted.

This is bad since a typical use case for "fuser -m" is to kill remaining users of a filesystem.

Testcase:

dd if=/dev/zero of=fs.img bs=1M count=100
losetup /dev/loop4 fs.img
mkfs.ext2 /dev/loop4
mkdir mnt
mount /dev/loop4 mnt
touch mnt/testfile
less mnt/testfile
<CTRL>-Z

these will work and display PID of less

fuser -m mnt
fuser -m /dev/loop4

lazy umount!! as there's open file it's actually still mounted and already open files can be accessed

umount -l mnt
fuser -m /dev/loop4

doesn't find anything!!

Patch:

Checked the /proc/PID/fd/# and it reports the correct device for a file on a lazy unmounted fs so fuser does the filtering.

It seems that fuser makes a check that a device is only added to the scanlist if it's found on the mounted filesystems. I can see this optimizing a little on some cases but it breaks functionality for a lazy unmounted fs.

Attached patch removes this check completely and also few routines and datatype definition becoming obsolete.

Discussion

  • Kari Hautio

    Kari Hautio - 2009-01-29

    patch allowing fuser -m <dev> work on lazy umounted fs

     
  • Daniel Novotny

    Daniel Novotny - 2009-02-10

    hello, I tested the patch on Red Hat Enterprise Linux 5 with positive results

     
  • Craig Small

    Craig Small - 2009-07-09

    Thankyou for your patch. I have applied it to the code in the CVS and it will appear in the next psmisc release.

     

Anonymous
Anonymous

Add attachments
Cancel