Lines Matching refs:head

102 	spin_lock_irqsave(&ns->head->requeue_lock, flags);  in nvme_failover_req()
104 bio_set_dev(bio, ns->head->disk->part0); in nvme_failover_req()
110 blk_steal_bios(&ns->head->requeue_list, req); in nvme_failover_req()
111 spin_unlock_irqrestore(&ns->head->requeue_lock, flags); in nvme_failover_req()
114 kblockd_schedule_work(&ns->head->requeue_work); in nvme_failover_req()
123 if (!ns->head->disk) in nvme_kick_requeue_lists()
125 kblockd_schedule_work(&ns->head->requeue_work); in nvme_kick_requeue_lists()
127 disk_uevent(ns->head->disk, KOBJ_CHANGE); in nvme_kick_requeue_lists()
143 struct nvme_ns_head *head = ns->head; in nvme_mpath_clear_current_path() local
147 if (!head) in nvme_mpath_clear_current_path()
151 if (ns == rcu_access_pointer(head->current_path[node])) { in nvme_mpath_clear_current_path()
152 rcu_assign_pointer(head->current_path[node], NULL); in nvme_mpath_clear_current_path()
167 kblockd_schedule_work(&ns->head->requeue_work); in nvme_mpath_clear_ctrl_paths()
174 struct nvme_ns_head *head = ns->head; in nvme_mpath_revalidate_paths() local
175 sector_t capacity = get_capacity(head->disk); in nvme_mpath_revalidate_paths()
179 srcu_idx = srcu_read_lock(&head->srcu); in nvme_mpath_revalidate_paths()
180 list_for_each_entry_rcu(ns, &head->list, siblings) { in nvme_mpath_revalidate_paths()
184 srcu_read_unlock(&head->srcu, srcu_idx); in nvme_mpath_revalidate_paths()
187 rcu_assign_pointer(head->current_path[node], NULL); in nvme_mpath_revalidate_paths()
188 kblockd_schedule_work(&head->requeue_work); in nvme_mpath_revalidate_paths()
207 static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node) in __nvme_find_path() argument
212 list_for_each_entry_rcu(ns, &head->list, siblings) { in __nvme_find_path()
216 if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA) in __nvme_find_path()
242 rcu_assign_pointer(head->current_path[node], found); in __nvme_find_path()
246 static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head, in nvme_next_ns() argument
249 ns = list_next_or_null_rcu(&head->list, &ns->siblings, struct nvme_ns, in nvme_next_ns()
253 return list_first_or_null_rcu(&head->list, struct nvme_ns, siblings); in nvme_next_ns()
256 static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head, in nvme_round_robin_path() argument
261 if (list_is_singular(&head->list)) { in nvme_round_robin_path()
267 for (ns = nvme_next_ns(head, old); in nvme_round_robin_path()
269 ns = nvme_next_ns(head, ns)) { in nvme_round_robin_path()
295 rcu_assign_pointer(head->current_path[node], found); in nvme_round_robin_path()
305 inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head) in nvme_find_path() argument
310 ns = srcu_dereference(head->current_path[node], &head->srcu); in nvme_find_path()
312 return __nvme_find_path(head, node); in nvme_find_path()
314 if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR) in nvme_find_path()
315 return nvme_round_robin_path(head, node, ns); in nvme_find_path()
317 return __nvme_find_path(head, node); in nvme_find_path()
321 static bool nvme_available_path(struct nvme_ns_head *head) in nvme_available_path() argument
325 list_for_each_entry_rcu(ns, &head->list, siblings) { in nvme_available_path()
343 struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data; in nvme_ns_head_submit_bio() local
344 struct device *dev = disk_to_dev(head->disk); in nvme_ns_head_submit_bio()
355 srcu_idx = srcu_read_lock(&head->srcu); in nvme_ns_head_submit_bio()
356 ns = nvme_find_path(head); in nvme_ns_head_submit_bio()
360 trace_block_bio_remap(bio, disk_devt(ns->head->disk), in nvme_ns_head_submit_bio()
363 } else if (nvme_available_path(head)) { in nvme_ns_head_submit_bio()
366 spin_lock_irq(&head->requeue_lock); in nvme_ns_head_submit_bio()
367 bio_list_add(&head->requeue_list, bio); in nvme_ns_head_submit_bio()
368 spin_unlock_irq(&head->requeue_lock); in nvme_ns_head_submit_bio()
375 srcu_read_unlock(&head->srcu, srcu_idx); in nvme_ns_head_submit_bio()
394 struct nvme_ns_head *head = disk->private_data; in nvme_ns_head_report_zones() local
398 srcu_idx = srcu_read_lock(&head->srcu); in nvme_ns_head_report_zones()
399 ns = nvme_find_path(head); in nvme_ns_head_report_zones()
402 srcu_read_unlock(&head->srcu, srcu_idx); in nvme_ns_head_report_zones()
449 static int nvme_add_ns_head_cdev(struct nvme_ns_head *head) in nvme_add_ns_head_cdev() argument
453 head->cdev_device.parent = &head->subsys->dev; in nvme_add_ns_head_cdev()
454 ret = dev_set_name(&head->cdev_device, "ng%dn%d", in nvme_add_ns_head_cdev()
455 head->subsys->instance, head->instance); in nvme_add_ns_head_cdev()
458 ret = nvme_cdev_add(&head->cdev, &head->cdev_device, in nvme_add_ns_head_cdev()
465 struct nvme_ns_head *head = in nvme_requeue_work() local
469 spin_lock_irq(&head->requeue_lock); in nvme_requeue_work()
470 next = bio_list_get(&head->requeue_list); in nvme_requeue_work()
471 spin_unlock_irq(&head->requeue_lock); in nvme_requeue_work()
481 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) in nvme_mpath_alloc_disk() argument
485 mutex_init(&head->lock); in nvme_mpath_alloc_disk()
486 bio_list_init(&head->requeue_list); in nvme_mpath_alloc_disk()
487 spin_lock_init(&head->requeue_lock); in nvme_mpath_alloc_disk()
488 INIT_WORK(&head->requeue_work, nvme_requeue_work); in nvme_mpath_alloc_disk()
496 !nvme_is_unique_nsid(ctrl, head) || !multipath) in nvme_mpath_alloc_disk()
499 head->disk = blk_alloc_disk(ctrl->numa_node); in nvme_mpath_alloc_disk()
500 if (!head->disk) in nvme_mpath_alloc_disk()
502 head->disk->fops = &nvme_ns_head_ops; in nvme_mpath_alloc_disk()
503 head->disk->private_data = head; in nvme_mpath_alloc_disk()
504 sprintf(head->disk->disk_name, "nvme%dn%d", in nvme_mpath_alloc_disk()
505 ctrl->subsys->instance, head->instance); in nvme_mpath_alloc_disk()
507 blk_queue_flag_set(QUEUE_FLAG_NONROT, head->disk->queue); in nvme_mpath_alloc_disk()
508 blk_queue_flag_set(QUEUE_FLAG_NOWAIT, head->disk->queue); in nvme_mpath_alloc_disk()
517 blk_queue_flag_set(QUEUE_FLAG_POLL, head->disk->queue); in nvme_mpath_alloc_disk()
520 blk_queue_logical_block_size(head->disk->queue, 512); in nvme_mpath_alloc_disk()
521 blk_set_stacking_limits(&head->disk->queue->limits); in nvme_mpath_alloc_disk()
522 blk_queue_dma_alignment(head->disk->queue, 3); in nvme_mpath_alloc_disk()
527 blk_queue_write_cache(head->disk->queue, vwc, vwc); in nvme_mpath_alloc_disk()
533 struct nvme_ns_head *head = ns->head; in nvme_mpath_set_live() local
536 if (!head->disk) in nvme_mpath_set_live()
544 if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { in nvme_mpath_set_live()
545 rc = device_add_disk(&head->subsys->dev, head->disk, in nvme_mpath_set_live()
551 nvme_add_ns_head_cdev(head); in nvme_mpath_set_live()
554 mutex_lock(&head->lock); in nvme_mpath_set_live()
558 srcu_idx = srcu_read_lock(&head->srcu); in nvme_mpath_set_live()
560 __nvme_find_path(head, node); in nvme_mpath_set_live()
561 srcu_read_unlock(&head->srcu, srcu_idx); in nvme_mpath_set_live()
563 mutex_unlock(&head->lock); in nvme_mpath_set_live()
565 synchronize_srcu(&head->srcu); in nvme_mpath_set_live()
566 kblockd_schedule_work(&head->requeue_work); in nvme_mpath_set_live()
660 if (ns->head->ns_id < nsid) in nvme_update_ana_state()
662 if (ns->head->ns_id == nsid) in nvme_update_ana_state()
666 if (ns->head->ns_id > nsid) in nvme_update_ana_state()
835 if (blk_queue_stable_writes(ns->queue) && ns->head->disk) in nvme_mpath_add_disk()
837 ns->head->disk->queue); in nvme_mpath_add_disk()
839 if (blk_queue_is_zoned(ns->queue) && ns->head->disk) in nvme_mpath_add_disk()
840 ns->head->disk->nr_zones = ns->disk->nr_zones; in nvme_mpath_add_disk()
844 void nvme_mpath_shutdown_disk(struct nvme_ns_head *head) in nvme_mpath_shutdown_disk() argument
846 if (!head->disk) in nvme_mpath_shutdown_disk()
848 kblockd_schedule_work(&head->requeue_work); in nvme_mpath_shutdown_disk()
849 if (test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { in nvme_mpath_shutdown_disk()
850 nvme_cdev_del(&head->cdev, &head->cdev_device); in nvme_mpath_shutdown_disk()
851 del_gendisk(head->disk); in nvme_mpath_shutdown_disk()
855 void nvme_mpath_remove_disk(struct nvme_ns_head *head) in nvme_mpath_remove_disk() argument
857 if (!head->disk) in nvme_mpath_remove_disk()
859 blk_mark_disk_dead(head->disk); in nvme_mpath_remove_disk()
861 kblockd_schedule_work(&head->requeue_work); in nvme_mpath_remove_disk()
862 flush_work(&head->requeue_work); in nvme_mpath_remove_disk()
863 put_disk(head->disk); in nvme_mpath_remove_disk()