Skip to contentSkip to conversation

R: Re: RFC: exporting info via sysfs [was Re: [patch 0/2] Control filesystem balances (kernel side)]

DISCUSSION Goffredo Baroncelli <[email protected]> 1 participant 1 message Nov 5, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines

----Messaggio originale----
Da: [email protected]
Data: 05/11/2010 13.41
A: "Goffredo Baroncelli"<[email protected]>
Cc: <[email protected]>, "Hugo Mills"<[email protected]>
Ogg: Re: RFC: exporting info via sysfs [was Re: [patch 0/2] Control

filesystem balances (kernel side)]

Quoted 9 lines

Hi, Goffredo,

Quoted 1 line · Goffredo Baroncelli

I make a prototype for exporting info from btrfs via sysfs.

Good stuff. I was going to take a look at doing that this
weekend. :)

Quoted 7 lines
Quoted 3 lines

Under /sys/btrfs were created two directories, named "fs" and "devices".

/sys/btrfs/fs/<fs-uuid>/

I'm pretty sure that /sys/btrfs won't get through any discussion on
LKML. I'd suggest /sys/fs/btrfs as the base, since that's where the other filesystems seem to put their sysfs information.

Not enough cofee... The right path is /sys/fs/btrfs (see examples in my email)

Quoted 14 lines
Quoted 9 lines
                         label		-> filesystem label
                         num_devices    -> total number of devices
                         open_devices   -> number of opened devices
                         [...]
/sys/btrfs/devices/<dev-uuid>/
                         devid          -> btrfs device number
                         fsid           -> filesystem uuid (fs-uuid)
                         major, minor   -> major minor

I think the major, minor should instead be be a symlink to the
relevant entry in /sys/devices/... (as done in /sys/block/*) or /sys/block (as done in /sys/block/md*/slaves). Call it "device".

Quoted 7 lines
Quoted 1 line
                         name           -> device name

Unnecessary -- and also, I think, unlikely to get through LKML
review. Putting a device name here implies that the kernel knows better than userspace what the name of the device is (i.e. which device node you should be using). Having the link to /sys/block/* or /sys/devices/... as above is, I think, all that's needed here.

Apparently btrfs opens the device only when the filesystem is mounted. So before mounting a filesystem only the device file path exists. After the mounting major/minor have meaning values.

Quoted 6 lines

Userspace should be able to convert the major/minor pair kept in /sys/fs/btrfs/devices/<uuid>/device/dev appropriately.

Quoted 3 lines
                         writeable      -> is the device writeable

where <fs-uuid> is the filesystem uuid, and <dev-uuid> is the device uuid.

The

Quoted 6 lines
Quoted 1 line

link between devices and filesystem is the <fsid> parameter of a device.

Could that be made a symlink instead? That seems to be the usual
approach in sysfs.

Quoted 1 line

I create these structure because we should handle the case were the

devices

Quoted 8 lines
Quoted 2 lines

are present (like after a "btrfs device scan") but the filesystem aren't mounted.

... ah, I see it can't. (Re: my previous comment)

Quoted 3 lines

In this case the devices/ subdirectory is populated. Instead the fs/ subdirectory is empty.

Quoted 6 lines
Quoted 2 lines

I don't attach a patch because the code is very ugly. Comments ? Thoughts ?

Is it ugly because there are significant difficulties in making
btrfs or sysfs do this, or just because you hacked something together as quickly as possible for a demo?

Both. Sysfs is not difficult to manage but there is a lot of redundant codes. Fortunately few #defines help a lot. In any case I have a lot of doubts about the
locking...

For this week I will try to sent the patches

Quoted 9 lines

Hugo.

Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
 PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- "There's a Martian war machine outside -- they want to talk ---   
               to you about a cure for the common cold."