Skip to contentSkip to conversation

minor ID for btrfs-control

DISCUSSION Helmut Hullen 4 participants 14 messages Apr 2, 2011 – Apr 3, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hallo,

if I've understood some mails in this list correct, then btrfs needs a character device "btrfs-control" with the ID 10:55

When I look for this device in

/sys/class/misc/btrfs-control/dev

I see 10:234

And when I run the command

mkfs.btrfs -d raid0 -m raid1 /dev/sda1 /dev/sdc1

I get the error messages

failed to open /dev/btrfs-control skipping device registration

---

ls -l /dev/bt*

shows

crw-rw-rw- 1 root root 10,55 2. Apr 17:55 /dev/btrfs-control

---

Kernel 2.6.38.1 (self made), no udev, no initrd, no tempfs. btrfs from nov. 2010

What goes wrong?

Viele Gruesse!
Helmut

#1 lore raw
Quoted 11 lines · Helmut Hullen

if I've understood some mails in this list correct, then btrfs needs a character device "btrfs-control" with the ID 10:55

When I look for this device in

/sys/class/misc/btrfs-control/dev

I see 10:234
Kernel 2.6.38.1 (self made), no udev, no initrd, no tempfs. btrfs from nov. 2010
What goes wrong?

No udev is wrong. Modern Linux kernels allocate minor devices dynamically.
If you do not use udev, you need to synchronise /dev/ node with /sys/class/misc/btrfs-control/dev manually on each boot.

Signature · 2 lines
Tomasz Torcz       ,,(...) today's high-end is tomorrow's embedded processor.''
xmpp: [email protected]                      -- Mitchell Blank on LKML
#2 lore raw

Hallo, Tomasz,

Du meintest am 02.04.11:

Quoted 1 line

No udev is wrong.

Sorry - no.
On the machines I use I don't need udev (they are a kind of server, not end user workstations with often changing hardware). And I could abstain (? - please excuse my gerlish) from btrfs, but not from fixed device names.

I may not believe that btrfs only works under udev.

Quoted 3 lines

Modern Linux kernels allocate minor devices
dynamically. If you do not use udev, you need to synchronise /dev/ node with /sys/class/misc/btrfs-control/dev manually on each boot.

How and where? From where gets the system the actual minor number 234 instead of the defined number 55?

By the way - the btrfs module is "builtin", is that a problem?

Viele Gruesse!
Helmut

#3 lore raw
In reply to Tomasz Torcz

Hallo, Tomasz,

Du meintest am 02.04.11:

Quoted 5 lines
Quoted 5 lines

if I've understood some mails in this list correct, then btrfs needs a character device "btrfs-control" with the ID 10:55

When I look for this device in

Quoted 7 lines
Quoted 3 lines

/sys/class/misc/btrfs-control/dev

I see 10:234

If you do not use udev, you need to synchronise /dev/ node with /sys/class/misc/btrfs-control/dev manually on each boot.

Solved (something like reverse engineering).

I re-create the (permanent) entry /dev/btrfs-control using the actual contents of "/sys/class/misc/btrfs-control/dev", and btrfs is happy (and me too).

Works now on two of my machines for the next long time test ...

------------------

I'll watch who changes the data ... some part of some program must have defined 234 as minor ID.

Viele Gruesse!
Helmut

#4 lore raw
Quoted 8 lines · Helmut Hullen
Quoted 2 lines

If you do not use udev, you need to synchronise /dev/ node with /sys/class/misc/btrfs-control/dev manually on each boot.

Solved (something like reverse engineering).

I re-create the (permanent) entry /dev/btrfs-control using the actual contents of "/sys/class/misc/btrfs-control/dev", and btrfs is happy (and me too).

This is fine, and is just what udev does; it creates the correct device node using kernel data.

//Peter

#5 lore raw

Hallo, Peter,

Du meintest am 03.04.11:

Quoted 8 lines
Quoted 5 lines

Solved (something like reverse engineering).

I re-create the (permanent) entry /dev/btrfs-control using the actual contents of "/sys/class/misc/btrfs-control/dev", and btrfs is happy (and me too).

This is fine, and is just what udev does; it creates the correct device node using kernel data.

Maybe. But if I want a cup of milk I don't buy a complete cow ...

Viele Gruesse!
Helmut

#6 lore raw
Quoted 10 lines · Helmut Hullen
Quoted 8 lines
Quoted 5 lines

Solved (something like reverse engineering).

I re-create the (permanent) entry /dev/btrfs-control using the actual contents of "/sys/class/misc/btrfs-control/dev", and btrfs is happy (and me too).

This is fine, and is just what udev does; it creates the correct device node using kernel data.

Maybe. But if I want a cup of milk I don't buy a complete cow ...

My point was that it's not so much reverse engineering, it's exactly how udev works, and that also makes it a really reliable solution.

//Peter

#7 lore raw

Hallo, Peter,

Du meintest am 03.04.11:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Solved (something like reverse engineering).

