Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2008 10:22:32 -0700
From:      Julian Elischer <julian@elischer.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        Ed Schouten <ed@80386.nl>, arch@freebsd.org
Subject:   Re: Simplifying devfs: minor == unit
Message-ID:  <483C4358.2050707@elischer.org>
In-Reply-To: <20080527150244.GN21317@deviant.kiev.zoral.com.ua>
References:  <20080527130615.GJ64397@hoeg.nl> <20080527150244.GN21317@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Kostik Belousov wrote:
> On Tue, May 27, 2008 at 03:06:15PM +0200, Ed Schouten wrote:
>> Hello everyone,
>>
>> Right before I left to BSDCan I was looking at the devfs code. When I
>> started hacking the TTY code, I discovered minor/unit numbers are still
>> actively used within the FreeBSD kernel, even though they are never
>> exposed to userspace. Devfs automatically generates an inode number for
>> each device. Right now, st_rdev is always equal to st_ino, which still
>> guarantees device numbers are unique throughout the system.
>>
>> In an experimental branch in Perforce, I decided to see what would
>> happen if I would completely remove minor numbers from device drivers.
>> This means make_dev()'s minor argument is removed, but also the minor(),
>> unit2minor(), etc. functions. Drivers could use si_drv0 directly, just
>> like si_drv1 and si_drv2 are used right now.
>>
>> This doesn't seem to be possible because of the design of the device
>> cloner (not the eventhandler, just the clone_* routines), which
>> preallocates an unnamed device with a specific unit numer, which can
>> later be passed to make_dev().
>>
>> This is why I want to do this in little steps right now. I was thinking
>> about doing the following:
>>
>> - si_drv0 currently contains the minor number. We could alter the
>>   minor2unit(), etc. routines to make minor numbers equal to unit
>>   numbers. This means most routines will now become a no-op. See
>>   attachment.
>>
>> - When that hits the tree, we could decide to run a big regexp on the
>>   source code to make drivers use si_drv0 directly.
>>
>> - I've seen most drivers only use the device cloner, because they need
>>   descriptor local storage. It turns out more drivers need this than I
>>   initially thought. kib@ has a patch for this, so I hope this gets
>>   committed one of these {days,weeks,months}.
> The patch was committed ~ a week ago.
>> - After we've got file descriptor local storage, I think we can live
>>   without the cloner. This means we could consider removing the minor
>>   number argument from make_dev(), removing the unique unit number
>>   restriction we currently have inside devfs, which causes many drivers
>>   to use number pools for no obvious reason.
> I think we cannot live without clones regardless of devfs_cdevpriv.
> The model assumed for the pty, snp and probably several other devices
> actually requires new cdev instead of the priv data.
> 
>> I was thinking about discussing this patch with my mentor + committing
>> it somewhere in the nearby future. Any comments?
> 
> Making minor == unit number looks to be not a bad idea, please, look at
> the saga of the tty_pty.c revs. 1.153, 156, 1.157. Making the devices use
> si_drv0 directly probably is not so good since we remove the indirection
> layer that is already present and allows for some (minor) freedom in the
> devfs/kern_conf implementation.

Make sure that old binaries that expect the minor number sot be on a 
certain format are not broken..

try run some old 2.2.5 binaries in a 2.2.5 jail with /dev mounted and 
make sure that things like ptys work.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?483C4358.2050707>