[SCSI] fix our current target reap infrastructure
[cascardo/linux.git] / include / scsi / scsi_device.h
index a44954c..ccabdc1 100644 (file)
@@ -52,8 +52,15 @@ enum scsi_device_state {
 
 enum scsi_device_event {
        SDEV_EVT_MEDIA_CHANGE   = 1,    /* media has changed */
+       SDEV_EVT_INQUIRY_CHANGE_REPORTED,               /* 3F 03  UA reported */
+       SDEV_EVT_CAPACITY_CHANGE_REPORTED,              /* 2A 09  UA reported */
+       SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED,       /* 38 07  UA reported */
+       SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED,        /* 2A 01  UA reported */
+       SDEV_EVT_LUN_CHANGE_REPORTED,                   /* 3F 0E  UA reported */
+
+       SDEV_EVT_FIRST          = SDEV_EVT_MEDIA_CHANGE,
+       SDEV_EVT_LAST           = SDEV_EVT_LUN_CHANGE_REPORTED,
 
-       SDEV_EVT_LAST           = SDEV_EVT_MEDIA_CHANGE,
        SDEV_EVT_MAXBITS        = SDEV_EVT_LAST + 1
 };
 
@@ -164,6 +171,7 @@ struct scsi_device {
        atomic_t disk_events_disable_depth; /* disable depth for disk events */
 
        DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
+       DECLARE_BITMAP(pending_events, SDEV_EVT_MAXBITS); /* pending events */
        struct list_head event_list;    /* asserted events */
        struct work_struct event_work;
 
@@ -227,12 +235,24 @@ struct scsi_dh_data {
 #define sdev_printk(prefix, sdev, fmt, a...)   \
        dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
 
+#define sdev_dbg(sdev, fmt, a...) \
+       dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
+
 #define scmd_printk(prefix, scmd, fmt, a...)                           \
         (scmd)->request->rq_disk ?                                     \
        sdev_printk(prefix, (scmd)->device, "[%s] " fmt,                \
                    (scmd)->request->rq_disk->disk_name, ##a) :         \
        sdev_printk(prefix, (scmd)->device, fmt, ##a)
 
+#define scmd_dbg(scmd, fmt, a...)                                         \
+       do {                                                               \
+               if ((scmd)->request->rq_disk)                              \
+                       sdev_dbg((scmd)->device, "[%s] " fmt,              \
+                                (scmd)->request->rq_disk->disk_name, ##a);\
+               else                                                       \
+                       sdev_dbg((scmd)->device, fmt, ##a);                \
+       } while (0)
+
 enum scsi_target_state {
        STARGET_CREATED = 1,
        STARGET_RUNNING,
@@ -249,7 +269,7 @@ struct scsi_target {
        struct list_head        siblings;
        struct list_head        devices;
        struct device           dev;
-       unsigned int            reap_ref; /* protected by the host lock */
+       struct kref             reap_ref; /* last put renders target invisible */
        unsigned int            channel;
        unsigned int            id; /* target id ... replace
                                     * scsi_device.id eventually */
@@ -261,6 +281,9 @@ struct scsi_target {
                                                 * means no lun present. */
        unsigned int            no_report_luns:1;       /* Don't use
                                                 * REPORT LUNS for scanning. */
+       unsigned int            expecting_lun_change:1; /* A device has reported
+                                                * a 3F/0E UA, other devices on
+                                                * the same target will also. */
        /* commands actually active on LLD. protected by host lock. */
        unsigned int            target_busy;
        /*
@@ -273,7 +296,6 @@ struct scsi_target {
 #define SCSI_DEFAULT_TARGET_BLOCKED    3
 
        char                    scsi_level;
-       struct execute_work     ew;
        enum scsi_target_state  state;
        void                    *hostdata; /* available to low-level driver */
        unsigned long           starget_data[0]; /* for the transport */