From patchwork Mon Dec 5 08:06:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9460577 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 252726071F for ; Mon, 5 Dec 2016 08:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1642424B5B for ; Mon, 5 Dec 2016 08:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B42F24DA2; Mon, 5 Dec 2016 08:07:14 +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 A718824B5B for ; Mon, 5 Dec 2016 08:07:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbcLEIHM (ORCPT ); Mon, 5 Dec 2016 03:07:12 -0500 Received: from mail-qk0-f180.google.com ([209.85.220.180]:33158 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbcLEIHM (ORCPT ); Mon, 5 Dec 2016 03:07:12 -0500 Received: by mail-qk0-f180.google.com with SMTP id x190so338335302qkb.0 for ; Mon, 05 Dec 2016 00:07:11 -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=iEoiItqxbIgVXVrQ22Pzz0TeGqoMu1QgYfceO1AP6zE=; b=TOT7oOhnIUzftmGUhEFuNL3kkrE72yK3YoSdbjOGatiddSzzVRlnakawq0P07Jdo6r MTMOmrYM3QTx+i68uC1rDO4l930ui6+04XL1Gqw91Uypjqo4OSNaWk3OHccSU5yeoVlu zLN/iZw8xkrxoT/X1QNOtNOXPXcmuH91L+3TA= 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=iEoiItqxbIgVXVrQ22Pzz0TeGqoMu1QgYfceO1AP6zE=; b=J5FBDK95sYXlhbP+XmlaLtVK7Hm6x1CjKShRsayDxQwS8BFLJAeDLjj4Z8vPIj92Xn uaAWC6FitYbmAOuD7YOAQZQ3gNyRZgZqyhi7MJB3eO5ueOYSLxaaMkjN/ZAFgIGwVVNR bsIgTNlASc66OlkcBglEWpW3Wod9LnzeyrkGCFyZ7y4vP5teuo0ZeGzgvre+3A4xSPn9 DxYKQpVs7lo8V7jmlzHRd4VV6D+hlCp7OJSC+sNyrz/7MQRv4qC6/kPv7oTLV7I4wkal GF128FdAnGQEJuxuO8VSfq3b6ZAPi7UoGuCJIL5PWUCTEoQx+b5Nj/sxNRbTWE4FLGbD c97g== X-Gm-Message-State: AKaTC001DE1Mdqg7tUYHyR9GzheGatfeT30jdVFtPThB1sk+ksol58jh1bmEWNNnl9RR+g1i X-Received: by 10.55.93.68 with SMTP id r65mr46187786qkb.84.1480925230569; Mon, 05 Dec 2016 00:07:10 -0800 (PST) Received: from android.dhcp.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id i19sm8890519qte.8.2016.12.05.00.07.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Dec 2016 00:07:10 -0800 (PST) From: Jitendra Bhivare To: cleech@redhat.com, lduncan@suse.com Cc: linux-scsi@vger.kernel.org, Jitendra Bhivare Subject: [PATCH 03/12] be2iscsi: Take iscsi_task ref in abort handler Date: Mon, 5 Dec 2016 13:36:42 +0530 Message-Id: <1480925211-13223-4-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480925211-13223-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1480925211-13223-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 --- 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 d86de5d..6eaa78bd 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",