Subject: Re: Supporting sector size != DEV_BSIZE -- patches
To: Trevin Beattie <trevin@xmission.com>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 06/04/2002 20:49:07
On Tue, Jun 04, 2002 at 12:54:07PM -0700, Trevin Beattie wrote:
> At 08:16 PM 6/3/2002 -0700, Chuck Silvers wrote:
> >currently every disk driver and almost all of the rest of the system
> >assume b_blkno is in units of DEV_BSIZE, so it would definitely be easier
> >to fix the few places that assume something else than to switch everything
> >that assumes units of DEV_BSIZE.
> >
> >as for FFS, I think the only place it has a problem is in its usage of
> >the fs_fsbtodb field in the superblock.  code that uses this field is
> >attempting to convert from a fragment size to the units of b_blkno,
> >so such code should really just compute the desired value
> >	(fs->fs_fshift - DEV_BSHIFT)
> >rather than using the value in the superblock.
> 
> As I understand it then, your suggestion is to replace every instance of
> fs->fsbtodb, fsbtodb(), and dbtofsb() with the above equation.  That would
> certainly be much clearer than the way it is now (since the very definition
> of "db" is still unsettled).

it would be less intrusive to just use

#define	fsbtodb(fs, b)	((b) << ((fs)->fs_fshift - DEV_BSHIFT))
#define	dbtofsb(fs, b)	((b) >> ((fs)->fs_fshift - DEV_BSHIFT))

and verify that fs->fs_fshift >= DEV_BSHIFT in the mount path.


> After fixing the kernel, what would we do with the unused fsbtodb and
> dbtofsb macros?  Define them in terms of sectors?  Deprecate them?  Replace
> them with something that issues a compiler error?  It seems to me that
> fs_fsbtodb should at least be deprecated, since its intended purpose can
> more reliably be derived from fs_fshift.

yea, fs_fsbtodb should just be ignored by the kernel and most of userland.
maybe newfs will want to initialize it to something and dumpfs will want to
print it, but that's probably all.

-Chuck