[SCSI] megaraid_sas: Fix FastPath I/O to work on degraded raid 1
[linux-2.6.git] / drivers / scsi / scsi_sysfs.c
index c3f6737..e0bd3f7 100644 (file)
@@ -251,6 +251,7 @@ shost_rd_attr(host_busy, "%hu\n");
 shost_rd_attr(cmd_per_lun, "%hd\n");
 shost_rd_attr(can_queue, "%hd\n");
 shost_rd_attr(sg_tablesize, "%hu\n");
+shost_rd_attr(sg_prot_tablesize, "%hu\n");
 shost_rd_attr(unchecked_isa_dma, "%d\n");
 shost_rd_attr(prot_capabilities, "%u\n");
 shost_rd_attr(prot_guard_type, "%hd\n");
@@ -262,6 +263,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = {
        &dev_attr_cmd_per_lun.attr,
        &dev_attr_can_queue.attr,
        &dev_attr_sg_tablesize.attr,
+       &dev_attr_sg_prot_tablesize.attr,
        &dev_attr_unchecked_isa_dma.attr,
        &dev_attr_proc_name.attr,
        &dev_attr_scan.attr,
@@ -320,14 +322,9 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
                kfree(evt);
        }
 
-       if (sdev->request_queue) {
-               sdev->request_queue->queuedata = NULL;
-               /* user context needed to free queue */
-               scsi_free_queue(sdev->request_queue);
-               /* temporary expedient, try to catch use of queue lock
-                * after free of sdev */
-               sdev->request_queue = NULL;
-       }
+       blk_put_queue(sdev->request_queue);
+       /* NULL queue means the device can't be used */
+       sdev->request_queue = NULL;
 
        scsi_target_reap(scsi_target(sdev));
 
@@ -381,7 +378,7 @@ struct bus_type scsi_bus_type = {
         .name          = "scsi",
         .match         = scsi_bus_match,
        .uevent         = scsi_bus_uevent,
-#ifdef CONFIG_PM_OPS
+#ifdef CONFIG_PM
        .pm             = &scsi_bus_pm_ops,
 #endif
 };
@@ -862,13 +859,15 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 
        error = device_add(&sdev->sdev_gendev);
        if (error) {
-               printk(KERN_INFO "error 1\n");
+               sdev_printk(KERN_INFO, sdev,
+                               "failed to add device: %d\n", error);
                return error;
        }
        device_enable_async_suspend(&sdev->sdev_dev);
        error = device_add(&sdev->sdev_dev);
        if (error) {
-               printk(KERN_INFO "error 2\n");
+               sdev_printk(KERN_INFO, sdev,
+                               "failed to add class device: %d\n", error);
                device_del(&sdev->sdev_gendev);
                return error;
        }
@@ -933,6 +932,12 @@ void __scsi_remove_device(struct scsi_device *sdev)
        if (sdev->host->hostt->slave_destroy)
                sdev->host->hostt->slave_destroy(sdev);
        transport_destroy_device(dev);
+
+       /* cause the request function to reject all I/O requests */
+       sdev->request_queue->queuedata = NULL;
+
+       /* Freeing the queue signals to block that we're done */
+       scsi_free_queue(sdev->request_queue);
        put_device(dev);
 }
 
@@ -962,10 +967,11 @@ static void __scsi_remove_target(struct scsi_target *starget)
        list_for_each_entry(sdev, &shost->__devices, siblings) {
                if (sdev->channel != starget->channel ||
                    sdev->id != starget->id ||
-                   sdev->sdev_state == SDEV_DEL)
+                   scsi_device_get(sdev))
                        continue;
                spin_unlock_irqrestore(shost->host_lock, flags);
                scsi_remove_device(sdev);
+               scsi_device_put(sdev);
                spin_lock_irqsave(shost->host_lock, flags);
                goto restart;
        }
@@ -990,16 +996,14 @@ static int __remove_child (struct device * dev, void * data)
  */
 void scsi_remove_target(struct device *dev)
 {
-       struct device *rdev;
-
        if (scsi_is_target_device(dev)) {
                __scsi_remove_target(to_scsi_target(dev));
                return;
        }
 
-       rdev = get_device(dev);
+       get_device(dev);
        device_for_each_child(dev, NULL, __remove_child);
-       put_device(rdev);
+       put_device(dev);
 }
 EXPORT_SYMBOL(scsi_remove_target);