From: Martin Petermann <martin@xxxxxxxxxxxxxxxxxx> On some hardware it can take some time to add a unit. If some remove this unit during this process the remove will fail. Signed-off-by: Martin Petermann <martin@xxxxxxxxxxxxxxxxxx> Signed-off-by: Christof Schmitt <christof.schmitt@xxxxxxxxxx> --- drivers/s390/scsi/zfcp_sysfs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) --- a/drivers/s390/scsi/zfcp_sysfs.c 2009-04-17 15:03:20.000000000 +0200 +++ b/drivers/s390/scsi/zfcp_sysfs.c 2009-04-17 15:03:42.000000000 +0200 @@ -254,12 +254,21 @@ static ssize_t zfcp_sysfs_unit_remove_st write_lock_irq(&zfcp_data.config_lock); unit = zfcp_get_unit_by_lun(port, fcp_lun); - if (unit && (atomic_read(&unit->refcount) == 0)) { - zfcp_unit_get(unit); - atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status); - list_move(&unit->list, &unit_remove_lh); - } else - unit = NULL; + if (unit) { + write_unlock_irq(&zfcp_data.config_lock); + /* wait for possible timeout during SCSI probe */ + flush_work(&unit->scsi_work); + write_lock_irq(&zfcp_data.config_lock); + + if (atomic_read(&unit->refcount) == 0) { + zfcp_unit_get(unit); + atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, + &unit->status); + list_move(&unit->list, &unit_remove_lh); + } else { + unit = NULL; + } + } write_unlock_irq(&zfcp_data.config_lock); -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html