linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-fsdevel@vger.kernel.org, Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: Some way of telling which block devices are in use (and how)
Date: Sun, 29 Apr 2012 13:18:30 -0700	[thread overview]
Message-ID: <20120429201830.GA10188@kroah.com> (raw)
In-Reply-To: <E1SOZJ1-0002IK-KC@tytso-glaptop.cam.corp.google.com>

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

  reply	other threads:[~2012-04-29 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-29 18:57 Some way of telling which block devices are in use (and how) Theodore Ts'o
2012-04-29 20:18 ` Greg KH [this message]
2012-04-29 21:23   ` Ted Ts'o
2012-04-29 22:05     ` Ted Ts'o
2012-04-30  5:10       ` Greg KH
2012-04-30  9:11         ` Ted Ts'o
2012-04-30 16:21           ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120429201830.GA10188@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).