All of lore.kernel.org
 help / color / mirror / Atom feed
* How to identify if a partition containing a btrfs volume is mounted and where
@ 2014-02-24 13:48 Mike Fleetwood
  2014-02-24 13:57 ` Hugo Mills
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Fleetwood @ 2014-02-24 13:48 UTC (permalink / raw)
  To: linux-btrfs

Hi,

I am trying to enhance GParted (http://www.gparted.org/) to better
support btrfs, specifically multi-device ones.  GParted displays the
busy status (mounted or not) and the mount point of each partition.

For a single device file system this is easy.  Entry in /proc/mounts
for the partition identifies it's mounted and provides the mount
point.

In the general case for btrfs I don't know how to get from device name
containing a btrfs volume to knowing if it's mounted and where?
btrfs filesystem show can identify the devices in a btrfs, but if the
mounting device was removed from the file system this linkage is
broken.

# mkfs.btrfs /dev/sdb2 /dev/sdb3 /dev/sdb4
# mount /dev/sdb2 /mnt/1
# btrfs device delete /dev/sdb2 /mnt/1

So /dev/sdb2 is no longer part of the file system, but it's still
mounted using it.

# grep btrfs /proc/mounts
/dev/sdb2 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0
# btrfs filesystem show /dev/sdb3
Label: none  uuid: d1e98472-e562-466c-8fa4-ddcaee757c20
    Total devices 2 FS bytes used 156.00KB
    devid    3 size 2.00GB used 961.56MB path /dev/sdb4
    devid    2 size 2.00GB used 552.00MB path /dev/sdb3

So in there a way to determine whether a specific partition containing
a btrfs volume is mounted and on what mount point?

Thanks,
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to identify if a partition containing a btrfs volume is mounted and where
  2014-02-24 13:48 How to identify if a partition containing a btrfs volume is mounted and where Mike Fleetwood
@ 2014-02-24 13:57 ` Hugo Mills
  2014-02-25  3:01   ` Anand Jain
  0 siblings, 1 reply; 6+ messages in thread
From: Hugo Mills @ 2014-02-24 13:57 UTC (permalink / raw)
  To: Mike Fleetwood; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

On Mon, Feb 24, 2014 at 01:48:55PM +0000, Mike Fleetwood wrote:
> Hi,
> 
> I am trying to enhance GParted (http://www.gparted.org/) to better
> support btrfs, specifically multi-device ones.  GParted displays the
> busy status (mounted or not) and the mount point of each partition.
> 
> For a single device file system this is easy.  Entry in /proc/mounts
> for the partition identifies it's mounted and provides the mount
> point.
> 
> In the general case for btrfs I don't know how to get from device name
> containing a btrfs volume to knowing if it's mounted and where?
> btrfs filesystem show can identify the devices in a btrfs, but if the
> mounting device was removed from the file system this linkage is
> broken.
[snip]
> So in there a way to determine whether a specific partition containing
> a btrfs volume is mounted and on what mount point?

   Right now: no.

   Anand posted some kernel patches for an ioctl a few weeks ago that
would allow you to get hold of the kernel's UUID<->device mapping.
There was also a suggestion that the information also be exposed in
/sys/fs/btrfs, and that mounted filesystems, and their list of
devices, be shown in /sys as well. See the discussion from [1]
onwards.

   Hugo.

[1] http://www.spinics.net/lists/linux-btrfs/msg31080.html

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
           --- There are three mistaikes in this sentance. ---           

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to identify if a partition containing a btrfs volume is mounted and where
  2014-02-24 13:57 ` Hugo Mills
@ 2014-02-25  3:01   ` Anand Jain
  2014-02-25 10:28     ` Mike Fleetwood
  0 siblings, 1 reply; 6+ messages in thread
From: Anand Jain @ 2014-02-25  3:01 UTC (permalink / raw)
  To: Hugo Mills, Mike Fleetwood, linux-btrfs


  Thanks Hugo for the heads-up.

