Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144485pxv; Fri, 9 Jul 2021 19:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycWk7dlQhDIpDhJep6wlIOo5RUtnHfV0gJmxm2iMMWqcaZHScvwGtvxxbubn9I9CUTkr8l X-Received: by 2002:a05:6402:1001:: with SMTP id c1mr50407398edu.26.1625883912593; Fri, 09 Jul 2021 19:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883912; cv=none; d=google.com; s=arc-20160816; b=PfuShlu7YDXFg9IkECjNgawCMpEbgzOnOn09EN1T7Yc2MpwHm/rf0ePmn2ESvUQtxU uSkYu67dK4gv2JI0a0Yph52CH4JcGEYvr+AOBC8244dAcj43DT6lrs3nBgh34VyvwLGM zPxqr7MntrXnmimcW2xGzvM5ps+2csBpjB1zpwLZpRoaDYBHCpza3yKncwFM9H+9jpnY aO0h3v5nMzAferXa5LD0ld2qsN7sGy4ESbbdG7hFKcNEWc2mlHqVp8oHh2wZ/+txx2Ss mft+MwszASJvzairaVyw68rysoUn0/V+x5fqPF9Dth5yg/OpaE2skcBG9P4+sh4/z3Ra LnXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8C4lKAnKorUCu7vN9+r6JnSIT0pijQ6R8l/iZnL/+C4=; b=Twl6wqrds2UYHAZgkyXpmpTVGpp48ifHKZ8NGyXymtygWZuwt3NEwsAYpFaL+nAO7S n1v/iowlrMylKfGNlOdEgel97LZoj4ASd4L7IkNrZvs9veoG93jQ1P+C2IF2/3vmN22d hO82I9Zw0/4KdKVujdejXDIaQwYoIPDG9+EJILBHgBKgRDmAVVJh94JXt613D2k6vSlB 7DL1+XA4ODgnpYJm8XZK/nJwXwrtXXKKAwcoRIq6XJ6FJYv0tg++/uDbrEaqNQZn2Io4 bOLltrqSdLBr3nsGHDIHxSrOPCb3PL3ISShzCdqv3CrHWwFwjLVFcNkkkNdxBEaxaC/O AIzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lKi4YEPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si9749142edo.404.2021.07.09.19.24.49; Fri, 09 Jul 2021 19:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lKi4YEPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233183AbhGJCX2 (ORCPT + 99 others); Fri, 9 Jul 2021 22:23:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:38204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbhGJCWT (ORCPT ); Fri, 9 Jul 2021 22:22:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D2FE60BD3; Sat, 10 Jul 2021 02:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883568; bh=2PZ0lzObAQRnJF57W3GYqnaYB/bfZfQaQjuMHASKseE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKi4YEPkVQyi21Mpv7GAZoEW4OeWp7Oh05C9omxhyxKgMFn/KvUj9XGsCuO7XJwPW vCVRrniomo+9x3GVXy/5YYUpwTTWT1E6q2lqc3V+wPLTkpPbks8CeJJl6wpFEVOZiC gtK7UU9+b8Bwbjwsv/T8HsyXc2EvqMZaMQScyQT1d2UGCFoSjVWaxOumpeSn+Ijpvn 5eWK9ke+OXXYHCzwmvJQ+MohLui5pyxWcctWURKnCCnLAzfgwBguvK+0ambQb6wZSj 7K+c5kCMWzqG5L9x2wm+LBwSgTsRQVW90X2RHzwqGuP/p1Hh2viGtQXcbxcCnNNYf+ rEGtR5WFULdng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Kelley , "Martin K . Petersen" , Sasha Levin , linux-hyperv@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 074/114] scsi: storvsc: Correctly handle multiple flags in srb_status Date: Fri, 9 Jul 2021 22:17:08 -0400 Message-Id: <20210710021748.3167666-74-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710021748.3167666-1-sashal@kernel.org> References: <20210710021748.3167666-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kelley [ Upstream commit 52e1b3b3daa9d53f0204bf474ee1d4b1beb38234 ] Hyper-V is observed to sometimes set multiple flags in the srb_status, such as ABORTED and ERROR. Current code in storvsc_handle_error() handles only a single flag being set, and does nothing when multiple flags are set. Fix this by changing the case statement into a series of "if" statements testing individual flags. The functionality for handling each flag is unchanged. Link: https://lore.kernel.org/r/1622827263-12516-3-git-send-email-mikelley@microsoft.com Signed-off-by: Michael Kelley Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/storvsc_drv.c | 61 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index e6718a74e5da..b2e28197a086 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1009,17 +1009,40 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, struct storvsc_scan_work *wrk; void (*process_err_fn)(struct work_struct *work); struct hv_host_device *host_dev = shost_priv(host); - bool do_work = false; - switch (SRB_STATUS(vm_srb->srb_status)) { - case SRB_STATUS_ERROR: + /* + * In some situations, Hyper-V sets multiple bits in the + * srb_status, such as ABORTED and ERROR. So process them + * individually, with the most specific bits first. + */ + + if (vm_srb->srb_status & SRB_STATUS_INVALID_LUN) { + set_host_byte(scmnd, DID_NO_CONNECT); + process_err_fn = storvsc_remove_lun; + goto do_work; + } + + if (vm_srb->srb_status & SRB_STATUS_ABORTED) { + if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID && + /* Capacity data has changed */ + (asc == 0x2a) && (ascq == 0x9)) { + process_err_fn = storvsc_device_scan; + /* + * Retry the I/O that triggered this. + */ + set_host_byte(scmnd, DID_REQUEUE); + goto do_work; + } + } + + if (vm_srb->srb_status & SRB_STATUS_ERROR) { /* * Let upper layer deal with error when * sense message is present. */ - if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID) - break; + return; + /* * If there is an error; offline the device since all * error recovery strategies would have already been @@ -1032,37 +1055,19 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, set_host_byte(scmnd, DID_PASSTHROUGH); break; /* - * On Some Windows hosts TEST_UNIT_READY command can return - * SRB_STATUS_ERROR, let the upper level code deal with it - * based on the sense information. + * On some Hyper-V hosts TEST_UNIT_READY command can + * return SRB_STATUS_ERROR. Let the upper level code + * deal with it based on the sense information. */ case TEST_UNIT_READY: break; default: set_host_byte(scmnd, DID_ERROR); } - break; - case SRB_STATUS_INVALID_LUN: - set_host_byte(scmnd, DID_NO_CONNECT); - do_work = true; - process_err_fn = storvsc_remove_lun; - break; - case SRB_STATUS_ABORTED: - if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID && - (asc == 0x2a) && (ascq == 0x9)) { - do_work = true; - process_err_fn = storvsc_device_scan; - /* - * Retry the I/O that triggered this. - */ - set_host_byte(scmnd, DID_REQUEUE); - } - break; } + return; - if (!do_work) - return; - +do_work: /* * We need to schedule work to process this error; schedule it. */ -- 2.30.2