Re: [RFC PATCH 3/9] target: add helper to find se_device by dev_index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/12/2017 10:46 AM, Bart Van Assche wrote:
> On Mon, 2017-06-12 at 05:10 -0500, Mike Christie wrote:
>> +struct se_device *target_find_device(int id)
>> +{
>> +	struct se_device *dev;
>> +
>> +	mutex_lock(&g_device_mutex);
>> +	dev = idr_find(&devices_idr, id);
>> +	mutex_unlock(&g_device_mutex);
>> +	return dev;
>> +}
>> +EXPORT_SYMBOL(target_find_device);
> 
> Hello Mike,

Hey,

> 
> Since target_find_device() does not increase any reference count, how is code
> that uses the return value of target_find_device() protected against concurrent
> removal of the returned device?
> 

I am still working on that.

For the target_core_user case, we control the lifetime (we are blocking
in the addition/deletion operations and using in there) or we are using
it in a place where we have a refcount (configfs command route) to it so
it will not be deleted under us.

For the xcopy use, I was still trying to figure out how that worked
before my patches. target_xcopy_locate_se_dev_e4 would return a device
under the g_device_mutex but I could not figure out how it was protected
from removal after that mutex was dropped.
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux