Skip to contentSkip to conversation

PATCH: Bogus disk geometry on large disks

PATCH Alan Cox 3 participants 5 messages May 26, 2006 SCSI

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

We currently stuff a truncated size into the geometry logic and return the result which can produce bizarre reports for a 4Tb array. Since that mapping logic isn't useful for disks that big don't try and map this way at all.

drivers/scsi/scsicam.c +1 -1
@@ -68,7 +68,7 @@
 			       (unsigned int *)ip + 0, (unsigned int *)ip + 1);
 	kfree(p);
 
-	if (ret == -1) {
+	if (ret == -1 && capacity < (1ULL << 32)) {
 		/* pick some standard mapping with at most 1024 cylinders,
 		   and at most 62 sectors per track - this works up to
 		   7905 MB */
#1 lore raw

drivers/scsi/scsicam.c line 72

Quoted 4 lines · Alan Cox
drivers/scsi/scsicam.c +1 -1
-	if (ret == -1) {
+	if (ret == -1 && capacity < (1ULL << 32)) {
 		/* pick some standard mapping with at most 1024 cylinders,

won't that provoke a gcc warning when sector_t is 32-bit? how about ...

+ if (ret == -1 && ((capacity >> 16) >> 16) > 0)

instead?

author
#2 lore raw
Quoted 7 lines · Matthew Wilcox

drivers/scsi/scsicam.c line 72

Quoted 4 lines · Alan Cox
drivers/scsi/scsicam.c +1 -1
-	if (ret == -1) {
+	if (ret == -1 && capacity < (1ULL << 32)) {
 		/* pick some standard mapping with at most 1024 cylinders,

won't that provoke a gcc warning when sector_t is 32-bit? how about ...

I don't believe it will as the type is forced to "1ULL"

#3 lore raw
Quoted 10 lines · Alan Cox
Quoted 7 lines · Matthew Wilcox

drivers/scsi/scsicam.c line 72

Quoted 4 lines · Alan Cox
drivers/scsi/scsicam.c +1 -1
-	if (ret == -1) {
+	if (ret == -1 && capacity < (1ULL << 32)) {
 		/* pick some standard mapping with at most 1024 cylinders,

won't that provoke a gcc warning when sector_t is 32-bit? how about ...

I don't believe it will as the type is forced to "1ULL"

gcc disagrees with you ;-)

$ cat test.c 
unsigned int y;

int main(void)

{
        if (y < (1ULL << 32))
                return 0;
        return 1;
}
$ gcc -O2 -W -Wall -o test test.c
test.c: In function ‘main’:
test.c:5: warning: comparison is always true due to limited range of data type
$ cat test.c 
unsigned int y;

int main(void)

{
        if (((y >> 16) >> 16) > 0)
                return 0;
        return 1;
}
$ gcc -O2 -W -Wall -o test test.c

(anyone know how you turn off that fucking UTF8 crap that gcc insists on putting into its warning/error messages? Who thought that was a good idea?)

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

On Fri, 26 May 2006 12:20:02 MDT, Matthew Wilcox wrote:
...

Quoted 3 lines

(anyone know how you turn off that fucking UTF8 crap that gcc insists on putting into its warning/error messages? Who thought that was a good idea?)

LANG=C works here, and inside emacs.

However, when run from gterm in FC5, looks ok on the screen.

$ gcc -O2 -W -Wall -o test test.c
x.c: In function \u2018main\u2019:
x.c:5: warning: comparison is always true due to limited range of data type
$ echo $LANG
en_US.UTF-8
$ LANG=C gcc -O2 -W -Wall -o test x.c
x.c: In function 'main':
x.c:5: warning: comparison is always true due to limited range of data type
$

So it appears to fix.

++doug