>> I am trying to enhance GParted (http://www.gparted.org/) to better
>> support btrfs, specifically multi-device ones.  GParted displays the
>> busy status (mounted or not) and the mount point of each partition.
>>
>> For a single device file system this is easy.  Entry in /proc/mounts
>> for the partition identifies it's mounted and provides the mount
>> point.
>>
>> In the general case for btrfs I don't know how to get from device name
>> containing a btrfs volume to knowing if it's mounted and where?
::
>> btrfs filesystem show can identify the devices in a btrfs,

  if its not for the final sync-up, I had posted a patch which shows
  mount-point in the btrfs fi show -m output that should help you as
  of now, I have plans of revising it later and make it integration
  ready.

 > # mkfs.btrfs /dev/sdb2 /dev/sdb3 /dev/sdb4
 > # mount /dev/sdb2 /mnt/1
 > # btrfs device delete /dev/sdb2 /mnt/1
 >
 > So /dev/sdb2 is no longer part of the file system, but it's still
 > mounted using it.
 >
 > # grep btrfs /proc/mounts
 > /dev/sdb2 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0


  This bug isn't there is the current btrfs-next. I couldn't
  reproduce.


>     Anand posted some kernel patches for an ioctl a few weeks ago that
> would allow you to get hold of the kernel's UUID<->device mapping.

  yes btrfs-devlist is WIP. As of now I am looking for some help
  as in here:

  http://www.spinics.net/lists/linux-fsdevel/msg72861.html
   OR
  http://www.spinics.net/lists/linux-btrfs/msg31784.html

  Team, Any help ? Thanks.

Anand

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to identify if a partition containing a btrfs volume is mounted and where
  2014-02-25  3:01   ` Anand Jain
@ 2014-02-25 10:28     ` Mike Fleetwood
  2014-02-26 21:50       ` Mike Fleetwood
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Fleetwood @ 2014-02-25 10:28 UTC (permalink / raw)
  To: Anand Jain; +Cc: Hugo Mills, linux-btrfs

On 25 February 2014 03:01, Anand Jain <Anand.Jain@oracle.com> wrote:
>
>> # mkfs.btrfs /dev/sdb2 /dev/sdb3 /dev/sdb4
>> # mount /dev/sdb2 /mnt/1
>> # btrfs device delete /dev/sdb2 /mnt/1
>>
>> So /dev/sdb2 is no longer part of the file system, but it's still
>> mounted using it.
>>
>> # grep btrfs /proc/mounts
>> /dev/sdb2 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0
>
>
>  This bug isn't there is the current btrfs-next. I couldn't
>  reproduce.

I've tested this again.  With linux 3.12.10 on Fedora 20 it is still
reproducible, but after upgrading to linux 3.13.3 /proc/mounts
automatically changes to show another device when the initial mounting
one is removed from the btrfs.

Thanks,
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to identify if a partition containing a btrfs volume is mounted and where
  2014-02-25 10:28     ` Mike Fleetwood
@ 2014-02-26 21:50       ` Mike Fleetwood
  2014-03-01 13:22         ` Anand Jain
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Fleetwood @ 2014-02-26 21:50 UTC (permalink / raw)
  To: Anand Jain; +Cc: Hugo Mills, linux-btrfs

On 25 February 2014 10:28, Mike Fleetwood <mike.fleetwood@googlemail.com> wrote:
> On 25 February 2014 03:01, Anand Jain <Anand.Jain@oracle.com> wrote:
>>
>>> # mkfs.btrfs /dev/sdb2 /dev/sdb3 /dev/sdb4
>>> # mount /dev/sdb2 /mnt/1
>>> # btrfs device delete /dev/sdb2 /mnt/1
>>>
>>> So /dev/sdb2 is no longer part of the file system, but it's still
>>> mounted using it.
>>>
>>> # grep btrfs /proc/mounts
>>> /dev/sdb2 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0
>>
>>
>>  This bug isn't there is the current btrfs-next. I couldn't
>>  reproduce.
>
> I've tested this again.  With linux 3.12.10 on Fedora 20 it is still
> reproducible, but after upgrading to linux 3.13.3 /proc/mounts
> automatically changes to show another device when the initial mounting
> one is removed from the btrfs.

Hi Anand,

I've done some more testing and stracing and would appreciate you
confirming the following understanding is correct:

1) btrfs-tools >= 3.12 (possibly earlier) will always display correct
results from btrfs fs show because it uses ioctls to get information
from the kernel for each mounted btrfs, and reads the disks for
non-mounted ones.

2) Old btrfs tools (tested with 0.20-rc1) only reads the disk and so
may get out of date information for mounted file systems, sometimes
showing *** Some devices missing.

3) Using btrfs fs sync /mnt makes the cached changes to device
membership get flushed to disk, thus avoiding seeing stale data in
(2).

So as such I plan to use /proc/mounts to determine FS busy status and
btrfs fs show to determine btrfs device membership.  As per my
previous and the above details this will be correct for linux >= 3.13
and current btrfs-tools, but for older kernel using /proc/mounts will
be wrong if the original mounting device has been removed from the
btrfs.

Thanks,
Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to identify if a partition containing a btrfs volume is mounted and where
  2014-02-26 21:50       ` Mike Fleetwood
@ 2014-03-01 13:22         ` Anand Jain
  0 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2014-03-01 13:22 UTC (permalink / raw)
  To: Mike Fleetwood; +Cc: Hugo Mills, linux-btrfs


Hi Mike,

On 27/02/2014 05:50, Mike Fleetwood wrote:
> On 25 February 2014 10:28, Mike Fleetwood <mike.fleetwood@googlemail.com> wrote:
>> On 25 February 2014 03:01, Anand Jain <Anand.Jain@oracle.com> wrote:
>>>
>>>> # mkfs.btrfs /dev/sdb2 /dev/sdb3 /dev/sdb4
>>>> # mount /dev/sdb2 /mnt/1
>>>> # btrfs device delete /dev/sdb2 /mnt/1
>>>>
>>>> So /dev/sdb2 is no longer part of the file system, but it's still
>>>> mounted using it.
>>>>
>>>> # grep btrfs /proc/mounts
>>>> /dev/sdb2 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0
>>>
>>>
>>>   This bug isn't there is the current btrfs-next. I couldn't
>>>   reproduce.
>>
>> I've tested this again.  With linux 3.12.10 on Fedora 20 it is still
>> reproducible, but after upgrading to linux 3.13.3 /proc/mounts
>> automatically changes to show another device when the initial mounting
>> one is removed from the btrfs.
>
> Hi Anand,
>
> I've done some more testing and stracing and would appreciate you
> confirming the following understanding is correct:
>
> 1) btrfs-tools >= 3.12 (possibly earlier) will always display correct
> results from btrfs fs show because it uses ioctls to get information
> from the kernel for each mounted btrfs, and reads the disks for
> non-mounted ones.

  it would scan kernel first to pick fsid which are opened
  and then reads disks directly to pick rest of the fsids.

> 2) Old btrfs tools (tested with 0.20-rc1) only reads the disk and so
> may get out of date information for mounted file systems,

  yes.

> 3) Using btrfs fs sync /mnt makes the cached changes to device
> membership get flushed to disk, thus avoiding seeing stale data i
> (2).

  nope this does not work. Calling flush not for the application
  purpose is not a good idea. it would alter the application
  performance when you run btrfs fi show that's unacceptable at
  a lot of data centers.

  further, if you delete the missing disk and if that disk reappears,
  just by user land read would make the wrong judgement on its mount
  status, thats the current bug which I am working on.

> So as such I plan to use /proc/mounts to determine FS busy status and
> btrfs fs show to determine btrfs device membership.

  I don't understand in full. but the toughest test case will
  be to test the theory with seed disk in place. /proc/mounts
  show the seed disk whose fsid is different from sprout fsid.

  IMO /proc/mounts should not show seed disk in theory.
  If there is a practical need, pls do let me know
  as I am planning to write a RFC on it.

> As per my
> previous and the above details this will be correct for linux >= 3.13
> and current btrfs-tools, but for older kernel using /proc/mounts will
> be wrong if the original mounting device has been removed from the
> btrfs.

  btrfs-kernel has no idea about the disk disappeared. Its WIP
  at my end.

Thanks,  Anand

> Thanks,
> Mike
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-01 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-24 13:48 How to identify if a partition containing a btrfs volume is mounted and where Mike Fleetwood
2014-02-24 13:57 ` Hugo Mills
2014-02-25  3:01   ` Anand Jain
2014-02-25 10:28     ` Mike Fleetwood
2014-02-26 21:50       ` Mike Fleetwood
2014-03-01 13:22         ` Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.