Skip to contentSkip to conversation

block: fix blk_queue_alignment_offset

PATCH In review Christoph Hellwig 2 participants 2 messages Jul 19, 2009 – Jul 20, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix blk_queue_alignment_offset

We need to mask out bits inside the logical block, not outside of it, otherwise we'll always get a 0 alignment_offset.

block/blk-settings.c +1 -1
Index: linux-2.6/block/blk-settings.c
===================================================================
@@ -371,7 +371,7 @@ EXPORT_SYMBOL(blk_queue_physical_block_s
 void blk_queue_alignment_offset(struct request_queue *q, unsigned int offset)
 {
 	q->limits.alignment_offset =
-		offset & (q->limits.physical_block_size - 1);
+		offset & ~(q->limits.physical_block_size - 1);
 	q->limits.misaligned = 0;
 }
 EXPORT_SYMBOL(blk_queue_alignment_offset);
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"hch" == Christoph Hellwig <[email protected]> writes:

hch> We need to mask out bits inside the logical block, not outside of hch> it, otherwise we'll always get a 0 alignment_offset.

The alignment_offset only makes sense if physical_block_size > logical_block_size. For instance (63 * 512) & (4096 - 1) = 3584.

Your patch would yield 28672 = 4096 * 7 and that's incorrect; LBA 63 is not aligned on a 4KB boundary...

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering