Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4045921rwi; Sat, 22 Oct 2022 04:23:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MdN0HqjP9m/E2KmHNE3AueZFifuY5xGl1muuZe4e+hWKWAXC8crpqreX7iXN6BO+75uEA X-Received: by 2002:a17:902:ce09:b0:178:bb78:49a5 with SMTP id k9-20020a170902ce0900b00178bb7849a5mr24118713plg.100.1666437815663; Sat, 22 Oct 2022 04:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666437815; cv=none; d=google.com; s=arc-20160816; b=hur/vaYdK4BskeFjVwIbLE9/cZqp87tEUJdwCoUxwr8g8f5CH4LASvkBKr1oWoy+41 U91VjhsEDFj/nIMqUXmE92rzJlxErDDj3A4oITh9FHTudGaW0kXcWVq5HoEyN9K0D89J FFtwPNE6MVXD4yCxhPELTM9p+SNXkq23tohbgUJxHU9eUewEc49SBwHsOWyQ1AzMnRCZ U2ChPDP0ABYO/vOeDDXhVkX43z10iuyuR2uler0AgvjD5QrIMd6pG3/mr1JcVNJ8w/0G RTIjD3nm2kk+HWoODO/icFLMXTBZ6Sr0FB4g4yNK1LULMZ76uXeb5GKiB4w3Ueag/5dM /jmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=desNJs9AUSp8zxleHiGDV/sX6RxWTQrr8O/nZpujTOg=; b=YuBHQ4Y1q8K9D7HmwdPLMGMAE5sd/lRUfScyuiRSTBbK/PMyQ2DYr+ZLPHyNByF6z+ qoA7FHDhiERi9owSKgok3F8kvSicQ/sw07GPxUc0XvW5+4WdUvNvOSEmFfimmHQO+u3D VxY7fT1htIYmGepV0R5NlNPHy4IeVisBqWlf16oj+nqWW4KvEGJeWsbwX6wJHtLUX5O1 hdNl3NcRk91dX7m9thaoSvSYehb4kFnv1Ur8MAHYF4hgypNsWQrQFzWudj2n0RL7Y/wO R1OQqiMk2Fx9f9pr5aRXXP//z9/J4i2r8hgLCLWWu22WY5Le76mPHhv24YohQmifM5gI otFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a170902eb8c00b00186748fe8e8si5333375plg.188.2022.10.22.04.23.23; Sat, 22 Oct 2022 04:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbiJVKta (ORCPT + 99 others); Sat, 22 Oct 2022 06:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231166AbiJVKtH (ORCPT ); Sat, 22 Oct 2022 06:49:07 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242CE31CB51; Sat, 22 Oct 2022 03:06:07 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Mvbpz29nhzJn7x; Sat, 22 Oct 2022 17:37:47 +0800 (CST) Received: from dggpemm500017.china.huawei.com (7.185.36.178) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 22 Oct 2022 17:40:22 +0800 Received: from [10.174.178.220] (10.174.178.220) by dggpemm500017.china.huawei.com (7.185.36.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 22 Oct 2022 17:40:21 +0800 Message-ID: <2adeb439-646b-ebb1-b266-c3ed4750eac2@huawei.com> Date: Sat, 22 Oct 2022 17:40:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v4] scsi:iscsi: Fix multiple iscsi session unbind event sent to userspace Content-Language: en-US To: Mike Christie , Lee Duncan , Chris Leech , "James E . J . Bottomley" , "Martin K . Petersen" , , CC: Steffen Maier , , References: <20221021235754.1968981-1-haowenchao@huawei.com> From: Wenchao Hao In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggpeml100008.china.huawei.com (7.185.36.48) To dggpemm500017.china.huawei.com (7.185.36.178) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/10/22 1:24, Mike Christie wrote: > On 10/21/22 6:57 PM, Wenchao Hao wrote: >> + >> int iscsi_session_chkready(struct iscsi_cls_session *session) >> { >> int err; >> @@ -1899,6 +1922,7 @@ static void __iscsi_unblock_session(struct work_struct *work) >> cancel_delayed_work_sync(&session->recovery_work); >> spin_lock_irqsave(&session->lock, flags); >> session->state = ISCSI_SESSION_LOGGED_IN; >> + session->target_state = ISCSI_SESSION_TARGET_BOUND; >> spin_unlock_irqrestore(&session->lock, flags); >> /* start IO */ > > Hey, > > Sorry for the late reply. > It doesn't matter. > For the initial login we have not scanned the session above, so there > is no target yet. If iscsid is restarted at this time, then iscsid wants > to sync the session and also do the initial scan. > > To handle that case and also better match the state names with the > session's target state we can: > > 1. Move the above line to iscsi_user_scan_session after we have scanned > the target. > 2. Add a new state ISCSI_SESSION_TARGET_ALLOCATED to reflect we have > allocated the target_id, but not yet scanned. > . I have some wonder about the target_id like be2iscsi which allocated from iscsi_sess_ida. Should not we get the target_id from iSCSI target? If they allocate target_id with an random value, how to handle the iscsi_user_scan_session which would check the session's target_id. I have no environment which deployed these iSCSI drivers like be2iscsi, so I can not valid my guess.