I have just installed/tested linux-2.2.0-pre8.

There seem to be a very old error in 
linux/drivers/scsi/sd.c
.

It appears in kernel v2.0.33 and 2.1.128 also.



I've an Adaptec 2940 UW SCSI controller and a IBM DDRS-39130 HD conected to it.

The capacity of the HD is:
9,138,286,080 bytes
8,924,107.500 KB
8,714.949     MB
8.510         GB !!! (remember: 1024 instead of 1000) !!!

The SCSI driver sd.c (linux/drivers/scsi/sd.c) reports:

=== cut ===
SCSI device sda: hdwr sector= 512 bytes. Sectors= 17850000 [8715 MB] [8.7 GB]
=== end cut===

------------------------------------------------------->    !!!!!!!   !!!!!!

The 2nd value is wrong!
8,715MB are 8.5GB - and not 8.7GB!!!

This seems not to be a major bug, but it would be nice to see the correct
values at kernel boot of a clean 2.2.0 ;-)

The following diff should explain how to correct the bug:
diff -u --recursive --new-file linux-2.2.0-pre8.orig/drivers/scsi/sd.c
linux-2.2.0-pre8/drivers/scsi/sd.c
=== cut ===
--- linux-2.2.0-pre8.orig/drivers/scsi/sd.c     Wed Jan 20 18:05:04 1999
+++ linux-2.2.0-pre8/drivers/scsi/sd.c  Wed Jan 20 19:51:31 1999
@@ -1378,7 +1378,7 @@
          * Jacques Gelinas ([EMAIL PROTECTED])
          */
         int m, mb;
-        int sz_quot, sz_rem;
+        /* int sz_quot, sz_rem;  not used anymore - calculation was wrong */
         int hard_sector = rscsi_disks[i].sector_size;
         /* There are 16 minors allocated for each major device */
         for (m=i<<4; m<((i+1)<<4); m++){
@@ -1387,12 +1387,25 @@
         mb = rscsi_disks[i].capacity / 1024 * hard_sector / 1024;
         /* sz = div(m/100, 10);  this seems to not be in the libr */
         m = (mb + 50) / 100;
+
+        /* This calculated/printed the wrong GB size!
         sz_quot = m / 10;
         sz_rem = m - (10 * sz_quot);
         printk ("SCSI device %s: hdwr sector= %d bytes."
                " Sectors= %d [%d MB] [%d.%1d GB]\n",
                 nbuff, hard_sector, rscsi_disks[i].capacity,
                 mb, sz_quot, sz_rem);
+        -- end of wrong section */
+        /* 
+         * Print whole gigabytes and tenths.  Treat tenths as a fixed point 
+         * quanitity scaled by 10, rounding up by adding .5 * .1 * 1G = 51.2M
+         * prior to the truncating division.
+         */
+        printk ("SCSI device %s: hdwr sector= %d bytes."
+                " Sectors= %d [%d MB] [%d.%1d GB]\n",
+                nbuff, hard_sector, rscsi_disks[i].capacity, 
+                mb, mb / 1024, (mb * 10 + 512) / 1024 % 10);
+
     }
         if(rscsi_disks[i].sector_size == 2048)
             rscsi_disks[i].capacity <<= 2;  /* Change into 512 byte sectors */
=== end cut ===



Looking forward for a clean 2.2.0
Niki



---
Niki W. Waibel - Author of the free N64 software emulator TrueReality

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]

Reply via email to