Subject: Re: Supporting sector size != DEV_BSIZE
To: None <tech-kern@netbsd.org>
From: Trevin Beattie <trevin@xmission.com>
List: tech-kern
Date: 06/05/2002 13:28:37
>> On Tue, 4 Jun 2002, Trevin Beattie wrote:
>>
>> # 	/* convert to disk blocks */
>> # 	blk = fsbtodb(fs, blk);
>> # 	nblk = fs->fs_bsize / DEV_BSIZE;
>> #
>> # Now, fsbtodb, as originally written, converts file system frags to
physical
>> # sectors.  So the first assignment yields a sector number, but the second
>> # assignment yields a DEV_BSIZE count!  This is certainly wrong.

>On Tue, 4 Jun 2002, Greywolf wrote:
>
>> I think you don't see what it's doing up there.
>>
>> fsbtodb converts filesystem _blocks_ to physical sectors, not frags.

At 08:26 AM 6/5/2002 -0700, Bill Studenmund wrote:
>
>Yes, and at this level of the code, a file system block is a fragment.
>i.e. on an 8k/1k ffs, dbtofsb() converts to the 1k things, not the 8k
>things.

On Wed, 5 Jun 2002, Trevin Beattie wrote :)

It seems like overuse of the term "block" is what led to the current state
of confusion in the code, because there are several different kinds of
blocks.  (That, or the fact that 4.4BSD switched from addressing physical
blocks to logical blocks.)  That's why I've tried to be very specific when
describing each type of block used from the fs layer through the device layer.

Sector => a physical attribute of the media; size is (supposed to be)
lp->d_secsize.  Typically 512 bytes, but can be 2048 bytes on larger
optical media, and other values are possible.

DEV_BSIZE block => a unit used internally by the kernel for passing I/O 
parameters (this is what 4.4BSD calls a 'logical block').  Usually
configured to 512 (to match the typical sector size), but doesn't have to be.

fs fragment (or 'frag') => smallest addressable unit in a Berkeley ffs file
system; size is fs->fs_fsize.  Often 1024 bytes, but varies widely
depending on the file system size and what the administrator wants.

fs block (lacks a better name) => a group of 1, 2, 4, or 8 consecutive
frags in the ffs file system; size is fs->fs_bsize.  Often 8192 (or 8*frag
size) for efficiency, but again varies a lot.

A lot of the changes I'd like to see are simply revising the comments so
that the intended use of each of the above units is absolutely clear.

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