Subject: Re: dd strangeness
To: Tad Hunt <tad@entrisphere.com>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 06/24/2002 22:53:44
On Fri, Jun 21, 2002 at 02:20:30PM -0700, Tad Hunt wrote:
> 
> I've got a NetBSD-1.5 system containing a IBM Microdrive with the
> disklabel below.  When I enter the following command:
> 
> 	# dd if=/dev/wd0d of=/dev/null bs=512
> 
> It runs fine for a long while, then at the end of the disk, I get a
> bunch of these:
> 
> 	wd0d: id not found reading fsbn 700560 of 700560-700567 \
> 		(wd0 bn 700560; cn 695 tn 0 sn 0), retrying
> 	...
> 
> 	wd0d: id not found reading fsbn 700568 of 700568-700575 \
> 		(wd0 bn 700568; cn 695 tn 0 sn 8), retrying
> 	...
> 
> Why is dd attempting to read fsbn 700560 and 7700568, when the disk
> ends at 700559 (see the disklabel)?
> 
> Is this the expected behavior?
> 
> dd(1) exits with an "Input/output error", this can't be right...
> 
> 	dd: /dev/wd0d: Input/output error
> 
> Has anyone else ever seen this behavior?
> 
> I've tried this same thing with ATA flash disks other than the
> Microdrive, and still see the same problem.
> 
> Manuel Boyer mentions here 
> 
> 	http://mail-index.netbsd.org/port-i386/2001/04/18/0005.html
> 
> that there is a PR opened against this problem, but doesn't give
> the PR number, and searching for "id not found" in the PR database
> doesn't return any hits...  Searching the kern PR database for
> "disk" hits upon this PR, which looks like what I'm seeing (except
> the error messages contains different text).
> 
> 	PR1238: Reading past end of IDE disk causes EIO, not EOF
> 
> I guess that this is what I'm running into.  Since it has been open
> since 1995, I'm assuming it is not considered harmful?

Yes, this is the problem you're running into. It's not very hight on my
priority list :)
BTW, I think it you use another partition than the raw partition you won't
have this problem.

It's not clear for me how to exactly solve this. Just matching the
disklabel may not be a good idea, as it may not contain the real size of
the device. Matching against the size the disk reported may also not
be a good idea, as some disks may report lower number of sectors than they
really have. I think the raw partition should still try to read past what
we believe is the end of the disk.

Other (e.g. SCSI) disks don't have this problem, because they have a better
programming interface and we can make a difference between an out of range
request and other errors. With IDE, id not found can also be a real 
media error.

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--