[PATCH] nvme: re-read ANA log on NS CHANGED AEN
Keith Busch
kbusch at kernel.org
Fri Dec 4 10:20:11 EST 2020
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.
More information about the Linux-nvme
mailing list