On Mon, Dec 09, 2019 at 10:05:39PM +0800, Anand Jain wrote: > Looked into this further, actually we don't need any lock here > the device delete thread which calls kobject_put() makes sure > sysfs read is closed. So an existing sysfs read thread will have > to complete before device free. > > > CPU1 CPU2 > > btrfs_rm_device > open file > btrfs_sysfs_rm_device_link > call read, access freed device > sysfs waits for the open file > to close. > btrfs_free_device > kfree(device) Ok, as long as this holds and sysfs file is removed before the device is freed, the locking is not necessary.
