From: Robert Hancock <hancockrwd@gmail.com>
Cc: "Sergei Shtylyov" <sshtylyov@ru.mvista.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
ide <linux-ide@vger.kernel.org>, "Jeff Garzik" <jeff@garzik.org>,
"Mark Lord" <liml@rtr.ca>, "Hanno Böck" <hanno@hboeck.de>
Subject: Re: [PATCH v2] libata: Don't trust current capacity values in identify words 57-58
Date: Mon, 02 Mar 2009 18:53:14 -0600 [thread overview]
Message-ID: <49AC7F7A.9020101@gmail.com> (raw)
In-Reply-To: <499A1DAC.6090200@gmail.com>
Robert Hancock wrote:
> 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.
>
> While we're at it, clean up this function to use named constants for the
> identify word values.
>
> Signed-off-by: Robert Hancock <hancockrwd@gmail.com>
Jeff, any thoughts on this one? I would suggest it's -upstream material
(for .30)..
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 9fbf059..33b5549 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -1322,14 +1322,16 @@ static u64 ata_id_n_sectors(const u16 *id)
> {
> if (ata_id_has_lba(id)) {
> if (ata_id_has_lba48(id))
> - return ata_id_u64(id, 100);
> + return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
> else
> - return ata_id_u32(id, 60);
> + return ata_id_u32(id, ATA_ID_LBA_CAPACITY);
> } else {
> if (ata_id_current_chs_valid(id))
> - return ata_id_u32(id, 57);
> + return id[ATA_ID_CUR_CYLS] * id[ATA_ID_CUR_HEADS] *
> + id[ATA_ID_CUR_SECTORS];
> else
> - return id[1] * id[3] * id[6];
> + return id[ATA_ID_CYLS] * id[ATA_ID_HEADS] *
> + id[ATA_ID_SECTORS];
> }
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2009-03-03 0:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49AC7F7A.9020101@gmail.com \
--to=hancockrwd@gmail.com \
--cc=hanno@hboeck.de \
--cc=jeff@garzik.org \
--cc=liml@rtr.ca \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sshtylyov@ru.mvista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).