From: Lee Duncan <lduncan@suse.com>
To: Wenchao Hao <haowenchao@huawei.com>,
Chris Leech <cleech@redhat.com>,
Mike Christie <michael.christie@oracle.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Steffen Maier <maier@linux.ibm.com>,
liuzhiqiang26@huawei.com, linfeilong@huawei.com
Subject: Re: [PATCH v5] scsi:iscsi: Fix multiple iscsi session unbind event sent to userspace
Date: Fri, 28 Oct 2022 08:05:04 -0700 [thread overview]
Message-ID: <c90423a5-b89a-6c51-20f5-4945b85349b2@suse.com> (raw)
In-Reply-To: <79683c37-904e-562f-fc18-98ffda777d08@huawei.com>
On 10/28/22 02:45, Wenchao Hao wrote:
>
> On 2022/10/28 0:18, Lee Duncan wrote:
>> On 10/27/22 19:00, Wenchao Hao wrote:
>>> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
>>> index cd3db9684e52..2e0d1cd6d4ea 100644
>>> --- a/drivers/scsi/scsi_transport_iscsi.c
>>> +++ b/drivers/scsi/scsi_transport_iscsi.c
>>> @@ -1676,6 +1676,30 @@ static const char *iscsi_session_state_name(int state)
>>> return name;
>>> }
>>> +static struct {
>>> + int value;
>>> + char *name;
>>> +} iscsi_session_target_state_names[] = {
>>> + { ISCSI_SESSION_TARGET_UNBOUND, "UNBOUND" },
>>> + { ISCSI_SESSION_TARGET_ALLOCATED, "ALLOCATED" },
>>> + { ISCSI_SESSION_TARGET_BOUND, "BOUND" },
>>> + { ISCSI_SESSION_TARGET_UNBINDING, "UNBINDING" },
>>> +};
>>> +
>>> +static const char *iscsi_session_target_state_name(int state)
>>> +{
>>> + int i;
>>> + char *name = NULL;
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(iscsi_session_target_state_names); i++) {
>>> + if (iscsi_session_target_state_names[i].value == state) {
>>> + name = iscsi_session_target_state_names[i].name;
>>> + break;
>>> + }
>>> + }
>>> + return name;
>>> +}
>>
>> It seems like it might be more efficient to use the target state as the array index, so you don't have to loop to find the name, e.g. something like:
>>
>>> static char* iscsi_session_target_state_names[] = {
>>> .ISCSI_SESSION_TARGET_UNBOUND = "UNBOUND",
>>> .ISCSI_SESSION_TARGET_ALLOCATED = "ALLOCATED",
>>> .ISCSI_SESSION_TARGET_BOUND = "BOUND",
>>> .ISCSI_SESSION_TARGET_UNBINDING = "UNBINDING",
>>> };
>>
>> I know there are only 4 states, and it's only used for sysfs, so not sure it matters much.
>>
>
> It's a better implement, I would update it.
>
>>> @@ -1961,6 +1987,15 @@ static void __iscsi_unbind_session(struct work_struct *work)
>>> unsigned long flags;
>>> unsigned int target_id;
>>> + spin_lock_irqsave(&session->lock, flags);
>>> + if (session->target_state != ISCSI_SESSION_TARGET_BOUND) {
>>> + spin_unlock_irqrestore(&session->lock, flags);
>>> + ISCSI_DBG_TRANS_SESSION(session, "Abort unbind sesison\n");
>>
>> It'd be nice if this said more, since debugging "Abort unbind sessions" would require finding the sources. How about "Abort unbind session: not bound", for example?
>>
>
> Of course, I would updated.
>
>>> @@ -264,6 +271,7 @@ struct iscsi_cls_session {
>>> */
>>> pid_t creator;
>>> int state;
>>> + int target_state; /* session target bind state */
>>> int sid; /* session id */
>>> void *dd_data; /* LLD private data */
>>> struct device dev; /* sysfs transport/container device */
>>
>> Thank you for sticking with this. It is very much appreciated.
>
> I should apologize for taking this issue off for a long time because of my slow response.
>
> What's more, should I add an acked-by or reviewed-by in my next patch?
Please add my Reviewed-by tag after you make these changes.
And no problem taking a while. I appreciate your effort!
--
Lee Duncan
next prev parent reply other threads:[~2022-10-28 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 2:00 Wenchao Hao
2022-10-27 16:18 ` Lee Duncan
2022-10-28 9:45 ` Wenchao Hao
2022-10-28 15:05 ` Lee Duncan [this message]
2022-11-07 12:35 ` Wenchao Hao
2022-10-27 21:02 ` Mike Christie
2022-10-28 9:49 ` Wenchao Hao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c90423a5-b89a-6c51-20f5-4945b85349b2@suse.com \
--to=lduncan@suse.com \
--cc=cleech@redhat.com \
--cc=haowenchao@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=linfeilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liuzhiqiang26@huawei.com \
--cc=maier@linux.ibm.com \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®