Asynchronous scan (scsi_add_lun()) sets state to SDEV_RUNNING, but the
device is not registered in sysfs. Before async scan it was OK, because before releasing scan_mutex old code called either scsi_sysfs_add_sdev() or scsi_destroy_sdev() and, therefore, completed the work or discarded it. With async scan the invariant is broken and scsi crashes in __scsi_remove_device() when trying to unregister not registered devices. The fix could be introducing new state(s), which is equivalent to SDEV_RUNNING, except for one thing, we know that scsi_sysfs_add_sdev() has not been called yet. Or a separate flag, because the state can be SDEV_BLOCK or even something else. Simpler way is just to check that the device is regstered in sysfs before unregistering. Another operations in __scsi_remove_device() seem to be idempotent or even required, because scsi_add_lun() makes some part of work duplicated in scsi_sysfs_add_sdev(). Signed-off-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Showing
Please register or sign in to comment