Subject: Re: Supporting sector size != DEV_BSIZE -- patches
To: Chuck Silvers <chuq@chuq.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/05/2002 08:48:45
On Tue, 4 Jun 2002, Chuck Silvers wrote:

> On Tue, Jun 04, 2002 at 12:54:07PM -0700, Trevin Beattie wrote:
> > 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.

Actually, what I suggest is:

1) add a new field to struct ufsmount, int32_t  um_fsbtodb;

2) On mount, after we check that fs_fshift is > DEV_BSHIFT, we:

um->um_fsbtodb = fs->fs_fsbtodb;
fs->fs_fsbtodb = fs->fs_fshift - DEV_BSHIFT;

3) When we go to update the superblock, we store um_fsbtodb in the on-disk
block, instead of the one we calculated.

We save a math operation (subtraction) each time we convert, and we keep
the on-disk format the same.

Take care,

Bill