PDA

View Full Version : [Solved] mdconfig and device numbers


tobe
June 11th, 2009, 13:13
Hi,

I'm using mdconfig to mount UFS snapshots.
The following code is used to create a device for a given snapshot:
device=$(mdconfig -a -t vnode -o readonly -f "${1}")
and the following code is used to delete the device:
mdconfig -d -u "${device}"

It works fine, but the device number (md0, md1, md...) is always increasing, i mean, if /dev/md0 doesn't exists, it is not reused, instead, a new device is created with the highest number available, until i destroy and recreate all devices.

Note: i know the -u flag can be used to pass in a device number, but i don't want to use it because of possible race conditions (i hope mdconfig take care of this when allocating a device number)

Questions:
- It is a bug or a feature of mdconfig? :)
- Is there a limit on the device numbers?

Thanks,
Tobé

pbd
June 12th, 2009, 07:54
- Is there a limit on the device numbers?


I'm sorry, that I cannot answer your question responsibly, but yesterday run an infinite loop that creates md devices. Now, the last is md2551863 and increasing.

mk
June 12th, 2009, 09:27
use -u in if statement to check is the specified number already in use. if so - increase device number for example with two to escape possiblity to hit another device in use. you can go further and specify ranges witch to be used for given device - memory device for multiple tmp dirs 100-200,mount iso (ala windows daemontools) 201-300 and so forth.

tobe
June 12th, 2009, 10:39
I'm sorry, that I cannot answer your question responsibly, but yesterday run an infinite loop that creates md devices. Now, the last is md2551863 and increasing.
Then the increasing numbering is probably not a problem :)

fronclynne
June 12th, 2009, 11:37
Then the increasing numbering is probably not a problem :)
From a quick glance at /usr/src/sbin/mdconfig/mdconfig.c:
mdio.md_unit == (unsigned)ULONG_MAX
But, not being fluent in C, I'm not clear if that's 1.84x10^19 or 4.29x10^9 or what. Probably an absurdly large number in human terms.

trev
June 12th, 2009, 13:07
From a quick glance at /usr/src/sbin/mdconfig/mdconfig.c:
mdio.md_unit == (unsigned)ULONG_MAX
But, not being fluent in C, I'm not clear if that's 1.84x10^19 or 4.29x10^9 or what. Probably an absurdly large number in human terms.

32 bit OS/compiler = 4,294,967,295
64 bit OS/compiler = 18,446,744,073,709,551,615 :-)

tobe
June 12th, 2009, 13:30
It should probably be enough :p

Thanks guys, it was my last open question for my snapsnot manager, now 'm going to submit it to the ports tree.