Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1990639imm; Thu, 24 May 2018 04:08:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqqmqbitn8P0a/+VBu+b/E5yLga8bew5TfLvMQotinLBlP/8X7qhDkILsk0tmnmFTTa1RZ9 X-Received: by 2002:a63:5f0b:: with SMTP id t11-v6mr4174815pgb.79.1527160108035; Thu, 24 May 2018 04:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160108; cv=none; d=google.com; s=arc-20160816; b=DlgjKYkdcWNfP+KyrqkZnTVjGlVjQ2pOTnrrbqSBzcz47colJH+rOIQ7obHTBYqdeM wbVe4MaE+B22elT7h1n3JBwnyrzI5OtlGqcmL5cmPPWDJ0Z81jkpUzJ+ymFG4K4G7pRp 4aB7qwGYJvNxHVTRZF3JIf6EODOGR5N3yIut6Z35siBwB+oG5AbI6W3gB1af8KkSGEQJ Mxqn03Zi1KM0UvlUXPjLmM8+AlvHnVsr98NNoGfU2QA3ivfQZ6DuG5vUgCOqkKRwOV9y V3rri51sOne2rik5eNNomaSotopZHKtgjIfFWJuwXmP1TxdAlhoPd9ce0iYGvHJigdj/ karA== 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=c70Q+rR6C+un2YIxxxHEmQxzFtCabrJ8y+Z3eHjNsCw=; b=S5bQhUQ5D5pqvAVUYt7tN4VdyxjZqXEgSuIMv+ReBHBzBuqzKFHiPP9/dZjumR3A7W 3VDmjRiswg0TYvEOSfb6WPohEyrtMpc/VccXZKXvvcnCrLRcUTMoHTLHxIUi1a1fgfmt jWpCQ6Qnn4KX46E4V4uMpxGu5OtoFOxlyZfbgsezE2DYZOdfWOzIOEwi4Z9Yllomi17j d/V/WKUCpTgKkZvumBcn8eYFxdCRRwTDyytwlpkpy8LWGwSIZ9QcyHzwQ3F+SVLBoZg9 kiWRHdLYzl7vvIIGEAcSY+Q4NSKKuEy9XvUeWEO2YPnhmUv7izIzTZINerd1jx0bfWpv FZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kSjUzeVM; 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 d8-v6si15980362pgu.671.2018.05.24.04.08.13; Thu, 24 May 2018 04:08:28 -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=kSjUzeVM; 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 S1032929AbeEXLHa (ORCPT + 99 others); Thu, 24 May 2018 07:07:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968240AbeEXJyv (ORCPT ); Thu, 24 May 2018 05:54:51 -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 59A7420893; Thu, 24 May 2018 09:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155690; bh=mViEPXWEZdogjujb+wEgyo1nhlXBUOK2DoCiYOgWpk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kSjUzeVMnyurK+Ywwu5SXv60zgJb/rIXc4evl8FVp33Ui9Jd1JXybTVYanFt+V+JA jT4bA/dYXtg588fo0MLqaWOPCLgYg1NXPtjdK8OsqcZEcRqfX54xrc0NlD+A3O0zha bKMJnxGixGCXx+C7HsHHSWHXpaU0u97siAC9esQY= 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.14 046/165] scsi: libsas: defer ata device eh commands to libata Date: Thu, 24 May 2018 11:37:32 +0200 Message-Id: <20180524093623.892469476@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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); } } @@ -630,12 +623,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); @@ -646,7 +639,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; }