From patchwork Sat Apr 3 23:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415241 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 F23DCC433ED for ; Sat, 3 Apr 2021 23:24:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA0EB61360 for ; Sat, 3 Apr 2021 23:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236948AbhDCXYP (ORCPT ); Sat, 3 Apr 2021 19:24:15 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44904 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236935AbhDCXYL (ORCPT ); Sat, 3 Apr 2021 19:24:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJGSb096803; Sat, 3 Apr 2021 23:23:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=HeoEFlt/87SiPD0/W3MJqIkj+3iiN5tWWFaeyfP/AFk=; b=fJ2/Qh/JsUFf9VJ5B9BbB0q3W8PWkfNVxcn5+pF7V0+HdspVL+m2RoD3KmTZfJEsnl3h q3JWjjvgGPCvi3Zf1eF4PPIBcDWyIAWzzXIUJ47yTZmHq3nYD0a4t8QF7Z8diIKri9QB rd2MTc54jkx1o2vQUArf+EQOS/uqnmhwiEHaEfSfvDu6xi0hOab0U1AfbPFRGvDAmyXh PsTycyVaU0Ps2sb7aWHrYuTKSFG0VV2oVLeiW36AjWgeDTZh4dNgL1Apm99MFwKH64li iWUgHZ+sFELrzJLlYGYj8wxXyLYaifJ+lrgn4SAqo80I82S9Gc3TKKrybI91841AiB25 PQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:49 +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 133NL7ld130247; Sat, 3 Apr 2021 23:23:48 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by aserp3020.oracle.com with ESMTP id 37pg61hu6n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=at3hAHJr1X0m0FgMgyZWckfMzV9sEchsvNFONFuYMDPTW34PdSS7vIyYWl27GssVahaywFW8ul6sgKPOKHAzv71E1220HKxEtd9CttPvxcjk6N4ZZOwyhfg4a0QDxiS02er//3eu9OhG8RsKBZ9S2iizs2db3qKR1gkrQBTKK9GHCgyBYgeAi5VbXUSI8BwF96QLCcjlbrWW7O8nObg9/HUYiFroD8xpFh22pSbfzEg90sTgcQuT81ap6zz3/1ftAuRPo/sEMlQTa/k1icHwqD/9V+9NRSHf8cYEBayxnpmV6CMsau2O5dgYJEE8iuQBtBLcMCEvzoWbzi4OEBdWkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HeoEFlt/87SiPD0/W3MJqIkj+3iiN5tWWFaeyfP/AFk=; b=LeYzzXXv18QkjhxIovxLGKKz9qfyBqfjxGDHWLMs5DiHKW9M43h2tE8IGohifgyPdEHWCW3dqOb9CEwDzNgrnQiiN0LX06JyF4+IqdJv0MFsKi19SGYdC1ngRm5iWrV9EfvZ5PlAjKSHjIU6xvO1pZNGJ3Znq+Id7bNkfVWsPj4dHeFcGppdtaVEkgIM8nSk2ZTbskpw0yC25R3HOyUpDxGKThclZEzYIDSN+aExG1xHM7xWkKpohqQUQ/ND6qdHt3Wf1FVRSYiqdOKE+A41Y1cbkRpFSkZa7vKIOhs1pxbcZgl0wEvooQm+22GmOYgh7XN6oLVW/62M/8FFB1LljA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HeoEFlt/87SiPD0/W3MJqIkj+3iiN5tWWFaeyfP/AFk=; b=b5E2nTCIRfjr/9VCVW84pbp3KNPlaH7MvOc10XWj3kRsC/yAouKAXFNwZxP0Xh8FSiPSwh3wg5QttXmyKMvGieK0m6tQjwQ9j/Hix2OueZ57ermlOO9mOcQYQ1YAurZ8/9G7Rzw0FTyj6VSqIxYzdh+aZIbit9O8h01Bn9lBM54= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3368.namprd10.prod.outlook.com (2603:10b6:a03:150::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Sat, 3 Apr 2021 23:23:45 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:45 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 01/40] scsi: iscsi: fix shost->max_id use Date: Sat, 3 Apr 2021 18:22:54 -0500 Message-Id: <20210403232333.212927-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95b383db-f3f5-4f7d-e37e-08d8f6f786c8 X-MS-TrafficTypeDiagnostic: BYAPR10MB3368: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jCkESXYw1JLX07gkp1KFhez1MwAJONDtLvxr3aBXYhMGGDXdkhngUoCJcWGK5DS4JNn7Y+rk+jg5Us9NZH4gpoiDK/mnGtDRdwxp3vBw4kFLKzNR8jrAMmKm0u/SUSYeCjoldjIhUJau9TwGFhGmqDMPMTXhFmhtZH1I5kIWFjkMUIC3Y/tZR7nvfUTnZbOLRHK1Zu6rmUVBe/li21sxb5CoyXeZ0jSAGy1bmQkfUWKotLSnhTvL+hqWbxiXCEcTqJOfPniV6Wtk7Kpk9YwrXASgkQ0ZXIUIMH2zUHwBaaGZw3QT3yW1vhOh2GOpnkMrC72+lkgOirBvOTieGuW7q3y1PGlAQrWV+fdn3JchF884qFLKZ39+Sm2CAFbPjM0/QIHdu0Wr3rv9go1TC8W309GDHdSgrzvhJpRApA+3RvZqDtSYrwfJ4nqZefaGZF6PK+1AJcs3zcOXzvhYlsLmk9ZQJPmsGBZ+jfSZdgKlrYK4LZ9AAL21RWL0IlAzyDqIRQeDso7iHgC1hIDjMFOwkUJc42PFNMlAZ+tiHmVpO48aCMSD8C+TvvExMskt7ce+5aUnxbmfbWx5C9a5xVvAatwcQDMveTGWOa4EQQKbUMHO6QjHQpHW0eSNxUXUSBY0O03MIEK706UzqRkKoQQb7MnxY6TB0Eh64QT/A/6s6vFvc3+7+fhIIivoYfK4o+aoxpTJaSNc7rhmlbg2zQeP3A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(346002)(366004)(396003)(376002)(956004)(478600001)(6666004)(921005)(4326008)(66946007)(2616005)(83380400001)(107886003)(8676002)(26005)(52116002)(8936002)(86362001)(38100700001)(16526019)(316002)(5660300002)(36756003)(186003)(66476007)(6506007)(6512007)(2906002)(6486002)(1076003)(7416002)(69590400012)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VBEs3i/jqXDguz9osuoKyD+LlXteM5gfHmjcQN+IqC8RsaNaMUC9cWkDkghy0u4qjLZvVtkdHzjTu8Kv+PS1yQdxMLv/AYa9ueo/UHCTbBIK+vvvW3ln29ZlFbRV+ZzzWxrQFx7Hf0QaDo3ZATg2aioB5KavCkQyu8Eu1ivTEe9cbTNKETs/XthSsh3a+FkGqLvHSU+qDW19KTVjd4+Oy/GjBu3qEHelDAmdQNJgSN26p0Kw3Nyc08PRKGStc9nbu8AJuTrwPDd7ZEBiEqvgwqMwHrytMHwV4OuqeVYIDLszIVrmMbgnwEeHHp9t3M43uAYq2N23DuerXYlIP04BUbSPc8DJ2jzywjuknVta4vpDz+6ejOf1OnuQH7iaFdd3grj/1dTSQyT1ib+mVrYf9fVe4NeWRQde9DNkkLw3ohZ/rKPhtCCm1/tsMXgwoKNNXqAN3tDox0YRGdSWV/wHj/lHytRHUma1OodzlfkufWNjrLlkPhn3XsfEm5yAKthyvRqW1Y3h5XAIJyziwWPMNdNrh7coz0NG1eY6qHzURc3B86byR370bKfZzb+1NeEBqiKvpgflKsId1MswrZEhDdZ/oiDd1w9DDW2BL1+8j+rLsaKnKpdGSls2/oNaEvINKMoqmCVoVOqbdo8AlisvFHlZE8XcFDnw0xBHjz53qOSHFdIV79xQOtvK8Umtrl9FpzJoWCyCNoGVvBZ4xFV0Tip2mquH71GFSIITNQ4ZK759P2kYSdSPyN8Z8DTYHEYMN+n74ihm1CEJJ4q3497Y14IIgnMd5yTjVTU0GQjfs76bqQ++5ElPZ074NCRUtRamIYWFjlsjtUTYq6BxFXvo7da8SSojg+jIcpMbJx1Rf7BWqJV8dze2p+18CE2kPsefN0u4fqGb0DbsioJm35foBqE4u6yX1iLI9G+iWUR3m+2cenCxPrNGun638SWADkub8hGPxvBeYkdV/ILWXeY1Lq/XxABn5wi1tiy+UQX9+VyZGUwh2rRobvq6pXAqGM7Gwfmj2AhQXoYUtEVwUdVG1icXgalAGgrcAzdJNWWmLvJD/WyfYvPlDPdGvH/ArYoLHvAOZ8Jb6XRZQ9caclDDR6M+pW+QE6s3ygXS0hlhfXapN93lhYzFCOb2Fvz+Wb2fUHX3iAXDRH4d/FkNw+j7WFbigKoeHIEH5Dxv5+wwtTWtalopbbfFPFXEfQzSQhN4QTZ82UOL5BaSMCMnFCR+ZmvQOdi2rOnyVx/DUSvoPuCLr3QQGzf2D+7Rn+s9xFu9xqFyKDphXlfNgm6erRJXogTUrobGGTK6nDjONY/gChajhjoS88m1AiQeXpYYTWlU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95b383db-f3f5-4f7d-e37e-08d8f6f786c8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:45.6110 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +GUwg7VIZxuawHFjiGPNCrJmOztLtGWTiZwqmPQVvis4fjxfnTLnC/c7vWWzaxzjJuy7kx9Hk6RsP0aMLN0HlhzztbzjuqXL2SBKRbGPMWo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3368 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: triwN_M6naVX0FJSk5l6Lcctw2wghGfg X-Proofpoint-ORIG-GUID: triwN_M6naVX0FJSk5l6Lcctw2wghGfg X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The iscsi offload drivers are setting the shost->max_id to the max number of sessions they support. The problem is that max_id is not the max number of targets but the highest identifier the targets can have. To use it to limit the number of targets we need to set it to max sessions - 1, or we can end up with a session we might not have preallocated resources for. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/be2iscsi/be_main.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- drivers/scsi/cxgbi/libcxgbi.c | 4 ++-- drivers/scsi/qedi/qedi_main.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 90fcddb76f46..56bd4441a789 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -416,7 +416,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) "beiscsi_hba_alloc - iscsi_host_alloc failed\n"); return NULL; } - shost->max_id = BE2_MAX_SESSIONS; + shost->max_id = BE2_MAX_SESSIONS - 1; shost->max_channel = 0; shost->max_cmd_len = BEISCSI_MAX_CMD_LEN; shost->max_lun = BEISCSI_NUM_MAX_LUN; @@ -5318,7 +5318,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba) /* Re-enable UER. If different TPE occurs then it is recoverable. */ beiscsi_set_uer_feature(phba); - phba->shost->max_id = phba->params.cxns_per_ctrl; + phba->shost->max_id = phba->params.cxns_per_ctrl - 1; phba->shost->can_queue = phba->params.ios_per_ctrl; ret = beiscsi_init_port(phba); if (ret < 0) { diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 1e6d8f62ea3c..37f5b719050e 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -791,7 +791,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic) return NULL; shost->dma_boundary = cnic->pcidev->dma_mask; shost->transportt = bnx2i_scsi_xport_template; - shost->max_id = ISCSI_MAX_CONNS_PER_HBA; + shost->max_id = ISCSI_MAX_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = 512; shost->max_cmd_len = 16; diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index f078b3c4e083..ecb134b4699f 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -337,7 +337,7 @@ void cxgbi_hbas_remove(struct cxgbi_device *cdev) EXPORT_SYMBOL_GPL(cxgbi_hbas_remove); int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, - unsigned int max_id, struct scsi_host_template *sht, + unsigned int max_conns, struct scsi_host_template *sht, struct scsi_transport_template *stt) { struct cxgbi_hba *chba; @@ -357,7 +357,7 @@ int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, shost->transportt = stt; shost->max_lun = max_lun; - shost->max_id = max_id; + shost->max_id = max_conns - 1; shost->max_channel = 0; shost->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE; diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 47ad64b06623..0aa0061dad40 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -642,7 +642,7 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev) goto exit_setup_shost; } - shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA; + shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = ~0; shost->max_cmd_len = 16; From patchwork Sat Apr 3 23:22:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415110 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 0E192C433B4 for ; Sat, 3 Apr 2021 23:24:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4EB961360 for ; Sat, 3 Apr 2021 23:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236949AbhDCXYP (ORCPT ); Sat, 3 Apr 2021 19:24:15 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44894 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236924AbhDCXYL (ORCPT ); Sat, 3 Apr 2021 19:24:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NL6XJ097803; Sat, 3 Apr 2021 23:23:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=fvWNDuFSuXa+uODipADiXT59+MXzQwm57qx98S0kMX0=; b=e2Tjjebfa0JW4jaeV6863xFhYcuH9mROBMRPesWN85VELxr13sWU0ZA5zd+l5MO4/8uG mXLjAc/67YA6prqFKGr3cSvhoJffFtIO0KV4/yyXts4eSjj9hEc9LNXj9MhZY56+stZY cllJW5W0mZeAJW38ghbnYvsGrdf4Y9E/sNi+4LGpMf5U2ci+hhNmjnkE8gHB/55pmz2g ihwyA8k45PtsS7Mf8tnab5vNfuZEKzrNlufot2i2tIPiCd41RXQLDfL0Hte2bQYpjztF h3BU2WsgQR75s0Du0xcVZZrLjyfCuUJifeRaCm09nqzcbC7h8zTtLNvjHa1rgxFTnA+K hg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:49 +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 133NL7le130247; Sat, 3 Apr 2021 23:23:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by aserp3020.oracle.com with ESMTP id 37pg61hu6n-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EPbScL+dqxHMUToN4yp0aPx+9nXqapc8awsPiVpT+mS1d0mc5ichrVwKiUVNCglKG+s5INNHk09w7vshy9txttq/v3JaFrZ+8BErNFFkdwWKaSUCGrIfTsT3crjuVcFYZGIaETdPezo0SXmnmrXoUY5Z2bQXKogUaF/xCdO5YPCfeola5W0z0RabZ5u26Cfu8Y05gSM3UDJSBRYlLq4PXYKNvIjTSNIDN1Ka90OpAuu2ddR+Nr2iP6cgJn0gNn33PKh7EGw9Y5BnoV9QiuZVt2Mysrw0xvIhH/+/KD+HlWpZuXU+o4CqOGOFnDr7Np0ss+GGGq6BXt2GbZT0yLSJ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fvWNDuFSuXa+uODipADiXT59+MXzQwm57qx98S0kMX0=; b=NPfsExPDU2ZAMW5EfhaaZu1lDfHSywnRBxu0vzNz61mSoN0VXtVSs+VulgMn8GJMeLF/znX93/ivf6PLKVkfdn9VTJggZR6RM/cvnwqKElij3vBAyh1dmPXtv1kCydGk8aXCBZwyoTMNCS/PMkcKCYMF7BlTVhFjU/uspjpC0nLRYMubiP9Tz+SH0edbCZbwX467l4upC/4mAuCro70FZznD8kz6kQH5iITfxR/OcoE7D8h3tkTDWY1L41i+lx+1HKXITzW0RYAXwVGM93G3KTVlqXsHKx7qNszgwzTV+Gzuiw8Z/9JhdrHeyMajN2HEp1MfGv3rh8tZqV33OHKKVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fvWNDuFSuXa+uODipADiXT59+MXzQwm57qx98S0kMX0=; b=o5R5hPtY9Q7JLgPsuFYmTHxjgvf+8Gd8z16+VcBbJitF81Md1ODsb2aSaNZAFjshtwtp//i1Bs0RT7hpy/8dNFBSAshsj/b5ALw6nuYJwHh1IyyMh/G2X6oF+m7ADzMPtl76MJbwrFVAkZW6++Xjbw2NwOlZHGqlVcGyeATJlY0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3368.namprd10.prod.outlook.com (2603:10b6:a03:150::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Sat, 3 Apr 2021 23:23:47 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:47 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 02/40] scsi: libiscsi: fix write starvation Date: Sat, 3 Apr 2021 18:22:55 -0500 Message-Id: <20210403232333.212927-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b432c93-b696-4831-261d-08d8f6f787ba X-MS-TrafficTypeDiagnostic: BYAPR10MB3368: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BCu4JGFhJEgMhxSE8Zwi2kSG/zBQouD3Xi6BqJK85UFRe8hahW1PiwDbpfQ4YQU/GY4X4XVD02jKAKW8eXPwOEIIm7WAPmD8/lbpQwzUsGuy+5umxCvyzxQ1ltRSp2YdN9eI6V37Kt5A3CNaRartBYzk7Tk/fAmvDZdAHBRV8ot/tP95wZM9hSr571Jm+U1REOF6EaTYRhw71EXasU/dy/fmja2TstBHU+c7E0ev5abRTSZOJ3oL5fUwdnQ+bvPKxtrwirvi+urwZrp2GeC1OJQmU/xxcoYGCR5/uiqmBRjtebhGM0wPk20QVR0xQf/oQ+e1EonE8zlebVqe9+N6ymMo53dKQ6UvqdHZwc2bwcQV7n6STeM+wdMnx0JmalRQX2pyHqI59+mimYGdsiviDu3U0qU+wVLv7oFrKcxg1zgkz3WqO4WHZPS15buXJLcPxNawYWcy+6eXvwLdlBdoFgj8Hn+ndedfCL1SybevyeriZrongQwMWymCuR1bFJ/+xmY3mAVO3aw6b0gZC0InYyDe2PMDJTN173GgPLQQrb+5jM2brCDYkPuaaEESRyaGAb8VMl9G3BsxXbM1fgu2C7TEECsuXbPHujSGHkgI4mV7s6o6NcBLiP4mhVRHo4vNw64Bb9SfuJJYUOnhz8zrvBsGx6RZSB4ooPuWRO8JzTE4cdVkSOVZUCXbph/dZ731RHwmnc11bNHnpfGF3R/5Tw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(346002)(366004)(396003)(376002)(956004)(478600001)(6666004)(921005)(4326008)(66946007)(2616005)(83380400001)(107886003)(8676002)(26005)(52116002)(8936002)(86362001)(38100700001)(16526019)(316002)(5660300002)(36756003)(186003)(66476007)(6506007)(6512007)(2906002)(6486002)(1076003)(7416002)(69590400012)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: NYJfyhYDVUP0KokVGh4VzTlAhyryMMU7dGBmoZrp7qv6om0nWn1malsOVDaLaeLLt5/64rp7cvaD4MtyXY4U7z5Nw2fqNBeqIf1sz/tcGNXW/lhu+aDoHl5R1ZkaV/mbAiZJy3ecL0XW9qgOWdeLWBM2RvvyEVP8Iro7wFDsK1r+NhvPiQ92yJPf9lJAOpyQ0nFGxH9o3ndFanEFm65nKVjkjtnEddyZ3VTEED0qyrPnTgGvPNW1ed7/zcgDH05fsw+oZTIEe/d3T8RbK0GJiyq9R7BIWDuE274jVILWaoXElkN44aNOaB4rAEZRB+KvDA6bEGhyZshXAwAK7vcBk9/lBsGpjAaulAKjxmq+ifa+g2ORaZw2neq5+UZe3RHNfAX8JHYr2Gry3+d+IMqh0qGfCSKfkJsJr6DiMyU/ZTeO8ZWe9EBV+HDMWe3zD062vyLqKnA9t+/iHjOcP6zt4aN33C3LY+5OACCsbuvfc5gtOarbotj/fKEb2UDJ643EnijlVdQudIMl0z3k9ntMKBRIuVNEAvrmRmqaVcAv3hCvKx6DwEqOwgv/SvtH3ucQ36GYj30NtnM1Wd1xVaJl/D5GZUNOQeet+WRrXy+NY/9PheCv2CrZP6150A/YznBTINkUWAZrLlXcFce+hv7UQnKqOxPuchz0cZ9WI8pq8Uz5JbmETCEZ4iHU9qUMcLDqF+rBA5vKXlq1nusknjttgqrmADSwQ7uKs/7JqPGFPP7X1lR6GTDownWYYYrAHe0QpbnTy8Gf6Y5KrGgt3x1u2D+PxzML9HZT7mclktaLFXqnHXDI6iXc6TjfbUdfvvoOqXkMihhmTlh3wViVK461NBgKyzDo9bTPTN8lcCAm+GQYlkh9mLbY9y3+Zdbhbk0SQvR+KrUAwtOUogE7aWXttNJ+z5anpMORnVX4fchCQ0GnsdIR1yB3ifsmQpiRSY/gk0vN0zXALWoX11tQzpbkY4+eFjwGZzcjmOsbaPRVRjwSXVTIewP92F1VGT/As93VmU/qAkSxlcBUlomGQcaGJNjvq3sj7NIILPemPqVeaBzapQkNBCT6qDaIrzfsrQohEsbT2CN57yjZVyZSr4+e+BMO1MtPdOgdZyLTwuL7IKz94aZjl/j9xBKvCeYf0ruF1We3mYXVtAmKhXqJs1khLqKdvzXsy9ok4kegk4pMxt66BAIvPBf4AVcgbxXCjJ3LzWKlmmlP6g0zxfbckB4DgArWvCWNsR1uFTepkmsZ6dVjHc3M0W/eXfRey/o8A5AF2ly0TKQYgo8BDdLJY/k3wA09KQzFvpmh/N8ZwLMVCC8jV3JOKdW1dXSDZdNR907k X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b432c93-b696-4831-261d-08d8f6f787ba X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:46.9392 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EkMKTJPlF8nEO6hSiO+FUHVktJX3ySVEBGn2NdBNTe1YJcjB3JCT6tB3O1wgi7Fv3PoW6fOR96Z2bTLkayokvuCfj1qXXEAdcKkq8pIAyDU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3368 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: 8RxmLf52uIcwxf_Jrabd7BdwOBB1x5Da X-Proofpoint-ORIG-GUID: 8RxmLf52uIcwxf_Jrabd7BdwOBB1x5Da X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We currently handle R2Ts after handling new cmds. This can lead to starving existing WRITEs waiting for R2T handling, if apps are sending new cmds so quickly cmdqueue is never empty. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 53 ++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 04633e5157e9..643edc4eb6fe 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1525,7 +1525,7 @@ EXPORT_SYMBOL_GPL(iscsi_requeue_task); static int iscsi_data_xmit(struct iscsi_conn *conn) { struct iscsi_task *task; - int rc = 0; + int rc = 0, cnt; spin_lock_bh(&conn->session->frwd_lock); if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { @@ -1562,7 +1562,30 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) goto done; } +check_requeue: + while (!list_empty(&conn->requeue)) { + /* + * we always do fastlogout - conn stop code will clean up. + */ + if (conn->session->state == ISCSI_STATE_LOGGING_OUT) + break; + + task = list_entry(conn->requeue.next, struct iscsi_task, + running); + + if (iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_DATA_OUT)) + break; + + list_del_init(&task->running); + rc = iscsi_xmit_task(conn, task, true); + if (rc) + goto done; + if (!list_empty(&conn->mgmtqueue)) + goto check_mgmt; + } + /* process pending command queue */ + cnt = 0; while (!list_empty(&conn->cmdqueue)) { task = list_entry(conn->cmdqueue.next, struct iscsi_task, running); @@ -1589,28 +1612,20 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) */ if (!list_empty(&conn->mgmtqueue)) goto check_mgmt; - } - - while (!list_empty(&conn->requeue)) { /* - * we always do fastlogout - conn stop code will clean up. + * Avoid starving the requeue list if new cmds keep coming in. + * Incase the app tried to batch cmds to us, we allow up to + * queueing limit. */ - if (conn->session->state == ISCSI_STATE_LOGGING_OUT) - break; + cnt++; + if (cnt == conn->session->host->cmd_per_lun) { + cnt = 0; - task = list_entry(conn->requeue.next, struct iscsi_task, - running); - - if (iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_DATA_OUT)) - break; - - list_del_init(&task->running); - rc = iscsi_xmit_task(conn, task, true); - if (rc) - goto done; - if (!list_empty(&conn->mgmtqueue)) - goto check_mgmt; + if (!list_empty(&conn->requeue)) + goto check_requeue; + } } + spin_unlock_bh(&conn->session->frwd_lock); return -ENODATA; From patchwork Sat Apr 3 23:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415113 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 34577C433ED for ; Sat, 3 Apr 2021 23:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 020FF6135F for ; Sat, 3 Apr 2021 23:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236922AbhDCXYI (ORCPT ); Sat, 3 Apr 2021 19:24:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54812 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236625AbhDCXYG (ORCPT ); Sat, 3 Apr 2021 19:24:06 -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 133NNpuS087662; Sat, 3 Apr 2021 23:23:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ZhM6KTE89lAF2XOjY5pwVv/csaTmIanjvosnILSNhVY=; b=cZdjWTeEYOhR4Burcv5m45lfI0MawiTRItbHSHDrSHS4m04j+mv7MZkW4kq7apgKWS+S y+NNJX6Ietw8Hy56z44n1KPk06SWvEyLSsb94NGyxCUQPPyHNPBypNZzdqTjbu72K8cT lc15wI6Ez5rAisTFnvCr35JsF7kecnMs4fTZ2P4v5J/BEPwn6dUvNIFrA5vlp85jLddI F9KHCz1JT7ga4nNtuP2oSDs7Ubgm/APfy+EYi0iyoiFGzctnRuleuxAcJaZZ+JM7Ywya 4wI4EPOUloXKoU1TI6Uu3GCB5EngrCSTNMDItZTTLPgRGyH6JVmcV6jtArahxAkOnj/n Gg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 37pq66rcv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJsFk132172; Sat, 3 Apr 2021 23:23:50 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by aserp3030.oracle.com with ESMTP id 37q1xk81gr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMB1NUHCUsc26e9vUpPB+rxdSthPhsRNleC+endHeVulyg79zsLXgX9htro6C1+Whdc8fZKfLv9dmgv15U10yElrVBkcDC4+tN7YOyffFLWuEft9eK/1AR4XnziUsRh0Mn4ZDXPzHyVdkh3MQ2/iZSDfK1Kw1EcjQ1QdB6xA1nGuH58aZ3tfgj4vbDmS6EpFtLEgExfKi5rDwJduhYuuShD5ezo+dOs3TZYmiNZyYemeMDiGnT4bTC3rDV/Jr1t1VMw2W9F5hzbFPzh5tHt5uRD/5h29yJCq4N0+WoXcxzyw3g/cFqSS4iP9Ee37Q7g7EWdy3nCyZzcbOgXDEPRlDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZhM6KTE89lAF2XOjY5pwVv/csaTmIanjvosnILSNhVY=; b=DfNll9gfWWG9ZOozJCndeycXIyvw9lbNi0BGVARS5eCHI0gwDMgMs8rEzcXAsshSrKZ08oT5z1bjXfv4HW3CGctGcmZRmLYeN3zEnJqwrGjiyagaxMVu8znTSRKP7Hc7Jijg5yrnTZ7B4+OTW54Li1AKKtmwW/HQNS+dqsuPQlYQ7RaJiWAKKMFA15U9CyaWou/YJ+n3fZjaHOEiE1td57VIkEO1fKW5sbnGPBm285q3aDYmgMZBYkjW14KY8WJbln1q47FtZZAXBIaBk412klonG13W9JujQ6w1/ZlTzZwxurNCxcHpLupGqdqmqzrE1thWvg4KvuwcNBUYhjMX9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZhM6KTE89lAF2XOjY5pwVv/csaTmIanjvosnILSNhVY=; b=ECS65exddA9PV2nRNdsFxX+MtzfwJElS8Ct9lHGsDrQsXNTtW5er7gUiueCrSHmViEE10e/XhRx5ZBq1ae9fp434opVGCIf2t7mboL5tGWTFRiRTzqqMdavmeELg9NtM4OgFZD04bACODiwcOuqQYiHT7nFT6nPQxL7sn53J6To= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:48 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:48 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 03/40] scsi: iscsi: remove unneeded task state check Date: Sat, 3 Apr 2021 18:22:56 -0500 Message-Id: <20210403232333.212927-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f55d26d3-f1b9-40b8-7872-08d8f6f78881 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x2TkAXF8eOMwVoJP57Wdyzt194NXyw1Qp4e0dd8M/EcBOWH8q5wUddre+cdbZDijkPe9w9vCxanDY+FVoWBygpzMd2BC3Sjk9fTzrnM2CKIT/bqPluJEnGzUfafVK0iTkKkBNt8ddcO4KuHzZpGawjK+urqdjG7k9c17YAaC9JyY2SQnupNRYE3WYy6iZUGLS8f6ZX2AkiTk7oXm6TaQHCSqdwh5Vl4L4NvGre77oy870H+xLrVuhxdj/jCtRACGcmQeADgzSZJlrGYRspZ40W2TZJBKV6JFvhnr+tdVZyv19r5o0fg+V9w1HNu+jlb19nvtFJxz67hyPA6A/5mXx+A+w2Wepmug5i8eBGK6SymOwrcDxyABoEqytIG7CU5JvDsvsfXasb8EI2K+3qnPIWw2/RlqaG+REIP4Rh9JQh1eLeAr1UMj4bamLX8R4/Zl915PsKArvj8ZO4cngDhHk8XKEis4nZU73b2qNuDAHgkBYRPifj9rY0g7dZqkXZ5kd3yYrG4FZmXgoDvCzPkJ9XmqCt3Q3QD8DeGA4Tg3DwpdYvA1MyOrAupPyKsCNS/NLX8rcFHf4BGGoO2VqTPMpJISPSuI9zSo2JwnGdtlsbGCHXibu9wM8r1oYXaq9D3hF+3IBqOgn0duEpjxzJetErm9fev0NHObwWwZq9BPc/pexrdPbqhzo0D2pIFgOSnpuCACwIRYNoHdm6fv6LRPfw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1OM+Q93vkQFwqqOY0BEA+MfGTpWzTFk43qoUSGHf8wTVAfFE0ZXK8gKSYCWgU+u/XAiWMRnn7wJS+OP8JGPajegTKauhEKHjnQOSWaks7HO4h2gVBI6hf/QaqG24DAoEKjzPlkKOFKPFkZrS96UcHmyHw4GgKDlwIEw0MqN6yPG7yz297XyDf7JdOlQ5k9oOVFRVd0eorMs0lrhccLuLJ/XcvlTYEbjA+9Srrvx9jevyHOkkjaqhzuUjoT+PgNdf49Ccqt6OM9Qlv/xosLPbjakItOs82IC86UY6OqwIGlwjdhVfjizYiR39u3lTvxCzJ7KM0uox8JZxCWObcO45/8TrrBTUIqXylZX1NQ3pgxDsn2KfAvvgYpz0WvmOKUVLij1eX/bvMWxXil7yJ8fOrOE7A2kdYbIQY/2pqeE8wiz8BUf/iYHtzAFPEDx2tXCvPG42gJ44AJiisOn9J2i9OwlgVaAJddaSDaN05xO5baZxdN3o8ThDhe2m/1KBklI53gE/0ltWgwYKG0eHVTy3PjXRAAHvVUybCx8WUy8AH3dLKG5jFaBS9hV2r3tWrSYv1Zz4chS+Ri4teE1jiSdJD9Zj9uIrsx/73ESASkJ0iNSZrLTWtZ5jA1blpy23Ftm7nJBQy/DOgCCdmTLvr6TiTpTnSge7qtEmyObRH2hSYm8YSssJoKxq887vcZ7GfZ9VeqW+R9rJb3jeQkq3TCWXmMWVPwoS/MAxjbphMAE8hW8MSnftAi8yIEIeLab5LMgqWbk9SY3NlOb5edA5Zk5jkcbimgtZli5PGPT8n25uoCCMJC5StDd0lc6ylghBqIpFMKRJhlSwIz58IOfflEuuU6WUJJVaKey/TNVvDsVFilHF7AoapJjRW4nlRSTk5fuTQCjEv96nlV3QwX/d/RWkZXAn/CrgHRpY76U+mBFd7nXblbe14ndDkG+Dw44XLCC14buNKY5Akv6qyXFf4qbjrKYs6RFtPXKo4v+yDi6NaIKl4ChjsXV7a0WbexccCov48aOk8M8GsBrfdm6RquKPJDpjM6dNxvO1D7W43hTe0ZXlEw/Uwp+8+Ey7A78EuIw1w+h0gbkkiCj6wAEWA6uLwDU/OYFt4f0jiD7naKC5rPcOcfk/eswNj2bVCF1aU5txKwJkO1cwyN6l1XDOu0+7r4NnvFObfwoYqoxXEgUjEldA/63eO4L+5sqEjXPRuBHDy0Oz8hg/H5uvkZ0/aI6Z8LjcUSkYtnfDW7Y9805RwHnRRSPk8SC1mCdQdeVDCnCHdr3vpF5QBpDGaj+r5rA2sQWgE4vpMeUehC6QDbC3rv9jMv45vBc7mRr9SUoeeMLY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f55d26d3-f1b9-40b8-7872-08d8f6f78881 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:48.2265 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eBjZVy2/Xa9RwUI8rOBIJv7deq5k29sM02sIguPzc+SIenZio01CGCD2oiY+lnn0cUsyxDLFe9Lf6B1Kh9Soltp7luRBT3Ws8FVMWcMxRZk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: -Ei82_Emy3z_OlK_d7vkRgw9JR4Y0hQM X-Proofpoint-GUID: -Ei82_Emy3z_OlK_d7vkRgw9JR4Y0hQM X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The patch: commit 5923d64b7ab6 ("scsi: libiscsi: Drop taskqueuelock") added an extra task->state because for commit 6f8830f5bbab ("scsi: libiscsi: add lock around task lists to fix list corruption regression") we didn't know why we ended up with cmds on the list and thought it might have been a bad target sending a response while we were still sending the cmd. It turns out the bug was just a race in libiscsi/ libiscsi_tcp where 1. iscsi_tcp_r2t_rsp queues a r2t to tcp_task->r2tqueue. 2. iscsi_tcp_task_xmit runs iscsi_tcp_get_curr_r2t and sees we have a r2t. It dequeues it and iscsi_tcp_task_xmit starts to process it. 3. iscsi_tcp_r2t_rsp runs iscsi_requeue_task and puts the task on the requeue list. 4. iscsi_tcp_task_xmit sends the data for r2t. This is the final chunk of data, so the cmd is done. 5. target sends the response. 6. On a different CPU from #3, iscsi_complete_task processes the response. Since there was no common lock for the list, the lists/tasks pointers are not fully in sync, so could end up with list corruption. Since it was just a race on our side, this patch removes the extra check. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 643edc4eb6fe..94cb9410230a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -562,16 +562,19 @@ static bool cleanup_queued_task(struct iscsi_task *task) struct iscsi_conn *conn = task->conn; bool early_complete = false; - /* Bad target might have completed task while it was still running */ + /* + * We might have raced where we handled a R2T early and got a response + * but have not yet taken the task off the requeue list, then a TMF or + * recovery happened and so we can still see it here. + */ if (task->state == ISCSI_TASK_COMPLETED) early_complete = true; if (!list_empty(&task->running)) { list_del_init(&task->running); /* - * If it's on a list but still running, this could be from - * a bad target sending a rsp early, cleanup from a TMF, or - * session recovery. + * If it's on a list but still running this could be cleanup + * from a TMF or session recovery. */ if (task->state == ISCSI_TASK_RUNNING || task->state == ISCSI_TASK_COMPLETED) @@ -1470,7 +1473,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, } /* regular RX path uses back_lock */ spin_lock(&conn->session->back_lock); - if (rc && task->state == ISCSI_TASK_RUNNING) { + if (rc) { /* * get an extra ref that is released next time we access it * as conn->task above. From patchwork Sat Apr 3 23:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415243 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 F4190C43460 for ; Sat, 3 Apr 2021 23:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9E2561360 for ; Sat, 3 Apr 2021 23:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236633AbhDCXYJ (ORCPT ); Sat, 3 Apr 2021 19:24:09 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45052 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236752AbhDCXYH (ORCPT ); Sat, 3 Apr 2021 19:24:07 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJjFC039009; Sat, 3 Apr 2021 23:23:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=UdOEpYCwx7+FBXgC/RRYfTA1ZnDFIqhvNcDjQd4hqfA=; b=PkZk7w3RQQ+hy/1O7/+RJDAJWnlMZikycIh0UnDhd7EZUqMFvwdwpFFMwqyQyp7Bx659 sURs35CapJ+9cfLiZHyHwT3dZ83143YSZp86Qt2RaShUU/gUwQZ08n4ICTHQ9wG1QuZV XKDohYzASHfUoLFPAuo2ERAYJonKUl+yTLuSbEKWtIEGV0Ffcdxf8CGnO63YMfA3zkvX tDZBNcazOnFfXAmMhHQVZBZUs+gnQHdZMLfO/gQddCwshitehrbTho0X2EkKSFE1y8uR PBwKsJfDiAjgfCPgm7lCpLsp7Hlsu3Hde3kBhV/VgKUqRykjN6wKIgB/3Ibv37VAuICi fQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 37pfsrrsgy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:52 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJsFl132172; Sat, 3 Apr 2021 23:23:51 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by aserp3030.oracle.com with ESMTP id 37q1xk81gr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/34NnJjwpJBh356UJ/HwiXstRbzmNH+0YoG/1dqXkQJTevMGr8eFILSrg0KkUOMAM0Y51lkjuNio2qaEHmgWgRNaHXBqSC1L0jMhpY3GjQFbU1MckIEncbLdbZGg7W1MeuDPTbeSs483ot3w5d6DF2irD9CcY//bSS9LI7GBVyjNYfA0WsVdXzra2KOeRSHZUvYJ49i+QgT7pibgMyyO+8qYcufHtEVD92Jn+fCpr9g6md6HVg+MOaHlcxDTayNCFfLneVd+Q4HFr2a1wEkOBxrPUa3bZkr2sSFLp+uqgVaTlU3fBQhMo/PKwl31WfZBvY4RSxXQ9EhVjbwgmeGgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UdOEpYCwx7+FBXgC/RRYfTA1ZnDFIqhvNcDjQd4hqfA=; b=RW2ohsvjuVPZtlQDJ4FPnIs84Si0qjto6KTDTQuDsAL+6iKLnvh/wEhEWU7SfSsQfRPRvE2a7s5tyY2/WSRlY9EkdnQV/zQg9NWX2EhgZs2gAoF3Mm8wotALJWAJYh1otGXeItczwJNeQz5WURltLiXPpA+QREFT3wormzQyfl4WFGzI+1Wkvs/TtQWicSiKsyN03coXSr6I+4YKNYb3bBh2avCxqWie3KjXBhULU6kein1oCAr1zTX9JoWXgkRjfsQazYXXZjflWte1weE+kHjYNkzhkogKIdtVdzCMx3CKNxWsEHuRmnHjKePxO3TCrf37OHJOGYF92jO4VMrSig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UdOEpYCwx7+FBXgC/RRYfTA1ZnDFIqhvNcDjQd4hqfA=; b=pVrwRAFwaVCfkPWrDEfNCje/DsnX13zQuay5R1CtdvwkdO88d1IhzwlSczyWbU/QOc64GsVimludMJZMS25kcj/AEPYjhFBVukMzNPO5G33W7Iiuc2tJJ65xLTszeQ7lMhWhj3v65sFS+5uRUrrkYeaNeRxdgeSVP+UhwGciDkE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:49 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:49 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 04/40] scsi: libiscsi: drop frwd lock for session state Date: Sat, 3 Apr 2021 18:22:57 -0500 Message-Id: <20210403232333.212927-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bfa59101-c6f3-4013-c6ee-08d8f6f78941 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:359; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nS50YqjE23kkjaSUUqAZ75NYYFdqWLqems6ZSaENXktGoTzSgb0V+mguUlm3geoxUD5XW5GvDI4R+EfczZozkRWG2UvPAN9ojCafV+obgto6l5uYjIeIyDcTT/aqmQ0kvUNdivB7GIzmWEu0GQLHP6Lcc8NjIvoOt4qjkCMoUEddilJPE/iCtoJ2cKhRmiADDRJSR/caJWJ5SoPLU8Fif6Z5ItPkZZUHZXTFm30+tVG0ZdQx62z0pjX9Np22x4noD5DkXWra3AzqkNAOY7R1cwat5wFfPyWiMuNxtOOn+731SyJxhINurd01gwF0I4UfbU0vbdK6Uha/o6gywLKNXka4Isxq/z34gHco6E+K/6cXlaIug+wkgAtoki7qDm4BAMkjxzlHilGhCByQDFbyaZHoL5pmgc/k6H772wg7GMUOymilhilmXSPHV4N3XSuYbOoBpzxV66Q9hyv2G3PTV7W5QmqfUXNMVXqjzbkYmQFC05C6A/d0yvXs7lOZq+ZuHDK79mYPxG1EvHfamiD98VNhDPM0WOydc0CjVqBf/ToUQrURjXVkDjTwnGy7flUvgwEJYaCfOe6QA5PKl04esq7we2G+G3YyzqiEa2VvEeUH/Qrdk5upAI22TbYu4RHrHUIaYhC2q3iutaT/4yfFzT97SDx7DQCpRy/S1E7AidPzJPYaSTrCcOhnnvNgjiiyhJbiy4Fvkq9bBHKPqBls3w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(30864003)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: g7Nme2pHvARn39VT7mPHcufFcYZppOAoiRlVh48Q7PUQAnsaTzuPW7v7O8bU39PwMRDILPk6hzZ3SCLqndZzfzMggxAQ6DfVNqncih5f70zQ5A992aeoPf0CoqYfgoT7kul0SyGINDddqk+zAsohTG2/3bNLVijfom+P75+Gr1o4jIDnFwL5fDVSTWNdhZfAmgK0lFWsYw4WiCnINKYcOzHMAfFHRki//xfF8KbrYOKJ9AsvXEuTVMsvxXonGPguY9003BtObpxGruHELuauonyN0uE5Ic5bRQNaF43rX5m5lz9P9tIqKusNSSD8FAOb5Lk00MsUc9Fu/97Zl2hgTDlECEJCS/dXa6bHPhbSOVNl6HqsSeGrmLoYgYeFsCY+L+k3y1tNJsxKQzoslD6czo7pfbsvRrMLDjfSqYqQ0bMYtMKGIjIlrUeJDd7DevertxgBB4C+20/BVpW1sqgRrPsouoV1N+pT1h1O0OusuSGalU5ARQo3z/gNYJz+Vtce43KbyF5Z9PRLYkI0mfduOZF4rAKo9RLlVBVgTRfzjtBlDoal3BXFzI6RTP7xTTIMW/vC5FSVmmwqqQkJm6xetHiPgR5FCmf2sEfU3KuDkvXtI/uaCDvjZu7xOWzExPO1XixvZ82IXvOfQyW7d2rrZcjFmrDemHHL2VOVLGqyHTMoq5ehPiscCtlqyxmN0mOSwYZHQ1H9ifSLVCFCbY1DKfOLFjmyD/asmJxAvpJCUDYMWqn4GC142Jf5imS99f0UIpq6PZ8wHSaIIXTLuX9ypHWnxL3oYXCbBlh0Nhzw8XmUnYSD7XEIvDBR+TPbk8zDRNrsbaiGNx5CdLOQjjfCDAjKyIY+Qp6t1E1GgDbQsAS0vU+uAv2gm1qkTbLVYFCOKNOo2cS+hslWn47X5XwXjutwcvkCLyBNRlpxuuhmK2Gl0pV70yleC6/phdiUd09lTg7h7euqsxJwyQ6koOWOo30KMAnAc1HdA0huaN8uCLiA+SUHMN+xLDXeySDc/tx10OzeqIYmf2mUCkIoP+DZB6Z3HklNk1iCaB0LYvOsJFbhH5ngYab/r3BTU/soDm1K87RIb/GJurJ8U2v0WkdDauXmtpL3p5/bnzKgnEHfojxV+tZTMi18xnBakN2ttjJ+O45P1NNL/Dzq8EQfx2Q70EqkUDUbO7Yqn0bVQobFLAIAh6IcZ+m0EFZdQnlbz74RPjq7h2oTdiZFxxtZOXDYrl/ofaNLsR8BRVyAVQtgFR++swTTqTmFwi3yA1cIUQ2cc+cwvf/NiyiiiXXO+ypJOSvfVKIWwpY78SY4u58fGaCEfR44UJH4+u9dfy1bf9TW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfa59101-c6f3-4013-c6ee-08d8f6f78941 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:49.4688 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RvloelexzFJRGR9MGhNzodBXy1zGziih0cJL6ZyVbCnxnba9Pj9Q9ppbJRIbulHZ4VCV4BWsORg7Moscx5C4h3H4BNsrWuL179z0vsbUSJw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: kzFU_LZoyXhBlIBtWOphLLPPa2kp_rdX X-Proofpoint-GUID: kzFU_LZoyXhBlIBtWOphLLPPa2kp_rdX X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This drops the frwd lock for the session state checks in queuecommand. Like with the transport class case, we only need it as a hint since when the session is cleaned up we will block the session which flushes the queues, and then we clean up all running IO. So the locking just prevents cleaning up extra cmds. This patch is a prep patch and does not help perf. This patch and the next ones are going to chip away the reasons we need the frwd lock in the queuecommand code path until there are none left for software iscsi. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 3 +- drivers/scsi/bnx2i/bnx2i_iscsi.c | 3 +- drivers/scsi/libiscsi.c | 86 +++++++++++++++++--------------- drivers/scsi/qedi/qedi_iscsi.c | 3 +- include/scsi/libiscsi.h | 14 ++++-- 5 files changed, 62 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 56bd4441a789..18d0591e4dbb 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -285,7 +285,8 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) session = cls_session->dd_data; spin_lock_bh(&session->frwd_lock); - if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) { + if (!session->leadconn || + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) { spin_unlock_bh(&session->frwd_lock); return FAILED; } diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 37f5b719050e..48809fc8f095 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -2056,7 +2056,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep) if (session) { spin_lock_bh(&session->frwd_lock); if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) { - if (session->state == ISCSI_STATE_LOGGING_OUT) { + if (READ_ONCE(session->state) == + ISCSI_STATE_LOGGING_OUT) { if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) { /* Logout sent, but no resp */ printk(KERN_ALERT "bnx2i (%s): WARNING" diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 94cb9410230a..7b83890aeb7a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -633,7 +633,7 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr; uint8_t opcode = hdr->opcode & ISCSI_OPCODE_MASK; - if (conn->session->state == ISCSI_STATE_LOGGING_OUT) + if (READ_ONCE(session->state) == ISCSI_STATE_LOGGING_OUT) return -ENOTCONN; if (opcode != ISCSI_OP_LOGIN && opcode != ISCSI_OP_TEXT) @@ -662,7 +662,7 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, return -EIO; if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) - session->state = ISCSI_STATE_LOGGING_OUT; + WRITE_ONCE(session->state, ISCSI_STATE_LOGGING_OUT); task->state = ISCSI_TASK_RUNNING; ISCSI_DBG_SESSION(session, "mgmtpdu [op 0x%x hdr->itt 0x%x " @@ -679,9 +679,10 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, struct iscsi_host *ihost = shost_priv(session->host); uint8_t opcode = hdr->opcode & ISCSI_OPCODE_MASK; struct iscsi_task *task; + int sess_state = READ_ONCE(session->state); itt_t itt; - if (session->state == ISCSI_STATE_TERMINATE) + if (sess_state == ISCSI_STATE_TERMINATE) return NULL; if (opcode == ISCSI_OP_LOGIN || opcode == ISCSI_OP_TEXT) { @@ -704,7 +705,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, task = conn->login_task; } else { - if (session->state != ISCSI_STATE_LOGGED_IN) + if (sess_state != ISCSI_STATE_LOGGED_IN) return NULL; if (data_size != 0) { @@ -1368,7 +1369,7 @@ void iscsi_session_failure(struct iscsi_session *session, spin_lock_bh(&session->frwd_lock); conn = session->leadconn; - if (session->state == ISCSI_STATE_TERMINATE || !conn) { + if (READ_ONCE(session->state) == ISCSI_STATE_TERMINATE || !conn) { spin_unlock_bh(&session->frwd_lock); return; } @@ -1395,13 +1396,13 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) struct iscsi_session *session = conn->session; spin_lock_bh(&session->frwd_lock); - if (session->state == ISCSI_STATE_FAILED) { + if (READ_ONCE(session->state) == ISCSI_STATE_FAILED) { spin_unlock_bh(&session->frwd_lock); return; } if (conn->stop_stage == 0) - session->state = ISCSI_STATE_FAILED; + WRITE_ONCE(session->state, ISCSI_STATE_FAILED); spin_unlock_bh(&session->frwd_lock); set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); @@ -1570,7 +1571,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) /* * we always do fastlogout - conn stop code will clean up. */ - if (conn->session->state == ISCSI_STATE_LOGGING_OUT) + if (READ_ONCE(conn->session->state) == ISCSI_STATE_LOGGING_OUT) break; task = list_entry(conn->requeue.next, struct iscsi_task, @@ -1593,7 +1594,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) task = list_entry(conn->cmdqueue.next, struct iscsi_task, running); list_del_init(&task->running); - if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { + if (READ_ONCE(conn->session->state) == ISCSI_STATE_LOGGING_OUT) { fail_scsi_task(task, DID_IMM_RETRY); continue; } @@ -1695,6 +1696,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) struct iscsi_session *session; struct iscsi_conn *conn; struct iscsi_task *task = NULL; + int sess_state; sc->result = 0; sc->SCp.ptr = NULL; @@ -1703,7 +1705,6 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; - spin_lock_bh(&session->frwd_lock); reason = iscsi_session_chkready(cls_session); if (reason) { @@ -1711,14 +1712,15 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto fault; } - if (session->state != ISCSI_STATE_LOGGED_IN) { + sess_state = READ_ONCE(session->state); + if (sess_state != ISCSI_STATE_LOGGED_IN) { /* * to handle the race between when we set the recovery state * and block the session we requeue here (commands could * be entering our queuecommand while a block is starting * up because the block code is not locked) */ - switch (session->state) { + switch (sess_state) { case ISCSI_STATE_FAILED: /* * cmds should fail during shutdown, if the session @@ -1753,26 +1755,31 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto fault; } + spin_lock_bh(&session->frwd_lock); conn = session->leadconn; if (!conn) { + spin_unlock_bh(&session->frwd_lock); reason = FAILURE_SESSION_FREED; sc->result = DID_NO_CONNECT << 16; goto fault; } if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { + spin_unlock_bh(&session->frwd_lock); reason = FAILURE_SESSION_IN_RECOVERY; sc->result = DID_REQUEUE << 16; goto fault; } if (iscsi_check_cmdsn_window_closed(conn)) { + spin_unlock_bh(&session->frwd_lock); reason = FAILURE_WINDOW_CLOSED; goto reject; } task = iscsi_alloc_task(conn, sc); if (!task) { + spin_unlock_bh(&session->frwd_lock); reason = FAILURE_OOM; goto reject; } @@ -1803,21 +1810,23 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) return 0; prepd_reject: + spin_unlock_bh(&session->frwd_lock); + spin_lock_bh(&session->back_lock); iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); spin_unlock_bh(&session->back_lock); reject: - spin_unlock_bh(&session->frwd_lock); ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason); return SCSI_MLQUEUE_TARGET_BUSY; prepd_fault: + spin_unlock_bh(&session->frwd_lock); + spin_lock_bh(&session->back_lock); iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); spin_unlock_bh(&session->back_lock); fault: - spin_unlock_bh(&session->frwd_lock); ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); scsi_set_resid(sc, scsi_bufflen(sc)); @@ -1885,8 +1894,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, * given up on recovery */ wait_event_interruptible(conn->ehwait, age != session->age || - session->state != ISCSI_STATE_LOGGED_IN || - conn->tmf_state != TMF_QUEUED); + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN || + conn->tmf_state != TMF_QUEUED); if (signal_pending(current)) flush_signals(current); del_timer_sync(&conn->tmf_timer); @@ -1895,7 +1904,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, spin_lock_bh(&session->frwd_lock); /* if the session drops it will clean up the task */ if (age != session->age || - session->state != ISCSI_STATE_LOGGED_IN) + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) return -ENOTCONN; return 0; } @@ -2025,7 +2034,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) __iscsi_get_task(task); spin_unlock(&session->back_lock); - if (session->state != ISCSI_STATE_LOGGED_IN) { + if (READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) { /* * During shutdown, if session is prematurely disconnected, * recovery won't happen and there will be hung cmds. Not @@ -2161,7 +2170,7 @@ static void iscsi_check_transport_timeouts(struct timer_list *t) unsigned long recv_timeout, next_timeout = 0, last_recv; spin_lock(&session->frwd_lock); - if (session->state != ISCSI_STATE_LOGGED_IN) + if (READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) goto done; recv_timeout = conn->recv_timeout; @@ -2242,7 +2251,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) * If we are not logged in or we have started a new session * then let the host reset code handle this */ - if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN || + if (!session->leadconn || + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN || sc->SCp.phase != session->age) { spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); @@ -2375,7 +2385,8 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) * Just check if we are not logged in. We cannot check for * the phase because the reset could come from a ioctl. */ - if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) + if (!session->leadconn || + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) goto unlock; conn = session->leadconn; @@ -2434,8 +2445,8 @@ void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session) struct iscsi_session *session = cls_session->dd_data; spin_lock_bh(&session->frwd_lock); - if (session->state != ISCSI_STATE_LOGGED_IN) { - session->state = ISCSI_STATE_RECOVERY_FAILED; + if (READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) { + WRITE_ONCE(session->state, ISCSI_STATE_RECOVERY_FAILED); if (session->leadconn) wake_up(&session->leadconn->ehwait); } @@ -2461,19 +2472,15 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) conn = session->leadconn; mutex_lock(&session->eh_mutex); - spin_lock_bh(&session->frwd_lock); - if (session->state == ISCSI_STATE_TERMINATE) { + if (READ_ONCE(session->state) == ISCSI_STATE_TERMINATE) { failed: ISCSI_DBG_EH(session, "failing session reset: Could not log back into " "%s [age %d]\n", session->targetname, session->age); - spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); return FAILED; } - - spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); /* * we drop the lock here but the leadconn cannot be destoyed while @@ -2483,21 +2490,19 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "wait for relogin\n"); wait_event_interruptible(conn->ehwait, - session->state == ISCSI_STATE_TERMINATE || - session->state == ISCSI_STATE_LOGGED_IN || - session->state == ISCSI_STATE_RECOVERY_FAILED); + READ_ONCE(session->state) == ISCSI_STATE_TERMINATE || + READ_ONCE(session->state) == ISCSI_STATE_LOGGED_IN || + READ_ONCE(session->state) == ISCSI_STATE_RECOVERY_FAILED); if (signal_pending(current)) flush_signals(current); mutex_lock(&session->eh_mutex); - spin_lock_bh(&session->frwd_lock); - if (session->state == ISCSI_STATE_LOGGED_IN) { + if (READ_ONCE(session->state) == ISCSI_STATE_LOGGED_IN) { ISCSI_DBG_EH(session, "session reset succeeded for %s,%s\n", session->targetname, conn->persistent_address); } else goto failed; - spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); return SUCCESS; } @@ -2538,7 +2543,8 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc) * Just check if we are not logged in. We cannot check for * the phase because the reset could come from a ioctl. */ - if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) + if (!session->leadconn || + READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) goto unlock; conn = session->leadconn; @@ -2892,7 +2898,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session = cls_session->dd_data; session->cls_session = cls_session; session->host = shost; - session->state = ISCSI_STATE_FREE; + WRITE_ONCE(session->state, ISCSI_STATE_FREE); session->fast_abort = 1; session->tgt_reset_timeout = 30; session->lu_reset_timeout = 15; @@ -3070,7 +3076,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) /* * leading connection? then give up on recovery. */ - session->state = ISCSI_STATE_TERMINATE; + WRITE_ONCE(session->state, ISCSI_STATE_TERMINATE); wake_up(&conn->ehwait); } spin_unlock_bh(&session->frwd_lock); @@ -3130,7 +3136,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) spin_lock_bh(&session->frwd_lock); conn->c_stage = ISCSI_CONN_STARTED; - session->state = ISCSI_STATE_LOGGED_IN; + WRITE_ONCE(session->state, ISCSI_STATE_LOGGED_IN); session->queued_cmdsn = session->cmdsn; conn->last_recv = jiffies; @@ -3216,9 +3222,9 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, * the recovery state again */ if (flag == STOP_CONN_TERM) - session->state = ISCSI_STATE_TERMINATE; + WRITE_ONCE(session->state, ISCSI_STATE_TERMINATE); else if (conn->stop_stage != STOP_CONN_RECOVER) - session->state = ISCSI_STATE_IN_RECOVERY; + WRITE_ONCE(session->state, ISCSI_STATE_IN_RECOVERY); old_stop_stage = conn->stop_stage; conn->stop_stage = flag; diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 08c05403cd72..0a85b347297c 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -1436,7 +1436,8 @@ void qedi_start_conn_recovery(struct qedi_ctx *qedi, qedi_conn->abrt_conn = 1; QEDI_ERR(&qedi->dbg_ctx, "Failing connection, state=0x%x, cid=0x%x\n", - conn->session->state, qedi_conn->iscsi_conn_id); + READ_ONCE(conn->session->state), + qedi_conn->iscsi_conn_id); iscsi_conn_failure(qedi_conn->cls_conn->dd_data, ISCSI_ERR_CONN_FAILED); } diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 02f966e9358f..ddd4b9a809a1 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -328,15 +328,21 @@ struct iscsi_session { * can enclose the mutual exclusion zone protected by the backward lock * but not vice versa. */ - spinlock_t frwd_lock; /* protects session state, * - * cmdsn, queued_cmdsn * - * session resources: * + spinlock_t frwd_lock; /* protects queued_cmdsn, * + * cmdsn, suspend_bit, * + * leadconn, _stage, * + * tmf_state and session * + * resources: * * - cmdpool kfifo_out , * * - mgmtpool, queues */ spinlock_t back_lock; /* protects cmdsn_exp * * cmdsn_max, * * cmdpool kfifo_in */ - int state; /* session state */ + /* + * frwd_lock must be held when transitioning states, but not needed + * if just checking the state in the scsi-ml or iscsi callouts. + */ + int state; int age; /* counts session re-opens */ int scsi_cmds_max; /* max scsi commands */ From patchwork Sat Apr 3 23:22:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415242 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 87177C433B4 for ; Sat, 3 Apr 2021 23:24:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63E2C61360 for ; Sat, 3 Apr 2021 23:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236939AbhDCXYN (ORCPT ); Sat, 3 Apr 2021 19:24:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45066 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236894AbhDCXYI (ORCPT ); Sat, 3 Apr 2021 19:24:08 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NNrvp041494; Sat, 3 Apr 2021 23:23:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Xa93Ay03GcSgd2wpFs9Aa6h+jReE8oiSY496gDiXKEY=; b=njiEQ1or5Yv3YnxqsozTWgUKKFO7kSyM3+zor/hx5nRlPhDSNbj6nhicgWjG0eKQjQum K4PnlWWSat1t/mA5mTVOkQB8jAQ4tLqy1PWjQdCY74lZQCRmYygP/j1eu6Y/FZ26oy6c ON8L9jXDLAis/Xy9Vb9TrDYz2wB2v7kfeVoetaENZQeZxAD0w6fxVimUsvWDZdY0/D2P q3Svi6wOUmLbJk1dNJ3Ejj8vF4xcFX3qRJUoB7etSwXhig87OUQy5RYu4/14A9MVucdJ PidhAxTZLmjo/3WYjn6Y+SwHF9WfcIPF436lcAAdWPbO7gX5FZUBaAuf9g6WNvjEiEv6 ig== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 37pfsrrsh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:52 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJsFm132172; Sat, 3 Apr 2021 23:23:52 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by aserp3030.oracle.com with ESMTP id 37q1xk81gr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVxw7bVWBPssK5KtCnz4lYlnjYbR1wKAFuIC7W+fSUmNHseld1QjjfWUrmuURBW8S2axWyDc/rzgwk5LYOG/PgigFtHl8nlO6tTXDeW+/8LN3Sg2EduN+3H9Fct48Z/wWoSD8N/gjejpQCXBqhc8zroIuIX+PdOxdSqHZU/7eM3RsJKElI4FhehKETCqIfyvXUVlBeSIS76cEV2o7qEOQ7ftrVaDfc4xxqQmqK/HZJl/0Pg8YTNgezVuxVQ9SIAV4bRdCm0wdSgxKuRQXgNf2ZSdOmDvfl6QmRE5l9g/SEen79cuSXvtPDvT/JQJHJCUN+9MsaszoTMxZQ2I9k06Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xa93Ay03GcSgd2wpFs9Aa6h+jReE8oiSY496gDiXKEY=; b=jbt3+t3GZaaYvWp/bIWe8zl3Fdx8uI6e4Ec1KjFK2f1tuLacyIlr1ajh5NWIvQZfiWbZQ5vcAE1wxMbAWMK9IyN7FG7VgGSG3tUmJurE5EJiq/yA3YeOmk79d8pcFOzdAOsUCXHlZm0S+SL7CKquTMsvF9JdyjAd5S85s96Ryk2GhL0gI95mGD+myYJ/jrgqOA0L70dqVB4nNmh11q5IUMejzTnCoZL9sS55Js8Xx7djgNvgDAE/PEn/5LMZYDVevYnSSN72QnqSNm7hON8XNqWMF3y1mFKHkt7kDMrnnNz1X+a84SKbwVCFT8R92NsaAL29eCohjX4bDMa+59UJBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xa93Ay03GcSgd2wpFs9Aa6h+jReE8oiSY496gDiXKEY=; b=bzt1X2c0UHDzhZDCQHDWymZnQU+qXoAnVlf0zCqq6f10IJrcPACSv4x69e7QDvy1Vjniyasdmou88He2raiKZL+NH3YrnssLM0agvzX+JQ+usI9bm0Ej3APPfUnmXCK6RiQANhdWqs+CqZvECIFjg8piUvnYZHy5tHU5Vf/iizo= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:50 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:50 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 05/40] scsi: iscsi: add task prealloc/free callouts Date: Sat, 3 Apr 2021 18:22:58 -0500 Message-Id: <20210403232333.212927-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 803dab62-2241-4d9d-10ed-08d8f6f78a04 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iRv5NABftcVLmZAuTnqKtvTd/s+7VF0aP56T9kBkHLCA0KXWEfWgfjDX8xxYOTdvOWUdEBrdPboKVCtBb5uIUPyuyQzZNPDX7O7UxE2NkrmbFYTE0iVGSaa2I625JT7oGPFl1rjPODZfJ5gXpDMFO3QD6jmMJVvtI+30Jt0r2v8pC3AOgqLbByPsdPbKXZdDUqwjbKJZiMSXuZsWBVgV9WnKJwvaEU/mSYLb9+Qo5fUvdbM5kokI+CRwEX9481S0R+uNOnk/lDk2IweKh8B87Z5qNZv+B6VFNUlj6gXgBElvz2gwzvgfsLetQzDa7re/R0eCf4FipPfa6vJ4OLXNT+TyT56P5fD/Jjs8K3IJPWerCqZjO9o6YpkkAoy06AHKgKDFsWYnMhKbM31InjaZ8kpcZCswt5E0hGuZStoHUJyi7Bc9tOLrIe9m4Z8HaVB5IpWSUPO1C9du3+azA6Og2+iatlHRO8wCafyoXBR8aMxu4rSBevHtgQcgVrO04J99snFwNgcaqKZvZtuTk6EbhHIQFHhLhv5Qo7rAt/NqnZ4CqdXp1/329u9yB4CKoCg7647lKYAdzeg16z/3NDxzUA4fxlYU6n84fNt6RYj6uhXAWEPG4QOOyEMK+NjpRc6bCdaT/NC2qd4U0r4znsN5GOTG6iEZygJf8j+9dFrbXjQ1HCVmt+NyK4c7O8dVkUKWhyYicqCsnEyWYkrWoeGMMA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jR3j+Q6INu/SGXBvgTuLmJjoR+SY6gRJAcsa5xnPmkcFJ27yp3wiaZdPe/txLwS72Mq+OAECo5dBQkXnGI470B8Lre/TY453KYI1K/ZEMe5wdfpzHEogPdpEgegkFm2MGXuo0fRpBKeubf10Q+y3Yumq3Kpp3DA/8oFyktl5m4sWYWRtPUMcjnW9xWCntdc4WrkXlxsQbfEWlmWaoAI3RijYABevz9Xp+6ekh3+fv4dkfpfi6UJA9R7WhnpUiso+ZlAnVs9Eiv+FVOhARl4jLYOafX/98KAh+Y2540q9/gwCGM33t/HTjrQGUJ6Sgq0w3F2ogEpCHTudQXMzb/bSi3vbzx2VTWJoWpAKO4Vlu9D1Wc3IOu27iZM+tXlVFUMjPgC1vk84+stnDxChP+y4wj46CC/9mhBT7ZMJEFwYVAai1omv+JCuBYp9DsGlKvO+SqGrDyhoKGZqq16p+kDJRaGgDmDa2HOr2aIZFdVpzaO1YDLvnpaQN2xRDyrJxOvAy8GFZxYeGh20kG0MNtaroCtIf9GF5QDVAbsOIQbVEQy6niznkKNg+C421UUT62pIM9LcSk0TuMqS/HyNURScNsvPnH3XPE0WYwhBNTtofmm3Mpi0kiLCnr8HKtqppWjxm7OIKPL7eNtX+N3GdLZWEn5hCV2g5keyiB3TBEai6cYGrgbHMLT7Mv4a4zMYSUmFWRFrC9p6yMSv+JIogz0TvbYzR9XO5+N8tvwiH+D827srCa8JJpyn3un5ufokdCOAFcHoLPnj0B3+KVSKbF8N4YOjPH9Eccp/56pnOqbStpxmCZ9LH6IAilQt/WSnNE4fSi6Zwizw/qOuW8iPFRj18yF4ddV03o60ygQF2FEkmUBQRWMEvrO0bFX5Xk7IICVLa7bypbzATNXLD4MYh7j/lqf1YHsl1hQIpWEtYsh33yANf5E+jFdVawthjDqQA5xxJmy7jaEMC8I7SY+H2IupxKYlgbOyjn/PvIXXwKA2bDR3+wCk8cRBtKezhhGsueVjyID1V0CNc/Vd/nckTnEgztxEGXD0kPrFVMz7tV8QYu56np8DSH/MtNpg1iZDXYKV8p8ixDUWEc0A7U/KcDcFkGHA6k1/y/ZiFNhs+RlID3rYDl2af9ayffRe7W6l+cpbB3sbvqCR3GP3kvixZYzf6yZML2Txc/YH7aE8q/2fPP5GisRavniMQDwDW+qE0GrhCU8746I863XzsfCQJFUAtbib/1eN2OZr4uq/Fg/dXgmZGV/0TlG/3e/ZSVa6zeec92QwiNwH/Yc82PCQCXcKXbAcgAEYDG8ruUvqrUlzC0C5WBlnp+kJ5iPakw9u8oig X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 803dab62-2241-4d9d-10ed-08d8f6f78a04 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:50.7421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Oa7NVXoa8MHNHrP2o0L6Bke2rDjgoBMIDHzydxNG1g1ya294W5Hy1v+1HPwcfZhrTZUV0DuidmytMSwgJlD/tBY25Ak52aY8U6Jmo31Xwg0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: FhMJCb5r31G5dEL2Dcd3qRMm6x0wQWaV X-Proofpoint-GUID: FhMJCb5r31G5dEL2Dcd3qRMm6x0wQWaV X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Some drivers need to allocate resources with functions like dma_alloc* that can't be allocated with the iscsi_task struct. The next patches have the iscsi drivers use the block/scsi mq cmd allocators for scsi tasks and the drivers can use the init_cmd_priv callout to allocate these extra resource for scsi tasks there. For mgmt tasks, drivers can use the callouts added in this patch. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 21 +++++++++++++++++++-- include/scsi/scsi_transport_iscsi.h | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 7b83890aeb7a..926d33b2c9c7 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2931,10 +2931,15 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, task->itt = cmd_i; task->state = ISCSI_TASK_FREE; INIT_LIST_HEAD(&task->running); + + if (iscsit->alloc_task_priv) { + if (iscsit->alloc_task_priv(session, task)) + goto free_task_priv; + } } if (!try_module_get(iscsit->owner)) - goto module_get_fail; + goto free_task_priv; if (iscsi_add_session(cls_session, id)) goto cls_session_fail; @@ -2943,7 +2948,12 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, cls_session_fail: module_put(iscsit->owner); -module_get_fail: +free_task_priv: + for (cmd_i--; cmd_i >= 0; cmd_i--) { + if (iscsit->free_task_priv) + iscsit->free_task_priv(session, session->cmds[cmd_i]); + } + iscsi_pool_free(&session->cmdpool); cmdpool_alloc_fail: iscsi_free_session(cls_session); @@ -2962,6 +2972,13 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) struct iscsi_session *session = cls_session->dd_data; struct module *owner = cls_session->transport->owner; struct Scsi_Host *shost = session->host; + int cmd_i; + + for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { + if (session->tt->free_task_priv) + session->tt->free_task_priv(session, + session->cmds[cmd_i]); + } iscsi_pool_free(&session->cmdpool); diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 8a26a2ffa952..cdd358e20a97 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -22,6 +22,7 @@ struct Scsi_Host; struct scsi_cmnd; struct iscsi_cls_conn; struct iscsi_conn; +struct iscsi_session; struct iscsi_task; struct sockaddr; struct iscsi_iface; @@ -106,6 +107,10 @@ struct iscsi_transport { void (*get_stats) (struct iscsi_cls_conn *conn, struct iscsi_stats *stats); + int (*alloc_task_priv) (struct iscsi_session *session, + struct iscsi_task *task); + void (*free_task_priv) (struct iscsi_session *session, + struct iscsi_task *task); int (*init_task) (struct iscsi_task *task); int (*xmit_task) (struct iscsi_task *task); void (*cleanup_task) (struct iscsi_task *task); From patchwork Sat Apr 3 23:22:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415244 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 AF993C433B4 for ; Sat, 3 Apr 2021 23:24:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CDDE6135F for ; Sat, 3 Apr 2021 23:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236919AbhDCXYH (ORCPT ); Sat, 3 Apr 2021 19:24:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45054 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236894AbhDCXYH (ORCPT ); Sat, 3 Apr 2021 19:24:07 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NLVcU040082; Sat, 3 Apr 2021 23:23:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=5tP7zD9lOE7cHvC1wwrp0NHGNmfmUqOUhuu6zpc83Gs=; b=bjhCBCZlYDitA/uR/fOQNnikyJnDhXZlAj0lvadW84RzDOObgEpMv9fIqcEi3x1exaET f+rAXqitWS1PiYzvM29kLL35mhjMooGo074flsRUrtgb4Cqd/ZnFoqwCIZceQwt5GWnx kbbj3kpxsANNfb+QqfT8APLKYXXzXfW6jMUTJoviOj64C5LgddtWTqoWbZp7bCHWsBmR h2b+Deq0UfC+bEzXKhQNqeySSi5a7HBGM8Q74b+e12RrIBkcyIep7U7QHX4qw6dJ/csS YNh3uVYL1kxGkkUoV9j86M2A6NGCao5JNYmwuUZQxr1rYT61wEcJDPNUNGttV5aY+Qll 6A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37pfsrrsh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:55 +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 133NKtAb116931; Sat, 3 Apr 2021 23:23:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by userp3020.oracle.com with ESMTP id 37pfpkbskt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzAkDSklXUH9H5IH3JB9MI6Vw4Kb/rV9p2qTiKJfRSuwz33tEJwWvEMmP8znkpoRMElXKj/0sEvavs60Ijj+oVxmeNGTeRXUWMGrRzi54//9BrwmU+8U0RZ+sP9ru0MSl6hhP4AKrPHG+likR5C0zug4LfCX7xs6DqDwfZSi5QNOYjGuvbZbUi5JpBRrQaDFJE/hp9LimRjBkpxtlDW1eRSu5kXkHGOJFtHjBrDfrcdC9SzTFCnxuaTMnlU3yiac8AicnXVZjqnFXGmQZaDuuCJ2CTdIPJqB3lAV+MDiKWZ7il+1iqMqFEwQqOGHcFHTpOqDsmxGOMlYC3otxY78nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5tP7zD9lOE7cHvC1wwrp0NHGNmfmUqOUhuu6zpc83Gs=; b=T9nfFoeElcSSHxa+1D49t598UrJqkkB7QL5oflYip6mmpMAGncGkSXibgSS28Xr+AnzgQjO2GH2gWDptDgOTM+uJyedaJf2l7vaMakoLE8itGfmj9ge3mCHM3PSXBc43E+9tayhaKZV9bfQErHCZipDGguF3a85Nxy6bORvgu7usHP5wEBhLyTGB4n2c1MimPBT9iEyzfnGnWmv8kl53uA7LjvBFJAxXyD3jbKn4eNawthEAWZXcQnWa5Y4wW/YpKdTeBILaVBymsKwx4rzYzGkmOgN0HTFgERIpLgsB3hrXFm+pMO0Q+Ka8lTpsE206nODj/o1DKU17/mbfMSxsaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5tP7zD9lOE7cHvC1wwrp0NHGNmfmUqOUhuu6zpc83Gs=; b=KdxSDI22bFtXpOvg67ub+CnhmItYzbJdnIT7kGE/ADrgs0veBEyLflZa7dD5v5Elqg6pVLng0Ge2H0AIpfUwWE9MrulQ7OrcdsaLIjx3bslScBLCiZf2xvj90DvrBQU0TASXM/mJySzMZK5P1le3cTJq6JkZRF9MgA5KN95SYGA= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:52 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:52 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 06/40] scsi: qedi: implement alloc_task_priv/free_task_priv Date: Sat, 3 Apr 2021 18:22:59 -0500 Message-Id: <20210403232333.212927-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b3beca4-f4e7-4553-4e23-08d8f6f78ac3 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6JjBfCe7VDIb1HAtV1Cm6s/iRAAOEjZ19ZB/Nz0e6J6JWD5Ty0nByyFG1pRui4cmV4d5oXJ811GWT+EJ22c4ruFPExvcxaJtuKc2uzM9xv9yTMb8bPP1ZdGd3u0hKC3WH95/q4qy71p8y4XTv/fDwaWUVCLSCgvHaRNqOna4QUiN1SpMRkNw/vkrh2UQ7Ti3FJTIHEJg5mQkXm2E/mYayTN/sJUXa1UWUjX+jgW+9OIGFnqnesOxlpJtDWjeql26Wn7CDnGLBR/uCB86obJbXfVP8xb+4nELiaNdS/xZh+i1m2ctXEY4GbErkWAxJbhZfXG9stA28gZZMS2dcwj5bW5sw6vdmy/yPnn9mMUTyPgKAdffGqHpRYob6frWQLAqrtMUukwq6nV8MNq2lNqWn+Ia4qCjNJk2zG6U6ob7Xhjuv1i01opLvcUlLVB9+iHL+DsRztwd7ZEksj6k/k1FgcgKo6Ds9PwqOJvbMA4BFL7xvgsgWfudjKg96ZRQdz69a6uDvJ1iTCbk/vmozBQgEv8ETRNzPQdKOE5+Sc3e1TUdBbpbfJqnRr2VDQjo7dztQjdWpshLgNk8KcaeAjjuhkMfXhf+H3frf3ZNbVisZN4OOIVlQ/CLuCyDPRuymCQAoRRx9GeoYUgjs83W0MncXSmq7At8wnI2wpUyAJt2iBVpXtptwS2ARzkEK4ttEz/SwcZ0hGY0BXJGJZcykpcAZw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: K4us9ks9U7bNRmbHHnl4NZgbRSq73RRj5gsQuJZsnPbKUgYiZ1mNEj8aVz3EaJ+xfgKhMn/fRShO6k+QuK/ZjP4Te+iIWYRO6WVuxiZSi/1PQ6BE1/cigIThmJET4ILWmsiPzrNdfDJnCfWbgz8squhRJJmuR5eEg1DFgaX8zqXuKek0+rPqt/jmOQYboI3QKCixXtB9WN7RgfmnNqQ0F/HlDZsOTulHxrUFVMY4kVU9qRY2FHq3z5svkuv3efu2b/F7YNZqJVaRybGDlAOOfI7UmwZdMm+e08RROlG3VyPVU+LKcLUaNJtUShKh/A+ErzyRktZ/p0DQ+/je0+DIdY1rwjNZprIVOPS7gG5V/Obcng3MIF8LgcDz6jUviUVihJz33wnz0kwSEortQNdlCe3YUIlXjLv9vf9Ves4QesI0twt4OR++pKn29fMBQQyu2JGweB+YyI83alse4gTwTyIgFJRy6j1jjpXDc89f40kFP1Xga/VvoOJF8bp9GhppMGzb07xW+Ju3zXVTBe0pQa6khi1vc1/vyKwIEzFuuQGownco0AmgMUplvc143szX8wjaFRAGSYKPE/8Jqx9SB6U+1sRKL7H+MeRl5q9G9UgnT3JGps8XbzGSIinwzmO3T4pcaUfqhy3xM2GDMXP+SX8/JjZ1gKsSoG5rGkGxQCdq/tLHhl+NVeYvI2TZav1Sv9qptbdZTrYwQbplXsmLUNsDY6HORez4990UMIJ98f4GfsW0AKG5clEO9CzGrzl63RPQGBdj6xx36Gc/B7AtC/r9a2dB7LJN+iV3SRwB/gFxCwrPea/nAAUijqaD3BeVKchpogqyEQ2+9Pzo9Wk/fFrjrF26acgaNCYWFCzw3TvzlaLTjYBu6wPW/cowl/D/Uck/JDaym6s2RrEqc9FzAJQE5rrmxdwHQIyXi7oZ3wC3H7qrYWtRyfSPhjAt7Xa/bUELtveV7EtX//E1JXhXKvmL69qj03CTJgpwipl1drhCYVyWNQB/A6ZHjP+oGn9maefNZ+lGrnRgAoyCc6IMJpL1xAe5HtVzxph2kUS/0//rcxBO14JLqzEEloHEQtSaETx4HHbmU1GFBdcRY+WvF4Frr/vWB+S/Z00xvkSjnzVUZhxUTqZ5F0T2hLaMBvE65wSGZ7NiHxvLMBYwORB+xQpxgDSYGdcCFKuG4amt1o9ejYRdTATRo93XdMpY/4H9ARzTyiDs8QMerXz3u0fBxO1JmcduJEtLl6nEcTpYRRbFMRWCHO4gJMiT+ID2E8cOX9IeeAS0/v17x4TJNVAt01DHYlu9Tm9KTLS+s6Jhd44uZ11Zya1Kttq33Secegql X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b3beca4-f4e7-4553-4e23-08d8f6f78ac3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:52.0494 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rUjRYli5uNsDcmvLLHxbitdtpw9miEeyb8P8b3zM/Hc5lG9Wj3kREBrcpfzi9sKByW2hUj2pHUdKuV5FCiy3F43q1Se4rSeJjUUKdfnKI3w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: 6c-J_sEGp7OW3VmoU1vCKE5afOESgADX X-Proofpoint-GUID: 6c-J_sEGp7OW3VmoU1vCKE5afOESgADX X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have qedi use the alloc_task_priv/free_task_priv instead of rolling its own loops. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_iscsi.c | 106 +++++++++++++-------------------- 1 file changed, 41 insertions(+), 65 deletions(-) diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 0a85b347297c..54c1d0a2484c 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -160,32 +160,30 @@ static int qedi_conn_alloc_login_resources(struct qedi_ctx *qedi, return -ENOMEM; } -static void qedi_destroy_cmd_pool(struct qedi_ctx *qedi, - struct iscsi_session *session) +static void qedi_free_sget(struct qedi_ctx *qedi, struct qedi_cmd *cmd) { - int i; + if (!cmd->io_tbl.sge_tbl) + return; - for (i = 0; i < session->cmds_max; i++) { - struct iscsi_task *task = session->cmds[i]; - struct qedi_cmd *cmd = task->dd_data; - - if (cmd->io_tbl.sge_tbl) - dma_free_coherent(&qedi->pdev->dev, - QEDI_ISCSI_MAX_BDS_PER_CMD * - sizeof(struct scsi_sge), - cmd->io_tbl.sge_tbl, - cmd->io_tbl.sge_tbl_dma); - - if (cmd->sense_buffer) - dma_free_coherent(&qedi->pdev->dev, - SCSI_SENSE_BUFFERSIZE, - cmd->sense_buffer, - cmd->sense_buffer_dma); - } + dma_free_coherent(&qedi->pdev->dev, + QEDI_ISCSI_MAX_BDS_PER_CMD * sizeof(struct scsi_sge), + cmd->io_tbl.sge_tbl, cmd->io_tbl.sge_tbl_dma); } -static int qedi_alloc_sget(struct qedi_ctx *qedi, struct iscsi_session *session, - struct qedi_cmd *cmd) +static void qedi_free_task_priv(struct iscsi_session *session, + struct iscsi_task *task) +{ + struct qedi_ctx *qedi = iscsi_host_priv(session->host); + struct qedi_cmd *cmd = task->dd_data; + + qedi_free_sget(qedi, cmd); + + if (cmd->sense_buffer) + dma_free_coherent(&qedi->pdev->dev, SCSI_SENSE_BUFFERSIZE, + cmd->sense_buffer, cmd->sense_buffer_dma); +} + +static int qedi_alloc_sget(struct qedi_ctx *qedi, struct qedi_cmd *cmd) { struct qedi_io_bdt *io = &cmd->io_tbl; struct scsi_sge *sge; @@ -195,8 +193,8 @@ static int qedi_alloc_sget(struct qedi_ctx *qedi, struct iscsi_session *session, sizeof(*sge), &io->sge_tbl_dma, GFP_KERNEL); if (!io->sge_tbl) { - iscsi_session_printk(KERN_ERR, session, - "Could not allocate BD table.\n"); + shost_printk(KERN_ERR, qedi->shost, + "Could not allocate BD table.\n"); return -ENOMEM; } @@ -204,33 +202,29 @@ static int qedi_alloc_sget(struct qedi_ctx *qedi, struct iscsi_session *session, return 0; } -static int qedi_setup_cmd_pool(struct qedi_ctx *qedi, - struct iscsi_session *session) +static int qedi_alloc_task_priv(struct iscsi_session *session, + struct iscsi_task *task) { - int i; + struct qedi_ctx *qedi = iscsi_host_priv(session->host); + struct qedi_cmd *cmd = task->dd_data; - for (i = 0; i < session->cmds_max; i++) { - struct iscsi_task *task = session->cmds[i]; - struct qedi_cmd *cmd = task->dd_data; + task->hdr = &cmd->hdr; + task->hdr_max = sizeof(struct iscsi_hdr); - task->hdr = &cmd->hdr; - task->hdr_max = sizeof(struct iscsi_hdr); + if (qedi_alloc_sget(qedi, cmd)) + return -ENOMEM; - if (qedi_alloc_sget(qedi, session, cmd)) - goto free_sgets; - - cmd->sense_buffer = dma_alloc_coherent(&qedi->pdev->dev, - SCSI_SENSE_BUFFERSIZE, - &cmd->sense_buffer_dma, - GFP_KERNEL); - if (!cmd->sense_buffer) - goto free_sgets; - } + cmd->sense_buffer = dma_alloc_coherent(&qedi->pdev->dev, + SCSI_SENSE_BUFFERSIZE, + &cmd->sense_buffer_dma, + GFP_KERNEL); + if (!cmd->sense_buffer) + goto free_sgets; return 0; free_sgets: - qedi_destroy_cmd_pool(qedi, session); + qedi_free_sget(qedi, cmd); return -ENOMEM; } @@ -264,27 +258,7 @@ qedi_session_create(struct iscsi_endpoint *ep, u16 cmds_max, return NULL; } - if (qedi_setup_cmd_pool(qedi, cls_session->dd_data)) { - QEDI_ERR(&qedi->dbg_ctx, - "Failed to setup cmd pool for ep=%p\n", qedi_ep); - goto session_teardown; - } - return cls_session; - -session_teardown: - iscsi_session_teardown(cls_session); - return NULL; -} - -static void qedi_session_destroy(struct iscsi_cls_session *cls_session) -{ - struct iscsi_session *session = cls_session->dd_data; - struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); - struct qedi_ctx *qedi = iscsi_host_priv(shost); - - qedi_destroy_cmd_pool(qedi, session); - iscsi_session_teardown(cls_session); } static struct iscsi_cls_conn * @@ -1398,7 +1372,7 @@ struct iscsi_transport qedi_iscsi_transport = { .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD | CAP_TEXT_NEGO, .create_session = qedi_session_create, - .destroy_session = qedi_session_destroy, + .destroy_session = iscsi_session_teardown, .create_conn = qedi_conn_create, .bind_conn = qedi_conn_bind, .start_conn = qedi_conn_start, @@ -1410,6 +1384,8 @@ struct iscsi_transport qedi_iscsi_transport = { .get_session_param = iscsi_session_get_param, .get_host_param = qedi_host_get_param, .send_pdu = iscsi_conn_send_pdu, + .alloc_task_priv = qedi_alloc_task_priv, + .free_task_priv = qedi_free_task_priv, .get_stats = qedi_conn_get_stats, .xmit_task = qedi_task_xmit, .cleanup_task = qedi_cleanup_task, @@ -1626,7 +1602,7 @@ void qedi_clear_session_ctx(struct iscsi_cls_session *cls_sess) qedi_conn_destroy(qedi_conn->cls_conn); - qedi_session_destroy(cls_sess); + iscsi_session_teardown(cls_sess); } void qedi_process_tcp_error(struct qedi_endpoint *ep, From patchwork Sat Apr 3 23:23:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415112 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 B0692C433ED for ; Sat, 3 Apr 2021 23:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A5BB61360 for ; Sat, 3 Apr 2021 23:24:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236925AbhDCXYL (ORCPT ); Sat, 3 Apr 2021 19:24:11 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49682 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236621AbhDCXYH (ORCPT ); Sat, 3 Apr 2021 19:24:07 -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 133NNuIC162515; Sat, 3 Apr 2021 23:23:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=rVE/f87u/MaZp4+kZPvkJQPJXH8XAAieEt+pvEUXr4g=; b=DmgvVhmPAFStaeVusFZUh6B6EqC7njPTLZ2NrI8Oh3zoVUQzKrzWw5g2HIHqF/aENzYx 8SpVvlRM2lUoUfuQDKZ6dV4o0HZS0ww/za/ig0qWkflUX9AuffGpyzTOljxERzpHV2g3 XF3m6hnSGYqPw3XPOM3+nTDQrAKSzqV32qC65gT7OhcnKKLPubUSWgwofO8oEb++GHmC eQRAWpg/it+/Byj12WKCe+3jgfSSUtx7cq0BXsz0dj5rGORQ2jkSd1ctrYShQ/2VdqKH RtBGxEs4AAvrC0hkab7jDV24zXjX1eMi0dhFikHB5yfIUwqOZ9F+3aJO/0hp0RJeKuIF cQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:56 +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 133NKtAc116931; Sat, 3 Apr 2021 23:23:55 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by userp3020.oracle.com with ESMTP id 37pfpkbskt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVjtTaHwBggV1uOQGcsIMWJmuM3c6Pisp5XLKaJalB+IcVj4thBE4AljEZe01/0hlRDaCoO8WS64hCLuiAYYYcHP8X5bRXnufXxpNtShhw04FaKDPtnHz0Wcd7V6x+Q0ZLcpd6wrPhK8NSfETs7CHNTMaJL9g0M/Af6Ub2Rjx+HyxQzRdDhdFUKz28FZVUiXagMEwixGxkCPLUBbgZ/IZZ8Vd8opysuNmo9rkhkdtk0VzhqhSguEJMIiaiF+5UFnc+D8kFzmT4noh8nRQPOFGK6sGKtMrDduj+crJ0gFODKbJIKg9OOrfuuelXtOWCOaSUpL+o48VfSoSQwvGpFFqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rVE/f87u/MaZp4+kZPvkJQPJXH8XAAieEt+pvEUXr4g=; b=QVo3XN8O9IHGEtDcuhAU0MGHhU1Fwpcjfbv7MFFh8Q7Y41er919cdo1UJZ/HfOhhij6V8tbuYETqv9YJk6/8x6uaEg+12pETLRKnno+6+l5csSMrRsq2bETmMEEzSjdkUgP8/2WumGtw0yUhJUnqgHgCZUpLVO2QqG2ceEac+HG6CE3/GKRRPSV2HlEzMDlg+lywHNB0ArvB+KsoMTOeA+Fo3uRe86BWQfa1dnqEqhUcPZuVnFdQzin3+91i7gzYAs6wM18G2G95S5MCqKPZqtQNwyyLICmZFWzSFyo6S9BwFyXiUFIl8k48a/ZuIcXhb2GIesARxe+/VYhhzEHREA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rVE/f87u/MaZp4+kZPvkJQPJXH8XAAieEt+pvEUXr4g=; b=aVSr9p8KelpRbN7URU1i5tA9cVQk1UdmtC+cglG4Fdz2DB2XEqg/h0H013BDW0x+UC+ulGm4LTghjMHz6S09VSEXCkNYtQhkLaHxPLQJBo/IkUI2JohpVbLxq9CYMtiLQ38BacIzFbo9c364xKJN5iKftWuCkhGJ/UmXD7iSDPM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:53 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:53 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 07/40] scsi: bnx2i: implement alloc_task_priv/free_task_priv Date: Sat, 3 Apr 2021 18:23:00 -0500 Message-Id: <20210403232333.212927-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 562f06ca-76d1-48c5-6ca3-08d8f6f78b87 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CNU/QummFQvZs1urzYMQpXvXJqBD2UjkzRZiUBWSvngpm8g1dA/FozmMHONuJakbbUbMFuVPuwUOf+OcewRrzOLOiFgC1H8acXeMD6yiCKXO4DLLsCoLe8HrzhTkwI1qfWxAVFOoLClSg/3sorE9puOd7WIn/y3rPLvqhQ1FP7KZEQHqAaXwWvOXfEnlBZ/ho621WgY5Q8eRUJRIr8Eqa6QM5Azm3X2umtFHVGymbFwF9BAyYOp/Dp0mxdmxafZKuvztcujXstb2YtSrQK2/+MnmCM5k9QGH40YGhQFZZ4gfrishZc/QvaUsTuXg0yp77F4Hpl4QhOvWUDr881WLfkxr4UrlYe8OGXguwziWL5cVBdpOU8JCQgz/8d5GUvsbdEham4bUEEZhRJ8k7rpc/x7owTnxQzXHWSnb5QKqHWFGWiuBC09cqrpO2sEkYOvrWxuHI64KXDszmG5vv6f6nhCQzR4NH/++mLwFPqbHCZj0kSasj7dlYxt5mIJvkJCywybNvi/FK6te+VpoYDEpGg6s9IKADfTkVyBWP9LSJoBan24F8vlbilXHdlCDuyIToa8pwCH4vwYKCpsU4xynfzUHnM5MTyMzcZ/UI1Yl3ZBzBsjxW4cHFSBooZIOHdVhDW5V5LOBfPX4DphzLNqS/88hHCqDp8Uh8fVHTJHCvEfjtBSuA49LkwoOIyN3Jr7nrzJO6DzPGv3tpeiOQuLOuQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6LHSW6mRBQ4IyunTro+6IIpA0g/Y4dl0kV8ioe6C6quJ1qM2jQGyF2ELCVcaIOXsikTo1alzUVCKTIdjiKbSt7fpOsm7AsVdn6I/jdhNCxtBtWbXxqkvZJ5FNqPx1MkolYcnZB8lpoSQk4yRXdLehqhb2TyJ+MVV23Ma+/cb8wzSMUoy7IWaRiF6GAPbXEYTAR7kDB/mzR+VBkxig0YuRKyWyReQKfW0FV/MSbzoFWqpUOnzNFkxSiz5SJIG9TSCqTlJj0BBopAnTO8qs78EJSAasMbTzVfCsijk6yr7NGfEn14C17vnQpGaR4zr1lOz3Cbi0x1kccnXVIONOA7MfRWPASM+2JZYyHORv5baMyZxxtokIKXi05E5DDwnMdCbUzrUG3gbqvGRkeyl5ncUdpnTE0/VN1KYkjeB14m/hoI6L7SrW9Zu6IHwqKR6fSWnNDpRnSJdbUCm2z1AyjsgIQjDB+/n14JX7VlS3oRp3pR7eH6Hgry++ktTV7N6Q7TszBcO7weQ8zhFNun1eD3Vra2/fS4TwPB+PKqhmt1TwFXE4FcrBnIBMf2aLn2khQ/x7vqmQsbQ9C1FzUh6WSwm26XA3gA/vV1yfO78Fn6I5eXWVHuNq2C8XO0oXT2B6EZf2wOBqYc+rtKRhh6Dum/SY6gEk+8XprgESydco+YQTFmITSMYDZCQqWgbG7Vjq8ulCvgHhaQuPqDcucqP6mpR7OvhwtyQs6BF+Zw0hOVy/kOHYFc7rFtVt+p3O0T0BMyxiAzvHRcaBXoLH6wxre+RG/mWGgCjc21lKXckoyWVXkjFtFyTlzAIk+DrRO+TteN4iyxbHXiA7hn16Y7XDwAYW54ul8DOYOLH/aIcadIpUHIgEAUCLHTh2oxButnxuv1TXc6ptC6xJIX2Q+VA8qM328NgkIUH4VecboFg0nK33OOluo8sbUiVjR0dHRgbLTUXnVAEhOntO5TCsA/zMmt8biIp8DEmEP+33TVX3Wpg3ia9rC9CgK/wNrqT1IIMVFZsxig6f2AZyMasIDCnLMvp1WLmIdJxX7xFZ0k+6UqcppGd/hMdACiYJ26FyxJajbkc0RWfZPxfhaPGl4n75wItRK7I0cSJHEHMLhD3hB81SSoL4Dif+dvburcmkih2KG5pz3goav014W7QJO1t9bmvPaHyDGSPwUodhuvWsMYPmY7TnfCFdf/nzVVVVIdJPxm/R82+0DMQ+dW0FtKX20rL4cyCQEG6T+QpHlnujt4nTWyY64egfeaWjVb3VXsHh1jCvUBSBHoBT3zS/M8sAHLRnadyqIo41wwWR112u81dvTF02BJ6Pyz3ShAn4jlMDTCm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 562f06ca-76d1-48c5-6ca3-08d8f6f78b87 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:53.3896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2Q+srCcUK0gdKPRvsyoWHJRPW3Z6rTm3JPn7UoyaRvb4D/JNNko1syjRPNZ6RSvvb7oEPUpVoxgPcYvR4m5KjpgGf85SEorzL1xvMdIE3sc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: kfar7xrhTvhmEWH4lWpU5AHCSP5zkkiz X-Proofpoint-GUID: kfar7xrhTvhmEWH4lWpU5AHCSP5zkkiz X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have bnx2i use the alloc_task_priv/free_task_priv instead of rolling its own loops. Signed-off-by: Mike Christie --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 107 +++++++------------------------ 1 file changed, 24 insertions(+), 83 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 48809fc8f095..ce98112799ed 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -438,11 +438,9 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep) /** * bnx2i_alloc_bdt - allocates buffer descriptor (BD) table for the command * @hba: adapter instance pointer - * @session: iscsi session pointer * @cmd: iscsi command structure */ -static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct iscsi_session *session, - struct bnx2i_cmd *cmd) +static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd) { struct io_bdt *io = &cmd->io_tbl; struct iscsi_bd *bd; @@ -451,68 +449,39 @@ static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct iscsi_session *session, ISCSI_MAX_BDS_PER_CMD * sizeof(*bd), &io->bd_tbl_dma, GFP_KERNEL); if (!io->bd_tbl) { - iscsi_session_printk(KERN_ERR, session, "Could not " - "allocate bdt.\n"); + shost_printk(KERN_ERR, hba->shost, "Could not allocate bdt.\n"); return -ENOMEM; } io->bd_valid = 0; return 0; } -/** - * bnx2i_destroy_cmd_pool - destroys iscsi command pool and release BD table - * @hba: adapter instance pointer - * @session: iscsi session pointer - */ -static void bnx2i_destroy_cmd_pool(struct bnx2i_hba *hba, - struct iscsi_session *session) +static void bnx2i_free_task_priv(struct iscsi_session *session, + struct iscsi_task *task) { - int i; - - for (i = 0; i < session->cmds_max; i++) { - struct iscsi_task *task = session->cmds[i]; - struct bnx2i_cmd *cmd = task->dd_data; + struct bnx2i_hba *hba = iscsi_host_priv(session->host); + struct bnx2i_cmd *cmd = task->dd_data; - if (cmd->io_tbl.bd_tbl) - dma_free_coherent(&hba->pcidev->dev, - ISCSI_MAX_BDS_PER_CMD * - sizeof(struct iscsi_bd), - cmd->io_tbl.bd_tbl, - cmd->io_tbl.bd_tbl_dma); - } + if (!cmd->io_tbl.bd_tbl) + return; + dma_free_coherent(&hba->pcidev->dev, + ISCSI_MAX_BDS_PER_CMD * sizeof(struct iscsi_bd), + cmd->io_tbl.bd_tbl, cmd->io_tbl.bd_tbl_dma); } - -/** - * bnx2i_setup_cmd_pool - sets up iscsi command pool for the session - * @hba: adapter instance pointer - * @session: iscsi session pointer - */ -static int bnx2i_setup_cmd_pool(struct bnx2i_hba *hba, - struct iscsi_session *session) +static int bnx2i_alloc_task_priv(struct iscsi_session *session, + struct iscsi_task *task) { - int i; - - for (i = 0; i < session->cmds_max; i++) { - struct iscsi_task *task = session->cmds[i]; - struct bnx2i_cmd *cmd = task->dd_data; - - task->hdr = &cmd->hdr; - task->hdr_max = sizeof(struct iscsi_hdr); - - if (bnx2i_alloc_bdt(hba, session, cmd)) - goto free_bdts; - } + struct bnx2i_hba *hba = iscsi_host_priv(session->host); + struct bnx2i_cmd *cmd = task->dd_data; - return 0; + task->hdr = &cmd->hdr; + task->hdr_max = sizeof(struct iscsi_hdr); -free_bdts: - bnx2i_destroy_cmd_pool(hba, session); - return -ENOMEM; + return bnx2i_alloc_bdt(hba, cmd); } - /** * bnx2i_setup_mp_bdt - allocate BD table resources * @hba: pointer to adapter structure @@ -1286,7 +1255,6 @@ bnx2i_session_create(struct iscsi_endpoint *ep, uint32_t initial_cmdsn) { struct Scsi_Host *shost; - struct iscsi_cls_session *cls_session; struct bnx2i_hba *hba; struct bnx2i_endpoint *bnx2i_ep; @@ -1310,40 +1278,11 @@ bnx2i_session_create(struct iscsi_endpoint *ep, else if (cmds_max < BNX2I_SQ_WQES_MIN) cmds_max = BNX2I_SQ_WQES_MIN; - cls_session = iscsi_session_setup(&bnx2i_iscsi_transport, shost, - cmds_max, 0, sizeof(struct bnx2i_cmd), - initial_cmdsn, ISCSI_MAX_TARGET); - if (!cls_session) - return NULL; - - if (bnx2i_setup_cmd_pool(hba, cls_session->dd_data)) - goto session_teardown; - return cls_session; - -session_teardown: - iscsi_session_teardown(cls_session); - return NULL; -} - - -/** - * bnx2i_session_destroy - destroys iscsi session - * @cls_session: pointer to iscsi cls session - * - * Destroys previously created iSCSI session instance and releases - * all resources held by it - */ -static void bnx2i_session_destroy(struct iscsi_cls_session *cls_session) -{ - struct iscsi_session *session = cls_session->dd_data; - struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); - struct bnx2i_hba *hba = iscsi_host_priv(shost); - - bnx2i_destroy_cmd_pool(hba, session); - iscsi_session_teardown(cls_session); + return iscsi_session_setup(&bnx2i_iscsi_transport, shost, + cmds_max, 0, sizeof(struct bnx2i_cmd), + initial_cmdsn, ISCSI_MAX_TARGET); } - /** * bnx2i_conn_create - create iscsi connection instance * @cls_session: pointer to iscsi cls session @@ -2274,7 +2213,7 @@ struct iscsi_transport bnx2i_iscsi_transport = { CAP_DATA_PATH_OFFLOAD | CAP_TEXT_NEGO, .create_session = bnx2i_session_create, - .destroy_session = bnx2i_session_destroy, + .destroy_session = iscsi_session_teardown, .create_conn = bnx2i_conn_create, .bind_conn = bnx2i_conn_bind, .destroy_conn = bnx2i_conn_destroy, @@ -2286,6 +2225,8 @@ struct iscsi_transport bnx2i_iscsi_transport = { .start_conn = bnx2i_conn_start, .stop_conn = iscsi_conn_stop, .send_pdu = iscsi_conn_send_pdu, + .alloc_task_priv = bnx2i_alloc_task_priv, + .free_task_priv = bnx2i_free_task_priv, .xmit_task = bnx2i_task_xmit, .get_stats = bnx2i_conn_get_stats, /* TCP connect - disconnect - option-2 interface calls */ From patchwork Sat Apr 3 23:23:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415240 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 6DDADC433ED for ; Sat, 3 Apr 2021 23:24:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 433B16135F for ; Sat, 3 Apr 2021 23:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236955AbhDCXYR (ORCPT ); Sat, 3 Apr 2021 19:24:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45260 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236752AbhDCXYL (ORCPT ); Sat, 3 Apr 2021 19:24:11 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJdJU038996; Sat, 3 Apr 2021 23:23:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=5sLtsUnPIHnwcvm8n80YNvEmn2MlZZ49l8TRIRFS66M=; b=bkkepWSIlEIEYaN87cdMWOFuCk46fs2gRX10g8rN8masmkbJYjN6yq9XtZVWE7iwutd1 na9nc/tnzA1uqlm7V5HhpfUHdskuX8363j4ZJf/+QHUO8szx0gGEdl0oB6A3uQ7FakhK CsodBxkv9vw3nlz1c5hSOUM+Qk37gL1Wf3/TUQkld4vbsuu6nkuFI3kTNUPwI0g6eKHw BmiYdxxwyT7A4gTDI1i8ONSyUYhBPdQ8ZK0R+pX/JmA/VhXJRl3+lqNbcJrGPWIv6CN8 4IXmb49DZav9uqbNy1xz6PIRckvLkIquyKEGXOxJ4jElsfPE08+AiEprbsyaxZ7QgYji 9A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 37pfsrrsh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJrET132118; Sat, 3 Apr 2021 23:23:57 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by aserp3030.oracle.com with ESMTP id 37q1xk81j5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aq0tVDHEzVKasLN4QS5UoyY6BGNxo5hBVmzMMGTiRsHY1PlA3PUnX0KhZardRRNJT3cYb7Di6GatfRpyBr8GE/JbaQbnBGclLreR8mOUuQNWyUrWKtJZ2Hlziwu1Nv7ZQBAALaFDfCUUWmX6bpBFvX51S4fjBppr6UTxEUdD1PniNYL2DeZNFmis12kFMPC1setps97VP2307Wk3BNhe4gJQ0YIwPWdfsMNSG761DX5cwKsQZQdk5Y4Kg//K+Z5lPDo+ZM/HHTlnqV9N0GN/Lq7uPhi858hFtM85UXraVuCS/QwqhtSzWeOz5ALgo9DJrrP46kFZCzMzU1FLleNdhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5sLtsUnPIHnwcvm8n80YNvEmn2MlZZ49l8TRIRFS66M=; b=gWicBlvv5m9OcKOVNwqkwX65Ljz3KmzdxTQENxMwI2jwzDsByej0jwR4LFy1D8X0eQ3R4g23+m2rdpTZQInip1oX8rmS695LATEZ95AHITeMRasnRul5l0evw2zS4BirZ68aVhV1vPRA8TAQDOZBmz6UgoqSiS2Hs2RW0hDQbOg/fW2T9NEAfR91qKOKS2/bn25brLK0g4fHYTunMW9CapVIjWBZKTLbNl3DKleqlLuZat2MoIy6sneSMwYOosiPa3iQy5VsCqOn41f7A3NjLdhjAMwX0XKKGcoZVjw+VGwHmf6U2skAti98oLmWEuibS2vKISQn5duy3p3rHZrkDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5sLtsUnPIHnwcvm8n80YNvEmn2MlZZ49l8TRIRFS66M=; b=DMDnUe7uQHeY3VKRYgCV5Xs6x7YKx/OcvkCauRJSRen3Vilo+zZmS4pc6ClaW99KtrIZ1PzX+6YSccogtBdI/4qx4Admhf1DAjuxOpTxqSwWoarNivqCs6AXsg6xFJ8DzW0h7+G7hxUAY/GnTesA9rJOBhrjE7xm0Tj4i6rmdqM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:55 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:54 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 08/40] scsi: iser, be2iscsi, qla4xxx: set scsi_host_template cmd_size Date: Sat, 3 Apr 2021 18:23:01 -0500 Message-Id: <20210403232333.212927-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e13ea49b-8bcb-4050-bdc5-08d8f6f78c60 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v3MZMDbQmhfs6jLayu7gPjHngr0fcDWdLwQJQ6DzJ5NnKdyYxtzPoBP1iZu43RCnrGjJgnjwIcS2dOxj7YcEHYnIaOnnc1+vbil7/M3cIXLJ7UdbUbZIJ2tyzganbOjfscUb8gtBGAfSYuZtULSBlCCHmNMCzw2Pg/yMxzxlnY8X3xbUkTpy3TclEEVshci5kTjw2lpKU1oKmYU001ZsNhJIOHAdpGeMG2vy3mCOEyRLFk55gvAAFgZieiFmpw1sHgBgQSzIiyo7wtEtIHYEfA/T/zLGiLJ4MfRH8X/AYuGbuEFd+PIavAq/kEl3qF088f5wu0VyutcMUQmd/xwve345wxueUOixt4juU3OW+/jNttmXLliIoHc7xWmczs+Y8o6YVk+ARrdzT0uSyMm9XxzxK1NyDMfgk1/Ng8giM1PQZS0jvbQ/Rt4Cn784q6YNGzWdhJOmbT/VcBF9NfD3M1paFoejmwasH3LeTiu2596bS7hzAu4HedOvMRH+HGVo+P/2ynHDhtpI76y4Ts6gno6XSBqFkAt5nTbosVkLATYSrILPovD94gzyaSZISiwRsEYGzqvlOPu8suZOHGJAkzklhb0uj6JxucL6Hrqa3yNTftj/kZCjtMlNGO4utKo1/VGes6FbDUlK5UzxziVF8GlJ4nRkmuTRVS3CdW0o9Kir00+7fkHzY2PXu7I5WXk+CH632zPphldG8faTuXw0USBbepgiE+0CD3nrza8Brw0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bKUKVAeyZU59pxdAT4TP+I9MAYkw4xrcchZ3ef8PtAyyI2k3hKDEel+0wnXsp2a7q5pSPbMvyGxh1oBmgQ61yM1OObsScrF5EHZySoV5a0wL0oPxzQu4Vfpjs9JidIXBinDy19E4a1JsEvuPe5Di6atMeKOZyWnsGyIhBAQed9OsmN1DnuVa8Vd8tF1u2tNt/ZAy6p4UFejFej+JjeBtK81WOkWqwO6XO+hpkxsQ60QMnupqUzdmOjgPHq87il3Ffg8E9J6m8tfMYWWbyGffffz8RiWNwti/ZHtfjQHQM4+KiilNIdx3xuS9WTCUr/aelCE6kb6P0rzoFLZM6NvZE/9FHFMqktcldClixhkAZkvhq1ZqnQIM+go7moTzTveb5ENX9erBn5v4+8j+tltyUgMSI9nAIZCZQ4U5XJivjtZZzZMZIxAYVVNhs+3nvN3yiIk+vqvJN6M3e5Tkp6Iq7YJpB+Yorc9gqaP0SPrW2fPhwLtQvSDZw294a4wKmC805vfxdF/qtDhsIz68K4V4+OWJlqpnikbgDt0iSr3rycPOc5gkDmtgq1nKk/qkmp3BZ7hpkk6swiJBTKQGjooO3ialcnebZ8ZQP/Fum6GRDn+59MM6WNHE+gaSY1UshkxOq0YJcQLowo/qzDP4/50Johgvhr+hHTgX7F5SkK8gkKNKWhK+SFp71vx8yKYZaOymETdzgwm0P5zczUicFC/oig5J980MCpGRS3j0z1jeU+LWe4T0XhZt91JK/5NNEVKLxGL6DfOXIcv0jCrGIq9vl+tfJIsYJngEeJEL8jTTlh9/UNSpBGWEjZlG8DE4L+8D6RtSYV9v13U+kA+a2qdGZT/6FMxnDfvCW8a5AyOqjPSCsbkWXQRqS2IAREBrgQf6pGc3greHGcecE2lPU8uBGo9vm7jhpUKuFf7xvgdpk/optbqxNP5gFrX8UGCE6hhFq59V4eqkGdhmbWasmXY/o0V5NiclPpzNaPITNLqCymnBXkCupqZrwjBrkDTVbywJWTY9O9D0p59UmoQe6YH6JvFBVPHkL7cMj8seNqWx32oZA3+CSBcSllWrYnFwKM2Zg8rODjqA/CwJxJlBBdVyvGCLCZE+un5ev8XucyhEfS5h4GSc7b6MYkbatvH6DhrMUok7Sdi1qNIVKcrYjgze1dWxXDpvjmrw3mD//QHYKYgPY+iWFjf61eZmWOnlTYWBTIFs1pCLOErE5ettdwlghOaZy714CjK5VRUU7y+Ik3hMTJp2nN9CSQLt2lQeICAFELSIb/M/B/pqeU0axCzGqz8k8+NFr57Y0omf2fYpnaTlgFCZ7Uuycf4z3RCnSCMk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e13ea49b-8bcb-4050-bdc5-08d8f6f78c60 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:54.7899 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M41h9TG48rhx+0fcvLTOPRxYvEu8sG8Wlu77lwNW9cEl1BZCgdDsV3LAg7NNWQ8Hj8Ojgnb4WlxI6wACEgGvfeqexALQZxdYmnTcdWBPXUA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: x_8NKDEzWaMFJl4TnpwFD9CAGRZ6Jabf X-Proofpoint-GUID: x_8NKDEzWaMFJl4TnpwFD9CAGRZ6Jabf X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_host_template cmd_size so the block/scsi-ml layers allocate the iscsi structs for the driver. This patch includes the easy drivers that just needed to set the size and a helper to init the iscsi task. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/iser/iscsi_iser.c | 3 +++ drivers/scsi/be2iscsi/be_main.c | 2 ++ drivers/scsi/libiscsi.c | 17 +++++++++++++++++ drivers/scsi/qla4xxx/ql4_os.c | 3 +++ include/scsi/libiscsi.h | 1 + 5 files changed, 26 insertions(+) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 8fcaa1136f2c..1f8997f29516 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -990,6 +990,9 @@ static struct scsi_host_template iscsi_iser_sht = { .proc_name = "iscsi_iser", .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_iser_task) + + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_init_cmd_priv, }; static struct iscsi_transport iscsi_iser_transport = { diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 18d0591e4dbb..bcb12e674795 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -402,6 +402,8 @@ static struct scsi_host_template beiscsi_sht = { .cmd_per_lun = BEISCSI_CMD_PER_LUN, .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID, .track_queue_depth = 1, + .cmd_size = sizeof(struct beiscsi_io_task) + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_init_cmd_priv, }; static struct scsi_transport_template *beiscsi_scsi_transport; diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 926d33b2c9c7..07b23f3967a9 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2850,6 +2850,23 @@ static void iscsi_host_dec_session_cnt(struct Scsi_Host *shost) scsi_host_put(shost); } +static void iscsi_init_task(struct iscsi_task *task) +{ + task->dd_data = &task[1]; + task->itt = ISCSI_RESERVED_TAG; + task->state = ISCSI_TASK_FREE; + INIT_LIST_HEAD(&task->running); +} + +int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + struct iscsi_task *task = scsi_cmd_priv(sc); + + iscsi_init_task(task); + return 0; +} +EXPORT_SYMBOL_GPL(iscsi_init_cmd_priv); + /** * iscsi_session_setup - create iscsi cls session and host and session * @iscsit: iscsi transport template diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 7bd9a4a04ad5..af89d39f19e5 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -239,6 +239,9 @@ static struct scsi_host_template qla4xxx_driver_template = { .this_id = -1, .cmd_per_lun = 3, .sg_tablesize = SG_ALL, + .cmd_size = sizeof(struct ql4_task_data) + + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_init_cmd_priv, .max_sectors = 0xFFFF, .shost_attrs = qla4xxx_host_attrs, diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index ddd4b9a809a1..11f0dc74d4c5 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -467,6 +467,7 @@ extern void __iscsi_put_task(struct iscsi_task *task); extern void __iscsi_get_task(struct iscsi_task *task); extern void iscsi_complete_scsi_task(struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn); +extern int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd); /* * generic helpers From patchwork Sat Apr 3 23:23:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415109 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 B1B42C433B4 for ; Sat, 3 Apr 2021 23:24:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 903556135E for ; Sat, 3 Apr 2021 23:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236957AbhDCXYU (ORCPT ); Sat, 3 Apr 2021 19:24:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54858 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236945AbhDCXYM (ORCPT ); Sat, 3 Apr 2021 19:24:12 -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 133NLsnI086884; Sat, 3 Apr 2021 23:23:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=3kvsXUEa5a9XTG3RrHcCQ2U8kE3+vSkwXtzP5Z2bOSU=; b=a2b8lAl/8h52pPlzQb4pNIYRP4lZmBqc2+TnV+jlRHTaUs4I28LZqrPSlB48NwNQArSw Jjn+y24KEXhfamaaRqgtmAM3ivP3k9utdyLz89ZeoPNifbdT/JEUyK5mmpc7em9Ogole CVBwNev2LvbPYqXnjlC8T3Ee/oZdRFBEKPGLUhmKevGBHhgNGizEPdAIp2I3v/I7dgQ4 d0Rk1M1TTLbDuJLhX+XPGsJbf7KCXNuyhbONAnXjIIOZ4Nqy+/6fQrxPioiThHJOlur1 AhGtOH41pN/c66Hv6GnlMm4aBpkoB7esjbN06ZmitK4kLeN534mn6nLewX/Y851kd5yH Dw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 37pq66rcv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:58 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJrEV132118; Sat, 3 Apr 2021 23:23:57 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by aserp3030.oracle.com with ESMTP id 37q1xk81j5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+9jIj4iQYupljzTKeNpikB7JWwFvykYLpocbIQY0JNYWwOLokFPXIP9m8HJqf1eK8GmDhSicVv1YiSKXChUa6s+ATUcukQnEbwj+R6iUUCXloP+ISSaC3CbpAZ1Mb/hse322+z2VLobrILIKPDc3TXUI2bq6pQGT0eKG658luU+pbJ3W6zrUtnjBfIiYUf/wqifEMOdKcTcFGC7jmSOH0hAzo94ZQa07BrKqLQUu/q/p79jiO4g0p9madcyydgvkI+7XvyqT3rwxoRquLrt+GpOGpZ4jK9nFJYAL5xCFCg17IfXP8Bpk7w/GWRbnTi8sHiTpkdomaDINjzlnkZRhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3kvsXUEa5a9XTG3RrHcCQ2U8kE3+vSkwXtzP5Z2bOSU=; b=PELLeDWwQ5NeRVgzOyvptgBL/UuN61axJTKAq125Itku8hYKJWie/HOfeJ68OJNCjMkVyHWLxV9MUqZTe6gZEHKLzAbUoDqbY5JEEj4pHxvdLsyuQSaLuZp2ECjmYcB6dt4KkEMigMx+l2luUkC8ZeRRzjFk0D3oncgDM1SLmPpTJhyYC5gD3hBwLGKhtFyLlNepA9AIpNCNAcE6A6lFn/Y9Ywb/rN3lSZVzXJOdVozJ/h5fCW130/hloXAtlhN9hrxgatnn/MbbzkuCTz0IdlluUk7a6oEibRqVqE9AYNA2X7tew4YVgyMN0GSmwH7aamLZLI5jHdvUbjvOwQAEUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3kvsXUEa5a9XTG3RrHcCQ2U8kE3+vSkwXtzP5Z2bOSU=; b=F0eogPO7jSakwszRMh0CX+kbjBJFzCJdCdPFrBtfh9r502ZsjCjGmG+G24EXJF8Fm6bCb3QeIfe3VcBGNNFON+ajXaG7dUUnednDimEhYyrctF5ZYAKTZRjWxpZLoXuK2ILxOrIi6OSoG2jCAvS43f55zAHiUkae90Q1EK68alc= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:56 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:56 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 09/40] scsi: bnx2i: set scsi_host_template cmd_size Date: Sat, 3 Apr 2021 18:23:02 -0500 Message-Id: <20210403232333.212927-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb5d2edc-1006-4104-17d6-08d8f6f78d36 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bcg6nmjS6Wn19TcAuwIn+EAdpO3ADocp/y4L+cigS0eZR94EnvIFehLeoIC8sdXAAp1ugF67G64l6SwOZ0L2yOul8DINGMQ5ORNrYN6W6FYs+Z9XLuLMig+/gSf9IALKTixxgj3DVSV3n4JaEc91h2ea+S3ecwkmvy/uWfqHbTlWLfcFsHdBaG0PMIuGvzv7MtHTkyKhqiUM2can5hcd5JS7q6iU9Ra0t5MrlYe+TAEVN2NC5GpJymshmvx8ZNkzqkPHt5guTgOn4lrKcw0sS4Keo+Wt1woVLgGcCKorPrNN8rkVbDNaeE4Z5+NT4fvbd2CJj3HXQAEIwGDh4n8nf8EfwLkMJIycTrLcM5wsBUuKS03kecWgP+WeSIeCms8Smb5pCtZkMLF6yHBixcp9XWJUAboYYI9Itq7Sl5RllI/9npD34hiSfcChzOCN2Q9M4zGt0zG+ux0RukaOlif5s6RzO5mp0SxTc2PV6p5zMLCWgSfwEDBCZbsu/doXpT1Yc8L6QQAA3yeDuA12aTgAZObaiJRrrvqEdACsW9PwKHdiYK2G05DGNjLzCooQGzVpIFoe5k29NrzNJqAVEP90inmjt1+22E2D/Ufx5c2iGrYUWQmsYh8ef5tv1hUTE7vVBve/i4PZAP11oxvpYFXZ1o3HRZdXgM3DReZCavq9hhT+PqNL/34FwKxmxn3bEeUT3Ite9EJIoxUEr08lpGTwOw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3UPzNirz8mpUQI9t6WgUot6fo0G1Cbs1lVEkZE7Su+CRV7umMubullrRnBHg7DuyJeJ7DTf7AyWojladhFYKzey+DBBxqld5NOQoy9eN1nGhaskMji7CuubZUVpo7YgDPCtGvgcUd/lbhllHDuHz+LgCFvxVSeNzFU/cCe/9sHloAdFtbq4whHVTnbEYJfoLqJqXQOd3NItg7THT/HCEAj1ylG1Xbv7Mn2VdbvW7Fw4gg+vCnJ9fwGf5J93x5UGX9K3oCwyMH5FRV5esFlggL41F55A1j5o277dWwgM7LxQsehSWtY60vW5Fw8rYj8CAxwqAKX93Fa6IcBc+68QMI4UrAUXlKR+ScAx4/598/QsaifwhtjFxJebYwkq4sBn661+qNTYd5dT+Rgp65o+avL1XfeGrarNrL4sxApDAQKlFSrs2SeJXTciC427VM0TTZGicEEOUhlpPjTzBScWpBmTH2Moq7CKpc7suJcfdGPEYkz49PoYe01xyoees845lqmRRRwKOqO7NkvhQEack9ADyF+9ZkZ+qj5n/gAjgzVERAOHq+rXT215HdmPoHZP5Are15FwO1opNWYkKHUsOQ34uY/qAZmFqanNmK3KeU1ObTMyt7ZO0AdeA6qYaZD5tJFsQHGJnEKiduxuRsoRDhBWyRwvkwjaPn0EDHEHov4GawL6vJ9sxFRVkxUt9s45bJvqPiOqPqABirxdJ/aeldftsf5bZNvUEoYBKZ8rWUJbQ5DQpRSQPKS8Rn9qu1RdYGaYS4jIAgCL8PA0IF206EMeSzUDLINJy8tiRfWdmHF1omHMhBtDUWhhhlHplRCN3XRKzRAa5v0Aepd5/1m/sS7tonKY9SyR0RyESyvV4ZMyCFNC0xq9cNFM8TdCTxcTP2QGHrjruEiTjFGvdIeJhO2/7kWNF7xLjqEl8utVC9E1xdQQTElqm2u0D3RI/1oXh9WbPvu+md+IUDKMDV+vdcIM1s7HGVm77jJlpwzrS6GonMegPqFPkNcAHsG0JNhqwIQxdtzY81VkFSAWqUR4QRM9tksviC+CHVUVLlRd7emejUKNeHQsP8QoI3rxrmKVK5/Td6ONC4sHdQKmkyQ7QH3Sg0lSKJAc/t8wSSmDX6gs6jqkUsPT8oPFbmhWAQme8tpG03yRJ7jbfyKAj8hVc35AuyWodThfSSOc+Pd7QDtkIbIf2ORlE3+lqJsHiWcGgZl0pGoDqaXdz1xX5vKSdTZbHcoEBEW6hkxUX1JHWjoB4AQsrdc7/E8+t4Fhkb7fzPMiO5b5jm2H2WlLvZLqg7seVcfuW80dgzrLTT4BoPBsfu4eVVJGB22gQba1VhEDV X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb5d2edc-1006-4104-17d6-08d8f6f78d36 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:56.1151 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4tSwRZVwb0vGVoErt3M4YU1B+9JIVULauyJQHCbRX+UaVEgauGUM0rptczxI1SrhxcxNOAAYM1nJIIvWKNKM/rTLCoxFiIfvH0BwRLg3T9I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: wLvD8zwTxpS80GzhFefcCLnt-LcBDyR3 X-Proofpoint-GUID: wLvD8zwTxpS80GzhFefcCLnt-LcBDyR3 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_host_template cmd_size so the block/scsi-ml layers allocate the iscsi structs for the driver. Signed-off-by: Mike Christie --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 55 ++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index ce98112799ed..a964e4e81a0c 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -434,6 +434,31 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep) iscsi_destroy_endpoint(ep); } +static void __bnx2i_free_task_priv(struct Scsi_Host *shost, + struct iscsi_task *task) +{ + struct bnx2i_hba *hba = iscsi_host_priv(shost); + struct bnx2i_cmd *cmd = task->dd_data; + + if (!cmd->io_tbl.bd_tbl) + return; + + dma_free_coherent(&hba->pcidev->dev, + ISCSI_MAX_BDS_PER_CMD * sizeof(struct iscsi_bd), + cmd->io_tbl.bd_tbl, cmd->io_tbl.bd_tbl_dma); +} + +static void bnx2i_free_task_priv(struct iscsi_session *session, + struct iscsi_task *task) +{ + __bnx2i_free_task_priv(session->host, task); +} + +static int bnx2i_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + __bnx2i_free_task_priv(shost, scsi_cmd_priv(sc)); + return 0; +} /** * bnx2i_alloc_bdt - allocates buffer descriptor (BD) table for the command @@ -456,30 +481,28 @@ static int bnx2i_alloc_bdt(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd) return 0; } -static void bnx2i_free_task_priv(struct iscsi_session *session, - struct iscsi_task *task) +static int __bnx2i_alloc_task_priv(struct Scsi_Host *shost, + struct iscsi_task *task) { - struct bnx2i_hba *hba = iscsi_host_priv(session->host); + struct bnx2i_hba *hba = iscsi_host_priv(shost); struct bnx2i_cmd *cmd = task->dd_data; - if (!cmd->io_tbl.bd_tbl) - return; + task->hdr = &cmd->hdr; + task->hdr_max = sizeof(struct iscsi_hdr); - dma_free_coherent(&hba->pcidev->dev, - ISCSI_MAX_BDS_PER_CMD * sizeof(struct iscsi_bd), - cmd->io_tbl.bd_tbl, cmd->io_tbl.bd_tbl_dma); + return bnx2i_alloc_bdt(hba, cmd); } static int bnx2i_alloc_task_priv(struct iscsi_session *session, struct iscsi_task *task) { - struct bnx2i_hba *hba = iscsi_host_priv(session->host); - struct bnx2i_cmd *cmd = task->dd_data; - - task->hdr = &cmd->hdr; - task->hdr_max = sizeof(struct iscsi_hdr); + return __bnx2i_alloc_task_priv(session->host, task); +} - return bnx2i_alloc_bdt(hba, cmd); +static int bnx2i_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + iscsi_init_cmd_priv(shost, sc); + return __bnx2i_alloc_task_priv(shost, scsi_cmd_priv(sc)); } /** @@ -2203,6 +2226,10 @@ static struct scsi_host_template bnx2i_host_template = { .sg_tablesize = ISCSI_MAX_BDS_PER_CMD, .shost_attrs = bnx2i_dev_attributes, .track_queue_depth = 1, + .cmd_size = sizeof(struct bnx2i_cmd) + + sizeof(struct iscsi_task), + .init_cmd_priv = bnx2i_init_cmd_priv, + .exit_cmd_priv = bnx2i_exit_cmd_priv, }; struct iscsi_transport bnx2i_iscsi_transport = { From patchwork Sat Apr 3 23:23:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415111 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 9104BC43461 for ; Sat, 3 Apr 2021 23:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CC3761360 for ; Sat, 3 Apr 2021 23:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236894AbhDCXYN (ORCPT ); Sat, 3 Apr 2021 19:24:13 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44902 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236926AbhDCXYL (ORCPT ); Sat, 3 Apr 2021 19:24:11 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NMuw6099171; Sat, 3 Apr 2021 23:24:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=bq29pdC0jNtoVNhLZ3878etoiwz1Ig+czOpsuB4cuLk=; b=A1OU2nkjuji6Srp+ObQOokAtZS7k3vj+egbYZ1wMrd7cHdSf/1BiN+ddvepGG7ACh94M u0VLHtzslocJDpG5GDw0p+HrzX2WSZAvrj5phc05EGkgPqpT8N286fOE4gnl42lw0Vxf ln90CIqiXSwALdwnBvS1xA2o6DBAjtzw06yxTgj5L3Li8dOGzfpjP2FI+OBPRQZFHHB+ YhDNBAg545p1CitTnSsrfpPYJLD1H3lRwlWvqoSJ4ZvuQ/E//ydSlRb5hdP2u5BfIlH3 ywqczeiDE640ujXSlzTHpP55ZXPmsvF6s9KYG6u3WjuJLQA+SVPtEnq+jlivk7JTE2Qm 1g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:59 +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 133NL7pH130170; Sat, 3 Apr 2021 23:23:59 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by aserp3020.oracle.com with ESMTP id 37pg61hu90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:23:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GamR3OuKIzcBeN9kk+2JjUo9IT0HTy2sVSAKYYdYzIJqAB1hQmxKiiplBcSJW8erf1mgqc4eN9+gG6jixP4wCSUXXCDFa1/4BNlV0RdLRLvHUl5Y7hMenDNe/kQencbbFmZn6nfPQ6Y+Dvc/AlSKkGp30sgq0e6rdqLZ8r+PK+nUQw9FcvlzIQ0mS+0quo/9bR3pYuYEf4n5FVdR55fVm2EO/Ulo1a4fm0MpxbO38GzIiBf7TAvtjVxtmThpLTzSuqDGj8uU++JCYO4p9WRxQrHamZTon27+0l9uRIratg682MS/VMFthywpHOHJJIaRL7ptRWGbthAsTnyyulXCxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bq29pdC0jNtoVNhLZ3878etoiwz1Ig+czOpsuB4cuLk=; b=oYFrXZiJ06ihKExxUhAhpLXj0pkWGm8uVFFR82awqUcV4ZyhNURA3snJ4CNld4Oa9GQP7osfimOUrVS75QNcBPCG6a+Uln1Ma1rWVHPBePpLWHe6osDL8t0ftAoP/TqWSpMUCcegD9B7pdkDyC0/hwGWy+qtYuYS/D6fk/oQ0f5FnGbwmI4em7Jkh9AECqie6Duouznq/G6C7K/ZXp326Gx63EkaIM4p/kqxRD/ZxhpN+sP9/OU58zf03FQJ1/5ysQ1okWs/U5yGne0Yw0z5Nv2FUOkwvJfDKLKv1QWLPI1jiLoSVOeWdLwi5AvQOm8FHYv9TxRUVMAF3MDVP8sRwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bq29pdC0jNtoVNhLZ3878etoiwz1Ig+czOpsuB4cuLk=; b=fsY6HGxDg3ELHrXphf9cSF6LEksWwOp8ONlcm2G2zUospteZsb9On2v8fLb2g9eTRLEV6GJ7CHa+uR6yCEQmXjzifbuJ8s29jMLHmqnmQumHpfDoVc0QNsepyE7sWEgoHBPS4eanu0SyNTXekUv0GcraPpsNo7mRdJ5s/f25cCs= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:57 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:57 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 10/40] scsi: qedi: set scsi_host_template cmd_size Date: Sat, 3 Apr 2021 18:23:03 -0500 Message-Id: <20210403232333.212927-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 595161be-6682-41d4-b466-08d8f6f78df6 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WpeKDlwbRhJCZzf/FXAlMDHd2cmZ2vZoiLAl7+xkXZ8sMzAEaoZoSmGWOKqzRg++XGz1WtgvdNeJCz/aqvKtDxtKtT4WAxlRtAmbS7QMyD3VzYwLuRR/BgVc2SC2VmJzOhQZLZ4hYD2R18hwRXL4UwVRDWMXQpcviWAg4suFeRkVUQ0Hz47Cduu1oX+3iHQWlitxXc38qI4ony9HFxtaGwF3k+tQWkajPMIy/p5lD2GHTDgs+IsfqPfUlgRr7l7RbS+azE8q7/hZ7f7ajdCux9Jh642QAgk/fDEuGJzMK3GHjDtmlnEW3ugdvBxQ/42/ofmwmnbeo1oTrPP9mey1eKPHF4n1KYcCeHFQ8kAmK+im3meKt3hj0Uu28fAn3Au7/uLPv1/Lvjixi+RUFvwCCqp3g7BkFIC+PwnumUDo0ap9afVGQPdLaKQB/hNiGrIy6uN6ky8gAhxTqG0au6UeO3VIgcVBo6nE9a+oyHfbZQ2WoxEGEO/2TwY3TFqu9FxztliUpuwXW3ed896hha86Sw9wZ6TXhwudMeuXmab0hemQgVOjaB86DjfxsSd8e5zZV0dPsj7ZIWQhAJpvKPLzFm8s4pC7/FuWqmc5EbV+aw9lyOKG3Nx+GfWBRsuLjsW2fv1mly73U1sBu1PhKwqW44/p6sQk5e2nWiLpXQJ5TsNYMyF6iI5Xhtn7mSzW2gyxpUhfmxsNpJQkbsPfy+F2MQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DsAXcfnBoXVGP8AmVk9xWDdLkovaThNEDQ8dOFAzydEfvPMoTY++x7lKxjtppqCjBzIz7lQLG571UBFyfCtJmIIbWBRXYRmyz5r/LEPderyOWggJqF5z83rZIMCcpzFfOwdDPA2prIgM/Cv6ba0AFjIUsSrrw+XFCDscWOXKc21wox0JpwIKsXcC3wAA2qOC6YFae5ihNFw5NiWTNYokfp/Ui2gOTLeV1iBDfxAhca7RnvsXvU+n+h9xlCJk1vjtzEC8jEV1zg9LpEHcf8eOuhoG7G6p4Jo0AdrNPBT31zm2Sa0YRvzEekjvy3w3/0ARqZgr4i76kE/kBT8h5pKtJxgNrQeuxK1C3JAukPWD0fR9vBHHjbA0DW/U7E/X42V9Z456+chEW5vIm7a+J9yKgc09jPVZIl5YSIFnDkqgUBhRJtUdiBkep/J2Q2QfjGb3Pmnu2FekEXLqec7IVbcpHh/9mleu1kPrU/49PvoXKNETzpAGM+1OtS61tdMYZqcsPypNFNf/QHpCfpy07V1Szp83wHsIBKSFsYhBBA7H22BdNrZ9mY4CIXPgHJMEpf12BhQnXvGz05CjIVYg9/gaTj8K/6SZBugtrI1MuB8nG0wof3mHPmU9SBqkB0zXNJ5UyyVPAurixVwEPMO2b0FPqqkJUS9tZVullNpl/3ExdiWHQavyVsJ7nLpwxhWWlQy6TO2UwddP71bvKQpP+EagDNlV5FjB0E+s5LR1kJjvjUYtviKnkxlX2NfePdpH13OwTj9teF2PHD8dtgP2WOZZfQBEHqDPDcwVPnXBXduPvZXmmcg3HWm6NGQXZI7OdDIyv7TcE2ngv1o11utvambJTt0r/8Hw2glLz+lH5Qs+0p6EwsfM7ZzLAmfXn+8zec7IEkevH0lyDqxZTuopMDNwOaXzoVDBK52/uV68S98w1jHRo9jZrgSWczqv//IxI+qPO2HeYpxy2Wld8dWeWxbbdcG237BosB+4Sb8/hdy0szFYDuLy2P6EaAdutfYb5y8K/xASFlfQC36BG4ry9xgq3s9vdvpafUIzUVOBFngEAg1yoscINCvGF4BCuDQXJQsBOFX5YsHpmkkosrRSxqEXWaqRPSm/ZoKcpNSWtz0pPFBtu7QXc2s4r4FzTgchA7LTNu03c4C5RSw5O3YcHmyTjEMpzt5D7dSSReaYGLmtUeXZ2CGXyl9iFxKk/YnaHepLHzGmxlK5NpG3E7qugmROUdD0J/4IIeQxLUC8pneF2U70PU6kr38MOLuy5/hiDVP7eBccxK3voZSBbJFoH5kXQuOJFyGZm/IuKHXwu6QHg2wrgXcfoRUxC7YfjIsVDiV9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 595161be-6682-41d4-b466-08d8f6f78df6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:57.4114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eQsTqkqyj8lxqW0dg17vxIPZCxXXst9V9kxipiCt0UptJPDB3iDSvZMg5AB6xvmH3jYf38cTSZNQTYNgPqW+JWBK4G6fgScyb+J37J4up+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: Td3M8OuZpHTBTDkU-EchgQxAOnilX0uB X-Proofpoint-ORIG-GUID: Td3M8OuZpHTBTDkU-EchgQxAOnilX0uB X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_host_template cmd_size so the block/scsi-ml layers allocate the iscsi structs for the driver. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_iscsi.c | 42 +++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 54c1d0a2484c..36e81eb567b2 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -14,6 +14,9 @@ #include "qedi_iscsi.h" #include "qedi_gbl.h" +static int qedi_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc); +static int qedi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc); + int qedi_recover_all_conns(struct qedi_ctx *qedi) { struct qedi_conn *qedi_conn; @@ -59,6 +62,9 @@ struct scsi_host_template qedi_host_template = { .dma_boundary = QEDI_HW_DMA_BOUNDARY, .cmd_per_lun = 128, .shost_attrs = qedi_shost_attrs, + .cmd_size = sizeof(struct qedi_cmd) + sizeof(struct iscsi_task), + .init_cmd_priv = qedi_init_cmd_priv, + .exit_cmd_priv = qedi_exit_cmd_priv, }; static void qedi_conn_free_login_resources(struct qedi_ctx *qedi, @@ -170,10 +176,10 @@ static void qedi_free_sget(struct qedi_ctx *qedi, struct qedi_cmd *cmd) cmd->io_tbl.sge_tbl, cmd->io_tbl.sge_tbl_dma); } -static void qedi_free_task_priv(struct iscsi_session *session, - struct iscsi_task *task) +static void __qedi_free_task_priv(struct Scsi_Host *shost, + struct iscsi_task *task) { - struct qedi_ctx *qedi = iscsi_host_priv(session->host); + struct qedi_ctx *qedi = iscsi_host_priv(shost); struct qedi_cmd *cmd = task->dd_data; qedi_free_sget(qedi, cmd); @@ -183,6 +189,18 @@ static void qedi_free_task_priv(struct iscsi_session *session, cmd->sense_buffer, cmd->sense_buffer_dma); } +static void qedi_free_task_priv(struct iscsi_session *session, + struct iscsi_task *task) +{ + return __qedi_free_task_priv(session->host, task); +} + +static int qedi_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + __qedi_free_task_priv(shost, scsi_cmd_priv(sc)); + return 0; +} + static int qedi_alloc_sget(struct qedi_ctx *qedi, struct qedi_cmd *cmd) { struct qedi_io_bdt *io = &cmd->io_tbl; @@ -202,10 +220,10 @@ static int qedi_alloc_sget(struct qedi_ctx *qedi, struct qedi_cmd *cmd) return 0; } -static int qedi_alloc_task_priv(struct iscsi_session *session, - struct iscsi_task *task) +static int __qedi_alloc_task_priv(struct Scsi_Host *shost, + struct iscsi_task *task) { - struct qedi_ctx *qedi = iscsi_host_priv(session->host); + struct qedi_ctx *qedi = iscsi_host_priv(shost); struct qedi_cmd *cmd = task->dd_data; task->hdr = &cmd->hdr; @@ -228,6 +246,18 @@ static int qedi_alloc_task_priv(struct iscsi_session *session, return -ENOMEM; } +static int qedi_alloc_task_priv(struct iscsi_session *session, + struct iscsi_task *task) +{ + return __qedi_alloc_task_priv(session->host, task); +} + +static int qedi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + iscsi_init_cmd_priv(shost, sc); + return __qedi_alloc_task_priv(shost, scsi_cmd_priv(sc)); +} + static struct iscsi_cls_session * qedi_session_create(struct iscsi_endpoint *ep, u16 cmds_max, u16 qdepth, uint32_t initial_cmdsn) From patchwork Sat Apr 3 23:23:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415239 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 01633C43461 for ; Sat, 3 Apr 2021 23:24:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D05F861361 for ; Sat, 3 Apr 2021 23:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236967AbhDCXYV (ORCPT ); Sat, 3 Apr 2021 19:24:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44912 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236950AbhDCXYM (ORCPT ); Sat, 3 Apr 2021 19:24:12 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NMvI8099207; Sat, 3 Apr 2021 23:24:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=3xOHOUuhPkAQK4C0JJbxkL4699iVaCfBhQgHUG+G2eI=; b=rEeWHWILr46Rtq7FGT3SRxb9HKf+NEggiDHr0bNKaZJ1skgUWIsOI0KFTXswp1fu+pfF tT4ETtYdebykueW+udhYLkp8FuHpKVLBG8AV5oMg8oGQKFjfKoYPYI8vhtKfeY+c3TDf IEEKK9jUxAQQCibp4qnXzfHoVUmabiRnGIWC43HFO1smhsqhMpcVmIJWd3TbggXIGxFz 2xYOsO7DqxR3vMP8SRACNfAM4atzERe8wp0IziwstQU5u0Q085bQ5abBfeu64c+j3HQg ZYtbQXvfyhOSP9OAP/TH0gU/Ta0uqLW8QGv/bso0UrHPqvN5+A7PJ33UkeZuGylyN8og JA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NKDHO132673; Sat, 3 Apr 2021 23:24:01 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2052.outbound.protection.outlook.com [104.47.45.52]) by aserp3030.oracle.com with ESMTP id 37q1xk81k3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJUq4FQYZBG8A89P2OsY97HPciJPqfbNR+VheWJsuZIpqnr9pVrEIiO3dKDZ5d2bd+GpiyUwOrPDajwK52WktqgNLidsAiNZS83Bv6UWC+9QuWciQl++K2E/LyZsqkW6E8hn/5xxqTcQS1NK+YYCfrbKH4DsOVpDRn7LDcsQQhgHrLLE/hx0DcjaWXmHqhBxfYNxAfpJ4fNkiI9cOEkBh+E9y0RxuiO9qNSPC7/FYrFxgxQVg+gn6flOp6kAbEvxvMX8kyLpmoEvnQ5Fk68OlEPpR7NxtWMiAtqPjhJY5Cj/wxzGF87kCheWdE+fMllP88HXfRXQPJXmdamd7R834g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3xOHOUuhPkAQK4C0JJbxkL4699iVaCfBhQgHUG+G2eI=; b=ggkgpajEwJhKoj7gxmKu2RCJV8FMfNCFdkbRwQLVD0dZct/ezVDSycjHit90kIqOpruuHNeFTNMoY+ysNtzNHb2rN59Bfb1NIC1jbDNKpkPVzRRnfHfupyCDBqJL5uaB9DIVBv9HK0Ngs8V5hH/xP2RSnkvLCU9jxOk3X0Fz8BZc6549aOzsnIdk9Zw8A6PluklbLCZT53QWN0uefLPR5nZ0b9O3UZvaREkcV7CV2UnYOy4DVSdQHquShY2kuHkcjfbgNAoxyorpQ9gFf9Bug4KJTgA5ZURiVzSl9+O60G83a4vyJMxkZYCkbyXWYz9ASq9Y3PeJkj1ycycytnLQ4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3xOHOUuhPkAQK4C0JJbxkL4699iVaCfBhQgHUG+G2eI=; b=u4M+nFozV6OmY7bJ1f+zT+8pYuXmtoj1e3h/MYn8MB7ElpHMflGn1Q1PVxUXC0DyOnEGuwH/2s03IhmPVX3BVVvWCWfK4c6aoRnuWu3rmlgUhtrc/c8GNi9RK6m7zPLfyUATtxARL26xRo3kZaRqXtQl0HuxX/KP67O+MWmiEog= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:23:58 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:23:58 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 11/40] scsi: iscsi_tcp, libcxgbi: use init_cmd_priv/exit_cmd_priv Date: Sat, 3 Apr 2021 18:23:04 -0500 Message-Id: <20210403232333.212927-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9893e3b8-da7f-4413-396c-08d8f6f78ed3 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QUp2QKoY6eBE7YcyrEblbQ6pWj3BekZv1rUmDxNjvntGj0ufsZqvvyN4kJ2YjRAHvZ6Bg/4dXjVMXaIO0MuRvtn3ZKiHvwnwW6gEH91KgdY2OSaNo1nsrzOJAQv8+pBwqAai5a447CikdlNQTdPqfOhT9d+pqpB8+GYlGi0QZuZDxlXQEqr0UmBklxt4JOFa7SiaRs2ciQeYPq5mWwakhE0JwJR6EVljyjO3b+Y6e1BgC/S/xx8/CL7vUD1LObebfvMruCLr3pShyovjlV0ytCDlhe/pulRB3PTyrXeI0q4amZwOgJOxFWjMh0pVFPdVIH0uCQBQcp2tnXucB0n6tcGkhQ6uCZs6NmwJLeEbASAf3xOLZU5sZUFHQJu5XBi9qijzDMv+SCEi5y1LVJ9Z/PVNIrkmlK7LsjWiIsE6BWxGiTy0qbfSSypfNKJHDnqxlDTCbblDIYjD7Rfh/ep6l17AP41cT54aiaocvmgT87hgQ4aM56r7B9AoZBk7dCu0Vxssui2iy3xF7WrzhoqGRmWBnXy2hxRJVMZ1IZG44W+LdlNyjx9cB4vtgjvnj0EFpX5GvVIeyLDmlcgo+ZJ7iigyqRVBPmetI6pLii43XQ/Hk0b7/jvDeGAX47nKctsD61uPPaXPAz5nALfD/NBY0zhDFXEbHjYVTg8W2pVi+0u+mZUjrKW3z46vRh7y8pX45zgez/tmyXwqeGBTXCGIOQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UWfO5pXX1tgV5jdPrptxwAPU/XsLfmmLx7MYn6LANg80198YmOlHA7hjZwZmqIKiiRhC9z0JfO8FJPPsZ4STP81ncq3fr3UL7emB69IwAYwTgoghvyV8y44GD9PZ65oinf+QknZSZfaWG7+wWNk0GNImIebFsKOyuez75w6E/DNDEOcTL0e5BrJTuRxxtV0yDhQ2cJj8QAf3atf4Sh4UWa8Bu3ThTqzwYSRMcxja73Z+YZ37o7gbusvCPVj/uTIak0xrWaBpmhjCEN5bc+Bj5ZJEpvrqjrBtMsiLAPLdbhh41BcaR4uRhAx91exZwZMfFgrrCQZ5KVIHV3edc/a32Lz6Jp5oJ2dz8gHex9sfHRqdB/vYR9TyywL0GBC9+BtJmISKnoJ/UNgynDlXJsm1EvXpbmd4//KJYJ2itmQYmIdDNkZJn3RNVGHcebZboOvJG9gA35IOcaIm+VmethNvV8WNFZJQLOQGFWpiQ9g3FAmewxVCB7/1FUr949lU8y66zmcIcCzdx3yF14UCDut69IY/6+vnjplRIj6c/9feOv9qlCzR67+x0BQvYMQMaibHB17VqZWMW41Y4DZNsDVL0M3wRT7TwnSQ9BDGdtjIV1HT6jXNL6ygwZtsXxdv5xXH9NAQI28C7Q8o2pg7kp3BDJacQHX7l7RMGitFXXQEUIP0yDtrsckQBPeQWMd1aZjS1JA38u7YbHnZFQATHsRtjDzfV4pILT/joSTgWkwzyi4QAc5aRgxEsQERTZMksapUW1zvpazhapr31AHhGY20kbV+9KqDAnIgAIhR2zNGjT4MgB4UCGB5tSzmUpALD24wbK4P7ZTjcCMAIfL4EczcfGgqivhin2Wa6hH8cj6sQ1sP8upGhBZyA8azPc0TdX4rVYJFwyxSv7o70FeSmHAyGMq3p3I9Zz/3Zl6Q5Mc/sO2K+2CXgGFxS8KjQOrwpml1a4PsCQXkjV0KYen59h7XWfYhrxazgCcE/zA6f6EGcI0VB5Xdyak963tYVR61XKtBeCRSdtOmjGGyNS1AZ/LJKEz9VLhcXTp1/ECcF20EfbShHv2xoWK+qSCPPjOshy+5WViWbl5xv9XwClTqt0UtZlZp56uiXl3le1eznnZL/04UyvhQ7j9Z2cK4Fxx5FAwTp3ZNb/LnEOMiudNRJUREaUxh2fp7lEz+pGIr2VvfCe+SS9F5ywIEe0vXjz2Sr7ifItPiFdM+7/03K6blgIUgMj7e7QCuOX1j7LUfFEfvycLfWr/xsNDPy4zeR7LAPT0l6lFbPAlpkEnvKknsoH5zzOUPGHOGGw4JNLdcD4oWghXf7x4SnFrPUZIz7eydf602 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9893e3b8-da7f-4413-396c-08d8f6f78ed3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:23:58.8616 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /qggGNS9nuJS9VcSlQwNF74GnJV70SVvpOmC1W5bIRo2UPE71MXRB0KsutUeLCDXs8xHP9x1UUYkOd04Wf66duSlrBdaWHC5KSzYJmbRRps= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: g0bpVOH8LDqRJaF-hNjUpSF9IUhzNVol X-Proofpoint-ORIG-GUID: g0bpVOH8LDqRJaF-hNjUpSF9IUhzNVol X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Implemet init_cmd_priv/exit_cmd_priv/cmd_size to have the block layer allocate the iscsi structs for the driver Note: Because for cxgbi we do not have access to the specific session we are creating cmds for, all sessions get the max of what is on the host but this is normally going to one so it should not be any different. Signed-off-by: Mike Christie --- drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 5 ++ drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 5 ++ drivers/scsi/cxgbi/libcxgbi.c | 10 --- drivers/scsi/iscsi_tcp.c | 11 ++-- drivers/scsi/libiscsi_tcp.c | 102 +++++++++++++++-------------- include/scsi/libiscsi_tcp.h | 5 +- 6 files changed, 72 insertions(+), 66 deletions(-) diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c index 37d99357120f..d45babca253a 100644 --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c @@ -98,6 +98,11 @@ static struct scsi_host_template cxgb3i_host_template = { .dma_boundary = PAGE_SIZE - 1, .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_tcp_task) + + sizeof(struct cxgbi_task_data) + + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_tcp_init_cmd_priv, + .exit_cmd_priv = iscsi_tcp_exit_cmd_priv, }; static struct iscsi_transport cxgb3i_iscsi_transport = { diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index 2c3491528d42..d6647fa04851 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c @@ -116,6 +116,11 @@ static struct scsi_host_template cxgb4i_host_template = { .dma_boundary = PAGE_SIZE - 1, .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_tcp_task) + + sizeof(struct cxgbi_task_data) + + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_tcp_init_cmd_priv, + .exit_cmd_priv = iscsi_tcp_exit_cmd_priv, }; static struct iscsi_transport cxgb4i_iscsi_transport = { diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index ecb134b4699f..919451810018 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -2727,7 +2727,6 @@ struct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *ep, struct cxgbi_hba *chba; struct Scsi_Host *shost; struct iscsi_cls_session *cls_session; - struct iscsi_session *session; if (!ep) { pr_err("missing endpoint.\n"); @@ -2748,17 +2747,9 @@ struct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *ep, if (!cls_session) return NULL; - session = cls_session->dd_data; - if (iscsi_tcp_r2tpool_alloc(session)) - goto remove_session; - log_debug(1 << CXGBI_DBG_ISCSI, "ep 0x%p, cls sess 0x%p.\n", ep, cls_session); return cls_session; - -remove_session: - iscsi_session_teardown(cls_session); - return NULL; } EXPORT_SYMBOL_GPL(cxgbi_create_session); @@ -2767,7 +2758,6 @@ void cxgbi_destroy_session(struct iscsi_cls_session *cls_session) log_debug(1 << CXGBI_DBG_ISCSI, "cls sess 0x%p.\n", cls_session); - iscsi_tcp_r2tpool_free(cls_session->dd_data); iscsi_session_teardown(cls_session); } EXPORT_SYMBOL_GPL(cxgbi_destroy_session); diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index dd33ce0e3737..eff5f8456ced 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -883,13 +883,8 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, session = cls_session->dd_data; tcp_sw_host = iscsi_host_priv(shost); tcp_sw_host->session = session; - - if (iscsi_tcp_r2tpool_alloc(session)) - goto remove_session; return cls_session; -remove_session: - iscsi_session_teardown(cls_session); remove_host: iscsi_host_remove(shost); free_host: @@ -905,7 +900,6 @@ static void iscsi_sw_tcp_session_destroy(struct iscsi_cls_session *cls_session) if (WARN_ON_ONCE(session->leadconn)) return; - iscsi_tcp_r2tpool_free(cls_session->dd_data); iscsi_session_teardown(cls_session); iscsi_host_remove(shost); @@ -1000,6 +994,11 @@ static struct scsi_host_template iscsi_sw_tcp_sht = { .proc_name = "iscsi_tcp", .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_tcp_task) + + sizeof(struct iscsi_sw_tcp_hdrbuf) + + sizeof(struct iscsi_task), + .init_cmd_priv = iscsi_tcp_init_cmd_priv, + .exit_cmd_priv = iscsi_tcp_exit_cmd_priv, }; static struct iscsi_transport iscsi_sw_tcp_transport = { diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 2e9ffe3d1a55..73d4fe20ba9d 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -1147,68 +1147,75 @@ void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn) } EXPORT_SYMBOL_GPL(iscsi_tcp_conn_teardown); -int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session) +static int iscsi_tcp_calc_max_r2t(struct device *dev, void *data) { - int i; - int cmd_i; + struct iscsi_cls_session *cls_session; + struct iscsi_session *session; + int *max_r2t = data; - /* - * initialize per-task: R2T pool and xmit queue - */ - for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { - struct iscsi_task *task = session->cmds[cmd_i]; - struct iscsi_tcp_task *tcp_task = task->dd_data; + if (!iscsi_is_session_dev(dev)) + return 0; - /* - * pre-allocated x2 as much r2ts to handle race when - * target acks DataOut faster than we data_xmit() queues - * could replenish r2tqueue. - */ + cls_session = iscsi_dev_to_session(dev); + session = cls_session->dd_data; + if (session->max_r2t > *max_r2t) + *max_r2t = session->max_r2t; + return 0; +} - /* R2T pool */ - if (iscsi_pool_init(&tcp_task->r2tpool, - session->max_r2t * 2, NULL, - sizeof(struct iscsi_r2t_info))) { - goto r2t_alloc_fail; - } +int iscsi_tcp_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) +{ + struct iscsi_task *task; + struct iscsi_tcp_task *tcp_task; + int max_r2t = 1; - /* R2T xmit queue */ - if (kfifo_alloc(&tcp_task->r2tqueue, - session->max_r2t * 4 * sizeof(void*), GFP_KERNEL)) { - iscsi_pool_free(&tcp_task->r2tpool); - goto r2t_alloc_fail; - } - spin_lock_init(&tcp_task->pool2queue); - spin_lock_init(&tcp_task->queue2pool); - } + iscsi_init_cmd_priv(shost, sc); - return 0; + /* + * cxgbi does not have access to the session so we use the max of all + * sessions on the host. + */ + device_for_each_child(&shost->shost_gendev, &max_r2t, + iscsi_tcp_calc_max_r2t); -r2t_alloc_fail: - for (i = 0; i < cmd_i; i++) { - struct iscsi_task *task = session->cmds[i]; - struct iscsi_tcp_task *tcp_task = task->dd_data; + task = scsi_cmd_priv(sc); + tcp_task = task->dd_data; - kfifo_free(&tcp_task->r2tqueue); + /* + * pre-allocated x2 as much r2ts to handle race when + * target acks DataOut faster than we data_xmit() queues + * could replenish r2tqueue. + */ + if (iscsi_pool_init(&tcp_task->r2tpool, max_r2t * 2, NULL, + sizeof(struct iscsi_r2t_info))) + return -ENOMEM; + + /* R2T xmit queue */ + if (kfifo_alloc(&tcp_task->r2tqueue, max_r2t * 4 * sizeof(void *), + GFP_KERNEL)) { iscsi_pool_free(&tcp_task->r2tpool); + goto r2t_queue_alloc_fail; } + spin_lock_init(&tcp_task->pool2queue); + spin_lock_init(&tcp_task->queue2pool); + return 0; + +r2t_queue_alloc_fail: + iscsi_pool_free(&tcp_task->r2tpool); return -ENOMEM; } -EXPORT_SYMBOL_GPL(iscsi_tcp_r2tpool_alloc); +EXPORT_SYMBOL_GPL(iscsi_tcp_init_cmd_priv); -void iscsi_tcp_r2tpool_free(struct iscsi_session *session) +int iscsi_tcp_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) { - int i; - - for (i = 0; i < session->cmds_max; i++) { - struct iscsi_task *task = session->cmds[i]; - struct iscsi_tcp_task *tcp_task = task->dd_data; + struct iscsi_task *task = scsi_cmd_priv(sc); + struct iscsi_tcp_task *tcp_task = task->dd_data; - kfifo_free(&tcp_task->r2tqueue); - iscsi_pool_free(&tcp_task->r2tpool); - } + kfifo_free(&tcp_task->r2tqueue); + iscsi_pool_free(&tcp_task->r2tpool); + return 0; } -EXPORT_SYMBOL_GPL(iscsi_tcp_r2tpool_free); +EXPORT_SYMBOL_GPL(iscsi_tcp_exit_cmd_priv); int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf) { @@ -1223,8 +1230,7 @@ int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf) return -EINVAL; session->max_r2t = r2ts; - iscsi_tcp_r2tpool_free(session); - return iscsi_tcp_r2tpool_alloc(session); + return 0; } EXPORT_SYMBOL_GPL(iscsi_tcp_set_max_r2t); diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h index 7c8ba9d7378b..4d502f61a948 100644 --- a/include/scsi/libiscsi_tcp.h +++ b/include/scsi/libiscsi_tcp.h @@ -89,6 +89,9 @@ extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb, extern void iscsi_tcp_cleanup_task(struct iscsi_task *task); extern int iscsi_tcp_task_init(struct iscsi_task *task); extern int iscsi_tcp_task_xmit(struct iscsi_task *task); +extern int iscsi_tcp_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc); +extern int iscsi_tcp_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc); + /* segment helpers */ extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn); @@ -118,8 +121,6 @@ iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size, extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn); /* misc helpers */ -extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session); -extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session); extern int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf); extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats); From patchwork Sat Apr 3 23:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415108 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 BA41FC433ED for ; Sat, 3 Apr 2021 23:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80BAB6135E for ; Sat, 3 Apr 2021 23:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhDCXY1 (ORCPT ); Sat, 3 Apr 2021 19:24:27 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44924 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236940AbhDCXYO (ORCPT ); Sat, 3 Apr 2021 19:24:14 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NLnO6098586; Sat, 3 Apr 2021 23:24:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=zkNnC5Zr/pyTVSPyvFmOs3tX4G4i76Ec274o9Fpsk5M=; b=dWYDlE2NTXL+rPVKMSRWxSYL+yaEMP9xNOv5e9CLLKN5MHCqw9Yh+2eNS9byFlk3oN83 dcqv3yXu3BfX6JDfhXO4YdblKJyullPXhg8ETk/I4bdpvNdx14259rN5yzZ1aF7fqJBc lDYr1mOW9g4TQVj+pA+ZLYXZ7rKoK8OmXbOvdHnTcx6J/5McskGBhBLHMxGdUDIYFyMF VgtAEXliIn9Cjv6RMiIaJPxwKXZ8wGcHlq7ib5MjxRDZ3IdgBov33DrmLpQPnGRMQ6QP rMxTKE/BXQDPraUk5dn5y0jpFtxi9WA1ViYpQv2T6rAzbXtbtfups8nRg/cdGmoMD6Wd Wg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:02 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NKDHP132673; Sat, 3 Apr 2021 23:24:01 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2052.outbound.protection.outlook.com [104.47.45.52]) by aserp3030.oracle.com with ESMTP id 37q1xk81k3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mezvyiIpVGMfeAV0OF97DXHE7vmMZELvNPbJ7v36RxdYOXDmDlVfpSD0uxi3G8LmKlH+Ja3u3vMKUO4gaab4FCKIvHdjRmgxKYGbjqrP5I+bWcIwhWhh6jxDYyFRRdZnaC4osJN41LrsIE54+lsGFLMkrpLquadD3EPSzicqyQ6Iw+kV1wvTmZNdlJDNC7R4qnyuL7dHUgwXAlGHOzyz4wrpvGftBdMDanVR3MNsqyuEqAog7eEFtRSuQeYar8jFmSyI+UD2E2nL7XnC0KZOtfWE+8D39IIX8H5IVxysqDpr4dq63hiFLwrY1ytZqbsffIZIo35VGRipmLpujurz+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zkNnC5Zr/pyTVSPyvFmOs3tX4G4i76Ec274o9Fpsk5M=; b=TeffIAm01xI4YmEGzVTqeEVaqzfJPXYan3D6aCJvEOcrh3CZ0h6uB5MODPisUOSFW4az+51QBdvHhszTcZ+MVqCAopi/780BD1ZnSRp7WPmznG9HzKpX30T25cNhGlYx/rzHBfbRMTp3aYxfMkoyn2aakAM31DpTQ33WAg78uqp/8IF8VPmMbJJNKYeZ3hc17hBQkOEfptRH4FfimXHMP+4JYmX7404CA3nT0u+XlXR7AQcnk7JV84vWh7CqE7a1M3dIyR+eYcZM79UOrYLtWs/oD4LWcUO4lHhPjKpzbf1FQrWIJ160HpU7K22O6tpoBp3LGm8DTzCRcDUKiFF0QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zkNnC5Zr/pyTVSPyvFmOs3tX4G4i76Ec274o9Fpsk5M=; b=v8GK3txCeX6yNSg4JD7dgeOFwSWbR5fjK4iRyiAEZDpmHiRAAGz4NTEHAeCA5Roh1FCpoCrT/7tDhLd2JWXgWRp4KUH8AqZ9Tp9JIsnY1nNcK4dscHjy3HrfQrsaFpgrvQiMck72paE3QG5qBpBeUje+maDfz6OJkM2uCIuXdmE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:00 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:00 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 12/40] scsi: libiscsi: use scsi_host_busy_iter Date: Sat, 3 Apr 2021 18:23:05 -0500 Message-Id: <20210403232333.212927-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:23:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef46426e-6090-4be8-ddaf-08d8f6f78fa1 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:330; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pynhm+38Wr0OWBE42PK32vp5tQSNUtxNkNLuYvo4G0Teu3mh/SIpGLmQW0pOJTMiEruin3pULD7pflbF2xgjbWIjVOfJlxZAD56qPMLIO8nbLVsAzxySJqaCtcRiXyp8hONxHH11byKcgw7MRCDEaINsRaqOLIhtpBTAJe+V3pBm59JYY6ob4HBQ8JGzZPbP9stx/q80iYk8MKrIyZ1fX0QZEpbMNvYGzbjsPB52dfRki9/8WKuVGYciGLfTGUDWuxcJnNUm1EEX9LCROgo0rP8W7KY+uTXXs5uPqC+Sv6UWJOPaWcas2/vSnQbJPdFgUWCsyXxsqAmzWndVeIhlBhU+gHDPPwiBcPoYHZ+v6bnhO/uVZPgyDZBxUojdUt0r+TUL8hRX/VKYvpp4puJdfXz9Cz+Ilk/xDBcXH0hrddaoYsg4pL8kj7BeSLdWq0kyOORRTl7lKgc44CFrjaP2f67DcKzLKw5A6uhmspMAxEne2r4s1pvS9SqPqPnNMyIpu0/qyUYwhKftwa7w6Vx9iT8oKZ6OiaEdieD35KRiqUun/ed9tGL/T8FDUCIwdAIMxyJZ8KuFz8HdABVeok94HSIJ2k2yjr34giltxGI/8Q9qnoMrMa1wlUjMHsK/ryEG/F30/uNlxIdLU9sS/5hHyqGdZX5qB08LerQq6T6gE82P4iIhBC/ghkf9RRqYofDJO+L1NyUYqhwf5Z2EJzi6Hw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AORdV6bhb62vHpZR5n0SLuIms2guf3Wzu4J7RR1deEOQGWyZVsL2r1Z8hWGsa4rYw809FHb9FiSCIS9AosGFW/MjoOIU07n+eIKgcvap4J67XLsilMvq/thAUAWo5p9eCyMZ/SYbQb2UqIbYJ0YglClzx2/ub6EdWPnCXZtU3mT/c1cc1Z4k0Cxmv93tdiPPZhGg/CU6eSvD3z2Pw/JgpoEJ9sbrc/GDSFyoQN1R9MWyzdN6k9yGB9AT7uN3lsqFkr03k0+VWufC7cJW90O5ULJYYcq57SM8smQ6J9ylna/EnEPk+6mEAegI9FNbsewYerLjSf4I8s1onaeCitoAb1RkPOOr3OM2dWkiYvMcf3szv0x175eN7B/nAWYb1TFtSq6V8vkplUO2/R8QD8+pitKwFq5vpCZIloT3E41IuDnDwBDbfvTTmDJwMDTC6DzVT0uesT1ub7ARKm+3zYt8q+cONn0DssKQQs+bSJQZgjDWWJFjQ6OUlubAgjz66iQ5B2AE0YDoGGL3gLwabC33xI9xnWSXSWtp3k7Rbw9oZVCEC4Sv0/Ny/83mo0TEfqMQRCdAB148/ZcrWWmdqLhQKOpmdi3rrwKyrc0Hs+vesD/JeVulMeQmpZIDJQ5XLNCfOMwb3yHuvMLIF9lj8nERw3qg6R53BhRTmxSMGid88Q6nOJDE8ytpIFTXRx8Ohdx2vi0NndP92ycxyMQRIe+OiJOx7LG6FqOVdPS4izLo5KMcpGRQg2DCzNuM3Ptw/rAYgiPmCdzcC5yT4DLZ2WSm5PoxC8UuyzSp26C5eCYeb1qamj+TID4VkFgJSlF0vy7LqFxUs2vEuES/0USVFAHnXH2uTIWgV+MUj6MIRdeMZ9s9STP/2ILCXLgl61yBpL7M71DZs2/69X2U/r9BDdHwG4BcktwN/5rqMKypEKTZlkR5J8GSDO0wwAwnEERa9LzN0QpQXiwwGHE9/WSnnrjJmk4UT1HwWSkuv1sze9EJEiHjJLpriSoV0JznlnoLGj3YAd7ieLVcjkgeaCWcPqlNejT9Dzg4tcBJJia8+eg8HP6ffx5DuUEnzGp5hn6cbuwIp3172nebOHRczTsdWWRbPixHzazTcbVstlE67e/rjoh5nGITw0/0Z7kgLicrQii+LfEE596psANNwKf9h2yq0Ey+Ln/gxPQd2uE1BtCDthLpqZHO38N0QLhqy5xYQUGZvxCeY1BfPy/nE8m83asFzLUKVHfoQxwo8s1QynDFz12I9F/RotiopH76YWr/eJews7qDo2Lo4qGk07Nn475JHF+SHy7LDz3xbzA4jS3MTB9yNLEWtvJGjE7ziS5zBlht X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef46426e-6090-4be8-ddaf-08d8f6f78fa1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:00.2348 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ylDBFujb552EcqKLT8vpQeI7DtSCn3wPCc/6NPy4/eiiea/1ntvTI8uD6ZhmIvMGtF3yjCgFNAWKPiHMoPpEghZVaym8I1KbF4Kk+Wv1xQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: seokZxHB-D4dZSSiN_bnQ0K6Q4z70MIh X-Proofpoint-ORIG-GUID: seokZxHB-D4dZSSiN_bnQ0K6Q4z70MIh X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patches remove the session->cmds array for the scsi_cmnd iscsi tasks. This patch has us use scsi_host_busy_iter instead of looping over that array for the scsi_cmnd case, so we can remove it in the next patches when we also switch over to using the blk layer cmd allocators. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 160 ++++++++++++++++++++++++---------------- include/scsi/libiscsi.h | 12 +++ 2 files changed, 110 insertions(+), 62 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 07b23f3967a9..8a9a9f5801e3 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1909,41 +1909,69 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, return 0; } -/* - * Fail commands. session frwd lock held and xmit thread flushed. - */ -static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error) +static bool fail_scsi_task_iter(struct scsi_cmnd *sc, void *data, bool rsvd) { + struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_sc_iter_data *iter_data = data; + struct iscsi_conn *conn = iter_data->conn; struct iscsi_session *session = conn->session; - struct iscsi_task *task; - int i; + + ISCSI_DBG_SESSION(session, "failing sc %p itt 0x%x state %d\n", + task->sc, task->itt, task->state); + __iscsi_get_task(task); + spin_unlock_bh(&session->back_lock); + + fail_scsi_task(task, *(int *)iter_data->data); + + spin_unlock_bh(&session->frwd_lock); + iscsi_put_task(task); + spin_lock_bh(&session->frwd_lock); spin_lock_bh(&session->back_lock); - for (i = 0; i < session->cmds_max; i++) { - task = session->cmds[i]; - if (!task->sc || task->state == ISCSI_TASK_FREE) - continue; + return true; +} - if (lun != -1 && lun != task->sc->device->lun) - continue; +static bool iscsi_sc_iter(struct scsi_cmnd *sc, void *data, bool rsvd) +{ + struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_sc_iter_data *iter_data = data; - __iscsi_get_task(task); - spin_unlock_bh(&session->back_lock); + if (!task || !task->sc || task->state == ISCSI_TASK_FREE || + task->conn != iter_data->conn) + return true; - ISCSI_DBG_SESSION(session, - "failing sc %p itt 0x%x state %d\n", - task->sc, task->itt, task->state); - fail_scsi_task(task, error); + if (iter_data->lun != -1 && iter_data->lun != task->sc->device->lun) + return true; - spin_unlock_bh(&session->frwd_lock); - iscsi_put_task(task); - spin_lock_bh(&session->frwd_lock); + return iter_data->fn(sc, iter_data, rsvd); +} - spin_lock_bh(&session->back_lock); - } +void iscsi_conn_for_each_sc(struct iscsi_conn *conn, + struct iscsi_sc_iter_data *iter_data) +{ + struct iscsi_session *session = conn->session; + struct Scsi_Host *shost = session->host; + iter_data->conn = conn; + spin_lock_bh(&session->back_lock); + scsi_host_busy_iter(shost, iscsi_sc_iter, iter_data); spin_unlock_bh(&session->back_lock); } +EXPORT_SYMBOL_GPL(iscsi_conn_for_each_sc); + +/* + * Fail commands. session frwd lock held and xmit thread flushed. + */ +static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error) +{ + struct iscsi_sc_iter_data iter_data = { + .lun = lun, + .fn = fail_scsi_task_iter, + .data = &error, + }; + + iscsi_conn_for_each_sc(conn, &iter_data); +} /** * iscsi_suspend_queue - suspend iscsi_queuecommand @@ -2005,14 +2033,51 @@ static int iscsi_has_ping_timed_out(struct iscsi_conn *conn) return 0; } +static bool check_scsi_task_iter(struct scsi_cmnd *sc, void *data, bool rsvd) +{ + struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_sc_iter_data *iter_data = data; + struct iscsi_task *timed_out_task = iter_data->data; + + if (task == timed_out_task) + return true; + /* + * Only check if cmds started before this one have made + * progress, or this could never fail + */ + if (time_after(task->sc->jiffies_at_alloc, + timed_out_task->sc->jiffies_at_alloc)) + return true; + + if (time_after(task->last_xfer, timed_out_task->last_timeout)) { + /* + * The timed out task has not made progress, but a task + * started before us has transferred data since we + * started/last-checked. We could be queueing too many tasks + * or the LU is bad. + * + * If the device is bad the cmds ahead of us on other devs will + * complete, and this loop will eventually fail starting the + * scsi eh. + */ + ISCSI_DBG_EH(task->conn->session, + "Command has not made progress but commands ahead of it have. Asking scsi-ml for more time to complete. Our last xfer vs running task last xfer %lu/%lu. Last check %lu.\n", + timed_out_task->last_xfer, task->last_xfer, + timed_out_task->last_timeout); + iter_data->rc = BLK_EH_RESET_TIMER; + return false; + } + return true; +} + enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) { enum blk_eh_timer_return rc = BLK_EH_DONE; - struct iscsi_task *task = NULL, *running_task; + struct iscsi_task *task; struct iscsi_cls_session *cls_session; + struct iscsi_sc_iter_data iter_data; struct iscsi_session *session; struct iscsi_conn *conn; - int i; cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; @@ -2091,45 +2156,16 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) goto done; } - spin_lock(&session->back_lock); - for (i = 0; i < conn->session->cmds_max; i++) { - running_task = conn->session->cmds[i]; - if (!running_task->sc || running_task == task || - running_task->state != ISCSI_TASK_RUNNING) - continue; - - /* - * Only check if cmds started before this one have made - * progress, or this could never fail - */ - if (time_after(running_task->sc->jiffies_at_alloc, - task->sc->jiffies_at_alloc)) - continue; + iter_data.data = task; + iter_data.rc = BLK_EH_DONE; + iter_data.fn = check_scsi_task_iter; + iter_data.lun = -1; - if (time_after(running_task->last_xfer, task->last_timeout)) { - /* - * This task has not made progress, but a task - * started before us has transferred data since - * we started/last-checked. We could be queueing - * too many tasks or the LU is bad. - * - * If the device is bad the cmds ahead of us on - * other devs will complete, and this loop will - * eventually fail starting the scsi eh. - */ - ISCSI_DBG_EH(session, "Command has not made progress " - "but commands ahead of it have. " - "Asking scsi-ml for more time to " - "complete. Our last xfer vs running task " - "last xfer %lu/%lu. Last check %lu.\n", - task->last_xfer, running_task->last_xfer, - task->last_timeout); - spin_unlock(&session->back_lock); - rc = BLK_EH_RESET_TIMER; - goto done; - } + iscsi_conn_for_each_sc(conn, &iter_data); + if (iter_data.rc != BLK_EH_DONE) { + rc = iter_data.rc; + goto done; } - spin_unlock(&session->back_lock); /* Assumes nop timeout is shorter than scsi cmd timeout */ if (task->have_checked_conn) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 11f0dc74d4c5..5a5f76adbca3 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -469,6 +469,18 @@ extern void iscsi_complete_scsi_task(struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn); extern int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd); +struct iscsi_sc_iter_data { + struct iscsi_conn *conn; + /* optional: if set to -1. It will be ignored */ + u64 lun; + void *data; + int rc; + bool (*fn)(struct scsi_cmnd *sc, void *data, bool rsvd); +}; + +extern void iscsi_conn_for_each_sc(struct iscsi_conn *conn, + struct iscsi_sc_iter_data *iter_data); + /* * generic helpers */ From patchwork Sat Apr 3 23:23:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415107 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 A1CDCC43460 for ; Sat, 3 Apr 2021 23:24:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F2406135F for ; Sat, 3 Apr 2021 23:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236940AbhDCXY2 (ORCPT ); Sat, 3 Apr 2021 19:24:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49786 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236956AbhDCXYS (ORCPT ); Sat, 3 Apr 2021 19:24:18 -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 133NO4Te162545; Sat, 3 Apr 2021 23:24:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=p40n1bd20cr1m6MtdJ5XHV4tBBzC41ZMwVLt5dIExxo=; b=kXzMtE1JJMQG6ND7HLudaAigUiRDk+yDZnplRuTpZhXU0M3WH1cTrSJAvWrk5Fu8Pbcn gRBBsV59OyhLVuVuAytpt+6psF3FdgojEQTrqtpd4XstojwDxCDELFlv/zeI9VElZ1j3 Q+unwxZZ9J4hoiW7lXFtDJjQtVjM9jLlxoQURXQW8KGwyxcgRi0mOPX3nUIF9K82NlDk dfvJcmt/H3Zctkm9k4GjAkexDN5cioqCZzjSSkEcLz1C+oT+6aK8Ddav6jMi0F3FOII0 r9lq9MkUXzQuuROcKmc26YfdZTgT+5Y04a1HS2cfTbWtZ/hO5eRW2a+DXsI81b/VYkm/ wg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:04 +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 133NKsHS116809; Sat, 3 Apr 2021 23:24:03 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2050.outbound.protection.outlook.com [104.47.45.50]) by userp3020.oracle.com with ESMTP id 37pfpkbsnv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVFB+XQibOl2ijzJXl4Yj/rhIy22f6NK/X/ErOoXad9LecEsZGYw4Tj9aG2J3vpAGD3Iu2kUAR5hZSFrl+fjJnyvSh25qkere1wtJxxLw5zzvrqnH6VySO7ap/RIDU4XxfpbOKsm3YcI3je4uwYaIlbLbuGnNP7E0giG4gcFVyX8KoG/UijQuDLlEUPshDDDzgbZ7DjkJcKU8hlNOApaT5g78LJDZ+lNwdZaJHhqy/hBzvZfB1Lz6IlQ8vjLBHqT/lMaEZLeS1TiPs/ZaWIQN568c2GS8Y/7vdi93+V/cWzp26utoL4BFZnefJVKSVW1RXY1zP0RhH1l4N1TwrnNog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p40n1bd20cr1m6MtdJ5XHV4tBBzC41ZMwVLt5dIExxo=; b=OVVXDp5BWLfCx24VaOdVu95TEg+p56HclZ3Kp2tek/gX5M4UR3r9jyPVz3b3nAJWplCr9oXJH339+zAg6LNJuTIQaKalawgK7S0LyAaPSSzcvap1CJCunEzsXXj7PaCsfmV4Wp0NgUOWA7m6BCJAeCCgL90tROCebItlpE+qhp/9k5QN1xwcjbbmd7Kli0GFAyfkrMWWGzqlzRoRPWGoRRDABftVKWVo3sEfRmjADCgo2x3pXp3lL7bj3937YwlV4E/6pbaeDtrGAlvh6LSj06NQrSGA0OmLe1U7ABQIsM/2EEJYthnbFBF2q5wxZ9JENgyvGaqUzeGB8oh8ErcYgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p40n1bd20cr1m6MtdJ5XHV4tBBzC41ZMwVLt5dIExxo=; b=Y0GfrCmgzS8P7c6/yf+Xy6U6vWwzI/sTcv2Ge99uZLLnGkSOTGeIxoSwOXYoEv42psptFKF5FVXzVoWqYvGCV9piQmC+q8Bv8jLBMYzIERgVEoB4D6E/e/jn39motw/QTWJCaLdWgtxhLUPxuRkph7adTPJTs3dH9HsEvxv4VX8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:01 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:01 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 13/40] scsi: be2iscsi: use scsi_host_busy_iter Date: Sat, 3 Apr 2021 18:23:06 -0500 Message-Id: <20210403232333.212927-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb7ac6ae-7d6e-415e-eec4-08d8f6f7906b X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P2Y9dWNxEPK56dpUkewB0xaNFilak/dkkr5HvG9PGdvLOc2DKPN5fqe4++RD2VKht+Le5N23olsTP5mfJT/GsdByqTupC6AXOzLKEK1aSueb4aN90yJavcZrVHms61WYAvAxeaUneBLMkGMVWS+mplNAVnmIMyjFbpG/gwaIs21vDQviKl3PPWP84vLlVIQWmd82EB0AFNwlju3CfBrmycoyWBDrD1yKgBhkeQR71NyBQFehzQMEid0MIFSg1HekGPrTIIeuX4DWeFl1FuRP/uJ6t/P6r2Rf5YeOQkUDFnLkKwGJ/LYeCm8dG6hV8C7wifTZKLVy4LHtZOS2Y3RF4lZAJVBLnKfzav+gYLK7S0kQQjQFvboilMWdopxg1hPjF7J/zi1GclDtRQmvrneDIODeg8NGXhmLaRjo2NWWeRow7iu0evYZN/zMG/ZSYzHesJZw67BTQ2uFMh7e9xDnx55Jp91D5dO7AkWWsl3o/FUETyQYFyorf4IcKcStNtBBlq/X1pYQ756uBsEqketMSemu/nYDPGPaO1x19UGrHCuCPlSNGDRBqMmFyMPs3k3iCwbQ3eNmBh9uyWeHHd14BpexmCsEHRi3Bt1IPGxxkxH3058gorkZJYOiWSHy5KaXbnrzmoTPpYxj+AFeQamj2Lp/efPYFlDGl5WrTt9U4fCrwXCeXT6HDvFl+AR5BPtrb5ssaHyhz8lPKH5ftc37SA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uHpoUgJ4ei9HszzdEKeLB+4teI0oo39ILMckykBPLf3KrEXKDCTKYnvWgpyDDBcU6uAX9ZRwtPIiDAMa7MnzRscOo0QZdOr/zBGXxXDiJSXGLYIvErjacJdmelZyzI4q/p40x5uzYzwSeQqbfih3sJXOmefw3FwtIw99bOzGiGxAHW+EArFfpB15yOsLZkXpQcAzU+zKigzHpFxL7PPLyKNtGFdMGrSCdm71+Bj2qydn/AWkJTwDN0IMu4zBtsRojVX9nrG22QSqJlndxbg9zYPncYZFdja+5fIyO4E7HEEmhgor/d/aJ9DWQX3yMa8hAtZskdRvMNte+FNmwhKCBYHwH9GRT/w8cnGR4lBZNU3wEKPi76N6V11pZkCYzyhO6IHivk/YCbsixfQfSOFMxUzahmA6QFqXIAAS9T/+EdE+NSOT22fGjM6t7wEEfDBhKEzrXsGrLP0fJXKiHHEUDyPS8qKyna1BdBQa1gdc401BHX3/b5/J+iqupHjpkWQlfYHmZxskhgIRM9KnePkHfb0wyo6Ih1RIbC6yF3HSLSgb4OjoTj2m6T4DGCqzQA3XGdg+3fI1wnc1OeMbCmVQhp3I6YBH/L9IN4t88ZEjigk0r65DkR7PyQC+yq8SRX9T6J5YXpWbM22U7Vx+Jrk32Hr22k5VPRPlRvd1mOK5DOpunvJ4Pet6Sok6tpiD2OcyOJWYjRHR4FXIEZZ8Rw2OfwB5LmbbIpW+TuJ0eaUxFuBDJijNDduF4xCmDk92omJlLGnW4TtVOuJZvHrLyXy0D+eSJHeIRis1z62NbOGnuRkmezczTIecYIJl8/fsbTlPLpYO0moGSgnQLUYD42rVhbVoP49emvMAC46uhK39rzJ6eZu6tLKJQhvHjR/rBIH6UcV7fazFWI0TAKStlSwph9rHeSmuSG2oEpMZPoOdS/J/Jun9nxc68qM/KVzEGktWjjxPNSfVW8teOqzXewvS59czYpzIoqshyxnSuezLjpThMliRd6/D7SlwgVuQTX3hQljyy37FWTLHqj1QiC8hUXgmCRzLxJ/MT9ts0wccS7L5PGYZsV6IGDP1GiTP7VC7Xg+VvDeWA6GLsWWmAcql2pn3SggSwJfai7nSCJ3EdNe5OqJp07tD5lLAoLe9BLg8Wl0uoCeRsd2liZ8qXxvrfynGVBB92WDro4IUp9pXnixTw/1fI8Yl771o7o6aJntEVT6aFtXeF12oN+4Bx6sWvKGcOM6Orkt2eqlKI6h/kFS533FkpRfp3Oxj4E/jfy+NZ8+C7GWt8O1YMaKwO312MhXLPDf5kg40lf5E4516/9gYV+OJIoX+0khxqdssj68P X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb7ac6ae-7d6e-415e-eec4-08d8f6f7906b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:01.5161 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6k+XKYYeNbp9rqIJJDkO0cUqXgjsJ6h+bw5ep5I1hjOucHXI1GXiqbemZMLbFT4kRFvwfPbSRhgDjtDplne7gppuB6bIEsYlEwRoGctV72U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: ed4VM3oRAU9WqCpwoDiqSd0yu3PMcQlW X-Proofpoint-GUID: ed4VM3oRAU9WqCpwoDiqSd0yu3PMcQlW X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the iscsi scsi_host_busy_iter helper so we are not digging into libiscsi structs and because the session cmds array is being removed. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 108 ++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index bcb12e674795..4d4e3d606e25 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -265,21 +265,63 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) return iscsi_eh_abort(sc); } +struct beiscsi_invldt_cmd_tbl { + struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ]; + struct iscsi_task *task[BE_INVLDT_CMD_TBL_SZ]; +}; + +static bool beiscsi_dev_reset_sc_iter(struct scsi_cmnd *sc, void *data, + bool rsvd) +{ + struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_sc_iter_data *iter_data = data; + struct beiscsi_invldt_cmd_tbl *inv_tbl = iter_data->data; + struct beiscsi_conn *beiscsi_conn = iter_data->conn->dd_data; + struct beiscsi_hba *phba = beiscsi_conn->phba; + int nents = iter_data->rc; + struct beiscsi_io_task *io_task; + + /* + * Can't fit in more cmds? Normally this won't happen b'coz + * BEISCSI_CMD_PER_LUN is same as BE_INVLDT_CMD_TBL_SZ. + */ + if (iter_data->rc == BE_INVLDT_CMD_TBL_SZ) { + iter_data->rc = BE_INVLDT_CMD_TBL_SZ + 1; + return false; + } + + /* get a task ref till FW processes the req for the ICD used */ + __iscsi_get_task(task); + io_task = task->dd_data; + /* mark WRB invalid which have been not processed by FW yet */ + if (is_chip_be2_be3r(phba)) { + AMAP_SET_BITS(struct amap_iscsi_wrb, invld, + io_task->pwrb_handle->pwrb, 1); + } else { + AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld, + io_task->pwrb_handle->pwrb, 1); + } + + inv_tbl->tbl[nents].cid = beiscsi_conn->beiscsi_conn_cid; + inv_tbl->tbl[nents].icd = io_task->psgl_handle->sgl_index; + inv_tbl->task[nents] = task; + nents++; + + iter_data->rc = nents; + return true; +} + static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) { - struct beiscsi_invldt_cmd_tbl { - struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ]; - struct iscsi_task *task[BE_INVLDT_CMD_TBL_SZ]; - } *inv_tbl; + struct iscsi_sc_iter_data iter_data; + struct beiscsi_invldt_cmd_tbl *inv_tbl; struct iscsi_cls_session *cls_session; struct beiscsi_conn *beiscsi_conn; - struct beiscsi_io_task *io_task; struct iscsi_session *session; struct beiscsi_hba *phba; struct iscsi_conn *conn; - struct iscsi_task *task; unsigned int i, nents; - int rc, more = 0; + int rc; cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; @@ -302,56 +344,28 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) "BM_%d : invldt_cmd_tbl alloc failed\n"); return FAILED; } - nents = 0; - /* take back_lock to prevent task from getting cleaned up under us */ - spin_lock(&session->back_lock); - for (i = 0; i < conn->session->cmds_max; i++) { - task = conn->session->cmds[i]; - if (!task->sc) - continue; - if (sc->device->lun != task->sc->device->lun) - continue; - /** - * Can't fit in more cmds? Normally this won't happen b'coz - * BEISCSI_CMD_PER_LUN is same as BE_INVLDT_CMD_TBL_SZ. - */ - if (nents == BE_INVLDT_CMD_TBL_SZ) { - more = 1; - break; - } - - /* get a task ref till FW processes the req for the ICD used */ - __iscsi_get_task(task); - io_task = task->dd_data; - /* mark WRB invalid which have been not processed by FW yet */ - if (is_chip_be2_be3r(phba)) { - AMAP_SET_BITS(struct amap_iscsi_wrb, invld, - io_task->pwrb_handle->pwrb, 1); - } else { - AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld, - io_task->pwrb_handle->pwrb, 1); - } + iter_data.data = inv_tbl; + iter_data.lun = sc->device->lun; + iter_data.rc = 0; + iter_data.fn = beiscsi_dev_reset_sc_iter; - inv_tbl->tbl[nents].cid = beiscsi_conn->beiscsi_conn_cid; - inv_tbl->tbl[nents].icd = io_task->psgl_handle->sgl_index; - inv_tbl->task[nents] = task; - nents++; - } - spin_unlock(&session->back_lock); + iscsi_conn_for_each_sc(conn, &iter_data); spin_unlock_bh(&session->frwd_lock); - rc = SUCCESS; - if (!nents) - goto end_reset; - - if (more) { + nents = iter_data.rc; + if (nents > BE_INVLDT_CMD_TBL_SZ) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, "BM_%d : number of cmds exceeds size of invalidation table\n"); + nents = BE_INVLDT_CMD_TBL_SZ; rc = FAILED; goto end_reset; } + rc = SUCCESS; + if (!nents) + goto end_reset; + if (beiscsi_mgmt_invalidate_icds(phba, &inv_tbl->tbl[0], nents)) { beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, "BM_%d : cid %u scmds invalidation failed\n", From patchwork Sat Apr 3 23:23:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415238 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 3ECA7C433B4 for ; Sat, 3 Apr 2021 23:24:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03BE661361 for ; Sat, 3 Apr 2021 23:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236989AbhDCXY1 (ORCPT ); Sat, 3 Apr 2021 19:24:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49772 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236924AbhDCXYQ (ORCPT ); Sat, 3 Apr 2021 19:24:16 -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 133NMCZS161763; Sat, 3 Apr 2021 23:24:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=1JwGlMMx/7GZe06clootYOICZGarTrVac4e4b5MrrEo=; b=ZgHKyuEcqqqJOTiSFXdqr8TPIU5ttT5mxCyxFX57DsEqmKakGdtnPIqNJfxCf0gQOCYl HOnjCHY+AzHjTB53ABbDmRHW1NEAsumQATTU/vzrJ0j1sIdtiM4R77mVw7OCoVdLqHVY 71ZiCRVRUY96hPrm1lQkjFEBPfE9VQyQVsfiFIHFxEqUr6mtJecS9vN9/qD97cOJigG9 oMo/bVtxKfRvl6ZIDYQ6N7RrSO3fwmBYAlQvf+i3sC/Pp9TwaJUh5c5lFnCNsn0Bcd9P jGa5DzDxiP2SqWKf1B8iERKm1Ze7E5zx0Ib9hV7UDUEUZ5S8nE3wIN0WC/HG+f1cIGqJ vA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:05 +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 133NKsHU116809; Sat, 3 Apr 2021 23:24:04 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2050.outbound.protection.outlook.com [104.47.45.50]) by userp3020.oracle.com with ESMTP id 37pfpkbsnv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aO5U+i6E/qQ7UhbWtWn2gONyCdKEZOuiZKE2nW+4lUnYGT7BcN3X7HSVPjQgGDVtNIux22/K3t89sE7rSGWEtR9KzGHY/ergKhWvCOi5ZdKN1JhOr90R81rtrpNDy1q3iUO+EGFkFHFQIs4ClydGq7EJNUAytQrJBQ7DUNkHNU7oiIpm6mvVYymRwr1Q+F58dqcTNmfPMekfLtoKLEqY+3ex8Kga0gw3dAdmitzFVTN1y8hsmWhxHitvZL1SgyejtMuAUNKeDR2eS1ytxcJJFeWUOTRvpeOXdjwSOT78oxMlBdETsJNWaaNyvAOM+BvGbvoUW9ZWelTcYUW+af86Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1JwGlMMx/7GZe06clootYOICZGarTrVac4e4b5MrrEo=; b=fa4OaZe9SCGrDMhWnh6InHgEFD452Jwa1Xx32Cl02aS5BMAMh1Zc5zJVrUzcEmVPBob2w+f2gQJxa6v6ao7RrB9IRQfPwDAtNMEkoVhT/t4heEs/7t+Cq7eAqnHuTlPGk1DHDlbon1MnwuHXqsUb9e+9qC8ooFKR5GYiOlg4bY6E7diGc23JHG5INJH8L59djYOSTAsPVaPgYX4sOG6WCVd7Vr+2FxIkJWIAYA9NcghYdbHErN769E3HX+M/gMKyyJAMQpOfmlyYPkXCajCLz44/LAa+q5XR45lgQVEr+5i8CBtxm8ir8WNivpWz050RpdVB7JipBX1IBughoXGnKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1JwGlMMx/7GZe06clootYOICZGarTrVac4e4b5MrrEo=; b=D2h65H18q0OrivOgl7JL6srxv3ow2PDLbxB6St3zHLC+PkXsk8x8nm5ELMnonY1XWAfs4BNh9eofOWiQxKrnmFXSBK4GbKsoHLbtCLr1Q7xwwR6AEPLWTGsu5xe4ccUFVuqHH70q/JAXduy5PMgpmw4hj+5BqBUEUL0QiuPvHD4= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:02 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:02 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 14/40] scsi: libiscsi rename iscsi_complete_task Date: Sat, 3 Apr 2021 18:23:07 -0500 Message-Id: <20210403232333.212927-15-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3293236a-8979-4356-1e8a-08d8f6f79131 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0HpJoeu0ohtDIWQqgMFmnPylTlme5JgJoTjs50NZUeIWmc8Q/VuKW/mf5wxX7bm9vKZUaNxDu/42csEWkRrGq5NPX+obDdrQO2Rg+xJ4Kv+AwyB52C047PHMePgnsJ7UKVvrfI6hyWlfMNoYNTJ4r6cTB2mTApTPagjPGgI1t0928mbOnayrcZi+qkH3FVJ60JEHoakzR2An/UY3sCrf9qcKPs4BZjKpCAQEkr+QWF8wZu6Y3PDhYaDXkTIQlewrvmL2Q2gn6jvXo/7B5uUNliebOxKSNMzv9qlIYVphciaY1DfHL65Pfa1frUL/f0kwhJ0JYCGLPIwXtpdhSulVenVk76rExSuEfCp6ggwogo65nBxG8bDzq1y12nHAIkqXz/FTTUSMeRlrtUrT2wt+RcDPfpCq1fJ8ZYrWtNtEQC9QKom518E4YwiBr5/IsGH0xgwwYlDQb9X8szJcd0PYfKnZsQSqZV94AjCp51ZlOqvjCqYCTuoqfKGHug8yB0GLtuCTjrBoT60Nvx+9Q7K8AWXfTvrjJgLYywwhHYFVkouNbByASONoTi7Xtw0VuO8YUDuZGkV2yoLdZAcvdkDaAimbVdcPmOIj/7V3OEvGP35LDs2M0Ddfo5ZDXfB6dIF24XGGTYdYFEnEj2Fg/T0tTD2QzdSctULR0ffbTx6VmLdbtoxth7cUkkKffSuC55pYYDYNZ/D/CTAS+xXJndFswQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: S2JSgxX7fwDKqLzp+9woSP/zHm6I5EhEE4r6foNvwmfc2UZ1ziZbv5lrFFiwWG+GX6Gpv7nMmuWAxTiJ76bf9gdltpAtbPDl/NeCPs2F05U6UIOb62WhL57C8xCv6PLHqA3J8XowpmeNJzTq/0HyqK9MHzILEqjfxYYMpTzu1RVNl0km5qh8sBMIPy5DQG53s6n2dZpOpWY2WSKxrmTafBZRnw9/hy4MxkqlcD2xY+UeTEW+1Oso+kRxy3kh+uNkLebLONZ75uipvTlYIb+IBNLfn6T2RIYLfC2anUPMLDXwj/bgYnqSHnQOabsYwbACPLvfXbsYLCF8ulLW5wJD1KMONnFYgs9JHy3vS5uX2+2jqfU+0IbKBsrRaf+pnCFtfBsrOl5ThhfzTZiUvBQwOTYjLDVZB04y9AAluAJdsaGwJ3k27i/WRc2WXP4t3ydaNTZUF733NGp8foKpSQ/pPGiyeGAotA/Iz0OGJ3p9wX/aSM8vzuMVvomm7qHE3mt2keyA3FKeR/YjSxNPQSqmor1hOcvzxLzr/Ult8yyIGaiA7hTVcLJMBsPjjlu0GndGG0K759l+Lx5lGgXEXnypkXTRIPipNJ3lS0WCeULio9KpFai5z0FzNHQqCY0jjA4GKhhp0+vwHXTRvy9iFgeTUR7pYcQpv0TdKfcUjHpdTEL8kv6QAQ+9vKZxvcYaumgbjwr32OeG5i445p6tinQem1LtyAjeIFFBRfzk9ZINH+JapIeCtro2dN60Zh4d5sbAGBwvaWsWZG6/HP+/9GFDCkYBH7pSq2XuBRMWVlOX1dNf/cupHxNQt3nCqi/e2JJxo1NsqAtmAFZG2NWwxBhRE+JtMMkvaSHFbr9R5NqPt2iKyWcyWnKVGbWNyeM6CmzUjRD7hmXb+LIk4+yPmNXghStloFAZcHUA6qF2GgvPCkM03WrDlMA959yIW6LnYhZnpALqCdd/55kvSW8qOdTn8Nkp3uRavLB+IxP50tH9jYkomzfgRIQtKUSezzAxsULFUSZvBVbJg5HGcPWLoJ3WT8CLTepRxAqKD5S0EqEcscDAaNziay4WHlyPQ0qd40QnggagzDo4QbEV1K2pd/J+hQsvyfQJp2JCvP4eYztLohhmHUWqQuGlQ2vmx8qmY6uleiXbLnveCc6je2hemGNLUQ1iAXjLTVDpNs/QJq6JqZaAG7rmfEi5xZk3Jno8R0MfMDP6xyjyIMEbCsWWauQTMwvB6clvDdAMd8ZX/XNNEPDqTLrcjn4WH2Kx9znOMARUFkaUvbrBctwZDaSH/sqkbXaeLXS0sthQy8KO8B/6FGCiYj2nuIgX3gHSEe9FPsF1 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3293236a-8979-4356-1e8a-08d8f6f79131 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:02.7784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7L2qYLoRRxzh+jxRsxqO4CCeF4IahZes4frXFY2lHLWNoGhKUYvfma/b1jaD8P33kQoeIuiDRMNcAbA8gQZzvbP8Nht/qp08WmrkIbEglxs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: wqEdgqFIWotZ7RBIdJQNsa642oOWBuqs X-Proofpoint-GUID: wqEdgqFIWotZ7RBIdJQNsa642oOWBuqs X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patch adds a helper that allows drivers like be2iscsi and qedi to complete a iscsi_task and a iscsi_hdr struct that was setup by libscsi and the driver. This allows drivers that do not use the libiscsi itt to fake it. To match the naming of the other exported completion functions this patch renames iscsi_complete_task to iscsi_finish_task so we can use the iscsi_complete prefix for the new function, iscsi_complete_task, to match iscsi_complete_pdu which is exported for completing pdus. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 8a9a9f5801e3..768b6cefd067 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -502,13 +502,13 @@ void iscsi_put_task(struct iscsi_task *task) EXPORT_SYMBOL_GPL(iscsi_put_task); /** - * iscsi_complete_task - finish a task + * iscsi_finish_task - finish a task * @task: iscsi cmd task * @state: state to complete task with * * Must be called with session back_lock. */ -static void iscsi_complete_task(struct iscsi_task *task, int state) +static void iscsi_finish_task(struct iscsi_task *task, int state) { struct iscsi_conn *conn = task->conn; @@ -550,7 +550,7 @@ void iscsi_complete_scsi_task(struct iscsi_task *task, conn->last_recv = jiffies; __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn); - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); } EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task); @@ -621,7 +621,7 @@ static void fail_scsi_task(struct iscsi_task *task, int err) sc = task->sc; sc->result = err << 16; scsi_set_resid(sc, scsi_bufflen(sc)); - iscsi_complete_task(task, state); + iscsi_finish_task(task, state); spin_unlock_bh(&conn->session->back_lock); } @@ -893,7 +893,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ISCSI_DBG_SESSION(session, "cmd rsp done [sc %p res %d itt 0x%x]\n", sc, sc->result, task->itt); conn->scsirsp_pdus_cnt++; - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); } /** @@ -934,7 +934,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, "[sc %p res %d itt 0x%x]\n", sc, sc->result, task->itt); conn->scsirsp_pdus_cnt++; - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); } static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) @@ -1018,7 +1018,7 @@ static int iscsi_nop_out_rsp(struct iscsi_task *task, rc = ISCSI_ERR_CONN_FAILED; } else mod_timer(&conn->transport_timer, jiffies + conn->recv_timeout); - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); return rc; } @@ -1258,7 +1258,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, } iscsi_tmf_rsp(conn, hdr); - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); break; case ISCSI_OP_NOOP_IN: iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); @@ -1281,7 +1281,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, recv_pdu: if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen)) rc = ISCSI_ERR_CONN_FAILED; - iscsi_complete_task(task, ISCSI_TASK_COMPLETED); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); return rc; } EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); @@ -1813,7 +1813,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) spin_unlock_bh(&session->frwd_lock); spin_lock_bh(&session->back_lock); - iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); + iscsi_finish_task(task, ISCSI_TASK_REQUEUE_SCSIQ); spin_unlock_bh(&session->back_lock); reject: ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", @@ -1824,7 +1824,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) spin_unlock_bh(&session->frwd_lock); spin_lock_bh(&session->back_lock); - iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); + iscsi_finish_task(task, ISCSI_TASK_REQUEUE_SCSIQ); spin_unlock_bh(&session->back_lock); fault: ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", @@ -3268,7 +3268,7 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) state = ISCSI_TASK_ABRT_SESS_RECOV; if (task->state == ISCSI_TASK_PENDING) state = ISCSI_TASK_COMPLETED; - iscsi_complete_task(task, state); + iscsi_finish_task(task, state); spin_unlock_bh(&session->back_lock); } } From patchwork Sat Apr 3 23:23:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415237 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 4A9E4C433ED for ; Sat, 3 Apr 2021 23:24:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 265BD6135E for ; Sat, 3 Apr 2021 23:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236993AbhDCXY3 (ORCPT ); Sat, 3 Apr 2021 19:24:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54914 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236959AbhDCXYV (ORCPT ); Sat, 3 Apr 2021 19:24:21 -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 133NO7oO087694; Sat, 3 Apr 2021 23:24:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ImbL4qq4FQRhBzRuRRACG3YX+SFWbP/iZDnu9PSvmVg=; b=JQqYYXoIDJzjl3CUsWQl8bZs3ifLchGmfZVuhxiBerfHZfoDzST3f6Rmy9Zfsilaxpw+ qzqt8yp+Ao6hV1HujxApX9IOSDEJUKHDqV7XzGceGibovIw0M0M0JSgtHNlY8GbiSZl7 RcSJ92F/xLQq27leZJO5EbtpLTU8Gy+kjLT/8nwcBXN3mJLYA6HTJCVU2KyHrqusjsNX 3SZG6R6sdIhf1BNfoL6eltX490rhHffi5D+AZX3RHIGyff+Sc6huvjeokj4GZdkwmGDy SdwIU7ZyjLQUAzkIXTnhRqz+onELC4mIymwAByYlImNLm8d8CqRx/ylKY3nInlj8MqMJ ig== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 37pq66rcv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:07 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJrfA132130; Sat, 3 Apr 2021 23:24:06 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2056.outbound.protection.outlook.com [104.47.45.56]) by aserp3030.oracle.com with ESMTP id 37q1xk81m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8HvHcalqxkE7li8RVnRa07wK/VWDfrQb5CL6G64c4QaQh7b7tt4Ju64avfRFPAQI4rC25dn0DrILrc629/8tbiKYKE0UFuadfZEh5hJ+DDJ7bXS1ssGiyjDwTU8znmNWPCAqGdXkccEZRD0BCvGp1JniRoxJVLJKz9bjIrjCY8aE00jHx/FJdSq9sk2mNCtn7R5un6tFumxnUtQvjq7DUShKoNmbuBjuAIeIwDPG0FAM+mVSZWfn1rn4c7d4j1uxSxIB3v2v5YjAdyuBZRgN5eGnDy1vZ1AA1U67SClc5UECV0Cwrovsasw3e/JlBXO3YFw2hulXGxaYg4N31SaIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImbL4qq4FQRhBzRuRRACG3YX+SFWbP/iZDnu9PSvmVg=; b=Vt83JOoHrHTJ6hDkvfViCnix8F+CEXL0F22jwhlex5pbFwy5DBog4WKHoU9ovMFCDho+mSzlyjAtQ6KE5KmjiSN1QazmpocFE//8wJOz84as2+yjnbjNwo1qMiO8L79inRvUIUH+JekJ9CcELEk6AKMgNkxDKNIVJTKF6Fzi16vhZ+lixyJGFOicdymNaViTsgvXr97VqbyvwL/vtVPIhXQAPf+HT3qxsAgfdrGGNR+IsHpJXqyxIn/BQHQktwJ8eAMo5DDUo0wVVg29Mf3e/eukJ7MFtYPOa20PTyEYpjDIj+JatlpOaMBQ9kHCSqsmpTfKEVJrVyfrUVp2ElA0eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImbL4qq4FQRhBzRuRRACG3YX+SFWbP/iZDnu9PSvmVg=; b=LOL0FxgmYJ3A/PJ6q5ORuKLcT1OBCsFCGeeD/JTlKWADGZOt+CmUPkpUKnTm4o3E3Tozy5hzo1lDwugj0wWO/B/ceIx/fjGjE4tTHfKxoEPX4zMk+ZEwDnOrw4li85EysiDk3OX2KrQ/xFNqfaeuwDr/La/93ZvfRxva5zvXIlI= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:04 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:04 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 15/40] scsi: libiscsi: add helper to complete a iscsi task Date: Sat, 3 Apr 2021 18:23:08 -0500 Message-Id: <20210403232333.212927-16-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fed46341-b51a-4194-a9c2-08d8f6f791f0 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gSIq7rNU2WlC+eAujG8DRY+sDy+jrhGF7Ejx8KEa0QQcR9gh+fjXrssgvgNb5yN6ZmR4/kD8TzRY/BMvcFfNy5CEPyho1NjzYcuGhe9vHCH7MLvNydTwf5DASUCBtCtZzOtzmJ//PFQaMrWizbp1LCqG8Fh6H4+Ik2gDhInAGkZHQjza8MXaLoTzugaOPa3p1RLZDH36SWkSsyFzhK7+tWKolV+/7oDQrp9VjDfPb7TO6tX/vTgHkN4nbule3P6EFkRtOaR/1+rW9NecYgfofDcFNII1o9I4F0Q4gE3ge/xhh89Q0/42i/3tRV/YVoJq96J5EEVwp6Dz69ziovaYB1jAHVN7U8CRijI17+xOiWG8CbOsgBQ5sWNroR2fQNXIAUYN0tPg/rU4NE1rzFr5KM1aTyR07GUgOIbTRvyYefQgzTVSgW0LSC+y92jFHmX+hTCAiFWRg6Hh87RAmZxVXvxWAbdBTG7yU02OvUGNzz6ct8P+t1KEiH7I0N4RhZUl56eC+H8J0/8VfvPA+cwp+/ESq4gkydmOF7rAmNbwyKZRE/c8xRQPdhVkRZwvLpORO8K7aSKvw6HETmPtH+cWQcligeYBnXasllAIHjB5VIZEkj29+9r5qNFazFqkPnP9SZQPcklvM51S+z/NWqNQIYrbZhAtY1jCnOoqyYNo8wpm/Ti6rYrO1TZNKWXVfSfL23lo0chicu5GNo/NnuldkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 67TmCPfT5tuiNiIsfitS0uIys2eUkJfrSAoayXOKmpeqJ6mS46qcUhj7214lv7dWklFLBweALhfzaDF/KOC0Dyvdy1vv9GQqedLGh6F0j4MJxe36qrdYTT/tGxNifVyegQYJSwIxRBzAsVkTT9LCjiPit6Y+GPBvhp/mS19SNlLvpbCWhytYAIxBtu3xGiMESq33h3aAYrX7tXRH2g6JWrDqsYWVwD9yvZoEqgQZ1QmV+5f25QY9akfGRv0EbYmdW8wfXrWJJ/f+4oSydBAIC+0+egzjIKZhikfzz1wDco0pW5JDpEmId2jTGpMq8qlLllP+8YTxHS4Wivag69BCxFdjGvOyJVyZchHSNdfAViNZdpg9jNOFLahVG+IolOzL+Braf+IcQxxtpLf7bwR9K6mF0gBlJL863TcG/tbns3nYb4INF3dBCETmoPilSJBR38V2jxheKNGPzMVpzBiCT4EDu2JOraJDe9SwdyUgeq2BKUfD73VRitZX95VjacbG/qtp3kg7ZyRhnqc6me7WZj4PZMThjD+y1PnmRmhjXT4tMesgIyTjxTbcpg65rB6Qazr+zMU8GB0lIg4Dk5baRJs1wJDgbRfqJnB6tz83pA6DTFGDqKqD56/0nVs2SL5YEGEnCuSt4YG13uhxCG8cliBeLwBHqD1NciaB/6OMD5gO5mcjZsF5ZIA+2k58Fhi/h6Mrqo83J914EU+UZhrs+Bmx3+Jf8SVek0AosUWM1RnSLArSI/4BxFyWmDbLVjVI61UWc9RmBdvu3kwBi4E9lNlUdt+Va8V6trsOLgEdyz/f5DpNTcWcoZ/r1Zw8aVyk/RnYIFshROmZC62gbzhhR/Vue4kAAJtPEasCESJ4xpCF9wfEA0QI+TC2asmbfgV3K2GnL12XAqQ2yzD7vjel+ngH5Qz2FGnhZKj+dQXoOhW+XWHuNUSfJzc9sE0/vVMlJ2TezjoinOekZz+DMhh4UvWZGHfB/4iBog/MmqHGtDDRKu2v3Jq2ox18XXAa6OsuMdgPrAP0R+nsBP/3/ganiQPSIPis+fIquhxh5uPexYFIgG9X6CBq1a1DIeUelM+YAHuGXYEbnPGh3zGRY74H6zLzOJ6by5HVruKH+ze7ko3gqFZejXdqoa3/4Mjvv8RJKIprwVesR51vMJzijs3oUXHiAajvGfYwKXk42ki4a9TTBXSqqwJ3jHJPCMFmz0yG92R8RG4iTw+mKgzKXzn8oCUHKOdq/vihISmBvChhPuxKFDVICCY4IqOIDQBteerPRmPWTCUew5+qMioNs4UtwxRC1cGw4zCz1DmLtoZ42VlNN2X60tM5KN1ozU91Qqko X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fed46341-b51a-4194-a9c2-08d8f6f791f0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:04.0647 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hc1M+LZOzDvH2P+ybeYE0ws2UQBj3qGbGxARJ2wW4u5WFXOjJpdcCmciSk8ybxXBSVGZulkpdevYzdkIPGqj+wWLdl5YC7qZwP6p5sEH5Gs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: OEt0M4Y2UbkMvbalyCvStGBLlgtZikIB X-Proofpoint-GUID: OEt0M4Y2UbkMvbalyCvStGBLlgtZikIB X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We export functions to complete a pdu and a scsi task, but for mgmt tasks the driver has to fake the itt for drivers like qedi, qla4xxx and be2iscsi which don't have direct access to the PDU that was put on the wire. This adds a helper to allow those drivers to complete a task directly. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 86 +++++++++++++++++++++++++++-------------- include/scsi/libiscsi.h | 2 + 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 768b6cefd067..cadbe1d19344 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1148,9 +1148,8 @@ EXPORT_SYMBOL_GPL(iscsi_itt_to_task); int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *data, int datalen) { - struct iscsi_session *session = conn->session; int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; - struct iscsi_task *task; + struct iscsi_task *task = NULL; uint32_t itt; conn->last_recv = jiffies; @@ -1163,10 +1162,60 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, else itt = ~0U; + if (itt == ~0U) + return iscsi_complete_task(conn, NULL, hdr, data, datalen); + + switch (opcode) { + case ISCSI_OP_SCSI_CMD_RSP: + case ISCSI_OP_SCSI_DATA_IN: + task = iscsi_itt_to_ctask(conn, hdr->itt); + break; + case ISCSI_OP_R2T: + /* LLD handles R2Ts if they need to. */ + return 0; + case ISCSI_OP_LOGOUT_RSP: + case ISCSI_OP_LOGIN_RSP: + case ISCSI_OP_TEXT_RSP: + case ISCSI_OP_SCSI_TMFUNC_RSP: + case ISCSI_OP_NOOP_IN: + task = iscsi_itt_to_task(conn, hdr->itt); + break; + } + + if (!task) + return ISCSI_ERR_BAD_OPCODE; + + return iscsi_complete_task(conn, task, hdr, data, datalen); +} +EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); + +/** + * iscsi_complete_task - complete iscsi task + * @conn: iscsi conn + * @task: iscsi task + * @hdr: iscsi response header with all fields set except the itt + * @data: data buffer + * @datalen: len of data buffer + * + * Completes task processing by freeing any resources allocated at + * queuecommand or send generic. + * + * This function should be used by drivers that do not use the libiscsi + * itt for the PDU that was sent to the target and has access to the + * iscsi_task struct directly. + * + * Session back_lock must be held. + */ +int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, + struct iscsi_hdr *hdr, char *data, int datalen) +{ + struct iscsi_session *session = conn->session; + int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; + ISCSI_DBG_SESSION(session, "[op 0x%x cid %d itt 0x%x len %d]\n", - opcode, conn->id, itt, datalen); + opcode, conn->id, task ? task->itt : ~0U, datalen); - if (itt == ~0U) { + if (!task) { iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); switch(opcode) { @@ -1201,33 +1250,12 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, goto out; } + task->last_xfer = jiffies; + switch(opcode) { - case ISCSI_OP_SCSI_CMD_RSP: - case ISCSI_OP_SCSI_DATA_IN: - task = iscsi_itt_to_ctask(conn, hdr->itt); - if (!task) - return ISCSI_ERR_BAD_ITT; - task->last_xfer = jiffies; - break; case ISCSI_OP_R2T: - /* - * LLD handles R2Ts if they need to. - */ - return 0; - case ISCSI_OP_LOGOUT_RSP: - case ISCSI_OP_LOGIN_RSP: - case ISCSI_OP_TEXT_RSP: - case ISCSI_OP_SCSI_TMFUNC_RSP: - case ISCSI_OP_NOOP_IN: - task = iscsi_itt_to_task(conn, hdr->itt); - if (!task) - return ISCSI_ERR_BAD_ITT; + /* LLD handles R2Ts if they need to. */ break; - default: - return ISCSI_ERR_BAD_OPCODE; - } - - switch(opcode) { case ISCSI_OP_SCSI_CMD_RSP: iscsi_scsi_cmd_rsp(conn, hdr, task, data, datalen); break; @@ -1284,7 +1312,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, iscsi_finish_task(task, ISCSI_TASK_COMPLETED); return rc; } -EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); +EXPORT_SYMBOL_GPL(iscsi_complete_task); int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *data, int datalen) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 5a5f76adbca3..8e01beba62f1 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -467,6 +467,8 @@ extern void __iscsi_put_task(struct iscsi_task *task); extern void __iscsi_get_task(struct iscsi_task *task); extern void iscsi_complete_scsi_task(struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn); +extern int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, + struct iscsi_hdr *hdr, char *data, int datalen); extern int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd); struct iscsi_sc_iter_data { From patchwork Sat Apr 3 23:23:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415106 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 EBEF2C433B4 for ; Sat, 3 Apr 2021 23:24:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C54E26135E for ; Sat, 3 Apr 2021 23:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236997AbhDCXYa (ORCPT ); Sat, 3 Apr 2021 19:24:30 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49802 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236958AbhDCXYV (ORCPT ); Sat, 3 Apr 2021 19:24:21 -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 133NJwpR160162; Sat, 3 Apr 2021 23:24:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=yJopOwKim0rn89DI/dAF4YiJvfQ3U7OAae29XlHOGWw=; b=ju9Wj9f/Sc0EBUAx8MYzSXFE5D4G5jQvfbO99OuD5zixd/4DazFlloSey2VZcWQBjcnp 8/ef0PB5H/bsnuXbmLk8GWyw9KJa0HDgXPr/KCWpC2r3AXo3eRkD30Sll4q7zdSRwP4o GolWwQygvJ916UuZdotpUCk+FNydOQCf9TgEbLk38v0IdnXwkutn78Xq5PbU1zDNCR4z BtBBtU1LVOuYwTV+vyDQbDKVo07I5EBUXtV//TLnCJF/u4gXzEwfl878fAgN1cLH3AoA 703ps7ZmtLo9YJdjU+3Gwhz5AC1gcopI6On6qHlZxT5yS16VAsL1BdlZ8epApuSVEkle kw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:08 +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 133NKte2116979; Sat, 3 Apr 2021 23:24:08 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2050.outbound.protection.outlook.com [104.47.45.50]) by userp3020.oracle.com with ESMTP id 37pfpkbspr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YwSnaIOTcRsemdV2D+KeSfVx7t8AKdQecqV/TfS88Z4yZ+Msrzenu/d4gf/iG5x5tvvWF48Klp6fa2oBA6EaSh/bKL+Ei0hYEgBw06NuEA/p8/te9/yozbr/ROwEpQctxKS4MXujwGAwnf+61DSDe1c02M+QeiMGHXQbnQlnBKEhEmma7cx+SpfMdjLYClUEeUN8G0WvIEu4SYz1v3IW/ZWfo41lJwblKCeZBDlB2g0kHseOlt6ld55kHrUlCv4QSXpsgDaiIsh8C0X6eddY82K7q6Tjk95huoy+/JsRZNpMxI97kThRhCAd5IQgSZH++xsZwlgS5v1GFBMHipo7nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yJopOwKim0rn89DI/dAF4YiJvfQ3U7OAae29XlHOGWw=; b=W5VGdUfXQN65FDcKaDclW2uTHQqjrYgrieZ1/gVgQG4MjNfEvyuE9URg56Qhe8P5E0WToUhMNpJzxUXp+x1UWKAndyGEnM9eUhvokus548Xdi+0DgcoaI0BZrtmMcZJix5czs1OxGS1uRrSL57htjJJHDx4ROFru0KIQIDIaB57B39PfO3qaXzY9S5XNp/dRHepIUtnJ6DV5ow1DrWiFmd2ADGDwjsbnrhHDrJFciiyS3wvueLTOvJaPTDGz8uBhv6KyEh2L0U6mmbU4uLoqgJLDCcm7y0eluwn6nsxh2g0LM+y9KnNWJJs8VRp8qrTVIZPhBn6Lb19zOASzfwmc4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yJopOwKim0rn89DI/dAF4YiJvfQ3U7OAae29XlHOGWw=; b=MHWeM341jMLscy9mLPGzFhJVw41EzBz/X19urfps+EJxXR6EI8WQMG1c8nmFV//xDznUWEaBZh85stOS6c7YmZJu4zMKog9kIn5tBpp8W1rc0q5mYOD3nQFvkWR59LxIbyGWSw/4m5FewFKHQv/AWfEJ8WfPnFv9yTZn5r6YXFE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:05 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:05 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 16/40] scsi: be2iscsi: switch to iscsi_complete_task Date: Sat, 3 Apr 2021 18:23:09 -0500 Message-Id: <20210403232333.212927-17-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fad1c277-82da-4d17-aa1e-08d8f6f792b0 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jz1LuixpQ+NsnjG2DhhE8EyFHHiqo3YLrp1QlW5lWRGvSSRhsuSWOzYBSgTVHc+PKovfDZOWlZIWu2pxNcmrS32zFVWUCgLRii0Gq6uTWmB3rLbeX49pmvlFPwZafsovcLSYTCSBuF9yltWCrGzXW9J4y2fusEjlQBKAIcabJ1Kzrg6HpMkS2I5mRP3ROjHjejGSj2358I4Hzq1WgUxKYVQWnNOD4sIiODe0hkGVwLexbPIwZQHoqOuiKbxzelJDlqZcGjbUsnfWee+XpZokeYl+dw01djLdy++piMbqTrNJ0klGbxENn++FvTikZHNayz+fNKeCPgiL+L+Etobhvb5X/QlIlSyuQH6gwFAD7cMHFpZigpynY6OfsRhgsm2jv/UPY1WH82lV2AlaBu7l7qPNMvPqGqig7GzUvNLndDmfthfOBBANlPkuY9JcqpCVXQFbnLQWpWlXgJ0D0e/npzDwz5iu3gk6oDuxNlFcrUnWGlR6Z4tHPtpPfSf/JFxz0+qhhlLhlPwNBeRI2zuNzbwTUUqckZ6Ck06sr10nVLO3h+vDJ0lX4VhJQp3JSBG7wkMsUhTsXPzAhfaL+8ZTs/W8Uua2CZj8cN4IROnRmrFX/yWi6WnAX8bl2mj48p8yorewr4JByjXYrXxa0tLhsYbST0okialpjZeRmWGvm748zKCmYFVN3es4cObp0oqozSK7DJCZExUfpm4I71V/Cg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: keA0SAEQ1LOCn0FxWm6JhP0H8edHqujYizbRrzwja61NRkpoOGPzS2tOL5BHEFbzUFSpl53x3KrMk2NpXWhDBNqcqYplBqHhpL7e4Uv56czZUswIvKXxOE+wfs4YUvXagELr9LxMWQ96yhUzid183/65UJEOOLiexI8KcKFOwT1dPbhOQ3Sec8DXBVm0dq4aY5ouk9KfTv4OiJtPrRKsGxyLNysThr4tv1/GpL1LMUFgALUkDct1mOiV0l0SAi1mpnNsarmNrz+K/6HIlqDFOiw9/l7+9YLtq1dfPjFiCNa3b6CdfwLVSDPPHtJgPgDubVFeUXXb0FjBuBr33L3hNFEBCVzxcqg3JqZlQoycqlYZfFKMJagJeTeJg3dCwsGi7sof8nmMA3nAjl9Es2j0LfMhjDZwJ8g0HKWiCUQwfxNDJg3O6rWYIc8EouLPeaBwK8AlBt5iuqLQTt741K7XmMothiRRmLLZ3xiVOELLlXQSJzcH4eGq74V6wPlsAFAlVmAE/Zfg/pLAj/x7x8sidd9v2avgBUFn3llkerHL0eHw2mh0ote+vdTd7GCh4es8zWCR6rFyfnMYwH/E87ABgTFXV9SIMBzj3bYLKC5RkyfaWmGQ2qgNmN8WYjASDMxo+fjbd++x/fFTWXMIbqdmknPu6suVu3TKD7Az3ca+Koauw9Do837DXK2C1LbdTZase2xfgrJTF2xXI6srUZmqvmK3nEBNyTP2v+0gyamovoHrRx2UW0dN9PmUFwnrDZ0OlKTLdg3H9dryMBN4bj90CUMTj+mphZ+kqez7uCwjyqX7N5E7WykYLojloSWrrUtrH3I+yo+xJpye/AOMblY9+QOErxn7ktyJ68AifBMfITNwTr5M9POBe3N0Pcn6/Sm3oFjOi5YS7B/fth4KbwxIL/zOW9QzhlvmZRHFiXPyd1tPHjCa02wBqtOQldi+VJJ6qVBZZGGv5BHRhhHX/PAyx9mQKvsAXAEToNxaqomMaKy+M74YdKFHpB9eBYjcKN7JKK6Xg9cXqcSJZCRnVL9TTsfnp1/C2/64EVUBurJ/+9JX6YC8vTHm8u6KTgMqcTUnRotOYkqy72jd9Y+zrPz+OrXUnzUTIt3cHDjNfKgD03hDBkMEsJSBubTdWvqncPCAIynZ4Kd5xEW1M2gyshDrS9jWSg/eN5PcH/GYiPIuqYVIluLk7xH5NOKzzk0eQ1ehMbzdXvcrvpImcdQFCRpeFc3va+Ub+TLTxBI423G1NxOQvMwQekPQUODsFbjp6OTz0evK/+w9fj3H5nOBdNFOOgGeGDDSIG98NYnp6qaALuJ21PWuNwweQf84p8SJZm+5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fad1c277-82da-4d17-aa1e-08d8f6f792b0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:05.3440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qnqDN6Qe2HUeYySv+bJ9DjjWeAEk5yw/8bWbcUV7VSi2ueYqofldDlaFsxfVBA1wMeLPY3r4OrqMFbopGOJg1JWyplDNyd4WAMHxv7RgkqQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: B-Q-_mbzJbJyhcBUOvWaijJ8g2Bu_Syp X-Proofpoint-GUID: B-Q-_mbzJbJyhcBUOvWaijJ8g2Bu_Syp X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has be2iscsi use iscsi_complete_task. It then does not need to do any itt hacks and can completely ignore the libiscsi itt. Note: parse_pdu_itt is now just used to tell libiscsi we don't use it's itt. In a future patchset this will be removed. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 30 ++++++++---------------------- drivers/scsi/be2iscsi/be_main.h | 1 - 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 4d4e3d606e25..99eae2add8da 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -1187,7 +1187,6 @@ be_complete_logout(struct beiscsi_conn *beiscsi_conn, struct common_sol_cqe *csol_cqe) { struct iscsi_logout_rsp *hdr; - struct beiscsi_io_task *io_task = task->dd_data; struct iscsi_conn *conn = beiscsi_conn->conn; hdr = (struct iscsi_logout_rsp *)task->hdr; @@ -1204,8 +1203,7 @@ be_complete_logout(struct beiscsi_conn *beiscsi_conn, hdr->dlength[1] = 0; hdr->dlength[2] = 0; hdr->hlength = 0; - hdr->itt = io_task->libiscsi_itt; - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, NULL, 0); } static void @@ -1215,7 +1213,6 @@ be_complete_tmf(struct beiscsi_conn *beiscsi_conn, { struct iscsi_tm_rsp *hdr; struct iscsi_conn *conn = beiscsi_conn->conn; - struct beiscsi_io_task *io_task = task->dd_data; hdr = (struct iscsi_tm_rsp *)task->hdr; hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; @@ -1224,9 +1221,7 @@ be_complete_tmf(struct beiscsi_conn *beiscsi_conn, hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn); hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn + csol_cqe->cmd_wnd - 1); - - hdr->itt = io_task->libiscsi_itt; - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, NULL, 0); } static void @@ -1271,7 +1266,6 @@ be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, { struct iscsi_nopin *hdr; struct iscsi_conn *conn = beiscsi_conn->conn; - struct beiscsi_io_task *io_task = task->dd_data; hdr = (struct iscsi_nopin *)task->hdr; hdr->flags = csol_cqe->i_flags; @@ -1280,8 +1274,7 @@ be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, csol_cqe->cmd_wnd - 1); hdr->opcode = ISCSI_OP_NOOP_IN; - hdr->itt = io_task->libiscsi_itt; - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, NULL, 0); } static void adapter_get_sol_cqe(struct beiscsi_hba *phba, @@ -1426,9 +1419,7 @@ beiscsi_complete_pdu(struct beiscsi_conn *beiscsi_conn, { struct beiscsi_hba *phba = beiscsi_conn->phba; struct iscsi_conn *conn = beiscsi_conn->conn; - struct beiscsi_io_task *io_task; - struct iscsi_hdr *login_hdr; - struct iscsi_task *task; + struct iscsi_task *task = NULL; u8 code; code = AMAP_GET_BITS(struct amap_pdu_base, opcode, phdr); @@ -1449,9 +1440,6 @@ beiscsi_complete_pdu(struct beiscsi_conn *beiscsi_conn, case ISCSI_OP_LOGIN_RSP: case ISCSI_OP_TEXT_RSP: task = conn->login_task; - io_task = task->dd_data; - login_hdr = (struct iscsi_hdr *)phdr; - login_hdr->itt = io_task->libiscsi_itt; break; default: beiscsi_log(phba, KERN_WARNING, @@ -1460,7 +1448,7 @@ beiscsi_complete_pdu(struct beiscsi_conn *beiscsi_conn, code); return 1; } - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)phdr, pdata, dlen); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)phdr, pdata, dlen); return 0; } @@ -4384,8 +4372,7 @@ static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, * * This is called with the session lock held. It will allocate * the wrb and sgl if needed for the command. And it will prep - * the pdu's itt. beiscsi_parse_pdu will later translate - * the pdu itt to the libiscsi task itt. + * the pdu's itt. */ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) { @@ -4405,7 +4392,6 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) if (!io_task->cmd_bhs) return -ENOMEM; io_task->bhs_pa.u.a64.address = paddr; - io_task->libiscsi_itt = (itt_t)task->itt; io_task->conn = beiscsi_conn; task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr; @@ -4803,9 +4789,9 @@ static int beiscsi_task_xmit(struct iscsi_task *task) beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_IO | BEISCSI_LOG_ISCSI, "BM_%d : scsi_dma_map Failed " - "Driver_ITT : 0x%x ITT : 0x%x Xferlen : 0x%x\n", + "Driver_ITT : 0x%x Xferlen : 0x%x\n", be32_to_cpu(io_task->cmd_bhs->iscsi_hdr.itt), - io_task->libiscsi_itt, scsi_bufflen(sc)); + scsi_bufflen(sc)); return num_sg; } diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 98977c0700f1..ccfdec3ccf21 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -461,7 +461,6 @@ struct beiscsi_io_task { struct scsi_cmnd *scsi_cmnd; int num_sg; struct hwi_wrb_context *pwrb_context; - itt_t libiscsi_itt; struct be_cmd_bhs *cmd_bhs; struct be_bus_address bhs_pa; unsigned short bhs_len; From patchwork Sat Apr 3 23:23:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415105 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 A1A33C433B4 for ; Sat, 3 Apr 2021 23:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A02F6135F for ; Sat, 3 Apr 2021 23:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236977AbhDCXYd (ORCPT ); Sat, 3 Apr 2021 19:24:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54922 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236972AbhDCXYW (ORCPT ); Sat, 3 Apr 2021 19:24:22 -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 133NLRrm085995; Sat, 3 Apr 2021 23:24:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=I2Kgcqp8lyJVjODGK2hpuTFRPtcj2wbRwthilETgz+s=; b=NHrhdaSQYYKrSf4TRKFa5D0XPYz7iO6fmGJ4aU5djWLAilw0+mbGDchizPPf+OwmQOV/ pA8OiXLuIU/hIV9k+AQCIA9B4MX/Nl+gLE79xtOvb4EGL1wJC8qvGQKhu+fspu0bUz4P gmT4B19h2TV096AT3Z3pkje1pTtg89N78OnoCfn2d7d2LADGUpCaWwC3/mid2d1ir24d UiZYQDoxjE39+ZGi33GMjf1NgD+MnofM5YzHIinsqaKXyGXuncQ9GF425TXdeAa3xAEU yY2N4Ik/uz0NSi9xGSyp+QhHqTCSzninh9Ud6vFbAuzmJackeYiecKktlQIv0RM3xmWN qQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37pq66rcv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:09 +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 133NKte3116979; Sat, 3 Apr 2021 23:24:08 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2050.outbound.protection.outlook.com [104.47.45.50]) by userp3020.oracle.com with ESMTP id 37pfpkbspr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2dAsvmZdKIIZjMMe6B1Yjc+jOUxr7ySBOK31JO6OGVrEPpzSchmsAotLqLAW95BIQe9Zmct6tujzqIRDSUyza6bp3ivzRT9nl/N5ebctrV5qtvApyVBl60QwKcnVGrfeUdg4OE72rovsE7yohoD6REq5BtHwe1Ja1T4fVrk0l8O7Tc92J+ZRdbZFsHRsEh/RJ6QW4iQ0nEB8twbQjZ8PqSlt7GREz9r8/HJ3ZL10Bn00pp2UsNXtCuj3nHcXANX0EaWUaVph/JW1g4XS5p8t3Ly9dJgB2JpTsmqPueDE5b0ctkd7Rcx4n3C++qMBAMwyv/xpKSUYt8dLhxrMm7tnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I2Kgcqp8lyJVjODGK2hpuTFRPtcj2wbRwthilETgz+s=; b=kdbnBwMT8zclwESoOQltSrS6VOP4+GbGcWfUA86O0XV9pqlXArh7UkHSruEyVVGn3ShX/QJgIlBX5Fv5bBEsHYXKvu7UlY+GyqtER3zhCMtUaclgVcteqJjzaDPi8zGU9+3wDTrMvKVYkyZPDMyqSs9q+WTzTyaW+Rsj2BlJ56Rs/WUSuV9by1thq6OtACTPGJqF8UypkJBtivMl5TtXC6NEzw9k1W8xvmGCFtRqZPBlAO0Mmb2opDV3LC44hMnx33M9w+qXr2hF4yOAEIraMJUTMeyZpVg7Wo8T9GXgYyDnYNb+cIYNLZwcljVrMi8lsKHe7AX4rKtroBBiDUf+FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I2Kgcqp8lyJVjODGK2hpuTFRPtcj2wbRwthilETgz+s=; b=vx35NWIezQu/tLE/jvWYejqwhQ3UiMNbBFvki8oiduJRJDOm3/80y2AxzHTkE8ZUEWZP3b26JQ1+PVpkUfkP4m9Qej84Jr1r0x0cJf3Ahyr8U9na0xS09tOCAwEE0OiyWTqVSIzWIo1TE+pz+YMZryZ99POAZHI19k05A+kv4eA= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:06 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:06 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 17/40] scsi: qedi: cleanup abort handling Date: Sat, 3 Apr 2021 18:23:10 -0500 Message-Id: <20210403232333.212927-18-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9f36024-c2e3-49c4-3db3-08d8f6f79375 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0b08b3M6+0OoWCHndKG79eXMCOJ2KFn6CslxyGQemS2idxAEYFEo4rQBJNErXnQFGoSWfBr/vUXX3R5W1Nz7lPGMojH18qF9eRBXWNgSZm9oZRB81OmfT9s+Ol9pns6FLsC7bLV2ajrOxEzWD79h360Re0qAaSQvZjXydi0BbhVo4Q0Zcw8AnWa4RjPqdB9zQDpSiLOUcblIZj3388jX+GlhQrKd1G4o0J4/ckTY3X2ae+6oyvNuiOwNSDcCF7+IJwO+yzGiTAgmXbB4CBtcsFg7FHqdIpyyxS73ac83yQpObGmJgAYDAjjxVhAyeAd/RXHIHSmdZx2oHLBKXOj/E1L07SmST+MMust8W9tl3/NYwsJOOFuGTmcRACqIdI2Rv92e+ln5Uo+co/WWhYcEgn9WKYvEXxAMyEZPon0CsSYJSXgVif8ZqGy4UD3pygP+QFSjlcgy0cxEWupm97oNAsI/E2kR28YvS0pC2qi6nQislyWCW8wkHIFY2STzO966CX7A1ta6Wa6SBYc1asTXZLU6iwXHqXLlaFJmqkHbawu/tIiig70+M7d6ySQkQcZ5ixhGe4PFrA8QVFh4X6qafhk/K02w1kjphjCgpMIX2mpKOvJ4pdC2OvuayuS+v10wlm4PotK6ardJfDmM4W6cieaLuHN4IYw+nIignfv7ytmwS1quJywU2GqoTgG6LU+abv6j/gqI/PpdGlCOMPlaSw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(30864003)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 02IPJuVkQ6u2M36ImSbqkBgu8Rp49j4ezJhNKUilHUgmGil7i5CqBip1ynSTQG/M6nhxGLa4ot5zWPVTfOw6FHlcVEbKeQM+x4DdxhSJ4ViqssqYsBfFm4GJFFFO/JQesJFQS32EOs0Jw7XJ0JLjpouzsP2PbsdeIGdkENvH7wm0cQeQUROsOtrmyZ6OdBAQo2SpZCHL+DxLFQ13trQbKXY6WumqTxLa63zPkrPsdAHJRZAdRzW4hi+ODRMKLE5Af60wY3lMNfvE3qcuVy0I82sZpfc1r49gMGxLQ2gksGpDLCHK4VkVih2lZkKSBzFCNYaas4JeQsWGHDnDk3shoiLtzJ9AeYX8CqtfMqYqZ17p+AOWkwzDL+UoP8C9UsxKvd7z8OHIeZ+ghgbbF71HbmQUp9CWcBTQzf3fDS6xfzqv/deWfT3zznZvXc5hEDaTr3lyYYLP4DV0y9dThJSFyF/QDXhlo0smBM4CU8ifrb/RIOhfPjOHK7ZV5RRfuWwWYPrtozXrWM7PCyq+rD97doVO2woKVfFpIFybCg/9Z5Eduba4DImgc2oiRUGdUdALT0k1M5M9rriMeh+vK5arNOjFmO67AJJPTjCy349BTTZC498gqeDGWZU/6sk1RmbWKVCI+Ff/kWQQ2ExTKeOD18GuhfR/gfkITRajXV1T4jxM52R/2ORxuzodJ6C8o7ai7TaRykCV1J38+eE3Y4n9U8yc4tEN0z/8X7WskEUnCMGYWAURwnKT45J5xC0HSfkZ38vV/NfxBvzkbnrm6qIKyfrcFdyUy1qjLJKAtHXNY79Uc1dcFApu8Ujt+dm9KkJKlEiHX0/eL8DNZcT2QN9vF9d2DKcMxPwVfoRcC1P9icFR6MSs48Bm056NEpm3uM3ZNo7lH+qq+JMYqb9MTil1tv+e/M4T49sVBl27R6yAgU38OTLTzpaCwwEGh11NmRd4X8wDjWJNGVRfi52Szi+jv/+ZqA4Vr6VDL2kocfTfK1/SY0E5xnZ3gImmdANetfInqKGT51HdrhL6Qu2g/lQ7WAoBZ2BTy/oTJBx6dZ/kTXJK1raSus9eqqC+nIN11DIgZpaavS6e2u/kWwcEmC77p9R7q3v6ws7kDwc3OVdaizMJihXwFA1DgUWBNMRUdggiY6t8bnI9K9C3ZqLAUN5+qTHR24IkkBM0C2QHjeg8sZJLbnQZmu7rElEcksHJIM8K1Zdxh7UUjhGXdi6Xwh+/Kz3+aSXDyL0AmgdNdZnZt3t0dfEGdJCYsoiqp3U1Eg2Jd+ZRlypc2SCIc3AboHTI7fzm4O+P4vKPjD8d6CZjm+NVFLt3++/oZBUjdovPh7ie X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9f36024-c2e3-49c4-3db3-08d8f6f79375 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:06.6073 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jn8aE2uA7F8NFhNagaYhff17/Q41NWH+esh4rrh7TnUzCmr/IWuuThuqm/6362mej1obUu7Y4gZiaNK5fJbiROXnijyLRH1JoaaeqrAQ8p0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: GpdZDyF3c1xXThhrsle7nkl8SuDatiab X-Proofpoint-GUID: GpdZDyF3c1xXThhrsle7nkl8SuDatiab X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has qedi do it's fw cleanup from the eh abort callout then call into libiscsi to do the protocol/libiscsi cleanup. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 216 ++++++++++----------------------- drivers/scsi/qedi/qedi_gbl.h | 4 +- drivers/scsi/qedi/qedi_iscsi.c | 48 +++++++- drivers/scsi/qedi/qedi_iscsi.h | 1 + 4 files changed, 113 insertions(+), 156 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 440ddd2309f1..d8e10e8d3d08 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -14,9 +14,6 @@ #include "qedi_fw_iscsi.h" #include "qedi_fw_scsi.h" -static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, - struct iscsi_task *mtask); - void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd) { struct scsi_cmnd *sc = cmd->scsi_cmd; @@ -739,7 +736,6 @@ static void qedi_process_nopin_local_cmpl(struct qedi_ctx *qedi, static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, struct iscsi_cqe_solicited *cqe, - struct iscsi_task *task, struct iscsi_conn *conn) { struct qedi_work_map *work, *work_tmp; @@ -752,8 +748,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, u32 iscsi_cid; struct qedi_conn *qedi_conn; struct qedi_cmd *dbg_cmd; - struct iscsi_task *mtask; - struct iscsi_tm *tmf_hdr = NULL; + struct iscsi_task *task; iscsi_cid = cqe->conn_id; qedi_conn = qedi->cid_que.conn_cid_tbl[iscsi_cid]; @@ -777,8 +772,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, WARN_ON(1); } found = 1; - mtask = qedi_cmd->task; - tmf_hdr = (struct iscsi_tm *)mtask->hdr; + task = work->task; rtid = work->rtid; list_del_init(&work->list); @@ -790,49 +784,30 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, if (found) { QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "TMF work, cqe->tid=0x%x, tmf flags=0x%x, cid=0x%x\n", - proto_itt, tmf_hdr->flags, qedi_conn->iscsi_conn_id); - - if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_ABORT_TASK) { - spin_lock_bh(&conn->session->back_lock); - - protoitt = build_itt(get_itt(tmf_hdr->rtt), - conn->session->age); - task = iscsi_itt_to_task(conn, protoitt); + "TMF work, cqe->tid=0x%x, cid=0x%x\n", + proto_itt, qedi_conn->iscsi_conn_id); - spin_unlock_bh(&conn->session->back_lock); + dbg_cmd = task->dd_data; - if (!task) { - QEDI_NOTICE(&qedi->dbg_ctx, - "IO task completed, tmf rtt=0x%x, cid=0x%x\n", - get_itt(tmf_hdr->rtt), - qedi_conn->iscsi_conn_id); - return; - } - - dbg_cmd = task->dd_data; - - QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "Abort tmf rtt=0x%x, i/o itt=0x%x, i/o tid=0x%x, cid=0x%x\n", - get_itt(tmf_hdr->rtt), get_itt(task->itt), - dbg_cmd->task_id, qedi_conn->iscsi_conn_id); + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, + "Abort i/o itt=0x%x, i/o tid=0x%x, cid=0x%x\n", + get_itt(task->itt), dbg_cmd->task_id, + qedi_conn->iscsi_conn_id); - if (qedi_cmd->state == CLEANUP_WAIT_FAILED) - qedi_cmd->state = CLEANUP_RECV; + if (qedi_cmd->state == CLEANUP_WAIT_FAILED) + qedi_cmd->state = CLEANUP_RECV; - qedi_clear_task_idx(qedi_conn->qedi, rtid); + qedi_clear_task_idx(qedi_conn->qedi, rtid); - spin_lock(&qedi_conn->list_lock); - if (likely(dbg_cmd->io_cmd_in_list)) { - dbg_cmd->io_cmd_in_list = false; - list_del_init(&dbg_cmd->io_cmd); - qedi_conn->active_cmd_count--; - } - spin_unlock(&qedi_conn->list_lock); - qedi_cmd->state = CLEANUP_RECV; - wake_up_interruptible(&qedi_conn->wait_queue); + spin_lock(&qedi_conn->list_lock); + if (likely(dbg_cmd->io_cmd_in_list)) { + dbg_cmd->io_cmd_in_list = false; + list_del_init(&dbg_cmd->io_cmd); + qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); + qedi_cmd->state = CLEANUP_RECV; + wake_up_interruptible(&qedi_conn->wait_queue); } else if (qedi_conn->cmd_cleanup_req > 0) { spin_lock_bh(&conn->session->back_lock); qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); @@ -959,8 +934,7 @@ void qedi_fp_process_cqes(struct qedi_work *work) goto exit_fp_process; case ISCSI_CQE_TYPE_TASK_CLEANUP: QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, "CleanUp CqE\n"); - qedi_process_cmd_cleanup_resp(qedi, &cqe->cqe_solicited, task, - conn); + qedi_process_cmd_cleanup_resp(qedi, &cqe->cqe_solicited, conn); goto exit_fp_process; default: QEDI_ERR(&qedi->dbg_ctx, "Error cqe.\n"); @@ -1368,59 +1342,41 @@ static int qedi_wait_for_cleanup_request(struct qedi_ctx *qedi, return 0; } -static void qedi_tmf_work(struct work_struct *work) +int qedi_fw_cleanup_cmd(struct iscsi_task *ctask) { - struct qedi_cmd *qedi_cmd = - container_of(work, struct qedi_cmd, tmf_work); - struct qedi_conn *qedi_conn = qedi_cmd->conn; + struct iscsi_conn *conn = ctask->conn; + struct qedi_conn *qedi_conn = conn->dd_data; struct qedi_ctx *qedi = qedi_conn->qedi; - struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct qedi_work_map *list_work = NULL; - struct iscsi_task *mtask; - struct qedi_cmd *cmd; - struct iscsi_task *ctask; - struct iscsi_tm *tmf_hdr; + struct qedi_work_map *list_work; + struct qedi_cmd *cmd, qedi_cmd; s16 rval = 0; - s16 tid = 0; - - mtask = qedi_cmd->task; - tmf_hdr = (struct iscsi_tm *)mtask->hdr; - set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); - - ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt); - if (!ctask || !ctask->sc) { - QEDI_ERR(&qedi->dbg_ctx, "Task already completed\n"); - goto abort_ret; - } - cmd = (struct qedi_cmd *)ctask->dd_data; + cmd = ctask->dd_data; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, - "Abort tmf rtt=0x%x, cmd itt=0x%x, cmd tid=0x%x, cid=0x%x\n", - get_itt(tmf_hdr->rtt), get_itt(ctask->itt), cmd->task_id, - qedi_conn->iscsi_conn_id); + "abort tmf cmd itt=0x%x, cmd tid=0x%x, cid=0x%x\n", + get_itt(ctask->itt), cmd->task_id, qedi_conn->iscsi_conn_id); - if (qedi_do_not_recover) { - QEDI_ERR(&qedi->dbg_ctx, "DONT SEND CLEANUP/ABORT %d\n", - qedi_do_not_recover); - goto abort_ret; - } - - list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); + list_work = kzalloc(sizeof(*list_work), GFP_NOIO); if (!list_work) { - QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); - goto abort_ret; + QEDI_ERR(&qedi->dbg_ctx, "memory allocation failed\n"); + return -ENOMEM; } - qedi_cmd->type = TYPEIO; - list_work->qedi_cmd = qedi_cmd; + memset(&qedi_cmd, 0, sizeof(struct qedi_cmd)); + qedi_cmd.conn = qedi_conn; + qedi_cmd.type = TYPEIO; + qedi_cmd.list_tmf_work = list_work; + qedi_cmd.state = CLEANUP_WAIT; + + INIT_LIST_HEAD(&list_work->list); + list_work->task = ctask; + list_work->qedi_cmd = &qedi_cmd; list_work->rtid = cmd->task_id; list_work->state = QEDI_WORK_SCHEDULED; - qedi_cmd->list_tmf_work = list_work; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "Queue tmf work=%p, list node=%p, cid=0x%x, tmf flags=0x%x\n", - list_work->ptr_tmf_work, list_work, qedi_conn->iscsi_conn_id, - tmf_hdr->flags); + "queue tmf work=%p, list node=%p, cid=0x%x\n", + list_work->ptr_tmf_work, list_work, qedi_conn->iscsi_conn_id); spin_lock_bh(&qedi_conn->tmf_work_lock); list_add_tail(&list_work->list, &qedi_conn->tmf_work_list); @@ -1428,34 +1384,21 @@ static void qedi_tmf_work(struct work_struct *work) qedi_iscsi_cleanup_task(ctask, false); - rval = qedi_wait_for_cleanup_request(qedi, qedi_conn, ctask, qedi_cmd, + rval = qedi_wait_for_cleanup_request(qedi, qedi_conn, ctask, &qedi_cmd, list_work); if (rval == -1) { QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, - "FW cleanup got escalated, cid=0x%x\n", + "fw cleanup got escalated, cid=0x%x\n", qedi_conn->iscsi_conn_id); - goto ldel_exit; + goto force_cleanup; } - tid = qedi_get_task_idx(qedi); - if (tid == -1) { - QEDI_ERR(&qedi->dbg_ctx, "Invalid tid, cid=0x%x\n", - qedi_conn->iscsi_conn_id); - goto ldel_exit; - } - - qedi_cmd->task_id = tid; - qedi_send_iscsi_tmf(qedi_conn, qedi_cmd->task); - -abort_ret: - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); - return; + return 0; -ldel_exit: +force_cleanup: spin_lock_bh(&qedi_conn->tmf_work_lock); - if (!qedi_cmd->list_tmf_work) { + if (!qedi_cmd.list_tmf_work) { list_del_init(&list_work->list); - qedi_cmd->list_tmf_work = NULL; kfree(list_work); } spin_unlock_bh(&qedi_conn->tmf_work_lock); @@ -1468,11 +1411,10 @@ static void qedi_tmf_work(struct work_struct *work) } spin_unlock(&qedi_conn->list_lock); - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); + return -1; } -static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, - struct iscsi_task *mtask) +int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) { struct iscsi_tmf_request_hdr tmf_pdu_header; struct iscsi_task_params task_params; @@ -1491,6 +1433,19 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, tmf_hdr = (struct iscsi_tm *)mtask->hdr; qedi_cmd = (struct qedi_cmd *)mtask->dd_data; + + switch (tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { + case ISCSI_TM_FUNC_ABORT_TASK: + case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET: + case ISCSI_TM_FUNC_TARGET_WARM_RESET: + case ISCSI_TM_FUNC_TARGET_COLD_RESET: + break; + default: + QEDI_ERR(&qedi->dbg_ctx, "Invalid tmf, cid=0x%x\n", + qedi_conn->iscsi_conn_id); + return -EINVAL; + } + ep = qedi_conn->ep; if (!ep) return -ENODEV; @@ -1566,49 +1521,6 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, return 0; } -int qedi_iscsi_abort_work(struct qedi_conn *qedi_conn, - struct iscsi_task *mtask) -{ - struct qedi_ctx *qedi = qedi_conn->qedi; - struct iscsi_tm *tmf_hdr; - struct qedi_cmd *qedi_cmd = (struct qedi_cmd *)mtask->dd_data; - s16 tid = 0; - - tmf_hdr = (struct iscsi_tm *)mtask->hdr; - qedi_cmd->task = mtask; - - /* If abort task then schedule the work and return */ - if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_ABORT_TASK) { - qedi_cmd->state = CLEANUP_WAIT; - INIT_WORK(&qedi_cmd->tmf_work, qedi_tmf_work); - queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work); - - } else if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || - ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_TARGET_WARM_RESET) || - ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_TARGET_COLD_RESET)) { - tid = qedi_get_task_idx(qedi); - if (tid == -1) { - QEDI_ERR(&qedi->dbg_ctx, "Invalid tid, cid=0x%x\n", - qedi_conn->iscsi_conn_id); - return -1; - } - qedi_cmd->task_id = tid; - - qedi_send_iscsi_tmf(qedi_conn, qedi_cmd->task); - - } else { - QEDI_ERR(&qedi->dbg_ctx, "Invalid tmf, cid=0x%x\n", - qedi_conn->iscsi_conn_id); - return -1; - } - - return 0; -} - int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, struct iscsi_task *task) { diff --git a/drivers/scsi/qedi/qedi_gbl.h b/drivers/scsi/qedi/qedi_gbl.h index 116645c08c71..a3b72e7ff9d9 100644 --- a/drivers/scsi/qedi/qedi_gbl.h +++ b/drivers/scsi/qedi/qedi_gbl.h @@ -31,8 +31,7 @@ int qedi_send_iscsi_login(struct qedi_conn *qedi_conn, struct iscsi_task *task); int qedi_send_iscsi_logout(struct qedi_conn *qedi_conn, struct iscsi_task *task); -int qedi_iscsi_abort_work(struct qedi_conn *qedi_conn, - struct iscsi_task *mtask); +int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask); int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, struct iscsi_task *task); int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, @@ -60,6 +59,7 @@ void qedi_mark_device_available(struct iscsi_cls_session *cls_session); void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu); int qedi_recover_all_conns(struct qedi_ctx *qedi); void qedi_fp_process_cqes(struct qedi_work *work); +int qedi_fw_cleanup_cmd(struct iscsi_task *ctask); int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, struct iscsi_task *task, bool in_recovery); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 36e81eb567b2..0f3704c4c985 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -43,13 +43,57 @@ static int qedi_eh_host_reset(struct scsi_cmnd *cmd) return qedi_recover_all_conns(qedi); } +static int qedi_eh_abort(struct scsi_cmnd *cmd) +{ + struct Scsi_Host *shost = cmd->device->host; + struct qedi_ctx *qedi = iscsi_host_priv(shost); + struct iscsi_cls_session *cls_session; + struct iscsi_session *session; + struct qedi_conn *qedi_conn; + struct iscsi_task *task; + int rc; + + cls_session = starget_to_session(scsi_target(cmd->device)); + session = cls_session->dd_data; + + if (qedi_do_not_recover) { + QEDI_ERR(&qedi->dbg_ctx, "dont send cleanup/abort %d\n", + qedi_do_not_recover); + return FAILED; + } + + /* check if we raced, task just got cleaned up under us */ + spin_lock_bh(&session->back_lock); + task = (struct iscsi_task *)cmd->SCp.ptr; + if (!task || !task->sc) { + spin_unlock_bh(&session->back_lock); + return SUCCESS; + } + + __iscsi_get_task(task); + spin_unlock_bh(&session->back_lock); + + qedi_conn = task->conn->dd_data; + set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); + + rc = qedi_fw_cleanup_cmd(task); + + iscsi_put_task(task); + clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); + + if (rc) + return FAILED; + + return iscsi_eh_abort(cmd); +} + struct scsi_host_template qedi_host_template = { .module = THIS_MODULE, .name = "QLogic QEDI 25/40/100Gb iSCSI Initiator Driver", .proc_name = QEDI_MODULE_NAME, .queuecommand = iscsi_queuecommand, .eh_timed_out = iscsi_eh_cmd_timed_out, - .eh_abort_handler = iscsi_eh_abort, + .eh_abort_handler = qedi_eh_abort, .eh_device_reset_handler = iscsi_eh_device_reset, .eh_target_reset_handler = iscsi_eh_recover_target, .eh_host_reset_handler = qedi_eh_host_reset, @@ -746,7 +790,7 @@ static int qedi_iscsi_send_generic_request(struct iscsi_task *task) rc = qedi_send_iscsi_logout(qedi_conn, task); break; case ISCSI_OP_SCSI_TMFUNC: - rc = qedi_iscsi_abort_work(qedi_conn, task); + rc = qedi_send_iscsi_tmf(qedi_conn, task); break; case ISCSI_OP_TEXT: rc = qedi_send_iscsi_text(qedi_conn, task); diff --git a/drivers/scsi/qedi/qedi_iscsi.h b/drivers/scsi/qedi/qedi_iscsi.h index 39dc27c85e3c..8a96c1fde630 100644 --- a/drivers/scsi/qedi/qedi_iscsi.h +++ b/drivers/scsi/qedi/qedi_iscsi.h @@ -212,6 +212,7 @@ struct qedi_cmd { struct qedi_work_map { struct list_head list; struct qedi_cmd *qedi_cmd; + struct iscsi_task *task; int rtid; int state; From patchwork Sat Apr 3 23:23:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415236 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 EED1FC433ED for ; Sat, 3 Apr 2021 23:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF88961360 for ; Sat, 3 Apr 2021 23:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236978AbhDCXYe (ORCPT ); Sat, 3 Apr 2021 19:24:34 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49822 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236973AbhDCXYW (ORCPT ); Sat, 3 Apr 2021 19:24:22 -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 133NOAgg162573; Sat, 3 Apr 2021 23:24:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=hja/OPjlstld1+Z7mdAJEvEkAo3po83aTuaS2zOEyQ0=; b=Kfp2ku3r0Z3bhHR3MfDFDXXHwsPtVQLWr3SXX9refo6ogn1MkYiFaTjktJMpXUppWDUJ W+MirY42UoPHybyuRS6YXMsFWrJg6+PemSU2EZ1/rUHx1Rc9BhPT+eHZGvZMWKzdMOKD gtRo4oKe5u3+l29AHj5aw4FxCgMHIk6K1ca9zL2Q0C8uyDoRUhAVlxQ3I+mpsOD1XS/a AV6hamkEoB8pWrWMpQ33QiHuGTQx1b6cCxKHVhYAcJWjcb82UGRe0Ls29iNSU4gNbcD8 0jPBHylSeEnUUAcKNTNOPcjDWjYeF7ORKx3GqHbqYnnL2VO8ETHX0tJ9d7xWthNhmlID fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:10 +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 133NKte4116979; Sat, 3 Apr 2021 23:24:09 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2050.outbound.protection.outlook.com [104.47.45.50]) by userp3020.oracle.com with ESMTP id 37pfpkbspr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H0QqeY/lZ+WkkSz2ZxrEr+FqlGJj6+Abi9p4YRYgpLgtfSZL3Rv7hZXhrFz7+rC3oEvf6tFKFIRK4WjrDyq+zM+7wr4m86GsGsk3PiB+TOmSPVnEf3jaAJ36RaVR0lPbxJabczvhSp7yQvtWk4wzIsCVIRkstGaBidvjWhsU/297SjHA3x2pN+kCoFOaDMNI4xleFdlmykvAH2NNNQoa4f2CAM60BCW7ZD3IGKEoG71BndpzfxZSDEFvTbO1pLxvTKTiGkTfXf7SxdKPE5N/iMXBdwzIBfibj3gnJLWv6kOY72eWbtdDf9vh1j/kG4f5Vg9fCGQfIhZ+t5F9VIiZDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hja/OPjlstld1+Z7mdAJEvEkAo3po83aTuaS2zOEyQ0=; b=VaQHMX6FuBUtzb571r2H1XdZUL9C/WCfLw/7RUP1GNUjoT5POQa9tZ2WrE9F3NuO28PWpu5ne3NoPUywiiUb112l0MR1LfTVPQtD5zqlZ2lxhFaafgtPb2fVkT8y07IVMazmQah6/JEjfSVnibm6l8S5rdI68v1ToErpvkfHKzCW3U2nIlRc2Q6vPwZKwxcmN8+Wct35AXOFFyo4LgBdOGUZgZUbbYVit9UAwZI4yzsllCr6tu+FmozBk47JQeoLeOBfeycXdAn32nf4BqzRT76CXnHVafTv6i4bPxeXnYqEStq5Zh+KFPA2LKWLAopTcy6Vo2Vljw437jc43SUanQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hja/OPjlstld1+Z7mdAJEvEkAo3po83aTuaS2zOEyQ0=; b=k1gSNRYsBcS5iFK/ksidDgFgwLkZXXfjGd9mHkVsOrZVXa6SrYlapC9cMA4EU6gF8pkyVBP3uMuNieqY8GXXUFGSx7b5DYK6N0/fuWeUkxjr9ACQcRN65wewbAd6gKe79FD1Ans6WmsVOYxbt7cy/niwSiPk1e1E8azeW2QK3rw= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:08 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:07 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 18/40] scsi: qedi: misc cleanup Date: Sat, 3 Apr 2021 18:23:11 -0500 Message-Id: <20210403232333.212927-19-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63b6e604-1f82-4f5f-aeb7-08d8f6f79437 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w2aoVMDrdrmldwDh90yDE2KOfZCyn56Tz0vwXap/2lYsomio7+WFh/2QRN9PRjPKJ+ESLjtbIXKCmfsfL2VlwY8rS+bHeKF0Wgyz+74dBEVzuN85YFyeKpFeF0BnV87KGi2OaMrlh5IeiiMrC2Gi4klJVqZbCfj03IuM0PjUsNteWECVEy5i0i+6Ee9C+br8POsNfXVUUpG8AtPXd0sANJAauUEx4j4R+0uG0THvd3Jwc7FPjtrqE7H4NPHHS9R+CLfVaKfqASEl9NSUCjVtesW3T+cR0ORrFgknZqDp4bzoyaQcbNWi3b6lnzFd3UAhpk2hI1rwZrUMrLriw/Yv69p9a0kSD/fyaRBi4E1Xdoff6nEfiJVHG5bkcxvFBdjg9nffz035BBs5odETkmqpnDwoqT9UaoeQS+QrYSPbkqiSPZLGmC/vJi+gmq7aTVXgT90BUsYRKnPep7vE/FbQXNyKX8QYeOxc0A/hP5Qlx56XjZC8//jYdoFSzJYnAD3q5ZXh5uSaSYykGWTiw4Q9V3eZFPRaOauzxP6EWhw8B8sM6JaE0fC3Rv0kyQ8u8m1yXMcDmyIX9CQUTMRjWtm+DoSUVMqoI8T9zyyey+8YiRB7+2zv0zaUeu8JYZ/0g8VYysHVMrVhtGbBd2ycOYWarXcMfST9xHogkxcENScon2u+RbI+qptgCvyNQbOBhS3AqqFMio+9Gu2arup/lmdM8Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ry5ov4Pkh/XjZGGJo/ZSTSYIxrDGCfZ1duAnKz+gxhgY4rnRaQU22hJMQ6qMC2Z/2+bGpIok1WwdsyL9C6boop8iYTND7W0opqIu6gPxYmW3oddQEtCMP9GkALJGwSHdPbZVSHeoQHVXQFxu5yGwipAVu/h8qKKxXoJfb7yq1/S3na8aYp3IqMO6+hGBUwXprpt/A/sGaBymWhmY18lYtiPmZZqVfZNfw6mubfEukbO9Ym8ctp+1OeZgwSG+AZ4VP4RN/cnbW1Y0O2PS+EEbZOoLldvq8tZyRtHnMA6HXSHPO9AedNO4yodxOWs8BiYADx0MJGyJER3TTNsb4rxkayduPVh/XcTx0fR5Ce1dU4Z+kQzSoXrykGl4rK4jMOfnALvjCikPd0/8hNsjTYAyHQKtqEnt5cSrTlT8oLIFnO/T+TfY02G4E0LhFwREruvrnT0vcEqVGtDUnJRk5VcgKW13Yb/XyXrc9ioSo0xaGyKERBhzfxz5aoPxrL09TWYBG3Un/1BiwxAM8xcHXAUiXncuw2Tm0U3X74Lif8tmMq/gnrAYFoo0b14T1wDws1Q7K4dO+7fe21jmVXh9xng5Kf5MwQuhLcmqtELaK7mIgoGd49ottIzjkDOYGR4UBmgGQWjjDo1Zd8wMAcO2sFRD7MHqsKsq+EtSML0dJvFdelupGNCwYWEjY4+2EGb1XlCXVHw6byh0qqEYYCV8WsPEJdYyBgXnNnO+BUl9MDvHO42xVK88e8TNUx8i8i6kPEiGE3mziS181xQEi45o/sa33CYjj9FiEELDzILsqFR+I7EaBdNRdjZ+Fn9Tdzv3gECMhFu8XfSjXfkEMUeKcLI4zIiufiJjKPE84Gs3U84hBdgMBpixu0hOphkCC299xj9MxafvRnR2GkbO92tXADHj0hqI5upwNZpN+yMiAHeJ/MSK6phKn8Mcs/qWWonFNO+3LwfLHnklZKYHN0a5+gOvJZEuNckoVSKuPByC3yoTybkpoE9ANGV029W9x3jjHQl7oc++oIC2SIWWg1Nvrt/Q1gTksdylyhGTufT1WfggcWSCcPtL7qJNqUVrt2+mPUnvfO3hOUBTKbcnSctXWpIy9W+lA6++lUBsi+OJtq/iM6lR67Kv6SC5/UCiehOp30Woce74oupHUOYMcVtKen6YvHmGGAUBuFY4ru9V9/cr8uydo9llwsROZ6va0Ki7GNhsbngylhpaU55GWP+byHaefTCznK1bRHt434ZpzHVEPPgX2YcMMdt2h7R/9h39MbNjIrDfkHC/jG9uwwFnuCGEIeJ8WHb9F36zmXldnyg2AU3tpTi1Aesxev8+pv9Tv9Fc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63b6e604-1f82-4f5f-aeb7-08d8f6f79437 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:07.8606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: txVJJEiD7nUSM5MzqL+TITNdFmJSW/FqM+jm1qI1uoZfYQ+5tsYclH1g9W8gGz46dCyWT4NYeL6LFXtC+YmzyC8mG5GuL71xsdmST0NoRFI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: _vEWRJ3Rc4VU6jdM5Ivr6BAGcJ1Rw7oW X-Proofpoint-GUID: _vEWRJ3Rc4VU6jdM5Ivr6BAGcJ1Rw7oW X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove some fields/args that are not used. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 11 +++++------ drivers/scsi/qedi/qedi_gbl.h | 3 +-- drivers/scsi/qedi/qedi_iscsi.h | 2 -- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index d8e10e8d3d08..3357b0ff7dba 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -1218,7 +1218,7 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, } } qedi_conn->cmd_cleanup_req++; - qedi_iscsi_cleanup_task(ctask, true); + qedi_iscsi_cleanup_task(ctask); cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -1374,15 +1374,14 @@ int qedi_fw_cleanup_cmd(struct iscsi_task *ctask) list_work->rtid = cmd->task_id; list_work->state = QEDI_WORK_SCHEDULED; - QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "queue tmf work=%p, list node=%p, cid=0x%x\n", - list_work->ptr_tmf_work, list_work, qedi_conn->iscsi_conn_id); + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, "list node=%p, cid=0x%x\n", + list_work, qedi_conn->iscsi_conn_id); spin_lock_bh(&qedi_conn->tmf_work_lock); list_add_tail(&list_work->list, &qedi_conn->tmf_work_list); spin_unlock_bh(&qedi_conn->tmf_work_lock); - qedi_iscsi_cleanup_task(ctask, false); + qedi_iscsi_cleanup_task(ctask); rval = qedi_wait_for_cleanup_request(qedi, qedi_conn, ctask, &qedi_cmd, list_work); @@ -2114,7 +2113,7 @@ int qedi_iscsi_send_ioreq(struct iscsi_task *task) return 0; } -int qedi_iscsi_cleanup_task(struct iscsi_task *task, bool mark_cmd_node_deleted) +int qedi_iscsi_cleanup_task(struct iscsi_task *task) { struct iscsi_task_params task_params; struct qedi_endpoint *ep; diff --git a/drivers/scsi/qedi/qedi_gbl.h b/drivers/scsi/qedi/qedi_gbl.h index a3b72e7ff9d9..098982e6f8a2 100644 --- a/drivers/scsi/qedi/qedi_gbl.h +++ b/drivers/scsi/qedi/qedi_gbl.h @@ -40,8 +40,7 @@ int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, int qedi_iscsi_send_ioreq(struct iscsi_task *task); int qedi_get_task_idx(struct qedi_ctx *qedi); void qedi_clear_task_idx(struct qedi_ctx *qedi, int idx); -int qedi_iscsi_cleanup_task(struct iscsi_task *task, - bool mark_cmd_node_deleted); +int qedi_iscsi_cleanup_task(struct iscsi_task *task); void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd); void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, u32 proto_itt, struct qedi_cmd *qedi_cmd); diff --git a/drivers/scsi/qedi/qedi_iscsi.h b/drivers/scsi/qedi/qedi_iscsi.h index 8a96c1fde630..5522df952c30 100644 --- a/drivers/scsi/qedi/qedi_iscsi.h +++ b/drivers/scsi/qedi/qedi_iscsi.h @@ -219,8 +219,6 @@ struct qedi_work_map { #define QEDI_WORK_QUEUED 1 #define QEDI_WORK_SCHEDULED 2 #define QEDI_WORK_EXIT 3 - - struct work_struct *ptr_tmf_work; }; struct qedi_boot_target { From patchwork Sat Apr 3 23:23:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415235 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 9A760C43461 for ; Sat, 3 Apr 2021 23:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FF156135F for ; Sat, 3 Apr 2021 23:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237003AbhDCXYf (ORCPT ); Sat, 3 Apr 2021 19:24:35 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45014 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236975AbhDCXYX (ORCPT ); Sat, 3 Apr 2021 19:24:23 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NOCFp099638; Sat, 3 Apr 2021 23:24:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=fyFz3rzvDTFxtt4Kde8ArSwaxDoPDHezHrGR+ztMdLs=; b=sxMl1zvkJ5mfjYPK6l7vDG0pEGXgiOMzRnI06pxCGidiuyLOgwNLIDp67fgJDzIkC+0O QB+obWaLsIFCy+zADNMJzCFYtq/ezy5nhQM4ZL6EAwPoMT3ynvjPH0ErjijloKcEXHYy rIA+O7zR/8VEa/nHNkBRSy9Ht/BB7ZvLUMIR6KdDL+XyM39+i1XH0BlkLhmANG/wLSCt lS6YTTqY5ooZyuW63hdP0mGQrct4XRXi4OpCeQVeEOj8fbfKB8pj3yg3vhSWL/U992at cpy3FkmmaAHvqfq2h3CfCgXh914NIKVFJD7lxsyPSvavCdaQf4yxwegknCrU3wtQlgDO 0Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:12 +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 133NL6x0130144; Sat, 3 Apr 2021 23:24:11 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2051.outbound.protection.outlook.com [104.47.45.51]) by aserp3020.oracle.com with ESMTP id 37pg61huas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hgnYxKiSfpmX0d9CZkwAwBzIqY0cucPjq4WUgjsTPANe9es83Hs8tudK5vOj/M8paCGDufvcm5LubZTUKCZchbuVoDQERUZDp9RuyvIYAX+NwBxKfzeNoigy/HMuNEKDgsBkyrf2qTCbw9BUsMwPQL6o9Dd90g30LFB340vGYD6ZTkg/8D3/JslKtnJ2XHa1ptBUanQIEJVp3WfV1iNbQHqxbVaOBrRGSQxtAjBMgN+5lL06LTuEuyPaRAv9KLYG94R4Zh+fFO3JZNRuM11RONI8LonsoeWqoMzGNmZj2gtWOLuJ42n+BbMWyVebIUA3u5HgBOmPPjgoEkaB9pcqjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fyFz3rzvDTFxtt4Kde8ArSwaxDoPDHezHrGR+ztMdLs=; b=kuVG4OzJ76skSHMnFJ1X03t3LP3qLiXpOA6qlNHXCXAq+WGmAmbJiDlVT7PWssa0mpDkbx2pqUllmmV+96nJHuyukSwoLE07Mwy8lu36tXQHm2nfK9fuKzFjM1yGU0KW89wmrr0Ie13+jeBvLQlgsY3dEuhsVD0tSQcTXIlhhhlA0V0TmD+T8KNPZHqN1VGTGnOkZ5uwGzAZwbwptJrOyBrKSpZNfSX9huIfMvK1Sjh12fQvQavluL6aqyfdPgdqzTmSZXGOwMQGD9oJj2oaha1IXz0Z0/OnOgGToWryQ7fshMHVSALnuYZ8ckK7rtL+n0iVwdLtcf4yywfzzh3ARg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fyFz3rzvDTFxtt4Kde8ArSwaxDoPDHezHrGR+ztMdLs=; b=Ve//lYy7H2YzfSazhL70o+k0iplWWIXYpvGVaqxDoAJL0CQ39cwCDXY9dS03JC3Zk3wN8IupxszCqzMjaxOrWIcb6oAvL0NJgS2Ja9UHTGICFIBUXApcSS/IuRCFOlzaoshcPsdFxhv2DQCytTdYrba+C4RMdEGco5N2QEsGNdw= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:09 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:09 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 19/40] scsi: qedi: drop libiscsi itt use Date: Sat, 3 Apr 2021 18:23:12 -0500 Message-Id: <20210403232333.212927-20-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 834ab8d3-2ca2-4592-f430-08d8f6f794fb X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gn0TH82NGIkL86aLKEodok3U0TDXPnMlrXQtUroxwoarSAJHvd1fSvK3TJbne3RHm0bKDbfmImQXAMA4S0j5oHMLmUqUzh75+n95WagSLacRznsYyeIjvfjm2d82hs++4n2fxoW6S0t3mFzSNe4mKK1eqPj8TUOwesFYAbTYX0wZOHD0fgKX50bT1yq16bg8frJOnhnG8Qgqu+ZZRuHytmtzFlpBMOoGAbIlEIC8qy3NdFmFjlSKKNhXxspln4kaMfSiB479ROkZMwZGMd4x/96Ee8Wi/yEIXWH+8xx04cleylRcHCwSrG/7lWe8uIH5m28UvyrY0M8eeoGZPPKIgo+0wQctI0bvIg+svBlbC4nEa5BMexC2dYIp7p/NJKP9Js/5eWif+At+iFSd3iODl9fbsKHnZ9ULs/9QNWGnNcAEXpTcHVdc6mvn3nZFlZPHz7oqGiMzZ68uy/+VzXmY85iqaXKCRolRJ4Pmu5uXwuEVjMHDa05wOVheyHffddjyXW8M4CyJGE1VNCAhJF5M2Ogvy7OGG/XexRzjRAB+smy7FLpXfrOAGBf1emM7UDIzxtlpy3wAMWX/UwogUrobcND7LYWY8LfjuH8xR6Iwu/wb6HnxYA+nokDiwel99E8MUeKXJPHalAepIz8ySE0eEgOFTRiUhiXAchnYSDATJOKrjccxWBA1Mrf5Slz4VbBb7/yenW9UYYOXB6xQoFaEBg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(30864003)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JvAGVmrY0GO0UTHmjIpty6E79la/YY3HjN2fqFYtDZaWtsUN2rQO4sYf9ef+3qa/6jXHTgFGhJIKm2igKbCA2QCFDaMbDT+T43YkzWAXhIEiSUmXsaOP4JWI8ln1FiI7recnrRTr4m1YKbuKz+mWnWihNjQY8GpGOi4Hti7wCQNzHZ1pQYlmwsuZdZxwvNsSgY1jGgcb3w4EPrY0pD+ZY/EqY8MvZOUkJBM063d+XIG7/zc4KV3gm6lqtAEhulEId/sImgoj0dsC3AL55BV9AdFVlYSj5Fpj3SpgGDEAg9W/mAHFSuTsqOxzeVUFvuvGHhS17TPssoYFUpHoUFjVW7C0BIeJeiNvdvRRjbLvINYnGtZAexAlbfYGARNA4B1dtVkhkUTa3MSL2ivYKrnjR/S2pE/oCuRmiX0IUAPBGhWcDJvsVxFkGtrv8MrMpP+saFfu0zfA7pRhOrqFw7CoAUFTRejSlAGib9wfexBqTCyPmSLYohu+J23pdPP2KRRLbmxYvrGaVAQwSzpqky2DU/QYbHv72JNkXk5T+bocRA977Gm2RPY6ChKvkrdMbUBwYN2PIe66rHZkhAhg2w4A50hn7KAvSIXcGcbFYx97q4Q7JPMFulFNKqjs8V1YZdulO27FF+7zFshnRNKtCt1CEvaavnEQ76MgmD2Gjf72Q2AslQyGvqeay/iJoV/8fv6QYcVVvE1x1OmRIn4jXOIgSj6ryHw9RAWX8Kj6g78EbGDWVa5GTLkZ1NFJ5VPsGQctORCKWLQAfXYlFKlNYx6WH7JtjosKerigXkZIJlbccavsaSCGq0sFjhkGWu7GcYIc22ByaFZGXRV4A+nrTTXJ7ilCR1QMSjhWlxI8JJvp+QZAUgVIKai2oIQICIJlC2Pmv7wFk9J0LbPHdYCDuEjCK+mL03jfjzrXV+kI1EoUIOV0dYrnVyT/rv7IADri6Thh7gZUF6MO5xj6iJH1nmW7QRBzHaBv214c6Ena3wAd/YILbuWCyB8SEzjBQAc4I6QNgDnAdniN6OpSXXwEWmZC+nWdAxa7nZ5Duc+geWpFoPj3OC7s/UTBBjd7aNzPPyt6zTBg0wZUdS1tj1FXs3IQYKv3JSxtD9EwX+5qPj0i+SJcrfvwrbwzCpekfVsTFGaZLthTisCO1lPgodgUfQAP9OkSkuR4ATQ7zXM47RYHFmVpSmR325t9bNwb+/i2et5r5LP+/cCK8UQXiDLcjNxk9GcyfkKHVaZhKYod4c/vjANqO78Z50fe5iVAVMP5K8zPPJgk51OGO99ksP1f07Z1EPhTbL84W6c5x4vH3dKaLrh5nlUBPTf/zDUjQw0WixCu X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 834ab8d3-2ca2-4592-f430-08d8f6f794fb X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:09.1559 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +WO/r/5PbgaKESNFgXTKVHJH8w/QtMS1mYqJWscvuA6lUWnxbM1nbZduqrDSzmb218X3vSw/wsUXhp97Z6IcSK4p8zHu+hwQA33155IAdB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: ayrHEdq5zA1PRh_SNqcwrb-loEzod4yC X-Proofpoint-ORIG-GUID: ayrHEdq5zA1PRh_SNqcwrb-loEzod4yC X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org qedi has several tags: 1. 16 bit hw/fw tag for each low level cq/sq entry. 2. libiscsi itt/tag which comes from libiscsi for each cmd/task. 3. 32 bit iscsi itt/tag used for each iscsi PDU. The driver combines 1 and 2 to form this. This patch simplifies the driver so we only have #1. Note that in a future patchset for qedi only we can go further and remove #1 and use the blk tag. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 127 ++++++++++++++++----------------- drivers/scsi/qedi/qedi_gbl.h | 4 +- drivers/scsi/qedi/qedi_iscsi.h | 3 - drivers/scsi/qedi/qedi_main.c | 22 ++---- 4 files changed, 70 insertions(+), 86 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 3357b0ff7dba..217291e81cdb 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -44,7 +44,6 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, resp_hdr->flags = cqe_logout_response->flags; resp_hdr->hlength = 0; - resp_hdr->itt = build_itt(cqe->cqe_solicited.itid, conn->session->age); resp_hdr->statsn = cpu_to_be32(cqe_logout_response->stat_sn); resp_hdr->exp_cmdsn = cpu_to_be32(cqe_logout_response->exp_cmd_sn); resp_hdr->max_cmdsn = cpu_to_be32(cqe_logout_response->max_cmd_sn); @@ -71,7 +70,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)resp_hdr, NULL, 0); spin_unlock(&session->back_lock); } @@ -104,8 +103,6 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, (cqe_text_response->hdr_second_dword & ISCSI_TEXT_RESPONSE_HDR_DATA_SEG_LEN_MASK)); - resp_hdr_ptr->itt = build_itt(cqe->cqe_solicited.itid, - conn->session->age); resp_hdr_ptr->ttt = cqe_text_response->ttt; resp_hdr_ptr->statsn = cpu_to_be32(cqe_text_response->stat_sn); resp_hdr_ptr->exp_cmdsn = cpu_to_be32(cqe_text_response->exp_cmd_sn); @@ -137,10 +134,10 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, - qedi_conn->gen_pdu.resp_buf, - (qedi_conn->gen_pdu.resp_wr_ptr - - qedi_conn->gen_pdu.resp_buf)); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)resp_hdr_ptr, + qedi_conn->gen_pdu.resp_buf, + (qedi_conn->gen_pdu.resp_wr_ptr - + qedi_conn->gen_pdu.resp_buf)); spin_unlock(&session->back_lock); } @@ -170,7 +167,8 @@ static void qedi_tmf_resp_work(struct work_struct *work) qedi_clear_task_idx(qedi, qedi_cmd->task_id); spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); + iscsi_complete_task(conn, qedi_cmd->task, + (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); spin_unlock(&session->back_lock); exit_tmf_resp: @@ -215,8 +213,6 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, hton24(resp_hdr_ptr->dlength, (cqe_tmp_response->hdr_second_dword & ISCSI_TMF_RESPONSE_HDR_DATA_SEG_LEN_MASK)); - resp_hdr_ptr->itt = build_itt(cqe->cqe_solicited.itid, - conn->session->age); resp_hdr_ptr->statsn = cpu_to_be32(cqe_tmp_response->stat_sn); resp_hdr_ptr->exp_cmdsn = cpu_to_be32(cqe_tmp_response->exp_cmd_sn); resp_hdr_ptr->max_cmdsn = cpu_to_be32(cqe_tmp_response->max_cmd_sn); @@ -244,7 +240,8 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, qedi_clear_task_idx(qedi, qedi_cmd->task_id); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); + iscsi_complete_task(conn, qedi_cmd->task, + (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); kfree(resp_hdr_ptr); unblock_sess: @@ -279,8 +276,6 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, hton24(resp_hdr_ptr->dlength, (cqe_login_response->hdr_second_dword & ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK)); - resp_hdr_ptr->itt = build_itt(cqe->cqe_solicited.itid, - conn->session->age); resp_hdr_ptr->tsih = cqe_login_response->tsih; resp_hdr_ptr->statsn = cpu_to_be32(cqe_login_response->stat_sn); resp_hdr_ptr->exp_cmdsn = cpu_to_be32(cqe_login_response->exp_cmd_sn); @@ -301,9 +296,9 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, memset(task_ctx, '\0', sizeof(*task_ctx)); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, - qedi_conn->gen_pdu.resp_buf, - (qedi_conn->gen_pdu.resp_wr_ptr - + iscsi_complete_task(conn, task, (struct iscsi_hdr *)resp_hdr_ptr, + qedi_conn->gen_pdu.resp_buf, + (qedi_conn->gen_pdu.resp_wr_ptr - qedi_conn->gen_pdu.resp_buf)); spin_unlock(&session->back_lock); @@ -448,8 +443,6 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, if (task) { cmd = task->dd_data; hdr->flags = ISCSI_FLAG_CMD_FINAL; - hdr->itt = build_itt(cqe->cqe_solicited.itid, - conn->session->age); lun[0] = 0xffffffff; lun[1] = 0xffffffff; memcpy(&hdr->lun, lun, sizeof(struct scsi_lun)); @@ -469,7 +462,8 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, } done: - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, bdq_data, pdu_len); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, bdq_data, + pdu_len); spin_unlock_bh(&session->back_lock); return tgt_async_nop; @@ -477,7 +471,6 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, static void qedi_process_async_mesg(struct qedi_ctx *qedi, union iscsi_cqe *cqe, - struct iscsi_task *task, struct qedi_conn *qedi_conn, u16 que_idx) { @@ -523,15 +516,14 @@ static void qedi_process_async_mesg(struct qedi_ctx *qedi, resp_hdr->param2 = cpu_to_be16(cqe_async_msg->param2_rsrv); resp_hdr->param3 = cpu_to_be16(cqe_async_msg->param3_rsrv); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bdq_data, - pdu_len); + iscsi_complete_task(conn, NULL, (struct iscsi_hdr *)resp_hdr, bdq_data, + pdu_len); spin_unlock_bh(&session->back_lock); } static void qedi_process_reject_mesg(struct qedi_ctx *qedi, union iscsi_cqe *cqe, - struct iscsi_task *task, struct qedi_conn *qedi_conn, uint16_t que_idx) { @@ -566,8 +558,8 @@ static void qedi_process_reject_mesg(struct qedi_ctx *qedi, hdr->statsn = cpu_to_be32(cqe_reject->stat_sn); hdr->ffffffff = cpu_to_be32(0xffffffff); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, - conn->data, pld_len); + iscsi_complete_task(conn, NULL, (struct iscsi_hdr *)hdr, conn->data, + pld_len); spin_unlock_bh(&session->back_lock); } @@ -628,7 +620,6 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, hdr->opcode = cqe_data_in->opcode; hdr->max_cmdsn = cpu_to_be32(cqe_data_in->max_cmd_sn); hdr->exp_cmdsn = cpu_to_be32(cqe_data_in->exp_cmd_sn); - hdr->itt = build_itt(cqe->cqe_solicited.itid, conn->session->age); hdr->response = cqe_data_in->reserved1; hdr->cmd_status = cqe_data_in->status_rsvd; hdr->flags = cqe_data_in->flags; @@ -647,7 +638,7 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, GET_FIELD(cqe_err_bits, CQE_ERROR_BITMAP_UNDER_RUN_ERR))) { QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, "Under flow itt=0x%x proto flags=0x%x tid=0x%x cid 0x%x fw resid 0x%x sc dlen 0x%x\n", - hdr->itt, cqe_data_in->flags, cmd->task_id, + task->itt, cqe_data_in->flags, cmd->task_id, qedi_conn->iscsi_conn_id, hdr->residual_count, scsi_bufflen(sc_cmd)); hdr->residual_count = cpu_to_be32(scsi_bufflen(sc_cmd)); @@ -671,8 +662,8 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, qedi_trace_io(qedi, task, cmd->task_id, QEDI_IO_TRACE_RSP); qedi_clear_task_idx(qedi, cmd->task_id); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, - conn->data, datalen); + iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, conn->data, + datalen); error: spin_unlock_bh(&session->back_lock); } @@ -740,15 +731,13 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, { struct qedi_work_map *work, *work_tmp; u32 proto_itt = cqe->itid; - u32 ptmp_itt = 0; - itt_t protoitt = 0; int found = 0; struct qedi_cmd *qedi_cmd = NULL; u32 rtid = 0; u32 iscsi_cid; struct qedi_conn *qedi_conn; struct qedi_cmd *dbg_cmd; - struct iscsi_task *task; + struct iscsi_task *task = NULL; iscsi_cid = cqe->conn_id; qedi_conn = qedi->cid_que.conn_cid_tbl[iscsi_cid]; @@ -809,16 +798,20 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, qedi_cmd->state = CLEANUP_RECV; wake_up_interruptible(&qedi_conn->wait_queue); } else if (qedi_conn->cmd_cleanup_req > 0) { - spin_lock_bh(&conn->session->back_lock); - qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); - protoitt = build_itt(ptmp_itt, conn->session->age); - task = iscsi_itt_to_task(conn, protoitt); + dbg_cmd = qedi_get_cmd_from_tid(qedi, cqe->itid, true); + if (dbg_cmd) { + /* + * We don't have a ref to the task so this is just used + * as a hint. + */ + task = dbg_cmd->task; + } + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "cleanup io itid=0x%x, protoitt=0x%x, cmd_cleanup_cmpl=%d, cid=0x%x\n", - cqe->itid, protoitt, qedi_conn->cmd_cleanup_cmpl, + "cleanup io itid=0x%x, cmd_cleanup_cmpl=%d, cid=0x%x\n", + cqe->itid, qedi_conn->cmd_cleanup_cmpl, qedi_conn->iscsi_conn_id); - spin_unlock_bh(&conn->session->back_lock); if (!task) { QEDI_NOTICE(&qedi->dbg_ctx, "task is null, itid=0x%x, cid=0x%x\n", @@ -834,12 +827,18 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, qedi_clear_task_idx(qedi_conn->qedi, cqe->itid); } else { - qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); - protoitt = build_itt(ptmp_itt, conn->session->age); - task = iscsi_itt_to_task(conn, protoitt); + dbg_cmd = qedi_get_cmd_from_tid(qedi, cqe->itid, false); + if (dbg_cmd) { + /* + * We don't have a ref to the task so this is just used + * for debugging. + */ + task = dbg_cmd->task; + } + QEDI_ERR(&qedi->dbg_ctx, - "Delayed or untracked cleanup response, itt=0x%x, tid=0x%x, cid=0x%x, task=%p\n", - protoitt, cqe->itid, qedi_conn->iscsi_conn_id, task); + "Delayed or untracked cleanup response, tid=0x%x, cid=0x%x, task=%p\n", + cqe->itid, qedi_conn->iscsi_conn_id, task); } } @@ -907,8 +906,6 @@ void qedi_fp_process_cqes(struct qedi_work *work) qedi_process_nopin_local_cmpl(qedi, &cqe->cqe_solicited, task, q_conn); } else { - cqe->cqe_solicited.itid = - qedi_get_itt(cqe->cqe_solicited); /* Process other solicited responses */ qedi_mtask_completion(qedi, cqe, task, q_conn, que_idx); } @@ -916,16 +913,14 @@ void qedi_fp_process_cqes(struct qedi_work *work) case ISCSI_CQE_TYPE_UNSOLICITED: switch (hdr_opcode) { case ISCSI_OPCODE_NOP_IN: - qedi_process_nopin_mesg(qedi, cqe, task, q_conn, + qedi_process_nopin_mesg(qedi, cqe, NULL, q_conn, que_idx); break; case ISCSI_OPCODE_ASYNC_MSG: - qedi_process_async_mesg(qedi, cqe, task, q_conn, - que_idx); + qedi_process_async_mesg(qedi, cqe, q_conn, que_idx); break; case ISCSI_OPCODE_REJECT: - qedi_process_reject_mesg(qedi, cqe, task, q_conn, - que_idx); + qedi_process_reject_mesg(qedi, cqe, q_conn, que_idx); break; } goto exit_fp_process; @@ -1035,8 +1030,8 @@ int qedi_send_iscsi_login(struct qedi_conn *qedi_conn, login_req_pdu_header.tsih = login_hdr->tsih; login_req_pdu_header.hdr_second_dword = ntoh24(login_hdr->dlength); - qedi_update_itt_map(qedi, tid, task->itt, qedi_cmd); - login_req_pdu_header.itt = qedi_set_itt(tid, get_itt(task->itt)); + qedi_update_itt_map(qedi, tid, qedi_cmd); + login_req_pdu_header.itt = tid; login_req_pdu_header.cid = qedi_conn->iscsi_conn_id; login_req_pdu_header.cmd_sn = be32_to_cpu(login_hdr->cmdsn); login_req_pdu_header.exp_stat_sn = be32_to_cpu(login_hdr->exp_statsn); @@ -1129,8 +1124,8 @@ int qedi_send_iscsi_logout(struct qedi_conn *qedi_conn, /* Update header info */ logout_pdu_header.opcode = logout_hdr->opcode; logout_pdu_header.reason_code = 0x80 | logout_hdr->flags; - qedi_update_itt_map(qedi, tid, task->itt, qedi_cmd); - logout_pdu_header.itt = qedi_set_itt(tid, get_itt(task->itt)); + qedi_update_itt_map(qedi, tid, qedi_cmd); + logout_pdu_header.itt = tid; logout_pdu_header.exp_stat_sn = be32_to_cpu(logout_hdr->exp_statsn); logout_pdu_header.cmd_sn = be32_to_cpu(logout_hdr->cmdsn); logout_pdu_header.cid = qedi_conn->iscsi_conn_id; @@ -1464,8 +1459,8 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) memset(&tmf_pdu_header, 0, sizeof(tmf_pdu_header)); /* Update header info */ - qedi_update_itt_map(qedi, tid, mtask->itt, qedi_cmd); - tmf_pdu_header.itt = qedi_set_itt(tid, get_itt(mtask->itt)); + qedi_update_itt_map(qedi, tid, qedi_cmd); + tmf_pdu_header.itt = tid; tmf_pdu_header.cmd_sn = be32_to_cpu(tmf_hdr->cmdsn); memcpy(scsi_lun, &tmf_hdr->lun, sizeof(struct scsi_lun)); @@ -1481,9 +1476,7 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) return 0; } cmd = (struct qedi_cmd *)ctask->dd_data; - tmf_pdu_header.rtt = - qedi_set_itt(cmd->task_id, - get_itt(tmf_hdr->rtt)); + tmf_pdu_header.rtt = cmd->task_id; } else { tmf_pdu_header.rtt = ISCSI_RESERVED_TAG; } @@ -1564,8 +1557,8 @@ int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, text_request_pdu_header.opcode = text_hdr->opcode; text_request_pdu_header.flags_attr = text_hdr->flags; - qedi_update_itt_map(qedi, tid, task->itt, qedi_cmd); - text_request_pdu_header.itt = qedi_set_itt(tid, get_itt(task->itt)); + qedi_update_itt_map(qedi, tid, qedi_cmd); + text_request_pdu_header.itt = tid; text_request_pdu_header.ttt = text_hdr->ttt; text_request_pdu_header.cmd_sn = be32_to_cpu(text_hdr->cmdsn); text_request_pdu_header.exp_stat_sn = be32_to_cpu(text_hdr->exp_statsn); @@ -1670,13 +1663,13 @@ int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, nop_out_pdu_header.cmd_sn = be32_to_cpu(nopout_hdr->cmdsn); nop_out_pdu_header.exp_stat_sn = be32_to_cpu(nopout_hdr->exp_statsn); - qedi_update_itt_map(qedi, tid, task->itt, qedi_cmd); + qedi_update_itt_map(qedi, tid, qedi_cmd); if (nopout_hdr->ttt != ISCSI_TTT_ALL_ONES) { nop_out_pdu_header.itt = be32_to_cpu(nopout_hdr->itt); nop_out_pdu_header.ttt = be32_to_cpu(nopout_hdr->ttt); } else { - nop_out_pdu_header.itt = qedi_set_itt(tid, get_itt(task->itt)); + nop_out_pdu_header.itt = tid; nop_out_pdu_header.ttt = ISCSI_TTT_ALL_ONES; spin_lock(&qedi_conn->list_lock); @@ -2025,8 +2018,8 @@ int qedi_iscsi_send_ioreq(struct iscsi_task *task) cmd_pdu_header.lun.lo = be32_to_cpu(scsi_lun[0]); cmd_pdu_header.lun.hi = be32_to_cpu(scsi_lun[1]); - qedi_update_itt_map(qedi, tid, task->itt, cmd); - cmd_pdu_header.itt = qedi_set_itt(tid, get_itt(task->itt)); + qedi_update_itt_map(qedi, tid, cmd); + cmd_pdu_header.itt = tid; cmd_pdu_header.expected_transfer_length = cpu_to_be32(hdr->data_length); cmd_pdu_header.hdr_second_dword = ntoh24(hdr->dlength); cmd_pdu_header.cmd_sn = be32_to_cpu(hdr->cmdsn); diff --git a/drivers/scsi/qedi/qedi_gbl.h b/drivers/scsi/qedi/qedi_gbl.h index 098982e6f8a2..4222d693c095 100644 --- a/drivers/scsi/qedi/qedi_gbl.h +++ b/drivers/scsi/qedi/qedi_gbl.h @@ -38,11 +38,13 @@ int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, struct iscsi_task *task, char *datap, int data_len, int unsol); int qedi_iscsi_send_ioreq(struct iscsi_task *task); +struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid, + bool clear_mapping); int qedi_get_task_idx(struct qedi_ctx *qedi); void qedi_clear_task_idx(struct qedi_ctx *qedi, int idx); int qedi_iscsi_cleanup_task(struct iscsi_task *task); void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd); -void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, u32 proto_itt, +void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, struct qedi_cmd *qedi_cmd); void qedi_get_proto_itt(struct qedi_ctx *qedi, u32 tid, u32 *proto_itt); void qedi_get_task_tid(struct qedi_ctx *qedi, u32 itt, int16_t *tid); diff --git a/drivers/scsi/qedi/qedi_iscsi.h b/drivers/scsi/qedi/qedi_iscsi.h index 5522df952c30..662e7380a14c 100644 --- a/drivers/scsi/qedi/qedi_iscsi.h +++ b/drivers/scsi/qedi/qedi_iscsi.h @@ -227,9 +227,6 @@ struct qedi_boot_target { u32 ipv6_en; }; -#define qedi_set_itt(task_id, itt) ((u32)(((task_id) & 0xffff) | ((itt) << 16))) -#define qedi_get_itt(cqe) (cqe.iscsi_hdr.cmd.itt >> 16) - #define QEDI_OFLD_WAIT_STATE(q) ((q)->state == EP_STATE_OFLDCONN_FAILED || \ (q)->state == EP_STATE_OFLDCONN_COMPL) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 0aa0061dad40..f10739148080 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -62,7 +62,6 @@ static LIST_HEAD(qedi_udev_list); /* Static function declaration */ static int qedi_alloc_global_queues(struct qedi_ctx *qedi); static void qedi_free_global_queues(struct qedi_ctx *qedi); -static struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid); static void qedi_reset_uio_rings(struct qedi_uio_dev *udev); static void qedi_ll2_free_skbs(struct qedi_ctx *qedi); static struct nvm_iscsi_block *qedi_get_nvram_block(struct qedi_ctx *qedi); @@ -1223,7 +1222,8 @@ static int qedi_queue_cqe(struct qedi_ctx *qedi, union iscsi_cqe *cqe, switch (cqe->cqe_common.cqe_type) { case ISCSI_CQE_TYPE_SOLICITED: case ISCSI_CQE_TYPE_SOLICITED_WITH_SENSE: - qedi_cmd = qedi_get_cmd_from_tid(qedi, cqe->cqe_solicited.itid); + qedi_cmd = qedi_get_cmd_from_tid(qedi, cqe->cqe_solicited.itid, + true); if (!qedi_cmd) { rc = -1; break; @@ -1850,10 +1850,8 @@ void qedi_clear_task_idx(struct qedi_ctx *qedi, int idx) "FW task context, already cleared, tid=0x%x\n", idx); } -void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, u32 proto_itt, - struct qedi_cmd *cmd) +void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, struct qedi_cmd *cmd) { - qedi->itt_map[tid].itt = proto_itt; qedi->itt_map[tid].p_cmd = cmd; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN, @@ -1878,15 +1876,8 @@ void qedi_get_task_tid(struct qedi_ctx *qedi, u32 itt, s16 *tid) WARN_ON(1); } -void qedi_get_proto_itt(struct qedi_ctx *qedi, u32 tid, u32 *proto_itt) -{ - *proto_itt = qedi->itt_map[tid].itt; - QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN, - "Get itt map tid [0x%x with proto itt[0x%x]", - tid, *proto_itt); -} - -struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid) +struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid, + bool clear_mapping) { struct qedi_cmd *cmd = NULL; @@ -1897,7 +1888,8 @@ struct qedi_cmd *qedi_get_cmd_from_tid(struct qedi_ctx *qedi, u32 tid) if (cmd->task_id != tid) return NULL; - qedi->itt_map[tid].p_cmd = NULL; + if (clear_mapping) + qedi->itt_map[tid].p_cmd = NULL; return cmd; } From patchwork Sat Apr 3 23:23:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415104 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 977E1C433ED for ; Sat, 3 Apr 2021 23:24:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78F0E61360 for ; Sat, 3 Apr 2021 23:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237008AbhDCXYg (ORCPT ); Sat, 3 Apr 2021 19:24:36 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45028 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236980AbhDCXYZ (ORCPT ); Sat, 3 Apr 2021 19:24:25 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJnFA097178; Sat, 3 Apr 2021 23:24:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=CnSpttLA/ZirQpqalclYb5twhGs410sfRKIPyzcvmOI=; b=V5wub5AHEf0WiaXuxEm2pnsqoQpMScJ+DCxSXZUoulVRO2CK15vfW9EiUlihjZnx4/dW aqDtFH9L+UOR1BrniwYlNQqPbg4BNmbttG1eJuaA7AvocgPsZw8MZzws3k4zJtk+VILn kt5485Tn3mA51yF6h+JWmOP70kaq78SFNGDH1SkRuZbUrFgeHyzWHi2c11rxpzL2LT2P 4GcXiXTnvzba/FKA9AMyA3TIFqGvlYqTR7M7BmBXpjOHwperd7HkZHB3Fu0AhUMfxRi8 wLONK2cM8tgD5zTwMcE+Uc5jDVq4atBtMq+SQuFc9ILcHkam0ruNBafgToT271cXni2p xw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:12 +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 133NL6x1130144; Sat, 3 Apr 2021 23:24:12 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2051.outbound.protection.outlook.com [104.47.45.51]) by aserp3020.oracle.com with ESMTP id 37pg61huas-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nTrgqfkbBD5qHokipKijxoWzw6G27zONH/3pKD4hMvEz6PHPyjaDDohGUZI39OFgvJGehF5ueWqwavAYxnkZVOfQMp2C2+Yx4PeKGYtYEvoZxi4T8asi94zGBUoPGfRKipnVq2rzciqrNof5dq4UkBBk8ngix3Bad/UoaViIvjZNOvZiQerjobyjmRzYUxLrm+KWLdjA1T/asVekNwseWBlG5e5DfRBUAu5q2liT6/+B9oh/jVuFWsWHHVvrH8TWmh3BM5YhydQDdrV51ks93NT+l3TehbXHBMk4W3SAxxVqqxhM1AkUrQ5yBIaA5gMWXfLexVPdP7nua5jg4ZAZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CnSpttLA/ZirQpqalclYb5twhGs410sfRKIPyzcvmOI=; b=VUHsDmIugzRskGXrYsLdpowJvVTbG/GS3C20+D0BJGX7NqH1lGTRuWH7wmhMoQb3qxookj0h/FRcx0p/hfILxYlMSrNxyRxCaafcW5FgIQ/whvaK9WcC1qgFNExV8HPR9RxHqQnBLSRiopuIiTikEJnmTTEs5vHJ2fozXtTGrwLY2S7JAwuZkbq/P3Kh9yWMMbfjw3+0K0nMvVzBqUBQ6yHSJfUflz+ino8B2RLCGq7kY+DiA19+5JobwswCGlwZ1dMDKKY9PSRvQmb9i7KoMfhJ99fvZ+xUnq8HvBSTVBtOCuorfJDofGoAXHNFyCRVEmlV0l0F90HfUng3Ipad2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CnSpttLA/ZirQpqalclYb5twhGs410sfRKIPyzcvmOI=; b=coguoGFCfOn9tuDjy2C2iepcbFCXzJE83ssQH2dRTaxGqU+GG0Gn1LkcVecVdBsCJQVvOoEiya76F/bwe2v7bblh0nAV9i23kS8Ot03Qwm12DeZXRWQhxTE3kws4TJu1WG5kI0fWNz0+vv0PdDXR5v9VM0wNopU0IB1uhhAHhio= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:10 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:10 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 20/40] scsi: qedi: rm unused nr_hw_queues Date: Sat, 3 Apr 2021 18:23:13 -0500 Message-Id: <20210403232333.212927-21-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eec19f62-6ca2-410b-30c3-08d8f6f795c4 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YhBt2SOAv+zZDzfzNr/F4TUqKBY8JymGuq0Dp79VceLwkMnh/qVKgb9mVybrwqwGO1vFIldteTdz8RDUe+xZnrOq9g/Dtnq5XVIF9m2BUbwqMSTPx1mkN6rW61Vr/7T6OFjnQy7RzCKogBLp/w8Zp+Bb3AxO0IT24MUrQackS1ZSmhIFVsF2VHF4HbiP1XXMl5Q+G3U/AtuKwZ2JdCg3O3GpqMxEJzZ414o8WWddlHLUSFDMLXGO7bdg1GAH/Duf/X8WSLaSRYd+4dt9Y53pWw9c+eTrdyb5Pcb97qKlq/VIIo7dKgBz1jyMQt49wBT8/7Ff7Dc+pXg3C8EBtpR06V/wb8qfENLagJZIEIe8U/lJ93Ral9qgOFObEZJebGVtKNKxUDsa5Mj8pYk1kUwqryWAvfV0GbTrK046DQHt/oyX7UDUmXmme6jQgVUtaL2+XXD7nAfpmMSHX2krOGOd95PzhSrTE3qjveTUWqppKwp6RQrWDHwNHMIXEpfpgSLQCEG9vhz418MfXAZ8Oc7tNN81DHy9rYNJ7qXvagbLyY/ofaLp80HBK4VOAhTN3SDtCZN0G1AfcBMxl74MRV7ezQIk/W4iUco/qbhLEDv4L9xTa0v/uFKDNj5zl9G2RV2kGqjbHhlykH65nWu6LLtiyfv0F6eyZ9beudimNi8jXGFCTRfx8AepaZnxSWfPURhmQgODSknxRK9YXbaybgh3Yw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(4744005)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(6666004)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /0oShcDT5LkGESFYwlpwr2qlEqUrucQQNIM+LnfOR0LzANwi2B4akAVJvXzEX6X+hdVhCPodCRhEn8IteUPDJ/96PoP4SfEUbZNqfSiOG1xsl3zaNPJWOQE7Mkeasq3gzaApKRDJ7SwBJ3ISvjg5grrepbIMeb14yWdKiZzDi9ctparFrBW/q7ltto4eQiCDxIiXDncICInQyEFF/L6lrS3HuTohVyX1EZua9JFlRhsAb9nHIRJF6aq4wFu42jheBYw+62tiu1E4s+9HUdhtt3T5ZG8dh6mhm4PYoLBUvWBuCtlBfXMCrsTokRCBogJrDCorOd5rbCm9PCmXh3XIjMgyJtts8BW5eJ9LlnFmjtUDYZYNOUKcKn17PXvm+OCLu/hAh0xJ7MN6hgtKv/h1EvoFVIHwwAiRFFw0AETSvFRFkBPRUoOdiSm0TbIMAw28LFBwrbYvpvVMj4MNKd8WyidMKARwsmr32kha7OO5MNJFugYVivn1l3U0or8IjQ+Q/0jug712G3YNLk3rWBYRswx04AhhIPKqqiffgJAHSsVh7YlegeIc4BG9FgKjXdurCX64A2gYhyB1Y0bp/VxMbwSmBUkilbYV0J5SaIRI4MWfvpQixzpSS3oIy6N2sIz/FCH7A0gJU6Vk6qq6aNhS4A9Ml3cBTcyYTaNCT7rbpNOSpmNiF3FEah8yrjKiaUPoS8/ePHgaWebSTGA6M4P9CuVPBt1mXy3mP0uCpaz1iICyWHi7aJqK6q6CVH8354qMPr83zBTJaUaj7bNRHiX+Sh4biVMmjFZh7FLiwe5wZQolanQnKb1Jjdfxbzb9UGMuC+GrCpqxcFXEtMrC3f/YXr7ULADKU4+v8zEMiBBuXW9DKdqztkNNqC9kimpl1jJcunuWPi7XmrlLXsp7/ViGUgSQBOJQ9uaYeoztWoJSY/HhSM6BR2S+57jEjJSf9eXOsUCa4la2sdEoiFvFgdVM7Kq09H5Rx34a/ALSwTKEgr8fINkb25TdNnJsiNdrxDlbIX5WDOWjfWbzV6/uLHw2S+Uoc5AliWTGR4Mv5X3dCoY6y54W7H/1/4aDRvyBBwGMtbdIP3w/ewYcAwyvlorqS2rJomyPOZU+Q8sOWGjRjpeHjqFGVlQ74qDcyqQhJaZTrz8yTyGrczakXHAmy50ezVEmvvd7RGj7jEDObLvZB+ekzP+pXoi4QetwLkFfeVDbDcG4ZA0Q6I/MTuA/nGXqjxRaMz6jAScczYEmuqRHPFy9VwZsyKSF3qFa4IinUAiUEKCVc8LoIp+Mohfa5HtPGt5+swDIbO1rnYxr1lM6hcC8TslD4Kq+lYgqDxqbtRR7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eec19f62-6ca2-410b-30c3-08d8f6f795c4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:10.5081 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2F2tiJOr+u90i6FBwh8YWJXb+uRp61YUdOg49gsyJ49VlTjpasCGRo6rR3pnnQu52QSob8kVYJHPTv1oE841on1jpOtd5OtIfSYiy528jls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: gzPKGUfAb9ZWA0nJIA82E84-Ps1VQuQV X-Proofpoint-ORIG-GUID: gzPKGUfAb9ZWA0nJIA82E84-Ps1VQuQV X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org nr_hw_queues is always 1, because qedi set the num cqs after qedi_host_alloc. It's a simple change to move this to before we do scsi_add_host, but setting it seems to drop performance. It looks like the problem is that there 3 locks in the main IO path, so we bash on them even when nr_hw_queues > 1. This patch just drops it for now why we work on removing those locks. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index f10739148080..cb792020b8be 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -656,8 +656,6 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev) qedi->max_active_conns = ISCSI_MAX_SESS_PER_HBA; qedi->max_sqes = QEDI_SQ_SIZE; - shost->nr_hw_queues = MIN_NUM_CPUS_MSIX(qedi); - pci_set_drvdata(pdev, qedi); exit_setup_shost: From patchwork Sat Apr 3 23:23:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415234 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 7F351C433B4 for ; Sat, 3 Apr 2021 23:24:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 595306135E for ; Sat, 3 Apr 2021 23:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237012AbhDCXYk (ORCPT ); Sat, 3 Apr 2021 19:24:40 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45050 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236988AbhDCXY1 (ORCPT ); Sat, 3 Apr 2021 19:24:27 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJwJN097218; Sat, 3 Apr 2021 23:24:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=TstOIiXBGB9nrKwYHL8XhCb0X1C8or19PXL5jaoy1mI=; b=SuqQpynjsG2/0ewuNQM/JUfMylamXMk5GAYntcgaOBio5gqnZNmiVFSdmEwE8l0vPipi fLeD7fdALE4T/UlSTNfeIRFCuScplVT78ATCdgyTNYhZMGLUK4J0GY2/goBUs48AQWeR iBULo1AfCcUUVYxapUZVsi4b621r0JtCVlCE2GmIsQiKJS92RNw9d7xFyyhLjFNWb9f9 6mBu4vXG9/3zhNKUzAizGATj7YXolXowHIxlzJiy3r0+OJNA+1fkAT1vphZIkb+IRdRP wZ+Kto2I9DyMuHmuLIYYIcKj6SoZqOTqLUX1MjIJ9TwJzeczdkqOw0tJ2qRo0pkyBrrz wg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:15 +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 133NKuMU117114; Sat, 3 Apr 2021 23:24:14 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2053.outbound.protection.outlook.com [104.47.45.53]) by userp3020.oracle.com with ESMTP id 37pfpkbsqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aaLkQ93VqbT4+nPET0Y1HWT+H9DV5a2n7OC1h0OR/ZIcls+13CukPC7Go8/0HEP2ioCZl5ZNEbqvx0cKM3t7Yie7Nb61XDVgk6FZNKW0JxvpdMZMZpT196QB74/Ip+jVZPzJRN2Rj0RtGurHTVPCzMJHU19yPadWk3LMkTH8M2bv3n6l21uGryITESsOQfmZ4ON/OMmRW9yPQuqe+CXAFxf1QXZHDi+C4uezG092q2ttdlX1Mjz92GtBxo9gr/ILDaDkdgZb4Al99PIroRZDI0g4seeCePdycxHf5SCuqohcEYi9ruwKkISOr8bNmo0qiFp6I+gNOZlTdE7qz/QkZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TstOIiXBGB9nrKwYHL8XhCb0X1C8or19PXL5jaoy1mI=; b=WdUg5uW4VBNIm/Wtbp51LbgluTR8GXXXVr5x6iUVmkpSr846Kbh27jtnyDLXudubWOP9orMuwuRmrQFBR402ayKZrUQ3lZjdT6hDkMM7jB1BFnBcpqihqmLWTasPKx6bcZVbGGsBotK5pXE1O7HcPYP+M2ya2bIlyEc1yY/5DVgX7aWdsuhw15vxql8gA5yypwxy+OpOy8qPTKGNBRqTukpQuw1jbr1O2OMj7fSS6HNgRYYSuRigEEc+cLtgtjsEJh05KopFOyKR0lrC7zeQGZA3vlejIfjvMSmjPDkqwWQJK0ih11kEJnWxcK/1nB594qsTPZgmDGVqNjPqmKYblw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TstOIiXBGB9nrKwYHL8XhCb0X1C8or19PXL5jaoy1mI=; b=lEDgIUnXAri7/s64AzocHqvEl4duLc0XKgQe9ARibL5ukhbq5ZFm0bSZ7xQ4AWw4AyJWwiKRk63YUAyCz5xXfntTsRsrwKBlDYyy97ILp2HK8sF59SSb6COPJIM8KpElvUf9Z5XI5uwqS59bQJx4AiGe6Rg4mmsBAttwa5fUJaQ= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:11 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:11 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 21/40] scsi: iscsi: use blk/scsi-ml mq cmd pre-allocator Date: Sat, 3 Apr 2021 18:23:14 -0500 Message-Id: <20210403232333.212927-22-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eacf9f02-01a9-462f-a08f-08d8f6f79698 X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ca2q46S5oarfJ3iMjE9O2NwweESBfqic45AZwA1fxff2d3iXkrRLlOdJlW2Po6oKLrVK9ZGmAA5qjzq7t/6SlLaYvId8AFzVWGQqxOlvBFrX39MP6xlEEW+EclPkc28SL3cScTVuJgL1LsIebz6NdBKb+23rBRRt131vAHSZUVPCGF0dENF2NH7k2okiwzUiPvZbRDB2kxhNEfRaBX0+gZszuz0UHNk6wokWEwp8QIC/k/Tt9i4DZh8OBgdwpFhSCs5ylyhecakOnCOShq7dSBChe9RvYIvKU66ImM2eA/+IBezfIdRwjWAIHmj4D0GLd+qJSqeQeJF7qwZlslKPb5KM7T5og7QP6nMMsow/WZK/qP630fcxzM4JzQImk9ObMzY9794LV/ZWeQt2t+RjRdz2iAgDZALPB2LvrGW2gTMunEC4UoTsJqQbNhZ/44++o1wwMDqvbDNjtS39kl/jbzE5Rcbdy6EDotIvwctn/OS0dzwnzOR6iWYe6XK/sRRtQx/JGmg0azOYRS3LW7UdEBIN15UEXfyaOSJfPvBg/7fYFvqRfaSMA7JVKEDwjv4sShkEZF7oYfemZlMYoqfiCHrP/SPKEcxB87J/weksF0kGNtLTFKoxIVcipT+Xwg/lq4ygSi6yN5LK61cUub9sKH/yS+FpF//1Clu/W6V5evtaHApp1iyU/KKmxK+w7aNqFBG8obxb0APoimolVc3gcw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(30864003)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nyQJBOtvwwUA5zREAQ7EJWDcMrjCpgnl1zXomiLpDN8XDVtv3XO+JV6jWjkMmk0hLoes+lbSgHM2w3I+aDp4MmcZ8KA8Wj02/6EdH6cPLLQat5l0xWve+ASGVof344KpiIKy3fXxmTVdRG9I8ODdck6+wbkRi4ZLFaYh2IQtSh8z2cqiRJ0bxEBczDqw0X2BsrEbc/rKtA9jWv9CaiKLd5TssJTPK3cQcI5C/yJYdX3K8mEgsNOJKPYiHp8qpr3MIiBap6UphAHnzURrSLjJ/DRa2Glll5PI088FFpDrhzEI4sbvJl4BHyPof0pN6l7NSRpsZYUltXScGrAkBlcdA9V3gAzs7YaNQPlSwvv6f5uVsGdDKGfwzo8sBrw8CE/BLc2ZYHQY6H/bYBDV2LxQcehUOZPGI9OGiCtL89AIeQjNnnnozgXU4/rQgGg91X8YWnWCdCNjDT/Y8u8/mNQsQpxe8mCp1CtAJ0ZyqMQBKyGAvKQWCGWbvK3tpqx49+tfIJN7UmtBpv5VdzaC4TW3WbGmPUf6zMPW1IBaxpZYWfgD9ulARe3CfIPEhSRr0aNZnCUVyQQa5+S/Wu3jVxJGcaH1WHmbtfat/E6W0cloVY29D91TQo5WKZjKQvVTd0iw++l/1F7yBuhOj55Srz0jSUqieEJr8fhKUvflz8W9pcPY6XXenrQgZfiOc/mjbgrf4qjaxCmTMVCdOwvHrtIYAdrxIkmzMccD0dYUJzRPw+nPIDi9QJY+dP+x0Nizn/eQIkBEw2/hPKCdlOTAZcDnqHq99HFylB6W0JL073V8r0m6FVJYkrE36fKaCvlYUJEagTIg26m34nyEXFp/ohz2azlDx9s7N/e1QThyAd4pPhVhicoWR968wJh51eNySJ2UbuDRKkhWYyX4unZETFB09gG7mi8zJ7MM2yBvqALFp6X9dp0xwJuTl+rt3hDhHuJXLp0KTkw/Vs90kde9bYEyNApbdlLPa/bcob1FzxZIDU5TiJnGdokZ/8DUDnG1QUcRWnGyw0qlsD1SOqskw7DAHlIyJ09WyAtPkevE68XbvdoFTKkmBRECJdd9NYdUZGjCDvz2XJ+XqoFCL1t0HtqYFDU9K/ZUbClRAdIBR338aS4cmtI8G7hUxkICIIEt31Al7g1PWtChuYr4yoYEyCJv5mfATak5t2Des+O9UD052UQBMcFVq5uyA7/0aZ6xMNduExKea38Thxh69yfwAvYjXyq60C7amFO53YtezaFOVnNe1YTMBy61eV77xY2QKnbevdNEDyRLoyJjJs8jMWqt8GhvQy+P4VZq6zg+692uDr9dr59PWqLTdi+kqksRoK2v X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eacf9f02-01a9-462f-a08f-08d8f6f79698 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:11.8564 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1sKF/weX+fFdT0wvwbz4nZvNpfxiA8RVUOTIvtb6fCR5mFugiYE73mXKHvgQUlffutoJKBuaOiRrh3AWE5sMokeHfq2EzzenZR0Uk6m8XYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: RsNrYpJS3J_EnyBR9eOulMacEdyqtHNG X-Proofpoint-ORIG-GUID: RsNrYpJS3J_EnyBR9eOulMacEdyqtHNG X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has us use the blk/scsi-ml mq cmd pre-allocator and blk tags for scsi tasks. We now do not need the back/frwd locks for scsi task allocation. We still need it for mgmt tasks, but that will be fixed in the next patches. Signed-off-by: Mike Christie --- drivers/scsi/cxgbi/libcxgbi.c | 2 +- drivers/scsi/libiscsi.c | 151 +++++++++++++++++++--------------- include/scsi/libiscsi.h | 46 +++++++---- 3 files changed, 116 insertions(+), 83 deletions(-) diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index 919451810018..cdaa67fd8c2e 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -366,7 +366,7 @@ int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, chba->ndev = cdev->ports[i]; chba->shost = shost; - shost->can_queue = sht->can_queue - ISCSI_MGMT_CMDS_MAX; + shost->can_queue = sht->can_queue - ISCSI_INFLIGHT_MGMT_MAX; log_debug(1 << CXGBI_DBG_DEV, "cdev 0x%p, p#%d %s: chba 0x%p.\n", diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index cadbe1d19344..46ab51e5a87b 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -463,9 +463,9 @@ static void iscsi_free_task(struct iscsi_task *task) if (conn->login_task == task) return; - kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*)); - - if (sc) { + if (!sc) { + kfifo_in(&session->mgmt_pool.queue, (void *)&task, sizeof(void *)); + } else { /* SCSI eh reuses commands to verify us */ sc->SCp.ptr = NULL; /* @@ -716,8 +716,8 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); - if (!kfifo_out(&session->cmdpool.queue, - (void*)&task, sizeof(void*))) + if (!kfifo_out(&session->mgmt_pool.queue, (void *)&task, + sizeof(void *))) return NULL; } /* @@ -1118,7 +1118,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) { struct iscsi_session *session = conn->session; - int i; + uint32_t i; if (itt == RESERVED_ITT) return NULL; @@ -1127,10 +1127,17 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) session->tt->parse_pdu_itt(conn, itt, &i, NULL); else i = get_itt(itt); - if (i >= session->cmds_max) - return NULL; - return session->cmds[i]; + if (i & ISCSI_TASK_TYPE_MGMT) { + i &= ~ISCSI_TASK_TYPE_MGMT; + + if (i >= ISCSI_MGMT_CMDS_MAX) + return NULL; + + return session->mgmt_cmds[i]; + } else { + return iscsi_itt_to_ctask(conn, itt); + } } EXPORT_SYMBOL_GPL(iscsi_itt_to_task); @@ -1348,12 +1355,6 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) return ISCSI_ERR_BAD_ITT; } - if (i >= session->cmds_max) { - iscsi_conn_printk(KERN_ERR, conn, - "received invalid itt index %u (max cmds " - "%u.\n", i, session->cmds_max); - return ISCSI_ERR_BAD_ITT; - } return 0; } EXPORT_SYMBOL_GPL(iscsi_verify_itt); @@ -1369,19 +1370,30 @@ EXPORT_SYMBOL_GPL(iscsi_verify_itt); */ struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) { + struct iscsi_session *session = conn->session; struct iscsi_task *task; + struct scsi_cmnd *sc; + int tag; if (iscsi_verify_itt(conn, itt)) return NULL; - task = iscsi_itt_to_task(conn, itt); - if (!task || !task->sc) + if (session->tt->parse_pdu_itt) + session->tt->parse_pdu_itt(conn, itt, &tag, NULL); + else + tag = get_itt(itt); + sc = scsi_host_find_tag(session->host, tag); + if (!sc) return NULL; - if (task->sc->SCp.phase != conn->session->age) { + task = scsi_cmd_priv(sc); + if (!task->sc) + return NULL; + + if (task->sc->SCp.phase != session->age) { iscsi_session_printk(KERN_ERR, conn->session, "task's session age %d, expected %d\n", - task->sc->SCp.phase, conn->session->age); + task->sc->SCp.phase, session->age); return NULL; } @@ -1679,19 +1691,16 @@ static void iscsi_xmitworker(struct work_struct *work) } while (rc >= 0 || rc == -EAGAIN); } -static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn, - struct scsi_cmnd *sc) +static struct iscsi_task *iscsi_init_scsi_task(struct iscsi_conn *conn, + struct scsi_cmnd *sc) { - struct iscsi_task *task; - - if (!kfifo_out(&conn->session->cmdpool.queue, - (void *) &task, sizeof(void *))) - return NULL; + struct iscsi_task *task = scsi_cmd_priv(sc); sc->SCp.phase = conn->session->age; sc->SCp.ptr = (char *) task; refcount_set(&task->refcount, 1); + task->itt = blk_mq_unique_tag(sc->request); task->state = ISCSI_TASK_PENDING; task->conn = conn; task->sc = sc; @@ -1805,12 +1814,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto reject; } - task = iscsi_alloc_task(conn, sc); - if (!task) { - spin_unlock_bh(&session->frwd_lock); - reason = FAILURE_OOM; - goto reject; - } + task = iscsi_init_scsi_task(conn, sc); if (!ihost->workq) { reason = iscsi_prep_scsi_cmd_pdu(task); @@ -2745,9 +2749,8 @@ int iscsi_host_get_max_scsi_cmds(struct Scsi_Host *shost, if (!total_cmds) total_cmds = ISCSI_DEF_XMIT_CMDS_MAX; /* - * The iscsi layer needs some tasks for nop handling and tmfs, - * so the cmds_max must at least be greater than ISCSI_MGMT_CMDS_MAX - * + 1 command for scsi IO. + * The iscsi layer needs some tasks for nop handling and tmfs, so the + * cmds_max must at least be greater than ISCSI_INFLIGHT_MGMT_MAX */ if (total_cmds < ISCSI_TOTAL_CMDS_MIN) { printk(KERN_ERR "iscsi: invalid max cmds of %d. Must be a power of two that is at least %d.\n", @@ -2773,7 +2776,7 @@ int iscsi_host_get_max_scsi_cmds(struct Scsi_Host *shost, requested_cmds_max, total_cmds); } - scsi_cmds = total_cmds - ISCSI_MGMT_CMDS_MAX; + scsi_cmds = total_cmds - ISCSI_INFLIGHT_MGMT_MAX; if (shost->can_queue && scsi_cmds > shost->can_queue) { total_cmds = shost->can_queue; @@ -2799,9 +2802,25 @@ int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev) if (!shost->can_queue) shost->can_queue = ISCSI_DEF_XMIT_CMDS_MAX; + if (shost->can_queue > ISCSI_TOTAL_CMDS_MAX) { + shost_printk(KERN_INFO, shost, + "Requested scsi host can_queue was %u. Limiting to %u\n", + shost->can_queue, ISCSI_TOTAL_CMDS_MAX); + shost->can_queue = ISCSI_TOTAL_CMDS_MAX; + } + if (!shost->cmd_per_lun) shost->cmd_per_lun = ISCSI_DEF_CMD_PER_LUN; + shost->host_tagset = 1; + /* + * We currently do not support nr_hw_queues > 1 because the iscsi spec + * itt is limited to 32 bits, and for drivers that support it, libiscsi + * uses some of the bits past BLK_MQ_UNIQUE_TAG_BITS for target sanity + * checks. Plus other drivers/fw can limit the itt to less than 16 bits. + */ + BUG_ON(shost->nr_hw_queues > 1); + return scsi_add_host(shost, pdev); } EXPORT_SYMBOL_GPL(iscsi_host_add); @@ -2914,9 +2933,11 @@ static void iscsi_host_dec_session_cnt(struct Scsi_Host *shost) scsi_host_put(shost); } -static void iscsi_init_task(struct iscsi_task *task) +static void iscsi_init_task(struct iscsi_task *task, int dd_task_size) { task->dd_data = &task[1]; + if (dd_task_size > 0) + memset(task->dd_data, 0, dd_task_size); task->itt = ISCSI_RESERVED_TAG; task->state = ISCSI_TASK_FREE; INIT_LIST_HEAD(&task->running); @@ -2926,7 +2947,7 @@ int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) { struct iscsi_task *task = scsi_cmd_priv(sc); - iscsi_init_task(task); + iscsi_init_task(task, shost->hostt->cmd_size - sizeof(*task)); return 0; } EXPORT_SYMBOL_GPL(iscsi_init_cmd_priv); @@ -2945,8 +2966,8 @@ EXPORT_SYMBOL_GPL(iscsi_init_cmd_priv); * a session per scsi host. * * Callers should set cmds_max to the largest total numer (mgmt + scsi) of - * tasks they support. The iscsi layer reserves ISCSI_MGMT_CMDS_MAX tasks - * for nop handling and login/logout requests. + * tasks they support. The iscsi layer reserves ISCSI_INFLIGHT_MGMT_MAX + * tasks for nop handling and login/logout requests. */ struct iscsi_cls_session * iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, @@ -2985,7 +3006,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->lu_reset_timeout = 15; session->abort_timeout = 10; session->scsi_cmds_max = scsi_cmds; - session->cmds_max = scsi_cmds + ISCSI_MGMT_CMDS_MAX; + session->cmds_max = scsi_cmds + ISCSI_INFLIGHT_MGMT_MAX; session->queued_cmdsn = session->cmdsn = initial_cmdsn; session->exp_cmdsn = initial_cmdsn + 1; session->max_cmdsn = initial_cmdsn + 1; @@ -2997,21 +3018,18 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, spin_lock_init(&session->frwd_lock); spin_lock_init(&session->back_lock); - /* initialize SCSI PDU commands pool */ - if (iscsi_pool_init(&session->cmdpool, session->cmds_max, - (void***)&session->cmds, + /* initialize mgmt task pool */ + if (iscsi_pool_init(&session->mgmt_pool, ISCSI_MGMT_CMDS_MAX, + (void ***)&session->mgmt_cmds, cmd_task_size + sizeof(struct iscsi_task))) - goto cmdpool_alloc_fail; + goto mgmt_pool_alloc_fail; /* pre-format cmds pool with ITT */ - for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { - struct iscsi_task *task = session->cmds[cmd_i]; + for (cmd_i = 0; cmd_i < ISCSI_MGMT_CMDS_MAX; cmd_i++) { + struct iscsi_task *task = session->mgmt_cmds[cmd_i]; - if (cmd_task_size) - task->dd_data = &task[1]; - task->itt = cmd_i; - task->state = ISCSI_TASK_FREE; - INIT_LIST_HEAD(&task->running); + iscsi_init_task(task, cmd_task_size); + task->itt = cmd_i | ISCSI_TASK_TYPE_MGMT; if (iscsit->alloc_task_priv) { if (iscsit->alloc_task_priv(session, task)) @@ -3032,11 +3050,11 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, free_task_priv: for (cmd_i--; cmd_i >= 0; cmd_i--) { if (iscsit->free_task_priv) - iscsit->free_task_priv(session, session->cmds[cmd_i]); + iscsit->free_task_priv(session, session->mgmt_cmds[cmd_i]); } - iscsi_pool_free(&session->cmdpool); -cmdpool_alloc_fail: + iscsi_pool_free(&session->mgmt_pool); +mgmt_pool_alloc_fail: iscsi_free_session(cls_session); dec_session_count: iscsi_host_dec_session_cnt(shost); @@ -3055,13 +3073,13 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) struct Scsi_Host *shost = session->host; int cmd_i; - for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { + for (cmd_i = 0; cmd_i < ISCSI_MGMT_CMDS_MAX; cmd_i++) { if (session->tt->free_task_priv) session->tt->free_task_priv(session, - session->cmds[cmd_i]); + session->mgmt_cmds[cmd_i]); } - iscsi_pool_free(&session->cmdpool); + iscsi_pool_free(&session->mgmt_pool); iscsi_remove_session(cls_session); @@ -3125,9 +3143,8 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, /* allocate login_task used for the login/text sequences */ spin_lock_bh(&session->frwd_lock); - if (!kfifo_out(&session->cmdpool.queue, - (void*)&conn->login_task, - sizeof(void*))) { + if (!kfifo_out(&session->mgmt_pool.queue, (void *)&conn->login_task, + sizeof(void *))) { spin_unlock_bh(&session->frwd_lock); goto login_task_alloc_fail; } @@ -3145,8 +3162,8 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, return cls_conn; login_task_data_alloc_fail: - kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, - sizeof(void*)); + kfifo_in(&session->mgmt_pool.queue, (void *)&conn->login_task, + sizeof(void *)); login_task_alloc_fail: iscsi_destroy_conn(cls_conn); return NULL; @@ -3189,8 +3206,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) kfree(conn->local_ipaddr); /* regular RX path uses back_lock */ spin_lock_bh(&session->back_lock); - kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, - sizeof(void*)); + kfifo_in(&session->mgmt_pool.queue, (void *)&conn->login_task, + sizeof(void *)); spin_unlock_bh(&session->back_lock); if (session->leadconn == conn) session->leadconn = NULL; @@ -3275,8 +3292,8 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) struct iscsi_task *task; int i, state; - for (i = 0; i < conn->session->cmds_max; i++) { - task = conn->session->cmds[i]; + for (i = 0; i < ISCSI_MGMT_CMDS_MAX; i++) { + task = conn->session->mgmt_cmds[i]; if (task->sc) continue; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 8e01beba62f1..7a78f8c5d670 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -35,8 +35,18 @@ struct iscsi_session; struct iscsi_nopin; struct device; -#define ISCSI_DEF_XMIT_CMDS_MAX 128 /* must be power of 2 */ -#define ISCSI_MGMT_CMDS_MAX 15 +#define ISCSI_DEF_XMIT_CMDS_MAX 128 +/* + * Max number of mgmt cmds we will preallocate and add to our mgmt fifo. + * This must be a pow of 2 due to the kfifo use. + */ +#define ISCSI_MGMT_CMDS_MAX 16 +/* + * For userspace compat we must allow at least 16 total cmds, so we have the + * the mgmt allocation limit above and this limit is the number of mgmt cmds + * that can be running. + */ +#define ISCSI_INFLIGHT_MGMT_MAX 15 #define ISCSI_DEF_CMD_PER_LUN 32 @@ -55,10 +65,19 @@ enum { /* Connection suspend "bit" */ #define ISCSI_SUSPEND_BIT 1 -#define ISCSI_ITT_MASK 0x1fff -#define ISCSI_TOTAL_CMDS_MAX 4096 -/* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */ -#define ISCSI_TOTAL_CMDS_MIN 16 +/* + * Note: + * - bnx2i needs the tag to be <= 0x3fff to fit in its fw req, and has a + * different itt space for scsi and mgmt cmds. + * - cxgbi assumes the tag will be at most 0x7fff. + * - iser needs the total cmds to be a pow of 2. + * - qedi, qla4xxx and be2iscsi ignore or pass through the libiscsi itt. + */ +#define ISCSI_ITT_MASK 0x3fff +#define ISCSI_TOTAL_CMDS_MAX 8192 +/* bit 14 is set for MGMT tasks and cleared for scsi cmds */ +#define ISCSI_TASK_TYPE_MGMT 0x2000 +#define ISCSI_TOTAL_CMDS_MIN (ISCSI_INFLIGHT_MGMT_MAX + 1) #define ISCSI_AGE_SHIFT 28 #define ISCSI_AGE_MASK 0xf @@ -331,13 +350,10 @@ struct iscsi_session { spinlock_t frwd_lock; /* protects queued_cmdsn, * * cmdsn, suspend_bit, * * leadconn, _stage, * - * tmf_state and session * - * resources: * - * - cmdpool kfifo_out , * - * - mgmtpool, queues */ + * tmf_state and mgmt * + * queues */ spinlock_t back_lock; /* protects cmdsn_exp * - * cmdsn_max, * - * cmdpool kfifo_in */ + * cmdsn_max, mgmt queues */ /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. @@ -346,9 +362,9 @@ struct iscsi_session { int age; /* counts session re-opens */ int scsi_cmds_max; /* max scsi commands */ - int cmds_max; /* size of cmds array */ - struct iscsi_task **cmds; /* Original Cmds arr */ - struct iscsi_pool cmdpool; /* PDU's pool */ + int cmds_max; /* Total number of tasks */ + struct iscsi_task **mgmt_cmds; + struct iscsi_pool mgmt_pool; /* mgmt task pool */ void *dd_data; /* LLD private data */ }; From patchwork Sat Apr 3 23:23:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415103 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 D2D4DC43460 for ; Sat, 3 Apr 2021 23:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26CE6135E for ; Sat, 3 Apr 2021 23:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236988AbhDCXYn (ORCPT ); Sat, 3 Apr 2021 19:24:43 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49912 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236945AbhDCXY3 (ORCPT ); Sat, 3 Apr 2021 19:24:29 -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 133NJwpS160162; Sat, 3 Apr 2021 23:24:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=lqAKfPI7QE+skpJI2H4juK07+TiLg2NEMYaRAD63Xl8=; b=i+TZLkBwcslwT7XbP1W0cLKOEN+G09fU/Dq5UQXiZBef88dhrLkkJuqL+xBM2on6SGpE TBuCDs+cMfHWVZv+gubU/XQ9OuNHgvc5/k59N4572T+REo59hQ8LXuzTLTWKcGs1a9fG 7wgnNYBm75UypBv5cILYJd5I+hIH9Ry0Zjq6TzUjPT3y+ii1NdsJnjmZcjColMMGNaYG BFKguu9KSg/CwJ8FZy26dnS/3QiWCQT2QDn5brRYHdoQHPA9e7QznoqUoEBbepCUbwMo vh9W1PV4UHPTLgnhmVi13++PC8Sn4BsuOUoFb9efV+CLr+20P7A4+I0IV8XiCWnwjGot KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:15 +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 133NKuMV117114; Sat, 3 Apr 2021 23:24:15 GMT Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2053.outbound.protection.outlook.com [104.47.45.53]) by userp3020.oracle.com with ESMTP id 37pfpkbsqx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LavbwoSIChBa1tqNLQLf+YvrZAwZShliTdN9CfpwPrdAjqdkalEIW8dgu0fY8zUBxmHAHF94firHR9lifV4S6E+2hQgHwpYtPowQYfo56qU3ihLrTvKw5iedqTURMfyVs7H5UMfnUB2p8wGis+pn/oxd4kViwpOQCAoxQqCIKe7iK2pUqmjOS6TXoXVKJfW/Gm4QnDeKske11tlFS3+hKkVGlt8m1T4zXeQcw6++oV9ZQEr0KYUtRDCcE+1Yfa5rdUdSz0ocMIjG2MTFxmUHoq2BgMXfsK7KHl3Y2VngX8sMhQDBq7U+cuIcNVTK/1JaTbbvpRpkmeIwUmtiT4QXXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lqAKfPI7QE+skpJI2H4juK07+TiLg2NEMYaRAD63Xl8=; b=a1c7m+EsMbIp798QddCyYACXVYEYA1KVb0xMkXxuhrOjkhafJKrbkmwvGhd0SBTyihRTmXsNTPmRks8i1Lmb3U3abwQAGzBL9QMhZszDygWg4e/pAm3AYjILCRQ6AGqMHX8UPwXE4MEuT7R8w8z11h5CnzbH+LnTba/GSx9wTxKbQWg1Ub6xJtsc1zWywjOgTLoR/wOkJDHDnLNn/hJZNWkKlX0JTAiRrfX/wEj51FzADMKDihlWLtLe7uUiK0lGTYHAlDtO25l0CbGPQzc41BgdX53V8rv5y3n7ucCOuCxHdWmdeh0e2WiBr5yrx0bFzMsczk/KtzjqgGUjroTB+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lqAKfPI7QE+skpJI2H4juK07+TiLg2NEMYaRAD63Xl8=; b=tLymLs85i/EoYQx0EdFvJfolJuv62hNmAK3fnENmCJrJxLmD3gt7DmxxhqLk1uQrRCX5CpJslSLiLQexTy5jjTCJtXIIoKhhFUyacCciaLM4INoxLZZXMPw/3dLHncrjrO83yC5dT1ao0hZI6nvl2n5MdV1snhMMlPTPGbDDiAA= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3526.namprd10.prod.outlook.com (2603:10b6:a03:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Sat, 3 Apr 2021 23:24:13 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:13 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 22/40] scsi: libiscsi: remove ISCSI_TASK_ABRT_SESS_RECOV Date: Sat, 3 Apr 2021 18:23:15 -0500 Message-Id: <20210403232333.212927-23-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f912624a-e5b5-4aef-089d-08d8f6f7975f X-MS-TrafficTypeDiagnostic: BYAPR10MB3526: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jx+H3iX9fj/BjSX7QvswcxR9ag7gii7iUuOZ6QSwbHIkDA3Jv0dZ3EpEBDSQeyBb7JtMGaeqIh7aNB0B826DaeVbQTzREreN6kGinrLMwO7kbviyQXbCJ1ttgpQ6yGkod9O+kniuvytYltu1QYSA7ukTcBCu1sO3WZZ1DeyrlkJESNWMxYsZLcgrKwHXAmXARDAMBY29P/MuW5CTYJNuChCnS6xS9OOVpIqqA8kwJL4q/BygFNvC+lKfADHwntiqac0q5wJa+Hs27vto+liyFDq22ByZpt+HPYnPHZzL418wwWSNKHPekUlisBKSVDKyNIelDD/47VJD6bxAGcpAAU2HQ3tV6HwES06mwqASwku2leYCP4CL8qr+HKjGlF4eIUqmG0ILgCmzeBL41YLDV2wDe9u4vgbi73k3XNDx18ORR7KA5Yo+yTNnx872xTIP4itmE6f7ZDe4npf92POoeXG77E4a6WhXR1uyLKBWeAe4awCz2/JTqrtcVrm4DSnKv8Bso+yl0bj53EFXZmBd6je0VYoJrKInts48x1XzhtBUoKSswulRfOu7ph5cSOtPxSz8QmKMTiM9Kx9RhjgU1/2nURWkrydITshgVGD4y/GpLCrhAmZn6M9UniqXbU+bF0lJ56sjtXAvpd6suft3u3jzcqndNwF3xNhHk1fCuYubuLTzDjor/BlC5+/TKu9/s7IU4+m9dfK6eDKg3fhggA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(478600001)(5660300002)(69590400012)(921005)(86362001)(6486002)(107886003)(1076003)(186003)(52116002)(16526019)(2906002)(26005)(83380400001)(6506007)(36756003)(956004)(2616005)(7416002)(4326008)(316002)(8676002)(6512007)(8936002)(66946007)(66556008)(38100700001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: z/nqr1/zhMflhArq9k84nQY9RSQkpXpuWnTM5F4YxX5reWn32cqoyLYDP6f8/4qmZFvGVUi2+1LBRBQFBeRimb/X3LFyyr7JSJ/7as8UJd+HBUhI/4YfLGEX/q0V1vZnmDVjW1baaGRmnaIPMdqnzmY4WK1g/aYjMCEVB+NBSHZTtqLBIQ+7w8Ss1vM1kD2ZX8xYib68uyEoI4yOcsNO2XYoMrpvZq662qaZo8gSFi/Hgnw74irQfLf7jVjCzNwlbS2yRunzQYdKsiV3D4w3ScWiRHSyW/INfYZR8PZcJaTvGbT+9+kIR/Rt+LMlNvFIHNGT431ZIHLY08QVT01Teatx3/gVEXaAUd/0Jq5GmO+t1nD8vbWkjuWm2uL+lDBx2aOvywH6hNXi/c5aaL40VCEZTeue4HLDdP99AyjQo6v+8mUxQjQdfowQ89Q3MXBJMPdP4R2nvHZFvPEC+DHI7Tjw//r48ZDFW8wFmc12aIu34lwK3uwjuybuFLO/+0VAmCughzo7W37CQek+Rbg4uWrJyW6v0hsWC4u2mhoft2HnToUPWD2yG5Ce4NWB/yX+8+nTbau3S8ayU+poy7QlG7HMeQ4XOWmUVyCULQCDlw46PX9jfN279sl0sC4lZtakrygXnJR+ub+lsvVZkMstval45lkj8YodvqdARZ00NgHARjsoo9MhW64SosMylxAoogj1SpogKPWAalWieIldQUpg9rG0mkEQWB1SiyqeyY7my07cPzSArzImNvzibJdAcFJ9buZgfxT5p7FJvvl+HdaS2O4g+JAeLgkkwGawj7qPdrkYPO+VJlA+CqH8dzxlyGRacmX7OP4klQK+C83tiFWMDesJafxma8PdnA3RUcWIjoOeAEG+gN5JEVZv87u1J6lvbXs4Sdvb7AX62QY+hnM+gav5knzPBa2L4zSOQaPNBuTbK5leigDsH3lS17tiUEBhJ2f8alBadArikntsZO1JgH7RKh1A62dejl0MmRmejjls7MHbvqyXtu3GwTQZQGAlN/3rYEQ1/lczXbwA7vLjfPt8Nr/0w3C8ZG4j/Xiis7CrzVUzlwLI0TP63tewUsQ8LPPgx2KSm9VeqyI2yP564dc0YVfxodU3WDDEhGYIFE4YvtBF5Pl9DtliMxxf3cC+F3E0cTjkhqniwnAqErNGLtXcxGz8qkTKP7njxiCU6cud53qk4Cl41opHe/4tQEnxylKGrk4wZWT0Fca13jPk9t5zNHGoxj7iT2DTAjjO+ti0peauHVSa/yfT+1tHCSiQUc4JpB5nhgI+qwRZv+1Mk6hksEW3Vba9U/rlve9Wc7A6qf2bzyxlkEkA9idm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f912624a-e5b5-4aef-089d-08d8f6f7975f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:13.1616 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h3p/VnxjsBQLtWg2XSip6dSI+pHxhR4eREQ9DCijwKKTDWDODDxH15waHC7fKqHAK5v1D87Uw/zOr3CFDEU2dolf2CvA6Io40NBVAkIXtuo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3526 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: EHZc7tul_2sFtkjgvujQ1mXrayrOlhAh X-Proofpoint-GUID: EHZc7tul_2sFtkjgvujQ1mXrayrOlhAh X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patches simplfy the task state, so we can more easily use it to detect if a command completed without the back lock becuase that is being removed. This patch removes ISCSI_TASK_ABRT_SESS_RECOV since no one checks for it and only cares if the command has completed. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 5 ++--- include/scsi/libiscsi.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 46ab51e5a87b..e2f3217afdc9 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -517,7 +517,6 @@ static void iscsi_finish_task(struct iscsi_task *task, int state) task->itt, task->state, task->sc); if (task->state == ISCSI_TASK_COMPLETED || task->state == ISCSI_TASK_ABRT_TMF || - task->state == ISCSI_TASK_ABRT_SESS_RECOV || task->state == ISCSI_TASK_REQUEUE_SCSIQ) return; WARN_ON_ONCE(task->state == ISCSI_TASK_FREE); @@ -614,7 +613,7 @@ static void fail_scsi_task(struct iscsi_task *task, int err) /* it was never sent so just complete like normal */ state = ISCSI_TASK_COMPLETED; } else if (err == DID_TRANSPORT_DISRUPTED) - state = ISCSI_TASK_ABRT_SESS_RECOV; + state = ISCSI_TASK_COMPLETED; else state = ISCSI_TASK_ABRT_TMF; @@ -3310,7 +3309,7 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) continue; } - state = ISCSI_TASK_ABRT_SESS_RECOV; + state = ISCSI_TASK_COMPLETED; if (task->state == ISCSI_TASK_PENDING) state = ISCSI_TASK_COMPLETED; iscsi_finish_task(task, state); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 7a78f8c5d670..589acc1d420d 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -97,7 +97,6 @@ enum { ISCSI_TASK_PENDING, ISCSI_TASK_RUNNING, ISCSI_TASK_ABRT_TMF, /* aborted due to TMF */ - ISCSI_TASK_ABRT_SESS_RECOV, /* aborted due to session recovery */ ISCSI_TASK_REQUEUE_SCSIQ, /* qcmd requeueing to scsi-ml */ }; From patchwork Sat Apr 3 23:23:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415233 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 F0C17C433B4 for ; Sat, 3 Apr 2021 23:24:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3AE66135F for ; Sat, 3 Apr 2021 23:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237015AbhDCXYo (ORCPT ); Sat, 3 Apr 2021 19:24:44 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49920 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236959AbhDCXYa (ORCPT ); Sat, 3 Apr 2021 19:24:30 -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 133NLs8l161540; Sat, 3 Apr 2021 23:24:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=aC8953mzsSDJbWNpC2hTfdHvgnMfNPphW+PPJ1mY8AY=; b=e+JkNBp+tp0z8WMcrm9q5xjq4BR1QAPqTnAVQiz276gh0K0H8C17wQgsnhWm3TCgy+oh vpsMrUSm94PutEapyzwkTFcb4CjdGU5+PB+S8HC9LWtnw91rkattmU5YP7B2sx/L9adz qNErhduq7luags/GjJhkZNzzBX5SkWVygQmJWwAI69z16uda8mP9QJpslJ7xZxybMp/o yQq6cR13z0OdpuitPVNjvikqmLdzTtazCES6Y3TeftVQHPMley8UizdeidPY3Tx2i/1C IMa1xHQMIqUCLhyrnWXggx25E4CCDm6pb1DNoDBbo4hV16mINFaBIaxfwH4Cz/NsomgU ww== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:19 +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 133NKtWj117032; Sat, 3 Apr 2021 23:24:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 37pfpkbsrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FjdBfo1UIpChwNakGBXEhFC1X9ajJGq+gtpAYMorN2LuQkg+yzewyOGPrcNTv1elhK08vlD96xKjjyZXbWG36vtwY7UBW4KbdL8IHgBIQlwvuS2mdVIBzwxdSAbjipovhhICWTG8HvVZ4jUUW/XFPq0Jx6eU53eW+gZ9EBnzpcE5cFjQqWH0L5qFwH9kIc5ij4BpKNtSpZbAc+MRHKHOnjjN12hkxZ9G+EXGQ1FtFN0lx1Xq8QzsxfnwVT36XrUpcowTeWnXU0Cdks1WuBAIDmKKH7WbdeyERTg09kFc3WMtZp6NgNox+kmGGKWBdY7E6IRa2kfYV9/hMr5boNr3ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aC8953mzsSDJbWNpC2hTfdHvgnMfNPphW+PPJ1mY8AY=; b=ZkvToi2Ax5t7EScjWGr4J6KtOrQKnaIUPp+sQZSJDwBq5o/dAzODx1yo3PlSIw11VnBmrWD93ifsaEwkAYpBrMueNsrz2Q60ZrbV1g4Jw3Patvj7cD7rd+mVMZz19LdO2se9mMluMxHIwm7knohUASQtnA9BiQaYRVs5cEyx9O13LKcovKN+tab8sREVkYJ5deLq3+SEMKrQou26JHBQwT7gNeu4ORKg4BTaNduJXOyfSj6cQBKF2bjqKJz3rQQy9CJ6rI+HN8OwZv4g3U6Q97CrE+5b/2IBDue7//Vg7fM1p/vmP/tZOaK9FPUg9qheGQcCaMtjRp/U5fhB9c625w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aC8953mzsSDJbWNpC2hTfdHvgnMfNPphW+PPJ1mY8AY=; b=Oo1m0PVO98EC9rFnWsjmR9wd6wuDPFQtD7TpjI7QFgSUtFfezuszBOM8IgP6EVP/oKf7hu0emex81/dTU7JB6SRa3oeKOWsZfC7+W04b4/YHXlNWjBJnTutxckoRjkLBcCxw/f2N5AAbJ2+RJmqURvIY98H/S84FLpt0IMbeR18= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:14 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:14 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 23/40] scsi: libiscsi: remove ISCSI_TASK_REQUEUE_SCSIQ Date: Sat, 3 Apr 2021 18:23:16 -0500 Message-Id: <20210403232333.212927-24-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee028ac6-2641-4f21-5675-08d8f6f79828 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EJVjCquGD5hpXgL79Qwp5arCkRCBSByet+D0AwFdx1w43U0ANjzZJLVTSxi9PJ+06/9C2n+EMjX/E/ZpbxfW9Yt0tGlTt7E114oFqkhFRaLT0UiAN/sXFB2bQCv3xoA2+Kiv10DZDFeOxlQ/81Rrn0FW+/mXkqXW2TK88H4b8R0IwRgs60QowvkJSP2gwD4xN3lHNUrnHG0SiKPtsa4NpvMRv6f+FgxZv0zfS47oNS2jFf5Ueh31oAmuKbynsiXPPmjmFzRFQfshsGHNSZ+H0awRyXKnkHDykOy0N/pxGPqidSd/c3ieQa6x1BqG7YFj9+1WY+qd6LBF6xDcFs8kbVFisw4hDkfoi7L+u9q9nDDeGJIll4k/0v17hoZUkLAvxeubXTTDzG6Znf/bDPhPLKuv1ng+HhAEKKFTErzNSentYX8TmHQdrSGMm1t3Cfx28aCNfBoUdub2+zob8zppHuPvzU+ixJqgknU15YSLH9I7ZEyHhGoAFIxr3i4UqbfKvzssK2DcJIxWFXvbucdPFtdoQRwQ0HrokkIIs3RMeB1YDOAbcGJtey0aE121nh9onbnOrewWv85fDsnCHIXl+swQSzHh+EO0wpoceklDDO2ztbPD/jwlTLGZGGTyXspv/tuuh5sKh0xBhMP7inat20FxE/migUTOnem4osLehJKz0WsBEubrd4HMSdoSBSAJKZ7QObYTzG2BnwyWi5KVoQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(8676002)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jw70AP2VlX4An67oregSfdoZ5jGdEgaae93f4mGCVX/8AT4AuFtxAG4bqjuVOKPPJqsmD9ZwyRoKppucLc/Rhf+mASUji5rFSzidVv/Cz8t7gdkVpxQW1JQnXD7tNCuwbbMjjTJABXJDGDjgGCHjt1GHz+ynhEV2DSuh/zfNkpZQ+/fYDS8vcJ91uVGWG6o+f36/BphTh/TkXotW/WluiGjG8Du1W3XV6YrQ008bkSDfOoQnVM5mTZZo+vpR8d+rSI6eJBy+KzRTHVvXojwCkFR9p04BiLMIJXjfwNjWdSpk0O0InnUwkgDljHvJhxz0SuddiWvj7rZbJSMItmI05ygsCagZwZ6a5XNdN/0+Q9HNvP7SK7/b3qNVzpGkk+/SmEscMOnMrYX6I0d3O5RgdBRbq+J97zJ6XFHps5vDNfKW+WlaDPfgpn8k7XFlKWTHqLSPDsnQxNdBQGeL+swmhpQ9bRp0haYV41YukqcKuWrqg2EzolIIZRbC+5NZXx9w27Dkx1RfNyJzxetO3cFRe5Mbj2vFXZXNuHTLZM656tMf9rIlmZHjRfk88Hty8lgNxzrqHhSgH+mVd3/CxyFjlkkgiEs4rizwHMQiO6azIuxRrp8ot2xmIyEej7NJD0iTpMGDcStvsfTQAmKYi1NBltCY1SEazznjn4Wd2QpKc1sUPk3AUUsEx0PAUe3pma/c8iKlLhMZRLdm5sEBzP+2/1mXa1R9l1cIexJVyquUjSX8Rh9rOi22kOET02YkRJ64gcNYpVBIJZZyXDSm/56mgLqjlRNvBLYbA3AsPFWDjXi/7XZbJ811T9LXTsAb+aPFE2D4NErGu3WV9p8bEgxYCbHefhuWwJySRDlYw37ZqI3jHoUYzzxSrYIAjL3xgGO8mtDqMbXXzfgXL3OAO9vpCD5qjuyVLBhM0sKTgpti2KGjM2BVUVKDb+VBLgFaOfVf54nAmuVtmmmDSQzmCGM4Hi4ESzYnnmyXUnrWLaV1eevy90iu8M31oVarv5jlhPexK27xB98uU4Q5cp0+XbLugz4hRf5c6RuE+8A17ZPUkXS2fwC/Nwb4I/amFDbLZeahgMv+tQKRTUcjgA96w8erEjwc0cfKUvGRKHtEmR4mXyDaCfgwEelx1Gbj/EAUXxX1d79KUVLHIi33kn6ZJvuFW6mmgH8Ixhh1JqJcThXMZOXEDYIWvpk1w8YSqjSzPmHGBH8yg9Ue00VxnvtU/5dbMvz+9LPHYJC+QSm0rV8La/oaMr94ecfS+UCrvu/34YOrCuJZGO+iVmN5wBfcTQQlWGnN0SsGQiKRpE7x8PCA35+znsT02/N51pOQmqv3eF3r X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee028ac6-2641-4f21-5675-08d8f6f79828 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:14.4919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HNzIif8cVE9VZRfGz+mAhyYbO+QE5ZN6T2VDQFCkj1xuBhGYJHYEjZJj0p67bYwG9oVmuX6gbIfApC5xZOwrEcrBJKa1CVtWJ3bfDH7F7Bg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: J_fkH0kTv3nKi82VdFAfKCcyzk2czB6x X-Proofpoint-GUID: J_fkH0kTv3nKi82VdFAfKCcyzk2czB6x X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ISCSI_TASK_REQUEUE_SCSIQ is just kind of awkward and it's wrong. If in queuecommand we are going to return SCSI_MLQUEUE_TARGET_BUSY then we must have finished up cleaning up the cmd when queuecommand returns. This has us call the final cleanup code directly. Because the cmd was allocated by the block/scsi layer and we've been under the frwd lock the entire time, we know that nothing else has a ref to the cmd and we can just call the free function directly. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 39 +++++++++++++++++++++------------------ include/scsi/libiscsi.h | 1 - 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index e2f3217afdc9..00a25af9eb98 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -437,19 +437,18 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) } /** - * iscsi_free_task - free a task + * __iscsi_free_task - free a task * @task: iscsi cmd task * * Must be called with session back_lock. * This function returns the scsi command to scsi-ml or cleans * up mgmt tasks then returns the task to the pool. */ -static void iscsi_free_task(struct iscsi_task *task) +static void __iscsi_free_task(struct iscsi_task *task) { struct iscsi_conn *conn = task->conn; struct iscsi_session *session = conn->session; struct scsi_cmnd *sc = task->sc; - int oldstate = task->state; ISCSI_DBG_SESSION(session, "freeing task itt 0x%x state %d sc %p\n", task->itt, task->state, task->sc); @@ -463,18 +462,21 @@ static void iscsi_free_task(struct iscsi_task *task) if (conn->login_task == task) return; - if (!sc) { + if (!sc) kfifo_in(&session->mgmt_pool.queue, (void *)&task, sizeof(void *)); - } else { - /* SCSI eh reuses commands to verify us */ - sc->SCp.ptr = NULL; - /* - * queue command may call this to free the task, so - * it will decide how to return sc to scsi-ml. - */ - if (oldstate != ISCSI_TASK_REQUEUE_SCSIQ) - sc->scsi_done(sc); - } +} + +static void iscsi_free_task(struct iscsi_task *task) +{ + struct scsi_cmnd *sc = task->sc; + + __iscsi_free_task(task); + if (!sc) + return; + + /* SCSI eh reuses commands to verify us */ + sc->SCp.ptr = NULL; + sc->scsi_done(sc); } void __iscsi_get_task(struct iscsi_task *task) @@ -516,8 +518,7 @@ static void iscsi_finish_task(struct iscsi_task *task, int state) "complete task itt 0x%x state %d sc %p\n", task->itt, task->state, task->sc); if (task->state == ISCSI_TASK_COMPLETED || - task->state == ISCSI_TASK_ABRT_TMF || - task->state == ISCSI_TASK_REQUEUE_SCSIQ) + task->state == ISCSI_TASK_ABRT_TMF) return; WARN_ON_ONCE(task->state == ISCSI_TASK_FREE); task->state = state; @@ -1844,7 +1845,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) spin_unlock_bh(&session->frwd_lock); spin_lock_bh(&session->back_lock); - iscsi_finish_task(task, ISCSI_TASK_REQUEUE_SCSIQ); + __iscsi_free_task(task); spin_unlock_bh(&session->back_lock); reject: ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", @@ -1855,8 +1856,10 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) spin_unlock_bh(&session->frwd_lock); spin_lock_bh(&session->back_lock); - iscsi_finish_task(task, ISCSI_TASK_REQUEUE_SCSIQ); + iscsi_finish_task(task, ISCSI_TASK_COMPLETED); spin_unlock_bh(&session->back_lock); + return 0; + fault: ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 589acc1d420d..ceb01ef12002 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -97,7 +97,6 @@ enum { ISCSI_TASK_PENDING, ISCSI_TASK_RUNNING, ISCSI_TASK_ABRT_TMF, /* aborted due to TMF */ - ISCSI_TASK_REQUEUE_SCSIQ, /* qcmd requeueing to scsi-ml */ }; struct iscsi_r2t_info { From patchwork Sat Apr 3 23:23:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415232 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 6D057C433B4 for ; Sat, 3 Apr 2021 23:24:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CDA26135F for ; Sat, 3 Apr 2021 23:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237023AbhDCXYr (ORCPT ); Sat, 3 Apr 2021 19:24:47 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54988 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236950AbhDCXYd (ORCPT ); Sat, 3 Apr 2021 19:24:33 -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 133NKHZG085514; Sat, 3 Apr 2021 23:24:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=KbcFnul8BHDnoY/3HGL3XfPZUV7AEC5QmF8qvwNFHbk=; b=TRWYRIfuAt9xOAquSDrANJg8GjHI/7O/7pZLAL+kKEEC8exDdYmPm7YzVwEkq3SCcAbr E4Mw7/CehAVJFjXUo7iesC1h3p73l6PdbxhlzKsPGyNVtpw2tk4OMzvSwYn/gIYgQNna Bs9a8EigImR0LL3YYPohcKSu7qpCofjNOJ+eTqGw1shr5tY/HkmpPSZ4hCA64qA7ZduJ 8ROZmCmbF9qn3OPAmkwi6dZFIdXnnJZaB696gaL/uGcL44PHSCssRWBW0t/V4Nsd/eOT pFwW5ewPquKEBharuVzfo9SqsUrGWjU7hxN5Ubx71AsZxAWDUL24enYE9jwYE3ovESbV lQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37pq66rcv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:19 +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 133NKtWk117032; Sat, 3 Apr 2021 23:24:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 37pfpkbsrd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vn1oHTihM7eQ3OgSv6ECT1lmJaFC6VpWt7SWuUZic3KqALMxeDOUVJpGHU/yFtRkdVf2MhaQQ6n8VQoDOzQeA5V6U9Vr4+fwNNVKvEAW4+DdYhIoHtPCupk+beZVOmKL1cc+zQs2Xh9ZJnhfHMwnp3094BCq8ofR+u+XDOIZtQ3soG3GgsOaCvs9t/yaCwsecPgC9A2QowOL0behMAE7lVagjF3y7TzHZfsVJbMTb9d8/m4lUvDeX+5YVtBQs8N5yaroTtYo7eZxbq4iQ505HUzv6sOv55iogwthlltcjv+NTSLtK/xIZON8NYkH1E4WmD1qWd9XjXC48qYcxsLGMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KbcFnul8BHDnoY/3HGL3XfPZUV7AEC5QmF8qvwNFHbk=; b=idkGsk8N6l2UvTiVF28+3oTcLST+BNsZEW8OyTuXrV1EwqSCMWAdQ90cdOsoVo5Gn+91ISt9vlO08rChV6gNzRfFN6UC+zNjCaM/u8qN9wPtAN7SbKQb39ht0RSzp6MnEYO5UVUwMphbSPJqIeQu20xpCJDQUGuyl7lvGw3XGwfa8LahfcRlKvI2rNN6fUWYjndXJSFBBzQCVvBN3A+xyYwq0forYaUe1+mfqtlyavqu/yVm/p2hIba3Waj82QpA144CniKMT8fF8OF0EAQ61WGtG44ppD/efBfySLa7RGUe3rW+onT4a71289Et3gmo3kQaM0+gszfbmVxRBkCSSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KbcFnul8BHDnoY/3HGL3XfPZUV7AEC5QmF8qvwNFHbk=; b=nTm//mDXQc5wy24nEDqDqEvSzw7u9Z14XTBkhiaZ2V6aMP3LqCEVSWW+C+NwNO/1qtsnN6s+F1Wqm+UaABXaLtQ+oYM3ixuw7WDDuzRjDcercm0g4gbiIN8IbJpr+KyizaHF6E9vlF15VBs3geYYKwv/6Y40wakbGDn/QbIWEAg= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:16 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:16 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 24/40] scsi: be2iscsi: check for running task under back_lock Date: Sat, 3 Apr 2021 18:23:17 -0500 Message-Id: <20210403232333.212927-25-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05e3b572-bf65-4e95-e118-08d8f6f798f0 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UtUrQhjxtebWcbj4RS4nStNrC7CyeB+Mfp7zT4glteK6Gelh1Pt/PQLC7WCjl7C4oTnCpPX7oMu6gPFRtZ9y1LrklCXZ1wYQ/Fjn65v0a6tUHAI+pf5p2e7d/AKf0IlTuL2R4fC2A+3fRxsNylxpVjjfSxUA2Zs3l/nFAG8voDxpH94WmZrXdTbkEU5Jv9kRDluaZ/PwIgkV3ZPDe4XYNpLFfTbe3e71bL2l9h+hx5fp+V7LwR6b8JI9u+YoOJWVvUxVJ26eACTUq2qSkUg3SaMgreexCyDevfRJuU3c2P+9fCenkSWEdZ7r6zbUwYoJLA2Wqxy9LpgA7+ueIUg+lydkC2SjcpNr+wiX47jVNWEwVU/4Y9YmbxnYs6g1cAp3iYIC+NBjl2tkOz4VRxiriWN9uM5QY0G9FVpFFmpUxO+g7rJRVFTAeovtbdWtA38oMMHK2xYPES100Hx4KojktqptTg72jDrSiDL5k7hc67CuDHQrkid+MqzBGmT2JmvLNeTNMxoMfSb4k0CtzrUXCI+snyoJSYrsQQec8CWUN9+XhTlcO3ryBXcQ+WTjEQ68MMe0sZCWEo87YZA1c0bIHKeT2vktM3TPUG6H6hjwScwH+wXytMKtOQ74Pd8eku8e4+keMcA3P11SQ4s5FTrfLJoQPNpu4pZX7RsjQRf+2M0PZAKG71d0DsINZFn2DhTx5iQmolKsB3bKV0yDB2T5Pg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(8676002)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Jc7cz/NebZsjghcMZdeICTm+aYlT+8wfJt/BcWMENlGmPMcEHo7/uajqVTkm7czOuLT/H5U3kPdH3o0Z3LUR6/AdANmPCLQnAPeHvYZbuMquPYBUfco2/z8ZmcmCqOhwhtZnJ/Ankd1aRsG3cRX4J9FwdHmM5MgVI5FCiaQUvnVlnCgY0Bdvl7vSO/Z2b0EWzziNLccN/a+aOxtb5GgZjE8Dq9a8xq76ppEmAX65cU0Zb93Rtu/+iCL9cMOgGTwSbmjbmrJ67qYsVdu0Onrds5Ze5iAD0B1f4FJyFis/r1oXlMbKVj/IGBPu8Ok3qdaVWgcXP+yUgodoOJB25hiloUj11R6LFeyH5m5pxIYTiWtbJN1JGxoLy4L/jXJpCTWKFxZQtz9+zN/vGAI/k+MLpD+WVj2Dn6/LJe6FIhdsICdVC1gFAq9znzRaiVSnrv4Njk4H0smEhBV8DdZKRN355Trp9U2c9aOLEvZVcxiyy18q0PRHZSVknU5iBfJAJ4RZpXhKrnkf3R5cnUpLRH8udHG+ScJePCPwA5Arto73hhvjCVT1IMTxL0gV3cFUNUIaoZLUdysDBJPAi4jeZo/38IOjMZnMuynWVUVJx/Cixd/p0qRFpCV+oapPrMh/mqcZxHi/ldgT4toD1PecH2fdcwWnjECn06gk3dRFewPhXqjSJC7iSiO1f2TQeFazWKrUdIlOka2ucClm7eMi1/TbL+lujzbgclf3N9RguUFIn7ltGCZ7Xc/8r1+UQB6IyN8DkU1Hxv2g521CgTVqcOUxrHPn3NM+JiuMfY6kY3QXKUzad2aNyuFwQG71XXsSpHPa3eMmqQYDNyJSS+CVV5Yeh2KMXflTWW+BsxFkwnscRFtI+DmtPo1i4qimGDXVJGpLTnkkFJIp/EO/y4KFYjC3kFw9/lgdWYkHrAIe/R+/2uaE4z7Bnm0znY+69mJ3S2NhfYHL44s986Gcfm2A2KmnAu3ZeBjm56JS4PpBfUnYEGjvC3MjNjBibuygGk0QgXrotbdzCbK9axCALxQPU1rg1++ZhGjxk+QU3W55X9W673SjZJjhbb7QOnNmmg76ZG15uKJq+ejXk2gwqpS80jXTLMYhCLr55deQKu97lrlPzUO8icoiLfEg0zEwrvLyG55NkilXkTgNGs8KKVMHcMYXHOIAQBe6bSD0fiiHHerkO1fag7jf5SRVql+oZ1FizsF6VPFAkWIm4D11XZQGLGXrOGRcfFWAPsKsKweAOnGfPQzJo7+tU3G4mRkAQjLDUPXNk5m/o+kPiyWCOcVe+fjmF7ymKvjnQis4FOHsxPE8MVoiO3sV0/KYWmI/qBQMznyc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05e3b572-bf65-4e95-e118-08d8f6f798f0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:15.8581 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7KVpzu/WnK6GP8f1ZckIaDItX23K9pwsHE3S8J6lP/KOh3+iGGd/4KJuIfuwDN7PfFVrvLFlqcZ0eIPVGfDfT7fEWhCiy/zZXJXqfahujDY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: gAllCpQ2vegZR3sRJP5oFVET_cVQea-y X-Proofpoint-GUID: gAllCpQ2vegZR3sRJP5oFVET_cVQea-y X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The tasks's sc is cleared when it's going to be sent back to scsi-ml. This is done under the back block in __iscsi_free_task, so we must set and check this under the same lock. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 99eae2add8da..4181769d7303 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -216,12 +216,12 @@ static char const *cqe_desc[] = { 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 beiscsi_io_task *abrt_io_task; struct beiscsi_conn *beiscsi_conn; struct iscsi_session *session; struct invldt_cmd_tbl inv_tbl; + struct iscsi_task *abrt_task; struct beiscsi_hba *phba; struct iscsi_conn *conn; int rc; @@ -231,7 +231,8 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) /* check if we raced, task just got cleaned up under us */ spin_lock_bh(&session->back_lock); - if (!abrt_task || !abrt_task->sc) { + abrt_task = scsi_cmd_priv(sc); + if (!abrt_task->sc) { spin_unlock_bh(&session->back_lock); return SUCCESS; } From patchwork Sat Apr 3 23:23:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415101 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 BFD14C433B4 for ; Sat, 3 Apr 2021 23:24:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D56F61361 for ; Sat, 3 Apr 2021 23:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236973AbhDCXYx (ORCPT ); Sat, 3 Apr 2021 19:24:53 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45092 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236970AbhDCXYd (ORCPT ); Sat, 3 Apr 2021 19:24:33 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NKJiK097412; Sat, 3 Apr 2021 23:24:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=UUD07z7QbguOgdelNpJw1RzE1qxtr9WjpkTD6DTLl/c=; b=sz93juKkzjxK9SPvyugq8WGhtMwPLz5f4FfDMcFIr5oqFyEM7jRrhzqGWX/RGiiefSO6 nQTuP7bQr7sn6sRcROM88a0jASKPX6nXa9jBK5GPv6FXlWK9V0wncY0MQvHWgxedg2q9 vk0OqH9jLcETAyD+frUqb9zu99ahVx4ZE0iApOGqfjZ0OJfsbdHrM9MZqwTB+cmxGmrW 95yryJF+9BlxTtCwMvQixjtCNiEYDJFbDvVZdIXEhvd1MKZYLSYq1BpZIYTwb2N/84Af MjnEPLa4pmmFMGLY/GR8wOeIUPsQB3Ws5ZhSgznnd2Eq1eXDc9EZfg5Zx7EPOU1nxCCH qw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:20 +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 133NKtWl117032; Sat, 3 Apr 2021 23:24:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 37pfpkbsrd-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0DN113trwd+nUAvhksXjynoqtkUVSPm5vZj1l+PG85O2xEvqaZU+adZxW9y0pZxX9STViPhKBfk1ekn6CbkwoHfslAdaKK3g7m5qyArDkhpwpVgc82GFtIMFuIfL9d36TTxrh9jACUIy6GZX0rx5WuPNZXqChY+v4etCvL2aFmZSMdX7QcxwZ5FPOJ4B/CoNiFkaBJqUmQggU8zlcvlkVaK4r5tjcUqymgfo/ZpTusLWf/1IVEnYYHqCtm+7ogV5po3110qr/Hua108/rYTvWFjjpl4EwjAJT0dRg0L+75qsHKFCMfnIJ78yQy+MqchXPWsIF4zpeeOzLiPhGS3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UUD07z7QbguOgdelNpJw1RzE1qxtr9WjpkTD6DTLl/c=; b=XbcwgqzSv6ZhGBn7UBZVELxwtC7blUuo9ZWwVSNvmNzimRRKHq/eCLx+mnY8lSkhj2h5mzJGXO4XuNQwWO7S1u8TJLrzrZ37rTViNo/IzNpdntyJQ+zhH0yxnAqNLNxHv3ofS1qvgM7NZXPDZzS4v1DlfhQGcE7YxCoHWdRYC43bSqW64sd2+y2ofHWUtUIEmrtpCwIXpMLHbL95TTYMGzznuzgIIYniRp+LEcG50gxabezg4RUsUVOw1Cd+vh19kpPCTh4h0xiT2nsBrYwK1RJWBMIaIacV5llLMi0Y75Ro/ARTuDR7SYIn4XLK42XiUibSqVtg/yRDfQiJQXTAuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UUD07z7QbguOgdelNpJw1RzE1qxtr9WjpkTD6DTLl/c=; b=uC0oKGfHjiw7n6cvss/b+1XRU1qpgqiKunfhAZWrYYGTb4MS1jmXARse3x8MQaxTd8OV74K6ueKD3y+6izYNJXjp763o98vmHVRBUZm3JmrhONNqJ3IYMaiFR2uQoL3VeZdiVjUiQQxiJiFv6HfNRkMvr4HdhYFUTRe2yyHFWeU= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:17 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:17 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 25/40] scsi: iscsi: add mgmt lock Date: Sat, 3 Apr 2021 18:23:18 -0500 Message-Id: <20210403232333.212927-26-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f45903a4-3d6b-41bf-e927-08d8f6f799be X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oN9P5lnut5a5kFonnmPUmRB0yetxgthbWoyv31k0LQIMLiJew2JxbHWGgTyOnuJaSdWVF3Xod/6I+5ErMGX/mClM9/EjsY9J09Uj+ZYaBPQ5GD23vr3RjsqLtjSFVwThzUs+H/511SnvTV3o+czLrYoGLYxwYIOnXmXCaNPR2wh67ogHaFJF3iGXwfjZUCQ7Fz3KGtED6dmNTtA+NmPg+e1Ji9wvz+WnwocdV0iW2sRV42gaeVV/feR7XFBFk5nH5losQX3PSp5tXKr1ioK6IaN9zT5BnRLgkiSO1WkmTsxNPHw71jbOCTeLYC6KtqhMmbSE0qy/6E1DobjFtYRaLSzcr+lo4Vl94Pz4fzV1NQ/zCwT68cc0trvt3JC1k/ylFbc93D9Gf6NBOqiU3kdOTYkGuIJFlP/EH0Tv/f7cDNKHi6oHG3Y0ihj+Xqfx97UpoREcL3nVBCxMmBJCZW9ouWclei2oo3tOsGoaQy8s9wzY25UAoV/PwzZw4vvE1hkixbvBWSXvHLUV97jhNmqJrcbV9aknFKLjwlFaFMql8UoyHsGvoGYOf4b8KltfXEVYiYbyeujnJiskgQQj9zq+IXzzBFi32+MgRfAHS64eBu2xbRsPnPEo5YJCgZPK3db8m9Hr4M9J70zsF/IRQJitwRmlFvZxE7tq1DHEr+eLATnn235IH4UgEmV1wMRbL7b+RrWfoXuiU9qxUQNTgsRgPg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(8676002)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ndc8ll45rayiNaZJQ6MtUdgMG0KoZnqQoWhIaFkZ9OjzSjKosMMRF7oAVdfHrzvYn+TNqE7nok8qkk9Bj79bsTnIwW633s+pPk+hthaZ0vpqCYYTH5bU1E2JS1rmm/XWYZ1Ls7peKYbekihw3O8JsAqoy2gXspIt2DyV0W9r7puaNUS5z4O10swG5o1n5iMvIlhj6q1w6u0nLZac1WowIgrVChPMlgF/h2iH0MJhYHFVOSWD2Bado7hmJwCz1CgDlGVwROqo8ipxeydmxsUaaFZVDo2YSWgGKUIU5dI7hZWXiaepYdCf2MKW7EEjdlk6mrwTX0Z1UHdVflGvDEavpLByNYOSxhJjiDgRogU7Fkm5odJfCBx+WJXIv884tUUNNclOPwu2BjYur8ctX7dwLwV9vvc/JmESABvprpWVw/Fkv6udaG0C3ItlmzfExyrbpYLBc9PkvSzuMmfn8ZhFnSDuUbnBwLj1etVAQe4j/8t/BNtZqSf9c3aHAi2q2jdrvyEYTfgOP57xpU4p6W6SW1n53rNd/o0AaOtyc4ZXL1gwNMRI5hB7764sMebeMXG/LRsaJqJEgsub83O/EKA/m2ZTLij3UiXqNKad/7zhQEiXVs2S/i42wrqizufYRWPgIVU5YHFKqOMormK60as3B67phLSi2EeuQ3Pp5VMo5PlmH4bon6/ZU5ZpHQiyZjQWl1RBySwnZGTvp6TgZNRNpxH8wxlS+OeCBaraU0/xnM4UScUod6OYKNpz9Q09Bk+c/reTGQw5fZwps70tE1ZNOX7ybkUmLZzBUlu563WHKh1BUvh/WBJ2ctfgsGop8r9yASZ93JTQswxG6ds4omhB6KOxVm+sREPhPpjjLg2tD6vcQaj2kmuHAMXotQq3potx0mKOxp1btAHtOl1OPVb8ITHRhmH61OGTq0sWc6ErL6tmxVz733ByjUeml/HYUHbuQ5qa1AF/hJTXXMS3I12xHu4CUBm8gxSWlySPxMmQX5gGnoo71wX+BOpbzUS8uvZCOQHLyVcHV5P6N7lj9wxfCKJg/UaDLIR19aMWSr2FNaiRpDf5TDBdwN/mXqpo53XkG7Nuxb7zuO104p7v9tst/+k0fudauC2uEVovL7zTEbyKCt0aOw/A6YyuYNgxoH636jFgrDLLlVR4dlspfNAIAYZQmV0cy0CxTNk4DbHxoxcLgfFya80T65FYNQV3HlWv/ixBKbrK6/YhANpXAGA3kpR3Q7WMW8LkACLckjbbacyFNDq7pp0b3D4cgfGw6siJqjZNdUk8V14tInucgUK/V4a2YgCCE7Cm7I67cxOVRtzZEOGNI2Vq2C1+KmJeUtwG X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f45903a4-3d6b-41bf-e927-08d8f6f799be X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:17.1554 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ebe7GfzeSjunINbttPzp4c4G+1MDVRwr5Y9rpp9mUzrYPEy0NLl88JyXd9HaoLN/JPI9NyWFpvFxVp7O7ikNZDcp7ojoIqlaLtQsgiBt+7k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: eY4qI32CPpMRWyvDOKIKeyt61qcM1ywb X-Proofpoint-ORIG-GUID: eY4qI32CPpMRWyvDOKIKeyt61qcM1ywb X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch adds a new lock around the mgmt pool, so we only need the back lock for the task state which will be fixed in the next patches. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 30 +++++++++++++++++++++--------- include/scsi/libiscsi.h | 8 ++++---- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 00a25af9eb98..f822c0cd5927 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -462,8 +462,12 @@ static void __iscsi_free_task(struct iscsi_task *task) if (conn->login_task == task) return; - if (!sc) - kfifo_in(&session->mgmt_pool.queue, (void *)&task, sizeof(void *)); + if (sc) + return; + + spin_lock_bh(&session->mgmt_lock); + kfifo_in(&session->mgmt_pool.queue, (void *)&task, sizeof(void *)); + spin_unlock_bh(&session->mgmt_lock); } static void iscsi_free_task(struct iscsi_task *task) @@ -716,9 +720,13 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); + spin_lock_bh(&session->mgmt_lock); if (!kfifo_out(&session->mgmt_pool.queue, (void *)&task, - sizeof(void *))) + sizeof(void *))) { + spin_unlock_bh(&session->mgmt_lock); return NULL; + } + spin_unlock_bh(&session->mgmt_lock); } /* * released in complete pdu for task we expect a response for, and @@ -3017,6 +3025,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->dd_data = cls_session->dd_data + sizeof(*session); mutex_init(&session->eh_mutex); + spin_lock_init(&session->mgmt_lock); spin_lock_init(&session->frwd_lock); spin_lock_init(&session->back_lock); @@ -3144,13 +3153,13 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, INIT_WORK(&conn->xmitwork, iscsi_xmitworker); /* allocate login_task used for the login/text sequences */ - spin_lock_bh(&session->frwd_lock); + spin_lock_bh(&session->mgmt_lock); if (!kfifo_out(&session->mgmt_pool.queue, (void *)&conn->login_task, sizeof(void *))) { - spin_unlock_bh(&session->frwd_lock); + spin_unlock_bh(&session->mgmt_lock); goto login_task_alloc_fail; } - spin_unlock_bh(&session->frwd_lock); + spin_unlock_bh(&session->mgmt_lock); data = (char *) __get_free_pages(GFP_KERNEL, get_order(ISCSI_DEF_MAX_RECV_SEG_LEN)); @@ -3164,8 +3173,10 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, return cls_conn; login_task_data_alloc_fail: + spin_lock_bh(&session->mgmt_lock); kfifo_in(&session->mgmt_pool.queue, (void *)&conn->login_task, sizeof(void *)); + spin_unlock_bh(&session->mgmt_lock); login_task_alloc_fail: iscsi_destroy_conn(cls_conn); return NULL; @@ -3206,11 +3217,12 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) get_order(ISCSI_DEF_MAX_RECV_SEG_LEN)); kfree(conn->persistent_address); kfree(conn->local_ipaddr); - /* regular RX path uses back_lock */ - spin_lock_bh(&session->back_lock); + + spin_lock_bh(&session->mgmt_lock); kfifo_in(&session->mgmt_pool.queue, (void *)&conn->login_task, sizeof(void *)); - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&session->mgmt_lock); + if (session->leadconn == conn) session->leadconn = NULL; spin_unlock_bh(&session->frwd_lock); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index ceb01ef12002..8d1918590aa6 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -348,10 +348,9 @@ struct iscsi_session { spinlock_t frwd_lock; /* protects queued_cmdsn, * * cmdsn, suspend_bit, * * leadconn, _stage, * - * tmf_state and mgmt * - * queues */ - spinlock_t back_lock; /* protects cmdsn_exp * - * cmdsn_max, mgmt queues */ + * tmf_state and queues */ + spinlock_t back_lock; /* protects cmdsn_exp and * + * cmdsn_max */ /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. @@ -363,6 +362,7 @@ struct iscsi_session { int cmds_max; /* Total number of tasks */ struct iscsi_task **mgmt_cmds; struct iscsi_pool mgmt_pool; /* mgmt task pool */ + spinlock_t mgmt_lock; /* protects mgmt pool/arr */ void *dd_data; /* LLD private data */ }; From patchwork Sat Apr 3 23:23:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415102 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 EE7D3C433ED for ; Sat, 3 Apr 2021 23:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C989061361 for ; Sat, 3 Apr 2021 23:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237022AbhDCXYq (ORCPT ); Sat, 3 Apr 2021 19:24:46 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49940 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236999AbhDCXYc (ORCPT ); Sat, 3 Apr 2021 19:24:32 -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 133NLQFK160775; Sat, 3 Apr 2021 23:24:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=w/7/CtmferOk0ASEUKWPbJwiXYHDgF7B++6tDRC3m80=; b=e1ONrA8uPR+f2kKv6TmDz4DeonInlxBl/hXpKp6vhFq4F2qdtH4kokXyZvCaUKXU4dUE mL3N++b3TM8a688npPnIZaE3Q1MAvJWiCIcyK14Ii5YqEYCwcC7Bq0UTw3Lgsa942XHT 6m+d5+GizLyahXj7CmoqYIcNu0bTJQ8DQXr1RvTteMIczPlZyPYoMF369ftRW0tq/L6n ctJjRkv/fiqmfd/FtPyZWs+QnZUqlGdam7rEj/Fn8lPqvsqs13r4lcIva36SRtZV3Swb Kq1qI60SvR8zP3T9Q/lsd172x6K7nQJEeN0ey260nmvIF5YzC9qAuNO2pcIYDXeZXDTt jw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:21 +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 133NKtWm117032; Sat, 3 Apr 2021 23:24:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 37pfpkbsrd-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T7lMvQd8LuXVda+KNlPOgQ5/XIJtXMzcaiaeLYybv5OVutWb3q+c0G8Eqbd6AJJNwElPov9cobVvO9lyh2rtVvGWEC1T96NH2GQ0rzRw0u4pOSsYhJwCjBAFXJ65Za9mjhAxmw7oUZTGfoZWiumEblE99VRcLo6KdcDzs1s/04UtxoOxrku/bMPKk9kCjc91rciplCPca079zvuxKy8MaE2pcJsS6Zflpf5SHj97ZN5oHRfXjavFDcK4Tr8u2OOJGzi/k+6JdkxuiJRL9NjPzYYpuuN4TC3nxd+CBBoVzeysaXbAg7yA4dTkZNx1bajbVCyRkFlKVe1UWwuecLMlmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/7/CtmferOk0ASEUKWPbJwiXYHDgF7B++6tDRC3m80=; b=Aqvorqyg9WGSqITkcGENKdkmx6J///rJAzcIpbtkArhwZjFWjt7jTNd2eIjl2swCZW2F7KEgVtpKJM0MguNM5zpqZvUQMn6NWZe5DTadwq9R7TGRAG2FhhnOhh55L12/i+cCNIUbbg1heZU7bvqWgoHB25PtH19K2OeiCP/hkab/jCXM9aHBdhYN20KazHy7FWDV1DKVXyeMg06OKj84YL4MAkIMsVVNWJZCB8w3IWMluKLmtvSKNvGQfUcqDxlzkQ/vdtWCTaEdFeC/+/GpXMOV2lYnVSfdDoA/WeyS3VZ8k7syrUpg5cv7ht6DteodyKGen3/zT7QcKkM+g24zZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/7/CtmferOk0ASEUKWPbJwiXYHDgF7B++6tDRC3m80=; b=C1zYUpgVXurJVCp5L5z5VxsncxBmfZyRLVGj+RC11dJTdJ1vHLWr4O40hS0TxjecueG+1jCc3f85lcUzekQnmILA6TxwaxR5ts7t16qRIA+/X2LlWzoa4K4Ey+uflHFayJ6Yagtiu7T35mZVF7clxPADasumwkGdKrjg+bIpD2o= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:18 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:18 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 26/40] scsi: iscsi: replace back_lock with task lock for lookup Date: Sat, 3 Apr 2021 18:23:19 -0500 Message-Id: <20210403232333.212927-27-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e30d19f-a13a-4217-a7a2-08d8f6f79a8a X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3oGYjNdQ0/kLUEfaM533ypBbj71p3Jl9bwDEavxWG9jXzCpk4Hzw6EIakh7zpuZIfQOt/YCrk8jJv3tdqk2HJZNU16jxo6PARGPA+FZFbOxM3K2HurxVxPwsPE3RAIv6Tf0znHzt0DFEjYDKxrPHVHx8VORh7SeNZ5BEX8GyV8CUqNEGQrrkpsPHAM7tcTsgv2GYzP1KKAPo1E8ylTujUkTx/+Ckh1WdX5gtt4aasf9WMJLnOPz/myJSsqqEi+CCHt2Xb3COlGkqvdURNa9Rw5o6ROOTvUviHLw7pF0jD1XKfkgHN9PAPJGiqtMyEDJllZgfX95+ZgxBJYgMm2wo53NlBV6rM6wRm3O2L1QFLK69wRhclXrbLPUNalG6LhTCvKqfr48m9qZ1IRnkJHbnt/2CsuJuO3KpsCZACLCAdt618hkN/iNzK8uXAfmyN9WocNtK7dTFlLQHSv/rKFIYr0YbAoXo2TSYuNo0A8DnCYucF6Hp9siGH6gCbXxbkgKp7Rw6bFMz+u5ZvtEmNf7DPYMf7uX1j+gL28RpqReDdA4TXhB6d3I0V5674BzLLLBjHM1Cd4m5gl3Y88ZyQvFHHNVel0PJ0dtx087TvsyWRUgxXi8nr0yx6nZMikL2GT3PV1JeAaUpU1VCRZdmyznA/rpnqkgquaQqMLqafpR5WHEVyGMOYnCw+9sN6drO9P56nIPMH2hKGOFSfGmkR6TYVg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(30864003)(8676002)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7e7kbHE6l86PDWhQdgY+yJuzY8jGz7PZULonBE2W9v8wVRJhIcTI5yUlgv2AEFL0hzu+2NPTtjqeBtxVmKECIbvxiUHNXwBzjl6cpArLJ2/89lc/07VPEKsDqIzT7z43DfI3WqbdQArUb/O+k/8x7fVKVsH5RWi3qZeM8VwrAdyG63MXTKNJckDPOQRaxA2QtCJaAizOxxYRkTfW0N7BT3etESEJXxHA8tFAdtM1iJrbV19FviDLzS74X39pB4Uw2/czFiB7DuBl4S/0/4G4Ip3ae8Yblflg9DjxkzQsuVwpAEqeeagHbKV9zsSlBek5OHa5rZSIUMU7pH2vpC4rwpARaIK6KnEjbh2NtjJc8kJwYughg3j/F8AIp1sYrSPnurkHbAJ1aikXf5unzGVGTEVcBNxP8DcghZpUgHMwprwULrfCEetULBD8WBhQVYCyegZ8BlyKvx5jcJ4habxNtIhzG06MHfWkBbCzP0/zsaNyCi/ohaJ6is8WyKHB3S9DwJ0lQia2czbGlLnZQc9F7b8EqoeWAR/H7i8b9rS/fuLI2Kn1netaeUQ3P82RNNkjfQrBu5WKG2PoIj8Ps/XUrkEo5wlWpFTj4fBeyDi9UEix+Hci0H1BUyW/mzkMbvgyMK8sqMBo5TSdH785z58rcM+SjUKKoHWAF1ipo++yctLpjArzTkmqOMcCRO2RA3ocYKIhonCy7mkSaqrGv2LIxYdHqtNZDPDnHvyr1npGIEVlBOi0aYEl9jFnErJJWmQitznsLNE1PSMBFeiNLFnGGycc9dnUCtXMzBMWYkkMNx62muc7joSAGAuFgriFp9I6BDiegx0Es4uQftJsKXkrEZgTaVf7RTyhI57KgkXwHvvFhd6e03SVaH/MgvPsdfPhUD/tEd4P3pXPgkdS3Vhvya4vFqo6oDqg+h/8iv42UQKpQwYS7TNcmwnePWJb1LWR2FLgt7wHSNtcQGo4p6AdrLU9T5eLydqgEdqfIJ0kETxDRBu+8Eh5PyJkZDiKl05tDREqWOzQPfs3skZ6tGbSnLBshVn6Zt3asL/FFf23YWmip6D+Bk2uXrFEmaFq1eJgL+4daeJuToGVmaB7QiYyP40KfBpsjuPTXc5Y0JiboCs9x/NMbniCcWzqjAsgi/2wEazLx3n1rCkHAWAJ0pnOPLc96TzdQoFAqFLIVNVGcmW8cncTiMUpc6WbLrYs0dQYPSRskFKI9PJ9ZtrNr2PR//18mXZAlYrl8LsknWla+7BfGVLTKDkEMus0PM63IfdhQuOR89yf78HwSAFrPV7zQq7G+X5JWDLUNZMPBH04SzCXDdErFSPVjLjgNdMgzdxA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e30d19f-a13a-4217-a7a2-08d8f6f79a8a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:18.5027 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /6NBsq17RQFO/bg/F3wKTACULTPgS2T+ZXDk7n7fR00owPWwcdSiqPsKjQkBnEasPP1ng8w/H2kvwGeO9G+vsEJgS54PoWDqdshYTQ7aiWQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: tdOfSed9e1PQ3iQL6IVZu2QsLyuutUZp X-Proofpoint-GUID: tdOfSed9e1PQ3iQL6IVZu2QsLyuutUZp X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We hold the back lock during completion to make sure commands do not complete from another thread but for drivers that can complete from multiple threads/isrs this adds a bottleneck. We also do not want to have to hold the back_lock while calling iscsi_put_task from the xmit path. This patch adds a per task lock which is used to test if a command has completed and can be used to get a ref to the task so it can't complete from under us in the recv paths. The next patch will convert the eh paths. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/iser/iser_initiator.c | 9 ++- drivers/scsi/bnx2i/bnx2i_hwi.c | 63 +++++++++++--------- drivers/scsi/cxgbi/libcxgbi.c | 3 +- drivers/scsi/libiscsi.c | 42 ++++++++++--- drivers/scsi/libiscsi_tcp.c | 18 +++--- drivers/scsi/qedi/qedi_fw.c | 6 +- drivers/scsi/qla4xxx/ql4_isr.c | 4 +- drivers/scsi/qla4xxx/ql4_os.c | 3 +- include/scsi/libiscsi.h | 12 +++- 9 files changed, 104 insertions(+), 56 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 27a6f75a9912..43757b312006 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c @@ -632,15 +632,20 @@ iser_check_remote_inv(struct iser_conn *iser_conn, if (iser_task->dir[ISER_DIR_IN]) { desc = iser_task->rdma_reg[ISER_DIR_IN].mem_h; - if (unlikely(iser_inv_desc(desc, rkey))) + if (unlikely(iser_inv_desc(desc, rkey))) { + iscsi_put_task(task); return -EINVAL; + } } if (iser_task->dir[ISER_DIR_OUT]) { desc = iser_task->rdma_reg[ISER_DIR_OUT].mem_h; - if (unlikely(iser_inv_desc(desc, rkey))) + if (unlikely(iser_inv_desc(desc, rkey))) { + iscsi_put_task(task); return -EINVAL; + } } + iscsi_put_task(task); } else { iser_err("failed to get task for itt=%d\n", hdr->itt); return -EINVAL; diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index bad396e5c601..af03ad7bc941 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -404,8 +404,8 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { case ISCSI_TM_FUNC_ABORT_TASK: case ISCSI_TM_FUNC_TASK_REASSIGN: - ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt); - if (!ctask || !ctask->sc) + ctask = iscsi_itt_to_ctask(conn, tmfabort_hdr->rtt); + if (!ctask) { /* * the iscsi layer must have completed the cmd while * was starting up. @@ -415,6 +415,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, * In this case, the task must be aborted */ return 0; + } ref_sc = ctask->sc; if (ref_sc->sc_data_direction == DMA_TO_DEVICE) @@ -425,6 +426,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, ISCSI_CMD_REQUEST_TYPE_SHIFT); tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK)); + iscsi_put_task(ctask); break; default: tmfabort_wqe->ref_itt = RESERVED_ITT; @@ -1346,7 +1348,6 @@ int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session, u32 datalen = 0; resp_cqe = (struct bnx2i_cmd_response *)cqe; - spin_lock_bh(&session->back_lock); task = iscsi_itt_to_task(conn, resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX); if (!task) @@ -1414,10 +1415,12 @@ int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session, } done: + spin_lock_bh(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, datalen); -fail: spin_unlock_bh(&session->back_lock); + iscsi_put_task(task); +fail: return 0; } @@ -1442,7 +1445,6 @@ static int bnx2i_process_login_resp(struct iscsi_session *session, int pad_len; login = (struct bnx2i_login_response *) cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, login->itt & ISCSI_LOGIN_RESPONSE_INDEX); if (!task) @@ -1481,11 +1483,13 @@ static int bnx2i_process_login_resp(struct iscsi_session *session, } } + spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bnx2i_conn->gen_pdu.resp_buf, bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); -done: spin_unlock(&session->back_lock); + iscsi_put_task(task); +done: return 0; } @@ -1510,7 +1514,6 @@ static int bnx2i_process_text_resp(struct iscsi_session *session, int pad_len; text = (struct bnx2i_text_response *) cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX); if (!task) goto done; @@ -1541,12 +1544,14 @@ static int bnx2i_process_text_resp(struct iscsi_session *session, bnx2i_conn->gen_pdu.resp_wr_ptr++; } } + spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bnx2i_conn->gen_pdu.resp_buf, bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); -done: spin_unlock(&session->back_lock); + iscsi_put_task(task); +done: return 0; } @@ -1569,7 +1574,6 @@ static int bnx2i_process_tmf_resp(struct iscsi_session *session, struct iscsi_tm_rsp *resp_hdr; tmf_cqe = (struct bnx2i_tmf_response *)cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX); if (!task) @@ -1583,9 +1587,11 @@ static int bnx2i_process_tmf_resp(struct iscsi_session *session, resp_hdr->itt = task->hdr->itt; resp_hdr->response = tmf_cqe->response; + spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); -done: spin_unlock(&session->back_lock); + iscsi_put_task(task); +done: return 0; } @@ -1608,7 +1614,6 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session, struct iscsi_logout_rsp *resp_hdr; logout = (struct bnx2i_logout_response *) cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX); if (!task) @@ -1628,11 +1633,14 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session, resp_hdr->t2wait = cpu_to_be32(logout->time_to_wait); resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain); + spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); + spin_unlock(&session->back_lock); + + iscsi_put_task(task); bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD; done: - spin_unlock(&session->back_lock); return 0; } @@ -1653,12 +1661,10 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session, struct iscsi_task *task; nop_in = (struct bnx2i_nop_in_msg *)cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, nop_in->itt & ISCSI_NOP_IN_MSG_INDEX); if (task) - __iscsi_put_task(task); - spin_unlock(&session->back_lock); + iscsi_put_task(task); } /** @@ -1690,14 +1696,13 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session, struct cqe *cqe) { struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; - struct iscsi_task *task; + struct iscsi_task *task = NULL; struct bnx2i_nop_in_msg *nop_in; struct iscsi_nopin *hdr; int tgt_async_nop = 0; nop_in = (struct bnx2i_nop_in_msg *)cqe; - spin_lock(&session->back_lock); hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr; memset(hdr, 0, sizeof(struct iscsi_hdr)); hdr->opcode = nop_in->op_code; @@ -1722,9 +1727,13 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session, memcpy(&hdr->lun, nop_in->lun, 8); } done: + spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); spin_unlock(&session->back_lock); + if (task) + iscsi_put_task(task); + return tgt_async_nop; } @@ -1833,13 +1842,14 @@ static void bnx2i_process_cmd_cleanup_resp(struct iscsi_session *session, struct iscsi_task *task; cmd_clean_rsp = (struct bnx2i_cleanup_response *)cqe; - spin_lock(&session->back_lock); task = iscsi_itt_to_task(conn, cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); - if (!task) + if (!task) { printk(KERN_ALERT "bnx2i: cmd clean ITT %x not active\n", cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); - spin_unlock(&session->back_lock); + } else { + iscsi_put_task(task); + } complete(&bnx2i_conn->cmd_cleanup_cmpl); } @@ -1907,18 +1917,15 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session, struct scsi_cmnd *sc; int rc = 0; - spin_lock(&session->back_lock); - task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data, - cqe->itt & ISCSI_CMD_RESPONSE_INDEX); - if (!task || !task->sc) { - spin_unlock(&session->back_lock); + task = iscsi_itt_to_ctask(bnx2i_conn->cls_conn->dd_data, + cqe->itt & ISCSI_CMD_RESPONSE_INDEX); + if (!task) return -EINVAL; - } sc = task->sc; - spin_unlock(&session->back_lock); - p = &per_cpu(bnx2i_percpu, blk_mq_rq_cpu(sc->request)); + iscsi_put_task(task); + spin_lock(&p->p_work_lock); if (unlikely(!p->iothread)) { rc = -EINVAL; diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index cdaa67fd8c2e..b3960e0b341a 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -1540,10 +1540,11 @@ skb_read_pdu_bhs(struct cxgbi_sock *csk, struct iscsi_conn *conn, struct iscsi_task *task = iscsi_itt_to_ctask(conn, itt); u32 data_sn = be32_to_cpu(((struct iscsi_data *) skb->data)->datasn); - if (task && task->sc) { + if (task) { struct iscsi_tcp_task *tcp_task = task->dd_data; tcp_task->exp_datasn = data_sn; + iscsi_put_task(task); } } diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index f822c0cd5927..955ca15ecf5f 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -454,8 +454,11 @@ static void __iscsi_free_task(struct iscsi_task *task) task->itt, task->state, task->sc); session->tt->cleanup_task(task); + + spin_lock_bh(&task->lock); task->state = ISCSI_TASK_FREE; task->sc = NULL; + spin_unlock_bh(&task->lock); /* * login task is preallocated so do not free */ @@ -1097,10 +1100,12 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, "Invalid pdu reject. Could " "not lookup rejected task.\n"); rc = ISCSI_ERR_BAD_ITT; - } else + } else { rc = iscsi_nop_out_rsp(task, (struct iscsi_nopin*)&rejected_pdu, NULL, 0); + iscsi_put_task(task); + } } break; default: @@ -1121,11 +1126,13 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, * This should be used for mgmt tasks like login and nops, or if * the LDD's itt space does not include the session age. * - * The session back_lock must be held. + * If the itt is valid a task will be returned with the reference held. The + * caller must call iscsi_put_task. */ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) { struct iscsi_session *session = conn->session; + struct iscsi_task *task; uint32_t i; if (itt == RESERVED_ITT) @@ -1142,7 +1149,12 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) if (i >= ISCSI_MGMT_CMDS_MAX) return NULL; - return session->mgmt_cmds[i]; + task = session->mgmt_cmds[i]; + if (iscsi_task_is_completed(task)) + return NULL; + + __iscsi_get_task(task); + return task; } else { return iscsi_itt_to_ctask(conn, itt); } @@ -1200,7 +1212,9 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, if (!task) return ISCSI_ERR_BAD_OPCODE; - return iscsi_complete_task(conn, task, hdr, data, datalen); + rc = iscsi_complete_task(conn, task, hdr, data, datalen); + iscsi_put_task(task); + return rc; } EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); @@ -1374,7 +1388,8 @@ EXPORT_SYMBOL_GPL(iscsi_verify_itt); * * This should be used for cmd tasks. * - * The session back_lock must be held. + * If the itt is valid a task will be returned with the reference held. The + * caller must call iscsi_put_task. */ struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) { @@ -1395,15 +1410,21 @@ struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) return NULL; task = scsi_cmd_priv(sc); - if (!task->sc) + spin_lock_bh(&task->lock); + if (!task->sc || iscsi_task_is_completed(task)) { + spin_unlock_bh(&task->lock); return NULL; + } if (task->sc->SCp.phase != session->age) { iscsi_session_printk(KERN_ERR, conn->session, "task's session age %d, expected %d\n", task->sc->SCp.phase, session->age); + spin_unlock_bh(&task->lock); return NULL; } + __iscsi_get_task(task); + spin_unlock_bh(&task->lock); return task; } @@ -1709,14 +1730,18 @@ static struct iscsi_task *iscsi_init_scsi_task(struct iscsi_conn *conn, refcount_set(&task->refcount, 1); task->itt = blk_mq_unique_tag(sc->request); - task->state = ISCSI_TASK_PENDING; task->conn = conn; - task->sc = sc; task->have_checked_conn = false; task->last_timeout = jiffies; task->last_xfer = jiffies; task->protected = false; INIT_LIST_HEAD(&task->running); + + spin_lock_bh(&task->lock); + task->state = ISCSI_TASK_PENDING; + task->sc = sc; + spin_unlock_bh(&task->lock); + return task; } @@ -2951,6 +2976,7 @@ static void iscsi_init_task(struct iscsi_task *task, int dd_task_size) task->itt = ISCSI_RESERVED_TAG; task->state = ISCSI_TASK_FREE; INIT_LIST_HEAD(&task->running); + spin_lock_init(&task->lock); } int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *sc) diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 73d4fe20ba9d..b1399ff5ca9e 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -539,13 +539,11 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) int r2tsn; int rc; - spin_lock(&session->back_lock); task = iscsi_itt_to_ctask(conn, hdr->itt); if (!task) { - spin_unlock(&session->back_lock); return ISCSI_ERR_BAD_ITT; } else if (task->sc->sc_data_direction != DMA_TO_DEVICE) { - spin_unlock(&session->back_lock); + iscsi_put_task(task); return ISCSI_ERR_PROTO; } /* @@ -553,16 +551,15 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) * so get a ref to the task that will be dropped in the xmit path. */ if (task->state != ISCSI_TASK_RUNNING) { - spin_unlock(&session->back_lock); /* Let the path that got the early rsp complete it */ return 0; } task->last_xfer = jiffies; - __iscsi_get_task(task); tcp_conn = conn->dd_data; rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr; /* fill-in new R2T associated with the task */ + spin_lock(&session->back_lock); iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr); spin_unlock(&session->back_lock); @@ -713,14 +710,15 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) switch(opcode) { case ISCSI_OP_SCSI_DATA_IN: - spin_lock(&conn->session->back_lock); task = iscsi_itt_to_ctask(conn, hdr->itt); if (!task) rc = ISCSI_ERR_BAD_ITT; else rc = iscsi_tcp_data_in(conn, task); + if (rc) { - spin_unlock(&conn->session->back_lock); + if (task) + iscsi_put_task(task); break; } @@ -753,11 +751,11 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) tcp_conn->in.datalen, iscsi_tcp_process_data_in, rx_hash); - spin_unlock(&conn->session->back_lock); + iscsi_put_task(task); return rc; } - rc = __iscsi_complete_pdu(conn, hdr, NULL, 0); - spin_unlock(&conn->session->back_lock); + rc = iscsi_complete_pdu(conn, hdr, NULL, 0); + iscsi_put_task(task); break; case ISCSI_OP_SCSI_CMD_RSP: if (tcp_conn->in.datalen) { diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 217291e81cdb..e28dc249c9f0 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -1469,14 +1469,16 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == ISCSI_TM_FUNC_ABORT_TASK) { - ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt); - if (!ctask || !ctask->sc) { + ctask = iscsi_itt_to_ctask(conn, tmf_hdr->rtt); + if (!ctask) { QEDI_ERR(&qedi->dbg_ctx, "Could not get reference task\n"); return 0; } + cmd = (struct qedi_cmd *)ctask->dd_data; tmf_pdu_header.rtt = cmd->task_id; + iscsi_put_task(ctask); } else { tmf_pdu_header.rtt = ISCSI_RESERVED_TAG; } diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c index 6f0e77dc2a34..92ef40d755e4 100644 --- a/drivers/scsi/qla4xxx/ql4_isr.c +++ b/drivers/scsi/qla4xxx/ql4_isr.c @@ -384,10 +384,8 @@ static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha, cls_conn = ddb_entry->conn; conn = cls_conn->dd_data; - spin_lock(&conn->session->back_lock); - task = iscsi_itt_to_task(conn, itt); - spin_unlock(&conn->session->back_lock); + task = iscsi_itt_to_task(conn, itt); if (task == NULL) { ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__); return; diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index af89d39f19e5..754046902141 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -3382,7 +3382,8 @@ static void qla4xxx_task_work(struct work_struct *wdata) sts->completionStatus); break; } - return; + /* Release ref taken in qla4xxx_passthru_status_entry */ + iscsi_put_task(task); } static int qla4xxx_alloc_pdu(struct iscsi_task *task, uint8_t opcode) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 8d1918590aa6..25590b1458ef 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -142,7 +142,11 @@ struct iscsi_task { /* T10 protection information */ bool protected; - /* state set/tested under session->lock */ + /* + * task lock must be held when using sc or state to check if task has + * completed + */ + spinlock_t lock; int state; refcount_t refcount; struct list_head running; /* running cmd list */ @@ -162,6 +166,12 @@ static inline void* iscsi_next_hdr(struct iscsi_task *task) return (void*)task->hdr + task->hdr_len; } +static inline bool iscsi_task_is_completed(struct iscsi_task *task) +{ + return task->state == ISCSI_TASK_COMPLETED || + task->state == ISCSI_TASK_ABRT_TMF; +} + /* Connection's states */ enum { ISCSI_CONN_INITIAL_STAGE, From patchwork Sat Apr 3 23:23:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415231 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 848B8C433ED for ; Sat, 3 Apr 2021 23:24:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6302661360 for ; Sat, 3 Apr 2021 23:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236919AbhDCXYx (ORCPT ); Sat, 3 Apr 2021 19:24:53 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49974 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237006AbhDCXYg (ORCPT ); Sat, 3 Apr 2021 19:24:36 -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 133NKtUo160711; Sat, 3 Apr 2021 23:24:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=CariIWqCyjLXVqIAsJaDY65GTfRnVfmIoDnLetlH36E=; b=NR8PCjlKF4gzw1gjIFeHXpkh/t+0vQ9X9MPYu6cQeQGDQe6ALLuS9VtrrRgB3Z5K0YOM toq7CIdylkWGso1BiDOEU3Gsu3L77aRstVuGK1BraZEXUSSvUSPFU3OV3w5G+KQNTCTI m57CFfsWA9HO77LKTv099xzT3lQqPZP+7JXQXeAkNZM0qb+5cV8TJJOsDvLS7w5b/Ho1 Xgs/kU58y+SJ2SzHIPIQsWTpmyCc0XaypHMcvQuM60LyVLwARj239C9pPyi+RBYrpvO6 5DsXpLfRS/HclyEIkwawuBtnTKiWXcL7846q5xpFp5GlzfdCbQqkB7xU0qgJ+aY62Wwe PQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37pgam8rpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:22 +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 133NL7JV130245; Sat, 3 Apr 2021 23:24:22 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by aserp3020.oracle.com with ESMTP id 37pg61huc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ekjZF2d/8GckDhkQZNn48edU0GBdbBFAHF3t3ZCPDC+OZEMJB46dlyrJkx3bNjbd/VnACNHgSXmwRgIWzxIkzWhEPGfqnXmwQmM8ATF9gdyUFlIufdjPyb5vHG3flb3WTjlWe8dlkqkRS68g8fFsDxOpguwuw5NHUZHwshrzcbd24QH1Ahr66Q3uR/f2kZ0806HjMFQANiVRrMaDLK7uMaBn22W2T9/dQDCBZ/AgkZvFq3n6XbJDTz0GsRa5jW1YTLJY20lHQYy4lbDb+6Jum43xF/fDiv/O6dQxPioqrZUFjCSmnGrAZZ79zmLpLpkRFn6aXEDsxHcFuA2yC88EnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CariIWqCyjLXVqIAsJaDY65GTfRnVfmIoDnLetlH36E=; b=OrOI2+CZcn0efbedYBi4HDSuUJMEaNKzj1fnYMJF76D4l+z0myc6J5ZoE9N/IjhF6o6BVxxp9M3SaEkkgZUS9U93RcdC9AvCkbvaENrCeD5HfZ4mM0fBEGbCE8kWcLSAR8WBSHzmSqhgcH38QAYibk70UgulwWgy9lwKOFfDF7etvaoub0bTdweXio/w0Pjma57ZGk48OmTxqZmszjcQc/Yjt8D9jwnuZS1Cw2BFZQt+s6UabuKlry9RCfBbPj8+4mw2W+YXv/IWy5/Q1rvjUiaLTUYWhI8Ks/b7+wqcBgeZhKdLkK3Myh/aYfgvVSzS+ujrppD/AZbbu96SZJqbKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CariIWqCyjLXVqIAsJaDY65GTfRnVfmIoDnLetlH36E=; b=wUJwV3qAsOsQOy0g0Z/JBhGPn7QaleHSCpo+FUR+AyXX+D/zrUMTX4nbsyFCLRWvmbKcljeayOSq332Vq1R9cX5VUNenKMTHtBbaENI8VJGgE8HmHfMBdbHE6DWsRyn771QV1HB7wedG2ZXHGww/6cf190yBSJ4laIT/IiYWtao= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:19 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:19 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 27/40] scsi: qedi: use task lock when checking task state Date: Sat, 3 Apr 2021 18:23:20 -0500 Message-Id: <20210403232333.212927-28-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 542cf57b-5622-41eb-3f0f-08d8f6f79b56 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m6f6Ull+aic1JeH8mgAqIBvKXkl3PKda/pF1v/AZuc+Ier2QwhL4xf7fTzsnugFMrpDcqOVsavAX8NUMzOts0/qeThEThlzd/ziPr23c84oWLRFzgfC8Kr/0nHztVHi5gRS4OHegCZVuXt34s/ckaQeOnR9vLnbXXTuk9UkCSDUOWdjnY/8D96XctPRLuin6KQwa5rHEeJNlV6kC5FP/6Hf4Av0v2YSHg3KpkPzUndDyQwp9fx5nwPyuu4s/OTzO1wyt67hCiFbu6Ss74u8rGLBO5n2l2+zNsgJ52PB/l8nhz518SN35UGzCZ1PTDMl5eypm0CgCbZywogc852cLEtaje+gmMNdn2VV2ieSgoFjTn5dJhHpf4yPukaHI1mLBOx4MOePhGPXabV+ohR/vrGvsPAef5Os5lr1Bv1A6277Kh1/cZDIYdWmWCYqUeUKcrUqTQQ7o04h0uHPK4UMy8L4DHhaMnm7OZE6MFzTkNv+fFXiDatimF5yuTUTdcjdAephQ7eO5v2A33Z7o64klJW4Y53aYw5b2fqlLrICW3+VkCUQyf22JVbffKp7Buz9+kgmf7xbA0Djx7RNF2p0TAl7M+6EY+RBTHKrX34PZH4K+WnCfBBiLNiruCNz9HAva3PD4j236ot3xF5Vpyv4eBWK8GmfA7GdCbLHROCFEPaoSqwoMUkH5iK5s0L1KxY1kMqg8udEBQoeajT9yqT+3Dw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(8676002)(6666004)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vPTBxpFOdpbow/w1nOZ1UK247WIZVavPqbax/d6qqjmh6PZvFYOG39lvOoAqFei/ldPHjgVdKBxiN95SFVulM0iVZasBkq8MBxsjMHScCFn+du1Kjkgs7nBIbLqAK7X5f4pa5wzV7kz0pB14mte3a6O4vIeRYk7KXbZ72oBRz+b0GVfS6C1B9X2j+EoeVTkFJH1Gxaqv28Cd3HBpUCGYzmpbURq4wXy4m0gN7zVCA44TfQ7oWn0NL0Jf357VOJG0YHKSOdejs5TptRWL2kj13jdHxrzxBETbIo5rHEv/+JrMtclzbN3vli7c1zkdiUs347pJ4BwpB467YEwwT2TIHfTwyhgrbw2pPwuyn/ANxjXuqKrjTUvFt3DqkQ3yt5LL2+LnzalDGvHKjbQfpsxbBBaumZBdQVfG+1J14eEy580eYx9bfXLj25vRo+SYqih8DV3K7RKnBRxaFlArbLROcsaX4UIqHWgAhHxmzy6cK9TNhm+oWBi3A//KqSY9lkb8gmLsedH7M5lbe+PAlMI1i3VimjdtTdRCw8FK/RD8P6mgQYhLHsZM+nNQi+CGhGFPjE/ls7vvvfv7GibdKHqiz2C1ovdJ1WRy3dZbHwMj1wdy66RxF09jffNzCBEOGhCiF+CWtzRyixt2kP/jqMUHprVuNup0Dg5YChwu0lct3p9Q06Tx/xIplJb2wlmqnaqIX2GT6gxpfWvFydE/OLy1cgutu0R3CxRnEAvP3xJFJ+BE10D8d7Q3bBCcMJCMZfOypjFnfA7J7hlrjmUckDhehpEUWnnwIjyFJ+Vf5qZkrLrabl4bhtW0TInxCtEY4Pn9W2fuhxjujMA5xjLnRqzcAIEM50TCLRj/PMK2ZF3wNbOX9jdKFftXtweFIC0Gks2gDsW+VCJiOF2FGXTlMjqprH647tHMyMxcDrL7Pv9S6dcdSm6MgHCFTOFU5TkHhZ8eaF3k4YBxQTNdBQ5x9vJKapyqLWjxJSMU/C8qQD72AApr/ipKZ8g0DAOmV6e3QKT9vJ/iagsc/BkpupdmFI5mPz/mQhWIFk88DI4eyqK7DX97YwPvxRrzpWaUU7On47sE4D6QFFt1Dwxle68p1V91gT86ZAVjoKi41XXOnRaJRiRcXjdyrFcVnvvfJQi6SDryF2aH3qCdtGYD804QvBvm/D99SeKUCmnCaN2eE4Now1PQdjZPcs/vOFE/HwCvT83hybd/XQfWBFWVytPNmxQJkqv2wbAegXwKb8tdNvr506N4lEB34eHr0D7xWamNfi+3y8ohS5xlv6vmD3WXCflRYEyZEEvEsyxG76/JPYrSgSomkY1Xe0AaT4r99IsqdB8e X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 542cf57b-5622-41eb-3f0f-08d8f6f79b56 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:19.7880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oprztvs8R860GY4d4o954K5ejs5/vMzaWQOZy7ZruM/+O1QwQl8Z1qy+gPTqA4ILMzDEgdvVNzqiZsgLDkROuok7BG9HF3jewMR70H/8mVU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: wW6enn3mOAwNXSWgKQF9hW-QTJfVl9h1 X-Proofpoint-GUID: wW6enn3mOAwNXSWgKQF9hW-QTJfVl9h1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Convert qedi to check for task->sc instead of SCp.ptr and use the task lock when grabbing a ref to the task. Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 2 +- drivers/scsi/qedi/qedi_iscsi.c | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index e28dc249c9f0..de5133be1c4b 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -594,7 +594,7 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, goto error; } - if (!sc_cmd->SCp.ptr) { + if (!task->sc) { QEDI_WARN(&qedi->dbg_ctx, "SCp.ptr is NULL, returned in another context.\n"); goto error; diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 0f3704c4c985..77f0445c0198 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -47,15 +47,10 @@ static int qedi_eh_abort(struct scsi_cmnd *cmd) { struct Scsi_Host *shost = cmd->device->host; struct qedi_ctx *qedi = iscsi_host_priv(shost); - struct iscsi_cls_session *cls_session; - struct iscsi_session *session; struct qedi_conn *qedi_conn; struct iscsi_task *task; int rc; - cls_session = starget_to_session(scsi_target(cmd->device)); - session = cls_session->dd_data; - if (qedi_do_not_recover) { QEDI_ERR(&qedi->dbg_ctx, "dont send cleanup/abort %d\n", qedi_do_not_recover); @@ -63,15 +58,15 @@ static int qedi_eh_abort(struct scsi_cmnd *cmd) } /* check if we raced, task just got cleaned up under us */ - spin_lock_bh(&session->back_lock); - task = (struct iscsi_task *)cmd->SCp.ptr; - if (!task || !task->sc) { - spin_unlock_bh(&session->back_lock); + task = scsi_cmd_priv(cmd); + spin_lock_bh(&task->lock); + if (!task->sc || iscsi_task_is_completed(task)) { + spin_unlock_bh(&task->lock); return SUCCESS; } __iscsi_get_task(task); - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&task->lock); qedi_conn = task->conn->dd_data; set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); From patchwork Sat Apr 3 23:23:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415100 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 CD108C433ED for ; Sat, 3 Apr 2021 23:24:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A084361360 for ; Sat, 3 Apr 2021 23:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236970AbhDCXY4 (ORCPT ); Sat, 3 Apr 2021 19:24:56 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45106 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237010AbhDCXYg (ORCPT ); Sat, 3 Apr 2021 19:24:36 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJwJO097218; Sat, 3 Apr 2021 23:24:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ovwEHoEg3xXbEepx/O5huMTk8CmXmNzVgX6wYqLv3Is=; b=VmOPo1TjkTZQcTLsIRDNH9s3ldfBuz1YyPyfgCbreyZFvCN4L60Ui4uNfuigtmy8t9Sd HSZp45U35HWwrSJJJj/YQUwe52FTnDhJ2uYVLwEXjGdLhvJG+/0lwKu/Tc8+2XigEKfx HKt2mgozikXCBUDESXU8uAyv3T912wGx33lFSvUPZDhrPxeh1MX2ZNIwtzfK2LJOvMHb 5TRynlh1OIUTOi5t2nANAw8e3R0Ucpy1C4zcoMMA1XgegMcsgjzWdHPrBXIPcK5a9hBf Uq/oYpGx7XhNH9LkfuerfXfNPqrdudAgjbIXeXcTr6qlxPzr1DS0ArIFpyY1cOT6kCAf Mw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37pdvb8v6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:23 +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 133NL7JW130245; Sat, 3 Apr 2021 23:24:23 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by aserp3020.oracle.com with ESMTP id 37pg61huc2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WR2S+G1hE3Z8tIl1rhKR4T2PpaUsXhdE9qrB70OYXpVDaiNa+WnKF43kw0PAyF0GLKpnXzYmTqEcI2FV8NDZ4Auz2wacH6H6cGa4PXXYoC4SqyYqpK0uenGNYvCNIWcithfvBUeKm4Kala9stZ8mwc3zVoX1BMYDevfwG14kEorHMa6w7YKEkznO9TdSj4Dcumav54y71d2vZMwp/MfASW8QeETYXlooG+tXy8019jLuTKtGXvur6UFty+DQebwb8K3OiKGhJIyu66I2nHZ2FagNb6oZdA8pwNvh+4B7HN8jFlp3EJGQaIDouqEdWbQFHXXIHpJaipd8IRujurpXTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ovwEHoEg3xXbEepx/O5huMTk8CmXmNzVgX6wYqLv3Is=; b=efCrU+vV36Wui9QgvrGhWnPRtV0kF+f5U8dm4q2tHad2ZXym6qDUFsJ6klLp2MKuFu4Y7n8ehXGzkYUctUsveN4OjG//9SRGTfhvNbWteErLMaEgEcy8bj3pf80/Rs8yR2SF78SIGcgmNqZmjPl9jrfDuQzxrQMRH3iIpF/qwuNYpuCwyD/5qWLTPka1VXBPa9MG2h56uIfjwJPihX+5CvQ17DU0QJJMcH9d3QebaGposIWfPooCeO5wZOj60HpPyT46ww+Vmhf0FXo6YlHkO+znZY4TlA1O8wO/63pkpw9R6w/1ID9D0EY+KFs5B1tgEJn9Waspc+JJujNpuKaVMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ovwEHoEg3xXbEepx/O5huMTk8CmXmNzVgX6wYqLv3Is=; b=aAuRPkGsKqiRM4SfNAGuLsrtIthE8pf43oxeBqHcy2qZlo48SrmH1s+hHqwkeSfFLX59nxNCpwKbHk+IppTYq0txyUhyTpS5M9KgoBq1ffOCNxyYiL77ediGEJF1kzIWCclCc1819XMkpGYHvzOJ9aXfZSVFypz/h+oKV/oBgm4= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:21 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:21 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 28/40] scsi: be2iscsi: replace back_lock with task lock during eh Date: Sat, 3 Apr 2021 18:23:21 -0500 Message-Id: <20210403232333.212927-29-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cfbe897-9cae-48ed-8d74-08d8f6f79c16 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8NZzIuOLGjLKfJAfiTCx51I+Ony0al3Ai1jgKtA2gxDmrNiiZ7a0RiljuPNGGD3pSCw8auLQhWzHQkwy7pZL0NDAtDvA08y5gdwLe0qbgzHC0G2xwlLOZ59311LT2c86CVZM13lm9QeobJWAzLalvwxWF7JqPWvhAPWNzVbMTkCYXRGAbW9+/1C8ggbVd9awgKtL63Ikt0NYRzXZHTPHRKkPz6zkyX1Rl45ktyXJ3lYvIYAswrdUHdwHDqGbhxEH76Z4kzFLCnd/25gJCvDalJ3523ZNdzX+zIW9nwUhB7TwCvsYN3A255FvtPx7S82rWTXEA62QJ7pxOyieFyEBPNryLZIotZomK+OR3F5YeUq7zkN4M2tYUIJv93yGt+I3+zakeSDht+5JV3Z/WquOXUj8uL+dYvAb0rM4QUTYDt9i0P1u/s0BIm5WNOyDFEaZXHCPunT5lDiKruMEf6n8xsL1pf7WNmHd1zCjX9m9CNkSQeBail09E5YQM6P3ZeMqUafXTMFLVxuoQWtwo1hoIjnOjrwTMUyccXupRhgPn4BoJk42R7Ll8rjVp6VPu+TLrI0BpHMtPi5rKKv9UWIS0u1j8rhfmHS2gUjNXkXWMmyvaATQ2kOFKGfop0188Q7Bj0EzD/99XoxtpPSBrScuDmaXSL55y5NTzeAtuNSOHjtRiPyQ2gdRUJH4zVq6zQqOWbKYHmVsZ001TbmxwGGShA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(8676002)(6666004)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5X4RCeAmwlrd3g2+3RASTmdlJ1F4CO3k9M9ixPLltY2OBA8o1aCR0ezZvLRXpgbF1VanvuS1hrXtzVhe0fQh6mSHnXKVAx0igLoscD/7u3X8iKo/qtsulmR+1046NTM/BVhROu46/qgzjvZRG2T4PzahyGcVZbongW0RPMAOcIyVq3H7XiBYNn8v2zwmvaPNTuXUfrd+vakEDw8yCuFCuUULTaXE0puQkcocUtThhLGI5fFxmA2LVrw4aT8AYEP83rWX9jH7DUiDAQoWS+2s4Z5TCbG43MPRRIPoxDeQ3IkwqePDkDkDXLJtxCmPjz3V8Q/Ie5vq/UwASuFHgP5XBHckCEmtCa8Ygps20+1RYuDMm9b7Td1/WWok3APTpzJm1mRn35RzZke5WTDpnHFmddHaLqgi6JfMta6MOr5NoWIRv9I0xnr3E4QMFgWlxWDXRif8YTeMwOpx8QFH6VEGcpCzG4H1IuCIkXQQVwcLJ3DGG4n3CWbh5xvr0wu41/ksPeesb5tWOzmnqR+P5hP8Dpuspqpxb5KZOQiw/G6tqtwS+Xeznx0dD+pU09OpB5ajk6/LFNws8pnwH51VyICn4Y3WT0AGi3QYD/IZOKTHEIztx40oI79nf6kuHc4n0w98AKP1baIc0fO7ZBxLmGKeegF4xXUGDtpcPNHGU6bvRRD7j9OXnFbE2/PZptCXYG007WI0FEUfO3Q9wTDZbrDekeW7oj93D2jyLiO4aJq2wnPjs8wHhJnqAsODWwPEXphXyxf+cdRExqAOel/bUtQW06Xqp/m4METqOxUZm1X8En2su92q9QSe60o1ZpJJSVMVLB9QbgoaoK2dYgwIasFeLulriQmKCHWYoo2aur/FgdjdRY/P9haePfAoUtEteNZ9v5PyUVLtnlCEcFnUobwj72YymTmmvIVcAdxyZDkdZ46Gqrb9iGu/a3pj6pqFLzN6cnRKP48S87K1CsMbfsHQB+diD5VY2+j36+qTm5Y0QbCcfcUNewqhdYvg+3kfW4b67ReOAibw01Lzh7ZASHzMFCJkjPtfgiyX/s7Cof8vgQzEt5TZ3mSU/CkHyjLUjWnEcUpSfxsSYQl+xtPykEPBBRsUNvsp4sbOhjLuJ2KPucEJ0oCUJRwmIoowTlr8bDz4nyZ21GmT9AuG3v/94dEDWrCh+w3L6yaRPM0lYLQZXA86cgauOqrylKgskqSzo0am3xS4ke+58BaQXvEyJv025ftFSbvYmc4c9l0CwGU0u0Mh8HPakkZPb2uwe0K5aTp5gl+gXaLnqQXcfIVx8IQHcchDlCIR+SM1haGMOuvKZBAXOr/NBCOBr3qJVhQ0T0TT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cfbe897-9cae-48ed-8d74-08d8f6f79c16 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:21.0543 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lz9XWT3W3w1QNFabacYyAxm242osAxCNQRpA67NlrszfsEY6PveDrWiypNfb78RVgCFbd2EdxfFP+399aH6AHbFtGxljdU6ArbICe9VtCOc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: Qw6_GYoChyhiYxyq1pebEuWJwGC7igFz X-Proofpoint-ORIG-GUID: Qw6_GYoChyhiYxyq1pebEuWJwGC7igFz X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This replaces the back_lock with the per task lock for when we were checking the task->state/task->sc/SCp.ptr during error handling. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 4181769d7303..da5ede4ef7f4 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -216,24 +216,19 @@ static char const *cqe_desc[] = { static int beiscsi_eh_abort(struct scsi_cmnd *sc) { - struct iscsi_cls_session *cls_session; struct beiscsi_io_task *abrt_io_task; struct beiscsi_conn *beiscsi_conn; - struct iscsi_session *session; struct invldt_cmd_tbl inv_tbl; struct iscsi_task *abrt_task; struct beiscsi_hba *phba; struct iscsi_conn *conn; int rc; - cls_session = starget_to_session(scsi_target(sc->device)); - session = cls_session->dd_data; - /* check if we raced, task just got cleaned up under us */ - spin_lock_bh(&session->back_lock); abrt_task = scsi_cmd_priv(sc); - if (!abrt_task->sc) { - spin_unlock_bh(&session->back_lock); + spin_lock_bh(&abrt_task->lock); + if (!abrt_task->sc || iscsi_task_is_completed(abrt_task)) { + spin_unlock_bh(&abrt_task->lock); return SUCCESS; } /* get a task ref till FW processes the req for the ICD used */ @@ -252,7 +247,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) } inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid; inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index; - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&abrt_task->lock); rc = beiscsi_mgmt_invalidate_icds(phba, &inv_tbl, 1); iscsi_put_task(abrt_task); @@ -274,7 +269,7 @@ struct beiscsi_invldt_cmd_tbl { static bool beiscsi_dev_reset_sc_iter(struct scsi_cmnd *sc, void *data, bool rsvd) { - struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_task *task = scsi_cmd_priv(sc); struct iscsi_sc_iter_data *iter_data = data; struct beiscsi_invldt_cmd_tbl *inv_tbl = iter_data->data; struct beiscsi_conn *beiscsi_conn = iter_data->conn->dd_data; From patchwork Sat Apr 3 23:23:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415230 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 6847AC433B4 for ; Sat, 3 Apr 2021 23:24:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41B4A6135F for ; Sat, 3 Apr 2021 23:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236985AbhDCXY5 (ORCPT ); Sat, 3 Apr 2021 19:24:57 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45570 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236980AbhDCXYk (ORCPT ); Sat, 3 Apr 2021 19:24:40 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NOPpk041904; Sat, 3 Apr 2021 23:24:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=l+cgs0CxZa0kdunLLv/LQau+6sVLgqZGMxefP3ziA2Q=; b=WrH6IfbxTFxg3dmsAARHKZ8ypqzH0/3VJmxgkAo4JjG+lQPBwk68AIiJDqOHuJMJEgIV r7fUlGqr6jih4p9YEvGbT+xcN0HRQID8JZm74v6K4oxAgkPhVTVj/KwkCzy5L181WgA0 BSjaEfBN46XT9nDUgfMebqPcWC8fzoJ7vk8wLjX7rmcNiStGJlXJ2OZjBxyTmSOzKiHP zXxz50pRkDasuHLKdYjdsWOxnJcV+t+6ijRRcW/nGGBUshACZx0f5gLNoF2WI6bYRpWj lqqsgvI8aA/P5HK9K8bNgJKpJdSTNOZ2WbmHV97g+rT0f35t56u/f+tG5X0wfxMxgfOu Jg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 37pfsrrsh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:25 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NJqbb074887; Sat, 3 Apr 2021 23:24:25 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by userp3030.oracle.com with ESMTP id 37pdfspp8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EFKeNoo733KF8P36J6/bThixmlvt2aucT7mfhA2TMfunRT5PdIu1CW1vh0c54gRRL60JgX1QuIyPIelkjNk5hJa6KS9qy2YraHTTQvhIkzFUU81uc7cjF/oeRQ7kHg3pyyYI92Ys8bP9PLZ2mxuJ4dNeDNK5XWGzhj49uaVl/av1OrI4uCD+A01Tkr4Z11hCnL75nwImSKRIjBmunIMO27Q4wEPHSKVftvNRcQw8uMZJ+MPKcDNY7lr/Y0Dyvkd+f2VVed5LRR+vwBiHSYK90I90+KGQMJo1z6DIPZytyLu0I61B+ws/g13DK1QvxfoTf3J+haPEFQobbL+QRuh9/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l+cgs0CxZa0kdunLLv/LQau+6sVLgqZGMxefP3ziA2Q=; b=b5ITWqKJn5PTgsMpq3CFV9+/PuDq1a/fno8mwHbd7JXCzkW7UV5JKBDCjCDMyLYYiMM0cSDBg+586gDiMGI16L6IS96207iMRNKqfvgV4Lbm1y0JHRewAFhybm6Hmy8VjH4XdY85j5Jakd64LkKz4xic9+Zh9Vd/0Lh6yM9CeoOCRuZ2TATJTLo9f8rPJnw4d/Jga6uiniw/lA7BcV4ls78vEJ/jTYqXjVWJ3grJnJYUjikpFzA5qCOkjzIvOj4QuXhAywMkTQxyjAZyj4+pFeUpYx3QXNiVZD2utwvB85qQ+yZFxKR0ibqMlHT/uZPyzFwjF/kdcveW4v6fhZnxVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l+cgs0CxZa0kdunLLv/LQau+6sVLgqZGMxefP3ziA2Q=; b=sf4isTv2XBIRt1p8iPpUWUXa8PBdhYikNstUc+ClCls2C100vSVmzY2y+0ThyGcrr8dXQK/fkL6xJO5mAumr2vG2d3UcgPYuErRDNatrkBHI9oux6COxXvGA7WSxoffTNZbmogjU2tiYGB1ypF3n+ci/yuIaQWlWKU4DqAZLBxM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:22 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:22 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 29/40] scsi: libiscsi: replace back_lock with task lock during eh Date: Sat, 3 Apr 2021 18:23:22 -0500 Message-Id: <20210403232333.212927-30-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dfa53353-d928-4eba-d769-08d8f6f79cd8 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QWj9YUWUTYXrAoEWSS93pBHNQDhk6ydSVejds81X/1l3R20Ojo3eo5H8ERCa0YIXgg2HKqXul2p/svZ+ym8ypQs7xw24oL8oCaYjHcoRYvxWHcyu8lcBqMRo2sN4G3syv4qzkebMhtQC7Zx2jY8263Auv6yzX5CKynF/eRMIDIm1EZdmIT9TdOCMA5Raa9mvptwdy//p3SwQd9AvFhD6P0RurTdAepiaeBpiiI5QqchZEMxbQ4tdgZVmpu96vBlC3GGW919IxKjJQOB72fNBH12TaKLlSfiQ7/eqOxEDsnXTO3caSAOgbLxZ866fALy1nW91WB13axKneWXWCM69LBkCh/FsCgBPxRl3ni4UdYzICbwJOTnEBlBdbpD3Q3St4/4yQBT1a/Vl8u4/YXNgjtiUw9TlFiaV2GQn/tiadIndc3ceMspumKyG8pBNF4hpo67mBepiuuSDxPSO0+sLAFIbdpk6LaPjoa67FHbqH64ORIT/LItvpMmXgDH/sVymUJLo+GMKG95IeGhxkhZYnNNLpOj5PLJtZeIrUfUpoksjJZnlMsAT+pe4foTJOZri3A/cVutkOFPWnruLThA/haOulzFOGbPhMzlQfDhyfe0pEhoSvffSVJpZ2fZybZJUvXC874KQ1lkZSfOYREoawTALCBcOHozVN+w/SMmB2vXkxnh5zspurqbg+VC6n+H5QbG+3E0JRnqbwGko96U+Ow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(38100700001)(69590400012)(316002)(7416002)(478600001)(2616005)(921005)(4326008)(66476007)(6506007)(66556008)(86362001)(2906002)(6512007)(107886003)(956004)(186003)(30864003)(8676002)(8936002)(6486002)(52116002)(36756003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VvD/leaKnnWG4iP8vJcDgRjrj2Eb5fc/tdllqDxlg/dfSeiMS1fjlWsDa7YhewHr7WSzdpHqBV2JGUQA8ul9U7n/wUDS9s+7LJJ8J3mgArteFiSDSCL6Jt0M6z9+hSLwlLxvvbMJjFxAzzKNAbuPebm939/Jc3KES1GcMVXoQQLt1+s0WA/VpbVZXU5qTZROvIlZdRnnuw0MgmbfGOduxSYWzQEodWP8LeInuku6khGYp1HK/vXwxaa2/nB2NWYvrvDZrTgDOLAbjRF9EoVDOXL+6qO1YBN+lWOxlb0l7vYrzH4tbMLGC5UjIPfFN90izEG27ePJo+ZnIRDjVp6Ngl7MPNAaXGywAjBT4p7SX7Iaf14/x3RGR7WkVLikQndow4AwqKlcY3/AQ8hOTTFYBLmPQApzt3TsLTzMdm6Q6rpqSTSgCRYemZ8mbTdo16IfK24fjGvRu5tjrbwWbicPBX6FlaIQaBFP/e9ZpQi+9Nkft9vtsGluiktsRMrUVrXeHbhtOCA60hL0cotKdr0ShrtmGvi1+XvQ0hv6mHWMDQAg7JieY7h7MLythClM+3lNY1ludZ4EvT2jmL2FMzSpKgK7+BBzvzg8ZGQkPNP+B6XCAfZs9W6Hg7ve3yAlZDkzDxRLK3z3rthoqHvcRd5/Xty6QIfiukzoG+xSlCbLA8YjlRDVmXl39Q3qHwQGrMFZMLCtE8pPpW5bhKA3F9POvxRvIrfvdaLh9nALHw2tvQsCHWGC74N7QjZqXkb9790dSw0AM+tZ2kIAKF9XrspgH9A+v4zJMF2Lwaf3dqrReh6KxY6CO0g4CxERrp/1Cwc2aews6bKIgf+Pb5alZXyZ81vwC9sygK/mAFbbZHvRlgeBu/p7RKAZC0fgRyfhzW3z51HReVYSkLosxKCs4hRSvrxUdFtj61FeRGN+gEHcMM74oYi8qX0SxcQyX2FoRW4vbxcFh0PskQZh4fhQ/ME+h0p2TeFJW7BU1r7/cAqnmcedATdVqYlk5G/7PuCTCoolSt/FZ93xWKT2yD8fgQg13UJyckNIngJcsqHCw804EnKueaf7TdS0mxeEStV9T0hBLHXqEkecA8xYie5HRqy/XhOQ/uIAoAqgZi51Q8IL3TCILUyyuT/9fSt9ekbuDwKvoLC0hLMdd8A1IkBh39iNlYsyfvogVJPNjMn85igUe8byl9HdE9eWc2+0f1ys0+MG+VgRyVXW1fnMfs5jtPbP1ZUYNE8omLDCl+TYiQoLYM99Nso/JZznhKhPcVD5YkmUWVttj3A16tV3+NvygTsDmtvJ133Va2ZMLhj1MHqXpCBBKiIpAydfs80kTzxntkY/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfa53353-d928-4eba-d769-08d8f6f79cd8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:22.4475 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qfzq7b4v+AKk2fU9mATFl8I+A/VaTPDHXwY9JgAC/tFIvmfyK/wr/GxCY4ZfN34MePLpGSfjx8YZRK3Ll1YHdts7NAXjeF2krRAVHKPyjAM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: MC6YwRvVE2cJ2fZ0aOFc4pdcoUgbr6Rx X-Proofpoint-GUID: MC6YwRvVE2cJ2fZ0aOFc4pdcoUgbr6Rx X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This replaces the back_lock with the per task lock for when we were checking the task->state/task->sc/SCp.ptr during error handling. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 132 +++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 955ca15ecf5f..61d73172283e 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -422,7 +422,10 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) if (session->tt->init_task && session->tt->init_task(task)) return -EIO; + spin_lock_bh(&task->lock); task->state = ISCSI_TASK_RUNNING; + spin_unlock_bh(&task->lock); + session->cmdsn++; conn->scsicmd_pdus_cnt++; @@ -440,7 +443,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) * __iscsi_free_task - free a task * @task: iscsi cmd task * - * Must be called with session back_lock. * This function returns the scsi command to scsi-ml or cleans * up mgmt tasks then returns the task to the pool. */ @@ -481,8 +483,6 @@ static void iscsi_free_task(struct iscsi_task *task) if (!sc) return; - /* SCSI eh reuses commands to verify us */ - sc->SCp.ptr = NULL; sc->scsi_done(sc); } @@ -514,8 +514,6 @@ EXPORT_SYMBOL_GPL(iscsi_put_task); * iscsi_finish_task - finish a task * @task: iscsi cmd task * @state: state to complete task with - * - * Must be called with session back_lock. */ static void iscsi_finish_task(struct iscsi_task *task, int state) { @@ -524,11 +522,15 @@ static void iscsi_finish_task(struct iscsi_task *task, int state) ISCSI_DBG_SESSION(conn->session, "complete task itt 0x%x state %d sc %p\n", task->itt, task->state, task->sc); - if (task->state == ISCSI_TASK_COMPLETED || - task->state == ISCSI_TASK_ABRT_TMF) + spin_lock_bh(&task->lock); + if (iscsi_task_is_completed(task)) { + spin_unlock_bh(&task->lock); return; + } + WARN_ON_ONCE(task->state == ISCSI_TASK_FREE); task->state = state; + spin_unlock_bh(&task->lock); if (READ_ONCE(conn->ping_task) == task) WRITE_ONCE(conn->ping_task, NULL); @@ -562,7 +564,7 @@ void iscsi_complete_scsi_task(struct iscsi_task *task, EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task); /* - * Must be called with back and frwd lock + * Must be called with the task and frwd lock */ static bool cleanup_queued_task(struct iscsi_task *task) { @@ -606,9 +608,9 @@ static void fail_scsi_task(struct iscsi_task *task, int err) struct scsi_cmnd *sc; int state; - spin_lock_bh(&conn->session->back_lock); + spin_lock_bh(&task->lock); if (cleanup_queued_task(task)) { - spin_unlock_bh(&conn->session->back_lock); + spin_unlock_bh(&task->lock); return; } @@ -628,8 +630,9 @@ static void fail_scsi_task(struct iscsi_task *task, int err) sc = task->sc; sc->result = err << 16; scsi_set_resid(sc, scsi_bufflen(sc)); + spin_unlock_bh(&task->lock); + iscsi_finish_task(task, state); - spin_unlock_bh(&conn->session->back_lock); } static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, @@ -1726,7 +1729,6 @@ static struct iscsi_task *iscsi_init_scsi_task(struct iscsi_conn *conn, struct iscsi_task *task = scsi_cmd_priv(sc); sc->SCp.phase = conn->session->age; - sc->SCp.ptr = (char *) task; refcount_set(&task->refcount, 1); task->itt = blk_mq_unique_tag(sc->request); @@ -1769,7 +1771,6 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) int sess_state; sc->result = 0; - sc->SCp.ptr = NULL; ihost = shost_priv(host); @@ -1877,9 +1878,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) prepd_reject: spin_unlock_bh(&session->frwd_lock); - spin_lock_bh(&session->back_lock); __iscsi_free_task(task); - spin_unlock_bh(&session->back_lock); reject: ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason); @@ -1888,9 +1887,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) prepd_fault: spin_unlock_bh(&session->frwd_lock); - spin_lock_bh(&session->back_lock); iscsi_finish_task(task, ISCSI_TASK_COMPLETED); - spin_unlock_bh(&session->back_lock); return 0; fault: @@ -1978,39 +1975,43 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, static bool fail_scsi_task_iter(struct scsi_cmnd *sc, void *data, bool rsvd) { - struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_task *task = scsi_cmd_priv(sc); struct iscsi_sc_iter_data *iter_data = data; struct iscsi_conn *conn = iter_data->conn; struct iscsi_session *session = conn->session; ISCSI_DBG_SESSION(session, "failing sc %p itt 0x%x state %d\n", task->sc, task->itt, task->state); - __iscsi_get_task(task); - spin_unlock_bh(&session->back_lock); fail_scsi_task(task, *(int *)iter_data->data); - - spin_unlock_bh(&session->frwd_lock); - iscsi_put_task(task); - spin_lock_bh(&session->frwd_lock); - - spin_lock_bh(&session->back_lock); return true; } static bool iscsi_sc_iter(struct scsi_cmnd *sc, void *data, bool rsvd) { - struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_task *task = scsi_cmd_priv(sc); struct iscsi_sc_iter_data *iter_data = data; + bool rc; - if (!task || !task->sc || task->state == ISCSI_TASK_FREE || - task->conn != iter_data->conn) + spin_lock_bh(&task->lock); + if (!task->sc || iscsi_task_is_completed(task) || + task->conn != iter_data->conn) { + spin_unlock_bh(&task->lock); return true; + } + __iscsi_get_task(task); + spin_unlock_bh(&task->lock); - if (iter_data->lun != -1 && iter_data->lun != task->sc->device->lun) - return true; + if (iter_data->lun != -1 && iter_data->lun != task->sc->device->lun) { + rc = true; + goto put_task; + } - return iter_data->fn(sc, iter_data, rsvd); + rc = iter_data->fn(sc, iter_data, rsvd); + +put_task: + iscsi_put_task(task); + return rc; } void iscsi_conn_for_each_sc(struct iscsi_conn *conn, @@ -2020,9 +2021,7 @@ void iscsi_conn_for_each_sc(struct iscsi_conn *conn, struct Scsi_Host *shost = session->host; iter_data->conn = conn; - spin_lock_bh(&session->back_lock); scsi_host_busy_iter(shost, iscsi_sc_iter, iter_data); - spin_unlock_bh(&session->back_lock); } EXPORT_SYMBOL_GPL(iscsi_conn_for_each_sc); @@ -2102,7 +2101,7 @@ static int iscsi_has_ping_timed_out(struct iscsi_conn *conn) static bool check_scsi_task_iter(struct scsi_cmnd *sc, void *data, bool rsvd) { - struct iscsi_task *task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_task *task = scsi_cmd_priv(sc); struct iscsi_sc_iter_data *iter_data = data; struct iscsi_task *timed_out_task = iter_data->data; @@ -2152,19 +2151,20 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); spin_lock_bh(&session->frwd_lock); - spin_lock(&session->back_lock); - task = (struct iscsi_task *)sc->SCp.ptr; - if (!task) { + + task = scsi_cmd_priv(sc); + spin_lock(&task->lock); + if (!task->sc || iscsi_task_is_completed(task)) { /* * Raced with completion. Blk layer has taken ownership * so let timeout code complete it now. */ rc = BLK_EH_DONE; - spin_unlock(&session->back_lock); + spin_unlock(&task->lock); goto done; } __iscsi_get_task(task); - spin_unlock(&session->back_lock); + spin_unlock(&task->lock); if (READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) { /* @@ -2336,20 +2336,37 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "aborting sc %p\n", sc); +check_done: mutex_lock(&session->eh_mutex); spin_lock_bh(&session->frwd_lock); /* * if session was ISCSI_STATE_IN_RECOVERY then we may not have * got the command. */ - if (!sc->SCp.ptr) { + task = scsi_cmd_priv(sc); + spin_lock_bh(&task->lock); + if (!task->sc) { ISCSI_DBG_EH(session, "sc never reached iscsi layer or " "it completed.\n"); + spin_unlock_bh(&task->lock); spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); return SUCCESS; } + if (iscsi_task_is_completed(task)) { + spin_unlock_bh(&task->lock); + spin_unlock_bh(&session->frwd_lock); + mutex_unlock(&session->eh_mutex); + + ISCSI_DBG_EH(session, "sc in process of completing. Waiting.\n"); + msleep(100); + goto check_done; + } + + __iscsi_get_task(task); + spin_unlock_bh(&task->lock); + /* * If we are not logged in or we have started a new session * then let the host reset code handle this @@ -2357,6 +2374,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) if (!session->leadconn || READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN || sc->SCp.phase != session->age) { + iscsi_put_task(task); spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); ISCSI_DBG_EH(session, "failing abort due to dropped " @@ -2368,25 +2386,16 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) conn->eh_abort_cnt++; age = session->age; - spin_lock(&session->back_lock); - task = (struct iscsi_task *)sc->SCp.ptr; - if (!task || !task->sc) { - /* task completed before time out */ - ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); - - spin_unlock(&session->back_lock); - spin_unlock_bh(&session->frwd_lock); - mutex_unlock(&session->eh_mutex); - return SUCCESS; - } ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt); - __iscsi_get_task(task); - spin_unlock(&session->back_lock); + spin_lock_bh(&task->lock); if (task->state == ISCSI_TASK_PENDING) { + spin_unlock_bh(&task->lock); + fail_scsi_task(task, DID_ABORT); goto success; } + spin_unlock_bh(&task->lock); /* only have one tmf outstanding at a time */ if (conn->tmf_state != TMF_INITIAL) @@ -2424,7 +2433,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); goto failed_unlocked; case TMF_NOT_FOUND: - if (!sc->SCp.ptr) { + if (!task->sc) { conn->tmf_state = TMF_INITIAL; memset(hdr, 0, sizeof(*hdr)); /* task completed before tmf abort response */ @@ -3334,27 +3343,28 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) for (i = 0; i < ISCSI_MGMT_CMDS_MAX; i++) { task = conn->session->mgmt_cmds[i]; - if (task->sc) - continue; - if (task->state == ISCSI_TASK_FREE) + spin_lock_bh(&task->lock); + if (task->state == ISCSI_TASK_FREE) { + spin_unlock_bh(&task->lock); continue; + } ISCSI_DBG_SESSION(conn->session, "failing mgmt itt 0x%x state %d\n", task->itt, task->state); - spin_lock_bh(&session->back_lock); if (cleanup_queued_task(task)) { - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&task->lock); continue; } state = ISCSI_TASK_COMPLETED; if (task->state == ISCSI_TASK_PENDING) state = ISCSI_TASK_COMPLETED; + spin_unlock_bh(&task->lock); + iscsi_finish_task(task, state); - spin_unlock_bh(&session->back_lock); } } From patchwork Sat Apr 3 23:23:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415229 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 47B88C433B4 for ; Sat, 3 Apr 2021 23:25:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CBC461360 for ; Sat, 3 Apr 2021 23:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236965AbhDCXZP (ORCPT ); Sat, 3 Apr 2021 19:25:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45958 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236633AbhDCXZM (ORCPT ); Sat, 3 Apr 2021 19:25:12 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NOvVb041947; Sat, 3 Apr 2021 23:24:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=6m/an33mev425U6J8CS50EjBY2eqVe6qeigwC7ISfDY=; b=uIB+oYgTUqyIlc8PnrmJW25ui+U8OSxnqe6m0rU4N+kFJTmfPGZc8pyUV2D6CMZXQ5Qn bkviKACnozK2Ep+duPoxSLCADjiIrq8E17ZVDv6Hp8XacrhcTl6Cc5S61s4+9zB8k6Gl EOeON3HzsJtR3JDWStfDCEjHkofvY6ws0aYJ1VQ7LtBq1DhndTzyap242e3mF71oFcdM Ugva7/q39iBXfJ0Lt2cegvHrQtGjke3b3ryJ9IExnTI5TKYAapZqd6xmPmV5F5Zb0ITS P5iDB/L3oB67B+1xPy9w/BnlTFyOHGXQjs7sUAciK/HOGJhwi7R5taPpSuMLNQ4Y8wP9 uw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37pfsrrsh7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:57 +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 133NKtBR117020; Sat, 3 Apr 2021 23:24:56 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXLBtoWvDB8eORd+ndJmj33TT2xrnzKBl6V2xJl6GC41QCkW5Fg5Hh1MvChzladByocqNS3fbWtHck6xHHapPFml01pzisnb0bNqiSFBo5JjLn00RbvZE99OSTwRaCNtwAGrUPo/xrT4gzvnkI0+AJqmsiu0LqnD03psyKoggozotAYEnMVF8tMYg3q1ZxaYvqbElPZy3BHN8Oifc5PdxdHSZnfKNk/mMofEnHPC4c9ORnOVvyTwBK1sh8TO1OWGn6eF1Ouz7X6yPzk6CH4MEs0MFhX7jlRo9heJjASYgCW8ZI1I+sYi4Q+w/N1I3um1JFnwxJOwBH155fSp0h8DHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6m/an33mev425U6J8CS50EjBY2eqVe6qeigwC7ISfDY=; b=XJOGLwyksHx+30vhKU5phw4kD348/GOwACLaTDy7q3c8TtCfQd/cYIjJ9HH1MhjbwlcLmhpU9eHFjh4t5SkgZM42T+Hw6Kph9tTWllzB8lNkxARcDN+C2fDXklLhVP+WuQJTfAxZUy9/twNiU+14WCS+dr4bLlGyqE30Z+NK6UMS4CVrKVqCPjoKB/2jCU8iDmUrtY7O8AJO3n+QmGtza68RNIxSRmK6/eh1Bv9UkVTQgeEeu1PfJ7GkW+ckzNdceahdSougcjQO/bS+RTdXGBJ3Wg9ZXqd+SVRAiMva2PRhqEx0+2/FU4SGS5MjcNhKDPa1y3CEfckzDecvRsDn7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6m/an33mev425U6J8CS50EjBY2eqVe6qeigwC7ISfDY=; b=JeshIR/bA1Cm2Jq2t65eu4TxTRHHGlOLfjzUDPePF72Qu0uu+dUc02LLPAguBxsvtPeFB6Yh67xxqAIuPWN+nTKkxQiK1aXL49dcHjqK4OT60+LRXtc+qJhgtuIZYy3S+8fmIR6GEx9DvohSc0PB2YS45YwaUuLzjFpYbWTkT/k= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:54 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:54 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 30/40] scsi: be2iscsi: prep for back_lock removal Date: Sat, 3 Apr 2021 18:23:23 -0500 Message-Id: <20210403232333.212927-31-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53d57d42-4db2-4557-c884-08d8f6f79db9 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vf0xxvZpJT+OALhiYCZHeHrvNoAbHSUSDAfRDkbdp+fgiPnWAQpVzdE1ODN2bMtiIz00+4IrfMuk0ECN+x2Bo8rd3NUcjwl83lG7n6E4PjgdWxSn6mdCD4HoFGeGFBqlLV9dmPleJfBZUXoLTR7E4iKQhhY5oiBicpwaARb+h4NhcW+rVPshpQcTKMWgGnHQqMTAA4PpXay9G4SVFjbrGok4QR2Vzift7rmM0gtKhhz8jEAhhVGGj0EHMmazZBabXalkRAUTF6cxHvAlPNeNVbld6HfIsBb/swGbXDdGY3k4yFvSfBEsJ4QTftnCGntg4bOa5s9tPzOQSNfqY51s4UpZ/Nm767YlA84CUbKRcFsNyTwk87+63cAKrk+MPqApQhMjuOqHMUkXgWq6p93TDENKYiCJm+XWrFn0XcQIT2y7/IWZv8ImljhsZhF/fPc6SJVB8bguGBuRlG+a+A3Jr7TMMJU2mgHeOzOAMp4xR+XUiy/UuNKE8CoiYScIQMt4hoNi18ervcZwfKrnFEz5xz8ks29Ek6utkaa7p9ZrAsg38u3IxLr5UjXvdqvqjHZNJgp9xccWU3i/8xkntkJodRlubSaEYCBCocn/1LAhex+rU2qJ/OERD+7sDLShxjgQfFw3Uy89ZOrYN8zjI44KlFpt8u3OqXp2DrSg48d7EF89DEK5NVTCLsZexvghiD50hdiGCCe588U5QjbYxpTTlg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tTsiSKdmp5PwihrsQitW+x84F19ZJaXjHfDA7Sl36ImhwVeKlt6WUyzHpNUb7AsdQi9Eu1cmlpFS52n9SK6C1hgxDSrLDRS1bISvM+OD30C0QNtNUkceYwEvQeKZBXoQ0X75vAG9p9iAGlgqfzyODv35dS0bxjYFuwgjxSvwZAUEoDOJ8YWMK+t/gdi/cwbd2swuZn24BQZNoQFhB62ri/FcWRbtMUbzS05m+DQnOg19o7zvnbtNdGAPerF2ZkHdViO1ByjWtT98V1XsO1S31y+fg2LQSxAZDm0v5PEMGvx8c1LZP+pYHkB4g8K2mhnA8xj3pm+PwTTn4uDoluUQ9WOK2cnWnaFXiPWdMsRR9bMpQ/WRdn3LkNsJdXx+9RkCugRM8wA18rwqdDe0j6ciRMzB/PGSVW98Hfzojb8oBdtkRu5z4ei/KhFiWiUzIt3H9Fdn4LOyFJCSqPNUSRim0eeSJ/IQuTpRocx0Jji0GS3ZDuTQ48bLTaezyz3jAuwz3nf1TjAf6fF1aZvWvRe4vu/9q4dOCc/nby2afLJdoGesfUBDVQGsdsH0usxO6Z9ukjBzQ0ObXnEnTiX3RAs1kn0VAWbXarPY87VczCukHDE6/YtSYO7q44iBHaeOxvd93QgQovBWqmNwnrego0F1GEWgk96U/VSCKNnISJYgfRipl/hXC+TTJyXkVzyE59kz6Gd74Qy1nw9Dpu5v00TqEgvuSI0JfYIyJIX8eNjx5y/M7sq328KJhmy+/VeP9d0WrvmgoxJsJCIrYnEyRaLq7PsW6jtcs88pgYsVaJea0oSHuSMWmMjGnP/NhbctJvc6RcYD5RM7e1xAJWI0nKAiD+YJZQ2HW+bjbcDhqKk3XvfW4REhS3ZmgeDkivDgDQOo52G/K905OI3VMBZlnScsHN/D6Y5Iixj67nm4PMAYFwXc5D7pQhoAqO2H2OkYCR8XqneGPqGuBIDlCLHYKbFDk68pVUeH+LpmHXeNxWiFds8CTTxMYJfqsII2BAPqFiYIuYMXFl67a5REUedN3zKwDjz5JqGmXikSTLPk/ktqYRkr3IcMVkp8k69iGt6Dt7KITopGTu4FpBvQgkDRIW9NNzUtW7A+CVgXBAuIZZCAQb+a0TlFDxyNmkz0rOABGHA7m+++s9AdtwSL8aI1T1m9W/T+6hh3wnDm1ReB2qOfl9Kdq4zE2t+4XBd/tN796Os6LX2J/hf/uYY+7bHPhBs7cRF9JKLGC5n+YV93zpuGt7byjUfX6NCXZLOcSMFbqHgMv1RvaKzWWyEUXL1VyMHvcqOA7pt6DfICmSWquNH6JUH3l+35gLDtnZ8WbaYjYiNK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53d57d42-4db2-4557-c884-08d8f6f79db9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:23.9526 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jOns3/V1E11HkihiugyL+oV9rwzoDJ3s8PsYMp1hr9kWETO0R5R0+klB0f4UgOXfNpZLJwib9BZDpgu98Ak3ICOcbQh/XjxIcSkCWPbFpEk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: NkEKhxlZCk0LIc6jw53l_GY00rJiPCdL X-Proofpoint-GUID: NkEKhxlZCk0LIc6jw53l_GY00rJiPCdL X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patchset removes the back_lock. To prep for that this patch has be2iscsi check if the cmd has completed in the driver under the wrb_lock and then grab the task lock to check if it's completed in libiscsi. We then get a ref to the task to make sure it doesn't complete from under us while we process it. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 39 +++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index da5ede4ef7f4..fd62258b1b6d 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -1228,8 +1228,8 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, uint16_t wrb_index, cid, cri_index; struct hwi_controller *phwi_ctrlr; struct wrb_handle *pwrb_handle; - struct iscsi_session *session; struct iscsi_task *task; + unsigned long flags; phwi_ctrlr = phba->phwi_ctrlr; if (is_chip_be2_be3r(phba)) { @@ -1247,12 +1247,21 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, cri_index = BE_GET_CRI_FROM_CID(cid); pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index]; - session = beiscsi_conn->conn->session; - spin_lock_bh(&session->back_lock); + + spin_lock_irqsave(&pwrb_context->wrb_lock, flags); task = pwrb_handle->pio_handle; + if (task) { + spin_lock(&task->lock); + if (!iscsi_task_is_completed(task)) + __iscsi_get_task(task); + else + task = NULL; + spin_unlock(&task->lock); + } + spin_unlock_irqrestore(&pwrb_context->wrb_lock, flags); + if (task) - __iscsi_put_task(task); - spin_unlock_bh(&session->back_lock); + iscsi_put_task(task); } static void @@ -1338,6 +1347,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, struct wrb_handle *pwrb_handle; struct iscsi_task *task; uint16_t cri_index = 0; + unsigned long flags; uint8_t type; phwi_ctrlr = phba->phwi_ctrlr; @@ -1351,12 +1361,22 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, pwrb_handle = pwrb_context->pwrb_handle_basestd[ csol_cqe.wrb_index]; - spin_lock_bh(&session->back_lock); + spin_lock_irqsave(&pwrb_context->wrb_lock, flags); task = pwrb_handle->pio_handle; - if (!task) { - spin_unlock_bh(&session->back_lock); - return; + if (task) { + spin_lock(&task->lock); + if (!iscsi_task_is_completed(task)) + __iscsi_get_task(task); + else + task = NULL; + spin_unlock(&task->lock); } + spin_unlock_irqrestore(&pwrb_context->wrb_lock, flags); + + if (!task) + return; + + spin_lock_bh(&session->back_lock); type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; switch (type) { @@ -1398,6 +1418,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, } spin_unlock_bh(&session->back_lock); + iscsi_put_task(task); } /* From patchwork Sat Apr 3 23:23:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415098 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 30106C43460 for ; Sat, 3 Apr 2021 23:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F197861360 for ; Sat, 3 Apr 2021 23:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236989AbhDCXZQ (ORCPT ); Sat, 3 Apr 2021 19:25:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45964 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236684AbhDCXZN (ORCPT ); Sat, 3 Apr 2021 19:25:13 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NNCmX041440; Sat, 3 Apr 2021 23:24:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=IlWg0hCcyD7CjdpwjgJ7rZVLTfeBDxV6Iyd+AfrHlAk=; b=Pydbc69FY3PkixP2qYfJWrqbhXUlWiMof9JKZXND/Bq+VSaAHLDWvm+ydcuoptvHLEPA UlMb/skjq6DDmOSb6OwA5lVjXKKSDHqu1JfG46pmRXsKp6wCXlwkkyzihx3rz2gnI9XW 8vPpvkTreoHfPH6rCceyEI/NdtgRcMK62n0ycCf2b13n/DXOzXPmlmzNs++pREdH3Q4b QAfRx5WoBahCFS8/VHrlq0ycxdNFbq1etBtx+2smmh6E059oCTQ0RNhhzOA2J/6kFkxB gUeRZ5SkB1Jch4WN3exW8NC8UX424AHC/ZEn5lf5SjmnYKY6vXz7lQcl/6sqyPVrHPXN 1A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37pfsrrsh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:57 +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 133NKtBS117020; Sat, 3 Apr 2021 23:24:57 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXuSgP2biBASOTsRxEPs84TKT+DIpzVPdatp7RwvMRL93yfFaTIxQPyU+9g7kwPsnYSM33tluhAfZ6gZHkSqke8x7y1C8y7FWfyoocDFPwNJ4nn+/0rabQsHQINNkNlshuD+erQQ1rHZSMLy3r8rs+omMakk8pEGlDkl5FF0LcqouOFu9T6cB90+8r7Lec/H0LS6gV67LMknXlkJ1oOnjAWHB4+G09dpfk2T/ajGECWod2fhYKb1eIAephcq9Rj2yDMqFsnPhL9KvJRCOtgz5+evuyCzzZu5Vu+sT2Vhwes3Icv3oJkZuc9/UT35zU0gqY4s6PyolDHAznNQvlP96w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IlWg0hCcyD7CjdpwjgJ7rZVLTfeBDxV6Iyd+AfrHlAk=; b=axAJy+JJreHISnNqdsF4KSYvajo6966UfNvWNVJGaqbc/ToMPndbsMwelQNJdkdJtNeTV6Z5uQL1jSgVD5GxaATJfm0Zsr4v2gZ+uq7nK81K53DKsf2eOOjdJnA+wv3l6u2/XLRyusWj0XnC7oS5Qfu/BJ+wctvz7skaubE51sp01kqhglH233Pmw3vdQdzXih9bjqoZlDqfKhFM1b/FRZAzHEosasLrQJyN7k1ACqKmy6xxkeHm+XzjL0sYenogFj+TbJ7XIMOZwc0t/vXRlnBvDDB8feLO18GZ43CLQorUJ3jwzrdyFQlLNkQNiD8QSoY0z+WdP1e12tuT47G7OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IlWg0hCcyD7CjdpwjgJ7rZVLTfeBDxV6Iyd+AfrHlAk=; b=z27uNG//GTfWmaBxA4K/4ZInNPjgfYHnuzTzV/JFYBFgMSp5xqjV6rpUBlY4EyeMwZVcg09zRHzFBrQ1fzloT9wa7JQZ5nOh4xghQ4fOqtFiuXhPefXBUD43AhIXkyE7Wt3PrJ2pxYoUHK+Y1y2atKPruVnPa4noPKcsgvP2xjk= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:54 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:54 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 31/40] scsi: iscsi: rm iscsi_put_task back_lock requirement Date: Sat, 3 Apr 2021 18:23:24 -0500 Message-Id: <20210403232333.212927-32-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10a2e080-fe71-4133-07bb-08d8f6f79e9b X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6RdAe1wkTBNjkuJyiaCskdLy8nTwC4GBGZob2kS+yWkr62iM8TZiGuHjCyPzBtnLjCfwdRbj8n4K9vkxBHHGdEi3CkfwuTz/+V3bpYlzrSqSIWF8uUSID5e4l1FIZyq3Xw2zf5VX/ySiGSCkKD7KSvNM9Ou3YJdWfP8PTDoMWBknTgtI+PcS2QMwStGxsAc3agWTWC/WXnGGpvg+GPnrAQJPXnAJh6AL3HsxtOVL+hU3MP8qlU5bPmw+zxI4s+dO22MA9ll4ASIiIhMrV91acP4v8nkVU9PoHoLwiPzbXl8bgOZRk96J6rAMQomGjc6yPl5Y22disd/8idXUK7cYCFk/iPUGhQb7biiz46Ck7jc9uUEYWrZAQHWnex5MUSwjgIWPW0ra4m3nWwc6xbzIe7bwL45GHhV5sEylVUyhNRxqHQQ45Y+l2izOsog5pOIrV59A/9wVh08dw6mlvX8JWk4z7k0brndti4nofyIv9oP9C/pqIdyvaOrifm2WLnmg1J+f7nAJxXET18E6P16zexNoRI9HgsVqW2bE9NdV9CUtyepyFHjO7Cyj90e3MQTJt9nyovMYGfRfw61Y/XDUKB5QFn84VEiD9Afzgm94wp9aQlkajNedYI/RyUZrbGfQgybLWyXxW6w8uHpQ6ZwAuwzsIIq4Tz8zAL+q/48jzA7KhjUqglsJSHFvmkkH2Ud6RUya+1nt2tN1+eOaFOIqBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: e0sz/O9M9wTK8AfVnAa8khrgXXceXnoy8uZyKWsXpf4WkAjI2DKwM3UoWdROtgPLoSrTgJGbifV+vgjjuL8NMV6YZ4oCUDAP9oMi8BNNtHuLVnX++eBNzt2AU0eg9ou/l3wCXB13ZRphYPO7mwsaVocIh/q/5JYrJqvUxarsGgSz93J33dVgsuI8baWsT/wJfVezAXiOhPIveR4fXm8VdEFD7zeBP9uAwsVql0mckd/SlkAARhG4YChEl51KeuUqm/sIIKQiTcwkG0gOfmitbE5YGNTs6agzTAOSWFf5h/F2WY7soxAcrmSZsaE+qKzeC38wcn6dc5omsFFDE3hc4jWKr2fFW++qXE9d8QqtX1Kms15rrT4h3AFk6wT25KvQhTGdfonkZ/QQ1SekUVPvqdocs9zVmuLzo9ifiT2uxVQvYLhvczpC/NPNNjUIOcu/xvXEUcdqicKBiKQixIkHYcegqHlDj289AweEqIIWCV6QViWFvYgZ0ee1cuFzgOsLwqarKVVJPqgq9YaSrtbfbEJJ+kH2IxvZcVC/BekXB2SMhmf0DmM1MdVB3wYKFOxhQPwnDXJikFz//1qKOJ/4pfaku9IcpMxQY4vVoSgUkaTB2YLTR0I8G1FpiXPr48XXYRX7kQGzsLkNsZcB2B53P1VCUbt5Xo67AFDmH5s+tCX5yhPWHnJQRmUeY5ViY+f406NDCLxrfkE93OLo1qLTXJMvYGtIWm6P3tDTHh98vvosSI/VMW1XOlRqpmnl6G1whqvGUD9AMRaBQDuIanTpa03nqDndpaubkKvnJK+1Ylk3Zl8DSFdyq56FQnBNnxVHoCsLNbAGBlEXLyjznNggz2zciDP8m/VZrradU+aT8+dUewHQg2TTGxKMYxeYXU/KQw+b1fCfXbP85v8BdR2HmfLHeZNWtxaBxgBMXSjlrgfYiBPVqesHIaYEvEOBTI/auiHaMOyjy7kUrVpYWexqHSkSWBL3tkjsfE5s/E7haOa9s4fPl9WED0yuT0PCPtC2OteK0j+meaCNTo8uG85zrNvdiya8K/vPFoa40l9CZbPSH5kgzhcvSFrUvLQkW9fZTuN6JP7ZVXOt7wPGH3u/COhAmt1x19wVwNaFgQWkT2/d3XPwnFVOt0gQr94wmpWPnWsJaxrwhi4Iuy2ExAwkAEsz+oPXhZwh94NNGk2MFHT57hjgOsjez6P4NhGFpRnSRqzDqUX65ODbc5PlL4jDV3jIGJ+OeNYkJQloo32RBK7LSyv4gT+if7n5UUMoYZwGrjW0lFfQAs0hpF+B/NVUOLfBd7aZRnRciLC4j+iPshB5HuomnM7fzOJa7PMaSg74 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10a2e080-fe71-4133-07bb-08d8f6f79e9b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:25.3479 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WQNhrQvHrns0WKF4+wF6dzQn7ffM7ayS61V2zn4qiEuAtbkBnq+LD2HZoVuSC4dS6u8cBTuh84G7iDAXH+4QPMGL73lvXzp+OPTvhmdpXDM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: UsLkXHqnGcE0ObBcWj5_8-xQ-kev909B X-Proofpoint-GUID: UsLkXHqnGcE0ObBcWj5_8-xQ-kev909B X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is now no need to hold the back_lock when calling iscsi_put_task. This patch removes the cases we were grabbing it, and syncs up the ref count naming functions. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 8 ++-- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 - drivers/scsi/libiscsi.c | 64 ++++++++++---------------------- drivers/scsi/qedi/qedi_fw.c | 11 ++---- drivers/scsi/qedi/qedi_iscsi.c | 2 +- include/scsi/libiscsi.h | 3 +- 6 files changed, 29 insertions(+), 61 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index fd62258b1b6d..9f1f8b95a2f7 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -232,7 +232,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) return SUCCESS; } /* get a task ref till FW processes the req for the ICD used */ - __iscsi_get_task(abrt_task); + iscsi_get_task(abrt_task); abrt_io_task = abrt_task->dd_data; conn = abrt_task->conn; beiscsi_conn = conn->dd_data; @@ -287,7 +287,7 @@ static bool beiscsi_dev_reset_sc_iter(struct scsi_cmnd *sc, void *data, } /* get a task ref till FW processes the req for the ICD used */ - __iscsi_get_task(task); + iscsi_get_task(task); io_task = task->dd_data; /* mark WRB invalid which have been not processed by FW yet */ if (is_chip_be2_be3r(phba)) { @@ -1253,7 +1253,7 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, if (task) { spin_lock(&task->lock); if (!iscsi_task_is_completed(task)) - __iscsi_get_task(task); + iscsi_get_task(task); else task = NULL; spin_unlock(&task->lock); @@ -1366,7 +1366,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, if (task) { spin_lock(&task->lock); if (!iscsi_task_is_completed(task)) - __iscsi_get_task(task); + iscsi_get_task(task); else task = NULL; spin_unlock(&task->lock); diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index a964e4e81a0c..41a1a325ab01 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1162,10 +1162,8 @@ static void bnx2i_cleanup_task(struct iscsi_task *task) if (task->state == ISCSI_TASK_ABRT_TMF) { bnx2i_send_cmd_cleanup_req(hba, task->dd_data); - spin_unlock_bh(&conn->session->back_lock); wait_for_completion_timeout(&bnx2i_conn->cmd_cleanup_cmpl, msecs_to_jiffies(ISCSI_CMD_CLEANUP_TIMEOUT)); - spin_lock_bh(&conn->session->back_lock); } bnx2i_iscsi_unmap_sg_list(task->dd_data); } diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 61d73172283e..d4709e20b05c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -486,28 +486,17 @@ static void iscsi_free_task(struct iscsi_task *task) sc->scsi_done(sc); } -void __iscsi_get_task(struct iscsi_task *task) +void iscsi_get_task(struct iscsi_task *task) { refcount_inc(&task->refcount); } -EXPORT_SYMBOL_GPL(__iscsi_get_task); +EXPORT_SYMBOL_GPL(iscsi_get_task); -void __iscsi_put_task(struct iscsi_task *task) +void iscsi_put_task(struct iscsi_task *task) { if (refcount_dec_and_test(&task->refcount)) iscsi_free_task(task); } -EXPORT_SYMBOL_GPL(__iscsi_put_task); - -void iscsi_put_task(struct iscsi_task *task) -{ - struct iscsi_session *session = task->conn->session; - - /* regular RX path uses back_lock */ - spin_lock_bh(&session->back_lock); - __iscsi_put_task(task); - spin_unlock_bh(&session->back_lock); -} EXPORT_SYMBOL_GPL(iscsi_put_task); /** @@ -536,7 +525,7 @@ static void iscsi_finish_task(struct iscsi_task *task, int state) WRITE_ONCE(conn->ping_task, NULL); /* release get from queueing */ - __iscsi_put_task(task); + iscsi_put_task(task); } /** @@ -587,12 +576,12 @@ static bool cleanup_queued_task(struct iscsi_task *task) */ if (task->state == ISCSI_TASK_RUNNING || task->state == ISCSI_TASK_COMPLETED) - __iscsi_put_task(task); + iscsi_put_task(task); } if (conn->task == task) { conn->task = NULL; - __iscsi_put_task(task); + iscsi_put_task(task); } return early_complete; @@ -788,10 +777,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, return task; free_task: - /* regular RX path uses back_lock */ - spin_lock(&session->back_lock); - __iscsi_put_task(task); - spin_unlock(&session->back_lock); + iscsi_put_task(task); return NULL; } @@ -1156,7 +1142,7 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) if (iscsi_task_is_completed(task)) return NULL; - __iscsi_get_task(task); + iscsi_get_task(task); return task; } else { return iscsi_itt_to_ctask(conn, itt); @@ -1426,7 +1412,7 @@ struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) spin_unlock_bh(&task->lock); return NULL; } - __iscsi_get_task(task); + iscsi_get_task(task); spin_unlock_bh(&task->lock); return task; @@ -1505,11 +1491,9 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, { int rc; - spin_lock_bh(&conn->session->back_lock); - if (!conn->task) { /* Take a ref so we can access it after xmit_task() */ - __iscsi_get_task(task); + iscsi_get_task(task); } else { /* Already have a ref from when we failed to send it last call */ conn->task = NULL; @@ -1520,7 +1504,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, * case a bad target sends a cmd rsp before we have handled the task. */ if (was_requeue) - __iscsi_put_task(task); + iscsi_put_task(task); /* * Do this after dropping the extra ref because if this was a requeue @@ -1532,31 +1516,26 @@ static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, * task and get woken up again. */ conn->task = task; - spin_unlock_bh(&conn->session->back_lock); return -ENODATA; } - spin_unlock_bh(&conn->session->back_lock); spin_unlock_bh(&conn->session->frwd_lock); rc = conn->session->tt->xmit_task(task); - spin_lock_bh(&conn->session->frwd_lock); if (!rc) { /* done with this task */ task->last_xfer = jiffies; + iscsi_put_task(task); } - /* regular RX path uses back_lock */ - spin_lock(&conn->session->back_lock); + + spin_lock_bh(&conn->session->frwd_lock); if (rc) { /* - * get an extra ref that is released next time we access it - * as conn->task above. + * Keep ref from above. Will be released next time we access it + * as conn->task. */ - __iscsi_get_task(task); conn->task = task; } - __iscsi_put_task(task); - spin_unlock(&conn->session->back_lock); return rc; } @@ -1627,10 +1606,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) running); list_del_init(&task->running); if (iscsi_prep_mgmt_task(conn, task)) { - /* regular RX path uses back_lock */ - spin_lock_bh(&conn->session->back_lock); - __iscsi_put_task(task); - spin_unlock_bh(&conn->session->back_lock); + iscsi_put_task(task); continue; } rc = iscsi_xmit_task(conn, task, false); @@ -1999,7 +1975,7 @@ static bool iscsi_sc_iter(struct scsi_cmnd *sc, void *data, bool rsvd) spin_unlock_bh(&task->lock); return true; } - __iscsi_get_task(task); + iscsi_get_task(task); spin_unlock_bh(&task->lock); if (iter_data->lun != -1 && iter_data->lun != task->sc->device->lun) { @@ -2163,7 +2139,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) spin_unlock(&task->lock); goto done; } - __iscsi_get_task(task); + iscsi_get_task(task); spin_unlock(&task->lock); if (READ_ONCE(session->state) != ISCSI_STATE_LOGGED_IN) { @@ -2364,7 +2340,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) goto check_done; } - __iscsi_get_task(task); + iscsi_get_task(task); spin_unlock_bh(&task->lock); /* diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index de5133be1c4b..53099d560eed 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -706,11 +706,8 @@ static void qedi_mtask_completion(struct qedi_ctx *qedi, static void qedi_process_nopin_local_cmpl(struct qedi_ctx *qedi, struct iscsi_cqe_solicited *cqe, - struct iscsi_task *task, - struct qedi_conn *qedi_conn) + struct iscsi_task *task) { - struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct qedi_cmd *cmd = task->dd_data; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_UNSOL, @@ -720,9 +717,7 @@ static void qedi_process_nopin_local_cmpl(struct qedi_ctx *qedi, cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); - spin_lock_bh(&session->back_lock); - __iscsi_put_task(task); - spin_unlock_bh(&session->back_lock); + iscsi_put_task(task); } static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, @@ -904,7 +899,7 @@ void qedi_fp_process_cqes(struct qedi_work *work) if ((nopout_hdr->itt == RESERVED_ITT) && (cqe->cqe_solicited.itid != (u16)RESERVED_ITT)) { qedi_process_nopin_local_cmpl(qedi, &cqe->cqe_solicited, - task, q_conn); + task); } else { /* Process other solicited responses */ qedi_mtask_completion(qedi, cqe, task, q_conn, que_idx); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 77f0445c0198..6276f49b6402 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -65,7 +65,7 @@ static int qedi_eh_abort(struct scsi_cmnd *cmd) return SUCCESS; } - __iscsi_get_task(task); + iscsi_get_task(task); spin_unlock_bh(&task->lock); qedi_conn = task->conn->dd_data; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 25590b1458ef..8f623de1476b 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -487,8 +487,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t); extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t); extern void iscsi_requeue_task(struct iscsi_task *task); extern void iscsi_put_task(struct iscsi_task *task); -extern void __iscsi_put_task(struct iscsi_task *task); -extern void __iscsi_get_task(struct iscsi_task *task); +extern void iscsi_get_task(struct iscsi_task *task); extern void iscsi_complete_scsi_task(struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn); extern int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, From patchwork Sat Apr 3 23:23:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415099 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 3735DC433ED for ; Sat, 3 Apr 2021 23:25:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B0656135E for ; Sat, 3 Apr 2021 23:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236950AbhDCXZN (ORCPT ); Sat, 3 Apr 2021 19:25:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45950 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236812AbhDCXZM (ORCPT ); Sat, 3 Apr 2021 19:25:12 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NOwFB041952; Sat, 3 Apr 2021 23:24:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=QjDqyc0OvUVrzoC/wGS7V5CgZzl6P9LaMdUEwhcilGw=; b=HZPodkEv3asV7paJLaUL0Fr1U86eSZqvFmOyqtYepHnldWf1s6xXJSudKcAup6RIKgrU BGmWAYvoO+o6CZ7iD9xYF1Y0aWTdD/+q/ogCxwb8tMkwOPuVejH/mcj2M9YiksDR4JFl cUO2ov2vzArNJMxEnfUDzja4ELLuaGUH1aJ2xlIrFxEDXloKD+SSf5/5TZdV30R0ArUI vxuqM0r6MEcMLbE4Q6IfGpPZBCYTe5coe5yw8CFjXlQOespAckVU8Q73xnIxo5bxvpFm tYHvhRxtcImCtDrxLtbpMmGw/zDNfDAizW4B+pq6TD40s5lxdGePRWparDNzwkj+DZ9N BA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37pfsrrsh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:58 +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 133NKtBT117020; Sat, 3 Apr 2021 23:24:58 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aoHkv2y1SsGrzpEqTFQxEuJHgNCcd4UEoLu1ol5QIFyzzrazOhD7mGZUEl3JMjoVB8gpsx+3D8BedrW3mHKqh4OulTk/T6kQdvjF7uZWZZJeEy0O05HeuWGKXyky3ByO3MAro2wu8tRfVsZqvy7ZI9x+Z9/HrXg4h4MRQevuXDN91MqLbEq2+09Eb4rtZA0l/2J0yRIGDx17N89EKdgmnpm0D2h8X7RwzwfUQdnBgW7OBQ9/Cnb+K65wF4wuoduKsq+YzIqPXXnGxU+z1BwV+okV1xS4M4IEb3tYu2AaXTBCrvqTZzhgwjdpAgUPq/ziE0Nn3NIQ08Hz67Mab/Aw3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QjDqyc0OvUVrzoC/wGS7V5CgZzl6P9LaMdUEwhcilGw=; b=gDIj8ajs97vjQMBonF9MEIO9LMXrtVPmvtwfkHtFqDgsWr4j8L8dv7pySF0c6ooe00A63khhIFgOAL1IMNLktlwZvSwv0O1mO01DD6KT9U4Jssv4svf+awqrsp/l3+ScUIscxqLHk3lvBIW6VDZJnznvo2HJiPGZhV2vY3DD0mcQC4JnSbws4vFETc61mHAvmjwPh1HnfNhR1nLd2j6qa/6hTXWsSXEQ7FRUz2qfMgF+POCdcIfLFANlKMzDowUR2QvVlaNI7yXm9KwMuZmfAfBh7rOaARLSROCxpPsHA1IuTjloW2jPaabxlzYhK61kkuFZZpeBWuMeY1VcxIzf2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QjDqyc0OvUVrzoC/wGS7V5CgZzl6P9LaMdUEwhcilGw=; b=pDWL/ubrWEjqpE5E+W66ShS2C7nGNtyJcJgB3ZcdIrOOZBxa7v3poXkG9dmElgj6Y83I193QYoLpjgHll4rwX0hvt4Zv69fBv2cl1pYl7Pm0Z82IP5Af/rXTtuvkUMqgN2qqH6+hrR4G3Wz6jAqf4DzOBxbzpfNRlh46uK0QIR0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:54 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:54 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 32/40] scsi: libiscsi: improve conn_send_pdu API Date: Sat, 3 Apr 2021 18:23:25 -0500 Message-Id: <20210403232333.212927-33-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78ba4e7a-5d18-4906-e449-08d8f6f79f6a X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UOYboiJK37hpc5WZbn07OOrkloL5PJf+09rlwIfUabcctzJ4ihLkcK50bH9KM5YklGuq9AQtsE7Ul/UDbHS08swfYDlMmLbDLwpcM1d78yxnx4CGFfsqA7R1/+gxr4j+vPvm0lwUWmApwum7lhJS4xIi3pr10HElefJgRU0kOTPYnO6ezFd7MXpsyFXhLb7acOJHA1w3SIISfnqPgBOncHKONrH81C3jfKzhPJdmblLEyZKmkXFvQ2MDwOKF+2gvu1EyTVO2nn1ATDqx4lVPZGDeImnHmc8dlUMDOU8hFMhg/4bpgAZjQIddPTaEGVKoZ9PiSiGE1Tm/hBA9PTwHld6hCAWCF+R0szWdQbW2VnekPO0yywuX4r2bBWinOZKzbMHVQuwtUTbixjiHTqquenNFqg9FUR4kxgi/Th+sZKw2OYb+rFvYz+P2la12wbe3tI1NDWlLoZx+544t8HahKZfpvFfP2btDCZ1WhiJeNhn5YWnjawt/q5ISefSv9uAvV7+94bv0Iz1hmhOpeCsGgZ1txQeEBmVT8/WU7O+gtNFKtmgqSql2KB1T+yTxESoofhawF2KXOklEhH1r+i2GBRXjf2uw2XgsWPodX+QMoyIf8EPQCHCRzZbUOxGpOCvOYMS+SJXOLTeBUWZs1WHT99lBy/VClejUZWOjlififIFdppFYMH2QUY+WMBhYj7/6ckBuWHdMm32mPuqQl6JKMg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GCkhLiRuzDJGBkStNKqYe6aZNZbScACdmWgM1eFwLhBPzgNJySwkyp6pQjdVk2UonBulxIQWtsdXRAum/GvnQqByCprEq3U4EOWwxeJIMUcpb1NgaNzZapf4viqdeKzH5zQHOu1i2R7DcQPkS8B1K9jVP6J/WW5QfiY1i6P/agFNj3M9AvJsY2hydcyvo3W1Yvvfy6RVU81e0OFcz+1Gcz2a2gKT74IMXJHXarzJqLnYn3cFnVQ/kkaevNDKZTjdU6/BNi19dfYYgC2p1DXu2wWA7O0JHjawfhNiYkqN3FSlEW5WRec53yiEFMg005Hj3IcNA/U3EA7xHR1BtCT5gK7LRy+bPT8+onA1ccxtQKYCEBiGD9PQdJtk+0/+0l2IWk6dzYxFy+zKibZuJGm4dIrnsTtEWq6kGj3F5AP4iojRK17CoXkM0V4W3fTZLBnGALUI8XRFV8FE5MkqedMRgnCH+OCmWVvAeozr/tWnlElSwlJ0qvmH4VYB3/TBSQAjfQH9Dn1JKPLKiydUVADBP2F9e+W5NlgU4xkMk/atlZdi27G0xtE736RX+vtSMOJEn0tJpuh8VI445dBI4PLNh4HFMEbML+Q+2K0CwMrHdSro/YAksUigDW3q84PhBjZ9XBdes9tzmuRECmaLWNQ5vtcqqTmmkw1FD4SbkNM2A70WUjM6oaH3bPmwVpQI1NXvCjacicfy4PHmnbM+yKM1AX8DPSaqc2qqhWK6Mv1El1KH38vr/Y5pZuI79hNEa5lP5QB5ha5jcpw6hY/j1J5u1ngDQx1p2QPoTHfH6UnaOtN75TRPqSns9Dw1hIYtXDCSNzEYv7P7bTo8YaLQJzQZOlIqxKfmZlW0kOVALw4WrikxmwiuMYuuMo04taztaJdW9hiq9tsgFZRwczm50C5hubP+1thgX0nssKoymGgvFVJy9lr9jWUr8Pu9BsSoBfWqDgiLBKMyPAbI2ZSI7dJqu7+yVlaqYL+FLi0WQoAhMM5oBOm4yKU9/xB1OL6eoy1sub1k6hLuaCnnH/EABcJNNJnq1k0IxkrrAyRtNr3RJsJBKEU3IkuIrI6kMHt8MLGiJVeIMqmcl61DiN8kONuBDbOo0tIgYbfJDQj14auWsnhi0vns73f9e6vi7lFxwKswTjyWP8ZUGtp3E5vIPHIlSDiX84b92nA6uvslL6DDLVNmW3pVINLaLc3ybYF8hIA1M4RAhuPVbMxSJFeH2RBwHF578S1Tl+1lo+S4LJB5qOeDUDLvA6PrGTzEKsCyCB5He4UidJUqmkjBi8nxzrNQsA6r9B5ge+nLPRfVZTP736xnpidBN4qBMhHYWubxI/nj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78ba4e7a-5d18-4906-e449-08d8f6f79f6a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:26.6651 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GDgHeifowTxICao6ImhP43zaNwJ/4EEzbBVP7QebRRRh9nfRZd1Kdgn+XGwWoR4AoBanIfx7I7Km48cNms3cRcduscgpg4NUmhY9R5gVsj4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: -ReBBC1kwAzgLY3fUCGpXT-5NxrtN87H X-Proofpoint-GUID: -ReBBC1kwAzgLY3fUCGpXT-5NxrtN87H X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The conn_send_pdu API is evil in that it returns a pointer to a iscsi_task, but that task might have been freed already so you can't touch it. This patch splits the task allocation and transmission, so functions like iscsi_send_nopout can access the task before its sent. We then can remove that INVALID_SCSI_TASK dance. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 68 +++++++++++++++++++++++++++++------------ include/scsi/libiscsi.h | 3 -- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index d4709e20b05c..33f8702faedd 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -671,11 +671,10 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, } static struct iscsi_task * -__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, +iscsi_alloc_mgmt_task(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *data, uint32_t data_size) { struct iscsi_session *session = conn->session; - struct iscsi_host *ihost = shost_priv(session->host); uint8_t opcode = hdr->opcode & ISCSI_OPCODE_MASK; struct iscsi_task *task; int sess_state = READ_ONCE(session->state); @@ -760,25 +759,50 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, task->conn->session->age); } - if (unlikely(READ_ONCE(conn->ping_task) == INVALID_SCSI_TASK)) - WRITE_ONCE(conn->ping_task, task); + return task; + +free_task: + iscsi_put_task(task); + return NULL; +} + +static int iscsi_send_mgmt_task(struct iscsi_task *task) +{ + struct iscsi_conn *conn = task->conn; + struct iscsi_session *session = conn->session; + struct iscsi_host *ihost = shost_priv(conn->session->host); + int rc = 0; if (!ihost->workq) { - if (iscsi_prep_mgmt_task(conn, task)) - goto free_task; + rc = iscsi_prep_mgmt_task(conn, task); + if (rc) + return rc; - if (session->tt->xmit_task(task)) - goto free_task; + rc = session->tt->xmit_task(task); + if (rc) + return rc; } else { list_add_tail(&task->running, &conn->mgmtqueue); iscsi_conn_queue_work(conn); } - return task; + return 0; +} -free_task: - iscsi_put_task(task); - return NULL; +static int __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, + char *data, uint32_t data_size) +{ + struct iscsi_task *task; + int rc; + + task = iscsi_alloc_mgmt_task(conn, hdr, data, data_size); + if (!task) + return -ENOMEM; + + rc = iscsi_send_mgmt_task(task); + if (rc) + iscsi_put_task(task); + return rc; } int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr, @@ -789,7 +813,7 @@ int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr, int err = 0; spin_lock_bh(&session->frwd_lock); - if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size)) + if (__iscsi_conn_send_pdu(conn, hdr, data, data_size)) err = -EPERM; spin_unlock_bh(&session->frwd_lock); return err; @@ -964,7 +988,6 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) if (!rhdr) { if (READ_ONCE(conn->ping_task)) return -EINVAL; - WRITE_ONCE(conn->ping_task, INVALID_SCSI_TASK); } memset(&hdr, 0, sizeof(struct iscsi_nopout)); @@ -978,10 +1001,18 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) } else hdr.ttt = RESERVED_ITT; - task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); - if (!task) { + task = iscsi_alloc_mgmt_task(conn, (struct iscsi_hdr *)&hdr, NULL, 0); + if (!task) + return -ENOMEM; + + if (!rhdr) + WRITE_ONCE(conn->ping_task, task); + + if (iscsi_send_mgmt_task(task)) { if (!rhdr) WRITE_ONCE(conn->ping_task, NULL); + iscsi_put_task(task); + iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); return -EIO; } else if (!rhdr) { @@ -1906,11 +1937,8 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, __must_hold(&session->frwd_lock) { struct iscsi_session *session = conn->session; - struct iscsi_task *task; - task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, - NULL, 0); - if (!task) { + if (__iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0)) { spin_unlock_bh(&session->frwd_lock); iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n"); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 8f623de1476b..6853b1dec0e3 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -153,9 +153,6 @@ struct iscsi_task { void *dd_data; /* driver/transport data */ }; -/* invalid scsi_task pointer */ -#define INVALID_SCSI_TASK (struct iscsi_task *)-1l - static inline int iscsi_task_has_unsol_data(struct iscsi_task *task) { return task->unsol_r2t.data_length > task->unsol_r2t.sent; From patchwork Sat Apr 3 23:23:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415228 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 5AAEDC433B4 for ; Sat, 3 Apr 2021 23:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FE4561360 for ; Sat, 3 Apr 2021 23:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236940AbhDCXZR (ORCPT ); Sat, 3 Apr 2021 19:25:17 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55230 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236949AbhDCXZN (ORCPT ); Sat, 3 Apr 2021 19:25:13 -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 133NOx4S088089; Sat, 3 Apr 2021 23:24:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=wYvshNF/mLhV9GmxZg+Sej7WB7NIEbBAqM/2I6rCus8=; b=uL6GOigt6GmtHN0MKrM+LnEFIh99m9l5XX7LyAmyH1Gj0Is9DPrHHMV4f0+ghb7OTRTc cvHykvDz8gvkGKoa7VOOv5XNLC6Opzi6svFkPU3oKdyNsGpW3vfRlvLwqnZPS4Di3b6J inw18SjQqDsc9OJ4hXln5oQxItGIcMQAJdyq8IMbVbbvN+1FnvC8EIY8akHfvs0x5/rU 6ONEisoip5p4qeNDerwrytMTbph78CncRNZOoFBZFJhz1q5UtS/T+83jI8+CgxQD4OhO sIflX2VRt2v3WFTAzIc5JFxXydhLtSyi/8XbXDHUbMu/DFIVjmoG/m9ZtLdmlEXAKE81 Qg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37pq66rcvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:59 +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 133NKtBU117020; Sat, 3 Apr 2021 23:24:59 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hK0XKoM7rGsIoVkqBkuAklJ0ALEf2lX0a2OWpBFXOj83jAx92Zx701fzJa1CLGmNvzmxBKV4nSDtol/HDlRk1sEdTuPnjmuh9KmrgNqLvFp17YIgVDBiZUhj+cgkYBIZ40vXw96iUP9qw5QkBdHfKGzbess6FgVx3a8OGPwnP4PqEP1oORPLXi2EdIoNu5TSX+Wq3JAsmnB1BNK2yRYFbr5NT4USnzGuS3bjav6r8WGHwsfV3RqxnopJI8cEqfzC4TDkYdaeHIRvLQjvr+j+Uk2MWlQJbyqWKLlRoYwxWOsznThrXREP2WLz/B+JECyxuxbswSOA2iFRewQa2DzEdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wYvshNF/mLhV9GmxZg+Sej7WB7NIEbBAqM/2I6rCus8=; b=NpziM2Pyptt3qogbbbYmdlfb/0/ZYRvECVpSagqcNYQAWHC+fMZVsMKOP3aVikgfJaTwN2hZbSCF7iiuw2kJ+WzQIyQgMEGOCAuyBowR+Nndp2ytJ6bYPikjKyS14+lrxEOK/6AFV0O8n4nzfbdR6LZ+lQu98LhJiOTHwjPjkKI4A4MAUlnNLuAv0OvdlU1yTdwdrkIQfSJFOli8lfxf7UVWm6nYSHS5kyfdQ9h0LQ+rwxy/MaAvIkSG4vqObXu+qJXrvrZSNLqnoJpwMjzwwoMzYs0r+35t1S+5JQ37ciE11LDU4Isz1QPBGe74PgVWmgj83rJmv1FDpqVKVabetw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wYvshNF/mLhV9GmxZg+Sej7WB7NIEbBAqM/2I6rCus8=; b=y6Rm5loSzk7i5+sWWqbHQzHqlIDzMSAZclRSxinsL9gfTWWT70hv69IJi7b0je+MR6mgtWlK66FeZOLdFsuv8qvhtXZKK2Wi8/CteG1C7B2EOksX4Vueztp2K5yB8FMryi5SCTP3DnCRaGaLPwkxv0vxGiWNoaMN6f7aPX4jPQ0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:55 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:55 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 33/40] scsi: libiscsi: add max/exp cmdsn lock Date: Sat, 3 Apr 2021 18:23:26 -0500 Message-Id: <20210403232333.212927-34-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e659933e-159c-411e-668b-08d8f6f7a02e X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qJQCPiIx1/I4gIHX98XfKvycuJ5xeIP4NZB9ElQK1owPxn9qyTgBJNaotbTb0+qJq13koU95KzVYG+E93b+nyFeUwMtquM+pO41duM0oZ7GIf+1KN6sqpTTAoNQDbRBebdOSsNEZ19cCfUaIKZpqkrNxjsA5HUCQdi3zYtmROhlU/0wvo+FtzaBJDraLqrlrDi+glstN5yFhZQFErJD7lb0hVwMXITU5hQPnVnFMEiYX1XNVoXQJhuSYvLqAjQDXsL8rPI2QBVnuoC9ZGJED69MqVvQtDWtMA/43KarBLen4DmMMRUMLvfKWSgBGKs8RMzfKWnqPO6DmpCSQaYK0gZfTgDJOSs1J2pJwuwTQD775WTD/vo1tU+cuIQa8kGf7Ssun8orXmAoM3MGYuyhu7kKWELiIGH0rOIpwnGf6XAE34WJwY8IIMpQfLpNykyaQMBhjC6RuYPTp09V11n4SlzfVwyI1vOJ2Hh/fhr0GUSpjYDaEF4EWi6IpCN6U3u2yO/zqkcvXpZ54tObWoGzMQi1uTe1wg5vciOz9y2v3aoXG6QnWIUUfZNk8BP6U4jhD8mSA7DT5fM3qUPF5drFIVgECFJjr2+8TxrfT1gXsJxOoXRk18dCczAjVdtUnJSRL+kRmfej/rmOLsxFYfq14SUNaEQ0xQViW8pVcodd3AzzZqd1TTvegB4KcK/MfosTqDq6vXJZKogpPwZLSTMyeyg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3Fr5bL+YYKOaBvv67LFvvOSYoJViwt1oyA/LY2DwZPP1krWiqoVf1Wf1tG1VLzoYgmFmASkQeVYEyzQUe6Bb8PVsg2yDDqvemcO1yNxm0qimST0PVr5qWpdWrVVqK4iF/13ieorh+9TYPtkKu0/dY4kN/3INW5b0nGqttXvRYn0dmci0ONNUZ1uLleo1Uh5mG5VrMFAFisZvO7Apr1Jhe5zp4oWFhxgH83X5KIZKLWUdfT6UnwCc6GZuCQFMTGEJZPpn1zPO7jQBGI/bPdtrbx8ZxpONKXpPssnNrROwvln9799AjbB5YNrPLrfpXwPztA1DkrLH9Sts3At3rIMeVcRVt1tPhe3PWnzbZ0fXaEfuDdtPXcWCf3q1MqfyyEsEPGwu1T+SzOfbAeG3EUba5+OKzkXod0OAv0V7EiYJ7e6ehgj+5sNb2ovMLDdygwMR2O6nY2/8eqscPMS3eCkWB6yHbpFqC26/XaJ6JzO1vhoGGMxtRGtyxXU4yIHzQFbBGxxZwtnWnnosJ5Bd+bxaOnCkA44oKrm9CA+KOPBHt93ssL3SeHod4HPFnGscrb+3F26ax8yYA9a2tU4eve2tYy4YdkQWB1y6TdaA0KVfYf1yiHvKnEC7UovNVitPFRN/VexkyLiKqYJk1xDd1ftz9/8kyookArOTentrV+Yo8a2WcLniYtDxEThQB0IVtisEsetv8wB2Z46mCnwfHP+tVxjdqPpL7rDncM1RbfVrc/nHF535MUgDwFvdteq6q5n47P/+j1WVGUpXycd/I76X407zgAizTv++QOcsCARuPfO2yhNnYw4vD6p42B5RqBZiZxlzKLuAEDShFx1gtDgd+qbgYy7zESayv5Z/xs2K1i6IjCuk1uvssT2/VJ+7euaLdjrTGJAaec1a88iiWtzFrRK2UddAHjhyGBoIxzXhV6xPev3sdENtGWPTlQrEyOTATKpWUekE1ICZDpGRX32MobVOEPpTEdaqgiFzmcnGrcK2agU5B4eqQ5E0nBAqvsR8YMM+FIyfxA4fofUNMEzAkBCqa4s7W/lZPJDyqn/PbiZ9ol0+/X0H69EtAS/cFT27MYMCs85ZtRG5nvz6XhO03myJpF+4JdyrTImLWkuj73Hmb0AvQuCYea6sT5BCpiBrb8BuFo2xBZJ8kLXFM07QXgloPnYmgxG6vo00W561p0Iw3D8OBOeCTGp+bfcqxzz1O6niw4fkaG0mrb2+OjsdMKgJeSjSjUhHeV+jROKfFqq0AgnPWY0OMfLnTXFiYSuT7QmgGzG/GG7LkN3CV6U35PrN/BcohvPNrjgy8Gm3IIDpqf7yI86x3q4osHsj/Vhw X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e659933e-159c-411e-668b-08d8f6f7a02e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:27.9354 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LdJvHdMvijSl01J2yLtN8UX1u+WSZbYRni+F2Ef9Tq64oKucTNVm7mAb9QiTVYjxA7AeP44KiEExanP0MTMrSKcuKr1lbD4n94e0+nReCMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: r23y9ayJwIFGIA51G1uTd3I1DroRGq5V X-Proofpoint-GUID: r23y9ayJwIFGIA51G1uTd3I1DroRGq5V X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch adds a lock for the max/exp_cmdsn handling. The next patch will then cleanup the back_lock uses. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 7 +++++-- drivers/scsi/libiscsi_tcp.c | 2 -- include/scsi/libiscsi.h | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 33f8702faedd..dbff0ed10e1f 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -103,6 +103,7 @@ static void __iscsi_update_cmdsn(struct iscsi_session *session, if (iscsi_sna_lt(max_cmdsn, exp_cmdsn - 1)) return; + spin_lock_bh(&session->back_cmdsn_lock); if (exp_cmdsn != session->exp_cmdsn && !iscsi_sna_lt(exp_cmdsn, session->exp_cmdsn)) session->exp_cmdsn = exp_cmdsn; @@ -110,6 +111,7 @@ static void __iscsi_update_cmdsn(struct iscsi_session *session, if (max_cmdsn != session->max_cmdsn && !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) session->max_cmdsn = max_cmdsn; + spin_unlock_bh(&session->back_cmdsn_lock); } void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) @@ -3067,6 +3069,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, spin_lock_init(&session->mgmt_lock); spin_lock_init(&session->frwd_lock); spin_lock_init(&session->back_lock); + spin_lock_init(&session->back_cmdsn_lock); /* initialize mgmt task pool */ if (iscsi_pool_init(&session->mgmt_pool, ISCSI_MGMT_CMDS_MAX, @@ -3470,9 +3473,9 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session, * The target could have reduced it's window size between logins, so * we have to reset max/exp cmdsn so we can see the new values. */ - spin_lock_bh(&session->back_lock); + spin_lock_bh(&session->back_cmdsn_lock); session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1; - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&session->back_cmdsn_lock); /* * Unblock xmitworker(), Login Phase will pass through. */ diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index b1399ff5ca9e..92e84a19b100 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -559,9 +559,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) tcp_conn = conn->dd_data; rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr; /* fill-in new R2T associated with the task */ - spin_lock(&session->back_lock); iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr); - spin_unlock(&session->back_lock); if (tcp_conn->in.datalen) { iscsi_conn_printk(KERN_ERR, conn, diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 6853b1dec0e3..3715b3d20890 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -296,10 +296,12 @@ struct iscsi_session { struct mutex eh_mutex; /* iSCSI session-wide sequencing */ - uint32_t cmdsn; + /* Protects exp and max cmdsn */ + spinlock_t back_cmdsn_lock; uint32_t exp_cmdsn; uint32_t max_cmdsn; + uint32_t cmdsn; /* This tracks the reqs queued into the initiator */ uint32_t queued_cmdsn; @@ -356,8 +358,7 @@ struct iscsi_session { * cmdsn, suspend_bit, * * leadconn, _stage, * * tmf_state and queues */ - spinlock_t back_lock; /* protects cmdsn_exp and * - * cmdsn_max */ + spinlock_t back_lock; /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. From patchwork Sat Apr 3 23:23:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415226 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 253DCC43461 for ; Sat, 3 Apr 2021 23:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2DE461360 for ; Sat, 3 Apr 2021 23:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236990AbhDCXZU (ORCPT ); Sat, 3 Apr 2021 19:25:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:50186 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236957AbhDCXZO (ORCPT ); Sat, 3 Apr 2021 19:25:14 -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 133NKOUe160347; Sat, 3 Apr 2021 23:25:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=4wm0Vlg1ct/yjlqnFEJVhyWa56Z8Wh82N99S84JVnb8=; b=L1p78LrcUCslqztZyx/wE8s9S6V8ehCEaUeg323Cu5ojSYMaLR2nXWEJo0DhB7mwLVV9 aM/Jx6JfgPAXZSLyeF1iIm8XUlhWP/IcTWDBsw/xJP3sALyoJ+3sIw60YrE5p+KFgkRu sF0qG75URrVenQ943hcgPsGdQTvAQQD6g1tAOFidywNfshv2EKqI0/AEp3oTg0FYErdy djPsdnECY/Qmq0JLDgDgtzbrjC8P+gVXi2JQSsxbbxaPexLsr9FAEQEcnQ8EgBMbz442 c9aleMeV5Tz5Mmhm/zSgCjexYPhmp10Q5I8g2a02ukOGELnevVbDfeGPebcx1FWcvv6J 2A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:01 +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 133NKtBW117020; Sat, 3 Apr 2021 23:25:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FIorZtmZkERKD7ELi1TSUJzhuHCTPARdQ6/Szx8+jE0AkJXOdViAXdu5BbT8SYSx1MQ2P50vhSHqUPb1XDItDeCtO5Kl65Tw6vJCKfolUdiSnOrSAG9ybdRQFAI050y9kyRuMmthXQOwnPpmUSDzVEKrkSPiFzZsDzaQVgYmc8s2byOvCcYlfhcXM5uCPoA71Q6kwPuJ4qUct3AJ7xc7hQ8zF0HWJfVflHiBsQ5Q02pINkCg31mOaunzhhUXf5Bctfww+zvuaCu90ANnMQRp5R62LahGjlrAORf+PrBtvG87i3YllX445NUCeSZFkdIP7ZJwPOatd5R64FScH2JNvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wm0Vlg1ct/yjlqnFEJVhyWa56Z8Wh82N99S84JVnb8=; b=Jm0CBBtKXBs18hqwAF6rn1ZH1mfvCt0KeUqGCkrbg/+pGaHlZVolH2n3ZdWXKbfuP3mZejLtLgeedqFJydB9pM6FAXwYQySpzclwh2+5COafT7nnOTh4ujOhwN3NOWma9uBqy3Haa2pGtgOWIt8kjBd5dN9ZMfh9ms2Cy34z0UYrDpsOYDzHu9Y5Xc46kVv6tBe9bQvg8+uZ6LYoGXTK9ExczuCjoLRW27+i4I+lzHbzN26uHz6np2PJfx31JlOkvV2Hiu8QkIWnKGx8NgGG5q7tXFm4nzk543i+4qlFVOqVOtOUmNvlVKQfNzzhZNLBlNWdXtJNkRL7RujL/5fX3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wm0Vlg1ct/yjlqnFEJVhyWa56Z8Wh82N99S84JVnb8=; b=hPn/+9LDtQ5bmIKEXm/uj+fXDagJvGRT+doXiTP4jI++XVQQgPUrk08sLjqeoWK3HNyCfDtXB9R9viGIV6GrlfsPeFgwJBQMb2AhGXm9w9YhKid27U/rLw0rH7YOb/AfsVZ8QPxjEb9aDghHCExSJOF+W0kydTHC1U91oQCH1HE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:55 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:55 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 34/40] scsi: iscsi: remove back_lock Date: Sat, 3 Apr 2021 18:23:27 -0500 Message-Id: <20210403232333.212927-35-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76058b42-a010-42b4-eca7-08d8f6f7a0f8 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VHWzbFO09RDVTeSHS8u9ZC9q2hjl1Q+Bjo+Y/1Cfk0WS7BVQUcQXf4CEdoU3Ee/z+sTdgEbOf6VloXuP+rr2WE0KqRSKPAlisB0ZOxm+DwMOUPYXQE52wn6PsHt7dtethS8DeOhv2emEgcWAuQgamzMMzrb39/YYTGWGhn+QcyZTuVnd8F4/0DM4kLC1+4Nm4eOUyilIAVvoPQDSlyMFXdvKfLAEtgEcWOOYZjOCZ+nAQUQDiOebATjL4EHTnHPYiQjrcKjV6tRWWvTxNIJ0eBtxGDHg8ZT3NzAmsRlEg9zdAPV4MrqF05obfka/N9jaYCko0HVbeSxqLUonwwzRfEUSVjgSjbT4yiet9n3ZzR86bR82exkoGtplxXze1gZnDNN5VyRvqqUAWhC5XF4m2l6f5y+DIoco2NiTQRDtckkog3lsv7Tmrp5pq1pc0o+Koj0SzRrb2A8wChD2w9VRPlu9iyPhMfdTATPQjlrgnlLKXgdc7hzykDGR1z7Brt8gI9aI6YPgt3nI9veOm0bgEG3KomyJdVL4DlIfCu6JNclQjre5+j99fx81jw3nP1j174Ke4JTQ+eroUDeWOEVoHHnJ1+KQos5z0WqkDJETTQPW4VStXXx0y37qqa2Uxpr/FMa7y+Znn8rFU6mxuOmmvnvt12Cifu5vOGWwBeEOhN1FPJKfSSHFoUIezXpPd45jG/3Ope8z25NxpufJLRKQyQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(30864003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jTzXwMbOR09XATqkwFeWpV8AO/RrKKPvklk+S8s6joAu4I1dlGSfECW4/NI09nzjyqUNjXjdfR1SBYAqjo+sH4CKsnigEIrEILxPsJ0TcpO/OJScuYR2zVKYgXGmBNElCAsj7x4HjYtc+z9fnSZR3ECb67tYXNcuDkE2cY/z8cM6ctj1bozp5hCCobjCaCE0YFdnZJ4sh5AbW9GH2lITi1XiRqLwYrr99AGnvALj0pab96ieKfysV0vgL0wD3QRwqqNueR/DOHqOr2VCjvL+Otbd13a6k+DbgdMIwOmJTGpw3C9myo5uDHzGf4JFPoUgNDnjGEVTAJK9ulY4Ds7LIaSiAS1DF0hJYzX6MutJ4EZFMAFvaMEK/1wxbJGEGaA3te0Ktj+L6Gax2+IoEyUX2PB+NZxsRwO37GN63xiGBT8a8T73KZMzi5uXPy4MlSBZ+pkouIA2kydslFAQnIm6/uV9A68JajicWmeKdIu6OAUTLwp/Y7GuJM2AW/nkO+hyMV1McGzBV8H5jp7hmGXHkNwLDbNnMPsK7uBGUz0FZjB8/+CliR6U/WSFy8qxE6ew0XIJuJ9j9oOtXEeNyQof2+yU3xnsJDOusdxkzTKRUincOCKq5y95XTuOYrPrv8I6jxMP/CcoOeHMClhEFT9UQbfdHGIc+GNd5Nt8t/tYtYyBj68a//gI8B11RE8a9W5bqIjOL0x9Q32lIXFB9wQb4TcM2lHMhePKK1RdkgJjwCgzhagP8EM7MmEztpRbQl0jp+28+9YCA+m1XEc5c5t2nGdgNhKAkDIt6eDmmIe/pixoRwiv0HAzn8qcUCcobMgm/NPqE4hgsRjXb0IeofwNSrKn93U6//+HBPfFa08ompWG4NE9xN9wS1ObNEPicznf9kYLEgYDGOMvdm2FMnqUgmOayzLESc/vPEdZAYRJQnYAUPwN9faTFGvbB6DcHDHX/PM7MrNYngSgHcFNjASfJItcagA1wZ0fy85AFwpopwRwyH5+jiZn3oFbdgfswhPgIAY2D/MS4BX5icBgz8I+hm2zFeLFEa/MHh9fGIzIj517qIua0IQAYhRaY8oA40fD0O4MKyZfK8I9ql5Vw+VHezIS266l2tFnzoCVLwqmI1BZVFUEDn739a5DyvU6gQl7wyn2iJ2CAw7U3neEC/ISQS2907mVjjJX7FLGevbGuPsTfDzWJbjNBG8YKMaCHEwlskYqKFiN9JK/k/i5+SWcksbovL4tZFzMu2P3ghgq4yfdKCJuXgN/fB/VBxD3fSJuoijUbJ3aU9yURh5/Tdn7WxBVQgT2GUEZ7N/vMBj36+PDS854KCFLYP0v5OZOAWPF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76058b42-a010-42b4-eca7-08d8f6f7a0f8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:29.2607 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IwJzjg/o1Qrp+r4iqORgErBy6IXBkIYZP8DkNnucuh6g85CQHSrLaNgm0bNuHvtiQS+1z9hgXqhVJbqzYOms3+28Ba7OTxZgC+uuKz+52iU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: G7WippQAM1XaoTMbobOhOk1WhL_RW026 X-Proofpoint-GUID: G7WippQAM1XaoTMbobOhOk1WhL_RW026 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The back_lock is no longer used so remove it. Signed-off-by: Mike Christie --- drivers/scsi/be2iscsi/be_main.c | 11 ---- drivers/scsi/bnx2i/bnx2i_hwi.c | 46 ++++--------- drivers/scsi/libiscsi.c | 41 +++--------- drivers/scsi/qedi/qedi_fw.c | 112 ++++++++++---------------------- include/scsi/libiscsi.h | 6 -- 5 files changed, 58 insertions(+), 158 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 9f1f8b95a2f7..e8e01b83965d 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -1339,8 +1339,6 @@ static void adapter_get_sol_cqe(struct beiscsi_hba *phba, static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct sol_cqe *psol) { - struct iscsi_conn *conn = beiscsi_conn->conn; - struct iscsi_session *session = conn->session; struct common_sol_cqe csol_cqe = {0}; struct hwi_wrb_context *pwrb_context; struct hwi_controller *phwi_ctrlr; @@ -1376,9 +1374,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, if (!task) return; - spin_lock_bh(&session->back_lock); type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; - switch (type) { case HWH_TYPE_IO: case HWH_TYPE_IO_RD: @@ -1417,7 +1413,6 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, break; } - spin_unlock_bh(&session->back_lock); iscsi_put_task(task); } @@ -1610,7 +1605,6 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn, struct hd_async_context *pasync_ctx, u16 cri) { - struct iscsi_session *session = beiscsi_conn->conn->session; struct hd_async_handle *pasync_handle, *plast_handle; struct beiscsi_hba *phba = beiscsi_conn->phba; void *phdr = NULL, *pdata = NULL; @@ -1651,9 +1645,7 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn, pasync_ctx->async_entry[cri].wq.bytes_needed, pasync_ctx->async_entry[cri].wq.bytes_received); } - spin_lock_bh(&session->back_lock); status = beiscsi_complete_pdu(beiscsi_conn, phdr, pdata, dlen); - spin_unlock_bh(&session->back_lock); beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); return status; } @@ -4325,7 +4317,6 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, struct hwi_wrb_context *pwrb_context = NULL; struct beiscsi_hba *phba = beiscsi_conn->phba; struct iscsi_task *task = beiscsi_conn->task; - struct iscsi_session *session = task->conn->session; u32 doorbell = 0; /* @@ -4333,9 +4324,7 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, * login/startup related tasks. */ beiscsi_conn->login_in_progress = 0; - spin_lock_bh(&session->back_lock); beiscsi_cleanup_task(task); - spin_unlock_bh(&session->back_lock); pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid, &pwrb_context); diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index af03ad7bc941..f41f9f5fe6cc 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -1415,10 +1415,8 @@ int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session, } done: - spin_lock_bh(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, - conn->data, datalen); - spin_unlock_bh(&session->back_lock); + iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, + conn->data, datalen); iscsi_put_task(task); fail: return 0; @@ -1483,11 +1481,9 @@ static int bnx2i_process_login_resp(struct iscsi_session *session, } } - spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, + iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, bnx2i_conn->gen_pdu.resp_buf, bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); - spin_unlock(&session->back_lock); iscsi_put_task(task); done: return 0; @@ -1544,12 +1540,10 @@ static int bnx2i_process_text_resp(struct iscsi_session *session, bnx2i_conn->gen_pdu.resp_wr_ptr++; } } - spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, - bnx2i_conn->gen_pdu.resp_buf, - bnx2i_conn->gen_pdu.resp_wr_ptr - - bnx2i_conn->gen_pdu.resp_buf); - spin_unlock(&session->back_lock); + iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, + bnx2i_conn->gen_pdu.resp_buf, + bnx2i_conn->gen_pdu.resp_wr_ptr - + bnx2i_conn->gen_pdu.resp_buf); iscsi_put_task(task); done: return 0; @@ -1587,9 +1581,7 @@ static int bnx2i_process_tmf_resp(struct iscsi_session *session, resp_hdr->itt = task->hdr->itt; resp_hdr->response = tmf_cqe->response; - spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); - spin_unlock(&session->back_lock); + iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); iscsi_put_task(task); done: return 0; @@ -1633,10 +1625,7 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session, resp_hdr->t2wait = cpu_to_be32(logout->time_to_wait); resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain); - spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); - spin_unlock(&session->back_lock); - + iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); iscsi_put_task(task); bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD; @@ -1727,10 +1716,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session, memcpy(&hdr->lun, nop_in->lun, 8); } done: - spin_lock(&session->back_lock); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); - spin_unlock(&session->back_lock); - + iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); if (task) iscsi_put_task(task); @@ -1765,7 +1751,6 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session, return; } - spin_lock(&session->back_lock); resp_hdr = (struct iscsi_async *) &bnx2i_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = async_cqe->op_code; @@ -1782,9 +1767,8 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session, resp_hdr->param2 = cpu_to_be16(async_cqe->param2); resp_hdr->param3 = cpu_to_be16(async_cqe->param3); - __iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data, - (struct iscsi_hdr *)resp_hdr, NULL, 0); - spin_unlock(&session->back_lock); + iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data, + (struct iscsi_hdr *)resp_hdr, NULL, 0); } @@ -1811,7 +1795,6 @@ static void bnx2i_process_reject_mesg(struct iscsi_session *session, } else bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); - spin_lock(&session->back_lock); hdr = (struct iscsi_reject *) &bnx2i_conn->gen_pdu.resp_hdr; memset(hdr, 0, sizeof(struct iscsi_hdr)); hdr->opcode = reject->op_code; @@ -1820,9 +1803,8 @@ static void bnx2i_process_reject_mesg(struct iscsi_session *session, hdr->max_cmdsn = cpu_to_be32(reject->max_cmd_sn); hdr->exp_cmdsn = cpu_to_be32(reject->exp_cmd_sn); hdr->ffffffff = cpu_to_be32(RESERVED_ITT); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, - reject->data_length); - spin_unlock(&session->back_lock); + iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, + reject->data_length); } /** diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index dbff0ed10e1f..e7d1b69c07b5 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -538,8 +538,6 @@ static void iscsi_finish_task(struct iscsi_task *task, int state) * * This is used when drivers do not need or cannot perform * lower level pdu processing. - * - * Called with session back_lock */ void iscsi_complete_scsi_task(struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn) @@ -831,7 +829,7 @@ EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu); * @datalen: len of buffer * * iscsi_cmd_rsp sets up the scsi_cmnd fields based on the PDU and - * then completes the command and task. called under back_lock + * then completes the command and task. **/ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, struct iscsi_task *task, char *data, @@ -929,7 +927,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, * @task: scsi command task * * iscsi_data_in_rsp sets up the scsi_cmnd fields based on the data received - * then completes the command and task. called under back_lock + * then completes the command and task. **/ static void iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, @@ -1033,7 +1031,7 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) * @datalen: length of data * * iscsi_nop_out_rsp handles nop response from use or - * from user space. called under back_lock + * from user space. **/ static int iscsi_nop_out_rsp(struct iscsi_task *task, struct iscsi_nopin *nop, char *data, int datalen) @@ -1103,13 +1101,10 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr, * nop-out in response to target's nop-out rejected. * Just resend. */ - /* In RX path we are under back lock */ - spin_unlock(&conn->session->back_lock); - spin_lock(&conn->session->frwd_lock); + spin_lock_bh(&conn->session->frwd_lock); iscsi_send_nopout(conn, (struct iscsi_nopin*)&rejected_pdu); - spin_unlock(&conn->session->frwd_lock); - spin_lock(&conn->session->back_lock); + spin_unlock_bh(&conn->session->frwd_lock); } else { struct iscsi_task *task; /* @@ -1184,17 +1179,16 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) EXPORT_SYMBOL_GPL(iscsi_itt_to_task); /** - * __iscsi_complete_pdu - complete pdu + * iscsi_complete_pdu - complete pdu * @conn: iscsi conn * @hdr: iscsi header * @data: data buffer * @datalen: len of data buffer * * Completes pdu processing by freeing any resources allocated at - * queuecommand or send generic. session back_lock must be held and verify - * itt must have been called. + * queuecommand or send generic. */ -int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, +int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, char *data, int datalen) { int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; @@ -1238,7 +1232,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, iscsi_put_task(task); return rc; } -EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); +EXPORT_SYMBOL_GPL(iscsi_complete_pdu); /** * iscsi_complete_task - complete iscsi task @@ -1254,8 +1248,6 @@ EXPORT_SYMBOL_GPL(__iscsi_complete_pdu); * This function should be used by drivers that do not use the libiscsi * itt for the PDU that was sent to the target and has access to the * iscsi_task struct directly. - * - * Session back_lock must be held. */ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, struct iscsi_hdr *hdr, char *data, int datalen) @@ -1280,11 +1272,9 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, break; /* In RX path we are under back lock */ - spin_unlock(&session->back_lock); spin_lock(&session->frwd_lock); iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr); spin_unlock(&session->frwd_lock); - spin_lock(&session->back_lock); break; case ISCSI_OP_REJECT: rc = iscsi_handle_reject(conn, hdr, data, datalen); @@ -1365,18 +1355,6 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, } EXPORT_SYMBOL_GPL(iscsi_complete_task); -int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, - char *data, int datalen) -{ - int rc; - - spin_lock(&conn->session->back_lock); - rc = __iscsi_complete_pdu(conn, hdr, data, datalen); - spin_unlock(&conn->session->back_lock); - return rc; -} -EXPORT_SYMBOL_GPL(iscsi_complete_pdu); - int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) { struct iscsi_session *session = conn->session; @@ -3068,7 +3046,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, mutex_init(&session->eh_mutex); spin_lock_init(&session->mgmt_lock); spin_lock_init(&session->frwd_lock); - spin_lock_init(&session->back_lock); spin_lock_init(&session->back_cmdsn_lock); /* initialize mgmt task pool */ diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 53099d560eed..7b66b573882f 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -31,13 +31,11 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; struct iscsi_logout_rsp *resp_hdr; - struct iscsi_session *session = conn->session; struct iscsi_logout_response_hdr *cqe_logout_response; struct qedi_cmd *cmd; cmd = (struct qedi_cmd *)task->dd_data; cqe_logout_response = &cqe->cqe_common.iscsi_hdr.logout_response; - spin_lock(&session->back_lock); resp_hdr = (struct iscsi_logout_rsp *)&qedi_conn->gen_pdu.resp_hdr; memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); resp_hdr->opcode = cqe_logout_response->opcode; @@ -55,7 +53,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -66,13 +64,11 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); iscsi_complete_task(conn, task, (struct iscsi_hdr *)resp_hdr, NULL, 0); - - spin_unlock(&session->back_lock); } static void qedi_process_text_resp(struct qedi_ctx *qedi, @@ -81,7 +77,6 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn) { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct e4_iscsi_task_context *task_ctx; struct iscsi_text_rsp *resp_hdr_ptr; struct iscsi_text_response_hdr *cqe_text_response; @@ -92,7 +87,6 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, task_ctx = qedi_get_task_mem(&qedi->tasks, cmd->task_id); cqe_text_response = &cqe->cqe_common.iscsi_hdr.text_response; - spin_lock(&session->back_lock); resp_hdr_ptr = (struct iscsi_text_rsp *)&qedi_conn->gen_pdu.resp_hdr; memset(resp_hdr_ptr, 0, sizeof(struct iscsi_hdr)); resp_hdr_ptr->opcode = cqe_text_response->opcode; @@ -118,7 +112,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -129,7 +123,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); @@ -138,7 +132,6 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, qedi_conn->gen_pdu.resp_buf, (qedi_conn->gen_pdu.resp_wr_ptr - qedi_conn->gen_pdu.resp_buf)); - spin_unlock(&session->back_lock); } static void qedi_tmf_resp_work(struct work_struct *work) @@ -166,11 +159,8 @@ static void qedi_tmf_resp_work(struct work_struct *work) iscsi_unblock_session(session->cls_session); qedi_clear_task_idx(qedi, qedi_cmd->task_id); - spin_lock(&session->back_lock); iscsi_complete_task(conn, qedi_cmd->task, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); - spin_unlock(&session->back_lock); - exit_tmf_resp: kfree(resp_hdr_ptr); clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); @@ -183,7 +173,6 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct iscsi_tmf_response_hdr *cqe_tmp_response; struct iscsi_tm_rsp *resp_hdr_ptr; struct iscsi_tm *tmf_hdr; @@ -200,7 +189,6 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, return; } - spin_lock(&session->back_lock); resp_hdr_ptr = (struct iscsi_tm_rsp *)qedi_cmd->tmf_resp_buf; memset(resp_hdr_ptr, 0, sizeof(struct iscsi_tm_rsp)); @@ -219,13 +207,13 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, tmf_hdr = (struct iscsi_tm *)qedi_cmd->task->hdr; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(qedi_cmd->io_cmd_in_list)) { qedi_cmd->io_cmd_in_list = false; list_del_init(&qedi_cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || @@ -235,7 +223,7 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, ISCSI_TM_FUNC_TARGET_COLD_RESET)) { INIT_WORK(&qedi_cmd->tmf_work, qedi_tmf_resp_work); queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work); - goto unblock_sess; + return; } qedi_clear_task_idx(qedi, qedi_cmd->task_id); @@ -243,9 +231,6 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, iscsi_complete_task(conn, qedi_cmd->task, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); kfree(resp_hdr_ptr); - -unblock_sess: - spin_unlock(&session->back_lock); } static void qedi_process_login_resp(struct qedi_ctx *qedi, @@ -254,7 +239,6 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn) { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct e4_iscsi_task_context *task_ctx; struct iscsi_login_rsp *resp_hdr_ptr; struct iscsi_login_response_hdr *cqe_login_response; @@ -266,7 +250,6 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, cqe_login_response = &cqe->cqe_common.iscsi_hdr.login_response; task_ctx = qedi_get_task_mem(&qedi->tasks, cmd->task_id); - spin_lock(&session->back_lock); resp_hdr_ptr = (struct iscsi_login_rsp *)&qedi_conn->gen_pdu.resp_hdr; memset(resp_hdr_ptr, 0, sizeof(struct iscsi_login_rsp)); resp_hdr_ptr->opcode = cqe_login_response->opcode; @@ -286,13 +269,13 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK; qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); memset(task_ctx, '\0', sizeof(*task_ctx)); @@ -301,7 +284,6 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, (qedi_conn->gen_pdu.resp_wr_ptr - qedi_conn->gen_pdu.resp_buf)); - spin_unlock(&session->back_lock); QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_TID, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); @@ -404,7 +386,6 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, u16 que_idx) { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct iscsi_nop_in_hdr *cqe_nop_in; struct iscsi_nopin *hdr; struct qedi_cmd *cmd; @@ -414,7 +395,6 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, char bdq_data[QEDI_BDQ_BUF_SIZE]; unsigned long flags; - spin_lock_bh(&session->back_lock); cqe_nop_in = &cqe->cqe_common.iscsi_hdr.nop_in; pdu_len = cqe_nop_in->hdr_second_dword & @@ -450,22 +430,20 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); cmd->state = RESPONSE_RECEIVED; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_clear_task_idx(qedi, cmd->task_id); } done: iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, bdq_data, pdu_len); - - spin_unlock_bh(&session->back_lock); return tgt_async_nop; } @@ -475,7 +453,6 @@ static void qedi_process_async_mesg(struct qedi_ctx *qedi, u16 que_idx) { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct iscsi_async_msg_hdr *cqe_async_msg; struct iscsi_async *resp_hdr; u32 lun[2]; @@ -483,8 +460,6 @@ static void qedi_process_async_mesg(struct qedi_ctx *qedi, char bdq_data[QEDI_BDQ_BUF_SIZE]; unsigned long flags; - spin_lock_bh(&session->back_lock); - cqe_async_msg = &cqe->cqe_common.iscsi_hdr.async_msg; pdu_len = cqe_async_msg->hdr_second_dword & ISCSI_ASYNC_MSG_HDR_DATA_SEG_LEN_MASK; @@ -518,8 +493,6 @@ static void qedi_process_async_mesg(struct qedi_ctx *qedi, iscsi_complete_task(conn, NULL, (struct iscsi_hdr *)resp_hdr, bdq_data, pdu_len); - - spin_unlock_bh(&session->back_lock); } static void qedi_process_reject_mesg(struct qedi_ctx *qedi, @@ -528,13 +501,11 @@ static void qedi_process_reject_mesg(struct qedi_ctx *qedi, uint16_t que_idx) { struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; struct iscsi_reject_hdr *cqe_reject; struct iscsi_reject *hdr; u32 pld_len, num_bdqs; unsigned long flags; - spin_lock_bh(&session->back_lock); cqe_reject = &cqe->cqe_common.iscsi_hdr.reject; pld_len = cqe_reject->hdr_second_dword & ISCSI_REJECT_HDR_DATA_SEG_LEN_MASK; @@ -560,7 +531,6 @@ static void qedi_process_reject_mesg(struct qedi_ctx *qedi, iscsi_complete_task(conn, NULL, (struct iscsi_hdr *)hdr, conn->data, pld_len); - spin_unlock_bh(&session->back_lock); } static void qedi_scsi_completion(struct qedi_ctx *qedi, @@ -570,7 +540,6 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, { struct scsi_cmnd *sc_cmd; struct qedi_cmd *cmd = task->dd_data; - struct iscsi_session *session = conn->session; struct iscsi_scsi_rsp *hdr; struct iscsi_data_in_hdr *cqe_data_in; int datalen = 0; @@ -585,33 +554,32 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, cqe_err_bits = cqe->cqe_common.error_bitmap.error_bits.cqe_error_status_bits; - spin_lock_bh(&session->back_lock); /* get the scsi command */ sc_cmd = cmd->scsi_cmd; if (!sc_cmd) { QEDI_WARN(&qedi->dbg_ctx, "sc_cmd is NULL!\n"); - goto error; + return; } if (!task->sc) { QEDI_WARN(&qedi->dbg_ctx, "SCp.ptr is NULL, returned in another context.\n"); - goto error; + return; } if (!sc_cmd->request) { QEDI_WARN(&qedi->dbg_ctx, "sc_cmd->request is NULL, sc_cmd=%p.\n", sc_cmd); - goto error; + return; } if (!sc_cmd->request->q) { QEDI_WARN(&qedi->dbg_ctx, "request->q is NULL so request is not valid, sc_cmd=%p.\n", sc_cmd); - goto error; + return; } qedi_iscsi_unmap_sg_list(cmd); @@ -646,13 +614,13 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, hdr->flags &= (~ISCSI_FLAG_CMD_OVERFLOW); } - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_TID, "Freeing tid=0x%x for cid=0x%x\n", @@ -664,8 +632,6 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, qedi_clear_task_idx(qedi, cmd->task_id); iscsi_complete_task(conn, task, (struct iscsi_hdr *)hdr, conn->data, datalen); -error: - spin_unlock_bh(&session->back_lock); } static void qedi_mtask_completion(struct qedi_ctx *qedi, @@ -783,13 +749,13 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, qedi_clear_task_idx(qedi_conn->qedi, rtid); - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(dbg_cmd->io_cmd_in_list)) { dbg_cmd->io_cmd_in_list = false; list_del_init(&dbg_cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_cmd->state = CLEANUP_RECV; wake_up_interruptible(&qedi_conn->wait_queue); } else if (qedi_conn->cmd_cleanup_req > 0) { @@ -1070,11 +1036,11 @@ int qedi_send_iscsi_login(struct qedi_conn *qedi_conn, if (rval) return -1; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); qedi_cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_ring_doorbell(qedi_conn); return 0; @@ -1143,11 +1109,11 @@ int qedi_send_iscsi_logout(struct qedi_conn *qedi_conn, if (rval) return -1; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); qedi_cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_ring_doorbell(qedi_conn); return 0; @@ -1162,8 +1128,6 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, struct iscsi_tm *tmf_hdr; unsigned int lun = 0; bool lun_reset = false; - struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_session *session = conn->session; /* From recovery, task is NULL or from tmf resp valid task */ if (task) { @@ -1184,10 +1148,7 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, qedi_conn->active_cmd_count, qedi_conn->iscsi_conn_id, in_recovery, lun_reset); - if (lun_reset) - spin_lock_bh(&session->back_lock); - - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_for_each_entry_safe(cmd, cmd_tmp, &qedi_conn->active_cmd_list, io_cmd) { @@ -1218,10 +1179,7 @@ int qedi_cleanup_all_io(struct qedi_ctx *qedi, struct qedi_conn *qedi_conn, &cmd->io_cmd, qedi_conn->iscsi_conn_id); } - spin_unlock(&qedi_conn->list_lock); - - if (lun_reset) - spin_unlock_bh(&session->back_lock); + spin_unlock_bh(&qedi_conn->list_lock); QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, "cmd_cleanup_req=%d, cid=0x%x\n", @@ -1392,13 +1350,13 @@ int qedi_fw_cleanup_cmd(struct iscsi_task *ctask) } spin_unlock_bh(&qedi_conn->tmf_work_lock); - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); return -1; } @@ -1500,11 +1458,11 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) if (rval) return -1; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); qedi_cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_ring_doorbell(qedi_conn); return 0; @@ -1599,11 +1557,11 @@ int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, if (rval) return -1; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); qedi_cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_ring_doorbell(qedi_conn); return 0; @@ -1669,11 +1627,11 @@ int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, nop_out_pdu_header.itt = tid; nop_out_pdu_header.ttt = ISCSI_TTT_ALL_ONES; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); qedi_cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); } /* Fill tx AHS and rx buffer */ @@ -2093,11 +2051,11 @@ int qedi_iscsi_send_ioreq(struct iscsi_task *task) if (rval) return -1; - spin_lock(&qedi_conn->list_lock); + spin_lock_bh(&qedi_conn->list_lock); list_add_tail(&cmd->io_cmd, &qedi_conn->active_cmd_list); cmd->io_cmd_in_list = true; qedi_conn->active_cmd_count++; - spin_unlock(&qedi_conn->list_lock); + spin_unlock_bh(&qedi_conn->list_lock); qedi_ring_doorbell(qedi_conn); return 0; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 3715b3d20890..8001c5a26a00 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -349,16 +349,10 @@ struct iscsi_session { struct iscsi_transport *tt; struct Scsi_Host *host; struct iscsi_conn *leadconn; /* leading connection */ - /* Between the forward and the backward locks exists a strict locking - * hierarchy. The mutual exclusion zone protected by the forward lock - * can enclose the mutual exclusion zone protected by the backward lock - * but not vice versa. - */ spinlock_t frwd_lock; /* protects queued_cmdsn, * * cmdsn, suspend_bit, * * leadconn, _stage, * * tmf_state and queues */ - spinlock_t back_lock; /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. From patchwork Sat Apr 3 23:23:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415227 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 277C1C433B4 for ; Sat, 3 Apr 2021 23:25:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 063DF61360 for ; Sat, 3 Apr 2021 23:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236959AbhDCXZV (ORCPT ); Sat, 3 Apr 2021 19:25:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:50190 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236958AbhDCXZO (ORCPT ); Sat, 3 Apr 2021 19:25:14 -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 133NKOUd160347; Sat, 3 Apr 2021 23:25:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=nRVocMsN7iqx5vbwaougkpKPCDoDa3HpVJLqxapjePQ=; b=Y6jQxThW7afXAOiFkyuK19wPvvSP6pW1aMzMdSC0gbdHt0c8UNsg45cBEBspuun44LEh jPy8f3v5hdeCT5jLxT2k8mp88eeHGbFB+u2wh78XbY8RiJc75gooSIuHtGk+6GsMZcTS /J/rE6fCNk91aTV9JTYgueVGpYlJEV922URHyHRPCRM3NgKq2VezBdZx23jBnUbzWD6w 9p8LHqXlOPj+i0IXSV4RV5EFWXOYqgScvo+3ar6xHK4gxaBIcKizyC0fb4Ta/b7a+viC OqDZgAy7FAXm70GX+SGC1aJbye56K1jZYc8Wa4q9dAMUw8Uvw59otJzi9z3ZjB/LdRLm Cw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:00 +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 133NKtBV117020; Sat, 3 Apr 2021 23:24:59 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:24:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBKNHwMFKZbAxOqdNU8u3opSGn0YFU8WYeYHXHhW6eoeAKFtsIbCfuBbM5ARYwyGqGeZasjHpF0EXOS/2MHsoa3ccIHgv21zLupmEwVUbaD49FSc5TBr/+ZvgdlEqn4zTx8fDtl6OpYzDcqlMBWcUl+ZlJYobPh5yrInGGZB5TKQ82K9ZtYRzSP9Rur8sFxFRtD9CnIINzpHhrSMct/LGlnlpybkkjeRFrsKxOZk11uWMbb0gFi7CVkz0syFJG3iaNGT0X8yVmpU+DK9zprtwg9C94jVnyJkjG1oEm/uZZgbU/ebKzrUD1alj6mN4Brdckb1YGlEQ4MBRidIEKdT2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nRVocMsN7iqx5vbwaougkpKPCDoDa3HpVJLqxapjePQ=; b=eaQnyPl6O1X/DGouggqJnVG8Q3TOT9MYhcabei6j0Hfm0sppn8mu/QpnFQCIG1GMsZFokXiZicU50EgT/i5y6DrSG1kM3aJTVQaxPoy0l0fLuBAHh+/rH0fnGQmv7ANkRvRGkBhxt2tP4RfeX4TG+PaUBnJ3KKGX1r7SE9Bw8MnladcS6gI76tROwZwYvQmbp9AjAdAkukr1++58T4jJusVQNwLBlXT36+mXek1uTJsENSWVyaV4qNaHQIpmMtH7a12ssFuIiLlA+wQECeMLkQFvzq1Apk5XVw2XkX+n1mSZxkYUC+M36ZgF4EmgV7ozBRUPaXzcf4fjcdB2Pl/VYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nRVocMsN7iqx5vbwaougkpKPCDoDa3HpVJLqxapjePQ=; b=b/olkOKhasRo2S4iUd0Yy8iPJTQ0V9J1vuFQMYI+qPsjZpJZwO/8pEayIytPVfZYvKsKuDAJzy0RTn2InT2OL+JoYm4eFzqukGnXADNuYuzNvXrZfEH0JlW5xRFLU0VQDJ++usSFqwevIKe2P/PD6ZTGakSwNG4iytjLGL74DrY= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:56 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:56 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 35/40] scsi: libiscsi: update leadconn comments/locking Date: Sat, 3 Apr 2021 18:23:28 -0500 Message-Id: <20210403232333.212927-36-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2298b6ed-cb6e-41b6-20d5-08d8f6f7a1bc X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ynRkwCO7C/lQtXs5TRi64BCuRti3+A7Ds6ZzyeEe0OLLZ70xLxPxQiYhIxAVdJe2RX8B/s7vpxkkagdBRf5QYCd6nMG3unQBde7M6EEg/e04KFl0HxZ85RPjUjbJi0aqWTd/pQOQv+QJMRdSInUDDnhw/l1hoUBDOlAp3AlNG/UDdU+QsU0KAvKXg/2mdVqYvSXiE4sq8M+/6C6G5mtN6OEBdbNjumU7XbM6xEwEtcGPZYJOeFxfF4xx9ZihCHtiitGef81srM9sAAruWTX79ichZ/R/YBLrpIFfzs+WMc2poOTQ+xFQhPzQoGy/hTj2mZpsQPj7nsLFY+37sX95ZY5DjRxrnE2DqQeUS7qbUQzK1F1CumYQqcZJBtnxT4Szk47ns46qv3krM4rmnDQd8NesN11pld/wQwWYi67JE9+Ny+QVAvBIQXPRPLUzRI4qxVgiLQIS0R2LVFF3XcIlK5yO9OH98qi3WKIV21WtoQQTw1exAZLRyDgzLi0NUq8kZ/v4JgyVSjUgX4kkBH9HxMJhMFQvePG03M6BNeJAvaV/126j4AxCrT5cqZx1XUeoXmcJlS2HSnuxDY7Ou6JPRS4DQsq46k1ysGlz3Jar6rS09xKAor15l69yQmgCJDfbFOEq5a2IkE2UrjsXZG+qiP/cISquittkKuxVcKREi70J0aAj38xw286M+vMSZTaeYEZi4F5msS8MGupzOL+D2g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(15650500001)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YenIm39+OtB+1M6lDM+oc0O4G6pWmQrgcgnoTor23ch1pSZXyGA2UGHRTvx2ZlBvp6tC5m4IBqvc+1j1Au175dsvGhpfajOnYZ9dZCbEbD0CUaf1jk6AWwkkK4CJTeNCUyqQ0yEsSWOZGETwy8prsOwDpuQMHsCDdVmYNtaX6aOxdxttQko4fafoap0F+FhzygyOamACToYlcvFl5OD5qE0EgjAdvQpSMZZd9kq4+C3sFbln921y9UdqUxXc6qKnBC1OiuoOxtvKB4UFEPwJcYoA6U3CRPqQwLx0W+kVsjTxGqxSSDcPBp7ux8aEDB1kqIrYeaoC+ML0IIqii2lWG4RjFUVbErNOw2QAy6OVLKWtmJ93Ok2NroaH0tc3kxZOXf5VlEzB8iFj1+Qs0t/nCsVeEKBXxESiOoplUAWAP7mz8WFWzvfkJyEYSszoJcE6JeSTooHGzRYYrYp3rw0PHj8esG7teL9mfgaZs1szKRyHBAt9J6zLVutIfGzKU2LrPjTPt1Rk9T1AlElL4j6h4PqVqFYeRMw0vMj1cQ2CgBVlMMbq8XELqdtEgT0lytpv5BMwZH0Pp/u3Ktlm2iKiwE9DgihEc5nhrxLWNQPOYHpMxVCphK44cnVRtyYv0bZMn2m+6GoXYjnYrtJifqStqShqlNr0zaxDYG5GMHrGZYQVtlK9wU8JVdhyrUkynzvaGYH/yfuBtGB6v2fnvwpBVkPOcnMr5hqtgeIdvtxiFKSnyM4dLb1440MTc4WgKCoP6XhTTNLiRuSjhtXPuwPQCDvWuQH8zj2zTkwJpqYFNi8IV8cmlUkZ4jqrplDj7XRlLzE352CkuwOGpwyF5zR5iNFENjvAdghIxKoQKZfZ59SlKe9sOMShnPExo++16J4v6S4CrG9np3qIU54udhmWPUzo7m61SmhhcQjrd+Ga31Aysh9dY/JJkKmKkoaXb94XxV0LiW/CirLDAVV15uUY5UV6VS1qharpS0g9ZH9sQeWkUzvmwleBr71rm6YkRC98Qg/JC5QO6lyEBGxyuIF/VlTZhol7nC7BgDgIVfM71MDL/KIpN6W4fBJsmH0z3zKhsVVrPoSVijEb81GQIzAsKpPWrIxqfCr2xonStT41r0KX1I5Iju/KlJzCsDtjAkvit/wktC8IxvniSZlHZm58Dnc56cYcGpL27bDt8DkySmu4QHwe2F8W/juU12VGqtEuYOi1XjEyM5FLIthyTb7t+6NrU5+/oe0wHBBYKv/FSG/aj4M8zmHCekGsdkZWUQ7B7hQfGyYXNedW+qRMq9Qou0fwNYDbbuThprcw5MbwX59W+RiY/TI87BrIk1z4WTes X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2298b6ed-cb6e-41b6-20d5-08d8f6f7a1bc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:30.6019 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aTzRyf/fzik3wTSjW8u3HNZtxDT986lhQGQeoOYX2SB7I6QiDNd69iZLvsOPcVRDXk6HQk9kDEgZELei27fZ9vJmkmck0JuREYXVoinNkYA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: EED16BBI-ZLp_gT1hf0rYw4YlFJjfm8P X-Proofpoint-GUID: EED16BBI-ZLp_gT1hf0rYw4YlFJjfm8P X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We don't need the frwd_lock to access the lead conn. It's setup at creation time and then only cleared during destruction. It was from when we supported MC/s before this code was merged upstream. We've only supported the single conn session for 15 years now. This cleans up the non iscsi and SCSI EH paths. The frwd lock is kind of intertwined with multiple checks in those paths and I have a another patchset to fix up the tmf handling. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 6 +----- include/scsi/libiscsi.h | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index e7d1b69c07b5..211c56fc6488 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1813,15 +1813,14 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto fault; } - spin_lock_bh(&session->frwd_lock); conn = session->leadconn; if (!conn) { - spin_unlock_bh(&session->frwd_lock); reason = FAILURE_SESSION_FREED; sc->result = DID_NO_CONNECT << 16; goto fault; } + spin_lock_bh(&session->frwd_lock); if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { spin_unlock_bh(&session->frwd_lock); reason = FAILURE_SESSION_IN_RECOVERY; @@ -3441,11 +3440,8 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session, struct iscsi_session *session = cls_session->dd_data; struct iscsi_conn *conn = cls_conn->dd_data; - spin_lock_bh(&session->frwd_lock); if (is_leading) session->leadconn = conn; - spin_unlock_bh(&session->frwd_lock); - /* * The target could have reduced it's window size between logins, so * we have to reset max/exp cmdsn so we can see the new values. diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 8001c5a26a00..c053de831c2c 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -351,8 +351,8 @@ struct iscsi_session { struct iscsi_conn *leadconn; /* leading connection */ spinlock_t frwd_lock; /* protects queued_cmdsn, * * cmdsn, suspend_bit, * - * leadconn, _stage, * - * tmf_state and queues */ + * _stage, tmf_state and * + * queues */ /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. From patchwork Sat Apr 3 23:23:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415097 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 4BBA5C43460 for ; Sat, 3 Apr 2021 23:25:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2844861360 for ; Sat, 3 Apr 2021 23:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237006AbhDCXZT (ORCPT ); Sat, 3 Apr 2021 19:25:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:50182 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhDCXZN (ORCPT ); Sat, 3 Apr 2021 19:25:13 -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 133NLQmc160772; Sat, 3 Apr 2021 23:25:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=aibAfH1QqGR+7pphYEdkVkPxVPEMDycY5PWo7MqxCmM=; b=f4GJtfek2jjjc6V/dWel4RrrPqUHPH3iZipcBbYCXbMnNgbt1mcNwmWFJhRH+IgXRe1U ex3Oi4fQ/j/EitrmEeMfof5BZn/PirgkuO5W3Cu4CiV/FFxAZ3F5wm4NuKGZdipUMx0i kiXJuOpPeSJeJTtIU3qpSQEi/n4u8EEf1/Qc3gUJUmFQghE1WtMShDZQ/SRDr5ZNmfQd z/iPceDFafCIQSWKbVZEtbtB+hVybFIKdxKeoH5BoX3qgQROXnNXdg+tgB8KOZ9qHpyf s2emaLJT7faYPFxMbFctLLId4kHBhvJhyQkPq+9cjO92bVr6qY2hq+ksd6xG4xr5QCnu 4w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37pgam8rpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:01 +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 133NKtBX117020; Sat, 3 Apr 2021 23:25:01 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VvRT+/rEZG1XzOqE0XLrvAdB6cZiIEpuGJyrLhoFeNXTFARWHn7/uupe+hfAeAx4bz/C/emxzVDAz/tzpkjrA7k4bvEERR1+2ifah6Uk6drLgp8hB1iKZsipCAqAIhXq9wWxTk2kBhaitZBilfGLdH6dV3ddk27pvLBcHoUUD78eBGOjEb1BeMdvbSVYeT37VmVTnE/GHO/2ZYt/oqdwIkrTxEpmGfGnC7udv+ZhdqQ0uRlOKdp7Q7dtz2M+MmIA1DAfaSW1+EtvyglxIqcy2Bq4UbuKgk4hsgI1zzZa5kJghra0xo/g8tU63VZu59GHuhI/EqVKtdgk3ommUcumtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aibAfH1QqGR+7pphYEdkVkPxVPEMDycY5PWo7MqxCmM=; b=Tssm6nZRvLOX4HCOcuZBaZ/i1ZtS6Uo2UXkFKCyfEzDqjV0g1Xtf/RKJ+j/CctwaHQxWENi6Y/cMqFWuVEVk05zR6gYNiRF8c3Z6MyBI2UKNyxiMI/p3SJ9jK8y2UD8W5E0IiV4HKJvwdzwVZBSwBiWFonCL+HjsPggAVsZB6uSdPOZdDO9VPHMYvGCvFPiWCidf2bZoqaZGl316EhKjIqC08chbgBeuP5ZvzkNjmfyfqY+fi4nARqPVWD5OLD3XH44x48q67M/gK6rQaFzovrKCgaPU/u698VpYOYQEesUUcqqOIvDDWPoJQUSC5T/a89pAQoJqC/uDDJfnmYY7gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aibAfH1QqGR+7pphYEdkVkPxVPEMDycY5PWo7MqxCmM=; b=b0cbPEhiZJ2BcK470cS6faenknD7oalPXILzWLRahLRp6keizKQ4M5j+TX3hvTEMM8JINOOd95dHj/cuV/G+5NU1MP7HlWjqB8tCj8mH2SWBewfJlMrkH8CeKxBzftugt1WeEkTxtsx9fLrvwO2pd7Ous06FJ62iqrRPrHEEtXE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:56 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:56 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 36/40] scsi: libiscsi: move ISCSI_SUSPEND_BIT check during queueing Date: Sat, 3 Apr 2021 18:23:29 -0500 Message-Id: <20210403232333.212927-37-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9452324-2c94-431f-0a2b-08d8f6f7a28f X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XTKxsRS0nKIuhldkvRVfQYiEWGSEpSsRpA39WzW/SnraCJj1o1MJrwoRue7b/WmcbAnzdyiHb8MHQL4MjFUCS+kDgzOlmBxLr8tPeYUhihvfMuf8uWeJAYWlSMcu0GpZrqbwJsB2l0Qm3PTqi4Fewfi0rxDAT03VC7Q8KN6XIPdsrIA6YvRzGf493YwJGk02ZsieLdtyaOnXdBA+P8AkU46lw7qUEaZ2m7DjFDldl6SAoabOULSfpt0h2wANf8nAnrIY+Lx12nfvhIiMi+4e7H2G9p5wLHHfumBNNnIwRD6lkc0TeQ5jxmtPpKyjHtAD0o5nZcg7frNylxC2d9/oNk6gVPbhRLYSxsg0HJNNVkq4Zs78e8sfII6Twj1+aR0XO2ALMUSqxXdPz5j1zlBXkom1hXtjktMNb+OMM9ZFgiw6WNnaFezZHQioSMRV9+ti9nEyhqLmBDGmnH6E0MIx3TxSgd3IQs/AHaNLId4me5CZbFJbGRw7wtfc4fW6iAiaqtXigpGMf3srtJIViSWAEs7RpBqq4RE70gxYj5Kk5EflA5HkMFhdjlU5E0nQbhk1Ma8c6Y8ZRiMFH+ZAPcdSJMYHCrHmBLz8BSztEUQKUJU+1lwyYBax30P3TTqoqhMQEkACNJ9uUb7m9r7cT5GV6jEXBU15MbBwySolx1Kazi+F8EgBOWPfht8L+73fiL1xEa+8hCbyrY2N9OyYaCs0oA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: svBUmGBgSB9D1m/k3xuiSquN/Ni5nW8EhMj4KHSiCfVTB0EvcoimzeygN5ST8SAXXP7qw+KPWK+a+eI23F++434KUyY1PTF2pHiCrjUumRdluo3ezfaEcsByJQXl2nxphOLCEBNko7cCW8M6pM6fWvu2KrAuxDWX94KeWmDTgF4HwskxMmflZDHmdd3JeY05VRAIEH5RsEXaXQo9RM9BKWsaD7C/Pv3JV7ZaZH3Aa7fskqBPwUnPliDPJ7iFVLTNrzyiZpoUumiBpJKCR9EvNGlLKHqcz3OmPJzHPnD4y4a0Pf8yIado2hk3HvoDZSatVqeypS/rQjednuFE9wUz4DrUwwHIReckAv9dkdlAs0CZXyOxOvjoVkuLdK/JOKW/hGd/MP+fjs7p2LcPjDuOeSzkpTNNKp3wSVRRzdXp01zEbeGQSdH/05tQwXliX4p9/xJ9NKvP7Xm+ZdWhwwZT0U7345nZkffuJm+bFrfJnFnRUaWiYnZya4fOR/bjn5KfRgoBr0E3SO++2H3gegmPnGc6oo81gPyohfejVEb13+4JUyGZ7OKh99VzSXjUMgP00+xuLcPMfv6C9Wjc8YyRufTM5LrosDO61m1eHWAa+Dne4ZkHHWfo8T/dafKGQ7mnpeGmtmY2FknrMcNF4j5RC5hcs9lqEL8KCYL+Ihcs/ti874sLQm7Tz/j+Hy/9ztcpbzeVlrr2WnziHKnez330BuVdDQWFS1LAToEzb+Sc9g7htCKJtiRWYdHcxe3Oi0rK1uMY6R7aAeiKdZw7OZ6lth7I4DIuDa6L0/8bZ0sBF+Obih6d/BGuxjqRW9zHsBuGcPbirxBSYQPlzF+D9KHrUpboxvQa14v4lLJD7Wq5EMaRGVgnZj2xeRFNpycdSnbNZY+7lq3ss3mZZQPuEcpd4yghHrFn9jrNGH2LFiDDY6fHYmuOCkH987BCJgFtIMXQgSllg0cj2qsoflvYgZG/ZZEPwvG+/4O27eC/1lNh/o6NjYpH/DoU2g8XaFsCHEhdLBsnQQFXDkyi5BOo2SARELohlNbhS7pnPDED9zFacmcPXMkOtKb/9/6giGqwtTPvP5D0H6VigQUV/VVID5ynj8eF2Gz5L/qKIoVjN85jM06iyXhWe4zNXI6/lkjaOZ+Ha49ftsNs6ZVDcevNlu5JB2GUbAyTECM5k5SiQ5goBWmHDTY5Dc5yfYe54aXHkeSuF6gmMiXCGFlRHa9eEhKetIO6nHw/TCXPfwuDd8U/8FB7AwHX4/+ZDGDjx1pOM/OapXDbs7qXI6KC53Af0+p/ZqEJL+gz0NXQZXZUXWU/7CVGjKsYWIBwhUgu6DXLqpy9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9452324-2c94-431f-0a2b-08d8f6f7a28f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:31.8942 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j5pP1yGk/rvvFBMVnQeze8AYp5ZCB7GhbUb5zfwrw8M5d5LZBeFRFdJTKDLQ2Ngfnzo7JtuLPF6sNc3sxaR/RkP7sIsXwMOpvmcFdbhWwlw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: a5QIxqD7HpyMKDNWAjF76NjvfMPyqBmp X-Proofpoint-GUID: a5QIxqD7HpyMKDNWAjF76NjvfMPyqBmp X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Drivers that use the iscsi host workqueue already check the ISCSI_SUSPEND_BIT when we run iscsi_data_xmit, so we don't need to check it in queuecommand. This patch moves the check to the full offload case. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 211c56fc6488..136531200643 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1821,22 +1821,22 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) } spin_lock_bh(&session->frwd_lock); - if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { - spin_unlock_bh(&session->frwd_lock); - reason = FAILURE_SESSION_IN_RECOVERY; - sc->result = DID_REQUEUE << 16; - goto fault; - } - if (iscsi_check_cmdsn_window_closed(conn)) { spin_unlock_bh(&session->frwd_lock); reason = FAILURE_WINDOW_CLOSED; goto reject; } - task = iscsi_init_scsi_task(conn, sc); - if (!ihost->workq) { + if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { + spin_unlock_bh(&session->frwd_lock); + reason = FAILURE_SESSION_IN_RECOVERY; + sc->result = DID_REQUEUE << 16; + goto fault; + } + + task = iscsi_init_scsi_task(conn, sc); + reason = iscsi_prep_scsi_cmd_pdu(task); if (reason) { if (reason == -ENOMEM || reason == -EACCES) { @@ -1853,6 +1853,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto prepd_reject; } } else { + task = iscsi_init_scsi_task(conn, sc); list_add_tail(&task->running, &conn->cmdqueue); iscsi_conn_queue_work(conn); } From patchwork Sat Apr 3 23:23:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415095 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 6BB2EC43462 for ; Sat, 3 Apr 2021 23:25:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CF066135F for ; Sat, 3 Apr 2021 23:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237017AbhDCXZW (ORCPT ); Sat, 3 Apr 2021 19:25:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55254 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236980AbhDCXZP (ORCPT ); Sat, 3 Apr 2021 19:25:15 -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 133NP2TJ088104; Sat, 3 Apr 2021 23:25:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=65jqzbwLvfQYj5//EyEY0w0SZCXjqEHPn6Sjs5GZ+F8=; b=Yx20doQRimv8PvTZI/JcI1uSH5zwflPP5MNLfdDKHRP8rPxOvnmn7KI6f++UqoWXj+xD lg5GiHDdMqNBt+6Ng432ddhPaPYyb7MJ6t0e3WrltHnrK08y5eDbpG37MbK+matqSkQb K8wc/ZuBaL0o+HosJQmyiCU7CquLfxB++YNl/hqfuRZ/+gjDV6Bu/KZ/yKnU2lgAqgvB sIFr7gh4XeysiosK01i0ygCwIE8OpAYlzOuVlHyhBHiuzg4LtgIb5Awndmb8Bi4TqAnS eMl1iZtp5muDwTk1ewrF/Jv2EJaoMDVeY3JKcX1eI2xfJaGBL8gPBXJ4cvTzijPtnsdj XQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37pq66rcve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:02 +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 133NKtBY117020; Sat, 3 Apr 2021 23:25:01 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C66kCMmZvuqZ3qWbEgmGcYmNNNlaZmukSfZVcSOK48XDxt3WGpoyP/ZjZ31tJrDNCw6T2TAJtDjDxxDsMhX6ji+gV5tBk9Bl0ctai0LsGbAI90piYdMvRLwntzJKRiOBJ3A/ltfYCWF214pKeoHtbhLPqUANNEqQFNR+zPyUf6G3kdRtyegyUf+39L8+xXE5qOVNi/SNBKepJcXj5Y+/rrpVznHjXuxlbWPAzJgDd81ScqzI9XpIW3PMGuKyZc7vuPsQWzOEMFHFsLFXUg+caGCiyedo2T1IZvEuDn+L7YUm0KhnuzzZ4nXLuwJW2roTf9ksF78qDria49qHzm8ntg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=65jqzbwLvfQYj5//EyEY0w0SZCXjqEHPn6Sjs5GZ+F8=; b=Vr82fiELqx7xONVreodybeE00gLZ14kMEiXGP6vuxmfbvOhGs7qItcPGdCpNpqCvLNsWnhntna5fkTBwSZDzwCAEGKszVI/bbRNIOH9AfL66LD55Vq5uG4uunozSABGqrM2MLI+JnGsYFgoM0/w9nmFHRcipDFLdHFWg/y7VYm1IQZeaXg5BMP9oiNhwJSaewkO1HNPTNxffjaIBFE1gkU7eUWsiZ138n7ad14us7XBmQZE1WULKTMuWyfquKhy/LfM7zvkW1rXvQ1E/9tRdYPjAASbVbSqHC+9L/xB8lQfypuOsjAnj3RzDFeq0xGYy7oHhH3mzgblsHMY7c//WUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=65jqzbwLvfQYj5//EyEY0w0SZCXjqEHPn6Sjs5GZ+F8=; b=L4aJgF/+AwNRq1ktNPC+VgRJefK1M+inpTbyhUN77eYUx1eN+vs0kPM+qE0Hv6pLizOkEJ4WPhwXlBW0QX/Ug/qoJ0RXcTMTraxFMBnBqxTRi+g2C1MaeQu+Pi1p8iUaZhOdeHswJnwNXfry85pPgO5l7xACL3uJB5YvdE52TjA= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:57 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:57 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 37/40] scsi: libiscsi: add new task state for requeues Date: Sat, 3 Apr 2021 18:23:30 -0500 Message-Id: <20210403232333.212927-38-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f95e3a5-67c5-4e38-cdad-08d8f6f7a34f X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SOTXtgulMlxTZmogelQmrhbxgILDybs8u2vQDqtfNyTftag10Qvx7L68xeikwcpHYGA01SwmJXd9x++EpAcGFmSmQ7K6JkS4IHeZWGIhzxLVFK+t+Tl1zWgU1kvhlV72Ns111aWZm45HE+d3aYFuoP3YqDku5uPZDjWBFPzbjNGLFAH0NyjLPQ33K75S0zCrmS72zXHwLK3sp6DrTGQAjZ7xc4oWMx1Peae1CIKgM8lHqaW/A+93H5cMkF3P6vm+j7AM0KiCtf7N/mrc0eL7Bftwl3wvnkJQlUJZolNPiFK16argla2d0ykUUP3QFjWDkZ86D+Dqw5Mc0zaUUgPIi1q23PvDVhhKGJgZvkYkGPK31+EpZTTKJnE9SFAMVnlZauMIK/W3vTRbGyOHmZSFllVEciPyUlNY8iVRJQ4XG//fpPLJHAf9sDQ8Q8mRk2QySbwb4VHWdkSRVH9AM0EJW/q7jRupy+BPzOPqT6paezpcy2No7La/3ubOQaIgarxeSmTJ2yRxOGdmToBHH6Rui4VUK3eQ518lscoBgsUW5dYKLfh+o3ky1SzEileB1maXr2WRfNgkE6nsqnO1c02suVMzjr0bEPeah4Y6XOckCe6cPa6Prn5eSMxfJOTXq/ZUO3Jdn9eTEzZ5fSJnjNA6TimNIJ0Glvorf9/S4DnlTzpyMgN2Dgg5FmdgpsptWtZzQfVyWzjvx8F/ZCL39WXmCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xZWWXNdZ6fs7gRCQuw0gEaO1HvuRZX57z+mFeOMu6SmTUyZ28BmqL7y84cLL/fP+NZjX0a5GeOuV5dmnHL4lmS3QIMk8L1SFCAOg/48kRFrtRHScC3ainQKAIMm932CMidsVBq0CGFiwYid+u/tV2/xjD8sJDXx1aM3niSWW0ZVorgIvdT8cfOTf4zJyd0okrUzVKLsajEjeoE4GPmxv0/suNTh0lysAMObh0Oyu2gzEn47TJIh740d/LxBmpkTWlhmlee4BGd2SyKEl2lUlFShBfTP9kulxaohm1MqyGYlvx2tQKXHkZYUjOnj/B+DHjLpMzutPRJuk2hNZCyykrwvQ+zdhvgxkHhClVFYeIoCAfkckS9KuEm9vObHN8m2Aj3UsF5TY46mKDTMvHeCSDeSIllB3ntal8j3Kw6K2jh9dZhwX0BTMss+D6WaJIZM36p2SEhb8WVOgum7TJEdbYp30eQ+iUG7LXKskgii+Ozi9Sqk0goD3AsgvkZyIBEZfqonlkg0CfOKygrAQsx7nO7Tf7kS0X9tzzPLBgUwUB/r7NmcfA+498Q5H+DrUHxYg8fCfUWOujEEfV1RF9APLYKf6BtJ2yU6Rj5/IZ3IwFNDw6RocC+M4289Ew5QfF0KxcuCaN2DZiZQIoe2n2yJlGMWm8hC0Ts5K66QzbEgOly1KtVnJ2DA0uDIc0cXZPp3B9l6OAkDg3/WzSorhaGYclApAhMyIncJzke/r12oQwWwvPw7e/Xv1vhTwre88xlr+W7PPaW+Wb7nIniZWMMmmdl5sgpxJfXReJ7vQJlaR+yQVdGv4Ej0zzOIJQCRJ+Sn0jplffUPiCpiLrEjpYcIJl2gwynqewmhQKkzKdk4lWLdzmw7wJIOr6p50CanX6uRisCxCgdROt4p22QNu7a6zhfQy/NcAcotp91gb/MrFlH7sMqEHUzuPF6mQ+a14nAxr1lnVRrzqyKd71h7uyPBnvJm3mrpiSe1iiwI+NLo/+2P+2upuy8v8kkB0seW4aWw3ysdOmZ63EkSHKV/pB/5ilOe8baXWzhPS45LRqIPiZxUw4gjw0IP4GbcBA+ncswzqLg8QTOuBCOp2+81AI4HiCyNRCRUc/hdou+VLFBMin/MAFX1stn3K3I5Q6WE2dVNiWtMgldCmQOXJu3Xh6qGpMJ6CjGHDC49SROBAP8tL1gP4Dc8I0J+upFZRDU/uLlG1ESXu/8cu7bJ3Iiaj3982FTzczc3Km2B80/0JpCfgpVFKfjkL7KbWuqwu488ro7y83Q9Pbc2uHW/K+XBghImsMHWEsQcKd3fv2Dp7PPyG9vOTTe1gHJS2e1T98b1EJ+9T X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f95e3a5-67c5-4e38-cdad-08d8f6f7a34f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:33.1975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CtxEp+bxn3DViFBxXFFMdmy99nEjbNeiqvopq90aL3dsNYDspv1aGa89MI1H0TWs4FYA9UGqK1BwB9G+74JAulu99mgpkT7rjBnBUSm7f4w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: Zm3Fn9md9IEy65JmScfyLljx39omaGcS X-Proofpoint-GUID: Zm3Fn9md9IEy65JmScfyLljx39omaGcS X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is a prep patch for the next patch that removes the frwd lock use when adding to the cmdqueue/requeue. This adds a new state ISCSI_TASK_REQUEUED so we can quickly check if the cmd is already requeued for R2T handling. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 16 ++++++++++++---- include/scsi/libiscsi.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 136531200643..1c134f721a56 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -574,7 +574,7 @@ static bool cleanup_queued_task(struct iscsi_task *task) * If it's on a list but still running this could be cleanup * from a TMF or session recovery. */ - if (task->state == ISCSI_TASK_RUNNING || + if (task->state == ISCSI_TASK_REQUEUED || task->state == ISCSI_TASK_COMPLETED) iscsi_put_task(task); } @@ -1565,15 +1565,19 @@ void iscsi_requeue_task(struct iscsi_task *task) * is handling the r2ts while we are adding new ones */ spin_lock_bh(&conn->session->frwd_lock); - if (list_empty(&task->running)) { - list_add_tail(&task->running, &conn->requeue); - } else { + spin_lock(&task->lock); + if (task->state == ISCSI_TASK_REQUEUED) { /* * Don't need the extra ref since it's already requeued and * has a ref. */ iscsi_put_task(task); + } else { + task->state = ISCSI_TASK_REQUEUED; + list_add_tail(&task->running, &conn->requeue); } + spin_unlock(&task->lock); + iscsi_conn_queue_work(conn); spin_unlock_bh(&conn->session->frwd_lock); } @@ -1639,7 +1643,11 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) if (iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_DATA_OUT)) break; + spin_lock_bh(&task->lock); + task->state = ISCSI_TASK_RUNNING; list_del_init(&task->running); + spin_unlock_bh(&task->lock); + rc = iscsi_xmit_task(conn, task, true); if (rc) goto done; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index c053de831c2c..358701227f7f 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -95,6 +95,7 @@ enum { ISCSI_TASK_FREE, ISCSI_TASK_COMPLETED, ISCSI_TASK_PENDING, + ISCSI_TASK_REQUEUED, ISCSI_TASK_RUNNING, ISCSI_TASK_ABRT_TMF, /* aborted due to TMF */ }; From patchwork Sat Apr 3 23:23:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415096 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 72D36C433ED for ; Sat, 3 Apr 2021 23:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5475B61361 for ; Sat, 3 Apr 2021 23:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237013AbhDCXZV (ORCPT ); Sat, 3 Apr 2021 19:25:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45358 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236959AbhDCXZP (ORCPT ); Sat, 3 Apr 2021 19:25:15 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NMuiV099139; Sat, 3 Apr 2021 23:25:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=9VWIMs1pYdJEFklfarLkvgKUTZg2zfIAAqxk53xO1To=; b=RHWOyLo2BPTdZ8lc6jjQbm2sg3jS5Lc761ZDEcThOn+h6orXBhQpzxbK4rrMQorE0vSj KM21Hb/vgyDkrLR5W1hw6Wv2+bGiJ+lkrEN6vfLxgqGGOwMgBDR1I0+62ASOXSOOWSb7 ojmx6eGrnuxH+tqc2duMK2yLGBGMqt++GZ7rCF0W6n/aUKN79JnGI9LVCSe5L7xZiN9A TGBGPrGkcH5ielrki87GscAjbJ6E8NIpyTcDeohZNCvKrYZl9YIfgkSwN4qxcbaUs/Hg jWlRejuXs+gn4LlS7vNMdq39IalzgeezsQnaiGIJEM7aG65uS1SGuWslsFSgRva7Qblc Jg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 37pdvb8v75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:03 +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 133NKtBZ117020; Sat, 3 Apr 2021 23:25:02 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vic67x8qE1feEV8zCDl3TWDBIaae0Ua5cYjTHhA1tWud0GReRSqcDeBlpRqsAUqJ82SMcHGSxvvZpkt/bcXgUryEx71DCzMmHFRd0zcm9VKC4GQl+b8q4QBSRiAFAP8HMn6lVzv8Ags2a0613eUTPyzM+nKmkfhO+t5zbopwQRj9B2uRqgkNG4Q2Uw3+ZimF0AEdfGyOjh0yDp4Pt1E+3DYxkw5uf7jDuWospfXbrlqTv52Re99RZ+W1t1X8TJ2h0v0VxEcbNzT0NPMkDkEYY3PyLNF58oNMiEGUPkCFfz7gxcrFbRA7NSzPzlYwagoo/DRN6wctB8xgiOk4tE5gwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9VWIMs1pYdJEFklfarLkvgKUTZg2zfIAAqxk53xO1To=; b=A4b0ma30kS/jRC7kBYW3VB8fipZ4/UmhOSSYxe+vZrGSOjTUT9t8cnxTX+dcW+FYeZCMaG/HXh07Dyp6jbDG40kkk2T5Ayx+1+AS58paMM3U9vrS0fEGZ/d4cjdjHtJVOsndUModV0p/x0eEjxBEL2d1pLSeSU8jhsKTFxbyRmqvlUWqMLdHwO/eKAYhJ68Z3Q6ZKJZryHCnn2v4FuSYbWLPJ2mEsoH2NoPrBOpyvJ70z8ciA+tEo9c/jlwFBLIkgHFOLabdpExdqViMZ+IcIQ0aXbFTZUrYajLpIWKIfr1wIYL18X87HCVBYDvN3nNRKdwP7mChJCfn/6SJd7P/AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9VWIMs1pYdJEFklfarLkvgKUTZg2zfIAAqxk53xO1To=; b=l+mOifuyK0lWaSAkeDobr+vfmfDhjdrCyeG38sCQLjosbrhxwR8Y/APIxPH2W0qDonKmfxZLmrF8+KZjAW1Nk1accZT9d3Cwo+F+061nmUPcWaxZ2Wt+PbrdkyUeoB4to6TfKHi2VGuTdSwvqaR5/rGh0+7FoiIv1Lh0lG0VCUU= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:57 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:57 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 38/40] scsi: libiscsi: replace list_head with llist_head Date: Sat, 3 Apr 2021 18:23:31 -0500 Message-Id: <20210403232333.212927-39-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55233370-6636-4643-f97b-08d8f6f7a40d X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0+IeshdDbKELyc8Mjr/X+mCho0ze7m/KKkLT2rxg44URNZ7OS0X6LNbECk5tQsuzDGCM7DJgTmk/Ajz6HTWI+GBEeMD7xYFaODKR8MYkz8iAYujppH/2V9kgJhHtHrLN2j+2gBuGbllkR28YjDSWx4nCtIrFCBNmPuaM4TUvcInxDgEL7lDp1g67LbJL8CjNRuALcplegf6wD9mSBp6exbgpeVx0XMhlXRlgZFb0a4W4ESZG2s8/RZan3pmwEcTnyV4owZSX3bx/r/CBWHBsQBRUO1b8/h6u1j3VrG8u3aw4Xb2LHRnk+3P76e56dfIxA1Tgaq09QgPdLRaFRwFT9Zml/H43ckGJakFWL33So/P4iJGJ9+0FVbdpvrpow2nrJGUl+zhunR0wYpuYv1zKBn+4D+XADq6xDQcMpq2I7+GmiwGvYkxdS01ZK3spI18Apla3xfKl3CfJFW/+KSduv0aberoUfQw7BtvYl+oYu9a/GMsCfguYCunN+T5IgDjSNG1t1HemRhMs7VpfPiGUU21NHviKP3Pm6q3lfTjojWtzq0d3JMO4cSKcpGVHR1dQANlqzFXlUCRivMDRnO/uiJV46s/QY0U2+c08w52S/BNVk/xLxkZ9Ab33mqZZ7ISjV0XicCzXT/lzDhOPZgy8xKYDr5pLSfCg3JByENvOt7jiwK2iZ61RvBZMBI/SEDmv49MvL+1H5kG2/h54RzYl+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(30864003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PbCCOAm7JX8dBWtvMWNrkzvwPDQ9GKB8h7wDE+sbwf5gujQWDXV96H9D/rLfU5vbjzr7bqPsq0cCw4llwtHQTC+DrU3BDeMfRauXAeGSg6KKjJG2shgKBVopJODLygQ2hSCEXCFBd0FjMNLL+zi44oAiH5n8G/4tlPib02T2fBo3p76D+pk5dV6yvnWw33D8hLkyyZprQP0k+xBLYZeIqVML11b64U2ttVdEuh8QHCJmLgR3pC1QXAXaFJkEU9DW1U0/HGWaYg9+2NbepAXEC/OktWigVMFFEg9E8d85dTNOsGB3Ic3q2m2PsKToGmaXPzC3iWqSKMrSZ4otzjoQYVKNO1FEWaojZglykCLyyqgSW0MrImWF0OLO5WqFq8fHYDZM/537Vb+9ICCVVUZsadSWcAY9VnPPtwBKp1C2HEYKNANHjMpWuN6WlGf+NKOzY6CHilyAtyJRfftmdSSn0mqbQ3Fh67NQfP9pGFP5WaXNWHLH1D1+gqdlC0MoVt6Njb1gSzOrXclbhN2LqjKuWS/TE0G3ME2rzeJl+0XuXhMD8JxTbRrzxBCRKLlh8lqodY9KYDNvX3K6BejO3PC3frkFnbgPwN9/D9y+HF1SxClXy4uPLKK+ZGg6iqctj9CIFDR4rYQvU6C1e/6N0DDsjGMTDBet8GRXagnwlbYKNyGinzkQ/UmNQSURexQwVo6zxxnRcUwTiKlBCeBYJPhQTRnaR3+8w4c3psy5MbTjEivgAW2qT0J1Kzvlg0H/7Pl++KHGjNjWEMTVq88yFl4HBCsjYk++aD0fCJgqafRlboQJSZAyK8eqtUlsOdqCNVVJCiBC2uhu2pSH44R26S7+wigHBz6fVQwYpL1NzpiW+kGCR24DT+zY2MJyYrLF3QADU4m8yyKCyfhoa+oPvdw6K2HioRDOeHvpa7dAmE4k93v39fN1hY8PMYuaQktlgyJqoH9gDq0KoQE1A88sGDP5E9ic3w/oKa/tmvrGZSvttMvrHAQlf3aNE1rvvrpAGJ5jMZndpg+oGKJoCiyBYO8R7gZ09HyAZD1iaSb11wa6a63ryX9j4l+8qs5fzv4deL8ulZo+/dChIUW8emWf0K7wWJhh060YUj5W5SHw3hAYF0QI8uIuSO7B6MJo4Q68bAe1FLBhnRiiiy8m294J47GUIAF4pSlAFSWQZc/0P+D4uSEqHN4Hwkw/cSzcO2oInVNyMVBXT/URCpupzlt8yN/CpWj6Q/O5kAXbIGSV2gumDYFWbOmI4GaTpSbzzkOD4mMwnx1CzmsZG49Es2xwJYoRetqeCX1F5Mae19a9bSfbGaXYmtHT9Wt03YlV0UDi3gWO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55233370-6636-4643-f97b-08d8f6f7a40d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:34.4408 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6+cx1osfFx4ZF5T3XlznZejgXgKg1zNrOh47Inuixqv/oaB6re8Zqge6tEL57JnPe3SM5cVxAu+8PQqDOuOIHpbaMbHEwh69oeuf/YWdKDo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-GUID: sYyvUC_jsR5WgFRDXXkOpEtQxYRxHYcm X-Proofpoint-ORIG-GUID: sYyvUC_jsR5WgFRDXXkOpEtQxYRxHYcm X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This replaces the cmdqueue and requeue list_heads with llist_heads. We can do not need the frwd_lock in the queuecommand and recv paths for this. This patch does not yet cleanup the frwd_lock because we still need it for the cmdsn handling. When that is fixed up the next patches then the frwd_lock will be completely removed for the software case. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 248 +++++++++++++++++++++++++++++----------- include/scsi/libiscsi.h | 23 ++-- 2 files changed, 198 insertions(+), 73 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 1c134f721a56..1b4b6ee246cf 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -730,7 +730,6 @@ iscsi_alloc_mgmt_task(struct iscsi_conn *conn, struct iscsi_hdr *hdr, refcount_set(&task->refcount, 1); task->conn = conn; task->sc = NULL; - INIT_LIST_HEAD(&task->running); task->state = ISCSI_TASK_PENDING; if (data_size) { @@ -782,7 +781,7 @@ static int iscsi_send_mgmt_task(struct iscsi_task *task) if (rc) return rc; } else { - list_add_tail(&task->running, &conn->mgmtqueue); + list_add_tail(&task->running, &conn->mgmt_exec_list); iscsi_conn_queue_work(conn); } @@ -1564,7 +1563,6 @@ void iscsi_requeue_task(struct iscsi_task *task) * this may be on the requeue list already if the xmit_task callout * is handling the r2ts while we are adding new ones */ - spin_lock_bh(&conn->session->frwd_lock); spin_lock(&task->lock); if (task->state == ISCSI_TASK_REQUEUED) { /* @@ -1574,129 +1572,238 @@ void iscsi_requeue_task(struct iscsi_task *task) iscsi_put_task(task); } else { task->state = ISCSI_TASK_REQUEUED; - list_add_tail(&task->running, &conn->requeue); + llist_add(&task->queue, &conn->requeue); } spin_unlock(&task->lock); iscsi_conn_queue_work(conn); - spin_unlock_bh(&conn->session->frwd_lock); } EXPORT_SYMBOL_GPL(iscsi_requeue_task); -/** - * iscsi_data_xmit - xmit any command into the scheduled connection - * @conn: iscsi connection - * - * Notes: - * The function can return -EAGAIN in which case the caller must - * re-schedule it again later or recover. '0' return code means - * successful xmit. - **/ -static int iscsi_data_xmit(struct iscsi_conn *conn) +static bool iscsi_move_tasks(struct llist_head *submit_queue, + struct list_head *exec_queue) { - struct iscsi_task *task; - int rc = 0, cnt; - - spin_lock_bh(&conn->session->frwd_lock); - if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { - ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); - spin_unlock_bh(&conn->session->frwd_lock); - return -ENODATA; - } - - if (conn->task) { - rc = iscsi_xmit_task(conn, conn->task, false); - if (rc) - goto done; - } + struct iscsi_task *task, *next_task; + struct list_head *list_end; + struct llist_node *node; /* - * process mgmt pdus like nops before commands since we should - * only have one nop-out as a ping from us and targets should not - * overflow us with nop-ins + * The llist_head is in the reverse order cmds were submitted in. We + * are going to reverse it here. If the exec_queue is empty we want + * to add cmds at starting at head. If the exec_queue has cmds from a + * previous call then we need to start adding this batch at the end of + * the last batch. */ -check_mgmt: - while (!list_empty(&conn->mgmtqueue)) { - task = list_entry(conn->mgmtqueue.next, struct iscsi_task, + list_end = exec_queue->prev; + + node = llist_del_all(submit_queue); + llist_for_each_entry_safe(task, next_task, node, queue) + list_add(&task->running, list_end); + + return !list_empty(exec_queue); +} + +static void iscsi_move_all_tasks(struct iscsi_conn *conn) +{ + iscsi_move_tasks(&conn->requeue, &conn->requeue_exec_list); + iscsi_move_tasks(&conn->cmdqueue, &conn->cmd_exec_list); +} + +static int iscsi_exec_mgmt_tasks(struct iscsi_conn *conn) +{ + struct iscsi_task *task; + int rc; + + while (!list_empty(&conn->mgmt_exec_list)) { + task = list_entry(conn->mgmt_exec_list.next, struct iscsi_task, running); list_del_init(&task->running); + if (iscsi_prep_mgmt_task(conn, task)) { iscsi_put_task(task); continue; } + rc = iscsi_xmit_task(conn, task, false); if (rc) - goto done; + return rc; } -check_requeue: - while (!list_empty(&conn->requeue)) { + return 0; +} + +static int iscsi_exec_requeued_tasks(struct iscsi_conn *conn, unsigned int *cnt) +{ + struct iscsi_task *task; + int rc = 0; + + while (!list_empty(&conn->requeue_exec_list)) { /* * we always do fastlogout - conn stop code will clean up. */ if (READ_ONCE(conn->session->state) == ISCSI_STATE_LOGGING_OUT) break; - task = list_entry(conn->requeue.next, struct iscsi_task, - running); + task = list_entry(conn->requeue_exec_list.next, + struct iscsi_task, running); if (iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_DATA_OUT)) break; spin_lock_bh(&task->lock); - task->state = ISCSI_TASK_RUNNING; + /* + * We might have raced and handld multiple R2Ts in one run. + */ list_del_init(&task->running); + if (task->state == ISCSI_TASK_COMPLETED) { + spin_unlock_bh(&task->lock); + iscsi_put_task(task); + continue; + } + + task->state = ISCSI_TASK_RUNNING; spin_unlock_bh(&task->lock); rc = iscsi_xmit_task(conn, task, true); if (rc) - goto done; - if (!list_empty(&conn->mgmtqueue)) - goto check_mgmt; + break; + (*cnt)++; + + rc = iscsi_exec_mgmt_tasks(conn); + if (rc) + break; } - /* process pending command queue */ - cnt = 0; - while (!list_empty(&conn->cmdqueue)) { - task = list_entry(conn->cmdqueue.next, struct iscsi_task, + ISCSI_DBG_CONN(conn, "executed %u requeued cmds.\n", *cnt); + return rc; +} + +static int iscsi_exec_tasks(struct iscsi_conn *conn, + struct llist_head *submit_queue, + struct list_head *exec_queue, + int (*exec_fn)(struct iscsi_conn *conn, + unsigned int *cnt)) +{ + unsigned int cnt = 0; + int rc = 0; + + while (iscsi_move_tasks(submit_queue, exec_queue)) { + rc = exec_fn(conn, &cnt); + if (rc) + break; + + } + + ISCSI_DBG_CONN(conn, "executed %u total %s cmds.\n", cnt, + exec_fn == iscsi_exec_requeued_tasks ? + "requeued" : "new"); + return 0; +} + +static int iscsi_exec_cmd_tasks(struct iscsi_conn *conn, unsigned int *cnt) +{ + struct iscsi_task *task; + int rc = 0; + + while (!list_empty(&conn->cmd_exec_list)) { + task = list_entry(conn->cmd_exec_list.next, struct iscsi_task, running); list_del_init(&task->running); + if (READ_ONCE(conn->session->state) == ISCSI_STATE_LOGGING_OUT) { fail_scsi_task(task, DID_IMM_RETRY); continue; } + rc = iscsi_prep_scsi_cmd_pdu(task); if (rc) { if (rc == -ENOMEM || rc == -EACCES) fail_scsi_task(task, DID_IMM_RETRY); else fail_scsi_task(task, DID_ABORT); + rc = 0; continue; } + rc = iscsi_xmit_task(conn, task, false); if (rc) - goto done; + break; + (*cnt)++; + /* - * we could continuously get new task requests so - * we need to check the mgmt queue for nops that need to - * be sent to aviod starvation + * Make sure we handle target pings quickly so it doesn't + * timeout and drop the conn on us. */ - if (!list_empty(&conn->mgmtqueue)) - goto check_mgmt; + rc = iscsi_exec_mgmt_tasks(conn); + if (rc) + break; /* * Avoid starving the requeue list if new cmds keep coming in. * Incase the app tried to batch cmds to us, we allow up to * queueing limit. */ - cnt++; - if (cnt == conn->session->host->cmd_per_lun) { - cnt = 0; + if (*cnt == conn->session->host->cmd_per_lun) { + *cnt = 0; + + ISCSI_DBG_CONN(conn, "hit dequeue limit.\n"); - if (!list_empty(&conn->requeue)) - goto check_requeue; + rc = iscsi_exec_tasks(conn, &conn->requeue, + &conn->requeue_exec_list, + iscsi_exec_requeued_tasks); + if (rc) + break; } } + ISCSI_DBG_CONN(conn, "executed %u cmds.\n", *cnt); + return rc; +} + +/** + * iscsi_data_xmit - xmit any command into the scheduled connection + * @conn: iscsi connection + * + * Notes: + * The function can return -EAGAIN in which case the caller must + * re-schedule it again later or recover. '0' return code means + * successful xmit. + **/ +static int iscsi_data_xmit(struct iscsi_conn *conn) +{ + int rc = 0; + + spin_lock_bh(&conn->session->frwd_lock); + if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { + ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); + spin_unlock_bh(&conn->session->frwd_lock); + return -ENODATA; + } + + if (conn->task) { + rc = iscsi_xmit_task(conn, conn->task, false); + if (rc) + goto done; + } + + /* + * process mgmt pdus like nops before commands since we should + * only have one nop-out as a ping from us and targets should not + * overflow us with nop-ins + */ + rc = iscsi_exec_mgmt_tasks(conn); + if (rc) + goto done; + + rc = iscsi_exec_tasks(conn, &conn->requeue, &conn->requeue_exec_list, + iscsi_exec_requeued_tasks); + if (rc) + goto done; + + rc = iscsi_exec_tasks(conn, &conn->cmdqueue, &conn->cmd_exec_list, + iscsi_exec_cmd_tasks); + if (rc) + goto done; + spin_unlock_bh(&conn->session->frwd_lock); return -ENODATA; @@ -1732,7 +1839,6 @@ static struct iscsi_task *iscsi_init_scsi_task(struct iscsi_conn *conn, task->last_timeout = jiffies; task->last_xfer = jiffies; task->protected = false; - INIT_LIST_HEAD(&task->running); spin_lock_bh(&task->lock); task->state = ISCSI_TASK_PENDING; @@ -1862,7 +1968,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) } } else { task = iscsi_init_scsi_task(conn, sc); - list_add_tail(&task->running, &conn->cmdqueue); + llist_add(&task->queue, &conn->cmdqueue); iscsi_conn_queue_work(conn); } @@ -2028,6 +2134,8 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error) .data = &error, }; + /* Make sure we don't leave cmds in the queues */ + iscsi_move_all_tasks(conn); iscsi_conn_for_each_sc(conn, &iter_data); } @@ -2381,7 +2489,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt); spin_lock_bh(&task->lock); - if (task->state == ISCSI_TASK_PENDING) { + /* + * If we haven't sent the cmd, but it's still on the cmdqueue we + * don't have an easy way to dequeue that single cmd here. + * iscsi_check_tmf_restrictions will end up handling it. + */ + if (task->state == ISCSI_TASK_PENDING && !list_empty(&task->running)) { spin_unlock_bh(&task->lock); fail_scsi_task(task, DID_ABORT); @@ -3174,9 +3287,12 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, timer_setup(&conn->transport_timer, iscsi_check_transport_timeouts, 0); - INIT_LIST_HEAD(&conn->mgmtqueue); - INIT_LIST_HEAD(&conn->cmdqueue); - INIT_LIST_HEAD(&conn->requeue); + init_llist_head(&conn->cmdqueue); + init_llist_head(&conn->requeue); + INIT_LIST_HEAD(&conn->cmd_exec_list); + INIT_LIST_HEAD(&conn->mgmt_exec_list); + INIT_LIST_HEAD(&conn->requeue_exec_list); + INIT_WORK(&conn->xmitwork, iscsi_xmitworker); /* allocate login_task used for the login/text sequences */ diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 358701227f7f..21579d3dc1f6 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -150,7 +150,8 @@ struct iscsi_task { spinlock_t lock; int state; refcount_t refcount; - struct list_head running; /* running cmd list */ + struct llist_node queue; + struct list_head running; void *dd_data; /* driver/transport data */ }; @@ -212,10 +213,18 @@ struct iscsi_conn { struct iscsi_task *task; /* xmit task in progress */ /* xmit */ - /* items must be added/deleted under frwd lock */ - struct list_head mgmtqueue; /* mgmt (control) xmit queue */ - struct list_head cmdqueue; /* data-path cmd queue */ - struct list_head requeue; /* tasks needing another run */ + struct llist_head cmdqueue; /* data-path cmd queue */ + struct llist_head requeue; /* tasks needing another run */ + + /* The frwd_lock is used to access these lists in the xmit and eh path */ + struct list_head cmd_exec_list; + struct list_head requeue_exec_list; + /* + * The frwd_lock is used to access this list in the xmit, eh and + * submission paths. + */ + struct list_head mgmt_exec_list; + struct work_struct xmitwork; /* per-conn. xmit workqueue */ unsigned long suspend_tx; /* suspend Tx */ unsigned long suspend_rx; /* suspend Rx */ @@ -352,8 +361,8 @@ struct iscsi_session { struct iscsi_conn *leadconn; /* leading connection */ spinlock_t frwd_lock; /* protects queued_cmdsn, * * cmdsn, suspend_bit, * - * _stage, tmf_state and * - * queues */ + * _stage, exec lists, and + * tmf_state */ /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. From patchwork Sat Apr 3 23:23:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415225 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 18FEDC433ED for ; Sat, 3 Apr 2021 23:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7F9261360 for ; Sat, 3 Apr 2021 23:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237018AbhDCXZX (ORCPT ); Sat, 3 Apr 2021 19:25:23 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55264 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236998AbhDCXZS (ORCPT ); Sat, 3 Apr 2021 19:25:18 -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 133NKHZH085514; Sat, 3 Apr 2021 23:25:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=U2mTF9UezzjXpeP+ud3NyxCmdd131DTUyBKAbOpFp5c=; b=qfnYRQMP1rG169LqjefmFL7F0JDXT79/F6MbneBA92UBVgL4+pIWQZ47kYmoSDnDvpiq Q7kYwVJZLCHXR/1H2o391krsV873Ie6UDUuCrG4dlAKVfWYLVP4fsi0Xqq1ngKwP8jc4 qpJZrhOnm/qUhmao04gbzB68iJWtdBxij6r8fHvXvgAJ8V57JTzyZ2vFKHIcjV9F7/Ki qqNeSbdu19ru27cnKvB16W1QHyVoU6/Dc1MZ7/nGxr7OE5dKhVwMT4pB1eRnW/RI8O0J FUrLuHZft+U7rszkyHHAHfXymU929a2AO/4zWdhLc1BUZ1T+Jww7TZBtabw943G5URuR 7g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37pq66rcvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:03 +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 133NKtBa117020; Sat, 3 Apr 2021 23:25:03 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvDLCdXzWmdIjYNfUqZdQ7Msou5c3Xc+H1tfNYD/zBrqjDyFkGprPuWs70AfCxtm3ngSowYIH///P2KmFPtGz0CMgGv3t+E8pJwjAnBqiUzw1qKLX46BUFE89xWMDOdec8KIItEuoyYsnL+yzNxRaOMK3NNkUJAXBTpESgMcpc11KYlEkoBoh/cYiz7GxdIq6ob74vs7QMRWUiZKf2bbsSqwISZpbeDu6j+BW5EyDxfu5r8fSutkFkVQrScmWunLJJCoWQ4FTsR9Mp3GdnIj4HtvtxNw2S9oZs74nZFHnwp6JMYkUaN2fB9WptXp2BByZrHFM6RduJcSQzkYY6JgPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U2mTF9UezzjXpeP+ud3NyxCmdd131DTUyBKAbOpFp5c=; b=PBIgkreoBIfSGk6DSKmeFEreiotdw0F1B/Y2p8JBnmXnhLgrUOPc9Qtt4JRxpsN0Buz3MFWlzDpU2QARdnSOxe1QanE7kpSFC0C+giweIh+sUTYwEtuemeBdjYAEqKJLssYqgVuCbc0ww3XRKeBiCL3uMF1XcMwudrIRibeKgO9yv3vj5oOznKoNo+5wMkmq09rg18r84QBcV1+tmdK47PSUfqfbmL7LrnMIGIeyQLdHOqyZYaGcsbyiRqTEXBeURkaASXuPKi4qPwSvvlVKMRGm2LWzkLFORUL8CKevGkf/M7sOxkrXrgMxo8K+r/aw6dXkBCwW6KLm95sf2spbWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U2mTF9UezzjXpeP+ud3NyxCmdd131DTUyBKAbOpFp5c=; b=Jr1BEcKfJzhtIZDDQdJkaDax1mgaQWSXnSe7u9Dp92QqF9Buge3dJzAf/7ApgP8udvWMTG/ghfkImw+0pwGFHrU9QlTCpJQ01x7LLkw70slKcB6YHz0C3S9QS2/Y0I7SE/TPNO3GNdbhfXGc1xezj+owuGrUQyo9yPgTEOdNghw= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:58 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:58 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 39/40] scsi: libiscsi: remove queued_cmdsn Date: Sat, 3 Apr 2021 18:23:32 -0500 Message-Id: <20210403232333.212927-40-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b85518b5-a580-488b-c9ca-08d8f6f7a4d1 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4PLf+KpJ1mISML64XMiSacpauCDk5hNfT1OmICixZzMCwpbv3yCw4vI2JZWhG4Tm4G01kaut88LD7onNOQq/CERcg+ZECQoa66aaHBJLWZt8pnngE4+3gvQup21nERLCv/YgIP8hi5yTCx7+0kJ7yKNnQ/3VdGZ5m6lqbn6MvNWjj3QKNZzwBbev2fg8oPrKdeaVHNgJxZDXKczNhY3ENqz6kuY6J38MUKsKDZ2o91TZiyIRXYu9VpAG2nZgeO+qU4q0rHCCnbnC4lf+olxqmoagWwqX7QCvY0pr01B69CqAFxfHCql08lzhQwnFIXunuXjKNyMds6z/QY5YZwQITzDZopg/8V3g7z2SFDXWqoTKx9D/whFYXiVaA5F+kxQ15tvkEN1PdhzDztrqwowDF3BNJBQkypd1pcyEHBc8yJpvyC18SBuM+FUjFPHnJH+RrUsXJbLA0WdslRqtKUrr8Ph5Oq3eCp6oPI+sE73BK9/Dtq66ilEBK26e385CIlcixcjXOWOKhL9ERn7rIkYi4hJRAYAI0QZHIdB+1JRA3945gPk9Q14C497ZcTii+iW/5OD7aCLhuwxbPtPUjaOXl0qwp+GkEeUSf8VD6ZBxHwkZdqmNX1ARIX9dIOB7/nHnOSqG0Us+qblZEDq1XhTAMB/VdYSLmAGlSALg3dvwpgOQAjg6p8omiimUGYAFdMWVoFMsw1gQYulZv3BzPrpcvA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(30864003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3895Ytg65wqzR/4tSPya7mTAnR9sXDaQMUThrjjZIs7E99EvdkF8PdNdUQsIVNh1gKyinTSp+EIco35KcJmV8mrMzweyqCZ9vCH4y+7LbbfgpzH7zs9/0x6MgN/N/cQp0edkqX2hmSiV6kG6mlmaDU7V2NRyTI8GXiQA89eMYahgMZvp+YWR+FHlFJ1kx5zFhbk7eEmgzCHI63UGwsVJxzbiIPpVjT49hxYLWkZmlYUPMuDylfackdmarKWqd/dJgURxVt6xYw2mVuU0JEaeEpo0QvzpL5WKPe6xaLnbpHqZhfRUxkNqg47p55t3RzBU1pw6Nnx8xLJsseHOuRiEASjcDMUg6aua1c43kkw7JCxzKG51ShSlp9TtBONNF1bm/BGEv8bu3YSj23x2j4ySm4pwp5ptmuskr348AlZoRZ5dazGOJnwGDjL5f7nLmHoO50eGOCi7ZPC/4/GQi/rigSakVsCBTGrEcgFmm0eh3urvnwirgOVX0SPY/6loALLf//u2izo7iIcwU7WFUX04KL+wSIjHJbI2ZhfCbfhjPjPPPctnw03Md/NS5aVYjN+QeR1CFH5FTen5SBtMITsoAo+mb82nY12/WBpXPR36LgGbnjTcBFdXrs4wXbFo4Skratl7h5Vv38Yal3/WVKUhN2gE7mVPgm80TQgmnSne/WVSlhngYGfNEZNuCHqpnDcitp9NBL/1EjjaghGxTVhAzew5FTMXNZA/ObR03CRpEnBr3mFesV4ANNMjIbrypKb/1w7zEm2PElSfsqAubUnYN+rLBXvXJqousTWjwuZyXG01mJ6d2K+7iK0AdiQ44OwCbp/kGC3VuY/fuufFMdEJxiiYG6HRwE4J0iGbrB7/M+XxpzUpVn01Cej8VmEtYVLNKvXzyG/l9fsXANwclNWZfDK18YpI1VsB++uo+8zjxNZ0rE4wkSqS4RQxizElhdF8HuFUgqni8GuIyvHMHjRm3sLlsyhs6lKbEYUGA68mv9Am69ISb1WMacR1UfFkR8+BlcgksvLTNRFYNv3zeItj/mR+kha5R03ei0MycLPKVzTxrQmqwSqf0i4RSX08lMLO4DDMDEomKMdlj1Ogxer3jVeFrdaYiOdnJS7tlK/2ZRDfSO368G61dRlnZ3UPgGGf3/om5k4e6wGEhRIPNhKUbcWg0cbN36855jbMNTsmTHUBN8jYcPJ8WBCgiN8gnVqt3nGd9QjeyZ36W66sYhTUT2tSfQ0BMX8eDWJVSMwpsseZFKZ8bc3OtRPKnvFBdqE+Ku+h4EiP3l08gtfzIVZVQf9FYPCPgKzQM3h3OxVJAmLY/d3DgwnsZ2cYBjqDUTnW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b85518b5-a580-488b-c9ca-08d8f6f7a4d1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:35.6991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LIEu+YBT1ovRhbRQeeFa3tf6poEmT5iyRcU3+PjCKMopBMGtVY9zClNa2egwJmy16OMBtyqyPSUnysj9O6CfQfkwx1A+OTQ2Tj/B8XzEI2o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: kyB9S4RlPtsdcr5ies48I56LuPhzGjPh X-Proofpoint-GUID: kyB9S4RlPtsdcr5ies48I56LuPhzGjPh X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org queue_cmdsn was meant to prevent cmds from sitting in the cmdqueue too long, but iscsi_eh_cmd_timed_out already handles this. By dropping it and moving the window check to iscsi_data_xmit we will no longer need the frwd lock for the cmdsn for the iscsi xmit wq based drivers. We also get the benefit that we can detect when nops open the window, and IOPs seems to have gone up for the cases we are hitting the window limit. Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 116 +++++++++++++++++++----------------- drivers/scsi/libiscsi_tcp.c | 4 +- include/scsi/libiscsi.h | 12 ++-- 3 files changed, 68 insertions(+), 64 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 1b4b6ee246cf..dd1e1963dd05 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -93,9 +93,30 @@ inline void iscsi_conn_queue_work(struct iscsi_conn *conn) } EXPORT_SYMBOL_GPL(iscsi_conn_queue_work); -static void __iscsi_update_cmdsn(struct iscsi_session *session, - uint32_t exp_cmdsn, uint32_t max_cmdsn) +static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) { + struct iscsi_session *session = conn->session; + + /* make sure we see the updated SNs */ + smp_rmb(); + /* + * Check for iSCSI window and take care of CmdSN wrap-around + */ + if (!iscsi_sna_lte(session->cmdsn, session->max_cmdsn)) { + ISCSI_DBG_SESSION(session, "iSCSI CmdSN closed. ExpCmdSn %u MaxCmdSN %u CmdSN %u\n", + session->exp_cmdsn, session->max_cmdsn, + session->cmdsn); + return -ENOSPC; + } + return 0; +} + +static void __iscsi_update_cmdsn(struct iscsi_conn *conn, uint32_t exp_cmdsn, + uint32_t max_cmdsn) +{ + struct iscsi_session *session = conn->session; + bool win_was_closed = false; + /* * standard specifies this check for when to update expected and * max sequence numbers @@ -109,14 +130,24 @@ static void __iscsi_update_cmdsn(struct iscsi_session *session, session->exp_cmdsn = exp_cmdsn; if (max_cmdsn != session->max_cmdsn && - !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) + !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) { + + if (iscsi_check_cmdsn_window_closed(conn)) + win_was_closed = true; + session->max_cmdsn = max_cmdsn; + /* Make sure we see the max_cmdsn from the xmit/queue paths */ + smp_wmb(); + + if (win_was_closed) + iscsi_conn_queue_work(conn); + } spin_unlock_bh(&session->back_cmdsn_lock); } -void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) +void iscsi_update_cmdsn(struct iscsi_conn *conn, struct iscsi_nopin *hdr) { - __iscsi_update_cmdsn(session, be32_to_cpu(hdr->exp_cmdsn), + __iscsi_update_cmdsn(conn, be32_to_cpu(hdr->exp_cmdsn), be32_to_cpu(hdr->max_cmdsn)); } EXPORT_SYMBOL_GPL(iscsi_update_cmdsn); @@ -429,14 +460,15 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) spin_unlock_bh(&task->lock); session->cmdsn++; + /* make sure window checkers see the update */ + smp_wmb(); conn->scsicmd_pdus_cnt++; ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x " "itt 0x%x len %d cmdsn %d win %d]\n", sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read", conn->id, sc, sc->cmnd[0], - task->itt, transfer_length, - session->cmdsn, + task->itt, transfer_length, session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); return 0; } @@ -547,7 +579,7 @@ void iscsi_complete_scsi_task(struct iscsi_task *task, ISCSI_DBG_SESSION(conn->session, "[itt 0x%x]\n", task->itt); conn->last_recv = jiffies; - __iscsi_update_cmdsn(conn->session, exp_cmdsn, max_cmdsn); + __iscsi_update_cmdsn(conn, exp_cmdsn, max_cmdsn); iscsi_finish_task(task, ISCSI_TASK_COMPLETED); } EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task); @@ -593,7 +625,6 @@ static bool cleanup_queued_task(struct iscsi_task *task) */ static void fail_scsi_task(struct iscsi_task *task, int err) { - struct iscsi_conn *conn = task->conn; struct scsi_cmnd *sc; int state; @@ -603,15 +634,8 @@ static void fail_scsi_task(struct iscsi_task *task, int err) return; } - if (task->state == ISCSI_TASK_PENDING) { - /* - * cmd never made it to the xmit thread, so we should not count - * the cmd in the sequencing - */ - conn->session->queued_cmdsn--; - /* it was never sent so just complete like normal */ - state = ISCSI_TASK_COMPLETED; - } else if (err == DID_TRANSPORT_DISRUPTED) + if (task->state == ISCSI_TASK_PENDING || + err == DID_TRANSPORT_DISRUPTED) state = ISCSI_TASK_COMPLETED; else state = ISCSI_TASK_ABRT_TMF; @@ -652,7 +676,6 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, */ if (conn->c_stage == ISCSI_CONN_STARTED && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) { - session->queued_cmdsn++; session->cmdsn++; } } @@ -838,7 +861,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, struct iscsi_session *session = conn->session; struct scsi_cmnd *sc = task->sc; - iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)rhdr); conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; sc->result = (DID_OK << 16) | rhdr->cmd_status; @@ -938,7 +961,7 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, if (!(rhdr->flags & ISCSI_FLAG_DATA_STATUS)) return; - iscsi_update_cmdsn(conn->session, (struct iscsi_nopin *)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); sc->result = (DID_OK << 16) | rhdr->cmd_status; conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW | @@ -1258,7 +1281,7 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, opcode, conn->id, task ? task->itt : ~0U, datalen); if (!task) { - iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); switch(opcode) { case ISCSI_OP_NOOP_IN: @@ -1303,7 +1326,7 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, iscsi_data_in_rsp(conn, hdr, task); break; case ISCSI_OP_LOGOUT_RSP: - iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); if (datalen) { rc = ISCSI_ERR_PROTO; break; @@ -1312,14 +1335,14 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, goto recv_pdu; case ISCSI_OP_LOGIN_RSP: case ISCSI_OP_TEXT_RSP: - iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); /* * login related PDU's exp_statsn is handled in * userspace */ goto recv_pdu; case ISCSI_OP_SCSI_TMFUNC_RSP: - iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); if (datalen) { rc = ISCSI_ERR_PROTO; break; @@ -1329,7 +1352,7 @@ int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, iscsi_finish_task(task, ISCSI_TASK_COMPLETED); break; case ISCSI_OP_NOOP_IN: - iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)hdr); if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || datalen) { rc = ISCSI_ERR_PROTO; break; @@ -1479,23 +1502,6 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) } EXPORT_SYMBOL_GPL(iscsi_conn_failure); -static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) -{ - struct iscsi_session *session = conn->session; - - /* - * Check for iSCSI window and take care of CmdSN wrap-around - */ - if (!iscsi_sna_lte(session->queued_cmdsn, session->max_cmdsn)) { - ISCSI_DBG_SESSION(session, "iSCSI CmdSN closed. ExpCmdSn " - "%u MaxCmdSN %u CmdSN %u/%u\n", - session->exp_cmdsn, session->max_cmdsn, - session->cmdsn, session->queued_cmdsn); - return -ENOSPC; - } - return 0; -} - static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, bool was_requeue) { @@ -1706,6 +1712,10 @@ static int iscsi_exec_cmd_tasks(struct iscsi_conn *conn, unsigned int *cnt) int rc = 0; while (!list_empty(&conn->cmd_exec_list)) { + rc = iscsi_check_cmdsn_window_closed(conn); + if (rc) + return rc; + task = list_entry(conn->cmd_exec_list.next, struct iscsi_task, running); list_del_init(&task->running); @@ -1934,14 +1944,14 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto fault; } - spin_lock_bh(&session->frwd_lock); - if (iscsi_check_cmdsn_window_closed(conn)) { - spin_unlock_bh(&session->frwd_lock); - reason = FAILURE_WINDOW_CLOSED; - goto reject; - } - if (!ihost->workq) { + spin_lock_bh(&session->frwd_lock); + if (iscsi_check_cmdsn_window_closed(conn)) { + spin_unlock_bh(&session->frwd_lock); + reason = FAILURE_WINDOW_CLOSED; + goto reject; + } + if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { spin_unlock_bh(&session->frwd_lock); reason = FAILURE_SESSION_IN_RECOVERY; @@ -1966,14 +1976,13 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) reason = FAILURE_SESSION_NOT_READY; goto prepd_reject; } + spin_unlock_bh(&session->frwd_lock); } else { task = iscsi_init_scsi_task(conn, sc); llist_add(&task->queue, &conn->cmdqueue); iscsi_conn_queue_work(conn); } - session->queued_cmdsn++; - spin_unlock_bh(&session->frwd_lock); return 0; prepd_reject: @@ -3157,7 +3166,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->abort_timeout = 10; session->scsi_cmds_max = scsi_cmds; session->cmds_max = scsi_cmds + ISCSI_INFLIGHT_MGMT_MAX; - session->queued_cmdsn = session->cmdsn = initial_cmdsn; + session->cmdsn = initial_cmdsn; session->exp_cmdsn = initial_cmdsn + 1; session->max_cmdsn = initial_cmdsn + 1; session->max_r2t = 1; @@ -3409,7 +3418,6 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) spin_lock_bh(&session->frwd_lock); conn->c_stage = ISCSI_CONN_STARTED; WRITE_ONCE(session->state, ISCSI_STATE_LOGGED_IN); - session->queued_cmdsn = session->cmdsn; conn->last_recv = jiffies; conn->last_ping = jiffies; diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 92e84a19b100..c38e39b1546a 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -496,7 +496,7 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task) * is status. */ if (!(rhdr->flags & ISCSI_FLAG_DATA_STATUS)) - iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)rhdr); if (tcp_conn->in.datalen == 0) return 0; @@ -559,7 +559,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) tcp_conn = conn->dd_data; rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr; /* fill-in new R2T associated with the task */ - iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr); + iscsi_update_cmdsn(conn, (struct iscsi_nopin *)rhdr); if (tcp_conn->in.datalen) { iscsi_conn_printk(KERN_ERR, conn, diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 21579d3dc1f6..12bdaee3b87e 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -310,10 +310,7 @@ struct iscsi_session { spinlock_t back_cmdsn_lock; uint32_t exp_cmdsn; uint32_t max_cmdsn; - uint32_t cmdsn; - /* This tracks the reqs queued into the initiator */ - uint32_t queued_cmdsn; /* configuration */ int abort_timeout; @@ -359,10 +356,9 @@ struct iscsi_session { struct iscsi_transport *tt; struct Scsi_Host *host; struct iscsi_conn *leadconn; /* leading connection */ - spinlock_t frwd_lock; /* protects queued_cmdsn, * - * cmdsn, suspend_bit, * - * _stage, exec lists, and - * tmf_state */ + spinlock_t frwd_lock; /* protects cmdsn for offload,* + * suspend_bit, _stage, exec * + * lists, and tmf_state */ /* * frwd_lock must be held when transitioning states, but not needed * if just checking the state in the scsi-ml or iscsi callouts. @@ -474,7 +470,7 @@ extern void iscsi_conn_queue_work(struct iscsi_conn *conn); /* * pdu and task processing */ -extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *); +extern void iscsi_update_cmdsn(struct iscsi_conn *conn, struct iscsi_nopin *hdr); extern void iscsi_prep_data_out_pdu(struct iscsi_task *task, struct iscsi_r2t_info *r2t, struct iscsi_data *hdr); From patchwork Sat Apr 3 23:23:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 415094 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, 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 544C6C433B4 for ; Sat, 3 Apr 2021 23:25:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27F2A61360 for ; Sat, 3 Apr 2021 23:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237021AbhDCXZY (ORCPT ); Sat, 3 Apr 2021 19:25:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46058 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237004AbhDCXZS (ORCPT ); Sat, 3 Apr 2021 19:25:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 133NOwFC041952; Sat, 3 Apr 2021 23:25:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=dsUkDGQV4RH0svfHIoEeCzwNZZ9V58taf8GYaJqCESs=; b=Tv3gScnvG4ulnRz4F0fLn8uKXsqwtDmXY8XLuW+2Ak43iPc73R67TvMzuFashlixEL82 zDWIvwHqySvao4J68m2zwzsxjR3YGusuyQWXYsWG/Srak1xx2hbQEtSobOSj+cbyXZ5K VNhtUTaHRNkxRV6Ohv+u2Scc6Vc9ECYe339p89quOoDC8bLkwNVBEWgDgJygvt5C4xEV RufSAfktuzcMOQEPQDbP8slt5cnQGYwBWc1cgR5k2e/ThyOSwjSHJQVzgIsDmkR/nnMR NdqImFoL5kUBKc3n2vcHV99ToBh9poQSxgj7RwOf5oP2mcRGSKuJQgcEvrjWs4SEQAHv hw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37pfsrrsha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:04 +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 133NKtBb117020; Sat, 3 Apr 2021 23:25:04 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3020.oracle.com with ESMTP id 37pfpkbt0w-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Apr 2021 23:25:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ct4kGYSxL/lX0+HgJMxWjc3knecE4st/b7NShOgk63JstR8Jlpd2ZmjQpC4o6lO2QG3/Sh1RbIQYHk8QjUclMMraacbh8quWGyMrOYBWxGEK+dkBb9eBnU48ojlcbyaFubfqu5uXZLeTqWLl9Nzb3zKe0olOY4J8yh8YPdxDNwQ0S3gPd3edkNy709cL2Sh9oGTVcfiL4Er0elSQevzK1N3USj/2ZUCSY5NY1jM+VyNVjdnBrOzzl8G7+cYXnFnyKVQULZGc8/0MGW5ueXKcSx2cYqMJZmitTOt9LQMLbXG2mcrxoEz6hnGmu1OW0Z9948th/Ib0cHuWVFlTwUOWqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dsUkDGQV4RH0svfHIoEeCzwNZZ9V58taf8GYaJqCESs=; b=GLGHUNuFH0DhEgqeIGCZxHxH4CWT0XRSlMSzRtXUX5wlLOdunNSgxQQMFJThuLYTr3L0WPo47HmbeSJ3Xr4dEiRKPSol1AnaBIt/GQjGYFELeSaO0VDWWhKN2mFzuD9O0puQvDBe85JLztuoF0Y+r+Wfchx8TQq9pwStosHibNCmg+DPhO/DGVIKXqni2qSGVpQkvkI6LWR1ASWWYFFrXty6TTOa2F4E95f2G4hSx0n3uNA/w7+ulCrrCG2xU+QuzD0ajjTOUhFt+lLeO4I4r9Ep65mvWkvXT+c9Sxe6PjFOIkXjAAmULvEs6y9K+QgRTWG1+NwQCoBdno8r1PSTAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dsUkDGQV4RH0svfHIoEeCzwNZZ9V58taf8GYaJqCESs=; b=kjuZ/Gsk88GkbEmowwq0DIn//6T8vfz2CJvipxkujadbENotwKKGxKhiqwN815nFJ/7VR/FN/di/fReKEQYCBIeCfUpX79lRTt4Bhkp9M0nYxwBO4kyLyjxXdCrqEVSJ+/722RdcMwg21EKWLTyLqUuNmyy9J+gS+Pl01V4mUcE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Sat, 3 Apr 2021 23:24:58 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.3999.032; Sat, 3 Apr 2021 23:24:58 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, varun@chelsio.com, subbu.seetharaman@broadcom.com, ketan.mukadam@broadcom.com, jitendra.bhivare@broadcom.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 40/40] scsi: iscsi_tcp: tell net layer we are sending multiple pdus Date: Sat, 3 Apr 2021 18:23:33 -0500 Message-Id: <20210403232333.212927-41-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403232333.212927-1-michael.christie@oracle.com> References: <20210403232333.212927-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sat, 3 Apr 2021 23:24:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11a1eaae-baac-43b5-2ded-08d8f6f7a591 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yLjpMHwRWF1jHwWIaglqaMaR0LCR98Hun/JVHPWx0u4kKenjMtYznLSkl+PohiNX+WPqHfuBpEfmGpv+verRvmAlQzI4MnzzMSpIeKIMQv/ggEuh1cXlpy3Ik/5youPcBM+/7TUXJ2t9w1gyxSeXNmTVNY1Q5ZniTnkJG9332iRQajK/UevN2tr55vVvKKowpL3o2DeGOI+s6l2J30J+Tr70U1C+JzxLrW7/rvf90XnsKT1P7SN0YBIS/t6ZlLrgk5E9qLgvFlB2kUH5f/Mqw7aLPV2j+VeP7KGnjDC0bskzd4q+3i5bkyqqeFiGMES2nKcKXVf3l7y7w9yfLkRR6RoFP1TCNc6nkD0K/3ojgLzBbohQDJn3aDbliGPYoMOhoORmIEGVCF7OnxIV9JsO6n/Ku8dbay4R7FQYnltX1LNvLMXCbB9gLrXWWsEK37KiMUoFUYngIJ5GuttVqYLfrXeAKwBVuuIxgSVMhPCTQzo0ePNRBobtsuS24uTSeRETWZ3SI3wQW/WbYokYnudKXCWDzbd0zs7VupP1tLunOCt5cc0E+5dlD0LBwrA9NWPPDT0fKEB99jleQFw+hdWart6n60l2o7P3bSEdsfibKyI+pS9F5T3nI0Qt657SEUH0nM8e64fZmxMVEQe/eexor6+Yx15hL8slQB+yVHcKB/u0TDTVAeEkf5uuhZ5S2Tp49YDbRRZ96jcMGT26XfZBvQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(376002)(366004)(346002)(396003)(39860400002)(8676002)(186003)(8936002)(6512007)(2906002)(956004)(107886003)(66946007)(1076003)(5660300002)(26005)(16526019)(83380400001)(52116002)(36756003)(6486002)(7416002)(86362001)(316002)(478600001)(38100700001)(69590400012)(66476007)(6506007)(66556008)(2616005)(921005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0YBCa06dZ7d9NoZmGJOp5N2ORi2/vW47km2njuGYmYYyskR1fbEKPJBFNxKKGiBSPMXW5K5lJGOmdZiKBLQkYji876d6776eSW13uOpO/qFgQAwcFDXMHywWEtlOfV1kz1055EAYvfdOCCHyEvG4TEPopsZqDTH/xt5GhjdUKz1RFxF9UF7h5BI829+ITQMfeHJhOx0znC+fTpvFO5iGGTwpslSUJUFC39ZrhMzYvSs2qJbM5ZaWb+bKLoSPP8QSlfdnKiqZizS8oF8HV3D9MJyo7FkOrDHoqdifWXR9KwR8KkG2S3Vj1zy8usXBMOmjMYfF1LA8bgIQg9jDvVyCgtzcpN/czxMtpIwWfwNMcjAdiQgC5JF2aU/p9NmJPsTTFSRFAJfZA5nwmcKXncDp8h88e5dn/xaXF0l1fLs7Myr8Z/9/sZGowsXnF8wjhwQ1Oighsj+a1crjDG5K5SNfMsE11Z5y2VbX0VpPpvMLnfHXB5LM+xqLihoftdlTyra/isoasOR2Fv9xadEFdfAJ+1xLfmHCle1zz644p7QWwtoeFgo88Nmg8X7u3IUUSQtLUmJL0XJAYCJWvlyMOfA9RakkFDHWFgw3vwysVPkDnPvRS8Id3IPOpwJrqC2Nq3QR6nbsgAi2EathAZdAIafh3zoLWSS17ipFP/bJuPNb+lGVpMdZR14KA2Cy9/hcFlzpPTZsnR/zHYoJlOzVZf/H9n+DLQ+Lx+MtURu8M4qZb8aMXu7imxYOvT+19U8qzevtCln9DMw9Yh9q24Sayi/d4rps0NplpZn68ur6Agg1yuucVAMZZ5dIxeDgG+05TA8TbOQ4uR+4ymqMckHQ8anVU9njZgBqg/dMit0JtmTKodvByUgfY7tnKzVj+NDMC20oLyhtE7b6gcMfNmu2xd/2c7+BkaXR2vcHiW1OQNO0FhSVvCwhmGq11i+jeDUV0BtM1rhNWw0PHmok74pwxdzgPqPzeNVHPnzyR2K+5eIniT6uJ300fdckkKIvPZW4k2w2gtRczt8lRn8IUChQBlgtHjlrZxIYR5nfnNRI3Z8phBQALWkqWD0VfcWEJuzBw30twKmjVZA+LZr93+f3pGUzVXEq+b/PCkVBbLiCdGvb1QcynTwQMcp224XeoyAryEF0SiQCeg7zD++56x+Gwclj17rQplZR+vQmaf7Q6RmTMGvyZSgxghovImGP4eEkOT/M2n6CyY6Yl3GQRjMNMLel/KV8TIma7bXYd4t/rQhjTej1pJoUiQ2S8dUNn2NJUJZybJuszvAkJaUKtjXE5x3KWHznZmtpr8fVDLwaLTp7NCuC6hYjsAkzqbmBrGi7/rpz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11a1eaae-baac-43b5-2ded-08d8f6f7a591 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2021 23:24:36.9514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bld4gT63DuHpSt4/f3DOUPOvMakRxeLEXVPxb/5cFrxD1NViBp4O0bm6hTsxG4PQCDQTxcKElkr09Wr9yRNPomODsd4EuyLuI/aoIq0Zivw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 X-Proofpoint-ORIG-GUID: uwFFUEt64Tl8NyQirJVdQRJ1HuDdUno6 X-Proofpoint-GUID: uwFFUEt64Tl8NyQirJVdQRJ1HuDdUno6 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9943 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103310000 definitions=main-2104030165 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If we are executing a multiple pdu sequence, tell the network layer we will have more data. This also sets MSG_MORE if the app batched cmds and we know we have more than one that are going to be sent. Signed-off-by: Mike Christie --- drivers/scsi/iscsi_tcp.c | 16 +++++++++++----- drivers/scsi/libiscsi.c | 10 ++++++++++ include/scsi/libiscsi.h | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index eff5f8456ced..a85688d7ae2b 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -246,7 +246,8 @@ iscsi_sw_tcp_conn_restore_callbacks(struct iscsi_conn *conn) /** * iscsi_sw_tcp_xmit_segment - transmit segment * @tcp_conn: the iSCSI TCP connection - * @segment: the buffer to transmnit + * @task: iscsi task we are transmitting data for + * @segment: the buffer to transmit * * This function transmits as much of the buffer as * the network layer will accept, and returns the number of @@ -257,6 +258,7 @@ iscsi_sw_tcp_conn_restore_callbacks(struct iscsi_conn *conn) * it will retrieve the hash value and send it as well. */ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, + struct iscsi_task *task, struct iscsi_segment *segment) { struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; @@ -273,7 +275,10 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, offset = segment->copied; copy = segment->size - offset; - if (segment->total_copied + segment->size < segment->total_size) + if (segment->total_copied + segment->size < + segment->total_size || + !(task->hdr->flags & ISCSI_FLAG_CMD_FINAL) || + !iscsi_xmit_list_is_empty(tcp_conn->iscsi_conn)) flags |= MSG_MORE; /* Use sendpage if we can; else fall back to sendmsg */ @@ -304,8 +309,9 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, /** * iscsi_sw_tcp_xmit - TCP transmit * @conn: iscsi connection + * @task: iscsi task to send data for **/ -static int iscsi_sw_tcp_xmit(struct iscsi_conn *conn) +static int iscsi_sw_tcp_xmit(struct iscsi_conn *conn, struct iscsi_task *task) { struct iscsi_tcp_conn *tcp_conn = conn->dd_data; struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; @@ -314,7 +320,7 @@ static int iscsi_sw_tcp_xmit(struct iscsi_conn *conn) int rc = 0; while (1) { - rc = iscsi_sw_tcp_xmit_segment(tcp_conn, segment); + rc = iscsi_sw_tcp_xmit_segment(tcp_conn, task, segment); /* * We may not have been able to send data because the conn * is getting stopped. libiscsi will know so propagate err @@ -382,7 +388,7 @@ static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) noreclaim_flag = memalloc_noreclaim_save(); while (iscsi_sw_tcp_xmit_qlen(conn)) { - rc = iscsi_sw_tcp_xmit(conn); + rc = iscsi_sw_tcp_xmit(conn, task); if (rc == 0) { rc = -EAGAIN; break; diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index dd1e1963dd05..168afcb63bcf 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1609,6 +1609,16 @@ static bool iscsi_move_tasks(struct llist_head *submit_queue, return !list_empty(exec_queue); } +inline bool iscsi_xmit_list_is_empty(struct iscsi_conn *conn) +{ + if (!list_empty(&conn->cmd_exec_list) || + !list_empty(&conn->requeue_exec_list)) + return false; + + return true; +} +EXPORT_SYMBOL_GPL(iscsi_xmit_list_is_empty); + static void iscsi_move_all_tasks(struct iscsi_conn *conn) { iscsi_move_tasks(&conn->requeue, &conn->requeue_exec_list); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 12bdaee3b87e..f53f41f032d5 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -491,6 +491,7 @@ extern void iscsi_complete_scsi_task(struct iscsi_task *task, extern int iscsi_complete_task(struct iscsi_conn *conn, struct iscsi_task *task, struct iscsi_hdr *hdr, char *data, int datalen); extern int iscsi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd); +extern bool iscsi_xmit_list_is_empty(struct iscsi_conn *conn); struct iscsi_sc_iter_data { struct iscsi_conn *conn;