Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1148538pxv; Fri, 9 Jul 2021 19:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAOt7LvUqMvIBKJbKWrRPCwhSBeMcRarNEcJ/A8ZH5JheZrHGGMwIWziAEV7/yekuaEgsi X-Received: by 2002:a17:907:1dc2:: with SMTP id og2mr2607999ejc.397.1625884426362; Fri, 09 Jul 2021 19:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884426; cv=none; d=google.com; s=arc-20160816; b=vwYsXyET7yZGcbZcTxrOtEf2ekiiVWoQx+vVyBpX1ubQp7tBP/PPkYRDhkpQUeJT7T 4wO9d03DZ7AA18RLiaa9PwkiwsEh+bIH+0j7n5itXT8pQ/JDOlvpZCe7vlAoX2315jzz H4Bc2yY0f84w+dDubKz2q1xjhKAAOZ65oLk10WGsmbAT6DJlBljJsXMDfs+UUmO3kgnw unm+2DF3YeQsfJ+yGWI3EDgu3cvYPvPMMB3NP1iax3ShaC7/EgmDG+wHFm2ZE+YUvHOU Tpuman6NNxMVJIyTcNxjR3yCcPQdSxH7jZVhQ9wRMAcMwpgfCmdCPmOxBBkT588EobZW HCZQ== 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=wt0JJtgSJtW/55SEJgJ7B28tZWd2oIwoUQkcR9XtI4o=; b=rhUdOxOkHp5zv3cRcNOwiEEBjqe4pfQ+uBD6bCVSPhe5KsjFTjqpPejROPHlZLUt8i /QJhGmd4EXE4fipPIcbOWHeBNVZKHs/C0WbVBXx7C6T+RYw5VJTWaQV4DzpK0XWKTO57 xrsmtPDq5G8ltQmgDvHsknKjHt73rWvlMmFlCnvI4BwKDBqVoC+CYSmCIc2+RQb49Cgz ywcRN15/FE2t0d0Xojeh7VbRvThORXTbp9CvJVXBaINzxqvOTnTnWz35ieHp1bXn52za KL1blgYWnmDQHT/DkvSrtHUjGZLI2SZ3678Bvab3h2UQNgo9FJ7sqiLuZs2lJv05WE+f I31Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cECSv5ui; 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 eb8si10117378edb.608.2021.07.09.19.33.23; Fri, 09 Jul 2021 19:33:46 -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=cECSv5ui; 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 S234589AbhGJCd1 (ORCPT + 99 others); Fri, 9 Jul 2021 22:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234344AbhGJC3X (ORCPT ); Fri, 9 Jul 2021 22:29:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6E9861441; Sat, 10 Jul 2021 02:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883948; bh=YqEKOD+jbFI2SPkTCsG8hHcld8NPo8tsmJX1Z8hqID4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cECSv5uig8b0K58gWeMMhx24CFUx1kB9Jrbx0kiBocVNkJpFFSxkhQdFmJZ29e154 XC8uvTCbnwkxqnwVM8lZ/h/tdmkyFA0Q5vyj1zW/x8Ry5Gpu6Jy5LIS1pb7+E4NnNO 6m0C/MFGLI1n4g0b2P2Eaiv93w8YY48AV/qO89Vy6IvWND3ryuZtXpjFCnq//WdVaz hg7Qjt63a3DZ1ODF7oBdrULCT2vfIwIU2w1XW9IhYRrUyr+4b24Cu+HOrdYDfSkAJw 6mye+jd4gYMCDiDP85qwMB3F/Tb7nswpg1oxuMytXjj3nJyUpH1xm4fkL5YNsZ8+pf PEHC6QUGv8IdA== 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.10 61/93] scsi: storvsc: Correctly handle multiple flags in srb_status Date: Fri, 9 Jul 2021 22:23:55 -0400 Message-Id: <20210710022428.3169839-61-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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 ded00a89bfc4..0ee0b80006e0 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -994,17 +994,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 @@ -1017,37 +1040,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