loop.c (c1c0ffff3a99caf40c3bd21447135db459194123) | loop.c (d09f2b45f346f0a9e5e1b5fcea531b1b393671dc) |
---|---|
1/* 2 * NVMe over Fabrics loopback device. 3 * Copyright (c) 2015-2016 HGST, a Western Digital Company. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 393 unchanged lines hidden (view full) --- 402 403 ctrl->ctrl.max_hw_sectors = 404 (NVME_LOOP_MAX_SEGMENTS - 1) << (PAGE_SHIFT - 9); 405 406 error = nvme_init_identify(&ctrl->ctrl); 407 if (error) 408 goto out_cleanup_queue; 409 | 1/* 2 * NVMe over Fabrics loopback device. 3 * Copyright (c) 2015-2016 HGST, a Western Digital Company. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 393 unchanged lines hidden (view full) --- 402 403 ctrl->ctrl.max_hw_sectors = 404 (NVME_LOOP_MAX_SEGMENTS - 1) << (PAGE_SHIFT - 9); 405 406 error = nvme_init_identify(&ctrl->ctrl); 407 if (error) 408 goto out_cleanup_queue; 409 |
410 nvme_start_keep_alive(&ctrl->ctrl); 411 | |
412 return 0; 413 414out_cleanup_queue: 415 blk_cleanup_queue(ctrl->ctrl.admin_q); 416out_free_tagset: 417 blk_mq_free_tag_set(&ctrl->admin_tag_set); 418out_free_sq: 419 nvmet_sq_destroy(&ctrl->queues[0].nvme_sq); 420 return error; 421} 422 423static void nvme_loop_shutdown_ctrl(struct nvme_loop_ctrl *ctrl) 424{ | 410 return 0; 411 412out_cleanup_queue: 413 blk_cleanup_queue(ctrl->ctrl.admin_q); 414out_free_tagset: 415 blk_mq_free_tag_set(&ctrl->admin_tag_set); 416out_free_sq: 417 nvmet_sq_destroy(&ctrl->queues[0].nvme_sq); 418 return error; 419} 420 421static void nvme_loop_shutdown_ctrl(struct nvme_loop_ctrl *ctrl) 422{ |
425 nvme_stop_keep_alive(&ctrl->ctrl); 426 | |
427 if (ctrl->ctrl.queue_count > 1) { 428 nvme_stop_queues(&ctrl->ctrl); 429 blk_mq_tagset_busy_iter(&ctrl->tag_set, 430 nvme_cancel_request, &ctrl->ctrl); 431 nvme_loop_destroy_io_queues(ctrl); 432 } 433 434 if (ctrl->ctrl.state == NVME_CTRL_LIVE) --- 6 unchanged lines hidden (view full) --- 441 nvme_loop_destroy_admin_queue(ctrl); 442} 443 444static void nvme_loop_del_ctrl_work(struct work_struct *work) 445{ 446 struct nvme_loop_ctrl *ctrl = container_of(work, 447 struct nvme_loop_ctrl, delete_work); 448 | 423 if (ctrl->ctrl.queue_count > 1) { 424 nvme_stop_queues(&ctrl->ctrl); 425 blk_mq_tagset_busy_iter(&ctrl->tag_set, 426 nvme_cancel_request, &ctrl->ctrl); 427 nvme_loop_destroy_io_queues(ctrl); 428 } 429 430 if (ctrl->ctrl.state == NVME_CTRL_LIVE) --- 6 unchanged lines hidden (view full) --- 437 nvme_loop_destroy_admin_queue(ctrl); 438} 439 440static void nvme_loop_del_ctrl_work(struct work_struct *work) 441{ 442 struct nvme_loop_ctrl *ctrl = container_of(work, 443 struct nvme_loop_ctrl, delete_work); 444 |
449 nvme_uninit_ctrl(&ctrl->ctrl); | 445 nvme_stop_ctrl(&ctrl->ctrl); 446 nvme_remove_namespaces(&ctrl->ctrl); |
450 nvme_loop_shutdown_ctrl(ctrl); | 447 nvme_loop_shutdown_ctrl(ctrl); |
448 nvme_uninit_ctrl(&ctrl->ctrl); |
|
451 nvme_put_ctrl(&ctrl->ctrl); 452} 453 454static int __nvme_loop_del_ctrl(struct nvme_loop_ctrl *ctrl) 455{ 456 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 457 return -EBUSY; 458 --- 31 unchanged lines hidden (view full) --- 490 491static void nvme_loop_reset_ctrl_work(struct work_struct *work) 492{ 493 struct nvme_loop_ctrl *ctrl = 494 container_of(work, struct nvme_loop_ctrl, ctrl.reset_work); 495 bool changed; 496 int ret; 497 | 449 nvme_put_ctrl(&ctrl->ctrl); 450} 451 452static int __nvme_loop_del_ctrl(struct nvme_loop_ctrl *ctrl) 453{ 454 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 455 return -EBUSY; 456 --- 31 unchanged lines hidden (view full) --- 488 489static void nvme_loop_reset_ctrl_work(struct work_struct *work) 490{ 491 struct nvme_loop_ctrl *ctrl = 492 container_of(work, struct nvme_loop_ctrl, ctrl.reset_work); 493 bool changed; 494 int ret; 495 |
496 nvme_stop_ctrl(&ctrl->ctrl); |
|
498 nvme_loop_shutdown_ctrl(ctrl); 499 500 ret = nvme_loop_configure_admin_queue(ctrl); 501 if (ret) 502 goto out_disable; 503 504 ret = nvme_loop_init_io_queues(ctrl); 505 if (ret) --- 4 unchanged lines hidden (view full) --- 510 goto out_destroy_io; 511 512 blk_mq_update_nr_hw_queues(&ctrl->tag_set, 513 ctrl->ctrl.queue_count - 1); 514 515 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 516 WARN_ON_ONCE(!changed); 517 | 497 nvme_loop_shutdown_ctrl(ctrl); 498 499 ret = nvme_loop_configure_admin_queue(ctrl); 500 if (ret) 501 goto out_disable; 502 503 ret = nvme_loop_init_io_queues(ctrl); 504 if (ret) --- 4 unchanged lines hidden (view full) --- 509 goto out_destroy_io; 510 511 blk_mq_update_nr_hw_queues(&ctrl->tag_set, 512 ctrl->ctrl.queue_count - 1); 513 514 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 515 WARN_ON_ONCE(!changed); 516 |
518 nvme_queue_scan(&ctrl->ctrl); 519 nvme_queue_async_events(&ctrl->ctrl); | 517 nvme_start_ctrl(&ctrl->ctrl); |
520 | 518 |
521 nvme_start_queues(&ctrl->ctrl); 522 | |
523 return; 524 525out_destroy_io: 526 nvme_loop_destroy_io_queues(ctrl); 527out_destroy_admin: 528 nvme_loop_destroy_admin_queue(ctrl); 529out_disable: 530 dev_warn(ctrl->ctrl.device, "Removing after reset failure\n"); --- 117 unchanged lines hidden (view full) --- 648 649 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 650 WARN_ON_ONCE(!changed); 651 652 mutex_lock(&nvme_loop_ctrl_mutex); 653 list_add_tail(&ctrl->list, &nvme_loop_ctrl_list); 654 mutex_unlock(&nvme_loop_ctrl_mutex); 655 | 519 return; 520 521out_destroy_io: 522 nvme_loop_destroy_io_queues(ctrl); 523out_destroy_admin: 524 nvme_loop_destroy_admin_queue(ctrl); 525out_disable: 526 dev_warn(ctrl->ctrl.device, "Removing after reset failure\n"); --- 117 unchanged lines hidden (view full) --- 644 645 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 646 WARN_ON_ONCE(!changed); 647 648 mutex_lock(&nvme_loop_ctrl_mutex); 649 list_add_tail(&ctrl->list, &nvme_loop_ctrl_list); 650 mutex_unlock(&nvme_loop_ctrl_mutex); 651 |
656 if (opts->nr_io_queues) { 657 nvme_queue_scan(&ctrl->ctrl); 658 nvme_queue_async_events(&ctrl->ctrl); 659 } | 652 nvme_start_ctrl(&ctrl->ctrl); |
660 661 return &ctrl->ctrl; 662 663out_remove_admin_queue: 664 nvme_loop_destroy_admin_queue(ctrl); 665out_free_queues: 666 kfree(ctrl->queues); 667out_uninit_ctrl: --- 82 unchanged lines hidden --- | 653 654 return &ctrl->ctrl; 655 656out_remove_admin_queue: 657 nvme_loop_destroy_admin_queue(ctrl); 658out_free_queues: 659 kfree(ctrl->queues); 660out_uninit_ctrl: --- 82 unchanged lines hidden --- |