Subject: Re: kern/3460: block io unit for sd should be sector size
To: Koji Imada - je4wob/2 <koji@math.human.nagoya-u.ac.jp>
From: Chris G. Demetriou <cgd@cs.cmu.edu>
List: netbsd-bugs
Date: 04/08/1997 15:15:19
> >>>>> "Chris" == Chris G Demetriou <cgd@cs.cmu.edu> writes:
> 
>  Chris> Do your patches allow for disks where the disklabel's notion of the
>  Chris> block size is > the actual disk block size (obviously, a power-of-two
>  Chris> multiple 8-) to be used correctly?
> 
> Does this mean that sector size in disklabel is bigger than actual
> sector size?

Yes, that's what I mean.


> I think it's impossible in current
> implementation. Because scsi disk driver invokes SCSI command
> according to disklabel information.

It's not clear to me that that's the "right" behaviour, though.

In the vast majority of cases (are there any cases in which the SCSI
drivers end up not knowing disk devices' block sizes?), the SCSI
driver knows the block size of the device.  Trying to use any other
block size is likely to be nonsensical; what would it mean, and how
could it ever produce a useful result?


>  Chris> For instance, if I want to set up a FFS file system for use on a
>  Chris> CD-ROM, i'd want to set up the disklabel for 2k blocks and the file
>  Chris> system to use 2k fragments.  Could such an image be used on a
>  Chris> 512-byte-block disk?
> 
> This means that making necessary size'ed partition according to real
> sector size(512bytes in my example, disklabel information should use
> "real" sector size) and make file system as if sector size is 2k
> bytes?
> 
> Answer to this question is yes and no.

Uh, unfortunately, I don't understand the question.  8-)


On a 1k/sector disk, i think it should be possible to say:

	disklabel sector size == 1k
	partition boundaries, etc., in disklabel are in units of
		1k, since that's the disklabel sector size.
	FFS file systems should be built with a 1k frag size, etc.

I'd like to be able to then dd off an image from that disk, dd it on
to a 512byte/sector disk, and use it unmodified.

Similarly, on a 512byte/sector disk, I think it should be possible to say:

	disklabel sector size == 1k
	partition boundaries, etc., in disklabel are in units of
		1k, since that's the disklabel sector size.
	FFS file system should be built with a 1k frag size, etc.

and have the resulting disk image be identical to one that could be
configured in the first "possible" list.

Such a "1k/sector disk image" should be usable (i.e. same exact bits)
on a 1k/sector disk and a 512byte/sector disk.  (It would not be
usable on a 2k/sector disk.)


On disks where you have no choice but to accept the disklabel's
sector size, that's what you have to use (right or wrong).  However,
where it's possible to do better I think the code should try to do
better...



> In any case, disklabel routine in sys/arch/<type>/<type>/disksubr.c
> needs some modification.

Yes.  (Really, they need to read the minimum size, as supported by the
device, but since BLKDEV_IOSIZE (or whatever the constant is) is used
by block device accesses, it's probably "safe enough.")


cgd