Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1970711imm; Thu, 24 May 2018 03:48:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruF9vhsA6gt3AxXj23oGvbkmFv/AWLiKE7Qyu/N4QIL3J8AWusBMPu+sbi8gqrYi2rLckt X-Received: by 2002:a63:5d6:: with SMTP id 205-v6mr5200862pgf.272.1527158901169; Thu, 24 May 2018 03:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158901; cv=none; d=google.com; s=arc-20160816; b=NbyVd64hQWd6z7dP1DpYcYFLvA8RKVb6HVbg6rG12mEkMxUc0q+jZ5jpCgtncTf3nU tR4Cq7MqNrslHNGcOacVWrNS+dOVm42pgwTR1yDaJmxXsiiUHRL3rCq0P1s6nEdw1kRY r4W4e6pfnbD4hL8yboIDUJAn6NQp3oxhwry2QTpLEJ+6wT8bCCbY9VUhcxU+JDUfAsuE EEPWb+z/BBcCU28gDSOfYtc/jiObK+o3AcWRktFOPZqgB71seHJ8eTfMq7Gvu3UarU3Z TmlIuwqbGhDm3NjjR2O49mB4uVXN6GnlPfMpJvTfhWdsmpgkJN5OEb6G8ggMmsPeOYzJ ladQ== 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=6zMc5lU4cU131ij1jcfM4RpfDWWp7Bi5PCbVDgpQF2g=; b=rUPEhxl6Rsog2AHxV/b6HupfYfiW6Iy22zWakjNYXJwLC6v7ZRt+TBBGsZ2Nyi7HDy fET9SZi7JXT3F2TGJ26bT8e7Q9/dU4ipjHRwns85Nt5LMLjv1vMCqWtaHEzepbpvUDpk Bsc4yecBAOgFqJutpZqbhMmC+83C4AzwB/m0PfwNSoUSYcHUzSc7Hl2HYnfZEBQoE0k9 uD0SHiutB4rQDrSEaIV97k7HWiXpOkVkoCWUqzBLR9aymjld7DVaiHrVYopG3GCI8lNE bD74Za05jJu1HKwVLYsRPxpCsikbVPg5BJXw5ZbszmDU7+d/IJ+2B95IAO7ZA5JqDvh1 tX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EJF7aK7y; 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 m26-v6si21555668pfk.56.2018.05.24.03.48.06; Thu, 24 May 2018 03:48:21 -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=EJF7aK7y; 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 S1032388AbeEXKq3 (ORCPT + 99 others); Thu, 24 May 2018 06:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030500AbeEXJ5k (ORCPT ); Thu, 24 May 2018 05:57:40 -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 ADF4E20893; Thu, 24 May 2018 09:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155860; bh=fGQZpGPJ3QV8bW9QT0jP+8ON9ez3GYVZfj+B15dh/q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJF7aK7yBqoI9i1a8xazohMnsBxKVYGCTN6QNWMead4xC7bgbtJaInzR5CaEoXyCI oWHE9pOcQYKTaVHjSdYfLJEZ6UkXKuFYc5P5FOMZNEaplJ7ix/LtOt/5jpETtYil2y ioooov59DSkMe9hyQdmik/xAXZpPcDNx7wuUsBy8= 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.14 116/165] scsi: core: Make SCSI Status CONDITION MET equivalent to GOOD Date: Thu, 24 May 2018 11:38:42 +0200 Message-Id: <20180524093626.712206816@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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 @@ -857,6 +857,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 */