In message <>, Andriy Gapon writes:

>2.3. this code passes to bread blkno that is calculated as 4*sector,
>where sector is a number of a physical 2048-byte sector. [**]
>[**] - I think that this is a requirement of buffcache system, because
>internally it performs many calculations that seem to assume that block
>size is always 512.

Yes, the buf-cache works in 512 bytes units throughout.

>3.1. for a fresh buf getlbk would assign the following:
>bsize = bo->bo_bsize;
>offset = blkno * bsize;

That's clearly wrong.

We need to assert that the blkno is aligned to the start of a sector
and use the 512 byte units, so I guess it would be:

offset = dbtob(blkno);
KASSERT(!(offset & (bsize - 1)), ("suitable diagnostic"));

Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________ mailing list
To unsubscribe, send any mail to ""