multipath.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * Copyright (c) 2017-2018 Christoph Hellwig.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. */
  13. #include <linux/backing-dev.h>
  14. #include <linux/moduleparam.h>
  15. #include <trace/events/block.h>
  16. #include "nvme.h"
  17. static bool multipath = true;
  18. module_param(multipath, bool, 0444);
  19. MODULE_PARM_DESC(multipath,
  20. "turn on native support for multiple controllers per subsystem");
  21. void nvme_mpath_unfreeze(struct nvme_subsystem *subsys)
  22. {
  23. struct nvme_ns_head *h;
  24. lockdep_assert_held(&subsys->lock);
  25. list_for_each_entry(h, &subsys->nsheads, entry)
  26. if (h->disk)
  27. blk_mq_unfreeze_queue(h->disk->queue);
  28. }
  29. void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
  30. {
  31. struct nvme_ns_head *h;
  32. lockdep_assert_held(&subsys->lock);
  33. list_for_each_entry(h, &subsys->nsheads, entry)
  34. if (h->disk)
  35. blk_mq_freeze_queue_wait(h->disk->queue);
  36. }
  37. void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
  38. {
  39. struct nvme_ns_head *h;
  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. /*
  46. * If multipathing is enabled we need to always use the subsystem instance
  47. * number for numbering our devices to avoid conflicts between subsystems that
  48. * have multiple controllers and thus use the multipath-aware subsystem node
  49. * and those that have a single controller and use the controller node
  50. * directly.
  51. */
  52. void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
  53. struct nvme_ctrl *ctrl, int *flags)
  54. {
  55. if (!multipath) {
  56. sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
  57. } else if (ns->head->disk) {
  58. sprintf(disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
  59. ctrl->cntlid, ns->head->instance);
  60. *flags = GENHD_FL_HIDDEN;
  61. } else {
  62. sprintf(disk_name, "nvme%dn%d", ctrl->subsys->instance,
  63. ns->head->instance);
  64. }
  65. }
  66. bool nvme_failover_req(struct request *req)
  67. {
  68. struct nvme_ns *ns = req->q->queuedata;
  69. u16 status = nvme_req(req)->status;
  70. unsigned long flags;
  71. switch (status & 0x7ff) {
  72. case NVME_SC_ANA_TRANSITION:
  73. case NVME_SC_ANA_INACCESSIBLE:
  74. case NVME_SC_ANA_PERSISTENT_LOSS:
  75. /*
  76. * If we got back an ANA error we know the controller is alive,
  77. * but not ready to serve this namespaces. The spec suggests
  78. * we should update our general state here, but due to the fact
  79. * that the admin and I/O queues are not serialized that is
  80. * fundamentally racy. So instead just clear the current path,
  81. * mark the the path as pending and kick of a re-read of the ANA
  82. * log page ASAP.
  83. */
  84. nvme_mpath_clear_current_path(ns);
  85. if (ns->ctrl->ana_log_buf) {
  86. set_bit(NVME_NS_ANA_PENDING, &ns->flags);
  87. queue_work(nvme_wq, &ns->ctrl->ana_work);
  88. }
  89. break;
  90. case NVME_SC_HOST_PATH_ERROR:
  91. /*
  92. * Temporary transport disruption in talking to the controller.
  93. * Try to send on a new path.
  94. */
  95. nvme_mpath_clear_current_path(ns);
  96. break;
  97. default:
  98. /* This was a non-ANA error so follow the normal error path. */
  99. return false;
  100. }
  101. spin_lock_irqsave(&ns->head->requeue_lock, flags);
  102. blk_steal_bios(&ns->head->requeue_list, req);
  103. spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
  104. blk_mq_end_request(req, 0);
  105. kblockd_schedule_work(&ns->head->requeue_work);
  106. return true;
  107. }
  108. void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
  109. {
  110. struct nvme_ns *ns;
  111. down_read(&ctrl->namespaces_rwsem);
  112. list_for_each_entry(ns, &ctrl->namespaces, list) {
  113. if (ns->head->disk)
  114. kblockd_schedule_work(&ns->head->requeue_work);
  115. }
  116. up_read(&ctrl->namespaces_rwsem);
  117. }
  118. static const char *nvme_ana_state_names[] = {
  119. [0] = "invalid state",
  120. [NVME_ANA_OPTIMIZED] = "optimized",
  121. [NVME_ANA_NONOPTIMIZED] = "non-optimized",
  122. [NVME_ANA_INACCESSIBLE] = "inaccessible",
  123. [NVME_ANA_PERSISTENT_LOSS] = "persistent-loss",
  124. [NVME_ANA_CHANGE] = "change",
  125. };
  126. static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head)
  127. {
  128. struct nvme_ns *ns, *fallback = NULL;
  129. list_for_each_entry_rcu(ns, &head->list, siblings) {
  130. if (ns->ctrl->state != NVME_CTRL_LIVE ||
  131. test_bit(NVME_NS_ANA_PENDING, &ns->flags))
  132. continue;
  133. switch (ns->ana_state) {
  134. case NVME_ANA_OPTIMIZED:
  135. rcu_assign_pointer(head->current_path, ns);
  136. return ns;
  137. case NVME_ANA_NONOPTIMIZED:
  138. fallback = ns;
  139. break;
  140. default:
  141. break;
  142. }
  143. }
  144. if (fallback)
  145. rcu_assign_pointer(head->current_path, fallback);
  146. return fallback;
  147. }
  148. static inline bool nvme_path_is_optimized(struct nvme_ns *ns)
  149. {
  150. return ns->ctrl->state == NVME_CTRL_LIVE &&
  151. ns->ana_state == NVME_ANA_OPTIMIZED;
  152. }
  153. inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
  154. {
  155. struct nvme_ns *ns = srcu_dereference(head->current_path, &head->srcu);
  156. if (unlikely(!ns || !nvme_path_is_optimized(ns)))
  157. ns = __nvme_find_path(head);
  158. return ns;
  159. }
  160. static blk_qc_t nvme_ns_head_make_request(struct request_queue *q,
  161. struct bio *bio)
  162. {
  163. struct nvme_ns_head *head = q->queuedata;
  164. struct device *dev = disk_to_dev(head->disk);
  165. struct nvme_ns *ns;
  166. blk_qc_t ret = BLK_QC_T_NONE;
  167. int srcu_idx;
  168. srcu_idx = srcu_read_lock(&head->srcu);
  169. ns = nvme_find_path(head);
  170. if (likely(ns)) {
  171. bio->bi_disk = ns->disk;
  172. bio->bi_opf |= REQ_NVME_MPATH;
  173. trace_block_bio_remap(bio->bi_disk->queue, bio,
  174. disk_devt(ns->head->disk),
  175. bio->bi_iter.bi_sector);
  176. ret = direct_make_request(bio);
  177. } else if (!list_empty_careful(&head->list)) {
  178. dev_warn_ratelimited(dev, "no path available - requeuing I/O\n");
  179. spin_lock_irq(&head->requeue_lock);
  180. bio_list_add(&head->requeue_list, bio);
  181. spin_unlock_irq(&head->requeue_lock);
  182. } else {
  183. dev_warn_ratelimited(dev, "no path - failing I/O\n");
  184. bio->bi_status = BLK_STS_IOERR;
  185. bio_endio(bio);
  186. }
  187. srcu_read_unlock(&head->srcu, srcu_idx);
  188. return ret;
  189. }
  190. static bool nvme_ns_head_poll(struct request_queue *q, blk_qc_t qc)
  191. {
  192. struct nvme_ns_head *head = q->queuedata;
  193. struct nvme_ns *ns;
  194. bool found = false;
  195. int srcu_idx;
  196. srcu_idx = srcu_read_lock(&head->srcu);
  197. ns = srcu_dereference(head->current_path, &head->srcu);
  198. if (likely(ns && nvme_path_is_optimized(ns)))
  199. found = ns->queue->poll_fn(q, qc);
  200. srcu_read_unlock(&head->srcu, srcu_idx);
  201. return found;
  202. }
  203. static void nvme_requeue_work(struct work_struct *work)
  204. {
  205. struct nvme_ns_head *head =
  206. container_of(work, struct nvme_ns_head, requeue_work);
  207. struct bio *bio, *next;
  208. spin_lock_irq(&head->requeue_lock);
  209. next = bio_list_get(&head->requeue_list);
  210. spin_unlock_irq(&head->requeue_lock);
  211. while ((bio = next) != NULL) {
  212. next = bio->bi_next;
  213. bio->bi_next = NULL;
  214. /*
  215. * Reset disk to the mpath node and resubmit to select a new
  216. * path.
  217. */
  218. bio->bi_disk = head->disk;
  219. generic_make_request(bio);
  220. }
  221. }
  222. int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
  223. {
  224. struct request_queue *q;
  225. bool vwc = false;
  226. mutex_init(&head->lock);
  227. bio_list_init(&head->requeue_list);
  228. spin_lock_init(&head->requeue_lock);
  229. INIT_WORK(&head->requeue_work, nvme_requeue_work);
  230. /*
  231. * Add a multipath node if the subsystems supports multiple controllers.
  232. * We also do this for private namespaces as the namespace sharing data could
  233. * change after a rescan.
  234. */
  235. if (!(ctrl->subsys->cmic & (1 << 1)) || !multipath)
  236. return 0;
  237. q = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE, NULL);
  238. if (!q)
  239. goto out;
  240. q->queuedata = head;
  241. blk_queue_make_request(q, nvme_ns_head_make_request);
  242. q->poll_fn = nvme_ns_head_poll;
  243. blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
  244. /* set to a default value for 512 until disk is validated */
  245. blk_queue_logical_block_size(q, 512);
  246. blk_set_stacking_limits(&q->limits);
  247. /* we need to propagate up the VMC settings */
  248. if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
  249. vwc = true;
  250. blk_queue_write_cache(q, vwc, vwc);
  251. head->disk = alloc_disk(0);
  252. if (!head->disk)
  253. goto out_cleanup_queue;
  254. head->disk->fops = &nvme_ns_head_ops;
  255. head->disk->private_data = head;
  256. head->disk->queue = q;
  257. head->disk->flags = GENHD_FL_EXT_DEVT;
  258. sprintf(head->disk->disk_name, "nvme%dn%d",
  259. ctrl->subsys->instance, head->instance);
  260. return 0;
  261. out_cleanup_queue:
  262. blk_cleanup_queue(q);
  263. out:
  264. return -ENOMEM;
  265. }
  266. static void nvme_mpath_set_live(struct nvme_ns *ns)
  267. {
  268. struct nvme_ns_head *head = ns->head;
  269. lockdep_assert_held(&ns->head->lock);
  270. if (!head->disk)
  271. return;
  272. if (!(head->disk->flags & GENHD_FL_UP))
  273. device_add_disk(&head->subsys->dev, head->disk,
  274. nvme_ns_id_attr_groups);
  275. synchronize_srcu(&ns->head->srcu);
  276. kblockd_schedule_work(&ns->head->requeue_work);
  277. }
  278. static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
  279. int (*cb)(struct nvme_ctrl *ctrl, struct nvme_ana_group_desc *,
  280. void *))
  281. {
  282. void *base = ctrl->ana_log_buf;
  283. size_t offset = sizeof(struct nvme_ana_rsp_hdr);
  284. int error, i;
  285. lockdep_assert_held(&ctrl->ana_lock);
  286. for (i = 0; i < le16_to_cpu(ctrl->ana_log_buf->ngrps); i++) {
  287. struct nvme_ana_group_desc *desc = base + offset;
  288. u32 nr_nsids = le32_to_cpu(desc->nnsids);
  289. size_t nsid_buf_size = nr_nsids * sizeof(__le32);
  290. if (WARN_ON_ONCE(desc->grpid == 0))
  291. return -EINVAL;
  292. if (WARN_ON_ONCE(le32_to_cpu(desc->grpid) > ctrl->anagrpmax))
  293. return -EINVAL;
  294. if (WARN_ON_ONCE(desc->state == 0))
  295. return -EINVAL;
  296. if (WARN_ON_ONCE(desc->state > NVME_ANA_CHANGE))
  297. return -EINVAL;
  298. offset += sizeof(*desc);
  299. if (WARN_ON_ONCE(offset > ctrl->ana_log_size - nsid_buf_size))
  300. return -EINVAL;
  301. error = cb(ctrl, desc, data);
  302. if (error)
  303. return error;
  304. offset += nsid_buf_size;
  305. if (WARN_ON_ONCE(offset > ctrl->ana_log_size - sizeof(*desc)))
  306. return -EINVAL;
  307. }
  308. return 0;
  309. }
  310. static inline bool nvme_state_is_live(enum nvme_ana_state state)
  311. {
  312. return state == NVME_ANA_OPTIMIZED || state == NVME_ANA_NONOPTIMIZED;
  313. }
  314. static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc,
  315. struct nvme_ns *ns)
  316. {
  317. mutex_lock(&ns->head->lock);
  318. ns->ana_grpid = le32_to_cpu(desc->grpid);
  319. ns->ana_state = desc->state;
  320. clear_bit(NVME_NS_ANA_PENDING, &ns->flags);
  321. if (nvme_state_is_live(ns->ana_state))
  322. nvme_mpath_set_live(ns);
  323. mutex_unlock(&ns->head->lock);
  324. }
  325. static int nvme_update_ana_state(struct nvme_ctrl *ctrl,
  326. struct nvme_ana_group_desc *desc, void *data)
  327. {
  328. u32 nr_nsids = le32_to_cpu(desc->nnsids), n = 0;
  329. unsigned *nr_change_groups = data;
  330. struct nvme_ns *ns;
  331. dev_info(ctrl->device, "ANA group %d: %s.\n",
  332. le32_to_cpu(desc->grpid),
  333. nvme_ana_state_names[desc->state]);
  334. if (desc->state == NVME_ANA_CHANGE)
  335. (*nr_change_groups)++;
  336. if (!nr_nsids)
  337. return 0;
  338. down_read(&ctrl->namespaces_rwsem);
  339. list_for_each_entry(ns, &ctrl->namespaces, list) {
  340. unsigned nsid = le32_to_cpu(desc->nsids[n]);
  341. if (ns->head->ns_id < nsid)
  342. continue;
  343. if (ns->head->ns_id == nsid)
  344. nvme_update_ns_ana_state(desc, ns);
  345. if (++n == nr_nsids)
  346. break;
  347. }
  348. up_read(&ctrl->namespaces_rwsem);
  349. return 0;
  350. }
  351. static int nvme_read_ana_log(struct nvme_ctrl *ctrl, bool groups_only)
  352. {
  353. u32 nr_change_groups = 0;
  354. int error;
  355. mutex_lock(&ctrl->ana_lock);
  356. error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_ANA,
  357. groups_only ? NVME_ANA_LOG_RGO : 0,
  358. ctrl->ana_log_buf, ctrl->ana_log_size, 0);
  359. if (error) {
  360. dev_warn(ctrl->device, "Failed to get ANA log: %d\n", error);
  361. goto out_unlock;
  362. }
  363. error = nvme_parse_ana_log(ctrl, &nr_change_groups,
  364. nvme_update_ana_state);
  365. if (error)
  366. goto out_unlock;
  367. /*
  368. * In theory we should have an ANATT timer per group as they might enter
  369. * the change state at different times. But that is a lot of overhead
  370. * just to protect against a target that keeps entering new changes
  371. * states while never finishing previous ones. But we'll still
  372. * eventually time out once all groups are in change state, so this
  373. * isn't a big deal.
  374. *
  375. * We also double the ANATT value to provide some slack for transports
  376. * or AEN processing overhead.
  377. */
  378. if (nr_change_groups)
  379. mod_timer(&ctrl->anatt_timer, ctrl->anatt * HZ * 2 + jiffies);
  380. else
  381. del_timer_sync(&ctrl->anatt_timer);
  382. out_unlock:
  383. mutex_unlock(&ctrl->ana_lock);
  384. return error;
  385. }
  386. static void nvme_ana_work(struct work_struct *work)
  387. {
  388. struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ana_work);
  389. nvme_read_ana_log(ctrl, false);
  390. }
  391. static void nvme_anatt_timeout(struct timer_list *t)
  392. {
  393. struct nvme_ctrl *ctrl = from_timer(ctrl, t, anatt_timer);
  394. dev_info(ctrl->device, "ANATT timeout, resetting controller.\n");
  395. nvme_reset_ctrl(ctrl);
  396. }
  397. void nvme_mpath_stop(struct nvme_ctrl *ctrl)
  398. {
  399. if (!nvme_ctrl_use_ana(ctrl))
  400. return;
  401. del_timer_sync(&ctrl->anatt_timer);
  402. cancel_work_sync(&ctrl->ana_work);
  403. }
  404. static ssize_t ana_grpid_show(struct device *dev, struct device_attribute *attr,
  405. char *buf)
  406. {
  407. return sprintf(buf, "%d\n", nvme_get_ns_from_dev(dev)->ana_grpid);
  408. }
  409. DEVICE_ATTR_RO(ana_grpid);
  410. static ssize_t ana_state_show(struct device *dev, struct device_attribute *attr,
  411. char *buf)
  412. {
  413. struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
  414. return sprintf(buf, "%s\n", nvme_ana_state_names[ns->ana_state]);
  415. }
  416. DEVICE_ATTR_RO(ana_state);
  417. static int nvme_lookup_ana_group_desc(struct nvme_ctrl *ctrl,
  418. struct nvme_ana_group_desc *desc, void *data)
  419. {
  420. struct nvme_ana_group_desc *dst = data;
  421. if (desc->grpid != dst->grpid)
  422. return 0;
  423. *dst = *desc;
  424. return -ENXIO; /* just break out of the loop */
  425. }
  426. void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
  427. {
  428. if (nvme_ctrl_use_ana(ns->ctrl)) {
  429. struct nvme_ana_group_desc desc = {
  430. .grpid = id->anagrpid,
  431. .state = 0,
  432. };
  433. mutex_lock(&ns->ctrl->ana_lock);
  434. ns->ana_grpid = le32_to_cpu(id->anagrpid);
  435. nvme_parse_ana_log(ns->ctrl, &desc, nvme_lookup_ana_group_desc);
  436. mutex_unlock(&ns->ctrl->ana_lock);
  437. if (desc.state) {
  438. /* found the group desc: update */
  439. nvme_update_ns_ana_state(&desc, ns);
  440. } else {
  441. /* group desc not found: trigger a re-read */
  442. set_bit(NVME_NS_ANA_PENDING, &ns->flags);
  443. queue_work(nvme_wq, &ns->ctrl->ana_work);
  444. }
  445. } else {
  446. mutex_lock(&ns->head->lock);
  447. ns->ana_state = NVME_ANA_OPTIMIZED;
  448. nvme_mpath_set_live(ns);
  449. mutex_unlock(&ns->head->lock);
  450. }
  451. if (bdi_cap_stable_pages_required(ns->queue->backing_dev_info)) {
  452. struct gendisk *disk = ns->head->disk;
  453. if (disk)
  454. disk->queue->backing_dev_info->capabilities |=
  455. BDI_CAP_STABLE_WRITES;
  456. }
  457. }
  458. void nvme_mpath_remove_disk(struct nvme_ns_head *head)
  459. {
  460. if (!head->disk)
  461. return;
  462. if (head->disk->flags & GENHD_FL_UP)
  463. del_gendisk(head->disk);
  464. blk_set_queue_dying(head->disk->queue);
  465. /* make sure all pending bios are cleaned up */
  466. kblockd_schedule_work(&head->requeue_work);
  467. flush_work(&head->requeue_work);
  468. blk_cleanup_queue(head->disk->queue);
  469. put_disk(head->disk);
  470. }
  471. int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
  472. {
  473. int error;
  474. /* check if multipath is enabled and we have the capability */
  475. if (!multipath || !ctrl->subsys || !(ctrl->subsys->cmic & (1 << 3)))
  476. return 0;
  477. ctrl->anacap = id->anacap;
  478. ctrl->anatt = id->anatt;
  479. ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
  480. ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
  481. mutex_init(&ctrl->ana_lock);
  482. timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
  483. ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
  484. ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc);
  485. ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32);
  486. if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) {
  487. dev_err(ctrl->device,
  488. "ANA log page size (%zd) larger than MDTS (%d).\n",
  489. ctrl->ana_log_size,
  490. ctrl->max_hw_sectors << SECTOR_SHIFT);
  491. dev_err(ctrl->device, "disabling ANA support.\n");
  492. return 0;
  493. }
  494. INIT_WORK(&ctrl->ana_work, nvme_ana_work);
  495. kfree(ctrl->ana_log_buf);
  496. ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL);
  497. if (!ctrl->ana_log_buf) {
  498. error = -ENOMEM;
  499. goto out;
  500. }
  501. error = nvme_read_ana_log(ctrl, false);
  502. if (error)
  503. goto out_free_ana_log_buf;
  504. return 0;
  505. out_free_ana_log_buf:
  506. kfree(ctrl->ana_log_buf);
  507. ctrl->ana_log_buf = NULL;
  508. out:
  509. return error;
  510. }
  511. void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
  512. {
  513. kfree(ctrl->ana_log_buf);
  514. ctrl->ana_log_buf = NULL;
  515. }