diff options
| -rw-r--r-- | drivers/s390/scsi/zfcp_erp.c | 29 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 8 | ||||
| -rw-r--r-- | drivers/s390/scsi/zfcp_sysfs.c | 14 | ||||
| -rw-r--r-- | drivers/scsi/Kconfig | 1 | ||||
| -rw-r--r-- | fs/bio.c | 20 | ||||
| -rw-r--r-- | include/linux/wait.h | 57 |
6 files changed, 110 insertions, 19 deletions
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 1d4c8fe72752..c82fe65c4128 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
| @@ -102,10 +102,13 @@ static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) | |||
| 102 | 102 | ||
| 103 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 103 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 104 | zfcp_erp_action_dismiss(&port->erp_action); | 104 | zfcp_erp_action_dismiss(&port->erp_action); |
| 105 | else | 105 | else { |
| 106 | shost_for_each_device(sdev, port->adapter->scsi_host) | 106 | spin_lock(port->adapter->scsi_host->host_lock); |
| 107 | __shost_for_each_device(sdev, port->adapter->scsi_host) | ||
| 107 | if (sdev_to_zfcp(sdev)->port == port) | 108 | if (sdev_to_zfcp(sdev)->port == port) |
| 108 | zfcp_erp_action_dismiss_lun(sdev); | 109 | zfcp_erp_action_dismiss_lun(sdev); |
| 110 | spin_unlock(port->adapter->scsi_host->host_lock); | ||
| 111 | } | ||
| 109 | } | 112 | } |
| 110 | 113 | ||
| 111 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) | 114 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) |
| @@ -592,9 +595,11 @@ static void _zfcp_erp_lun_reopen_all(struct zfcp_port *port, int clear, | |||
| 592 | { | 595 | { |
| 593 | struct scsi_device *sdev; | 596 | struct scsi_device *sdev; |
| 594 | 597 | ||
| 595 | shost_for_each_device(sdev, port->adapter->scsi_host) | 598 | spin_lock(port->adapter->scsi_host->host_lock); |
| 599 | __shost_for_each_device(sdev, port->adapter->scsi_host) | ||
| 596 | if (sdev_to_zfcp(sdev)->port == port) | 600 | if (sdev_to_zfcp(sdev)->port == port) |
| 597 | _zfcp_erp_lun_reopen(sdev, clear, id, 0); | 601 | _zfcp_erp_lun_reopen(sdev, clear, id, 0); |
| 602 | spin_unlock(port->adapter->scsi_host->host_lock); | ||
| 598 | } | 603 | } |
| 599 | 604 | ||
| 600 | static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) | 605 | static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) |
| @@ -1434,8 +1439,10 @@ void zfcp_erp_set_adapter_status(struct zfcp_adapter *adapter, u32 mask) | |||
| 1434 | atomic_set_mask(common_mask, &port->status); | 1439 | atomic_set_mask(common_mask, &port->status); |
| 1435 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | 1440 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
| 1436 | 1441 | ||
| 1437 | shost_for_each_device(sdev, adapter->scsi_host) | 1442 | spin_lock_irqsave(adapter->scsi_host->host_lock, flags); |
| 1443 | __shost_for_each_device(sdev, adapter->scsi_host) | ||
| 1438 | atomic_set_mask(common_mask, &sdev_to_zfcp(sdev)->status); | 1444 | atomic_set_mask(common_mask, &sdev_to_zfcp(sdev)->status); |
| 1445 | spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags); | ||
| 1439 | } | 1446 | } |
| 1440 | 1447 | ||
| 1441 | /** | 1448 | /** |
| @@ -1469,11 +1476,13 @@ void zfcp_erp_clear_adapter_status(struct zfcp_adapter *adapter, u32 mask) | |||
| 1469 | } | 1476 | } |
| 1470 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | 1477 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
| 1471 | 1478 | ||
| 1472 | shost_for_each_device(sdev, adapter->scsi_host) { | 1479 | spin_lock_irqsave(adapter->scsi_host->host_lock, flags); |
| 1480 | __shost_for_each_device(sdev, adapter->scsi_host) { | ||
| 1473 | atomic_clear_mask(common_mask, &sdev_to_zfcp(sdev)->status); | 1481 | atomic_clear_mask(common_mask, &sdev_to_zfcp(sdev)->status); |
| 1474 | if (clear_counter) | 1482 | if (clear_counter) |
| 1475 | atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); | 1483 | atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); |
| 1476 | } | 1484 | } |
| 1485 | spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags); | ||
| 1477 | } | 1486 | } |
| 1478 | 1487 | ||
| 1479 | /** | 1488 | /** |
| @@ -1487,16 +1496,19 @@ void zfcp_erp_set_port_status(struct zfcp_port *port, u32 mask) | |||
| 1487 | { | 1496 | { |
| 1488 | struct scsi_device *sdev; | 1497 | struct scsi_device *sdev; |
| 1489 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; | 1498 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
| 1499 | unsigned long flags; | ||
| 1490 | 1500 | ||
| 1491 | atomic_set_mask(mask, &port->status); | 1501 | atomic_set_mask(mask, &port->status); |
| 1492 | 1502 | ||
| 1493 | if (!common_mask) | 1503 | if (!common_mask) |
| 1494 | return; | 1504 | return; |
| 1495 | 1505 | ||
| 1496 | shost_for_each_device(sdev, port->adapter->scsi_host) | 1506 | spin_lock_irqsave(port->adapter->scsi_host->host_lock, flags); |
| 1507 | __shost_for_each_device(sdev, port->adapter->scsi_host) | ||
| 1497 | if (sdev_to_zfcp(sdev)->port == port) | 1508 | if (sdev_to_zfcp(sdev)->port == port) |
| 1498 | atomic_set_mask(common_mask, | 1509 | atomic_set_mask(common_mask, |
| 1499 | &sdev_to_zfcp(sdev)->status); | 1510 | &sdev_to_zfcp(sdev)->status); |
| 1511 | spin_unlock_irqrestore(port->adapter->scsi_host->host_lock, flags); | ||
| 1500 | } | 1512 | } |
| 1501 | 1513 | ||
| 1502 | /** | 1514 | /** |
| @@ -1511,6 +1523,7 @@ void zfcp_erp_clear_port_status(struct zfcp_port *port, u32 mask) | |||
| 1511 | struct scsi_device *sdev; | 1523 | struct scsi_device *sdev; |
| 1512 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; | 1524 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
| 1513 | u32 clear_counter = mask & ZFCP_STATUS_COMMON_ERP_FAILED; | 1525 | u32 clear_counter = mask & ZFCP_STATUS_COMMON_ERP_FAILED; |
| 1526 | unsigned long flags; | ||
| 1514 | 1527 | ||
| 1515 | atomic_clear_mask(mask, &port->status); | 1528 | atomic_clear_mask(mask, &port->status); |
| 1516 | 1529 | ||
| @@ -1520,13 +1533,15 @@ void zfcp_erp_clear_port_status(struct zfcp_port *port, u32 mask) | |||
| 1520 | if (clear_counter) | 1533 | if (clear_counter) |
| 1521 | atomic_set(&port->erp_counter, 0); | 1534 | atomic_set(&port->erp_counter, 0); |
| 1522 | 1535 | ||
| 1523 | shost_for_each_device(sdev, port->adapter->scsi_host) | 1536 | spin_lock_irqsave(port->adapter->scsi_host->host_lock, flags); |
| 1537 | __shost_for_each_device(sdev, port->adapter->scsi_host) | ||
| 1524 | if (sdev_to_zfcp(sdev)->port == port) { | 1538 | if (sdev_to_zfcp(sdev)->port == port) { |
| 1525 | atomic_clear_mask(common_mask, | 1539 | atomic_clear_mask(common_mask, |
| 1526 | &sdev_to_zfcp(sdev)->status); | 1540 | &sdev_to_zfcp(sdev)->status); |
| 1527 | if (clear_counter) | 1541 | if (clear_counter) |
| 1528 | atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); | 1542 | atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); |
| 1529 | } | 1543 | } |
| 1544 | spin_unlock_irqrestore(port->adapter->scsi_host->host_lock, flags); | ||
| 1530 | } | 1545 | } |
| 1531 | 1546 | ||
| 1532 | /** | 1547 | /** |
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 665e3cfaaf85..de0598eaacd2 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
| @@ -224,11 +224,9 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, | |||
| 224 | 224 | ||
| 225 | static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) | 225 | static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) |
| 226 | { | 226 | { |
| 227 | spin_lock_irq(&qdio->req_q_lock); | ||
| 228 | if (atomic_read(&qdio->req_q_free) || | 227 | if (atomic_read(&qdio->req_q_free) || |
| 229 | !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) | 228 | !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) |
| 230 | return 1; | 229 | return 1; |
| 231 | spin_unlock_irq(&qdio->req_q_lock); | ||
| 232 | return 0; | 230 | return 0; |
| 233 | } | 231 | } |
| 234 | 232 | ||
| @@ -246,9 +244,8 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) | |||
| 246 | { | 244 | { |
| 247 | long ret; | 245 | long ret; |
| 248 | 246 | ||
| 249 | spin_unlock_irq(&qdio->req_q_lock); | 247 | ret = wait_event_interruptible_lock_irq_timeout(qdio->req_q_wq, |
| 250 | ret = wait_event_interruptible_timeout(qdio->req_q_wq, | 248 | zfcp_qdio_sbal_check(qdio), qdio->req_q_lock, 5 * HZ); |
| 251 | zfcp_qdio_sbal_check(qdio), 5 * HZ); | ||
| 252 | 249 | ||
| 253 | if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) | 250 | if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) |
| 254 | return -EIO; | 251 | return -EIO; |
| @@ -262,7 +259,6 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) | |||
| 262 | zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1"); | 259 | zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1"); |
| 263 | } | 260 | } |
| 264 | 261 | ||
| 265 | spin_lock_irq(&qdio->req_q_lock); | ||
| 266 | return -EIO; | 262 | return -EIO; |
| 267 | } | 263 | } |
| 268 | 264 | ||
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 3f01bbf0609f..890639274bcf 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c | |||
| @@ -27,6 +27,16 @@ static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \ | |||
| 27 | static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ | 27 | static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ |
| 28 | zfcp_sysfs_##_feat##_##_name##_show, NULL); | 28 | zfcp_sysfs_##_feat##_##_name##_show, NULL); |
| 29 | 29 | ||
| 30 | #define ZFCP_DEFINE_ATTR_CONST(_feat, _name, _format, _value) \ | ||
| 31 | static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \ | ||
| 32 | struct device_attribute *at,\ | ||
| 33 | char *buf) \ | ||
| 34 | { \ | ||
| 35 | return sprintf(buf, _format, _value); \ | ||
| 36 | } \ | ||
| 37 | static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ | ||
| 38 | zfcp_sysfs_##_feat##_##_name##_show, NULL); | ||
| 39 | |||
| 30 | #define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \ | 40 | #define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \ |
| 31 | static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ | 41 | static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ |
| 32 | struct device_attribute *at,\ | 42 | struct device_attribute *at,\ |
| @@ -75,6 +85,8 @@ ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n", | |||
| 75 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", | 85 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", |
| 76 | (zfcp_unit_sdev_status(unit) & | 86 | (zfcp_unit_sdev_status(unit) & |
| 77 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); | 87 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); |
| 88 | ZFCP_DEFINE_ATTR_CONST(unit, access_shared, "%d\n", 0); | ||
| 89 | ZFCP_DEFINE_ATTR_CONST(unit, access_readonly, "%d\n", 0); | ||
| 78 | 90 | ||
| 79 | static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, | 91 | static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, |
| 80 | struct device_attribute *attr, | 92 | struct device_attribute *attr, |
| @@ -347,6 +359,8 @@ static struct attribute *zfcp_unit_attrs[] = { | |||
| 347 | &dev_attr_unit_in_recovery.attr, | 359 | &dev_attr_unit_in_recovery.attr, |
| 348 | &dev_attr_unit_status.attr, | 360 | &dev_attr_unit_status.attr, |
| 349 | &dev_attr_unit_access_denied.attr, | 361 | &dev_attr_unit_access_denied.attr, |
| 362 | &dev_attr_unit_access_shared.attr, | ||
| 363 | &dev_attr_unit_access_readonly.attr, | ||
| 350 | NULL | 364 | NULL |
| 351 | }; | 365 | }; |
| 352 | static struct attribute_group zfcp_unit_attr_group = { | 366 | static struct attribute_group zfcp_unit_attr_group = { |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 48b2918e0d65..92ff027746f2 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
| @@ -1353,7 +1353,6 @@ config SCSI_LPFC | |||
| 1353 | tristate "Emulex LightPulse Fibre Channel Support" | 1353 | tristate "Emulex LightPulse Fibre Channel Support" |
| 1354 | depends on PCI && SCSI | 1354 | depends on PCI && SCSI |
| 1355 | select SCSI_FC_ATTRS | 1355 | select SCSI_FC_ATTRS |
| 1356 | select GENERIC_CSUM | ||
| 1357 | select CRC_T10DIF | 1356 | select CRC_T10DIF |
| 1358 | help | 1357 | help |
| 1359 | This lpfc driver supports the Emulex LightPulse | 1358 | This lpfc driver supports the Emulex LightPulse |
| @@ -1045,12 +1045,22 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs, | |||
| 1045 | int bio_uncopy_user(struct bio *bio) | 1045 | int bio_uncopy_user(struct bio *bio) |
| 1046 | { | 1046 | { |
| 1047 | struct bio_map_data *bmd = bio->bi_private; | 1047 | struct bio_map_data *bmd = bio->bi_private; |
| 1048 | int ret = 0; | 1048 | struct bio_vec *bvec; |
| 1049 | int ret = 0, i; | ||
| 1049 | 1050 | ||
| 1050 | if (!bio_flagged(bio, BIO_NULL_MAPPED)) | 1051 | if (!bio_flagged(bio, BIO_NULL_MAPPED)) { |
| 1051 | ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, | 1052 | /* |
| 1052 | bmd->nr_sgvecs, bio_data_dir(bio) == READ, | 1053 | * if we're in a workqueue, the request is orphaned, so |
| 1053 | 0, bmd->is_our_pages); | 1054 | * don't copy into a random user address space, just free. |
| 1055 | */ | ||
| 1056 | if (current->mm) | ||
| 1057 | ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, | ||
| 1058 | bmd->nr_sgvecs, bio_data_dir(bio) == READ, | ||
| 1059 | 0, bmd->is_our_pages); | ||
| 1060 | else if (bmd->is_our_pages) | ||
| 1061 | bio_for_each_segment_all(bvec, bio, i) | ||
| 1062 | __free_page(bvec->bv_page); | ||
| 1063 | } | ||
| 1054 | bio_free_map_data(bmd); | 1064 | bio_free_map_data(bmd); |
| 1055 | bio_put(bio); | 1065 | bio_put(bio); |
| 1056 | return ret; | 1066 | return ret; |
diff --git a/include/linux/wait.h b/include/linux/wait.h index f487a4750b7f..a67fc1635592 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
| @@ -811,6 +811,63 @@ do { \ | |||
| 811 | __ret; \ | 811 | __ret; \ |
| 812 | }) | 812 | }) |
| 813 | 813 | ||
| 814 | #define __wait_event_interruptible_lock_irq_timeout(wq, condition, \ | ||
| 815 | lock, ret) \ | ||
| 816 | do { \ | ||
| 817 | DEFINE_WAIT(__wait); \ | ||
| 818 | \ | ||
| 819 | for (;;) { \ | ||
| 820 | prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \ | ||
| 821 | if (condition) \ | ||
| 822 | break; \ | ||
| 823 | if (signal_pending(current)) { \ | ||
| 824 | ret = -ERESTARTSYS; \ | ||
| 825 | break; \ | ||
| 826 | } \ | ||
| 827 | spin_unlock_irq(&lock); \ | ||
| 828 | ret = schedule_timeout(ret); \ | ||
| 829 | spin_lock_irq(&lock); \ | ||
| 830 | if (!ret) \ | ||
| 831 | break; \ | ||
| 832 | } \ | ||
| 833 | finish_wait(&wq, &__wait); \ | ||
| 834 | } while (0) | ||
| 835 | |||
| 836 | /** | ||
| 837 | * wait_event_interruptible_lock_irq_timeout - sleep until a condition gets true or a timeout elapses. | ||
| 838 | * The condition is checked under the lock. This is expected | ||
| 839 | * to be called with the lock taken. | ||
| 840 | * @wq: the waitqueue to wait on | ||
| 841 | * @condition: a C expression for the event to wait for | ||
| 842 | * @lock: a locked spinlock_t, which will be released before schedule() | ||
| 843 | * and reacquired afterwards. | ||
| 844 | * @timeout: timeout, in jiffies | ||
| 845 | * | ||
| 846 | * The process is put to sleep (TASK_INTERRUPTIBLE) until the | ||
| 847 | * @condition evaluates to true or signal is received. The @condition is | ||
| 848 | * checked each time the waitqueue @wq is woken up. | ||
| 849 | * | ||
| 850 | * wake_up() has to be called after changing any variable that could | ||
| 851 | * change the result of the wait condition. | ||
| 852 | * | ||
| 853 | * This is supposed to be called while holding the lock. The lock is | ||
| 854 | * dropped before going to sleep and is reacquired afterwards. | ||
| 855 | * | ||
| 856 | * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it | ||
| 857 | * was interrupted by a signal, and the remaining jiffies otherwise | ||
| 858 | * if the condition evaluated to true before the timeout elapsed. | ||
| 859 | */ | ||
| 860 | #define wait_event_interruptible_lock_irq_timeout(wq, condition, lock, \ | ||
| 861 | timeout) \ | ||
| 862 | ({ \ | ||
| 863 | int __ret = timeout; \ | ||
| 864 | \ | ||
| 865 | if (!(condition)) \ | ||
| 866 | __wait_event_interruptible_lock_irq_timeout( \ | ||
| 867 | wq, condition, lock, __ret); \ | ||
| 868 | __ret; \ | ||
| 869 | }) | ||
| 870 | |||
| 814 | 871 | ||
| 815 | /* | 872 | /* |
| 816 | * These are the old interfaces to sleep waiting for an event. | 873 | * These are the old interfaces to sleep waiting for an event. |
