Re: ATA support for 4k sector size

From: Matthew Wilcox
Date: Thu Feb 26 2009 - 07:36:45 EST


On Thu, Feb 26, 2009 at 12:16:00AM -0500, Martin K. Petersen wrote:
> >>>>> "Matthew" == Matthew Wilcox <matthew@xxxxxx> writes:
>
> Matthew> Lowest aligned logical block address=0
>
> Matthew> This disagrees with Martin's assertion.
>
> Quick answer from one of my contacts. Desktop drives will indeed ship
> with an alignment of 1(*). The alignment is hardwired at time of
> manufacture and can't be changed.

Hm. I'll have to poke my contacts about this drive they've given me then.
I just checked (with hdparm --Istdout) and word 209 is 0x4000 with
this drive.

> (*) I had to go back and reread the ATA spec to grok this. READ
> CAPACITY(16) indicates the lowest naturally aligned LBA. With LBA 63
> offset in play that would be LBA 7.
>
> ATA, on the other hand, indicates how much LBA 0 is offset from the
> beginning of the first physical sector. If LBA 63 is naturally aligned
> that means that LBA 0 is offset 512 bytes (physical sector 0 starts at
> LBA -1 if you will). Hence IDENTIFY DEVICE word 209 will contain 0x4001.
>
> So you need to tweak your RC16 response a bit...

You're right. I think I want something like:

((1 << log_per_phys) - first_sector_offset) % (1 << log_per_phys);

If you have 8 logical sectors per physical, and ATA reports 0x4001, SCSI
wants to hear 7. The only corner case is ATA reporting 0x4000 and SCSI
wanting to hear 0, not 8, hence the % (1 << log_per_phys).

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/