From: zhongjinghua <zhongjinghua@huawei.com>
To: Mike Christie <michael.christie@oracle.com>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"emilne@redhat.com" <emilne@redhat.com>,
"hare@suse.de" <hare@suse.de>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"zhangyi (F)" <yi.zhang@huawei.com>,
"yukuai (C)" <yukuai3@huawei.com>,
"houtao (A)" <houtao1@huawei.com>,
yangerkun <yangerkun@huawei.com>
Subject: 答复: [PATCH] scsi: fix iscsi rescan fails to create block
Date: Sat, 28 Jan 2023 06:51:51 +0000 [thread overview]
Message-ID: <40d06d0004354b79989168a90e5d7a60@huawei.com> (raw)
In-Reply-To: <c3bd2bf7-e174-3afd-43d2-7010d9809815@oracle.com>
Hello,
We also want to write get_device_unless_zero, I will try to make a patch.
I'm not sure if this problem exists in other places and can be fixed in this way, because we only tested this problem.
I want to fix this problem that is now tested first.
Thanks.
-----邮件原件-----
发件人: Mike Christie <michael.christie@oracle.com>
发送时间: 2023年1月19日 7:07
收件人: zhongjinghua <zhongjinghua@huawei.com>; jejb@linux.ibm.com; martin.petersen@oracle.com; bvanassche@acm.org; emilne@redhat.com; hare@suse.de
抄送: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; zhangyi (F) <yi.zhang@huawei.com>; yukuai (C) <yukuai3@huawei.com>; houtao (A) <houtao1@huawei.com>
主题: Re: [PATCH] scsi: fix iscsi rescan fails to create block
On 1/16/23 21:01, Zhong Jinghua wrote:
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 42db9c52208e..e7893835b99a 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1503,6 +1503,13 @@ void scsi_remove_device(struct scsi_device
> *sdev) } EXPORT_SYMBOL(scsi_remove_device);
>
> +static int scsi_device_try_get(struct scsi_device *sdev) {
> + if (!kobject_get_unless_zero(&sdev->sdev_gendev.kobj))
> + return -ENXIO;
> + return 0;
> +}
> +
> static void __scsi_remove_target(struct scsi_target *starget) {
> struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
> @@ -1521,9 +1528,7 @@ static void __scsi_remove_target(struct scsi_target *starget)
> if (sdev->channel != starget->channel ||
> sdev->id != starget->id)
> continue;
> - if (sdev->sdev_state == SDEV_DEL ||
> - sdev->sdev_state == SDEV_CANCEL ||
> - !get_device(&sdev->sdev_gendev))
> + if (scsi_device_try_get(sdev))
> continue;
> spin_unlock_irqrestore(shost->host_lock, flags);
> scsi_remove_device(sdev);
I think the patch will work ok. I don't think we want to mix in our own reference getting function that works on kobjects directly with the put_device use a little below that line above.
Since this is the second time (looks like Hannes was wanting one when he originally fixed this) we've wanted a get_unless_zero type function did you send Greg a get_device_unless_zero type of patch already and was that rejected?
Why doesn't scsi_forget_host have the same issue with other drivers and similar scan/delete/host-removal type of tests? Is there something that flushes those async scans? I'm just wondering if we can do something similar for the target removal or if the host removal needs a similar fix.
prev parent reply other threads:[~2023-01-28 6:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 3:01 Zhong Jinghua
2023-01-18 23:07 ` Mike Christie
2023-01-28 6:51 ` zhongjinghua [this message]
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=40d06d0004354b79989168a90e5d7a60@huawei.com \
--to=zhongjinghua@huawei.com \
--cc=bvanassche@acm.org \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=houtao1@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.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
Powered by JetHome