Lines Matching refs:dev_info

112 	struct dcssblk_dev_info *dev_info;  in dcssblk_release_segment()  local
115 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_release_segment()
116 list_for_each_entry_safe(entry, temp, &dev_info->seg_list, lh) { in dcssblk_release_segment()
120 kfree(dev_info); in dcssblk_release_segment()
131 dcssblk_assign_free_minor(struct dcssblk_dev_info *dev_info) in dcssblk_assign_free_minor() argument
136 if (dev_info == NULL) in dcssblk_assign_free_minor()
148 dev_info->gd->first_minor = minor; in dcssblk_assign_free_minor()
178 struct dcssblk_dev_info *dev_info; in dcssblk_get_segment_by_name() local
181 list_for_each_entry(dev_info, &dcssblk_devices, lh) { in dcssblk_get_segment_by_name()
182 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_get_segment_by_name()
194 dcssblk_find_highest_addr(struct dcssblk_dev_info *dev_info) in dcssblk_find_highest_addr() argument
200 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_find_highest_addr()
211 dcssblk_find_lowest_addr(struct dcssblk_dev_info *dev_info) in dcssblk_find_lowest_addr() argument
219 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_find_lowest_addr()
235 dcssblk_is_continuous(struct dcssblk_dev_info *dev_info) in dcssblk_is_continuous() argument
240 if (dev_info->num_of_segments <= 1) in dcssblk_is_continuous()
243 sort_list = kcalloc(dev_info->num_of_segments, in dcssblk_is_continuous()
249 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_is_continuous()
255 for (i = 0; i < dev_info->num_of_segments; i++) in dcssblk_is_continuous()
256 for (j = 0; j < dev_info->num_of_segments; j++) in dcssblk_is_continuous()
267 for (i = 0; i < dev_info->num_of_segments - 1; i++) { in dcssblk_is_continuous()
339 struct dcssblk_dev_info *dev_info; in dcssblk_shared_show() local
341 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_shared_show()
342 return sprintf(buf, dev_info->is_shared ? "1\n" : "0\n"); in dcssblk_shared_show()
348 struct dcssblk_dev_info *dev_info; in dcssblk_shared_store() local
355 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_shared_store()
356 if (atomic_read(&dev_info->use_count)) { in dcssblk_shared_store()
362 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
371 dev_info->is_shared = 1; in dcssblk_shared_store()
372 switch (dev_info->segment_type) { in dcssblk_shared_store()
376 set_disk_ro(dev_info->gd, 1); in dcssblk_shared_store()
380 if (dev_info->segment_type == SEG_TYPE_SC) { in dcssblk_shared_store()
383 dev_info->segment_name); in dcssblk_shared_store()
387 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
396 dev_info->is_shared = 0; in dcssblk_shared_store()
397 set_disk_ro(dev_info->gd, 0); in dcssblk_shared_store()
407 "change\n", dev_info->segment_name); in dcssblk_shared_store()
409 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
413 list_del(&dev_info->lh); in dcssblk_shared_store()
416 dax_remove_host(dev_info->gd); in dcssblk_shared_store()
417 kill_dax(dev_info->dax_dev); in dcssblk_shared_store()
418 put_dax(dev_info->dax_dev); in dcssblk_shared_store()
419 del_gendisk(dev_info->gd); in dcssblk_shared_store()
420 put_disk(dev_info->gd); in dcssblk_shared_store()
444 struct dcssblk_dev_info *dev_info; in dcssblk_save_show() local
446 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_save_show()
447 return sprintf(buf, dev_info->save_pending ? "1\n" : "0\n"); in dcssblk_save_show()
453 struct dcssblk_dev_info *dev_info; in dcssblk_save_store() local
458 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_save_store()
462 if (atomic_read(&dev_info->use_count) == 0) { in dcssblk_save_store()
465 "saved\n", dev_info->segment_name); in dcssblk_save_store()
466 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_save_store()
480 dev_info->segment_name); in dcssblk_save_store()
481 dev_info->save_pending = 1; in dcssblk_save_store()
484 if (dev_info->save_pending) { in dcssblk_save_store()
487 dev_info->save_pending = 0; in dcssblk_save_store()
490 dev_info->segment_name); in dcssblk_save_store()
511 struct dcssblk_dev_info *dev_info; in dcssblk_seglist_show() local
515 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_seglist_show()
518 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_seglist_show()
550 struct dcssblk_dev_info *dev_info; in dcssblk_add_store() local
555 dev_info = NULL; in dcssblk_add_store()
596 dev_info = kzalloc(sizeof(struct dcssblk_dev_info), in dcssblk_add_store()
598 if (dev_info == NULL) { in dcssblk_add_store()
602 strcpy(dev_info->segment_name, local_buf); in dcssblk_add_store()
603 dev_info->segment_type = seg_info->segment_type; in dcssblk_add_store()
604 INIT_LIST_HEAD(&dev_info->seg_list); in dcssblk_add_store()
606 list_add_tail(&seg_info->lh, &dev_info->seg_list); in dcssblk_add_store()
620 dev_info->num_of_segments = num_of_segments; in dcssblk_add_store()
621 rc = dcssblk_is_continuous(dev_info); in dcssblk_add_store()
625 dev_info->start = dcssblk_find_lowest_addr(dev_info); in dcssblk_add_store()
626 dev_info->end = dcssblk_find_highest_addr(dev_info); in dcssblk_add_store()
628 dev_set_name(&dev_info->dev, "%s", dev_info->segment_name); in dcssblk_add_store()
629 dev_info->dev.release = dcssblk_release_segment; in dcssblk_add_store()
630 dev_info->dev.groups = dcssblk_dev_attr_groups; in dcssblk_add_store()
631 INIT_LIST_HEAD(&dev_info->lh); in dcssblk_add_store()
632 dev_info->gd = blk_alloc_disk(NUMA_NO_NODE); in dcssblk_add_store()
633 if (dev_info->gd == NULL) { in dcssblk_add_store()
637 dev_info->gd->major = dcssblk_major; in dcssblk_add_store()
638 dev_info->gd->minors = DCSSBLK_MINORS_PER_DISK; in dcssblk_add_store()
639 dev_info->gd->fops = &dcssblk_devops; in dcssblk_add_store()
640 dev_info->gd->private_data = dev_info; in dcssblk_add_store()
641 dev_info->gd->flags |= GENHD_FL_NO_PART; in dcssblk_add_store()
642 blk_queue_logical_block_size(dev_info->gd->queue, 4096); in dcssblk_add_store()
643 blk_queue_flag_set(QUEUE_FLAG_DAX, dev_info->gd->queue); in dcssblk_add_store()
645 seg_byte_size = (dev_info->end - dev_info->start + 1); in dcssblk_add_store()
646 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors in dcssblk_add_store()
650 dev_info->save_pending = 0; in dcssblk_add_store()
651 dev_info->is_shared = 1; in dcssblk_add_store()
652 dev_info->dev.parent = dcssblk_root_dev; in dcssblk_add_store()
662 rc = dcssblk_assign_free_minor(dev_info); in dcssblk_add_store()
665 sprintf(dev_info->gd->disk_name, "dcssblk%d", in dcssblk_add_store()
666 dev_info->gd->first_minor); in dcssblk_add_store()
667 list_add_tail(&dev_info->lh, &dcssblk_devices); in dcssblk_add_store()
676 rc = device_register(&dev_info->dev); in dcssblk_add_store()
680 dev_info->dax_dev = alloc_dax(dev_info, &dcssblk_dax_ops); in dcssblk_add_store()
681 if (IS_ERR(dev_info->dax_dev)) { in dcssblk_add_store()
682 rc = PTR_ERR(dev_info->dax_dev); in dcssblk_add_store()
683 dev_info->dax_dev = NULL; in dcssblk_add_store()
686 set_dax_synchronous(dev_info->dax_dev); in dcssblk_add_store()
687 rc = dax_add_host(dev_info->dax_dev, dev_info->gd); in dcssblk_add_store()
691 get_device(&dev_info->dev); in dcssblk_add_store()
692 rc = device_add_disk(&dev_info->dev, dev_info->gd, NULL); in dcssblk_add_store()
696 switch (dev_info->segment_type) { in dcssblk_add_store()
700 set_disk_ro(dev_info->gd,1); in dcssblk_add_store()
703 set_disk_ro(dev_info->gd,0); in dcssblk_add_store()
711 put_device(&dev_info->dev); in dcssblk_add_store()
712 dax_remove_host(dev_info->gd); in dcssblk_add_store()
714 kill_dax(dev_info->dax_dev); in dcssblk_add_store()
715 put_dax(dev_info->dax_dev); in dcssblk_add_store()
717 list_del(&dev_info->lh); in dcssblk_add_store()
718 put_disk(dev_info->gd); in dcssblk_add_store()
719 list_for_each_entry(seg_info, &dev_info->seg_list, lh) { in dcssblk_add_store()
722 put_device(&dev_info->dev); in dcssblk_add_store()
726 list_del(&dev_info->lh); in dcssblk_add_store()
728 put_disk(dev_info->gd); in dcssblk_add_store()
731 if (dev_info == NULL) in dcssblk_add_store()
733 list_for_each_entry_safe(seg_info, temp, &dev_info->seg_list, lh) { in dcssblk_add_store()
738 kfree(dev_info); in dcssblk_add_store()
751 struct dcssblk_dev_info *dev_info; in dcssblk_remove_store() local
776 dev_info = dcssblk_get_device_by_name(local_buf); in dcssblk_remove_store()
777 if (dev_info == NULL) { in dcssblk_remove_store()
784 if (atomic_read(&dev_info->use_count) != 0) { in dcssblk_remove_store()
792 list_del(&dev_info->lh); in dcssblk_remove_store()
794 list_for_each_entry(entry, &dev_info->seg_list, lh) in dcssblk_remove_store()
798 dax_remove_host(dev_info->gd); in dcssblk_remove_store()
799 kill_dax(dev_info->dax_dev); in dcssblk_remove_store()
800 put_dax(dev_info->dax_dev); in dcssblk_remove_store()
801 del_gendisk(dev_info->gd); in dcssblk_remove_store()
802 put_disk(dev_info->gd); in dcssblk_remove_store()
804 device_unregister(&dev_info->dev); in dcssblk_remove_store()
805 put_device(&dev_info->dev); in dcssblk_remove_store()
816 struct dcssblk_dev_info *dev_info = disk->private_data; in dcssblk_open() local
819 if (NULL == dev_info) { in dcssblk_open()
823 atomic_inc(&dev_info->use_count); in dcssblk_open()
832 struct dcssblk_dev_info *dev_info = disk->private_data; in dcssblk_release() local
835 if (!dev_info) { in dcssblk_release()
840 if (atomic_dec_and_test(&dev_info->use_count) in dcssblk_release()
841 && (dev_info->save_pending)) { in dcssblk_release()
843 "now\n", dev_info->segment_name); in dcssblk_release()
844 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_release()
852 dev_info->save_pending = 0; in dcssblk_release()
860 struct dcssblk_dev_info *dev_info; in dcssblk_submit_bio() local
869 dev_info = bio->bi_bdev->bd_disk->private_data; in dcssblk_submit_bio()
870 if (dev_info == NULL) in dcssblk_submit_bio()
877 if (dev_info->is_shared) { in dcssblk_submit_bio()
878 switch (dev_info->segment_type) { in dcssblk_submit_bio()
885 dev_name(&dev_info->dev)); in dcssblk_submit_bio()
894 source_addr = dev_info->start + (index<<12) + bytes_done; in dcssblk_submit_bio()
912 __dcssblk_direct_access(struct dcssblk_dev_info *dev_info, pgoff_t pgoff, in __dcssblk_direct_access() argument
918 dev_sz = dev_info->end - dev_info->start + 1; in __dcssblk_direct_access()
920 *kaddr = (void *) dev_info->start + offset; in __dcssblk_direct_access()
922 *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), in __dcssblk_direct_access()
933 struct dcssblk_dev_info *dev_info = dax_get_private(dax_dev); in dcssblk_dax_direct_access() local
935 return __dcssblk_direct_access(dev_info, pgoff, nr_pages, kaddr, pfn); in dcssblk_dax_direct_access()
943 struct dcssblk_dev_info *dev_info; in dcssblk_check_params() local
962 dev_info = dcssblk_get_device_by_name(buf); in dcssblk_check_params()
964 if (dev_info) in dcssblk_check_params()
965 dcssblk_shared_store(&dev_info->dev, in dcssblk_check_params()