Re: Some way of telling which block devices are in use (and how)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 29, 2012 at 02:57:11PM -0400, Theodore Ts'o wrote:
> 
> It would be useful if there was a way to be able to determine,
> conclusively, whether a partciular block is in device, and how (i.e.,
> whether some process has the block open, or it is mounted, or it is
> being used as part of a device mapper, or md setup, etc.).
> 
> That way when users complain that trying to open a particular device in
> exclusive mode returns EBUSY, there's an easy way to figure out why this
> might be the case.  The lsof program works for the first method, but it
> doesn't help for the other cases; and using /proc/mounts doesn't help if
> the block device is mounted in some other namespace; you could try to
> look at /proc/*/mounts for every single process, but that's exquisitely
> painful, and only works for block devices used by mounted file systems.
> 
> So the question is, what's the best way of doing this?  Adding a new
> flags field after the block device name in /proc/partitions would be the
> simplest, but that might break some userspace programs that aren't
> expecting it.  There's the holders directory in sysfs, i.e.,
> /sys/dev/block/8:5/holders/*, but that only seems to only record usage
> by device mapper.
> 
> Should we extend the holders directory in the block device directory in
> sysfs?  Add a new directory to record when a file system might be
> mounted?  Add a new /proc file?

Don't we already have a way to do all of this through sysfs today?  How
does gnome/kde handle this when you try to eject a device with an active
mount that is busy?  It pops up a dialog telling you why this can't be
ejected, and which device it is.  I think everything you want is already
there, if not, perhaps dm just needs to add a few more sysfs links to
tie it all together.

And no, no more /proc files for filesystem stuff like this, that way
lies madness.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux