All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Brabec <sbrabec@suse.cz>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org, "David Štěrba" <dsterba@suse.cz>
Subject: Re: [PATCH] libmount: handle btrfs default subvolume mount
Date: Tue, 2 Feb 2016 20:36:52 +0100	[thread overview]
Message-ID: <56B10554.7080205@suse.cz> (raw)
In-Reply-To: <20160202184354.goms7zouusq6pmun@ws.net.home>

Dne 2.2.2016 v 19:43 Karel Zak wrote:

> For what purpose do you need it in lsblk? When the same device is
> mounded on more places?

When lsblk is called on a device with btrfs mounted, the lsblk heuristic 
may return sub-optimal (and even inconsistent) result.

> Anyway, in libmount we can extend mnt_fs_* API and add some additional
> functions -- for example add mnt_fs_get_default_root().
>
> I definitely don't want btrfs specific functions. The API should be
> generic.

The heuristic code is part of lsblk.c: get_device_mountpoint()

https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/misc-utils/lsblk.c?id=4c01c98ca20b404940a4be749e729411d861ae97#n486

It already implements btrfs support, but the heurictic sometimes does 
not do what one would expect:

1) Search for ANY mount point that refers to device in question.

2) Check whether it is a fsroot if it is equal to "/" (always true for 
non-btrfs)

3) If not, search through all mounts that match 1).

4) Compare results, and if fsroot is equal to "/", use it.

5) Otherwise return result of 1).


In some installations (e. g. default openSUSE/SLE installation with 
btrfs root), fsroot is not mounted, 4) fails and 5) returns the 
sub-optimal guess 1).

The algorithm could be easily improved to search for the default 
subvolume as well, and only if it is not mounted, use the sub-optimal 
result.


My idea was:

1) Make btrfs_get_default_subvol_id_str() public

2) Add another loop to get_device_mountpoint() (before existing one) 
searching for a volume, where subvol_id_str returned by 
btrfs_get_default_subvol_id_str() matches option in the mountinfo.


Use of mnt_fs_get_default_root() would work as well, with a bit of overhead.

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

      reply	other threads:[~2016-02-02 19:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 20:34 [PATCH] libmount: handle btrfs default subvolume mount Stanislav Brabec
2016-01-20 21:51 ` Stanislav Brabec
2016-01-20 21:57   ` Stanislav Brabec
2016-01-21  9:48     ` Karel Zak
2016-01-21 15:24       ` Stanislav Brabec
2016-01-21 15:37         ` Karel Zak
2016-01-21 15:45           ` Karel Zak
2016-01-21 17:24             ` Stanislav Brabec
2016-01-22  8:42             ` David Sterba
2016-01-21 21:58       ` Stanislav Brabec
2016-01-26 10:15         ` Karel Zak
2016-01-28 14:22         ` Stanislav Brabec
2016-02-01 12:18           ` Karel Zak
2016-02-01 15:38             ` Stanislav Brabec
2016-02-02 10:11               ` Karel Zak
2016-02-02 15:04                 ` Stanislav Brabec
2016-02-02 18:43                   ` Karel Zak
2016-02-02 19:36                     ` Stanislav Brabec [this message]

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=56B10554.7080205@suse.cz \
    --to=sbrabec@suse.cz \
    --cc=dsterba@suse.cz \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /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 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.