Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1941798imm; Thu, 24 May 2018 03:19:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZozRXIek0+HfKDFAmmKN8JqKEQh3tmH4KRFehGssdB+/bybD4yiSjxgRCVGL2LixsuSCPEh X-Received: by 2002:a17:902:5a03:: with SMTP id q3-v6mr5762893pli.300.1527157146106; Thu, 24 May 2018 03:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157146; cv=none; d=google.com; s=arc-20160816; b=IsCPZlrsMIr4Td9gZUlT2Np2dc2aOLOzlBl69gnzegKrxHx63TkATkDey8pGNG0jPs z9QPvJ9Has9OFILymT8r8wIxTxkaRkqrSBly7r9q3hninvNolbUsCZ/XZdjLgHv/mpgl C0HXLmhh3h3nltFJc0QAudm3ykztQAkKzLbRTfJ/XulDxm3wolYbcJmI7mRUnTNUw/MY vokvmnlmjTl9XTwe7kbH+OmANYaqBzq7xPlnyXd6MVJ3RRS+P6f0LYBgAWsgLk68itGO ctxqzROpo8gSSEO1jCYWyl+KNiPNe0UsWoD65U36iB6zRt8s+YLdGHHsF6332uSXXaDG BvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Qk+MBQhGMMQUCXIoUmloiNhT6VGn9Fd8xaaghzJ/si4=; b=fproIRLltV301/AUB92ozIgUdPHPXEWNU27Nt6YZJa9eEFKaDDBfTKevvKYS4XtFS9 3MNgBzSJhkiqHJRtToMX//AOfINcG5W2WfpJ54+79f059IOb6kZJYZ4xgRLOSK4EqW0H 4Ej3k2JldGFIWSivWmTwaY/WwHnOwy5sv8izHvM3tBSv1Dqy/s4o0C+wLYAIH2Y585Ji KEI8LtRfvg3V0Bj/mM4+YWiCI5SGIOlegth1HUH9THoMdJ6saLE1AvSk8WREYyD31XRy LmbJtazEiF5GA4nycl10EDIRLoCLYJwAKc43VahW6Ra318pFn+w4zJyj8eZyHGYAFUsW rEYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K9i6jVHW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si21780377pfb.39.2018.05.24.03.18.51; Thu, 24 May 2018 03:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K9i6jVHW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031878AbeEXKSF (ORCPT + 99 others); Thu, 24 May 2018 06:18:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031318AbeEXKDq (ORCPT ); Thu, 24 May 2018 06:03:46 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3BD3A20890; Thu, 24 May 2018 10:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156225; bh=BrxmB5IPJrAYHBznB4XkgGVgLRdgUbFV8TC8RqR6htE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9i6jVHWckrXTqSSA8apQmVZ1RzqEs2aouwUZ9WpZ460dCH0zCZvv6LAm8g4+QXP9 sA8Xjz0/xNVf21+cN4dE+yqCxXC0x0RsgiPgrQ3CRcCJ74WMJmKEkzVD3GaRF2seeL v9Hok6zhwNaqgi6+2T/SfscF8NbxF83jGMQ0Zqn4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Gilbert , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.16 110/161] scsi: core: Make SCSI Status CONDITION MET equivalent to GOOD Date: Thu, 24 May 2018 11:38:55 +0200 Message-Id: <20180524093031.545799659@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Douglas Gilbert [ Upstream commit 1875ede02ed5e176a18dccbca84abc28d5b3e141 ] The SCSI PRE-FETCH (10 or 16) command is present both on hard disks and some SSDs. It is useful when the address of the next block(s) to be read is known but it is not following the LBA of the current READ (so read-ahead won't help). It returns two "good" SCSI Status values. If the requested blocks have fitted (or will most likely fit (when the IMMED bit is set)) into the disk's cache, it returns CONDITION MET. If it didn't (or will not) fit then it returns GOOD status. The goal of this patch is to stop the SCSI subsystem treating the CONDITION MET SCSI status as an error. The current state makes the PRE-FETCH command effectively unusable via pass-throughs. Signed-off-by: Douglas Gilbert Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_lib.c | 11 +++++++++++ include/scsi/scsi.h | 2 ++ 2 files changed, 13 insertions(+) --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -856,6 +856,17 @@ void scsi_io_completion(struct scsi_cmnd /* for passthrough error may be set */ error = BLK_STS_OK; } + /* + * Another corner case: the SCSI status byte is non-zero but 'good'. + * Example: PRE-FETCH command returns SAM_STAT_CONDITION_MET when + * it is able to fit nominated LBs in its cache (and SAM_STAT_GOOD + * if it can't fit). Treat SAM_STAT_CONDITION_MET and the related + * intermediate statuses (both obsolete in SAM-4) as good. + */ + if (status_byte(result) && scsi_status_is_good(result)) { + result = 0; + error = BLK_STS_OK; + } /* * special case: failed zero length commands always need to --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -47,6 +47,8 @@ static inline int scsi_status_is_good(in */ 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 */