From patchwork Tue Jun 30 23:35:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3A11C433E1 for ; Tue, 30 Jun 2020 23:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ECB120722 for ; Tue, 30 Jun 2020 23:37:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JVx34hXZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726352AbgF3Xht (ORCPT ); Tue, 30 Jun 2020 19:37:49 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51630 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbgF3Xhs (ORCPT ); Tue, 30 Jun 2020 19:37:48 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWDhv049444; Tue, 30 Jun 2020 23:37:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=fZQkrJSPPN3m5ztR5Drs0Jg3OGpL50U0/mSFfMgkEuo=; b=JVx34hXZloQGWVdfyOXkV0O8u/gR0PO9re579K83vClbrtGF1QZ3Gsn6cF2UgwAPu7w+ AxlKlODOhD16TbOT1eYDVD2rLKGB9yjTYewV+jLaRrclMBMnEia3DirSTUVrNJ/g9CFp JncAag6sgw0PnsK0ZHaxP2zmNllbLFzxfZJwssJ8X5OyoW4Twi8uUCibPQDaVPb/lLk9 WmUtvB5JWjmvmqwEqKss36UxExe9wf5MIP/UIxQrxjmlGxb+ztD+tHj5LpI55EBrnpfC AJkT7CfTNTXU5PKwV6lqA6jKONqzIokBV0jrhuWvHgmMl1q441qT5jC9AIktGHrC8fHP 7Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 31xx1dv8cj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Jun 2020 23:37:40 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWZ94051433; Tue, 30 Jun 2020 23:35:40 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 31xfvt5xgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jun 2020 23:35:40 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05UNZaOs012732; Tue, 30 Jun 2020 23:35:39 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jun 2020 23:35:36 +0000 From: Mike Christie To: cleech@redhat.com, lduncan@suse.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Subject: [PATCH 2/4] iscsi class: delay freeing target_id Date: Tue, 30 Jun 2020 18:35:32 -0500 Message-Id: <1593560134-28148-3-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> References: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 mlxlogscore=999 cotscore=-2147483648 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If we are doing async removal of the session, we could be doing a scsi_remove_target from the removal workqueue, and for the offload case we could be doing a new session addition and scan to the same host. The add/scan might then end up trying to use the target_id of the target we are removing. This patch just has a delay the freeing of the target_id until after the scsi_remove_target has completed, so we know it's no longer in use. Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index bbf2eb7..2be28d8 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2037,11 +2037,11 @@ static void __iscsi_unbind_session(struct work_struct *work) spin_unlock_irqrestore(&session->lock, flags); mutex_unlock(&ihost->mutex); + scsi_remove_target(&session->dev); + if (session->ida_used) ida_simple_remove(&iscsi_sess_ida, target_id); - scsi_remove_target(&session->dev); - unbind_session_exit: iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n"); From patchwork Tue Jun 30 23:35:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4B6AC433E1 for ; Tue, 30 Jun 2020 23:35:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8164320780 for ; Tue, 30 Jun 2020 23:35:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="zHzAgH+5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgF3Xfu (ORCPT ); Tue, 30 Jun 2020 19:35:50 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35498 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgF3Xft (ORCPT ); Tue, 30 Jun 2020 19:35:49 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWGTv011121; Tue, 30 Jun 2020 23:35:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=6YsuJ3mlzl9g2yunSMZCeNPAfaw2piOOPLje1+wpPwA=; b=zHzAgH+5djDBbt8n/o8+vmprB4OK1lW5/1vKHgpXJEwiBp7NhpJeMZ0cih+hJyGOhadv nNh1Qas6SNmjKp6t5T8XU5CEdnsTKc99tucT5CGnZOt3WO9SD5JJhBUvea9LB4vD/N4e gHTk0EMptJsfyL2jMWzEJgA1brFdg1IIwc/rUyKDjyFKtp6Qlzrm4ybSyDZtP3lllzlL 1nUG+aOb2bVQEun0HmfBO8Mc7NUnlaCzhAMJ3F5Zyt5YPQ2bDV2kSRsgsN78ozwhzI2Z Z3JzuJY02eoYIC8BEL67lDzFvecEftx1G8rZCWPuAMRK0andjIaU6AaJZ3PDPJF+7/hk kw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31wxrn7c00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Jun 2020 23:35:41 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWhWt137113; Tue, 30 Jun 2020 23:35:40 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 31xg14ps08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jun 2020 23:35:40 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05UNZaXr002884; Tue, 30 Jun 2020 23:35:39 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jun 2020 23:35:36 +0000 From: Mike Christie To: cleech@redhat.com, lduncan@suse.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Subject: [PATCH 3/4] iscsi class: optimize work queue flush use Date: Tue, 30 Jun 2020 18:35:33 -0500 Message-Id: <1593560134-28148-4-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> References: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 cotscore=-2147483648 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no need for one session to flush the entire iscsi_eh_timer_workq when removing/unblocking a session. During removal we need to make sure our works are not running anymore. And iscsi_unblock_session only needs to make sure it's work is done. The unblock work function will flush/cancel the works it has conflicts with. Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2be28d8..2b3af43 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1979,10 +1979,11 @@ void iscsi_unblock_session(struct iscsi_cls_session *session) { queue_work(iscsi_eh_timer_workq, &session->unblock_work); /* - * make sure all the events have completed before tell the driver - * it is safe + * Blocking the session can be done from any context so we only + * queue the block work. Make sure the unblock work has completed + * because it flushes/cancels the other works and updates the state. */ - flush_workqueue(iscsi_eh_timer_workq); + flush_work(&session->unblock_work); } EXPORT_SYMBOL_GPL(iscsi_unblock_session); @@ -2206,11 +2207,9 @@ void iscsi_remove_session(struct iscsi_cls_session *session) list_del(&session->sess_list); spin_unlock_irqrestore(&sesslock, flags); - /* make sure there are no blocks/unblocks queued */ - flush_workqueue(iscsi_eh_timer_workq); - /* make sure the timedout callout is not running */ - if (!cancel_delayed_work(&session->recovery_work)) - flush_workqueue(iscsi_eh_timer_workq); + flush_work(&session->block_work); + flush_work(&session->unblock_work); + cancel_delayed_work_sync(&session->recovery_work); /* * If we are blocked let commands flow again. The lld or iscsi * layer should set up the queuecommand to fail commands. From patchwork Tue Jun 30 23:35:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 213630 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA6E6C433DF for ; Tue, 30 Jun 2020 23:35:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FA2D20722 for ; Tue, 30 Jun 2020 23:35:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="E+qJGHob" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbgF3Xfu (ORCPT ); Tue, 30 Jun 2020 19:35:50 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35496 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgF3Xft (ORCPT ); Tue, 30 Jun 2020 19:35:49 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWLe1011137; Tue, 30 Jun 2020 23:35:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=vVICrlJAS2PqSjeeB2xQKLiJ2RKt33flFfhW6cec9QA=; b=E+qJGHobcy3fK6x9dEGLqBLaP5vdj66Z4/z5lSyB7DWhqmpkx5L2jAjo+6DEjOBlW2gs AAaIh9J9OaWK01ku6jIeaIMi40t/WL2z6LLpdm8n1f6VUOHws0Qo7d2TWNSSLLck0sCN uTfd0gc2PRIVMxig+AeeaRDsD4ZvL0nS0YNZGNYP3n+w65tlvOAQ523mUifZ8CWS6pGC jMk/RFoMdY2rCAlAmvc6EUA0D+gB5NTOAC9ES4xVCdW9U5tJpUy4sbNqCiH8yqH/PBIO wOGJWQqPtXD1wMf7W3mspKq5J13LXy+bnkPckuQUSX7Nr2ZVVDwqMPk2j0CKAg7TfmSH 3g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31wxrn7byy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Jun 2020 23:35:41 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNWhgY137074; Tue, 30 Jun 2020 23:35:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31xg14ps0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jun 2020 23:35:40 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05UNZbtr008588; Tue, 30 Jun 2020 23:35:39 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jun 2020 23:35:37 +0000 From: Mike Christie To: cleech@redhat.com, lduncan@suse.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Subject: [PATCH 4/4] iscsi class: remove sessdestroylist Date: Tue, 30 Jun 2020 18:35:34 -0500 Message-Id: <1593560134-28148-5-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> References: <1593560134-28148-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 clxscore=1011 malwarescore=0 phishscore=0 adultscore=0 cotscore=-2147483648 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Just delete the sess from the session list instead of adding it to some list we never use. Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2b3af43..85a68cb 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1623,7 +1623,6 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class, static DEFINE_MUTEX(conn_mutex); static LIST_HEAD(sesslist); -static LIST_HEAD(sessdestroylist); static DEFINE_SPINLOCK(sesslock); static LIST_HEAD(connlist); static LIST_HEAD(connlist_err); @@ -2204,7 +2203,8 @@ void iscsi_remove_session(struct iscsi_cls_session *session) ISCSI_DBG_TRANS_SESSION(session, "Removing session\n"); spin_lock_irqsave(&sesslock, flags); - list_del(&session->sess_list); + if (!list_empty(&session->sess_list)) + list_del(&session->sess_list); spin_unlock_irqrestore(&sesslock, flags); flush_work(&session->block_work); @@ -3679,7 +3679,7 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport, /* Prevent this session from being found again */ spin_lock_irqsave(&sesslock, flags); - list_move(&session->sess_list, &sessdestroylist); + list_del_init(&session->sess_list); spin_unlock_irqrestore(&sesslock, flags); queue_work(iscsi_destroy_workq, &session->destroy_work);