multi disk btrfs problem

.. ink .. mhogomchungu at gmail.com
Mon Jan 27 20:07:28 PST 2014


greetings everyone.
writing this post as an extension to this bug report[1]

I just added support for multi disk btrfs in my project zuluCrypt[2] and i
though i should write here to discuss how i did it.

First,the problem:

A btrfs can be created across multiple devices,let say across
"/dev/sdc1","/dev/sdb2" and "/dev/sdd3".

With btrfs,any one of them can be used to mount the volume and this creates
a problem because one
 device will appear as mounted in "/proc/self/mountinfo" and the remaining
two will appear as not mounted.
This scenario is explained in comment #4 in link[1]

Solution i came up with:

Btrfs has the following UUID property,all 3 devices in the example above
will share the same "UUID" but
 will have different "UUID_SUB".

With the above in mind,the route i decided to take is as follows:

When scanning for a list of devices,i check for the file system on each
device and when i see a btrfs volume,
i note its UUID and register the device and then i ignore all sub sequence
btrfs devices with the same UUID.
In other words,i only keep and show only the first seen btrfs device if the
btrfs volume covers multiple devices.

When the btrfs volume is mounted,i display the size of the volume as
reported by the file system.

When the btrfs volume is not mounted,i read its UUID and then i match it
against UUID of all devices and add up device sizes
if the UUID match the btrfs volume i am interested in.

In other words,the way to keep track of devices with btrfs is to do that
through their shared UUID.
A btrfs volume with only one device will give a UUID that show up only once.

For example,as in comment number 4 in link[1],i would only show "/dev/vda2"
and hide "/dev/vdb1" and "/dev/vda2" will be the only valid
representative of the btrfs volume and i will use "UUID" in "/dev/vda2" to
know this device belong to the same btrfs file system "/dev/sda2" belong.

thanks for letting me share my solution for btrfs problem.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=608204

[2] http://code.google.com/p/zulucrypt/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/devkit-devel/attachments/20140127/2f30b4d6/attachment.html>


More information about the devkit-devel mailing list