Lines Matching full:hd
609 * Search hash table for a hydration with hd->region_nr == region_nr
616 struct dm_clone_region_hydration *hd; in __hash_find() local
618 hlist_for_each_entry(hd, &bucket->head, h) { in __hash_find()
619 if (hd->region_nr == region_nr) in __hash_find()
620 return hd; in __hash_find()
632 struct dm_clone_region_hydration *hd) in __insert_region_hydration() argument
634 hlist_add_head(&hd->h, &bucket->head); in __insert_region_hydration()
646 struct dm_clone_region_hydration *hd) in __find_or_insert_region_hydration() argument
650 hd2 = __hash_find(bucket, hd->region_nr); in __find_or_insert_region_hydration()
654 __insert_region_hydration(bucket, hd); in __find_or_insert_region_hydration()
656 return hd; in __find_or_insert_region_hydration()
664 struct dm_clone_region_hydration *hd; in alloc_hydration() local
670 hd = mempool_alloc(&clone->hydration_pool, GFP_NOIO); in alloc_hydration()
671 hd->clone = clone; in alloc_hydration()
673 return hd; in alloc_hydration()
676 static inline void free_hydration(struct dm_clone_region_hydration *hd) in free_hydration() argument
678 mempool_free(hd, &hd->clone->hydration_pool); in free_hydration()
682 static void hydration_init(struct dm_clone_region_hydration *hd, unsigned long region_nr) in hydration_init() argument
684 hd->region_nr = region_nr; in hydration_init()
685 hd->overwrite_bio = NULL; in hydration_init()
686 bio_list_init(&hd->deferred_bios); in hydration_init()
687 hd->status = 0; in hydration_init()
689 INIT_LIST_HEAD(&hd->list); in hydration_init()
690 INIT_HLIST_NODE(&hd->h); in hydration_init()
699 static int hydration_update_metadata(struct dm_clone_region_hydration *hd) in hydration_update_metadata() argument
704 struct clone *clone = hd->clone; in hydration_update_metadata()
710 if (likely(!r) && hd->status == BLK_STS_OK) in hydration_update_metadata()
711 r = dm_clone_set_region_hydrated(clone->cmd, hd->region_nr); in hydration_update_metadata()
713 bucket = get_hash_table_bucket(clone, hd->region_nr); in hydration_update_metadata()
717 hlist_del(&hd->h); in hydration_update_metadata()
733 static void hydration_complete(struct dm_clone_region_hydration *hd) in hydration_complete() argument
737 struct clone *clone = hd->clone; in hydration_complete()
739 r = hydration_update_metadata(hd); in hydration_complete()
741 if (hd->status == BLK_STS_OK && likely(!r)) { in hydration_complete()
742 if (hd->overwrite_bio) in hydration_complete()
743 complete_overwrite_bio(clone, hd->overwrite_bio); in hydration_complete()
745 issue_deferred_bios(clone, &hd->deferred_bios); in hydration_complete()
747 status = r ? BLK_STS_IOERR : hd->status; in hydration_complete()
749 if (hd->overwrite_bio) in hydration_complete()
750 bio_list_add(&hd->deferred_bios, hd->overwrite_bio); in hydration_complete()
752 fail_bios(&hd->deferred_bios, status); in hydration_complete()
755 free_hydration(hd); in hydration_complete()
765 struct dm_clone_region_hydration *tmp, *hd = context; in hydration_kcopyd_callback() local
766 struct clone *clone = hd->clone; in hydration_kcopyd_callback()
776 list_splice_tail(&hd->list, &batched_hydrations); in hydration_kcopyd_callback()
778 hd->status = status; in hydration_kcopyd_callback()
779 hydration_complete(hd); in hydration_kcopyd_callback()
782 list_for_each_entry_safe(hd, tmp, &batched_hydrations, list) { in hydration_kcopyd_callback()
783 hd->status = status; in hydration_kcopyd_callback()
784 hydration_complete(hd); in hydration_kcopyd_callback()
793 static void hydration_copy(struct dm_clone_region_hydration *hd, unsigned int nr_regions) in hydration_copy() argument
798 struct clone *clone = hd->clone; in hydration_copy()
804 region_start = hd->region_nr; in hydration_copy()
834 hydration_kcopyd_callback, hd); in hydration_copy()
839 struct dm_clone_region_hydration *hd = bio->bi_private; in overwrite_endio() local
841 bio->bi_end_io = hd->overwrite_bio_end_io; in overwrite_endio()
842 hd->status = bio->bi_status; in overwrite_endio()
844 hydration_complete(hd); in overwrite_endio()
847 static void hydration_overwrite(struct dm_clone_region_hydration *hd, struct bio *bio) in hydration_overwrite() argument
854 hd->overwrite_bio = bio; in hydration_overwrite()
855 hd->overwrite_bio_end_io = bio->bi_end_io; in hydration_overwrite()
858 bio->bi_private = hd; in hydration_overwrite()
860 atomic_inc(&hd->clone->hydrations_in_flight); in hydration_overwrite()
878 struct dm_clone_region_hydration *hd, *hd2; in hydrate_bio_region() local
885 hd = __hash_find(bucket, region_nr); in hydrate_bio_region()
886 if (hd) { in hydrate_bio_region()
888 bio_list_add(&hd->deferred_bios, bio); in hydrate_bio_region()
906 hd = alloc_hydration(clone); in hydrate_bio_region()
907 hydration_init(hd, region_nr); in hydrate_bio_region()
914 free_hydration(hd); in hydrate_bio_region()
919 hd2 = __find_or_insert_region_hydration(bucket, hd); in hydrate_bio_region()
920 if (hd2 != hd) { in hydrate_bio_region()
924 free_hydration(hd); in hydrate_bio_region()
934 hlist_del(&hd->h); in hydrate_bio_region()
936 free_hydration(hd); in hydrate_bio_region()
950 hydration_overwrite(hd, bio); in hydrate_bio_region()
952 bio_list_add(&hd->deferred_bios, bio); in hydrate_bio_region()
954 hydration_copy(hd, 1); in hydrate_bio_region()
979 struct dm_clone_region_hydration *hd) in __batch_hydration() argument
981 struct clone *clone = hd->clone; in __batch_hydration()
987 (batch->head->region_nr + batch->nr_batched_regions) == hd->region_nr) { in __batch_hydration()
988 list_add_tail(&hd->list, &batch->head->list); in __batch_hydration()
990 hd = NULL; in __batch_hydration()
994 if (batch->nr_batched_regions >= max_batch_size || hd) { in __batch_hydration()
1001 if (!hd) in __batch_hydration()
1006 hydration_copy(hd, 1); in __batch_hydration()
1011 BUG_ON(!list_empty(&hd->list)); in __batch_hydration()
1012 batch->head = hd; in __batch_hydration()
1021 struct dm_clone_region_hydration *hd; in __start_next_hydration() local
1024 hd = alloc_hydration(clone); in __start_next_hydration()
1037 hydration_init(hd, offset); in __start_next_hydration()
1038 __insert_region_hydration(bucket, hd); in __start_next_hydration()
1042 __batch_hydration(batch, hd); in __start_next_hydration()
1051 if (hd) in __start_next_hydration()
1052 free_hydration(hd); in __start_next_hydration()