]> git.ipfire.org Git - thirdparty/util-linux.git/commit
umount: don't use mountinfo if possible
authorKarel Zak <kzak@redhat.com>
Mon, 3 Mar 2014 09:36:15 +0000 (10:36 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Mar 2014 09:36:15 +0000 (10:36 +0100)
commit6a52473ecd877227f6f7da2b95da0b51593ffec1
tree6dd6778cf47560258450468de30c6e49c4adc169
parent53e227cc8d46c4b6fc705ac6608460a8a8156436
umount: don't use mountinfo if possible

The umount(8) always parses /proc/self/mountinfo to get fstype and to
merge kernel mount options with userspace mount options from
/run/mount/utab. This behavior is overkill in many cases and it's
pretty expensive as kernel has to always compose *whole* mountinfo.
This performance disadvantage is visible for crazy use-cases with huge
number of mountpoints and frequently called umount(8).

It seems that we can bypass /proc/self/mountinfo by statfs() to get
filesystem type (statfs.f_type magic) and analyze /run/mount/utab
before we parse mountinfo.

This optimization is not used when:

 * umount(8) executed by non-root (as user= in utab is expected)
 * umount --lazy / --force (target is probably unreachable NFS, then
   use statfs() is pretty bad idea)
 * target is not a directory (e.g. umount /dev/sda1)
 * there is (deprecated) writeable mtab

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
libmount/src/context_umount.c
libmount/src/mountP.h
libmount/src/tab_parse.c
libmount/src/utils.c