Skip to contentSkip to conversation

clipped disk reports clipped lba size

PATCH [email protected] 2 participants 2 messages Jan 30, 2002 – Feb 1, 2002

lore
Share & tools
lore
#0 lore raw

Review

Quoted 10 lines · Eduardo Trpani

Since my BIOS does not support my disk (WD400) I had to clip to 33.8G. At boot time Linux (2.4.17) uses the lba size reported by the disk, that is 33.8 and does not allow me to access the rest of the disk.

(quoted diff) +6 -0
+     /* If the geometry has been forced recalculate lba_capacity */
+     if ((id->capability & 2) && lba_capacity_is_ok(id) &&
+      drive->forced_geom)
+     {
+             id->lba_capacity = drive->bios_head * drive->bios_sect * drive->bios_cyl;
+     }

This is not really the right patch, although it may solve your problem. It looks a bit silly to first test lba_capacity_is_ok() and then throw away lba_capacity anyway.
Using a product of strange numbers is a bad idea.
Often this simple patch will not help, see below.

My point of view would be more like: we now have three levels of information. First C/H/S - very outdated. On all large disks it will be 16383/16/63. Then LBA. When it looks reasonable, we believe it, and let it override C/H/S. Third what the disk returns for READ_NATIVE_MAX_ADDRESS. Especially when LBA says 33.8GB we have a good reason to ask for this and see whether it is more.

Some disk types fake LBA at 33.8GB, but allow access past this point. Some disks actually give I/O errors past the 33.8GB (when jumpered), and a SETMAX command is needed to make the rest accessible.

Two years ago I wrote a tiny utility setmax that does this. If I am not mistaken this stuff is now part of the 2.5 kernel. No doubt some of it will eventually be backported to 2.4 / 2.2 / 2.0. It is in 2.4.18-pre7-ac1.

[Just looked at patch-2.5.3-pre1. And indeed, some nice code. Andre, others: is there a reason to make CONFIG_IDEDISK_STROKE a configuration option? I very much dislike configuration options, especially in cases like this, where the user may choose between things happening correctly and things not happening correctly. And it looks like the option is undocumented as well.
Is setting CONFIG_IDEDISK_STROKE ever harmful?

It looks like the code

+ /* if OK, compute maximum address value */
+ if ((args.tfRegister[IDE_STATUS_OFFSET] & 0x01) == 0) {
+ addr = ((args.tfRegister[IDE_SELECT_OFFSET] & 0x0f) << 24)

+                    | ((args.tfRegister[  IDE_HCYL_OFFSET]       ) << 16)
+                    | ((args.tfRegister[  IDE_LCYL_OFFSET]       ) <<  8)
+                    | ((args.tfRegister[IDE_SECTOR_OFFSET]       ));
+       }
+       addr++; /* since the return value is (maxlba - 1), we add 1 */
+       return addr;

has a bug: the addr++ should be inside the if(), I suppose. The same bug occurs a number of places.]

Andries

#1 lore raw
Quoted 8 lines · [email protected] wrote:

Some disk types fake LBA at 33.8GB, but allow access past this point. Some disks actually give I/O errors past the 33.8GB (when jumpered), and a SETMAX command is needed to make the rest accessible.

Two years ago I wrote a tiny utility setmax that does this. If I am not mistaken this stuff is now part of the 2.5 kernel. No doubt some of it will eventually be backported to 2.4 / 2.2 / 2.0. It is in 2.4.18-pre7-ac1.

Alan has said (quite reasonably) that he is not interested in inclusion of the big IDE patch that exists for 2.2.x -- however, a minimal cut and paste backport from 2.4.x IDE to just support HDIO_DRIVE_CMD_AEB (and thus support setmax) is only about a 100 line diff which I did a while ago.

If there is any interest in this I can check it still applies cleanly to current 2.2 pre kernel and send it along for inclusion.

Paul.