Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a97712e authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen
Browse files

scsi: make 'state' device attribute pollable



While the 'state' attribute can (and will) change occasionally,
calling 'poll()' or 'select()' on it fails as sysfs is never
notified that the state has changed.
With this patch calling 'poll()' or 'select()' will work
properly.

Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 8cd1ec78
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -2654,6 +2654,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)


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


 illegal:
 illegal:
@@ -3077,6 +3078,7 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
	case SDEV_BLOCK:
	case SDEV_BLOCK:
	case SDEV_TRANSPORT_OFFLINE:
	case SDEV_TRANSPORT_OFFLINE:
		sdev->sdev_state = new_state;
		sdev->sdev_state = new_state;
		sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
		break;
		break;
	case SDEV_CREATED_BLOCK:
	case SDEV_CREATED_BLOCK:
		if (new_state == SDEV_TRANSPORT_OFFLINE ||
		if (new_state == SDEV_TRANSPORT_OFFLINE ||
@@ -3084,6 +3086,7 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
			sdev->sdev_state = new_state;
			sdev->sdev_state = new_state;
		else
		else
			sdev->sdev_state = SDEV_CREATED;
			sdev->sdev_state = SDEV_CREATED;
		sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
		break;
		break;
	case SDEV_CANCEL:
	case SDEV_CANCEL:
	case SDEV_OFFLINE:
	case SDEV_OFFLINE:
+4 −1
Original line number Original line Diff line number Diff line
@@ -556,8 +556,11 @@ int srp_reconnect_rport(struct srp_rport *rport)
		 */
		 */
		shost_for_each_device(sdev, shost) {
		shost_for_each_device(sdev, shost) {
			mutex_lock(&sdev->state_mutex);
			mutex_lock(&sdev->state_mutex);
			if (sdev->sdev_state == SDEV_OFFLINE)
			if (sdev->sdev_state == SDEV_OFFLINE) {
				sdev->sdev_state = SDEV_RUNNING;
				sdev->sdev_state = SDEV_RUNNING;
				sysfs_notify(&sdev->sdev_gendev.kobj,
					     NULL, "state");
			}
			mutex_unlock(&sdev->state_mutex);
			mutex_unlock(&sdev->state_mutex);
		}
		}
	} else if (rport->state == SRP_RPORT_RUNNING) {
	} else if (rport->state == SRP_RPORT_RUNNING) {