[PATCH] nvme: re-read ANA log on NS CHANGED AEN

Hannes Reinecke hare at suse.de
Fri Dec 4 11:32:21 EST 2020


On 12/4/20 4:20 PM, Keith Busch wrote:
> On Fri, Dec 04, 2020 at 04:03:10PM +0100, Hannes Reinecke wrote:
>> -	error = nvme_parse_ana_log(ctrl, &nr_change_groups,
>> -			nvme_update_ana_state);
>> -	if (error)
>> -		goto out_unlock;
>> +	/*
>> +	 * Don't update ANA groups if triggered by an NS CHANGED
>> +	 * AEN; we'll be rescanning all namespaces anyway afterwards.
>> +	 */
>> +	if (!test_bit(NVME_AER_NOTICE_NS_CHANGED, &ctrl->events)) {
>> +		error = nvme_parse_ana_log(ctrl, &nr_change_groups,
>> +					   nvme_update_ana_state);
>> +		if (error)
>> +			goto out_unlock;
>> +	}
>>   
>>   	/*
>>   	 * In theory we should have an ANATT timer per group as they might enter
>> @@ -557,6 +563,10 @@ static int nvme_read_ana_log(struct nvme_ctrl *ctrl)
>>   		del_timer_sync(&ctrl->anatt_timer);
>>   out_unlock:
>>   	mutex_unlock(&ctrl->ana_lock);
>> +
>> +	if (test_bit(NVME_AER_NOTICE_NS_CHANGED, &ctrl->events))
>> +		nvme_queue_scan(ctrl);
>> +
>>   	return error;
>>   }
> 
> The scan work can be started from other contexts too, so there are some
> unfortunate races here if one of those other contexts clears ctrl->events
> before the ANA work gets to see it, which then gets you back to having
> unusable namespaces when that scan work uses a stale ana log.
> 
Maybe this on top?

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 27be05ef0ed7..83e28fb9fba4 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -114,6 +114,10 @@ static void nvme_set_queue_dying(struct nvme_ns *ns)

  static void nvme_queue_scan(struct nvme_ctrl *ctrl)
  {
+#ifdef CONFIG_NVME_MULTIPATH
+       if (ctrl->ana_log_buf)
+               flush_work(nvme_wq, &ctrl->ana_work);
+#endif
         /*
          * Only new queue scan work when admin and IO queues are both alive
          */


Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer



More information about the Linux-nvme mailing list