[PATCH] nvmet: Fix possible infinite loop triggered on hot namespace removal

Sagi Grimberg sagi at grimberg.me
Tue Nov 1 07:37:01 PDT 2016


>>  void nvmet_ns_disable(struct nvmet_ns *ns)
>> @@ -324,13 +324,10 @@ void nvmet_ns_disable(struct nvmet_ns *ns)
>>  	struct nvmet_subsys *subsys = ns->subsys;
>>  	struct nvmet_ctrl *ctrl;
>>
>> -	mutex_lock(&subsys->lock);
>> -	if (list_empty(&ns->dev_link)) {
>> -		mutex_unlock(&subsys->lock);
>> +	if (!test_and_clear_bit(NVMET_NS_ENABLED, &ns->flags))
>>  		return;
>> -	}
>> -	list_del_init(&ns->dev_link);
>> -	mutex_unlock(&subsys->lock);
>> +
>> +	list_del_rcu(&ns->dev_link);
>
> We'll still need the lock here, don't we?

we do... And we also need to protect with the subsys lock on
nvmet_ns_disable as a whole against concurrent enable/disable (unless
we want to add a new lock to nvmet_ns)



More information about the Linux-nvme mailing list