Lines Matching refs:dev_info

124 	struct dcssblk_dev_info *dev_info;  in dcssblk_release_segment()  local
127 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_release_segment()
128 list_for_each_entry_safe(entry, temp, &dev_info->seg_list, lh) { in dcssblk_release_segment()
132 kfree(dev_info); in dcssblk_release_segment()
143 dcssblk_assign_free_minor(struct dcssblk_dev_info *dev_info) in dcssblk_assign_free_minor() argument
148 if (dev_info == NULL) in dcssblk_assign_free_minor()
160 dev_info->gd->first_minor = minor; in dcssblk_assign_free_minor()
190 struct dcssblk_dev_info *dev_info; in dcssblk_get_segment_by_name() local
193 list_for_each_entry(dev_info, &dcssblk_devices, lh) { in dcssblk_get_segment_by_name()
194 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_get_segment_by_name()
206 dcssblk_find_highest_addr(struct dcssblk_dev_info *dev_info) in dcssblk_find_highest_addr() argument
212 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_find_highest_addr()
223 dcssblk_find_lowest_addr(struct dcssblk_dev_info *dev_info) in dcssblk_find_lowest_addr() argument
231 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_find_lowest_addr()
247 dcssblk_is_continuous(struct dcssblk_dev_info *dev_info) in dcssblk_is_continuous() argument
252 if (dev_info->num_of_segments <= 1) in dcssblk_is_continuous()
255 sort_list = kcalloc(dev_info->num_of_segments, in dcssblk_is_continuous()
261 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_is_continuous()
267 for (i = 0; i < dev_info->num_of_segments; i++) in dcssblk_is_continuous()
268 for (j = 0; j < dev_info->num_of_segments; j++) in dcssblk_is_continuous()
279 for (i = 0; i < dev_info->num_of_segments - 1; i++) { in dcssblk_is_continuous()
351 struct dcssblk_dev_info *dev_info; in dcssblk_shared_show() local
353 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_shared_show()
354 return sprintf(buf, dev_info->is_shared ? "1\n" : "0\n"); in dcssblk_shared_show()
360 struct dcssblk_dev_info *dev_info; in dcssblk_shared_store() local
367 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_shared_store()
368 if (atomic_read(&dev_info->use_count)) { in dcssblk_shared_store()
374 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
383 dev_info->is_shared = 1; in dcssblk_shared_store()
384 switch (dev_info->segment_type) { in dcssblk_shared_store()
388 set_disk_ro(dev_info->gd, 1); in dcssblk_shared_store()
392 if (dev_info->segment_type == SEG_TYPE_SC) { in dcssblk_shared_store()
395 dev_info->segment_name); in dcssblk_shared_store()
399 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
408 dev_info->is_shared = 0; in dcssblk_shared_store()
409 set_disk_ro(dev_info->gd, 0); in dcssblk_shared_store()
419 "change\n", dev_info->segment_name); in dcssblk_shared_store()
421 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_shared_store()
425 list_del(&dev_info->lh); in dcssblk_shared_store()
427 kill_dax(dev_info->dax_dev); in dcssblk_shared_store()
428 put_dax(dev_info->dax_dev); in dcssblk_shared_store()
429 del_gendisk(dev_info->gd); in dcssblk_shared_store()
430 blk_cleanup_disk(dev_info->gd); in dcssblk_shared_store()
455 struct dcssblk_dev_info *dev_info; in dcssblk_save_show() local
457 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_save_show()
458 return sprintf(buf, dev_info->save_pending ? "1\n" : "0\n"); in dcssblk_save_show()
464 struct dcssblk_dev_info *dev_info; in dcssblk_save_store() local
469 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_save_store()
473 if (atomic_read(&dev_info->use_count) == 0) { in dcssblk_save_store()
476 "saved\n", dev_info->segment_name); in dcssblk_save_store()
477 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_save_store()
491 dev_info->segment_name); in dcssblk_save_store()
492 dev_info->save_pending = 1; in dcssblk_save_store()
495 if (dev_info->save_pending) { in dcssblk_save_store()
498 dev_info->save_pending = 0; in dcssblk_save_store()
501 dev_info->segment_name); in dcssblk_save_store()
522 struct dcssblk_dev_info *dev_info; in dcssblk_seglist_show() local
526 dev_info = container_of(dev, struct dcssblk_dev_info, dev); in dcssblk_seglist_show()
529 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_seglist_show()
561 struct dcssblk_dev_info *dev_info; in dcssblk_add_store() local
566 dev_info = NULL; in dcssblk_add_store()
607 dev_info = kzalloc(sizeof(struct dcssblk_dev_info), in dcssblk_add_store()
609 if (dev_info == NULL) { in dcssblk_add_store()
613 strcpy(dev_info->segment_name, local_buf); in dcssblk_add_store()
614 dev_info->segment_type = seg_info->segment_type; in dcssblk_add_store()
615 INIT_LIST_HEAD(&dev_info->seg_list); in dcssblk_add_store()
617 list_add_tail(&seg_info->lh, &dev_info->seg_list); in dcssblk_add_store()
631 dev_info->num_of_segments = num_of_segments; in dcssblk_add_store()
632 rc = dcssblk_is_continuous(dev_info); in dcssblk_add_store()
636 dev_info->start = dcssblk_find_lowest_addr(dev_info); in dcssblk_add_store()
637 dev_info->end = dcssblk_find_highest_addr(dev_info); in dcssblk_add_store()
639 dev_set_name(&dev_info->dev, "%s", dev_info->segment_name); in dcssblk_add_store()
640 dev_info->dev.release = dcssblk_release_segment; in dcssblk_add_store()
641 dev_info->dev.groups = dcssblk_dev_attr_groups; in dcssblk_add_store()
642 INIT_LIST_HEAD(&dev_info->lh); in dcssblk_add_store()
643 dev_info->gd = blk_alloc_disk(NUMA_NO_NODE); in dcssblk_add_store()
644 if (dev_info->gd == NULL) { in dcssblk_add_store()
648 dev_info->gd->major = dcssblk_major; in dcssblk_add_store()
649 dev_info->gd->minors = DCSSBLK_MINORS_PER_DISK; in dcssblk_add_store()
650 dev_info->gd->fops = &dcssblk_devops; in dcssblk_add_store()
651 dev_info->gd->private_data = dev_info; in dcssblk_add_store()
652 blk_queue_logical_block_size(dev_info->gd->queue, 4096); in dcssblk_add_store()
653 blk_queue_flag_set(QUEUE_FLAG_DAX, dev_info->gd->queue); in dcssblk_add_store()
655 seg_byte_size = (dev_info->end - dev_info->start + 1); in dcssblk_add_store()
656 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors in dcssblk_add_store()
660 dev_info->save_pending = 0; in dcssblk_add_store()
661 dev_info->is_shared = 1; in dcssblk_add_store()
662 dev_info->dev.parent = dcssblk_root_dev; in dcssblk_add_store()
672 rc = dcssblk_assign_free_minor(dev_info); in dcssblk_add_store()
675 sprintf(dev_info->gd->disk_name, "dcssblk%d", in dcssblk_add_store()
676 dev_info->gd->first_minor); in dcssblk_add_store()
677 list_add_tail(&dev_info->lh, &dcssblk_devices); in dcssblk_add_store()
686 rc = device_register(&dev_info->dev); in dcssblk_add_store()
690 dev_info->dax_dev = alloc_dax(dev_info, dev_info->gd->disk_name, in dcssblk_add_store()
692 if (IS_ERR(dev_info->dax_dev)) { in dcssblk_add_store()
693 rc = PTR_ERR(dev_info->dax_dev); in dcssblk_add_store()
694 dev_info->dax_dev = NULL; in dcssblk_add_store()
698 get_device(&dev_info->dev); in dcssblk_add_store()
699 rc = device_add_disk(&dev_info->dev, dev_info->gd, NULL); in dcssblk_add_store()
703 switch (dev_info->segment_type) { in dcssblk_add_store()
707 set_disk_ro(dev_info->gd,1); in dcssblk_add_store()
710 set_disk_ro(dev_info->gd,0); in dcssblk_add_store()
718 put_device(&dev_info->dev); in dcssblk_add_store()
719 kill_dax(dev_info->dax_dev); in dcssblk_add_store()
720 put_dax(dev_info->dax_dev); in dcssblk_add_store()
722 list_del(&dev_info->lh); in dcssblk_add_store()
723 blk_cleanup_disk(dev_info->gd); in dcssblk_add_store()
724 list_for_each_entry(seg_info, &dev_info->seg_list, lh) { in dcssblk_add_store()
727 put_device(&dev_info->dev); in dcssblk_add_store()
731 list_del(&dev_info->lh); in dcssblk_add_store()
733 blk_cleanup_disk(dev_info->gd); in dcssblk_add_store()
736 if (dev_info == NULL) in dcssblk_add_store()
738 list_for_each_entry_safe(seg_info, temp, &dev_info->seg_list, lh) { in dcssblk_add_store()
743 kfree(dev_info); in dcssblk_add_store()
756 struct dcssblk_dev_info *dev_info; in dcssblk_remove_store() local
781 dev_info = dcssblk_get_device_by_name(local_buf); in dcssblk_remove_store()
782 if (dev_info == NULL) { in dcssblk_remove_store()
789 if (atomic_read(&dev_info->use_count) != 0) { in dcssblk_remove_store()
797 list_del(&dev_info->lh); in dcssblk_remove_store()
798 kill_dax(dev_info->dax_dev); in dcssblk_remove_store()
799 put_dax(dev_info->dax_dev); in dcssblk_remove_store()
800 del_gendisk(dev_info->gd); in dcssblk_remove_store()
801 blk_cleanup_disk(dev_info->gd); in dcssblk_remove_store()
804 list_for_each_entry(entry, &dev_info->seg_list, lh) in dcssblk_remove_store()
809 device_unregister(&dev_info->dev); in dcssblk_remove_store()
810 put_device(&dev_info->dev); in dcssblk_remove_store()
821 struct dcssblk_dev_info *dev_info; in dcssblk_open() local
824 dev_info = bdev->bd_disk->private_data; in dcssblk_open()
825 if (NULL == dev_info) { in dcssblk_open()
829 atomic_inc(&dev_info->use_count); in dcssblk_open()
838 struct dcssblk_dev_info *dev_info = disk->private_data; in dcssblk_release() local
841 if (!dev_info) { in dcssblk_release()
846 if (atomic_dec_and_test(&dev_info->use_count) in dcssblk_release()
847 && (dev_info->save_pending)) { in dcssblk_release()
849 "now\n", dev_info->segment_name); in dcssblk_release()
850 list_for_each_entry(entry, &dev_info->seg_list, lh) { in dcssblk_release()
858 dev_info->save_pending = 0; in dcssblk_release()
866 struct dcssblk_dev_info *dev_info; in dcssblk_submit_bio() local
877 dev_info = bio->bi_bdev->bd_disk->private_data; in dcssblk_submit_bio()
878 if (dev_info == NULL) in dcssblk_submit_bio()
885 if (dev_info->is_shared) { in dcssblk_submit_bio()
886 switch (dev_info->segment_type) { in dcssblk_submit_bio()
893 dev_name(&dev_info->dev)); in dcssblk_submit_bio()
902 source_addr = dev_info->start + (index<<12) + bytes_done; in dcssblk_submit_bio()
922 __dcssblk_direct_access(struct dcssblk_dev_info *dev_info, pgoff_t pgoff, in __dcssblk_direct_access() argument
928 dev_sz = dev_info->end - dev_info->start + 1; in __dcssblk_direct_access()
930 *kaddr = (void *) dev_info->start + offset; in __dcssblk_direct_access()
932 *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), in __dcssblk_direct_access()
942 struct dcssblk_dev_info *dev_info = dax_get_private(dax_dev); in dcssblk_dax_direct_access() local
944 return __dcssblk_direct_access(dev_info, pgoff, nr_pages, kaddr, pfn); in dcssblk_dax_direct_access()
952 struct dcssblk_dev_info *dev_info; in dcssblk_check_params() local
971 dev_info = dcssblk_get_device_by_name(buf); in dcssblk_check_params()
973 if (dev_info) in dcssblk_check_params()
974 dcssblk_shared_store(&dev_info->dev, in dcssblk_check_params()