Re: [PATCH 1/1] scsi: Fix racing between dev init and dev reset
From: Miles Chen
Date: Thu Mar 03 2022 - 17:58:33 EST
Hi Alice,
> Device reset thread uses kobject_uevent_env() to get kobj.parent
> after scsi_evt_emit(), and it races with device init thread which
> calls device_add() to create kobj.parent before kobject_uevent_env().
>
> Device reset call trace:
> fill_kobj_path
> kobject_get_path
> kobject_uevent_env
> scsi_evt_emit <- add wait_event()
> scsi_evt_thread
>
> Device init call trace:
> fill_kobj_path
> kobject_get_path
> kobject_uevent_env
> device_add <- create kobj.parent
> scsi_target_add
> scsi_sysfs_add_sdev
> scsi_add_lun
> scsi_probe_and_add_lun
>
> These two jobs are scheduled asynchronously, we can't guaranteed that
> kobj.parent will be created in device init thread before device reset
> thread calls kobj_get_path().
>
> To resolve the racing issue between device init thread and device
> reset thread, we use wait_event() in scsi_evt_emit() to wait for
> device_add() to complete the creation of kobj.parent.
>
> Signed-off-by: Alice Chao <alice.chao@xxxxxxxxxxxx>
> Change-Id: I2848cf054186739d3a125a0635dbed5539557e64
please remove Change-Id here
thanks,
Miles