Commit 2eca25e4 authored by Douglas Gilbert's avatar Douglas Gilbert Committed by James Bottomley

scsi_debug 1.64 , remove detect(), "hotplug" hosts

This patch is against lk 2.5.46-bk3 which includes
Christoph's work removing the requirement for
detect() functions in LLDDs. He sent me an example
for scsi_debug which I have built on with this patch.

As threatened, this version includes a "scsi_debug_add_host"
parameter. At kernel or module load time this is an absolute
number (0..127 are allowable and 1 is the default). So:
     modprobe scsi_debug scsi_debug_num_devs=20 scsi_debug_add_host=0
will result in no scsi_debug hosts (thus no devices) but
the driver has 20 slots available for devices.

Then a host can be introduced (simulated hotplug) by
     echo 1 > /sysfs/bus/scsi/drivers/scsi_debug/add_host
This causes a scsi_debug host to appear and devices get
found on it [14 in my system: 7 targets (0..6) each with
2 luns (0..1)]. Another host hotplug can be simulated by
     echo 1 > /sysfs/bus/scsi/drivers/scsi_debug/add_host
which results in another 6 devices being attached (for a
total of 20 scsi_debug devices as dictated by the original
scsi_debug_num_devs).

That last (second) scsi_debug host can be removed by
     echo -1 > /sysfs/bus/scsi/drivers/scsi_debug/add_host
and its 6 devices go. Another application of this "echo"
removes the first host and all remaining devices.

Seems to work fine.
parent 55b283a5
This diff is collapsed.
#ifndef _SCSI_DEBUG_H #ifndef _SCSI_DEBUG_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/kdev_t.h>
static int scsi_debug_detect(struct SHT *);
static int scsi_debug_slave_attach(struct scsi_device *); static int scsi_debug_slave_attach(struct scsi_device *);
static void scsi_debug_slave_detach(struct scsi_device *); static void scsi_debug_slave_detach(struct scsi_device *);
static int scsi_debug_release(struct Scsi_Host *);
/* static int scsi_debug_command(struct scsi_cmnd *); */
static int scsi_debug_queuecommand(struct scsi_cmnd *, static int scsi_debug_queuecommand(struct scsi_cmnd *,
void (*done) (struct scsi_cmnd *)); void (*done) (struct scsi_cmnd *));
static int scsi_debug_ioctl(struct scsi_device *, int, void *); static int scsi_debug_ioctl(struct scsi_device *, int, void *);
...@@ -20,10 +16,6 @@ static int scsi_debug_host_reset(struct scsi_cmnd *); ...@@ -20,10 +16,6 @@ static int scsi_debug_host_reset(struct scsi_cmnd *);
static int scsi_debug_proc_info(char *, char **, off_t, int, int, int); static int scsi_debug_proc_info(char *, char **, off_t, int, int, int);
static const char * scsi_debug_info(struct Scsi_Host *); static const char * scsi_debug_info(struct Scsi_Host *);
#ifndef NULL
#define NULL 0
#endif
/* /*
* This driver is written for the lk 2.5 series * This driver is written for the lk 2.5 series
*/ */
...@@ -31,14 +23,12 @@ static const char * scsi_debug_info(struct Scsi_Host *); ...@@ -31,14 +23,12 @@ static const char * scsi_debug_info(struct Scsi_Host *);
#define SCSI_DEBUG_MAX_CMD_LEN 16 #define SCSI_DEBUG_MAX_CMD_LEN 16
static Scsi_Host_Template driver_template = { static Scsi_Host_Template sdebug_driver_template = {
.proc_info = scsi_debug_proc_info, .proc_info = scsi_debug_proc_info,
.name = "SCSI DEBUG", .name = "SCSI DEBUG",
.info = scsi_debug_info, .info = scsi_debug_info,
.detect = scsi_debug_detect,
.slave_attach = scsi_debug_slave_attach, .slave_attach = scsi_debug_slave_attach,
.slave_detach = scsi_debug_slave_detach, .slave_detach = scsi_debug_slave_detach,
.release = scsi_debug_release,
.ioctl = scsi_debug_ioctl, .ioctl = scsi_debug_ioctl,
.queuecommand = scsi_debug_queuecommand, .queuecommand = scsi_debug_queuecommand,
.eh_abort_handler = scsi_debug_abort, .eh_abort_handler = scsi_debug_abort,
...@@ -50,8 +40,9 @@ static Scsi_Host_Template driver_template = { ...@@ -50,8 +40,9 @@ static Scsi_Host_Template driver_template = {
.this_id = 7, .this_id = 7,
.sg_tablesize = 64, .sg_tablesize = 64,
.cmd_per_lun = 3, .cmd_per_lun = 3,
.max_sectors = 4096,
.unchecked_isa_dma = 0, .unchecked_isa_dma = 0,
.use_clustering = ENABLE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING,
}; /* the name 'driver_template' is used by scsi_module.c */ };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment