From patchwork Tue Dec 13 10:25:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9472021 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 3D9DC607EE for ; Tue, 13 Dec 2016 10:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F2D2858C for ; Tue, 13 Dec 2016 10:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17FD02858E; Tue, 13 Dec 2016 10:26:48 +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 928132858C for ; Tue, 13 Dec 2016 10:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932529AbcLMK0r (ORCPT ); Tue, 13 Dec 2016 05:26:47 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:34106 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932220AbcLMK0q (ORCPT ); Tue, 13 Dec 2016 05:26:46 -0500 Received: by mail-qk0-f173.google.com with SMTP id q130so111366706qke.1 for ; Tue, 13 Dec 2016 02:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zxtNPsXB2pXl41hQQ6YVO7OSGqCvCkwm6XsE4BTMg+k=; b=ZBldJimuaIZcpwEdKxaq/AlV9GTZVjl/ZuJje9xTt0oFloACoIE7ZmzCPgtPT7mWXZ +iGdalJuM6lKwKA0hNrEbe4D0sEa/HoWlvP2/tKYlaBC/MJdiMUCktDHhmfJc8RWcdV+ pX99Ef9yFNW/iqRGbW7bZ158cP6aiL1498g3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zxtNPsXB2pXl41hQQ6YVO7OSGqCvCkwm6XsE4BTMg+k=; b=j/yCE1HgIV1kaIpnZR8CNET00X1ddwnHB4Gwk+WjspGsFa7Dm6xAzSW7aXUaq/o794 vxJTLdglg7ArVImzbgNbmHHVgObp29UWqp/XvFlHkeyjfextKQc1I+CLxdjMBhwI9z10 BY2UDIQ7pOPJPhVMt+B3JEGJMsDJosldI0OO7JK0U0xc5S0NNflx8hze0ybR7lUm4DPW 36B4KEyndRLaGCiTRUXE/LKNli4GU/Ywn14W7dEGRUSThpBPMMBiRZsFcMMx63gCNY2Z kn5DDmEZaoe6rQAcIRk6ZS+6QBEtc2U1XySku49OSDtdpLjLRBzibNhIAvc35n9suYkz KKTg== X-Gm-Message-State: AKaTC001ePhs8UNSbL27oL8SB8HkXh2QQWOG4ooPU5odQhwh0tgMrBtLqGn+QZXSmKebcia0 X-Received: by 10.55.48.11 with SMTP id w11mr93112870qkw.109.1481624805374; Tue, 13 Dec 2016 02:26:45 -0800 (PST) Received: from android.dhcp.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id t124sm28606864qke.3.2016.12.13.02.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Dec 2016 02:26:45 -0800 (PST) From: Jitendra Bhivare To: cleech@redhat.com, lduncan@suse.com Cc: linux-scsi@vger.kernel.org, Jitendra Bhivare Subject: [PATCH v2 03/13] be2iscsi: Take iscsi_task ref in abort handler Date: Tue, 13 Dec 2016 15:55:56 +0530 Message-Id: <1481624766-13846-4-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481624766-13846-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1481624766-13846-1-git-send-email-jitendra.bhivare@broadcom.com> 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 Hold the reference of iscsi_task till invalidation completes. This prevents use of ICD when invalidation of that ICD is being processed. Signed-off-by: Jitendra Bhivare Reviewed-by: Hannes Reinecke --- drivers/scsi/be2iscsi/be_main.c | 45 +++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 7feecc0..260842a 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -218,47 +218,40 @@ static int beiscsi_slave_configure(struct scsi_device *sdev) static int beiscsi_eh_abort(struct scsi_cmnd *sc) { + struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr; struct iscsi_cls_session *cls_session; - struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr; - struct beiscsi_io_task *aborted_io_task; - struct iscsi_conn *conn; + struct beiscsi_io_task *abrt_io_task; struct beiscsi_conn *beiscsi_conn; - struct beiscsi_hba *phba; struct iscsi_session *session; struct invldt_cmd_tbl inv_tbl; - unsigned int cid; + struct beiscsi_hba *phba; + struct iscsi_conn *conn; int rc; cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; - spin_lock_bh(&session->frwd_lock); - if (!aborted_task || !aborted_task->sc) { - /* we raced */ - spin_unlock_bh(&session->frwd_lock); - return SUCCESS; - } - - aborted_io_task = aborted_task->dd_data; - if (!aborted_io_task->scsi_cmnd) { - /* raced or invalid command */ - spin_unlock_bh(&session->frwd_lock); + /* check if we raced, task just got cleaned up under us */ + spin_lock_bh(&session->back_lock); + if (!abrt_task || !abrt_task->sc) { + spin_unlock_bh(&session->back_lock); return SUCCESS; } - spin_unlock_bh(&session->frwd_lock); - - conn = aborted_task->conn; + /* get a task ref till FW processes the req for the ICD used */ + __iscsi_get_task(abrt_task); + abrt_io_task = abrt_task->dd_data; + conn = abrt_task->conn; beiscsi_conn = conn->dd_data; phba = beiscsi_conn->phba; - /* Invalidate WRB Posted for this Task */ + /* mark WRB invalid which have been not processed by FW yet */ AMAP_SET_BITS(struct amap_iscsi_wrb, invld, - aborted_io_task->pwrb_handle->pwrb, - 1); - /* invalidate iocb */ - cid = beiscsi_conn->beiscsi_conn_cid; - inv_tbl.cid = cid; - inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index; + abrt_io_task->pwrb_handle->pwrb, 1); + inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid; + inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index; + spin_unlock_bh(&session->back_lock); + rc = beiscsi_mgmt_invalidate_icds(phba, &inv_tbl, 1); + iscsi_put_task(abrt_task); if (rc) { beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, "BM_%d : sc %p invalidation failed %d\n",