Skip to content

Commit a817e73

Browse files
committed
Revert "scsi: make 'state' device attribute pollable"
This reverts commit 8a97712. This commit added a call to sysfs_notify() from within scsi_device_set_state(), which in turn turns out to make libata very unhappy, because ata_eh_detach_dev() does spin_lock_irqsave(ap->lock, flags); .. if (ata_scsi_offline_dev(dev)) { dev->flags |= ATA_DFLAG_DETACHED; ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; } and ata_scsi_offline_dev() then does that scsi_device_set_state() to set it offline. So now we called sysfs_notify() from within a spinlocked region, which really doesn't work. The 0day robot reported this as: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238 because sysfs_notify() ends up calling kernfs_find_and_get_ns() which then does mutex_lock(&kernfs_mutex).. The pollability of the device state isn't critical, so revert this all for now, and maybe we'll do it differently in the future. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e4880bc commit a817e73

2 files changed

Lines changed: 1 addition & 7 deletions

File tree

drivers/scsi/scsi_lib.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,6 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
26852685

26862686
}
26872687
sdev->sdev_state = state;
2688-
sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
26892688
return 0;
26902689

26912690
illegal:
@@ -3109,15 +3108,13 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
31093108
case SDEV_BLOCK:
31103109
case SDEV_TRANSPORT_OFFLINE:
31113110
sdev->sdev_state = new_state;
3112-
sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
31133111
break;
31143112
case SDEV_CREATED_BLOCK:
31153113
if (new_state == SDEV_TRANSPORT_OFFLINE ||
31163114
new_state == SDEV_OFFLINE)
31173115
sdev->sdev_state = new_state;
31183116
else
31193117
sdev->sdev_state = SDEV_CREATED;
3120-
sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
31213118
break;
31223119
case SDEV_CANCEL:
31233120
case SDEV_OFFLINE:

drivers/scsi/scsi_transport_srp.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,8 @@ int srp_reconnect_rport(struct srp_rport *rport)
556556
*/
557557
shost_for_each_device(sdev, shost) {
558558
mutex_lock(&sdev->state_mutex);
559-
if (sdev->sdev_state == SDEV_OFFLINE) {
559+
if (sdev->sdev_state == SDEV_OFFLINE)
560560
sdev->sdev_state = SDEV_RUNNING;
561-
sysfs_notify(&sdev->sdev_gendev.kobj,
562-
NULL, "state");
563-
}
564561
mutex_unlock(&sdev->state_mutex);
565562
}
566563
} else if (rport->state == SRP_RPORT_RUNNING) {

0 commit comments

Comments
 (0)