From: James Bottomley <jejb@linux.ibm.com>
To: Wenchao Hao <haowenchao@huawei.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Mike Christie <michael.christie@oracle.com>
Cc: linux-scsi@vger.kernel.org, linfeilong@huawei.com,
yanaijie@huawei.com, xuhujie@huawei.com, lijinlin3@huawei.com
Subject: Re: [QUESTION]: Why did we clear the lowest bit of SCSI command's status in scsi_status_is_good
Date: Mon, 28 Nov 2022 07:52:34 -0500 [thread overview]
Message-ID: <ca7e2aba5db5bd6e15182070f26e0c2c77c70927.camel@linux.ibm.com> (raw)
In-Reply-To: <6e9ea80e-d4e0-6d52-47c1-8939c13d60a8@huawei.com>
On Mon, 2022-11-28 at 11:58 +0800, Wenchao Hao wrote:
> static inline bool scsi_status_is_good(int
> status)
>
>
> {
> if (status < 0)
> return false;
>
> if (host_byte(status) == DID_NO_CONNECT)
> return false;
>
> /*
> * FIXME: bit0 is listed as reserved in SCSI-2, but is
> * significant in SCSI-3. For now, we follow the SCSI-2
> * behaviour and ignore reserved bits.
> */
> status &= 0xfe;
> return ((status == SAM_STAT_GOOD) ||
> (status == SAM_STAT_CONDITION_MET) ||
> /* Next two "intermediate" statuses are obsolete in
> SAM-4 */
> (status == SAM_STAT_INTERMEDIATE) ||
> (status == SAM_STAT_INTERMEDIATE_CONDITION_MET) ||
> /* FIXME: this is obsolete in SAM-3 */
> (status == SAM_STAT_COMMAND_TERMINATED));
> }
> We have function defined in include/scsi/scsi.h as above, which is
> used to check if the status in result is good.
>
> But the function cleared the lowest bit of SCSI command's status,
> which would translate an undefined status to good in some condition,
> for example the status is 0x1.
>
> This code seems introduced in this patch:
> https://lore.kernel.org/all/1052403312.2097.35.camel@mulgrave/
>
> Is anyone who knows why did we clear the lowest bit?
It says why in the comment you quote above ... what is unclear about
it?
> We found some firmware or drivers would return status which did not
> defined in SAM. Now SCSI middle level do not have an uniform behavior
> for these undefined status. I want to change the logic to return
> error for all status which did not defined in SAM or define a method
> in host template to let drivers to judge what to do in this
> condition.
Why? The general rule of thumb is be strict in what you emit and
generous in what you receive (which is why reserved bits are ignored).
Is the drive you refer to above not working in some way, in which case
detail it so people can understand the actual problem.
James
next prev parent reply other threads:[~2022-11-28 12:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 3:58 [QUESTION]: Why did we clear the lowest bit of SCSI command's status in scsi_status_is_good Wenchao Hao
2022-11-28 12:52 ` James Bottomley [this message]
2022-11-28 14:41 ` Wenchao Hao
2022-11-28 15:21 ` James Bottomley
2022-11-28 17:38 ` Wenchao Hao
2022-11-28 18:12 ` James Bottomley
2022-12-02 13:58 ` Wenchao Hao
2022-12-02 14:17 ` James Bottomley
2022-12-02 16:26 ` Wenchao Hao
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=ca7e2aba5db5bd6e15182070f26e0c2c77c70927.camel@linux.ibm.com \
--to=jejb@linux.ibm.com \
--cc=haowenchao@huawei.com \
--cc=lijinlin3@huawei.com \
--cc=linfeilong@huawei.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=xuhujie@huawei.com \
--cc=yanaijie@huawei.com \
/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