From patchwork Wed Feb 21 17:23:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10233617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96881602A7 for ; Wed, 21 Feb 2018 17:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F75922A68 for ; Wed, 21 Feb 2018 17:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F1D23B32; Wed, 21 Feb 2018 17:23:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B085122A68 for ; Wed, 21 Feb 2018 17:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934609AbeBURXT (ORCPT ); Wed, 21 Feb 2018 12:23:19 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:60743 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934244AbeBURXR (ORCPT ); Wed, 21 Feb 2018 12:23:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519233798; x=1550769798; h=from:to:cc:subject:date:message-id; bh=xNl8ttpYanMB7oHKjkvzLbmcyxrlrX2b7H/89ue71t4=; b=NMhtstXRVDoDV8tmT005JhckWAYjcnE2fP4qSKCDY74QRJ/1pSH19SAa jdi+oP483JiW1WcxhXqPG6ZY8n4wmbNpVn6Bymb+UKGoQGgVG4wYU8kUs sbKOC0clJ7wPWSvIZ6ajBAiKGEFl1vpVFOnEkzeOwuc/7sySrXdqDvcOE B/3zlp9O1UaXU9hOt8yLyrvFGN4np2HEZp8LK960p7o8g99/0t1T+2S/X UO9DVzb7eUx3YCysSX8VxhnPaF8C8Gy3dc37woxv49hTnlNgDu21p/hnZ 1DmcXTbmIL8QmdQ5B5wGQt1MeRK6rHSd4ep0o74ICsRh/ADESgLGKRU96 w==; X-IronPort-AV: E=Sophos;i="5.46,543,1511798400"; d="scan'208";a="71733931" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Feb 2018 01:23:17 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 21 Feb 2018 09:16:59 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip01.wdc.com with ESMTP; 21 Feb 2018 09:23:17 -0800 From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Natanael Copa , Damien Le Moal , Pavel Tikhomirov , Hannes Reinecke , Johannes Thumshirn , stable@vger.kernel.org Subject: [PATCH] Avoid that ATA error handling hangs Date: Wed, 21 Feb 2018 09:23:16 -0800 Message-Id: <20180221172316.11884-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid that the recently introduced call_rcu() call in the SCSI core causes the RCU core to complain about double call_rcu() calls. Reported-by: Natanael Copa Reported-by: Damien Le Moal References: https://bugzilla.kernel.org/show_bug.cgi?id=198861 Fixes: 3bd6f43f5cb3 ("scsi: core: Ensure that the SCSI error handler gets woken up") Signed-off-by: Bart Van Assche Cc: Natanael Copa Cc: Damien Le Moal Cc: Pavel Tikhomirov Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: --- drivers/scsi/scsi_error.c | 5 +++-- include/scsi/scsi_cmnd.h | 3 +++ include/scsi/scsi_host.h | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ae325985eac1..ac9ce099530e 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -229,7 +229,8 @@ static void scsi_eh_reset(struct scsi_cmnd *scmd) static void scsi_eh_inc_host_failed(struct rcu_head *head) { - struct Scsi_Host *shost = container_of(head, typeof(*shost), rcu); + struct scsi_cmnd *scmd = container_of(head, typeof(*scmd), rcu); + struct Scsi_Host *shost = scmd->device->host; unsigned long flags; spin_lock_irqsave(shost->host_lock, flags); @@ -265,7 +266,7 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd) * Ensure that all tasks observe the host state change before the * host_failed change. */ - call_rcu(&shost->rcu, scsi_eh_inc_host_failed); + call_rcu(&scmd->rcu, scsi_eh_inc_host_failed); } /** diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index d8d4a902a88d..2280b2351739 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -68,6 +68,9 @@ struct scsi_cmnd { struct list_head list; /* scsi_cmnd participates in queue lists */ struct list_head eh_entry; /* entry for the host eh_cmd_q */ struct delayed_work abort_work; + + struct rcu_head rcu; + int eh_eflags; /* Used by error handlr */ /* diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 1a1df0d21ee3..a8b7bf879ced 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -571,8 +571,6 @@ struct Scsi_Host { struct blk_mq_tag_set tag_set; }; - struct rcu_head rcu; - atomic_t host_busy; /* commands actually active on low-level */ atomic_t host_blocked;