race between nvme device creation and discovery?
Daniel Wagner
dwagner at suse.de
Mon Feb 5 00:46:27 PST 2024
On Mon, Feb 05, 2024 at 04:57:24PM +0900, Hannes Reinecke wrote:
> I thought something along these lines:
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 85ab0fcf9e88..3ed706f595fe 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2845,6 +2845,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl,
> struct nvme_id_ctrl *id)
> goto out_put_subsystem;
> }
> } else {
> + dev_set_uevent_suppress(&subsys->dev, 1);
> ret = device_add(&subsys->dev);
> if (ret) {
> dev_err(ctrl->device,
> @@ -2869,6 +2870,10 @@ static int nvme_init_subsystem(struct nvme_ctrl
> *ctrl, struct nvme_id_ctrl *id)
> ctrl->subsys = subsys;
> list_add_tail(&ctrl->subsys_entry, &subsys->ctrls);
> mutex_unlock(&nvme_subsystems_lock);
> + if (!found) {
> + dev_set_uevent_suppress(&subsys->dev, 0);
> + kobject_uevent(&subsys->dev.kobj, KOBJ_ADD);
> + }
> return 0;
Unfortunatly, this fixes a different race. Not the one I reported here:
nvme/030 (ensure the discovery generation counter is updated appropriately) [failed]
runtime 0.602s ... 0.542s
--- tests/nvme/030.out 2023-08-30 10:39:08.428409596 +0200
+++ /home/wagi/work/blktests/results/nodev/nvme/030.out.bad 2024-02-05 09:44:28.768208105 +0100
@@ -1,2 +1,3 @@
Running nvme/030
+failed to lookup subsystem for controller nvme0
Test complete
More information about the Linux-nvme
mailing list