make ide-scsi more selective
RFC PATCH 1/1 make ide-scsi more selective
Quoted 3 lines · Ion Badulescu
The current IDE code doesn't allow the user to reserve a drive to be used only with ide-scsi emulation, if the ide-scsi layer is compiled as a module.
I've been rather annoyed by a dual problem in the ide-scsi setup:
during initialisation, ide-scsi will claim ALL currently unassigned IDE devices. This is a problem in modular setups, since there's no guarantee that currently unassigned devices actually are intended for ide-scsi.
In my case ide-scsi would often steal my ATAPI tape drive since my ide-tape module usually isn't loaded. Since I don't want this to happen (for both practical and aesthetic reasons) I've used a hack in my /etc/modules.conf to forcibly load ide-tape before scsi_mod, but this is extremely ugly.
Seeing Ion's comment I decided to do something about this, so I implemented a "units=" module parameter for ide-scsi, which causes ide-scsi to skip units not explicitly listed. For symmetry one can also specify this with a "idescsi=" kernel boot parameter.
Caveat: When listing multiple units, don't use "," to separate their names (e.g. units=hdc,hdd). modutils insists that "," separates array elements but the actual MODULE_PARM is a single string. I'd use "+" instead (e.g. units=hdc+hdd), except I actually want to restrict ide-scsi to a single unit, so I pass "units=hdc" to it.
The patch below implements this option for 2.4.8-ac9. I've also put it in http://www.csd.uu.se/~mikpe/linux/idescsi/ together with patches for 2.2.20pre9 with and without Andre's big IDE patch.
Comments?
/Mikael
drivers/ide/ide.c renamed from drivers/ide/ide.c.~1~ +3 -0
@@ -3006,6 +3006,9 @@if (strncmp (s,"hd" ,2 ) ==0 && s[2 ] =='=' )/* hd= is for hd.c */ return 0 ;/* driver and not us */ +if (!strncmp (s,"idescsi=" ,8 ))/* for ide-scsi.c not us */ +return 0 ; +if (strncmp (s,"ide" ,3 ) &&strncmp (s,"idebus" ,6 ) &&strncmp (s,"hd" ,2 ))/* hdx= & hdxlun= */
drivers/scsi/ide-scsi.c renamed from drivers/scsi/ide-scsi.c.~1~ +15 -1
@@ -561,6 +561,19 @@ NULL }; +static char *units; +#ifdef MODULE +MODULE_PARM (units,"s" ); +#else +/* the name "idescsi_setup" has already been taken :-( */ +static int __init setup_idescsi (char *s) +{ + units = s; +return 1 ; +} +__setup ("idescsi=" , setup_idescsi); +#endif +/* * idescsi_init will register the driver for each scsi. */
@@ -580,7 +593,8 @@for (i =0 ; media[i] !=255 ; i++) { failed =0 ;while ((drive =ide_scan_devices (media[i], idescsi_driver.name,NULL , failed++)) !=NULL ) { - +if (units && !strstr (units, drive->name)) +continue ;if ((scsi = (idescsi_scsi_t *)kmalloc (sizeof (idescsi_scsi_t),GFP_KERNEL )) ==NULL ) {printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n" , drive->name);continue ;
Quoted 3 lines · Mikael Pettersson
Caveat: When listing multiple units, don't use "," to separate their names (e.g. units=hdc,hdd). modutils insists that "," separates array elements but the actual
MODULE_PARMis a single string.
man modules.conf, under options keyword
If any of the MODULE_SPECIFIC_OPTIONS contain characters that are special to the shell (e.g. space, comma, parentheses) then the option must be enclosed in '"..."'. The '' delimit the option in modules.conf, the "" delimit the option when it is passed to the shell. For example,
abc='"def,ghi jkl (xyz)"'
If that does not work for a string, tell me.