Subject: Re: Supporting sector size != DEV_BSIZE on lfs
To: Konrad Schroder <perseant@hhhh.org>
From: Trevin Beattie <trevin@xmission.com>
List: tech-kern
Date: 06/20/2002 10:13:33
At 05:55 PM 6/19/2002 -0700, Konrad Schroder wrote:
>On Wed, 19 Jun 2002, Trevin Beattie wrote:
>
>> So you're saying that in v1, lfs_fsbtodb is zero; while in v2, lfs_fsbtodb
>> == lfs_blktodb - lfs_fbshift.  So the whole purpose of fragstofsb() is to
>> cancel out the effect of (lfs_blktodb - lfs_fbshift)?  Can I put that in a
>> code comment?
>
>Sure, though if it's really converting between frags and fsb, I'm not sure
>what the point of commenting that is?
>
>How about this above the XtoY macros in lfs.h:
>
>/*
> * 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.
> */

The problem with that is 'db' and 'fsb' are ambiguous; especially 'db',
because  DEV_BSIZE is NOT equal to the sector size.  And as currently
written, the db macros *don't* convert to/from DEV_BSIZE; they use the
sector size.

>?  Some of the macros (e.g., "segtod" and "numfrags") don't follow the
>conventions, but those can be changed to suit.

I'm very hesitant to change any existing symbol names in header files, for
fear of breaking some user-land code I'm not aware of.  I'll leave that
option to the core developers.

But if you want to do that, remember that many members of struct dlfs also
use the unit identifiers 's', 'd', 'b', 'f', 'frag', 'seg', 'fsb', 'blk',
and 'db'; and the one that are there are not always consistent (e.g.,
ffshift).  IMO, the affix 'db' should be eliminated entirely from struct
dlfs in favor of one that denotes sector size.

I just got an idea: maybe I can add a few more members to the end of struct
lfs (presuming that only the kernel uses it) denoting the log2(size) of
each of the units you mentioned which aren't already covered.  This could
simplify some of the conversion macros, because then they would only need
to take the difference between two units instead of combining three or
more.  (Four of the existing macros use three terms; the fix for lfs_ifind
(lfs_inode.c:138) requires four.)

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