Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2061275imm; Thu, 24 May 2018 05:15:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhtJVi4aA4/jLqG4idv9KLIUc5U3BqKnxBNZW1KuKb9U8tZt6E+D9ejTt75sS5es89i7Q3 X-Received: by 2002:a65:4805:: with SMTP id h5-v6mr5700000pgs.96.1527164118193; Thu, 24 May 2018 05:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527164118; cv=none; d=google.com; s=arc-20160816; b=c6bLu7CUCU7PMwWKQ/WRejrMW7BUsVL1jAtUM9rRXIAZwbUaaYSUiPyehyDevoNTrL Shc0OPHh//SYkptZRBIDSkBqMeusdzQ+1UTbewWEXAGjz7Lb0h2oDaiA/ustUxNQCBPb Sx2ymBW7lyllzuB2Zp8wyZQdTWU+vEsUplp7Gji9d7RxEOmvkSVGCrBcgo5uYiYiSx2m pYusJ6VvDR+7tE+uwSJVHhAa6zmKkqeyxOrDDnoKQBN6mV/Hs7lOeAj9HgRJnNN59qoO Jr+o27wi50gFojjE5otUirNcJoHck1xbcj+L5lgypKoNsV8R8Gdeli8dM+qNsORQfrX7 G6ew== 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=BC8QYowRQ57Uiu/uv5HRfA0Z5AVB7j9aVPKY2czErBU=; b=ikAXtd+YoROiBFo6weowXbdLXxzYOXdTxaGynCnUVyrLuQYgGfwd9nJ9pBc6G45tv1 tPyZ3fSsFfTI/kzm2rbviFj5cTsgORlOS33zigpjMOaDarW/WHvCTvhGZ7bIKNmDYyep cvAyIe03MybkVGHRmgwGXzFVR1aYf6xiCBj0DwG7wR6gfUGEO8I23I827JsS08Lg+Ih0 2cQj2aC2MuCRDD3dTvwnDQNFdR7B4Wm0VO7vcVMgWlth2QcB/mkTPj/aczj8CWrOmZhK biEep634fsDoG2/v5ywj9O/770TDMHdAUNUBkyzNqfGQ/rjHwnnUPOni09eNYBjx2MCU UcqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lFvfrRx0; 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 c1-v6si19509750pld.103.2018.05.24.05.15.02; Thu, 24 May 2018 05:15:18 -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=lFvfrRx0; 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 S966340AbeEXJmY (ORCPT + 99 others); Thu, 24 May 2018 05:42:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966326AbeEXJmS (ORCPT ); Thu, 24 May 2018 05:42:18 -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 16CF42087E; Thu, 24 May 2018 09:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154937; bh=SiDeMSn690H+Ebkqadwru+NrE4QDXop/8SA5fxr5xCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFvfrRx0/PVJymkrXpW2gyL9W0cKXW/ag1uhHYhAtQ29vZ+OaJJrBQdaNEkxceGeJ ovoQRMcM2phowkb1dK5GSh5Es2rPpmhfo5Wrk57LYpekDV1SPaJk9ZT1zydIUVX/MH IaFBA+KIxqBFLitWPZiV60aeMQ554bgfqYZxbJxY= 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 3.18 41/45] scsi: libsas: defer ata device eh commands to libata Date: Thu, 24 May 2018 11:38:49 +0200 Message-Id: <20180524093126.164208523@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093120.599252450@linuxfoundation.org> References: <20180524093120.599252450@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 3.18-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 @@ -250,6 +250,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 @@ -258,6 +259,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. @@ -265,22 +274,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; @@ -288,7 +281,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); } } @@ -678,12 +671,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); @@ -694,7 +687,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; }