linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix accesses at LBA28 boundary (old bug, but nasty)
@ 2010-04-06 22:45 Mark Lord
  2010-04-06 22:47 ` Mark Lord
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mark Lord @ 2010-04-06 22:45 UTC (permalink / raw)
  To: IDE/ATA development list, Jeff Garzik, Tejun Heo, Alan Cox,
	Ric Wheeler

Most drives from Seagate, Hitachi, and possibly other brands,
do not allow LBA28 access to sector number 0x0fffffff (2^28 - 1).
So instead use LBA48 for such accesses.

This bug could bite a lot of systems, especially when the user has
taken care to align partitions to 4KB boundaries.  On misaligned systems,
it is less likely to be encountered, since a 4KB read would end at 0x10000000
rather than at 0x0fffffff.

Signed-off-by: Mark Lord <mlord@pobox.com>

--- linux-2.6.34-rc3/include/linux/ata.h	2010-03-30 12:24:39.000000000 -0400
+++ linux/include/linux/ata.h	2010-04-06 18:39:41.167702612 -0400
@@ -1025,8 +1025,8 @@
  
  static inline int lba_28_ok(u64 block, u32 n_block)
  {
-	/* check the ending block number */
-	return ((block + n_block) < ((u64)1 << 28)) && (n_block <= 256);
+	/* check the ending block number: must be LESS THAN 0x0fffffff */
+	return ((block + n_block) < (u64)((1 << 28) - 1)) && (n_block <= 256);
  }
  
  static inline int lba_48_ok(u64 block, u32 n_block)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-04-15 13:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-06 22:45 [PATCH] Fix accesses at LBA28 boundary (old bug, but nasty) Mark Lord
2010-04-06 22:47 ` Mark Lord
2010-04-07  1:29 ` Tejun Heo
2010-04-07  3:30   ` Mark Lord
2010-04-07  5:11     ` Tejun Heo
2010-04-07 17:52       ` Mark Lord
2010-04-07 17:52 ` [PATCH] Fix accesses at LBA28 boundary (old bug, but nasty) (v2) Mark Lord
2010-04-07 19:18   ` Alan Cox
2010-04-07 21:01   ` Tejun Heo
2010-04-08 17:00   ` Jeff Garzik
2010-04-15 13:46     ` Mark Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).