Skip to contentSkip to conversation

fix read capacity for large disks when CONFIG_LBD=n (updated)

PATCH In review Tony Battersby 2 participants 4 messages Jan 4, 2005 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix read capacity for large disks when CONFIG_LBD=n (updated)

(updated - this patch is correct for the case that sdkp->fix_capacity is set)

If CONFIG_LBD=n, then sd_read_capacity computes the capacity of a large disk on a 32-bit platform as 1 + 0xffffffff = 0. Make it 0xffffffff instead.

Anthony J. Battersby
Cybernetics

drivers/scsi/sd.c renamed from drivers/scsi/sd.c.orig +6 -2
@@ -1082,9 +1082,13 @@ repeat:
 				       " READ CAPACITY(16).\n", diskname);
 				longrc = 1;
 				goto repeat;
-			} else {
-				printk(KERN_ERR "%s: too big for kernel.  Assuming maximum 2Tb\n", diskname);
 			}
+			printk(KERN_ERR "%s: too big for kernel.  Assuming "
+			                "maximum 2TB\n", diskname);
+			/* Don't add 1 as is normally done to avoid
+			 * overflow. */
+			sdkp->capacity = 0xffffffff;
+			goto got_data;
 		}
 		sdkp->capacity = 1 + (((sector_t)buffer[0] << 24) |
 			(buffer[1] << 16) |
#1 lore raw
Quoted 3 lines · Tony Battersby

If CONFIG_LBD=n, then sd_read_capacity computes the capacity of a large disk on a 32-bit platform as 1 + 0xffffffff = 0. Make it 0xffffffff instead.

Actually, I don't think this is at all a good idea. Not allowing a LBD device to be configured if the user hasn't enabled LBD (which is accidentally what the current code does) seems better to me.

Imagine a 4TB fs. Plug it in to a system like this and you're going to corrupt it because you can't see half the disc.

James

#2 lore raw

RE: [PATCH] fix read capacity for large disks when CONFIG_LBD=n(updated)

Quoted 4 lines

Actually, I don't think this is at all a good idea. Not allowing a LBD
device to be configured if the user hasn't enabled LBD (which is accidentally what the current code does) seems better to me.

That's fine with me.

Anthony J. Battersby
Cybernetics

#3 lore raw

RE: [PATCH] fix read capacity for large disks when CONFIG_LBD=n(updated)

In reply to James Bottomley

Here's an alternate patch that corrects the kernel message and sets the capacity to 0 explicitly.

Anthony J. Battersby
Cybernetics

drivers/scsi/sd.c renamed from drivers/scsi/sd.c.orig +5 -2
@@ -1082,9 +1082,12 @@ repeat:
 				       " READ CAPACITY(16).\n", diskname);
 				longrc = 1;
 				goto repeat;
-			} else {
-				printk(KERN_ERR "%s: too big for kernel.  Assuming maximum 2Tb\n", diskname);
 			}
+			printk(KERN_ERR "%s: too big for this kernel.  Use a "
+			       "kernel compiled with support for large block "
+			       "devices.\n", diskname);
+			sdkp->capacity = 0;
+			goto got_data;
 		}
 		sdkp->capacity = 1 + (((sector_t)buffer[0] << 24) |
 			(buffer[1] << 16) |