blob: 5d7bc58a27bd984dc7f19341dcdcf1a3d3af658d [file] [log] [blame]
Christoph Hellwigbc50ad72019-02-18 09:36:29 +01001// SPDX-License-Identifier: GPL-2.0
Christoph Hellwig32acab32017-11-02 12:59:30 +01002/*
Christoph Hellwig0d0b6602018-05-14 08:48:54 +02003 * Copyright (c) 2017-2018 Christoph Hellwig.
Christoph Hellwig32acab32017-11-02 12:59:30 +01004 */
5
Keith Buschb2ce4d92020-04-09 09:09:04 -07006#include <linux/backing-dev.h>
Christoph Hellwig32acab32017-11-02 12:59:30 +01007#include <linux/moduleparam.h>
Hannes Reinecke2796b562018-06-07 10:38:47 +02008#include <trace/events/block.h>
Christoph Hellwig32acab32017-11-02 12:59:30 +01009#include "nvme.h"
10
11static bool multipath = true;
Keith Busch5cadde82018-04-26 14:24:29 -060012module_param(multipath, bool, 0444);
Christoph Hellwig32acab32017-11-02 12:59:30 +010013MODULE_PARM_DESC(multipath,
14 "turn on native support for multiple controllers per subsystem");
15
Sagi Grimbergb9156da2019-07-31 11:00:26 -070016void nvme_mpath_unfreeze(struct nvme_subsystem *subsys)
17{
18 struct nvme_ns_head *h;
19
20 lockdep_assert_held(&subsys->lock);
21 list_for_each_entry(h, &subsys->nsheads, entry)
22 if (h->disk)
23 blk_mq_unfreeze_queue(h->disk->queue);
24}
25
26void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
27{
28 struct nvme_ns_head *h;
29
30 lockdep_assert_held(&subsys->lock);
31 list_for_each_entry(h, &subsys->nsheads, entry)
32 if (h->disk)
33 blk_mq_freeze_queue_wait(h->disk->queue);
34}
35
36void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
37{
38 struct nvme_ns_head *h;
39
40 lockdep_assert_held(&subsys->lock);
41 list_for_each_entry(h, &subsys->nsheads, entry)
42 if (h->disk)
43 blk_freeze_queue_start(h->disk->queue);
44}
45
Keith Buscha785dbc2018-04-26 14:22:41 -060046/*
47 * If multipathing is enabled we need to always use the subsystem instance
48 * number for numbering our devices to avoid conflicts between subsystems that
49 * have multiple controllers and thus use the multipath-aware subsystem node
50 * and those that have a single controller and use the controller node
51 * directly.
52 */
Christoph Hellwig9953ab02021-04-07 12:46:46 +020053bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name, int *flags)
Keith Buscha785dbc2018-04-26 14:22:41 -060054{
Christoph Hellwig9953ab02021-04-07 12:46:46 +020055 if (!multipath)
56 return false;
57 if (!ns->head->disk) {
58 sprintf(disk_name, "nvme%dn%d", ns->ctrl->subsys->instance,
59 ns->head->instance);
60 return true;
Keith Buscha785dbc2018-04-26 14:22:41 -060061 }
Christoph Hellwig9953ab02021-04-07 12:46:46 +020062 sprintf(disk_name, "nvme%dc%dn%d", ns->ctrl->subsys->instance,
63 ns->ctrl->instance, ns->head->instance);
64 *flags = GENHD_FL_HIDDEN;
65 return true;
Keith Buscha785dbc2018-04-26 14:22:41 -060066}
67
Christoph Hellwig5ddaabe2020-08-18 09:11:30 +020068void nvme_failover_req(struct request *req)
Christoph Hellwig32acab32017-11-02 12:59:30 +010069{
70 struct nvme_ns *ns = req->q->queuedata;
Christoph Hellwig5ddaabe2020-08-18 09:11:30 +020071 u16 status = nvme_req(req)->status & 0x7ff;
Christoph Hellwig32acab32017-11-02 12:59:30 +010072 unsigned long flags;
Daniel Wagnerce86dad2021-05-03 19:03:03 +020073 struct bio *bio;
Christoph Hellwig32acab32017-11-02 12:59:30 +010074
Christoph Hellwig5ddaabe2020-08-18 09:11:30 +020075 nvme_mpath_clear_current_path(ns);
76
77 /*
78 * If we got back an ANA error, we know the controller is alive but not
79 * ready to serve this namespace. Kick of a re-read of the ANA
80 * information page, and just try any other available path for now.
81 */
82 if (nvme_is_ana_error(status) && ns->ctrl->ana_log_buf) {
83 set_bit(NVME_NS_ANA_PENDING, &ns->flags);
84 queue_work(nvme_wq, &ns->ctrl->ana_work);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +020085 }
86
John Meneghini764e9332020-02-20 10:05:38 +090087 spin_lock_irqsave(&ns->head->requeue_lock, flags);
Daniel Wagnerce86dad2021-05-03 19:03:03 +020088 for (bio = req->bio; bio; bio = bio->bi_next)
89 bio_set_dev(bio, ns->head->disk->part0);
John Meneghini764e9332020-02-20 10:05:38 +090090 blk_steal_bios(&ns->head->requeue_list, req);
91 spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
John Meneghini764e9332020-02-20 10:05:38 +090092
Christoph Hellwig5ddaabe2020-08-18 09:11:30 +020093 blk_mq_end_request(req, 0);
Christoph Hellwig32acab32017-11-02 12:59:30 +010094 kblockd_schedule_work(&ns->head->requeue_work);
95}
96
Christoph Hellwig32acab32017-11-02 12:59:30 +010097void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
98{
99 struct nvme_ns *ns;
100
Jianchao Wang765cc0312018-02-12 20:54:46 +0800101 down_read(&ctrl->namespaces_rwsem);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100102 list_for_each_entry(ns, &ctrl->namespaces, list) {
103 if (ns->head->disk)
104 kblockd_schedule_work(&ns->head->requeue_work);
105 }
Jianchao Wang765cc0312018-02-12 20:54:46 +0800106 up_read(&ctrl->namespaces_rwsem);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100107}
108
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200109static const char *nvme_ana_state_names[] = {
110 [0] = "invalid state",
111 [NVME_ANA_OPTIMIZED] = "optimized",
112 [NVME_ANA_NONOPTIMIZED] = "non-optimized",
113 [NVME_ANA_INACCESSIBLE] = "inaccessible",
114 [NVME_ANA_PERSISTENT_LOSS] = "persistent-loss",
115 [NVME_ANA_CHANGE] = "change",
116};
117
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700118bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
Christoph Hellwig32acab32017-11-02 12:59:30 +0100119{
Christoph Hellwigf3334442018-09-11 09:51:29 +0200120 struct nvme_ns_head *head = ns->head;
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700121 bool changed = false;
Christoph Hellwigf3334442018-09-11 09:51:29 +0200122 int node;
123
124 if (!head)
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700125 goto out;
Christoph Hellwigf3334442018-09-11 09:51:29 +0200126
127 for_each_node(node) {
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700128 if (ns == rcu_access_pointer(head->current_path[node])) {
Christoph Hellwigf3334442018-09-11 09:51:29 +0200129 rcu_assign_pointer(head->current_path[node], NULL);
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700130 changed = true;
131 }
Christoph Hellwigf3334442018-09-11 09:51:29 +0200132 }
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700133out:
134 return changed;
135}
136
137void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl)
138{
139 struct nvme_ns *ns;
140
141 mutex_lock(&ctrl->scan_lock);
Anton Eidelman763303a2019-11-01 17:27:55 -0700142 down_read(&ctrl->namespaces_rwsem);
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700143 list_for_each_entry(ns, &ctrl->namespaces, list)
144 if (nvme_mpath_clear_current_path(ns))
145 kblockd_schedule_work(&ns->head->requeue_work);
Anton Eidelman763303a2019-11-01 17:27:55 -0700146 up_read(&ctrl->namespaces_rwsem);
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700147 mutex_unlock(&ctrl->scan_lock);
Christoph Hellwigf3334442018-09-11 09:51:29 +0200148}
149
Hannes Reineckee7d65802021-08-24 16:57:42 +0200150void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
151{
152 struct nvme_ns_head *head = ns->head;
153 sector_t capacity = get_capacity(head->disk);
154 int node;
155
156 list_for_each_entry_rcu(ns, &head->list, siblings) {
157 if (capacity != get_capacity(ns->disk))
158 clear_bit(NVME_NS_READY, &ns->flags);
159 }
160
161 for_each_node(node)
162 rcu_assign_pointer(head->current_path[node], NULL);
163}
164
Hannes Reineckeca7ae5c2019-07-04 08:10:46 +0200165static bool nvme_path_is_disabled(struct nvme_ns *ns)
166{
Sagi Grimbergecca390e2020-07-22 16:32:19 -0700167 /*
168 * We don't treat NVME_CTRL_DELETING as a disabled path as I/O should
169 * still be able to complete assuming that the controller is connected.
170 * Otherwise it will fail immediately and return to the requeue list.
171 */
172 if (ns->ctrl->state != NVME_CTRL_LIVE &&
173 ns->ctrl->state != NVME_CTRL_DELETING)
174 return true;
175 if (test_bit(NVME_NS_ANA_PENDING, &ns->flags) ||
Hannes Reineckee7d65802021-08-24 16:57:42 +0200176 !test_bit(NVME_NS_READY, &ns->flags))
Sagi Grimbergecca390e2020-07-22 16:32:19 -0700177 return true;
178 return false;
Hannes Reineckeca7ae5c2019-07-04 08:10:46 +0200179}
180
Christoph Hellwigf3334442018-09-11 09:51:29 +0200181static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
182{
183 int found_distance = INT_MAX, fallback_distance = INT_MAX, distance;
184 struct nvme_ns *found = NULL, *fallback = NULL, *ns;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100185
186 list_for_each_entry_rcu(ns, &head->list, siblings) {
Hannes Reineckeca7ae5c2019-07-04 08:10:46 +0200187 if (nvme_path_is_disabled(ns))
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200188 continue;
Christoph Hellwigf3334442018-09-11 09:51:29 +0200189
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100190 if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
191 distance = node_distance(node, ns->ctrl->numa_node);
192 else
193 distance = LOCAL_DISTANCE;
Christoph Hellwigf3334442018-09-11 09:51:29 +0200194
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200195 switch (ns->ana_state) {
196 case NVME_ANA_OPTIMIZED:
Christoph Hellwigf3334442018-09-11 09:51:29 +0200197 if (distance < found_distance) {
198 found_distance = distance;
199 found = ns;
200 }
201 break;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200202 case NVME_ANA_NONOPTIMIZED:
Christoph Hellwigf3334442018-09-11 09:51:29 +0200203 if (distance < fallback_distance) {
204 fallback_distance = distance;
205 fallback = ns;
206 }
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200207 break;
208 default:
209 break;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100210 }
211 }
212
Christoph Hellwigf3334442018-09-11 09:51:29 +0200213 if (!found)
214 found = fallback;
215 if (found)
216 rcu_assign_pointer(head->current_path[node], found);
217 return found;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200218}
219
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100220static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head,
221 struct nvme_ns *ns)
222{
223 ns = list_next_or_null_rcu(&head->list, &ns->siblings, struct nvme_ns,
224 siblings);
225 if (ns)
226 return ns;
227 return list_first_or_null_rcu(&head->list, struct nvme_ns, siblings);
228}
229
230static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
231 int node, struct nvme_ns *old)
232{
Martin Wilcke3988632020-08-06 15:19:32 +0200233 struct nvme_ns *ns, *found = NULL;
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100234
Hannes Reinecke2032d072019-07-04 08:10:46 +0200235 if (list_is_singular(&head->list)) {
236 if (nvme_path_is_disabled(old))
237 return NULL;
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100238 return old;
Hannes Reinecke2032d072019-07-04 08:10:46 +0200239 }
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100240
241 for (ns = nvme_next_ns(head, old);
Daniel Wagnerd1bcf002021-01-27 11:30:33 +0100242 ns && ns != old;
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100243 ns = nvme_next_ns(head, ns)) {
Hannes Reineckeca7ae5c2019-07-04 08:10:46 +0200244 if (nvme_path_is_disabled(ns))
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100245 continue;
246
247 if (ns->ana_state == NVME_ANA_OPTIMIZED) {
248 found = ns;
249 goto out;
250 }
251 if (ns->ana_state == NVME_ANA_NONOPTIMIZED)
Martin Wilcke3988632020-08-06 15:19:32 +0200252 found = ns;
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100253 }
254
Martin Wilck93eb0382020-08-06 15:19:31 +0200255 /*
256 * The loop above skips the current path for round-robin semantics.
257 * Fall back to the current path if either:
258 * - no other optimized path found and current is optimized,
259 * - no other usable path found and current is usable.
260 */
Martin Wilck3f6e3242020-07-27 18:08:02 +0200261 if (!nvme_path_is_disabled(old) &&
Martin Wilck93eb0382020-08-06 15:19:31 +0200262 (old->ana_state == NVME_ANA_OPTIMIZED ||
Martin Wilcke3988632020-08-06 15:19:32 +0200263 (!found && old->ana_state == NVME_ANA_NONOPTIMIZED)))
Martin Wilck93eb0382020-08-06 15:19:31 +0200264 return old;
265
Martin Wilcke3988632020-08-06 15:19:32 +0200266 if (!found)
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100267 return NULL;
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100268out:
269 rcu_assign_pointer(head->current_path[node], found);
270 return found;
271}
272
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200273static inline bool nvme_path_is_optimized(struct nvme_ns *ns)
274{
275 return ns->ctrl->state == NVME_CTRL_LIVE &&
276 ns->ana_state == NVME_ANA_OPTIMIZED;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100277}
278
279inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
280{
Christoph Hellwigf3334442018-09-11 09:51:29 +0200281 int node = numa_node_id();
282 struct nvme_ns *ns;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100283
Christoph Hellwigf3334442018-09-11 09:51:29 +0200284 ns = srcu_dereference(head->current_path[node], &head->srcu);
Hannes Reineckefbd6a422020-07-27 18:08:03 +0200285 if (unlikely(!ns))
286 return __nvme_find_path(head, node);
287
288 if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
289 return nvme_round_robin_path(head, node, ns);
290 if (unlikely(!nvme_path_is_optimized(ns)))
291 return __nvme_find_path(head, node);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100292 return ns;
293}
294
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700295static bool nvme_available_path(struct nvme_ns_head *head)
296{
297 struct nvme_ns *ns;
298
299 list_for_each_entry_rcu(ns, &head->list, siblings) {
Victor Gladkov8c4dfea2020-11-24 18:34:59 +0000300 if (test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ns->ctrl->flags))
301 continue;
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700302 switch (ns->ctrl->state) {
303 case NVME_CTRL_LIVE:
304 case NVME_CTRL_RESETTING:
305 case NVME_CTRL_CONNECTING:
306 /* fallthru */
307 return true;
308 default:
309 break;
310 }
311 }
312 return false;
313}
314
Christoph Hellwig1496bd42021-04-07 14:22:12 +0200315static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
Christoph Hellwig32acab32017-11-02 12:59:30 +0100316{
Christoph Hellwig309dca302021-01-24 11:02:34 +0100317 struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100318 struct device *dev = disk_to_dev(head->disk);
319 struct nvme_ns *ns;
320 blk_qc_t ret = BLK_QC_T_NONE;
321 int srcu_idx;
322
Hannes Reinecke525aa5a2019-04-30 18:57:09 +0200323 /*
Christoph Hellwigf695ca32020-07-01 10:59:39 +0200324 * The namespace might be going away and the bio might be moved to a
325 * different queue via blk_steal_bios(), so we need to use the bio_split
326 * pool from the original queue to allocate the bvecs from.
Hannes Reinecke525aa5a2019-04-30 18:57:09 +0200327 */
Christoph Hellwigf695ca32020-07-01 10:59:39 +0200328 blk_queue_split(&bio);
Hannes Reinecke525aa5a2019-04-30 18:57:09 +0200329
Christoph Hellwig32acab32017-11-02 12:59:30 +0100330 srcu_idx = srcu_read_lock(&head->srcu);
331 ns = nvme_find_path(head);
332 if (likely(ns)) {
Christoph Hellwiga7c7f7b2021-01-26 15:33:06 +0100333 bio_set_dev(bio, ns->disk->part0);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100334 bio->bi_opf |= REQ_NVME_MPATH;
Christoph Hellwig1c02fca2020-12-03 17:21:38 +0100335 trace_block_bio_remap(bio, disk_devt(ns->head->disk),
Hannes Reinecke2796b562018-06-07 10:38:47 +0200336 bio->bi_iter.bi_sector);
Christoph Hellwig5a6c35f2020-07-01 10:59:47 +0200337 ret = submit_bio_noacct(bio);
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700338 } else if (nvme_available_path(head)) {
339 dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n");
Christoph Hellwig32acab32017-11-02 12:59:30 +0100340
341 spin_lock_irq(&head->requeue_lock);
342 bio_list_add(&head->requeue_list, bio);
343 spin_unlock_irq(&head->requeue_lock);
344 } else {
Sagi Grimberg0157ec82019-07-25 11:56:57 -0700345 dev_warn_ratelimited(dev, "no available path - failing I/O\n");
Christoph Hellwig32acab32017-11-02 12:59:30 +0100346
347 bio->bi_status = BLK_STS_IOERR;
348 bio_endio(bio);
349 }
350
351 srcu_read_unlock(&head->srcu, srcu_idx);
352 return ret;
353}
354
Christoph Hellwig1496bd42021-04-07 14:22:12 +0200355static int nvme_ns_head_open(struct block_device *bdev, fmode_t mode)
356{
357 if (!nvme_tryget_ns_head(bdev->bd_disk->private_data))
358 return -ENXIO;
359 return 0;
360}
361
362static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
363{
364 nvme_put_ns_head(disk->private_data);
365}
366
Christoph Hellwig8b4fb0f2021-05-19 09:17:06 +0200367#ifdef CONFIG_BLK_DEV_ZONED
368static int nvme_ns_head_report_zones(struct gendisk *disk, sector_t sector,
369 unsigned int nr_zones, report_zones_cb cb, void *data)
370{
371 struct nvme_ns_head *head = disk->private_data;
372 struct nvme_ns *ns;
373 int srcu_idx, ret = -EWOULDBLOCK;
374
375 srcu_idx = srcu_read_lock(&head->srcu);
376 ns = nvme_find_path(head);
377 if (ns)
378 ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
379 srcu_read_unlock(&head->srcu, srcu_idx);
380 return ret;
381}
382#else
383#define nvme_ns_head_report_zones NULL
384#endif /* CONFIG_BLK_DEV_ZONED */
385
Christoph Hellwig1496bd42021-04-07 14:22:12 +0200386const struct block_device_operations nvme_ns_head_ops = {
387 .owner = THIS_MODULE,
388 .submit_bio = nvme_ns_head_submit_bio,
389 .open = nvme_ns_head_open,
390 .release = nvme_ns_head_release,
391 .ioctl = nvme_ns_head_ioctl,
392 .getgeo = nvme_getgeo,
Christoph Hellwig8b4fb0f2021-05-19 09:17:06 +0200393 .report_zones = nvme_ns_head_report_zones,
Christoph Hellwig1496bd42021-04-07 14:22:12 +0200394 .pr_ops = &nvme_pr_ops,
395};
396
Minwoo Im2637bae2021-04-21 16:45:04 +0900397static inline struct nvme_ns_head *cdev_to_ns_head(struct cdev *cdev)
398{
399 return container_of(cdev, struct nvme_ns_head, cdev);
400}
401
402static int nvme_ns_head_chr_open(struct inode *inode, struct file *file)
403{
404 if (!nvme_tryget_ns_head(cdev_to_ns_head(inode->i_cdev)))
405 return -ENXIO;
406 return 0;
407}
408
409static int nvme_ns_head_chr_release(struct inode *inode, struct file *file)
410{
411 nvme_put_ns_head(cdev_to_ns_head(inode->i_cdev));
412 return 0;
413}
414
415static const struct file_operations nvme_ns_head_chr_fops = {
416 .owner = THIS_MODULE,
417 .open = nvme_ns_head_chr_open,
418 .release = nvme_ns_head_chr_release,
419 .unlocked_ioctl = nvme_ns_head_chr_ioctl,
420 .compat_ioctl = compat_ptr_ioctl,
421};
422
423static int nvme_add_ns_head_cdev(struct nvme_ns_head *head)
424{
425 int ret;
426
427 head->cdev_device.parent = &head->subsys->dev;
428 ret = dev_set_name(&head->cdev_device, "ng%dn%d",
429 head->subsys->instance, head->instance);
430 if (ret)
431 return ret;
432 ret = nvme_cdev_add(&head->cdev, &head->cdev_device,
433 &nvme_ns_head_chr_fops, THIS_MODULE);
434 if (ret)
435 kfree_const(head->cdev_device.kobj.name);
436 return ret;
437}
438
Christoph Hellwig32acab32017-11-02 12:59:30 +0100439static void nvme_requeue_work(struct work_struct *work)
440{
441 struct nvme_ns_head *head =
442 container_of(work, struct nvme_ns_head, requeue_work);
443 struct bio *bio, *next;
444
445 spin_lock_irq(&head->requeue_lock);
446 next = bio_list_get(&head->requeue_list);
447 spin_unlock_irq(&head->requeue_lock);
448
449 while ((bio = next) != NULL) {
450 next = bio->bi_next;
451 bio->bi_next = NULL;
452
Christoph Hellwiged00aab2020-07-01 10:59:44 +0200453 submit_bio_noacct(bio);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100454 }
455}
456
457int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
458{
Christoph Hellwig32acab32017-11-02 12:59:30 +0100459 bool vwc = false;
460
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200461 mutex_init(&head->lock);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100462 bio_list_init(&head->requeue_list);
463 spin_lock_init(&head->requeue_lock);
464 INIT_WORK(&head->requeue_work, nvme_requeue_work);
465
466 /*
467 * Add a multipath node if the subsystems supports multiple controllers.
468 * We also do this for private namespaces as the namespace sharing data could
469 * change after a rescan.
470 */
Keith Busch92decf12020-04-03 10:53:46 -0700471 if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) || !multipath)
Christoph Hellwig32acab32017-11-02 12:59:30 +0100472 return 0;
473
Christoph Hellwigf165fb82021-05-21 07:51:08 +0200474 head->disk = blk_alloc_disk(ctrl->numa_node);
475 if (!head->disk)
476 return -ENOMEM;
477 head->disk->fops = &nvme_ns_head_ops;
478 head->disk->private_data = head;
479 sprintf(head->disk->disk_name, "nvme%dn%d",
480 ctrl->subsys->instance, head->instance);
481
482 blk_queue_flag_set(QUEUE_FLAG_NONROT, head->disk->queue);
Christoph Hellwigd32d3d02021-06-14 13:17:34 +0200483 blk_queue_flag_set(QUEUE_FLAG_NOWAIT, head->disk->queue);
484
Christoph Hellwigf165fb82021-05-21 07:51:08 +0200485 /* set to a default value of 512 until the disk is validated */
486 blk_queue_logical_block_size(head->disk->queue, 512);
487 blk_set_stacking_limits(&head->disk->queue->limits);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100488
489 /* we need to propagate up the VMC settings */
490 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
491 vwc = true;
Christoph Hellwigf165fb82021-05-21 07:51:08 +0200492 blk_queue_write_cache(head->disk->queue, vwc, vwc);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100493 return 0;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100494}
495
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200496static void nvme_mpath_set_live(struct nvme_ns *ns)
Christoph Hellwig32acab32017-11-02 12:59:30 +0100497{
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200498 struct nvme_ns_head *head = ns->head;
499
Christoph Hellwig32acab32017-11-02 12:59:30 +0100500 if (!head->disk)
501 return;
Baegjae Sung9bd82b12018-02-28 16:06:04 +0900502
Minwoo Im2637bae2021-04-21 16:45:04 +0900503 if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
Hannes Reinecke33b14f672018-09-28 08:17:20 +0200504 device_add_disk(&head->subsys->dev, head->disk,
505 nvme_ns_id_attr_groups);
Minwoo Im2637bae2021-04-21 16:45:04 +0900506 nvme_add_ns_head_cdev(head);
507 }
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200508
Anton Eidelmand8a22f82020-06-24 01:53:11 -0700509 mutex_lock(&head->lock);
Keith Busch886fabf2018-10-05 09:49:37 -0600510 if (nvme_path_is_optimized(ns)) {
511 int node, srcu_idx;
512
513 srcu_idx = srcu_read_lock(&head->srcu);
514 for_each_node(node)
515 __nvme_find_path(head, node);
516 srcu_read_unlock(&head->srcu, srcu_idx);
517 }
Sagi Grimberge1644712020-06-24 01:53:10 -0700518 mutex_unlock(&head->lock);
Keith Busch886fabf2018-10-05 09:49:37 -0600519
Sagi Grimberge1644712020-06-24 01:53:10 -0700520 synchronize_srcu(&head->srcu);
521 kblockd_schedule_work(&head->requeue_work);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200522}
523
524static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
525 int (*cb)(struct nvme_ctrl *ctrl, struct nvme_ana_group_desc *,
526 void *))
527{
528 void *base = ctrl->ana_log_buf;
529 size_t offset = sizeof(struct nvme_ana_rsp_hdr);
530 int error, i;
531
532 lockdep_assert_held(&ctrl->ana_lock);
533
534 for (i = 0; i < le16_to_cpu(ctrl->ana_log_buf->ngrps); i++) {
535 struct nvme_ana_group_desc *desc = base + offset;
Prabhath Sajeepa64fab722019-10-28 16:56:48 -0600536 u32 nr_nsids;
537 size_t nsid_buf_size;
538
539 if (WARN_ON_ONCE(offset > ctrl->ana_log_size - sizeof(*desc)))
540 return -EINVAL;
541
542 nr_nsids = le32_to_cpu(desc->nnsids);
543 nsid_buf_size = nr_nsids * sizeof(__le32);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200544
545 if (WARN_ON_ONCE(desc->grpid == 0))
546 return -EINVAL;
547 if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
548 return -EINVAL;
549 if (WARN_ON_ONCE(desc->state == 0))
550 return -EINVAL;
551 if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
552 return -EINVAL;
553
554 offset += sizeof(*desc);
555 if (WARN_ON_ONCE(offset > ctrl->ana_log_size - nsid_buf_size))
556 return -EINVAL;
557
558 error = cb(ctrl, desc, data);
559 if (error)
560 return error;
561
562 offset += nsid_buf_size;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200563 }
564
565 return 0;
566}
567
568static inline bool nvme_state_is_live(enum nvme_ana_state state)
569{
570 return state == NVME_ANA_OPTIMIZED || state == NVME_ANA_NONOPTIMIZED;
571}
572
573static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc,
574 struct nvme_ns *ns)
575{
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200576 ns->ana_grpid = le32_to_cpu(desc->grpid);
577 ns->ana_state = desc->state;
578 clear_bit(NVME_NS_ANA_PENDING, &ns->flags);
579
Martin Georgecc2278c2019-03-27 09:52:56 +0100580 if (nvme_state_is_live(ns->ana_state))
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200581 nvme_mpath_set_live(ns);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200582}
583
584static int nvme_update_ana_state(struct nvme_ctrl *ctrl,
585 struct nvme_ana_group_desc *desc, void *data)
586{
587 u32 nr_nsids = le32_to_cpu(desc->nnsids), n = 0;
588 unsigned *nr_change_groups = data;
589 struct nvme_ns *ns;
590
Hannes Reinecke592b6e72019-04-28 20:24:42 -0700591 dev_dbg(ctrl->device, "ANA group %d: %s.\n",
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200592 le32_to_cpu(desc->grpid),
593 nvme_ana_state_names[desc->state]);
594
595 if (desc->state == NVME_ANA_CHANGE)
596 (*nr_change_groups)++;
597
598 if (!nr_nsids)
599 return 0;
600
Sagi Grimberg657f1972020-04-02 09:34:54 -0700601 down_read(&ctrl->namespaces_rwsem);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200602 list_for_each_entry(ns, &ctrl->namespaces, list) {
Anton Eidelmane01f91d2019-08-16 13:00:10 -0700603 unsigned nsid = le32_to_cpu(desc->nsids[n]);
604
605 if (ns->head->ns_id < nsid)
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200606 continue;
Anton Eidelmane01f91d2019-08-16 13:00:10 -0700607 if (ns->head->ns_id == nsid)
608 nvme_update_ns_ana_state(desc, ns);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200609 if (++n == nr_nsids)
610 break;
611 }
Sagi Grimberg657f1972020-04-02 09:34:54 -0700612 up_read(&ctrl->namespaces_rwsem);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200613 return 0;
614}
615
Anton Eidelman86cccfb2019-10-18 11:32:51 -0700616static int nvme_read_ana_log(struct nvme_ctrl *ctrl)
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200617{
618 u32 nr_change_groups = 0;
619 int error;
620
621 mutex_lock(&ctrl->ana_lock);
Keith Buschbe93e872020-06-29 12:06:40 -0700622 error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA, 0, NVME_CSI_NVM,
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200623 ctrl->ana_log_buf, ctrl->ana_log_size, 0);
624 if (error) {
625 dev_warn(ctrl->device, "Failed to get ANA log: %d\n", error);
626 goto out_unlock;
627 }
628
629 error = nvme_parse_ana_log(ctrl, &nr_change_groups,
630 nvme_update_ana_state);
631 if (error)
632 goto out_unlock;
633
634 /*
635 * In theory we should have an ANATT timer per group as they might enter
636 * the change state at different times. But that is a lot of overhead
637 * just to protect against a target that keeps entering new changes
638 * states while never finishing previous ones. But we'll still
639 * eventually time out once all groups are in change state, so this
640 * isn't a big deal.
641 *
642 * We also double the ANATT value to provide some slack for transports
643 * or AEN processing overhead.
644 */
645 if (nr_change_groups)
646 mod_timer(&ctrl->anatt_timer, ctrl->anatt * HZ * 2 + jiffies);
647 else
648 del_timer_sync(&ctrl->anatt_timer);
649out_unlock:
650 mutex_unlock(&ctrl->ana_lock);
651 return error;
652}
653
654static void nvme_ana_work(struct work_struct *work)
655{
656 struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work);
657
Sagi Grimbergecca390e2020-07-22 16:32:19 -0700658 if (ctrl->state != NVME_CTRL_LIVE)
659 return;
660
Anton Eidelman86cccfb2019-10-18 11:32:51 -0700661 nvme_read_ana_log(ctrl);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200662}
663
664static void nvme_anatt_timeout(struct timer_list *t)
665{
666 struct nvme_ctrl *ctrl = from_timer(ctrl, t, anatt_timer);
667
668 dev_info(ctrl->device, "ANATT timeout, resetting controller.\n");
669 nvme_reset_ctrl(ctrl);
670}
671
672void nvme_mpath_stop(struct nvme_ctrl *ctrl)
673{
674 if (!nvme_ctrl_use_ana(ctrl))
675 return;
676 del_timer_sync(&ctrl->anatt_timer);
677 cancel_work_sync(&ctrl->ana_work);
678}
679
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100680#define SUBSYS_ATTR_RW(_name, _mode, _show, _store) \
681 struct device_attribute subsys_attr_##_name = \
682 __ATTR(_name, _mode, _show, _store)
683
684static const char *nvme_iopolicy_names[] = {
685 [NVME_IOPOLICY_NUMA] = "numa",
686 [NVME_IOPOLICY_RR] = "round-robin",
687};
688
689static ssize_t nvme_subsys_iopolicy_show(struct device *dev,
690 struct device_attribute *attr, char *buf)
691{
692 struct nvme_subsystem *subsys =
693 container_of(dev, struct nvme_subsystem, dev);
694
Daniel Wagnerbff4bcf2021-04-01 11:54:10 +0200695 return sysfs_emit(buf, "%s\n",
696 nvme_iopolicy_names[READ_ONCE(subsys->iopolicy)]);
Hannes Reinecke75c10e72019-02-18 11:43:26 +0100697}
698
699static ssize_t nvme_subsys_iopolicy_store(struct device *dev,
700 struct device_attribute *attr, const char *buf, size_t count)
701{
702 struct nvme_subsystem *subsys =
703 container_of(dev, struct nvme_subsystem, dev);
704 int i;
705
706 for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++) {
707 if (sysfs_streq(buf, nvme_iopolicy_names[i])) {
708 WRITE_ONCE(subsys->iopolicy, i);
709 return count;
710 }
711 }
712
713 return -EINVAL;
714}
715SUBSYS_ATTR_RW(iopolicy, S_IRUGO | S_IWUSR,
716 nvme_subsys_iopolicy_show, nvme_subsys_iopolicy_store);
717
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200718static ssize_t ana_grpid_show(struct device *dev, struct device_attribute *attr,
719 char *buf)
720{
Daniel Wagnerbff4bcf2021-04-01 11:54:10 +0200721 return sysfs_emit(buf, "%d\n", nvme_get_ns_from_dev(dev)->ana_grpid);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200722}
723DEVICE_ATTR_RO(ana_grpid);
724
725static ssize_t ana_state_show(struct device *dev, struct device_attribute *attr,
726 char *buf)
727{
728 struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
729
Daniel Wagnerbff4bcf2021-04-01 11:54:10 +0200730 return sysfs_emit(buf, "%s\n", nvme_ana_state_names[ns->ana_state]);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200731}
732DEVICE_ATTR_RO(ana_state);
733
Anton Eidelman489dd102020-06-24 01:53:09 -0700734static int nvme_lookup_ana_group_desc(struct nvme_ctrl *ctrl,
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200735 struct nvme_ana_group_desc *desc, void *data)
736{
Anton Eidelman489dd102020-06-24 01:53:09 -0700737 struct nvme_ana_group_desc *dst = data;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200738
Anton Eidelman489dd102020-06-24 01:53:09 -0700739 if (desc->grpid != dst->grpid)
740 return 0;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200741
Anton Eidelman489dd102020-06-24 01:53:09 -0700742 *dst = *desc;
743 return -ENXIO; /* just break out of the loop */
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200744}
745
746void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
747{
748 if (nvme_ctrl_use_ana(ns->ctrl)) {
Anton Eidelman489dd102020-06-24 01:53:09 -0700749 struct nvme_ana_group_desc desc = {
750 .grpid = id->anagrpid,
751 .state = 0,
752 };
753
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200754 mutex_lock(&ns->ctrl->ana_lock);
755 ns->ana_grpid = le32_to_cpu(id->anagrpid);
Anton Eidelman489dd102020-06-24 01:53:09 -0700756 nvme_parse_ana_log(ns->ctrl, &desc, nvme_lookup_ana_group_desc);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200757 mutex_unlock(&ns->ctrl->ana_lock);
Anton Eidelman489dd102020-06-24 01:53:09 -0700758 if (desc.state) {
759 /* found the group desc: update */
760 nvme_update_ns_ana_state(&desc, ns);
Hannes Reineckedd8f7fa2020-12-05 16:29:01 +0100761 } else {
762 /* group desc not found: trigger a re-read */
763 set_bit(NVME_NS_ANA_PENDING, &ns->flags);
764 queue_work(nvme_wq, &ns->ctrl->ana_work);
Anton Eidelman489dd102020-06-24 01:53:09 -0700765 }
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200766 } else {
Niklas Cassele234f1f2021-04-10 20:15:45 +0000767 ns->ana_state = NVME_ANA_OPTIMIZED;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200768 nvme_mpath_set_live(ns);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200769 }
Keith Buschb2ce4d92020-04-09 09:09:04 -0700770
Christoph Hellwig1cb039f2020-09-24 08:51:38 +0200771 if (blk_queue_stable_writes(ns->queue) && ns->head->disk)
772 blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES,
773 ns->head->disk->queue);
Keith Busch73a1a222021-02-05 11:50:02 -0800774#ifdef CONFIG_BLK_DEV_ZONED
775 if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
776 ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
777#endif
Christoph Hellwig32acab32017-11-02 12:59:30 +0100778}
779
Hannes Reinecke5396fda2021-07-16 13:30:35 +0200780void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
Christoph Hellwig32acab32017-11-02 12:59:30 +0100781{
782 if (!head->disk)
783 return;
Hannes Reinecke5396fda2021-07-16 13:30:35 +0200784 kblockd_schedule_work(&head->requeue_work);
Christoph Hellwig916a4702021-08-09 08:40:24 +0200785 if (test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
Minwoo Im2637bae2021-04-21 16:45:04 +0900786 nvme_cdev_del(&head->cdev, &head->cdev_device);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200787 del_gendisk(head->disk);
Minwoo Im2637bae2021-04-21 16:45:04 +0900788 }
Hannes Reinecke5396fda2021-07-16 13:30:35 +0200789}
790
791void nvme_mpath_remove_disk(struct nvme_ns_head *head)
792{
793 if (!head->disk)
794 return;
Christoph Hellwig32acab32017-11-02 12:59:30 +0100795 blk_set_queue_dying(head->disk->queue);
796 /* make sure all pending bios are cleaned up */
797 kblockd_schedule_work(&head->requeue_work);
798 flush_work(&head->requeue_work);
Christoph Hellwigf165fb82021-05-21 07:51:08 +0200799 blk_cleanup_disk(head->disk);
Christoph Hellwig32acab32017-11-02 12:59:30 +0100800}
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200801
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200802void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl)
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200803{
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200804 mutex_init(&ctrl->ana_lock);
805 timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
806 INIT_WORK(&ctrl->ana_work, nvme_ana_work);
807}
808
809int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
810{
811 size_t max_transfer_size = ctrl->max_hw_sectors << SECTOR_SHIFT;
812 size_t ana_log_size;
813 int error = 0;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200814
Marta Rybczynska66b20ac2019-07-23 07:41:20 +0200815 /* check if multipath is enabled and we have the capability */
Keith Busch92decf12020-04-03 10:53:46 -0700816 if (!multipath || !ctrl->subsys ||
817 !(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA))
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200818 return 0;
819
Daniel Wagner120bb362021-06-07 10:56:56 +0200820 if (!ctrl->max_namespaces ||
821 ctrl->max_namespaces > le32_to_cpu(id->nn)) {
822 dev_err(ctrl->device,
823 "Invalid MNAN value %u\n", ctrl->max_namespaces);
824 return -EINVAL;
825 }
826
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200827 ctrl->anacap = id->anacap;
828 ctrl->anatt = id->anatt;
829 ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
830 ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
831
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200832 ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
833 ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc) +
834 ctrl->max_namespaces * sizeof(__le32);
835 if (ana_log_size > max_transfer_size) {
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200836 dev_err(ctrl->device,
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200837 "ANA log page size (%zd) larger than MDTS (%zd).\n",
838 ana_log_size, max_transfer_size);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200839 dev_err(ctrl->device, "disabling ANA support.\n");
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200840 goto out_uninit;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200841 }
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200842 if (ana_log_size > ctrl->ana_log_size) {
843 nvme_mpath_stop(ctrl);
844 kfree(ctrl->ana_log_buf);
Hou Pue1818112021-05-13 21:04:10 +0800845 ctrl->ana_log_buf = kmalloc(ana_log_size, GFP_KERNEL);
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200846 if (!ctrl->ana_log_buf)
847 return -ENOMEM;
Susobhan Deybb830ad2018-09-25 12:29:15 -0700848 }
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200849 ctrl->ana_log_size = ana_log_size;
Anton Eidelman86cccfb2019-10-18 11:32:51 -0700850 error = nvme_read_ana_log(ctrl);
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200851 if (error)
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200852 goto out_uninit;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200853 return 0;
Christoph Hellwig5e1f6892021-04-29 14:18:53 +0200854
855out_uninit:
856 nvme_mpath_uninit(ctrl);
Susobhan Deybb830ad2018-09-25 12:29:15 -0700857 return error;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200858}
859
860void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
861{
862 kfree(ctrl->ana_log_buf);
Hannes Reineckec7055fd2019-01-08 12:46:58 +0100863 ctrl->ana_log_buf = NULL;
Christoph Hellwig0d0b6602018-05-14 08:48:54 +0200864}