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");