From patchwork Wed Apr 4 18:14:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 10323015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBC8B60541 for ; Wed, 4 Apr 2018 18:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB9B728DD6 for ; Wed, 4 Apr 2018 18:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C015328E1E; Wed, 4 Apr 2018 18:15:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14E7428DD6 for ; Wed, 4 Apr 2018 18:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412AbeDDSPG (ORCPT ); Wed, 4 Apr 2018 14:15:06 -0400 Received: from smtp.infotech.no ([82.134.31.41]:34933 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbeDDSPE (ORCPT ); Wed, 4 Apr 2018 14:15:04 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id C058B2041D4; Wed, 4 Apr 2018 20:15:02 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zHelUJ--UShT; Wed, 4 Apr 2018 20:14:56 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-184-164-15-239.dyn.295.ca [184.164.15.239]) by smtp.infotech.no (Postfix) with ESMTPA id 972C1204179; Wed, 4 Apr 2018 20:14:55 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, bart.vanassche@wdc.com Subject: [PATCH] scsi: fix __scsi_error_from_host_byte() breakage Date: Wed, 4 Apr 2018 14:14:53 -0400 Message-Id: <20180404181453.30737-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.14.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch e39a97353e53 titled "scsi: core: return BLK_STS_OK for DID_OK in __scsi_error_from_host_byte()" attempted to make that function return BLK_STS_OK when it was given host_byte(result)==DID_OK. While that seems sensible, it failed to take into account that there may be errors present in the driver_byte and the status byte. Add those checks and expand description of function accordingly. Signed-off-by: Douglas Gilbert --- The function would be better called blk_status_from_scsi_result(). Is the leading "__" needed? drivers/scsi/scsi_lib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index aaf485e36450..6a8bf312d82f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -727,13 +727,18 @@ static bool scsi_end_request(struct request *req, blk_status_t error, * @cmd: SCSI command (unused) * @result: scsi error code * - * Translate SCSI error code into block errors. + * Translate SCSI error code into block errors. In the case of result==DID_OK + * also check driver and status bytes for errors. */ static blk_status_t __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result) { switch (host_byte(result)) { case DID_OK: + if (driver_byte(result) != DRIVER_OK) + return BLK_STS_IOERR; + else if (status_byte(result) && !scsi_status_is_good(result)) + return BLK_STS_IOERR; /* e.g. reservation conflict */ return BLK_STS_OK; case DID_TRANSPORT_FAILFAST: return BLK_STS_TRANSPORT;