stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 3/3] scsi_transport_sas: Fix error handling in sas_smp_request()
       [not found] <20170828204149.28693-1-bart.vanassche@wdc.com>
@ 2017-08-28 20:41 ` Bart Van Assche
  2017-08-28 20:41 ` Bart Van Assche
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2017-08-28 20:41 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Paul E . McKenney, Ingo Molnar, Christoph Hellwig,
	Bart Van Assche, Hannes Reinecke, Johannes Thumshirn, stable

sas_function_template.smp_handler implementations either return
0 or a Unix error code. Convert that error code into a SCSI
result. This patch is what I came up with after having analyzed
the following sparse warnings:

drivers/scsi/scsi_transport_sas.c:187:21: warning: incorrect type in assignment (different base types)
drivers/scsi/scsi_transport_sas.c:187:21:    expected restricted blk_status_t [usertype] ret
drivers/scsi/scsi_transport_sas.c:187:21:    got int
drivers/scsi/scsi_transport_sas.c:188:39: warning: incorrect type in assignment (different base types)
drivers/scsi/scsi_transport_sas.c:188:39:    expected int [signed] result
drivers/scsi/scsi_transport_sas.c:188:39:    got restricted blk_status_t [usertype] ret

Fixes: commit 17d5363b83f8 ("scsi: introduce a result field in struct scsi_request")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/scsi_transport_sas.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index e2e948f1ce28..6c05fd9a0be5 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -173,7 +173,7 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
 			    struct sas_rphy *rphy)
 {
 	struct request *req;
-	blk_status_t ret;
+	int ret;
 	int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
 
 	while ((req = blk_fetch_request(q)) != NULL) {
@@ -185,7 +185,9 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
 				blk_rq_bytes(req->next_rq);
 		handler = to_sas_internal(shost->transportt)->f->smp_handler;
 		ret = handler(shost, rphy, req);
-		scsi_req(req)->result = ret;
+		WARN_ONCE(ret != 0 && !IS_ERR_VALUE((uintptr_t)ret),
+			  "%s: ret = %d\n", __func__, ret);
+		scsi_req(req)->result = ret ? DID_ERROR << 16 : 0;
 
 		blk_end_request_all(req, 0);
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v3 3/3] scsi_transport_sas: Fix error handling in sas_smp_request()
       [not found] <20170828204149.28693-1-bart.vanassche@wdc.com>
  2017-08-28 20:41 ` [PATCH v3 3/3] scsi_transport_sas: Fix error handling in sas_smp_request() Bart Van Assche
@ 2017-08-28 20:41 ` Bart Van Assche
  2017-08-29 13:08   ` Christoph Hellwig
  1 sibling, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2017-08-28 20:41 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Paul E . McKenney, Ingo Molnar, Christoph Hellwig,
	Bart Van Assche, Hannes Reinecke, Johannes Thumshirn, stable

sas_function_template.smp_handler implementations either return
0 or a Unix error code. Convert that error code into a SCSI
result. This patch is what I came up with after having analyzed
the following sparse warnings:

drivers/scsi/scsi_transport_sas.c:187:21: warning: incorrect type in assignment (different base types)
drivers/scsi/scsi_transport_sas.c:187:21:    expected restricted blk_status_t [usertype] ret
drivers/scsi/scsi_transport_sas.c:187:21:    got int
drivers/scsi/scsi_transport_sas.c:188:39: warning: incorrect type in assignment (different base types)
drivers/scsi/scsi_transport_sas.c:188:39:    expected int [signed] result
drivers/scsi/scsi_transport_sas.c:188:39:    got restricted blk_status_t [usertype] ret

Fixes: commit 17d5363b83f8 ("scsi: introduce a result field in struct scsi_request")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/scsi_transport_sas.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index e2e948f1ce28..6c05fd9a0be5 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -173,7 +173,7 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
 			    struct sas_rphy *rphy)
 {
 	struct request *req;
-	blk_status_t ret;
+	int ret;
 	int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
 
 	while ((req = blk_fetch_request(q)) != NULL) {
@@ -185,7 +185,9 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
 				blk_rq_bytes(req->next_rq);
 		handler = to_sas_internal(shost->transportt)->f->smp_handler;
 		ret = handler(shost, rphy, req);
-		scsi_req(req)->result = ret;
+		WARN_ONCE(ret != 0 && !IS_ERR_VALUE((uintptr_t)ret),
+			  "%s: ret = %d\n", __func__, ret);
+		scsi_req(req)->result = ret ? DID_ERROR << 16 : 0;
 
 		blk_end_request_all(req, 0);
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 3/3] scsi_transport_sas: Fix error handling in sas_smp_request()
  2017-08-28 20:41 ` Bart Van Assche
@ 2017-08-29 13:08   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2017-08-29 13:08 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Paul E . McKenney, Ingo Molnar, Christoph Hellwig,
	Hannes Reinecke, Johannes Thumshirn, stable

> -	blk_status_t ret;
> +	int ret;
>  	int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);

This part looks ok.

>  	while ((req = blk_fetch_request(q)) != NULL) {
> @@ -185,7 +185,9 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
>  				blk_rq_bytes(req->next_rq);
>  		handler = to_sas_internal(shost->transportt)->f->smp_handler;
>  		ret = handler(shost, rphy, req);
> -		scsi_req(req)->result = ret;
> +		WARN_ONCE(ret != 0 && !IS_ERR_VALUE((uintptr_t)ret),
> +			  "%s: ret = %d\n", __func__, ret);
> +		scsi_req(req)->result = ret ? DID_ERROR << 16 : 0;

This one doesn't.  All the way back until this code was fixed up
after the initial introduction it returned negative error codes
to user space.

Take a look at committs 7aa68e80bd481faae1234bc2a7e4bcc9348f98b4 and
2d507a01dac338831266b44ccbb01c69e84606ed for details.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-29 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20170828204149.28693-1-bart.vanassche@wdc.com>
2017-08-28 20:41 ` [PATCH v3 3/3] scsi_transport_sas: Fix error handling in sas_smp_request() Bart Van Assche
2017-08-28 20:41 ` Bart Van Assche
2017-08-29 13:08   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).