From patchwork Fri Jul 9 13:18:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 472301 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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 1DBB8C07E9B for ; Fri, 9 Jul 2021 13:18:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 070BC61377 for ; Fri, 9 Jul 2021 13:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231980AbhGINVk (ORCPT ); Fri, 9 Jul 2021 09:21:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:51858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbhGINVh (ORCPT ); Fri, 9 Jul 2021 09:21:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 74ED5613B6; Fri, 9 Jul 2021 13:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836733; bh=2/6PFKcqQpIK27RimnGf9jRd+T7ijjCZEd7Fgyj2bVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nhFpbWdJUTz6/6Pmblr/mo+VrgQpt1AWgG80qHEXUChFZNDDiTgSMdigVJD8w3pQV QWBGOGOsXdx9WjLiugDOCqBHFOKRuS2jXgJZ3Y9exOSQJZGuBBFvicmBJBUpActupL 6zvN2rVBmawM6+mApLennwznXnGUbpccWym38O1U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ManYi Li , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 5/9] scsi: sr: Return appropriate error code when disk is ejected Date: Fri, 9 Jul 2021 15:18:32 +0200 Message-Id: <20210709131550.250648459@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131542.410636747@linuxfoundation.org> References: <20210709131542.410636747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: ManYi Li [ Upstream commit 7dd753ca59d6c8cc09aa1ed24f7657524803c7f3 ] Handle a reported media event code of 3. This indicates that the media has been removed from the drive and user intervention is required to proceed. Return DISK_EVENT_EJECT_REQUEST in that case. Link: https://lore.kernel.org/r/20210611094402.23884-1-limanyi@uniontech.com Signed-off-by: ManYi Li Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/sr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 67a73ea0a615..5e51a39a0c27 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -216,6 +216,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) return DISK_EVENT_EJECT_REQUEST; else if (med->media_event_code == 2) return DISK_EVENT_MEDIA_CHANGE; + else if (med->media_event_code == 3) + return DISK_EVENT_EJECT_REQUEST; return 0; }