mdconfig and device numbers

Hi,

I'm using mdconfig to mount UFS snapshots.
The following code is used to create a device for a given snapshot:
Code:
device=$(mdconfig -a -t vnode -o readonly -f "${1}")
and the following code is used to delete the device:
Code:
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é
 
tobe said:
- 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.
 
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.
 
pbd said:
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 :)
 
Carl Sagan stole my lunch money

tobe said:
Then the increasing numbering is probably not a problem :)
From a quick glance at /usr/src/sbin/mdconfig/mdconfig.c:
Code:
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.
 
fronclynne said:
From a quick glance at /usr/src/sbin/mdconfig/mdconfig.c:
Code:
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 :)
 
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.
 
Back
Top