From patchwork Thu Apr 6 15:39:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9667681 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 0524F6021C for ; Thu, 6 Apr 2017 15:40:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA1312847F for ; Thu, 6 Apr 2017 15:40:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEB0828584; Thu, 6 Apr 2017 15:40:20 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 84EC12847F for ; Thu, 6 Apr 2017 15:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933093AbdDFPkT (ORCPT ); Thu, 6 Apr 2017 11:40:19 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:53982 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933010AbdDFPkS (ORCPT ); Thu, 6 Apr 2017 11:40:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=I9te7CB2ui0FnSnj/corK4Wt1rltclAI+8v+hvLeX3o=; b=Pilfj5yRxIKyMt+oJwFwMXrGe Tw3jVJkxi1z9a0YVK9/k1CcvXTiZpKNbygT3EH1zT1itW3Tw0LHrdDq3N2KqUttBQXOZ0xnEtKv8F Zl+PkNkqidhc2fivCJ2PRljDBFJfztzxdgd+yuskWnMDcKvPRj2t5UXhOIdenxm7RERVFgRSfZVXJ RYkS44gTPoQ1fz3mcekQ6Eu+J0Q9Rtrsseahay0uv6Ls9pi7w7V7FEiMGYwWy3U7B701LS6MXwGAb yolDiFgxUHWTmoJCoj0C1Y2aDfrDOpa6g+t6Ek1iHRthYU0C4Bnzah6LuuajC+HQyBN86fRsFUfQl NxN1DK20A==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cw9W4-0002QC-G3; Thu, 06 Apr 2017 15:40:08 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , James Smart , Konrad Rzeszutek Wilk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, dm-devel@redhat.com Subject: [PATCH 08/25] scsi: fix fast-fail for non-passthrough requests Date: Thu, 6 Apr 2017 17:39:27 +0200 Message-Id: <20170406153944.10058-9-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170406153944.10058-1-hch@lst.de> References: <20170406153944.10058-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently error is always 0 for non-passthrough requests when reaching the scsi_noretry_cmd check in scsi_io_completion, which effectively disables all fastfail logic. Fix this by having a single call to __scsi_error_from_host_byte at the beginning of the function and always having a valid error value. Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 11972d1075f1..89b4d9e69866 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -779,21 +779,17 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) sense_valid = scsi_command_normalize_sense(cmd, &sshdr); if (sense_valid) sense_deferred = scsi_sense_is_deferred(&sshdr); + + if (!sense_deferred) + error = __scsi_error_from_host_byte(cmd, result); } if (blk_rq_is_passthrough(req)) { - if (result) { - if (sense_valid) { - /* - * SG_IO wants current and deferred errors - */ - scsi_req(req)->sense_len = - min(8 + cmd->sense_buffer[7], - SCSI_SENSE_BUFFERSIZE); - } - if (!sense_deferred) - error = __scsi_error_from_host_byte(cmd, result); + if (result && sense_valid) { + scsi_req(req)->sense_len = min(8 + cmd->sense_buffer[7], + SCSI_SENSE_BUFFERSIZE); } + /* * __scsi_error_from_host_byte may have reset the host_byte */ @@ -812,13 +808,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) BUG(); return; } - } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) { - /* - * Flush commands do not transfers any data, and thus cannot use - * good_bytes != blk_rq_bytes(req) as the signal for an error. - * This sets the error explicitly for the problem case. - */ - error = __scsi_error_from_host_byte(cmd, result); } /* no bidi support for !blk_rq_is_passthrough yet */ @@ -848,7 +837,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) else if (!(req->rq_flags & RQF_QUIET)) scsi_print_sense(cmd); result = 0; - /* for passthrough error may be set */ error = 0; } @@ -877,8 +865,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) if (result == 0) goto requeue; - error = __scsi_error_from_host_byte(cmd, result); - if (host_byte(result) == DID_RESET) { /* Third party bus reset or reset for error recovery * reasons. Just retry the command and see what