* [PATCHv2 0/2] scsi: pollable 'state' attribute
@ 2017-08-11 6:53 Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 1/2] scsi_lib: rework scsi_internal_device_unblock_nowait() Hannes Reinecke
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hannes Reinecke @ 2017-08-11 6:53 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke
Hi all,
here's a small patchset to make the 'state' device attribute pollable.
It was supposed to be a small patch, but then hch suggested a rework.
So there you go.
Changes to v2:
- Removed duplicate case value found by kbuild robot
- Dropped state update patch
Hannes Reinecke (2):
scsi_lib: rework scsi_internal_device_unblock_nowait()
scsi: make 'state' device attribute pollable
drivers/scsi/scsi_lib.c | 20 ++++++++++++++------
drivers/scsi/scsi_transport_srp.c | 5 ++++-
2 files changed, 18 insertions(+), 7 deletions(-)
--
1.8.5.6
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCHv2 1/2] scsi_lib: rework scsi_internal_device_unblock_nowait()
2017-08-11 6:53 [PATCHv2 0/2] scsi: pollable 'state' attribute Hannes Reinecke
@ 2017-08-11 6:53 ` Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 2/2] scsi: make 'state' device attribute pollable Hannes Reinecke
2017-08-15 3:01 ` [PATCHv2 0/2] scsi: pollable 'state' attribute Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2017-08-11 6:53 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
Hannes Reinecke
Rework scsi_internal_device_unblock_nowait() into using a
switch statement.
No functional changes.
Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/scsi/scsi_lib.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 1ae531b..9169396 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3074,19 +3074,24 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
* Try to transition the scsi device to SDEV_RUNNING or one of the
* offlined states and goose the device queue if successful.
*/
- if ((sdev->sdev_state == SDEV_BLOCK) ||
- (sdev->sdev_state == SDEV_TRANSPORT_OFFLINE))
+ switch (sdev->sdev_state) {
+ case SDEV_BLOCK:
+ case SDEV_TRANSPORT_OFFLINE:
sdev->sdev_state = new_state;
- else if (sdev->sdev_state == SDEV_CREATED_BLOCK) {
+ break;
+ case SDEV_CREATED_BLOCK:
if (new_state == SDEV_TRANSPORT_OFFLINE ||
new_state == SDEV_OFFLINE)
sdev->sdev_state = new_state;
else
sdev->sdev_state = SDEV_CREATED;
- } else if (sdev->sdev_state != SDEV_CANCEL &&
- sdev->sdev_state != SDEV_OFFLINE)
+ break;
+ case SDEV_CANCEL:
+ case SDEV_OFFLINE:
+ break;
+ default:
return -EINVAL;
-
+ }
scsi_start_queue(sdev);
return 0;
--
1.8.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCHv2 2/2] scsi: make 'state' device attribute pollable
2017-08-11 6:53 [PATCHv2 0/2] scsi: pollable 'state' attribute Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 1/2] scsi_lib: rework scsi_internal_device_unblock_nowait() Hannes Reinecke
@ 2017-08-11 6:53 ` Hannes Reinecke
2017-08-15 3:01 ` [PATCHv2 0/2] scsi: pollable 'state' attribute Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2017-08-11 6:53 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
Hannes Reinecke
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: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/scsi/scsi_lib.c | 3 +++
drivers/scsi/scsi_transport_srp.c | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9169396..eda41b0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2655,6 +2655,7 @@ void scsi_exit_queue(void)
}
sdev->sdev_state = state;
+ sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
return 0;
illegal:
@@ -3078,6 +3079,7 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
case SDEV_BLOCK:
case SDEV_TRANSPORT_OFFLINE:
sdev->sdev_state = new_state;
+ sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
break;
case SDEV_CREATED_BLOCK:
if (new_state == SDEV_TRANSPORT_OFFLINE ||
@@ -3085,6 +3087,7 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
sdev->sdev_state = new_state;
else
sdev->sdev_state = SDEV_CREATED;
+ sysfs_notify(&sdev->sdev_gendev.kobj, NULL, "state");
break;
case SDEV_CANCEL:
case SDEV_OFFLINE:
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index f617021..698cc46 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -556,8 +556,11 @@ int srp_reconnect_rport(struct srp_rport *rport)
*/
shost_for_each_device(sdev, shost) {
mutex_lock(&sdev->state_mutex);
- if (sdev->sdev_state == SDEV_OFFLINE)
+ if (sdev->sdev_state == SDEV_OFFLINE) {
sdev->sdev_state = SDEV_RUNNING;
+ sysfs_notify(&sdev->sdev_gendev.kobj,
+ NULL, "state");
+ }
mutex_unlock(&sdev->state_mutex);
}
} else if (rport->state == SRP_RPORT_RUNNING) {
--
1.8.5.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv2 0/2] scsi: pollable 'state' attribute
2017-08-11 6:53 [PATCHv2 0/2] scsi: pollable 'state' attribute Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 1/2] scsi_lib: rework scsi_internal_device_unblock_nowait() Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 2/2] scsi: make 'state' device attribute pollable Hannes Reinecke
@ 2017-08-15 3:01 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-08-15 3:01 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
linux-scsi
Hannes,
> here's a small patchset to make the 'state' device attribute pollable.
> It was supposed to be a small patch, but then hch suggested a rework.
Applied to 4.14/scsi-queue. Thank you!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-15 3:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 6:53 [PATCHv2 0/2] scsi: pollable 'state' attribute Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 1/2] scsi_lib: rework scsi_internal_device_unblock_nowait() Hannes Reinecke
2017-08-11 6:53 ` [PATCHv2 2/2] scsi: make 'state' device attribute pollable Hannes Reinecke
2017-08-15 3:01 ` [PATCHv2 0/2] scsi: pollable 'state' attribute Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.