Subject: Re: Supporting sector size != DEV_BSIZE
To: None <tech-kern@netbsd.org>
From: Trevin Beattie <trevin@xmission.com>
List: tech-kern
Date: 06/25/2002 15:52:51
At 05:00 PM 6/3/2002 -0700, Bill Studenmund wrote:
>
>The problem is fs_fsbtodb and its use when we have block offsets in units
>other than disk sectors. fs_fsbtodb (as I recall) is used both to
>translate file system blocks <-> physical sectors, and file system blocks
><-> buffer cache offsets.
>
>In the work I did, that was fine since the two were the same. But the
>solution we're looking at here they are different.
>
>I think the thing to do is find uses of fs_fsbtodb and separate them into
>uses to determine an offset to disk (i.e. where newfs put something) and
>uses to determine an offset in the buffer cache. The latter should use
>"fs_fstoDEV_BSIZEb" - an offset we will make up.

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.

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.

-----------------------
Trevin Beattie          "Do not meddle in the affairs of wizards,
trevin@xmission.com     for you are crunchy and good with ketchup."
      {:->                                     --unknown