From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B000C10F03 for ; Tue, 23 Apr 2019 20:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46F4C21900 for ; Tue, 23 Apr 2019 20:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556051742; bh=VzjpABVc+w08O99JxaJJmeJcy94PHIqu1k9WUT5lQ3M=; h=Subject:To:Cc:From:Date:List-ID:From; b=xUQtVfY43hQu5tyFK3slTtGPPKBTx6e8eo9G0ZfcocFcaAZAAQCN1krJWnVkfko+D 9nIta9E21KeytLwb7pRxxTXKcaxLAQkMxR0TGQ2LUhoQ8/xKoe25XPtaG3rdkfYHeD QzvGp2YqlD0QzK7qeWTgxzxm7leUohIIamvCdjaI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727519AbfDWUfl (ORCPT ); Tue, 23 Apr 2019 16:35:41 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:38339 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726029AbfDWUfl (ORCPT ); Tue, 23 Apr 2019 16:35:41 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8A08020222; Tue, 23 Apr 2019 16:35:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 23 Apr 2019 16:35:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=rU8XZx 1Vn5Ii3Wfgl576QLXwfj8Sv0mkARwahzcBs9A=; b=LTApyOxWMNsqAZmCTDVDec xvDaDSiyn4zBTNz2BqC+WkDeO+TvFYx2LgZx+3ckKNUg6bIBEhhHXkGbcyhp/C6e q3RvVIQ/0TxbVZ6gyloZ8towBOZzCPhetqaaiEsscp0vwHm4ETbVktfg3mb5Qymp vr586qKj1OJqxFkP/Hql09Pji2qBY5bkmdDyxPWACH4qsWQNj9c+P6eraxkIKeyq jNgzrNTTNbUp8U8oTYLsnIc/m+I69/mfeYJLBPSlBzDzwlTinHZPfGDEJ8bnY7nx LU3NO4qhrU86F6vYHhsqCSZSHjdNvISq3NcOKOQ+Bj0ot/CgUB8RKXBkzFvpfDdg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrgeekgddufeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeeivddrudelfedrhedtrddvvdelnecurfgrrhgrmhepmhgrihhlfhhroh hmpehgrhgvgheskhhrohgrhhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) by mail.messagingengine.com (Postfix) with ESMTPA id 67869E4176; Tue, 23 Apr 2019 16:35:39 -0400 (EDT) Subject: FAILED: patch "[PATCH] scsi: core: set result when the command cannot be dispatched" failed to apply to 4.9-stable tree To: jalee@purestorage.com, bvanassche@acm.org, hare@suse.com, martin.petersen@oracle.com, stable@vger.kernel.org Cc: From: Date: Tue, 23 Apr 2019 22:35:38 +0200 Message-ID: <1556051738200193@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.9-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From be549d49115422f846b6d96ee8fd7173a5f7ceb0 Mon Sep 17 00:00:00 2001 From: Jaesoo Lee Date: Tue, 9 Apr 2019 17:02:22 -0700 Subject: [PATCH] scsi: core: set result when the command cannot be dispatched When SCSI blk-mq is enabled, there is a bug in handling errors in scsi_queue_rq. Specifically, the bug is not setting result field of scsi_request correctly when the dispatch of the command has been failed. Since the upper layer code including the sg_io ioctl expects to receive any error status from result field of scsi_request, the error is silently ignored and this could cause data corruptions for some applications. Fixes: d285203cf647 ("scsi: add support for a blk-mq based I/O path.") Cc: Signed-off-by: Jaesoo Lee Reviewed-by: Hannes Reinecke Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 601b9f1de267..07dfc17d4824 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1706,8 +1706,12 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, ret = BLK_STS_DEV_RESOURCE; break; default: + if (unlikely(!scsi_device_online(sdev))) + scsi_req(req)->result = DID_NO_CONNECT << 16; + else + scsi_req(req)->result = DID_ERROR << 16; /* - * Make sure to release all allocated ressources when + * Make sure to release all allocated resources when * we hit an error, as we will never see this command * again. */