Skip to contentSkip to conversation

scsi: core: Allow the state change from SDEV_QUIESCE to SDEV_BLOCK

PATCH Applied Dexuan Cui 4 participants 6 messages Apr 18, 2020 – Apr 22, 2020 SCSI

lore
Share & tools
lore

Dexuan Cui

author
#0 lore raw

PATCH 1/1 scsi: core: Allow the state change from SDEV_QUIESCE to SDEV_BLOCK

The APIs scsi_host_block()/scsi_host_unblock() are recently added by:
2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function") and so far the APIs are only used by:
3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")

However, from reading the code, I think the APIs don't really work for aacraid, because, in the resume path of hibernation, when aac_suspend() -> scsi_host_block() is called, scsi_device_quiesce() has set the state to SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Fixes 2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function")
---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_lib.c +1 -0
index 47835c4b4ee0..06c260f6cdae 100644
@@ -2284,6 +2284,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
 		switch (oldstate) {
 		case SDEV_RUNNING:
 		case SDEV_CREATED_BLOCK:
+		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 			break;
 		default:
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Dexuan Cui

The APIs scsi_host_block()/scsi_host_unblock() are recently added by:
2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function") and so far the APIs are only used by:
3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")

However, from reading the code, I think the APIs don't really work for aacraid, because, in the resume path of hibernation, when aac_suspend() -> scsi_host_block() is called, scsi_device_quiesce() has set the state to SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Fixes 2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function")
---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_lib.c +0 -0
index 47835c4b4ee0..06c260f6cdae 100644

drivers/scsi/scsi_lib.c scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) · line 2290

Quoted 7 lines
drivers/scsi/scsi_lib.c +1 -0
@@ -2284,6 +2284,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
 		switch (oldstate) {
 		case SDEV_RUNNING:
 		case SDEV_CREATED_BLOCK:
+		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 			break;
 		default:

Looks reasonable because SDEV_BLOCK is one more strict state than QEIESCE, so:

Thanks,
Ming

author
#2 lore raw
Quoted 36 lines

From: Ming Lei <[email protected]>
Sent: Friday, April 17, 2020 7:42 PM
To: Dexuan Cui <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Michael Kelley <[email protected]>; Long Li <[email protected]>
Subject: Re: [PATCH] scsi: core: Allow the state change from SDEV_QUIESCE to SDEV_BLOCK

Quoted 5 lines · Dexuan Cui

The APIs scsi_host_block()/scsi_host_unblock() are recently added by:
2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function") and so far the APIs are only used by:
3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")

Quoted 8 lines

However, from reading the code, I think the APIs don't really work for aacraid, because, in the resume path of hibernation, when aac_suspend() -> scsi_host_block() is called, scsi_device_quiesce() has set the state to SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Fixes 2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper

function")

drivers/scsi/scsi_lib.c scsi_device_set_state(struct scsi_device *sdev,

Quoted 10 lines
---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_lib.c +0 -0
index 47835c4b4ee0..06c260f6cdae 100644
@@ -2284,6 +2284,7 @@ scsi_device_set_state(struct scsi_device *sdev,

enum scsi_device_state state)

Quoted 10 lines

drivers/scsi/scsi_lib.c scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) · line 2290

Quoted 7 lines
drivers/scsi/scsi_lib.c +1 -0
 		switch (oldstate) {
 		case SDEV_RUNNING:
 		case SDEV_CREATED_BLOCK:
+		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 			break;
 		default:

Looks reasonable because SDEV_BLOCK is one more strict state than QEIESCE, so:

Thanks, Ming!

Quoted 4 lines

Thanks,
Ming

There should be a small typo: s/redha/redhat :-)

Thanks,
-- Dexuan

Reviewed-by
#3 lore raw
Quoted 47 lines · Dexuan Cui
Quoted 36 lines

From: Ming Lei <[email protected]>
Sent: Friday, April 17, 2020 7:42 PM
To: Dexuan Cui <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Michael Kelley <[email protected]>; Long Li <[email protected]>
Subject: Re: [PATCH] scsi: core: Allow the state change from SDEV_QUIESCE to SDEV_BLOCK

Quoted 5 lines · Dexuan Cui

The APIs scsi_host_block()/scsi_host_unblock() are recently added by:
2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function") and so far the APIs are only used by:
3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")

Quoted 8 lines

However, from reading the code, I think the APIs don't really work for aacraid, because, in the resume path of hibernation, when aac_suspend() -> scsi_host_block() is called, scsi_device_quiesce() has set the state to SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Fixes 2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper

function")

drivers/scsi/scsi_lib.c scsi_device_set_state(struct scsi_device *sdev,

Quoted 10 lines
---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_lib.c +0 -0
index 47835c4b4ee0..06c260f6cdae 100644
@@ -2284,6 +2284,7 @@ scsi_device_set_state(struct scsi_device *sdev,

enum scsi_device_state state)

Quoted 10 lines

drivers/scsi/scsi_lib.c scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) · line 2290

Quoted 7 lines
drivers/scsi/scsi_lib.c +1 -0
 		switch (oldstate) {
 		case SDEV_RUNNING:
 		case SDEV_CREATED_BLOCK:
+		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 			break;
 		default:

Looks reasonable because SDEV_BLOCK is one more strict state than QEIESCE, so:

Quoted 8 lines

Thanks, Ming!

Quoted 4 lines

Thanks,
Ming

There should be a small typo: s/redha/redhat :-)

Sorry for the fault:

Thanks,
Ming

Reviewed-by on v1 1/1
#4 lore raw
In reply to Dexuan Cui
Quoted 36 lines · Dexuan Cui

The APIs scsi_host_block()/scsi_host_unblock() are recently added by:
2bb955840c1d ("scsi: core: add scsi_host_(block,unblock) helper function")
and so far the APIs are only used by:
3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")

However, from reading the code, I think the APIs don't really work for
aacraid, because, in the resume path of hibernation, when aac_suspend() ->
scsi_host_block() is called, scsi_device_quiesce() has set the state to
SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Fixes 2bb955840c1d ("scsi: core: add scsi_host_(block,unblock)

helper function")

---
 drivers/scsi/scsi_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_lib.c +1 -0
index 47835c4b4ee0..06c260f6cdae 100644
@@ -2284,6 +2284,7 @@ scsi_device_set_state(struct scsi_device *sdev,
 enum scsi_device_state state)
 		switch (oldstate) {
 		case SDEV_RUNNING:
 		case SDEV_CREATED_BLOCK:
+		case SDEV_QUIESCE:
 		case SDEV_OFFLINE:
 			break;
Quoted 1 line

default:

I think this should be OK.

#5 lore raw
In reply to Dexuan Cui

Dexuan,

Quoted 7 lines

However, from reading the code, I think the APIs don't really work for aacraid, because, in the resume path of hibernation, when aac_suspend() -> scsi_host_block() is called, scsi_device_quiesce() has set the state to SDEV_QUIESCE, so aac_suspend() -> scsi_host_block() returns -EINVAL.

Fix the issue by allowing the state change.

Applied to 5.7/scsi-fixes, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering