On Thu, Mar 21, 2019 at 04:48:23PM -0400, Theodore Ts'o wrote: > On Thu, Mar 21, 2019 at 09:17:10PM +0100, Lukas Czerner wrote: > > > > Right, I did mention it later in the reply. It can be filtered > > > > grep -v '^/dev/' > > Well, that assumes all device nodes are in /dev. Which is not > necessarily always the case, especially in some of the more _whacky_ > container setups which I've seen. (Hmm, is whacky redundant here?) Fair enough, I've never seen this outside dm/lvm testing. > > I suppose can test whether or not the path is a block device or a > directory..... > > > > > For me this new function is the wors of all. > > > > cold cache: > > real 0m2.115s > > user 0m0.040s > > sys 0m0.154s > > > > second time: > > real 0m1.100s > > user 0m0.037s > > sys 0m0.122s > > > > But that's because of blkid which is terribly slow for some reason. > > I ran my test on a system with a NVMe SSD, and no HDD's attached. I > just did an strace, and I see the util-linux folks have really done a > great job of pessimizing blkid. :-( Yeah, all I have on that system is spinning rust :) lsblk works good enough for me so I am not sure how I feel about special binary to check the mount point :) -Lukas > > My version used to just pull the information from the blkid cache file > and then verified the results, but it looks like the new, improved > util-linux version of blkid scans the /dev directory and opens and > reads from each device node, even when we're querying a single block > device. <groan> > > Even lsblk is *amazingly* inefficient in terms of the number of > useless file opens which it performs, although at least they are all > /sysfs files. > > I'm half tempted to create and ship a binary which just calls > ext2fs_check_mount_point() and returns the value, since it's the most > efficient. This command > > sudo strace -o /tmp/st /build/e2fsprogs-maint/lib/ext2fs/tst_ismounted /dev/lambda/tp > > Opens /proc/mounts and does a trial mount of /dev/lambda/tp to make > sure it's actually busy, and that's it. > > Sigh... > > - Ted