Re: request for test with your quirky drive enclosure

Oliver Neukum <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Am Mittwoch, 31. Januar 2007 17:22 schrieb Alan Stern:
> On Wed, 31 Jan 2007, Oliver Neukum wrote:

> If some other device ends up needing this in the future, what makes you 
> think the heuristic you have chosen will be appropriate?

I've checked my disks and asked for counterexamples.
If you have a better heuristics, please tell me. It is derived
from the informal "rules" of pseudo CHS.
 
> > +	/* Some devices have version which report the correct sizes
> > +	 * and others which do not. We guess size according toa heuristic
> > +	 * and err on the side of lowering the capacity. */
> > +	if (sdp->guess_capacity)
> 
> The patch doesn't define sdp->guess_capacity anywhere.

This is the second time today. I need a notebook. Corrected version included.

> > +		if (sdkp->capacity % 63 || sdkp->capacity % 255)
> > +			--sdkp->capacity;
> 
> This is a strange computation.  You avoid decrementing the capacity iff it
> is already divisible both by 63 and by 255.  Maybe you really want to use
> && rather than || ?  The idea being, I presume, that the last partition
> will extend only as far as a pseudo-cylinder boundary.

Yes, but I am conservative. When in doubt, decrement.
This patch is a result of despair, I am running out of solutions.

	Regards
		Oliver
----

--- a/drivers/usb/storage/unusual_devs.h	2007-01-31 14:48:08.000000000 +0100
+++ b/drivers/usb/storage/unusual_devs.h	2007-01-31 15:37:40.000000000 +0100
@@ -1323,7 +1323,7 @@
 		"DataStor",
 		"USB4500 FW1.04",
 		US_SC_DEVICE, US_PR_DEVICE, NULL,
-		US_FL_FIX_CAPACITY),
+		US_FL_CAPACITY_HEURISTICS),
 
 /* Control/Bulk transport for all SubClass values */
 USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
--- a/drivers/usb/storage/scsiglue.c	2007-01-31 14:56:36.000000000 +0100
+++ b/drivers/usb/storage/scsiglue.c	2007-01-31 15:37:35.000000000 +0100
@@ -155,6 +155,12 @@
 		if (us->flags & US_FL_FIX_CAPACITY)
 			sdev->fix_capacity = 1;
 
+		/* A few disks have two indistinguishable version, one of
+		 * which reports the correct capacity and the other does not.
+		 * The sd driver has to guess which is the case. */
+		if (us->flags & US_FL_CAPACITY_HEURISTICS)
+			sdev->guess_capacity = 1;
+
 		/* Some devices report a SCSI revision level above 2 but are
 		 * unable to handle the REPORT LUNS command (for which
 		 * support is mandatory at level 3).  Since we already have
--- a/drivers/scsi/sd.c	2007-01-31 15:33:57.000000000 +0100
+++ b/drivers/scsi/sd.c	2007-01-31 15:37:52.000000000 +0100
@@ -1274,6 +1274,13 @@
 	if (sdp->fix_capacity)
 		--sdkp->capacity;
 
+	/* Some devices have version which report the correct sizes
+	 * and others which do not. We guess size according toa heuristic
+	 * and err on the side of lowering the capacity. */
+	if (sdp->guess_capacity)
+		if (sdkp->capacity % 63 || sdkp->capacity % 255)
+			--sdkp->capacity;
+
 got_data:
 	if (sector_size == 0) {
 		sector_size = 512;
--- a/include/linux/usb_usual.h	2007-01-31 14:49:55.000000000 +0100
+++ b/include/linux/usb_usual.h	2007-01-31 15:37:49.000000000 +0100
@@ -46,7 +46,9 @@
 	US_FLAG(MAX_SECTORS_64,	0x00000400)			\
 		/* Sets max_sectors to 64    */			\
 	US_FLAG(IGNORE_DEVICE,	0x00000800)			\
-		/* Don't claim device */
+		/* Don't claim device */			\
+	US_FLAG(CAPACITY_HEURISTICS,	0x00001000)		\
+		/* sometimes sizes is too big */
 
 #define US_FLAG(name, value)	US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
--- a/include/scsi/scsi_device.h	2007-01-31 15:17:30.000000000 +0100
+++ b/include/scsi/scsi_device.h	2007-01-31 15:37:55.000000000 +0100
@@ -122,6 +122,7 @@
 	unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
 	unsigned select_no_atn:1;
 	unsigned fix_capacity:1;	/* READ_CAPACITY is too high by 1 */
+	unsigned guess_capacity:1;	/* READ_CAPACITY might be too high by 1 */
 	unsigned retry_hwerror:1;	/* Retry HARDWARE_ERROR */
 
 	unsigned int device_blocked;	/* Device returned QUEUE_FULL. */

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.