Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2029411imm; Thu, 24 May 2018 04:48:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQpCkII/0wwrDimr9+0oJ6HJfaC5SSKh5TNlYPUSyDanXAjSANvf1nSuMu8EfFrNxuU5Nd X-Received: by 2002:a62:62c2:: with SMTP id w185-v6mr6942224pfb.78.1527162485780; Thu, 24 May 2018 04:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162485; cv=none; d=google.com; s=arc-20160816; b=0wgPu/dthlbIIF9UMTLF22K6z9tiInD+oA6F4XzheN+t+q63PYAZm0yI0QILUXm8lN 41KuB/pjkOthqbTeQrlypu0z5C1iAtF/h/5DIECP1xM+JDkYz01xpYudR6Vj3CbvRz7P 7YX6ZlgXMWBpekKeGGWrssxZCcrNSSmfC2FAn/6s6vPTfzhVh6dYGli3HR7/KDVJ5sTh 8btcxQvwxh9YmltpK+Kfu7v+vutPXLGMrrt6Q6L9GNB4nwJeYjfn0a4Bd0Y7AB9z98XP LckX3+qo9NGPVHz4TH4GlsPR2Cqn850i5XxisQKSD4qPKP6PZSWkmkeLddESvkUmwn5u ZfUg== 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=TLRC/931Aez8SerOOPtbBlwgykvQiQEuC1I55zSNd5o=; b=BTWKg4bgSiUOTACyXu7P2Ndd3QhP8XGim3S6sSBogROYMSQOHnIs/prFxOKEcVcRew yPaIcXXWiiRXQjVuuaQchTHuds2jdS8CsVBwOL1jjxjv35jM5K7c1LPs3pyEX2/7bUtg Me3Flu3zFGYrjScu3pn8A+jV0Cp7R3GoZj2IF1g80uU7na7bCcr98u9tBuUEq3QhMKRO LC9Tj0uPnEf/5NS1gpfSIuTrl18IaAqL9QlLKbxvUkmMClaf0UsgddbwF6IRlYEmdJEr yZC2KBCTro0+OAllzXg8AsH24cFZkAHBmnrgkj9xXYdlaySDrtn1Z9Cov5GO0f8JO4Zd XFpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Glng4R5K; 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 j12-v6si16457534pgf.222.2018.05.24.04.47.50; Thu, 24 May 2018 04:48:05 -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=Glng4R5K; 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 S967078AbeEXJrj (ORCPT + 99 others); Thu, 24 May 2018 05:47:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:60156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967014AbeEXJrb (ORCPT ); Thu, 24 May 2018 05:47:31 -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 27BD2208DD; Thu, 24 May 2018 09:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155250; bh=ZyvqfMBEhUaj6/OG/1rc41z+Mcf+3DSk62CmgQeTgcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Glng4R5K9z6T6tyGvYADvEWk3ef/1dyi48X8IG1L+qyGIuXecwe1fYNGKB4clCsQo odE7fmeCuH2h06928SuNxV43of9KClR1+PxMuWPnAHCXkcC0HQer6evozaIsyb0aL8 q5TMp/AoRNjC/U+MjYR+ZI+UrXbrz61nbwBZOowY= 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.9 18/96] scsi: libsas: defer ata device eh commands to libata Date: Thu, 24 May 2018 11:38:01 +0200 Message-Id: <20180524093606.632176066@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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; }