[...]

Quoted 2 lines

My point was that it's not so much reverse engineering, it's exactly how udev works, and that also makes it a really reliable solution.

But in this special case Goffredo has shown that I neither need udev nor reverse engineering: the minor number is hard coded (but may have changed some time ago).

Viele Gruesse!
Helmut

#8 lore raw
In reply to Helmut Hullen
Quoted 25 lines · Helmut Hullen

Hallo,

if I've understood some mails in this list correct, then btrfs needs a character device "btrfs-control" with the ID 10:55

When I look for this device in

/sys/class/misc/btrfs-control/dev

I see 10:234

And when I run the command

mkfs.btrfs -d raid0 -m raid1 /dev/sda1 /dev/sdc1

I get the error messages

failed to open /dev/btrfs-control skipping device registration

---

ls -l /dev/bt*

shows

Quoted 8 lines

crw-rw-rw- 1 root root 10,55 2. Apr 17:55 /dev/btrfs-control

---

Kernel 2.6.38.1 (self made), no udev, no initrd, no tempfs. btrfs from nov. 2010

What goes wrong?

As wrote by Tomasz the minor number of the btrfs-control is allocated dynamically. A lot of drivers create a device which is registered dynamically in the "misc" group. In linux this is a well established behavior from a long time.

If you don't want to use udev you have two choices:
- use devtmpfs
- create manually a device. But nobody guarantee that the minor/major will not change.

Quoted 10 lines

Viele Gruesse!
Helmut
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
.

#9 lore raw
Quoted 4 lines · Goffredo Baroncelli

If you don't want to use udev you have two choices:
- use devtmpfs
- create manually a device. But nobody guarantee that the minor/major will not change.

- use a udev replacement intended for embedded systems, such as mdev

//Peter

#10 lore raw

Hallo, Peter,

Du meintest am 03.04.11:

Quoted 6 lines
Quoted 4 lines

If you don't want to use udev you have two choices:
- use devtmpfs
- create manually a device. But nobody guarantee that the minor/major will not change.

- use a udev replacement intended for embedded systems, such as mdev

http://wildanm.wordpress.com/2007/08/21/mdev-mini-udev-in-busybox/
http://tinderbox.dev.gentoo.org/misc/mdev.conf

I'll take a try - thank you!

Viele Gruesse!
Helmut

#11 lore raw
In reply to Goffredo Baroncelli

Hallo, Goffredo,

Du meintest am 03.04.11:

Quoted 11 lines
Quoted 8 lines

if I've understood some mails in this list correct, then btrfs needs a character device "btrfs-control" with the ID 10:55

When I look for this device in

/sys/class/misc/btrfs-control/dev

I see 10:234

As wrote by Tomasz the minor number of the btrfs-control is allocated dynamically.

At which place?

Quoted 2 lines

If you don't want to use udev you have two choices:
- use devtmpfs

That leads to similar problems as "udev": I have to define on another place ("/lib/udev/devices") the desired device.

Quoted 2 lines

- create manually a device. But nobody guarantee that the minor/major will not change.

That seems to be the behaviour I'm watching on my test machine. "hard coded" device with 10:55, but the system uses 10:234

If btrfs is designed to work only under udev then it has to check wether udev is running.

Viele Gruesse!
Helmut

#12 lore raw

Hello Helmut,

Quoted 1 line · Helmut Hullen

Hallo, Goffredo,

[..]

Quoted 4 lines
Quoted 2 lines

As wrote by Tomasz the minor number of the btrfs-control is allocated dynamically.

At which place?

I replied you too fast. Btrfs register a "misc" device, but its number is not dynamically allocated (see [1] for further information), but it is static.

$ grep BTRFS_MINOR -r include/
include/linux/miscdevice.h:#define BTRFS_MINOR          234

I can conclude that _now_ the minor is 234 and not 55. But I don't know if it is a _stable_ interface.

I think that during the boot you should check the minor with

grep btrfs-control /proc/misc | awk '{ print $1 }'

Regards
G.Baroncelli

[1] http://www.linuxjournal.com/article/2920

Quoted 9 lines

Viele Gruesse!
Helmut
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
.

#13 lore raw

Hallo, Goffredo,

Du meintest am 03.04.11:

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

As wrote by Tomasz the minor number of the btrfs-control is allocated dynamically.

At which place?

I replied you too fast. Btrfs register a "misc" device, but its number is not dynamically allocated (see [1] for further information), but it is static.

$ grep BTRFS_MINOR -r include/
include/linux/miscdevice.h:#define BTRFS_MINOR          234

Ah - there it is!
I'd only searched in fs/btrfs

Quoted 2 lines

I can conclude that _now_ the minor is 234 and not 55. But I don't know if it is a _stable_ interface.

We'll see ... now I know the error message and the place where I can examine the actual major and minor value. Should be enough information for the next months ...

Thank you!

Viele Gruesse!
Helmut