PATCH: 2.6.10 - Still mishandles volumes without geometry data
An IDE device can choose not to report geometry. In this situation the base 2.6 kernel tries to verify the LBA data despite having nothing to validate it against and prints it out (although now only as pr_debug).
This patch fixes these problems and has in various forms been in 2.6.9-ac and Fedora Core for a considerable time now
drivers/ide/ide-disk.c +6 -1
@@ -84,6 +84,10 @@ {unsigned long lba_sects, chs_sects, head, tail; +/* No non-LBA info .. so valid! */ +if (id->cyls ==0 ) +return 1 ; +/* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size.
@@ -201,7 +205,8 @@ head = track % drive->head; cyl = track / drive->head; -pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); +if (drive->bios_cyl) +pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); hwif->OUTB (0x00 ,IDE_FEATURE_REG ); hwif->OUTB (nsectors.b.low,IDE_NSECTOR_REG );
Quoted 22 lines · Alan Cox
An IDE device can choose not to report geometry. In this situation the base 2.6 kernel tries to verify the LBA data despite having nothing to validate it against and prints it out (although now only as
pr_debug).This patch fixes these problems and has in various forms been in 2.6.9-ac and Fedora Core for a considerable time now
diff -u --new-file --recursive --exclude-from
/usr/src/excludelinux.vanilla-2.6.10/drivers/ide/ide-disk.clinux-2.6.10/drivers/ide/ide-disk.cdrivers/ide/ide-disk.c 2004-12-26 21:55:43.084714368 +0000 renamed from drivers/ide/ide-disk.c 2004-12-25 21:15:34.000000000 +0000 +4
-0@@ -84,6 +84,10 @@ { unsigned long lba_sects, chs_sects, head, tail; + /* No non-LBA info .. so valid! */ + if (id->cyls == 0) + return 1; + /* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size.
drivers/ide/ide-disk.c 2004-12-26 21:55:43.084714368 +0000 line 212
Quoted 9 lines
drivers/ide/ide-disk.c 2004-12-26 21:55:43.084714368 +0000 renamed from drivers/ide/ide-disk.c 2004-12-25 21:15:34.000000000 +0000 +2
-1@@ -201,7 +205,8 @@ head = track % drive->head; cyl = track / drive->head; - pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect); + if(drive->bios_cyl) + pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect); hwif->OUTB(0x00, IDE_FEATURE_REG); hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
Shouldn't this check be around printk in idedisk_setup() instead?
Quoted 4 lines
Quoted 3 lines
+
/*Shouldn't this check be around printk in
idedisk_setup()instead?
Yes that would be useful as well. I'll send you a new patch that catches that printk as well.
Ok how about this revision which also silences the boot time CHS data as Bartlomiej suggested.
drivers/ide/ide-disk.c +9 -3
@@ -84,6 +84,10 @@ {unsigned long lba_sects, chs_sects, head, tail; +/* No non-LBA info .. so valid! */ +if (id->cyls ==0 ) +return 1 ; +/* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size.
@@ -201,7 +205,8 @@ head = track % drive->head; cyl = track / drive->head; -pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); +if (cyl) +pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); hwif->OUTB (0x00 ,IDE_FEATURE_REG ); hwif->OUTB (nsectors.b.low,IDE_NSECTOR_REG );
@@ -1239,8 +1257,9 @@if (id->buf_size)printk (" w/%dKiB Cache" , id->buf_size/2 ); -printk (", CHS=%d/%d/%d" , - drive->bios_cyl, drive->bios_head, drive->bios_sect); +if (drive->bios_cyl) +printk (", CHS=%d/%d/%d" , + drive->bios_cyl, drive->bios_head, drive->bios_sect);if (drive->using_dma)ide_dma_verbose (drive);printk ("\n" );
Quoted 6 lines · Alan Cox
Ok how about this revision which also silences the boot time CHS data as Bartlomiej suggested.
drivers/ide/ide-disk.c line 93
Quoted 10 lines
drivers/ide/ide-disk.c +4
-0@@ -84,6 +84,10 @@ {unsigned long lba_sects, chs_sects, head, tail; +/* No non-LBA info .. so valid! */ +if (id->cyls ==0 ) +return 1 ; +/* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size.
Reasonable in case this actually occurs. Do you have examples?
drivers/ide/ide-disk.c line 212
Quoted 10 lines
drivers/ide/ide-disk.c +2
-1@@ -201,7 +205,8 @@ head = track % drive->head; cyl = track / drive->head; -pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); +if (cyl) +pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); hwif->OUTB (0x00 ,IDE_FEATURE_REG ); hwif->OUTB (nsectors.b.low,IDE_NSECTOR_REG );
Unreasonable. This part must be a misunderstanding. The cyl here is not the number of cylinders of a disk, it is the cylinder affected by I/O and may well be zero.
drivers/ide/ide-disk.c line 1265
Quoted 12 lines
drivers/ide/ide-disk.c +3
-2@@ -1239,8 +1257,9 @@if (id->buf_size)printk (" w/%dKiB Cache" , id->buf_size/2 ); -printk (", CHS=%d/%d/%d" , - drive->bios_cyl, drive->bios_head, drive->bios_sect); +if (drive->bios_cyl) +printk (", CHS=%d/%d/%d" , + drive->bios_cyl, drive->bios_head, drive->bios_sect);if (drive->using_dma)ide_dma_verbose (drive);printk ("\n" );
Reasonable. (But s/if(/if (/ .)
On the other hand, I like the "CHS=0/0/0" - it makes very clear what is wrong in case lilo or so has geometry problems.
Andries
Quoted 9 lines · Andries Brouwer
drivers/ide/ide-disk.c line 93
Quoted 7 lines
drivers/ide/ide-disk.c +4
-0+/* No non-LBA info .. so valid! */ +if (id->cyls ==0 ) +return 1 ; +/* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size. Reasonable in case this actually occurs. Do you have examples?
Yes - raid volumes on IT8212 is one such example.
Quoted 9 lines
drivers/ide/ide-disk.c line 212
Quoted 6 lines
drivers/ide/ide-disk.c +2
-1-pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); +if (cyl) +pr_debug ("%s: CHS=%u/%u/%u\n" , drive->name, cyl, head, sect); hwif->OUTB (0x00 ,IDE_FEATURE_REG ); hwif->OUTB (nsectors.b.low,IDE_NSECTOR_REG );Unreasonable. This part must be a misunderstanding. The cyl here is not the number of cylinders of a disk,
Yep - as Bartlomiej correctly noted this was a mismerge when I fixed up to 2.6.10
Quoted 4 lines
Quoted 4 lines
drivers/ide/ide-disk.c +2
-2-printk (", CHS=%d/%d/%d" , - drive->bios_cyl, drive->bios_head, drive->bios_sect); +if (drive->bios_cyl) + printk(", CHS=%d/%d/%d",
Quoted 8 lines
drivers/ide/ide-disk.c line 1265
Quoted 4 lines
drivers/ide/ide-disk.c +1
-0+ drive->bios_cyl, drive->bios_head, drive->bios_sect);if (drive->using_dma)ide_dma_verbose (drive);printk ("\n" );Reasonable. (But s/if(/if (/ .)
On the other hand, I like the "CHS=0/0/0" - it makes very clear what is wrong in case lilo or so has geometry problems.
0/0/0 is valid in these cases - would it be better if it printed something else instead for that situation ("No physical geometry, ") perhaps ?
Quoted 10 lines · Alan Cox
Quoted 9 lines
drivers/ide/ide-disk.c line 1262
Quoted 5 lines
drivers/ide/ide-disk.c +3
-2-printk (", CHS=%d/%d/%d" , - drive->bios_cyl, drive->bios_head, drive->bios_sect); +if (drive->bios_cyl) +printk (", CHS=%d/%d/%d" , + drive->bios_cyl, drive->bios_head, drive->bios_sect);Reasonable. (But s/if(/if (/ .)
On the other hand, I like the "CHS=0/0/0" - it makes very clear what is wrong in case lilo or so has geometry problems.
Quoted 3 lines
0/0/0 is valid in these cases - would it be better if it printed something else instead for that situation ("No physical geometry, ") perhaps ?
But it is not the "physical geometry" (whatever that may be) that is printed. Not drive->head but drive->bios_head. It is easiest just to leave it.
Andries