linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata: Don't trust current capacity values in identify words 57-58
@ 2009-02-16 20:19 Robert Hancock
  2009-02-16 20:43 ` Sergei Shtylyov
  2009-02-16 23:01 ` [PATCH] " Mark Lord
  0 siblings, 2 replies; 10+ messages in thread
From: Robert Hancock @ 2009-02-16 20:19 UTC (permalink / raw)
  To: linux-kernel, ide
  Cc: Jeff Garzik, Sergei Shtylyov, Mark Lord, Hanno Böck

Hanno Böck reported a problem where an old Conner CP30254 240MB hard drive
was reported as 1.1TB in capacity by libata:

http://lkml.org/lkml/2009/2/13/134

This was caused by libata trusting the drive's reported current capacity in 
sectors in identify words 57 and 58 if the drive does not support LBA and the
current CHS translation values appear valid. Unfortunately it seems older
ATA specs were vague about what this field should contain and a number of drives
used values with wrong byte order or that were totally bogus. There's no
unique information that it conveys and so we can just calculate the number
of sectors from the reported current CHS values.

Signed-off-by: Robert Hancock <hancockrwd@gmail.com>

---

Should likely go into -next for testing for a while. Of course, the fact that
this problem showed up in the first place shows that the number of people
that test libata with such boat anchors is fairly small :-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9fbf059..5389cbc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1327,7 +1327,7 @@ static u64 ata_id_n_sectors(const u16 *id)
 			return ata_id_u32(id, 60);
 	} else {
 		if (ata_id_current_chs_valid(id))
-			return ata_id_u32(id, 57);
+			return id[54] * id[55] * id[56];
 		else
 			return id[1] * id[3] * id[6];
 	}



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

end of thread, other threads:[~2009-03-03  0:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-16 20:19 [PATCH] libata: Don't trust current capacity values in identify words 57-58 Robert Hancock
2009-02-16 20:43 ` Sergei Shtylyov
2009-02-17  2:15   ` [PATCH v2] " Robert Hancock
2009-02-17 11:32     ` Sergei Shtylyov
2009-03-03  0:53     ` Robert Hancock
2009-02-16 23:01 ` [PATCH] " Mark Lord
2009-02-16 23:03   ` Mark Lord
2009-02-16 23:46   ` Robert Hancock
2009-02-17  2:43     ` Mark Lord
2009-02-17  0:35   ` Sergei Shtylyov

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).