9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] i/o error reading large sata disk
Date: Tue, 22 Apr 2008 09:56:18 -0400	[thread overview]
Message-ID: <5843760afa99950a072d65ecabc79dfe@quanstro.net> (raw)
In-Reply-To: <ee54f08125cd185f588cbaaa2c09804d@quanstro.net>

> > read: i/o error
>
> i think i see the problem.  we're off by one bit.
>
[...]
> /n/sources/plan9//sys/src/9/pc/sdata.c:1344,1350 - sdata.c:1344,1350
>   };
>
>   static int
> - atageniostart(Drive* drive, vlong lba)
> + atageniostart(Drive* drive, uvlong lba)
>   {
>   	Ctlr *ctlr;
>   	uchar cmd;
> /n/sources/plan9//sys/src/9/pc/sdata.c:1351,1357 - sdata.c:1351,1357
>   	int as, c, cmdport, ctlport, h, len, s, use48;
>
>   	use48 = 0;
> - 	if((drive->flags&Lba48always) || (lba>>28) || drive->count > 256){
> + 	if((drive->flags&Lba48always) || (lba>>27) || drive->count > 256){
>   		if(!(drive->flags & Lba48))
>   			return -1;
>   		use48 = 1;

while this does fix the problem, it's sloppy.  the problem is actually
that ata reports device sizes as number of sectors+1.  it also does not follow
the tradition used for sector counts, where 0 sector count = all-ones+1 = 256.
this is because removable media drives with no media (eg cdroms) give size = 0.
therefore if under any ata addressing scheme, the all-ones sector is not accessable.
credit to sam hopkins for pointing this out.

/n/sources/plan9//sys/src/9/pc/sdata.c:1344,1350 - sdata.c:1344,1350
  };

+ enum{
+ 	Last28	= (1<<28) - 1 - 1,
+ };
+
  static int
- atageniostart(Drive* drive, vlong lba)
+ atageniostart(Drive* drive, uvlong lba)
  {
  	Ctlr *ctlr;
  	uchar cmd;
/n/sources/plan9//sys/src/9/pc/sdata.c:1351,1357 - sdata.c:1355,1361
  	int as, c, cmdport, ctlport, h, len, s, use48;

  	use48 = 0;
- 	if((drive->flags&Lba48always) || (lba>>28) || drive->count > 256){
+ 	if((drive->flags&Lba48always) || lba > Last28 || drive->count > 256){
  		if(!(drive->flags & Lba48))
  			return -1;
		use48 = 1;


- erik


      parent reply	other threads:[~2008-04-22 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-06  2:50 sqweek
2008-04-06  3:58 ` erik quanstrom
2008-04-06 16:19   ` sqweek
     [not found]     ` <b0541197023336a814de597a7abcaa66@quanstro.net>
2008-04-14  4:51       ` sqweek
2008-04-22 13:56   ` erik quanstrom [this message]

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=5843760afa99950a072d65ecabc79dfe@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /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).