From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
"hare@suse.de" <hare@suse.de>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"hch@lst.de" <hch@lst.de>,
"jthumshirn@suse.de" <jthumshirn@suse.de>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] scsi_transport_sas: Fix error handling in sas_smp_request()
Date: Thu, 24 Aug 2017 16:06:07 +0000 [thread overview]
Message-ID: <1503590766.2702.7.camel@wdc.com> (raw)
In-Reply-To: <349346ee-bc08-a608-1c8f-0dcf0991686a@suse.de>
On Thu, 2017-08-24 at 14:21 +0200, Hannes Reinecke wrote:
> On 08/23/2017 08:25 PM, Bart Van Assche wrote:
> > 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 5006a656e16a..a318c46db7cc 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(ret + 0UL),
> > + "%s: ret = %d\n", __func__, ret);
> > + scsi_req(req)->result = ret ? DID_ERROR << 16 : 0;
> >
> > blk_end_request_all(req, 0);
> >
> >
>
> Weelll ... I'd rather audit the handler so as to ensure that the correct
> value is returned.
> And this 'ret + 0UL' construct is decidedly ugly ...
Hello Hannes,
Changing "+ 0UL" into an explicit (unsigned long) cast is easy. But I would
prefer to leave the conversion of the smp_handler functions to someone who
has the hardware available to test such a conversion. These are the smp_handler
implementations I am aware of:
$ git grep -nH '\.smp_handler[[:blank:]]*='
drivers/message/fusion/mptsas.c:2356: .smp_handler = mptsas_smp_handler,
drivers/scsi/hpsa.c:9463: .smp_handler = hpsa_sas_smp_handler,
drivers/scsi/libsas/sas_init.c:548: .smp_handler = sas_smp_handler,
drivers/scsi/mpt3sas/mpt3sas_transport.c:2129: .smp_handler = _transport_smp_handler,
drivers/scsi/smartpqi/smartpqi_sas_transport.c:349: .smp_handler = pqi_sas_smp_handler,
Bart.
next prev parent reply other threads:[~2017-08-24 16:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-23 18:25 [PATCH] scsi_transport_sas: Fix error handling in sas_smp_request() Bart Van Assche
2017-08-24 8:47 ` Christoph Hellwig
2017-08-24 12:21 ` Hannes Reinecke
2017-08-24 16:06 ` Bart Van Assche [this message]
2017-08-25 8:54 ` Hannes Reinecke
2017-08-25 15:35 ` Christoph Hellwig
2017-08-25 15:38 ` Bart Van Assche
2017-08-25 15:57 ` hch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503590766.2702.7.camel@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox