fc.c (29c09648734b94e42802f021658a47361169403b) | fc.c (c5017e85705bfea721732e153305d1988ff965c2) |
---|---|
1/* 2 * Copyright (c) 2016 Avago Technologies. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of version 2 of the GNU General Public License as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful. --- 143 unchanged lines hidden (view full) --- 152 153 u64 association_id; 154 155 struct list_head ctrl_list; /* rport->ctrl_list */ 156 157 struct blk_mq_tag_set admin_tag_set; 158 struct blk_mq_tag_set tag_set; 159 | 1/* 2 * Copyright (c) 2016 Avago Technologies. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of version 2 of the GNU General Public License as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful. --- 143 unchanged lines hidden (view full) --- 152 153 u64 association_id; 154 155 struct list_head ctrl_list; /* rport->ctrl_list */ 156 157 struct blk_mq_tag_set admin_tag_set; 158 struct blk_mq_tag_set tag_set; 159 |
160 struct work_struct delete_work; | |
161 struct delayed_work connect_work; 162 163 struct kref ref; 164 u32 flags; 165 u32 iocnt; 166 wait_queue_head_t ioabort_wait; 167 168 struct nvme_fc_fcp_op aen_ops[NVME_FC_NR_AEN_COMMANDS]; --- 49 unchanged lines hidden (view full) --- 218 * a generic FC class. See comments in module init. 219 */ 220static struct class *fc_class; 221static struct device *fc_udev_device; 222 223 224/* *********************** FC-NVME Port Management ************************ */ 225 | 160 struct delayed_work connect_work; 161 162 struct kref ref; 163 u32 flags; 164 u32 iocnt; 165 wait_queue_head_t ioabort_wait; 166 167 struct nvme_fc_fcp_op aen_ops[NVME_FC_NR_AEN_COMMANDS]; --- 49 unchanged lines hidden (view full) --- 217 * a generic FC class. See comments in module init. 218 */ 219static struct class *fc_class; 220static struct device *fc_udev_device; 221 222 223/* *********************** FC-NVME Port Management ************************ */ 224 |
226static int __nvme_fc_del_ctrl(struct nvme_fc_ctrl *); | |
227static void __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *, 228 struct nvme_fc_queue *, unsigned int); 229 230static void 231nvme_fc_free_lport(struct kref *ref) 232{ 233 struct nvme_fc_lport *lport = 234 container_of(ref, struct nvme_fc_lport, ref); --- 422 unchanged lines hidden (view full) --- 657 if (portptr->port_state != FC_OBJSTATE_ONLINE) { 658 spin_unlock_irqrestore(&rport->lock, flags); 659 return -EINVAL; 660 } 661 portptr->port_state = FC_OBJSTATE_DELETED; 662 663 /* tear down all associations to the remote port */ 664 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) | 225static void __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *, 226 struct nvme_fc_queue *, unsigned int); 227 228static void 229nvme_fc_free_lport(struct kref *ref) 230{ 231 struct nvme_fc_lport *lport = 232 container_of(ref, struct nvme_fc_lport, ref); --- 422 unchanged lines hidden (view full) --- 655 if (portptr->port_state != FC_OBJSTATE_ONLINE) { 656 spin_unlock_irqrestore(&rport->lock, flags); 657 return -EINVAL; 658 } 659 portptr->port_state = FC_OBJSTATE_DELETED; 660 661 /* tear down all associations to the remote port */ 662 list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) |
665 __nvme_fc_del_ctrl(ctrl); | 663 nvme_delete_ctrl(&ctrl->ctrl); |
666 667 spin_unlock_irqrestore(&rport->lock, flags); 668 669 nvme_fc_abort_lsops(rport); 670 671 nvme_fc_rport_put(rport); 672 return 0; 673} --- 1957 unchanged lines hidden (view full) --- 2631 nvme_fc_free_io_queues(ctrl); 2632 } 2633 2634 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); 2635 nvme_fc_free_queue(&ctrl->queues[0]); 2636} 2637 2638static void | 664 665 spin_unlock_irqrestore(&rport->lock, flags); 666 667 nvme_fc_abort_lsops(rport); 668 669 nvme_fc_rport_put(rport); 670 return 0; 671} --- 1957 unchanged lines hidden (view full) --- 2629 nvme_fc_free_io_queues(ctrl); 2630 } 2631 2632 __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[0], 0); 2633 nvme_fc_free_queue(&ctrl->queues[0]); 2634} 2635 2636static void |
2639nvme_fc_delete_ctrl_work(struct work_struct *work) | 2637nvme_fc_delete_ctrl(struct nvme_ctrl *nctrl) |
2640{ | 2638{ |
2641 struct nvme_fc_ctrl *ctrl = 2642 container_of(work, struct nvme_fc_ctrl, delete_work); | 2639 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); |
2643 2644 cancel_work_sync(&ctrl->ctrl.reset_work); 2645 cancel_delayed_work_sync(&ctrl->connect_work); 2646 nvme_stop_ctrl(&ctrl->ctrl); 2647 nvme_remove_namespaces(&ctrl->ctrl); 2648 /* 2649 * kill the association on the link side. this will block 2650 * waiting for io to terminate --- 7 unchanged lines hidden (view full) --- 2658 * invoked. From there, the transport will tear down it's 2659 * logical queues and association. 2660 */ 2661 nvme_uninit_ctrl(&ctrl->ctrl); 2662 2663 nvme_put_ctrl(&ctrl->ctrl); 2664} 2665 | 2640 2641 cancel_work_sync(&ctrl->ctrl.reset_work); 2642 cancel_delayed_work_sync(&ctrl->connect_work); 2643 nvme_stop_ctrl(&ctrl->ctrl); 2644 nvme_remove_namespaces(&ctrl->ctrl); 2645 /* 2646 * kill the association on the link side. this will block 2647 * waiting for io to terminate --- 7 unchanged lines hidden (view full) --- 2655 * invoked. From there, the transport will tear down it's 2656 * logical queues and association. 2657 */ 2658 nvme_uninit_ctrl(&ctrl->ctrl); 2659 2660 nvme_put_ctrl(&ctrl->ctrl); 2661} 2662 |
2666static int 2667__nvme_fc_del_ctrl(struct nvme_fc_ctrl *ctrl) 2668{ 2669 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 2670 return -EBUSY; 2671 if (!queue_work(nvme_wq, &ctrl->delete_work)) 2672 return -EBUSY; 2673 return 0; 2674} 2675 2676/* 2677 * Request from nvme core layer to delete the controller 2678 */ 2679static int 2680nvme_fc_del_nvme_ctrl(struct nvme_ctrl *nctrl) 2681{ 2682 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); 2683 int ret; 2684 2685 nvme_get_ctrl(&ctrl->ctrl); 2686 ret = __nvme_fc_del_ctrl(ctrl); 2687 if (!ret) 2688 flush_work(&ctrl->delete_work); 2689 nvme_put_ctrl(&ctrl->ctrl); 2690 2691 return ret; 2692} 2693 | |
2694static void 2695nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) 2696{ 2697 /* If we are resetting/deleting then do nothing */ 2698 if (ctrl->ctrl.state != NVME_CTRL_RECONNECTING) { 2699 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || 2700 ctrl->ctrl.state == NVME_CTRL_LIVE); 2701 return; --- 9 unchanged lines hidden (view full) --- 2711 ctrl->cnum, ctrl->ctrl.opts->reconnect_delay); 2712 queue_delayed_work(nvme_wq, &ctrl->connect_work, 2713 ctrl->ctrl.opts->reconnect_delay * HZ); 2714 } else { 2715 dev_warn(ctrl->ctrl.device, 2716 "NVME-FC{%d}: Max reconnect attempts (%d) " 2717 "reached. Removing controller\n", 2718 ctrl->cnum, ctrl->ctrl.nr_reconnects); | 2663static void 2664nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) 2665{ 2666 /* If we are resetting/deleting then do nothing */ 2667 if (ctrl->ctrl.state != NVME_CTRL_RECONNECTING) { 2668 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW || 2669 ctrl->ctrl.state == NVME_CTRL_LIVE); 2670 return; --- 9 unchanged lines hidden (view full) --- 2680 ctrl->cnum, ctrl->ctrl.opts->reconnect_delay); 2681 queue_delayed_work(nvme_wq, &ctrl->connect_work, 2682 ctrl->ctrl.opts->reconnect_delay * HZ); 2683 } else { 2684 dev_warn(ctrl->ctrl.device, 2685 "NVME-FC{%d}: Max reconnect attempts (%d) " 2686 "reached. Removing controller\n", 2687 ctrl->cnum, ctrl->ctrl.nr_reconnects); |
2719 WARN_ON(__nvme_fc_del_ctrl(ctrl)); | 2688 WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); |
2720 } 2721} 2722 2723static void 2724nvme_fc_reset_ctrl_work(struct work_struct *work) 2725{ 2726 struct nvme_fc_ctrl *ctrl = 2727 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); --- 15 unchanged lines hidden (view full) --- 2743 .name = "fc", 2744 .module = THIS_MODULE, 2745 .flags = NVME_F_FABRICS, 2746 .reg_read32 = nvmf_reg_read32, 2747 .reg_read64 = nvmf_reg_read64, 2748 .reg_write32 = nvmf_reg_write32, 2749 .free_ctrl = nvme_fc_nvme_ctrl_freed, 2750 .submit_async_event = nvme_fc_submit_async_event, | 2689 } 2690} 2691 2692static void 2693nvme_fc_reset_ctrl_work(struct work_struct *work) 2694{ 2695 struct nvme_fc_ctrl *ctrl = 2696 container_of(work, struct nvme_fc_ctrl, ctrl.reset_work); --- 15 unchanged lines hidden (view full) --- 2712 .name = "fc", 2713 .module = THIS_MODULE, 2714 .flags = NVME_F_FABRICS, 2715 .reg_read32 = nvmf_reg_read32, 2716 .reg_read64 = nvmf_reg_read64, 2717 .reg_write32 = nvmf_reg_write32, 2718 .free_ctrl = nvme_fc_nvme_ctrl_freed, 2719 .submit_async_event = nvme_fc_submit_async_event, |
2751 .delete_ctrl = nvme_fc_del_nvme_ctrl, | 2720 .delete_ctrl = nvme_fc_delete_ctrl, |
2752 .get_address = nvmf_get_address, 2753 .reinit_request = nvme_fc_reinit_request, 2754}; 2755 2756static void 2757nvme_fc_connect_ctrl_work(struct work_struct *work) 2758{ 2759 int ret; --- 86 unchanged lines hidden (view full) --- 2846 ctrl->lport = lport; 2847 ctrl->rport = rport; 2848 ctrl->dev = lport->dev; 2849 ctrl->cnum = idx; 2850 2851 get_device(ctrl->dev); 2852 kref_init(&ctrl->ref); 2853 | 2721 .get_address = nvmf_get_address, 2722 .reinit_request = nvme_fc_reinit_request, 2723}; 2724 2725static void 2726nvme_fc_connect_ctrl_work(struct work_struct *work) 2727{ 2728 int ret; --- 86 unchanged lines hidden (view full) --- 2815 ctrl->lport = lport; 2816 ctrl->rport = rport; 2817 ctrl->dev = lport->dev; 2818 ctrl->cnum = idx; 2819 2820 get_device(ctrl->dev); 2821 kref_init(&ctrl->ref); 2822 |
2854 INIT_WORK(&ctrl->delete_work, nvme_fc_delete_ctrl_work); | |
2855 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); 2856 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); 2857 spin_lock_init(&ctrl->lock); 2858 2859 /* io queue count */ 2860 ctrl->ctrl.queue_count = min_t(unsigned int, 2861 opts->nr_io_queues, 2862 lport->ops->max_hw_queues); --- 290 unchanged lines hidden --- | 2823 INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); 2824 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); 2825 spin_lock_init(&ctrl->lock); 2826 2827 /* io queue count */ 2828 ctrl->ctrl.queue_count = min_t(unsigned int, 2829 opts->nr_io_queues, 2830 lport->ops->max_hw_queues); --- 290 unchanged lines hidden --- |