Subject: Re: Supporting sector size != DEV_BSIZE
To: Trevin Beattie <trevin@xmission.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/25/2002 16:24:09
On Tue, 25 Jun 2002, Trevin Beattie wrote:

> At 05:55 PM 6/19/2002 -0700, Konrad Schroder wrote:
> >/*
> > * The following macros convert between various different sized units:
> > *
> > * b:     bytes.
> > * db:    logical disk sectors, currently equal to DEV_BSIZE which is also
> > *        equal to the disklabel sector size.
> > * fsb:   the unit of block addressing; equal to fragments in v2, but equal
> > *        to db in v1.  All on-disk data structures pertaining to block
> > *        addresses are in fsb.
> > * frags: filesystem fragments (lfs_fsize).
> > * blk:   filesystem blocks (lfs_bsize).
> > * seg:   filesystem segments.
> > */
>
> Okay, I think it's about time for me to clean up my patches a bit (after I
> pull up the latest -current to make sure I'm in sync), so I'd like to get
> back to this (old) point.
>
> Right now I'm of the opinion that the existing conversion macros and unit
> affixes should keep their historical meaning.  Specifically, 'db' means
> "disk blocks" a.k.a. physical sectors.  (I think that's what it used to be,
> a long time ago, isn't it?)  A new set of macros should be created that
> convert to/from DEV_BSIZE units, adding a new affix to the list of block
> types.
>
> I have the following suggestions for identifying a DEV_BSIZE unit:
> 	* kb		(kernel block)
> 	* DB		(DEV_BSIZE; differentiated from disk block by case)
> 	* iob		(I/O block)
>
> Each possible code has its cons: "kb" could be confused with "kilobyte"
> (which is a different number); "DB" is spelled the same as "db" (any
> case-insensitive compiler tools?); "iob" is longer and not specific enough.
>  Any better suggestion, or vote for one of the above options, is welcome.

I agree, 'kb' is too close to kilobyte. :-) I could live with DB. Or, how
about 'bb' for bufcache block?

> Once we've settled on the names, I'd like to add the new macros to the
> appropriate header files, possibly within a "#ifdef KERNEL" conditional
> block.  Then I'll go back through the code and make the necessary changes
> to use the new macros.  This means all instances of fsbtodb() and dbtofsb()
> in ffs, newfs_ffs, and fsck will be changed to fsbtoXX() and XXtofsb() (and
> the fsbtodb() and dbtofsb() macros will be changed back to use the sector
> size).  I'm hoping there aren't any other programs that use those macros.
> In the lfs code, I've already used fsbtodb() where sector size is intended;
> I just have to replace open equations that use DEV_BSIZE.

Sounds good.

Take care,

Bill