Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2033186imm; Thu, 24 May 2018 04:52:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqaa5UYr/jmMpl+Hps3NJAczy9dSvYWyMxxDDIS1c/mh9/Cq3jhnnEZqo18tvtOILZrgwb0 X-Received: by 2002:a17:902:bd82:: with SMTP id q2-v6mr6994686pls.77.1527162728777; Thu, 24 May 2018 04:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162728; cv=none; d=google.com; s=arc-20160816; b=wjltmsGvqihCPqjBX54VaydCFmvxyhNOcYzN4HsvwsjDPvSgnhcrl2H2Rm/CrAHEmk Yh0H3rDk2mPa6w53Tr+l+EgG30U3/8BUHm6MorwO8oPhmq5tCUsnB5sb8FzpwxNTC+hE 5GHQk688vUzwrVTljkfvTf8mmxIWI0oNHyoPYsX/uqoQN89ol73NUiL+no8bxdviMpON 1ldqMMX8SReUJE8DVJX3ncTgk6n6VR2JKQVcUZ8/zjc0/9kysq8s9A+++h5bCkERuNG9 jCfDquxHnUnoQNNdbP8k/DHp9wQJOEds1JEVOq8VDFJarblWczDFwMrqUNDVk8L+EhVf g5fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=GT3LQBs7tEs4updRxqEivfimiTrXWW8XBv0KfI8lAEg=; b=lIHYYmKSdStt7qBYeZQ3t0gJ9W+RU4IORqA1FeMw4+uSAir0g9tN8EF28JnAqM7UsA lsE5L1Zpvba55U5VI9WAC212CYm66HPSfZFZ7VhHDON04oZrH4lK5iqHQFPaPG6WDxGw 9/k4To9zqq3Px5zWzP/xqGZyT0OKro3pyhBmkunWL1pcl11gtgCuPf40tM4ueYjVqY3P D8wDRrrJsCT4BshZomqlfUgRT5iPMXJUegWk440Ujk7hxCx0AZaYxnr5Tay0aprtZgrq FCqpMAGQtGAMNEKz6hi0DW8qXftrHUgFlLXzO040I6+OvHsZJ2vnweiU5LUEZ/kCIuCv HztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OAfIsDJm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18-v6si8588178pgs.668.2018.05.24.04.51.54; Thu, 24 May 2018 04:52:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OAfIsDJm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969255AbeEXLuz (ORCPT + 99 others); Thu, 24 May 2018 07:50:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:58750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966974AbeEXJqx (ORCPT ); Thu, 24 May 2018 05:46:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 354D6208DF; Thu, 24 May 2018 09:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155212; bh=9of1wrRvudGtwXxTRQBezR3U7qMMzCBr1HXU/u/Mg0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAfIsDJmZakA2VdjCEZY14yh38F/K0Tc2pT5G91IWrOyT+va0btGf4FlOsw3zm5e6 svsD5JIKWtTo4HxWyeoaR7mnhYEHz8toywIj6Nro81giyJYZKjhxai5QOYkNXnY3iz /M0JduRCJ36UxycCCGY+nhJPv4G7CGZGupDHnVjw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Yan , Xiaofei Tan , John Garry , Dan Williams , "Martin K. Petersen" , Guenter Roeck Subject: [PATCH 4.4 84/92] scsi: libsas: defer ata device eh commands to libata Date: Thu, 24 May 2018 11:39:01 +0200 Message-Id: <20180524093207.321493337@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Yan commit 318aaf34f1179b39fa9c30fa0f3288b645beee39 upstream. When ata device doing EH, some commands still attached with tasks are not passed to libata when abort failed or recover failed, so libata did not handle these commands. After these commands done, sas task is freed, but ata qc is not freed. This will cause ata qc leak and trigger a warning like below: WARNING: CPU: 0 PID: 28512 at drivers/ata/libata-eh.c:4037 ata_eh_finish+0xb4/0xcc CPU: 0 PID: 28512 Comm: kworker/u32:2 Tainted: G W OE 4.14.0#1 ...... Call trace: [] ata_eh_finish+0xb4/0xcc [] ata_do_eh+0xc4/0xd8 [] ata_std_error_handler+0x44/0x8c [] ata_scsi_port_error_handler+0x480/0x694 [] async_sas_ata_eh+0x4c/0x80 [] async_run_entry_fn+0x4c/0x170 [] process_one_work+0x144/0x390 [] worker_thread+0x144/0x418 [] kthread+0x10c/0x138 [] ret_from_fork+0x10/0x18 If ata qc leaked too many, ata tag allocation will fail and io blocked for ever. As suggested by Dan Williams, defer ata device commands to libata and merge sas_eh_finish_cmd() with sas_eh_defer_cmd(). libata will handle ata qcs correctly after this. Signed-off-by: Jason Yan CC: Xiaofei Tan CC: John Garry CC: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Martin K. Petersen Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/libsas/sas_scsi_host.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -222,6 +222,7 @@ out_done: static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) { struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(cmd->device->host); + struct domain_device *dev = cmd_to_domain_dev(cmd); struct sas_task *task = TO_SAS_TASK(cmd); /* At this point, we only get called following an actual abort @@ -230,6 +231,14 @@ static void sas_eh_finish_cmd(struct scs */ sas_end_task(cmd, task); + if (dev_is_sata(dev)) { + /* defer commands to libata so that libata EH can + * handle ata qcs correctly + */ + list_move_tail(&cmd->eh_entry, &sas_ha->eh_ata_q); + return; + } + /* now finish the command and move it on to the error * handler done list, this also takes it off the * error handler pending list. @@ -237,22 +246,6 @@ static void sas_eh_finish_cmd(struct scs scsi_eh_finish_cmd(cmd, &sas_ha->eh_done_q); } -static void sas_eh_defer_cmd(struct scsi_cmnd *cmd) -{ - struct domain_device *dev = cmd_to_domain_dev(cmd); - struct sas_ha_struct *ha = dev->port->ha; - struct sas_task *task = TO_SAS_TASK(cmd); - - if (!dev_is_sata(dev)) { - sas_eh_finish_cmd(cmd); - return; - } - - /* report the timeout to libata */ - sas_end_task(cmd, task); - list_move_tail(&cmd->eh_entry, &ha->eh_ata_q); -} - static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd) { struct scsi_cmnd *cmd, *n; @@ -260,7 +253,7 @@ static void sas_scsi_clear_queue_lu(stru list_for_each_entry_safe(cmd, n, error_q, eh_entry) { if (cmd->device->sdev_target == my_cmd->device->sdev_target && cmd->device->lun == my_cmd->device->lun) - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); } } @@ -622,12 +615,12 @@ static void sas_eh_handle_sas_errors(str case TASK_IS_DONE: SAS_DPRINTK("%s: task 0x%p is done\n", __func__, task); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); continue; case TASK_IS_ABORTED: SAS_DPRINTK("%s: task 0x%p is aborted\n", __func__, task); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); continue; case TASK_IS_AT_LU: SAS_DPRINTK("task 0x%p is at LU: lu recover\n", task); @@ -638,7 +631,7 @@ static void sas_eh_handle_sas_errors(str "recovered\n", SAS_ADDR(task->dev), cmd->device->lun); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); sas_scsi_clear_queue_lu(work_q, cmd); goto Again; }