Lines Matching refs:clone

33 #include "dm-clone-metadata.h"
35 #define DM_MSG_PREFIX "clone"
60 /* dm-clone metadata modes */
69 struct clone {
141 * dm-clone flags
152 static enum clone_metadata_mode get_clone_mode(struct clone *clone)
154 return READ_ONCE(clone->mode);
157 static const char *clone_device_name(struct clone *clone)
159 return dm_table_device_name(clone->ti->table);
162 static void __set_clone_mode(struct clone *clone, enum clone_metadata_mode new_mode)
170 enum clone_metadata_mode old_mode = get_clone_mode(clone);
179 dm_clone_metadata_set_read_only(clone->cmd);
183 dm_clone_metadata_set_read_write(clone->cmd);
187 WRITE_ONCE(clone->mode, new_mode);
190 dm_table_event(clone->ti->table);
191 DMINFO("%s: Switching to %s mode", clone_device_name(clone),
196 static void __abort_transaction(struct clone *clone)
198 const char *dev_name = clone_device_name(clone);
200 if (get_clone_mode(clone) >= CM_READ_ONLY)
204 if (dm_clone_metadata_abort(clone->cmd)) {
206 __set_clone_mode(clone, CM_FAIL);
210 static void __reload_in_core_bitset(struct clone *clone)
212 const char *dev_name = clone_device_name(clone);
214 if (get_clone_mode(clone) == CM_FAIL)
219 if (dm_clone_reload_in_core_bitset(clone->cmd)) {
221 __set_clone_mode(clone, CM_FAIL);
225 static void __metadata_operation_failed(struct clone *clone, const char *op, int r)
228 clone_device_name(clone), op, r);
230 __abort_transaction(clone);
231 __set_clone_mode(clone, CM_READ_ONLY);
238 __reload_in_core_bitset(clone);
244 static inline void wakeup_hydration_waiters(struct clone *clone)
246 wake_up_all(&clone->hydration_stopped);
249 static inline void wake_worker(struct clone *clone)
251 queue_work(clone->wq, &clone->worker);
259 static inline void remap_to_source(struct clone *clone, struct bio *bio)
261 bio_set_dev(bio, clone->source_dev->bdev);
264 static inline void remap_to_dest(struct clone *clone, struct bio *bio)
266 bio_set_dev(bio, clone->dest_dev->bdev);
269 static bool bio_triggers_commit(struct clone *clone, struct bio *bio)
272 dm_clone_changed_this_transaction(clone->cmd);
276 static inline sector_t region_to_sector(struct clone *clone, unsigned long region_nr)
278 return ((sector_t)region_nr << clone->region_shift);
282 static inline unsigned long bio_to_region(struct clone *clone, struct bio *bio)
284 return (bio->bi_iter.bi_sector >> clone->region_shift);
288 static void bio_region_range(struct clone *clone, struct bio *bio,
293 *rs = dm_sector_div_up(bio->bi_iter.bi_sector, clone->region_size);
294 end = bio_end_sector(bio) >> clone->region_shift;
303 static inline bool is_overwrite_bio(struct clone *clone, struct bio *bio)
305 return (bio_data_dir(bio) == WRITE && bio_sectors(bio) == clone->region_size);
339 static void issue_bio(struct clone *clone, struct bio *bio)
341 if (!bio_triggers_commit(clone, bio)) {
350 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY)) {
359 spin_lock_irq(&clone->lock);
360 bio_list_add(&clone->deferred_flush_bios, bio);
361 spin_unlock_irq(&clone->lock);
363 wake_worker(clone);
372 static void remap_and_issue(struct clone *clone, struct bio *bio)
374 remap_to_dest(clone, bio);
375 issue_bio(clone, bio);
385 static void issue_deferred_bios(struct clone *clone, struct bio_list *bios)
396 if (bio_triggers_commit(clone, bio))
402 spin_lock_irqsave(&clone->lock, flags);
403 bio_list_merge(&clone->deferred_bios, &normal_bios);
404 bio_list_merge(&clone->deferred_flush_bios, &flush_bios);
405 spin_unlock_irqrestore(&clone->lock, flags);
407 wake_worker(clone);
410 static void complete_overwrite_bio(struct clone *clone, struct bio *bio)
433 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY)) {
442 spin_lock_irqsave(&clone->lock, flags);
443 bio_list_add(&clone->deferred_flush_completions, bio);
444 spin_unlock_irqrestore(&clone->lock, flags);
446 wake_worker(clone);
455 static void complete_discard_bio(struct clone *clone, struct bio *bio, bool success)
464 if (test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags) && success) {
465 remap_to_dest(clone, bio);
466 bio_region_range(clone, bio, &rs, &nr_regions);
467 trim_bio(bio, region_to_sector(clone, rs),
468 nr_regions << clone->region_shift);
474 static void process_discard_bio(struct clone *clone, struct bio *bio)
478 bio_region_range(clone, bio, &rs, &nr_regions);
484 if (WARN_ON(rs >= clone->nr_regions || (rs + nr_regions) < rs ||
485 (rs + nr_regions) > clone->nr_regions)) {
487 clone_device_name(clone), rs, nr_regions,
488 clone->nr_regions,
499 if (dm_clone_is_range_hydrated(clone->cmd, rs, nr_regions)) {
500 complete_discard_bio(clone, bio, true);
509 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY)) {
517 spin_lock_irq(&clone->lock);
518 bio_list_add(&clone->deferred_discard_bios, bio);
519 spin_unlock_irq(&clone->lock);
521 wake_worker(clone);
527 * dm-clone region hydrations.
530 struct clone *clone;
576 static int hash_table_init(struct clone *clone)
583 clone->ht = kvmalloc_array(sz, sizeof(struct hash_table_bucket), GFP_KERNEL);
584 if (!clone->ht)
588 bucket = clone->ht + i;
597 static void hash_table_exit(struct clone *clone)
599 kvfree(clone->ht);
602 static struct hash_table_bucket *get_hash_table_bucket(struct clone *clone,
605 return &clone->ht[hash_long(region_nr, HASH_TABLE_BITS)];
662 static struct dm_clone_region_hydration *alloc_hydration(struct clone *clone)
670 hd = mempool_alloc(&clone->hydration_pool, GFP_NOIO);
671 hd->clone = clone;
678 mempool_free(hd, &hd->clone->hydration_pool);
696 * Update dm-clone's metadata after a region has finished hydrating and remove
704 struct clone *clone = hd->clone;
706 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY))
711 r = dm_clone_set_region_hydrated(clone->cmd, hd->region_nr);
713 bucket = get_hash_table_bucket(clone, hd->region_nr);
726 * 1. Update dm-clone's metadata.
737 struct clone *clone = hd->clone;
743 complete_overwrite_bio(clone, hd->overwrite_bio);
745 issue_deferred_bios(clone, &hd->deferred_bios);
757 if (atomic_dec_and_test(&clone->hydrations_in_flight))
758 wakeup_hydration_waiters(clone);
766 struct clone *clone = hd->clone;
771 DMERR_LIMIT("%s: hydration failed", clone_device_name(clone));
788 if (test_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags) &&
789 !atomic_read(&clone->ios_in_flight))
790 wake_worker(clone);
798 struct clone *clone = hd->clone;
803 region_size = clone->region_size;
807 total_size = region_to_sector(clone, nr_regions - 1);
809 if (region_end == clone->nr_regions - 1) {
814 tail_size = clone->ti->len & (region_size - 1);
823 from.bdev = clone->source_dev->bdev;
824 from.sector = region_to_sector(clone, region_start);
827 to.bdev = clone->dest_dev->bdev;
832 atomic_add(nr_regions, &clone->hydrations_in_flight);
833 dm_kcopyd_copy(clone->kcopyd_client, &from, 1, &to, 0,
860 atomic_inc(&hd->clone->hydrations_in_flight);
874 static void hydrate_bio_region(struct clone *clone, struct bio *bio)
880 region_nr = bio_to_region(clone, bio);
881 bucket = get_hash_table_bucket(clone, region_nr);
893 if (dm_clone_is_region_hydrated(clone->cmd, region_nr)) {
896 issue_bio(clone, bio);
906 hd = alloc_hydration(clone);
912 if (dm_clone_is_region_hydrated(clone->cmd, region_nr)) {
915 issue_bio(clone, bio);
933 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY)) {
948 if (is_overwrite_bio(clone, bio)) {
981 struct clone *clone = hd->clone;
982 unsigned int max_batch_size = READ_ONCE(clone->hydration_batch_size);
1016 static unsigned long __start_next_hydration(struct clone *clone,
1022 unsigned long nr_regions = clone->nr_regions;
1024 hd = alloc_hydration(clone);
1028 offset = dm_clone_find_next_unhydrated_region(clone->cmd, offset);
1032 bucket = get_hash_table_bucket(clone, offset);
1035 if (!dm_clone_is_region_hydrated(clone->cmd, offset) &&
1061 static void do_hydration(struct clone *clone)
1064 unsigned long offset, nr_regions = clone->nr_regions;
1071 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY))
1074 if (dm_clone_is_hydration_done(clone->cmd))
1080 atomic_inc(&clone->hydrations_in_flight);
1092 offset = clone->hydration_offset;
1093 while (likely(!test_bit(DM_CLONE_HYDRATION_SUSPENDED, &clone->flags)) &&
1094 !atomic_read(&clone->ios_in_flight) &&
1095 test_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags) &&
1097 current_volume = atomic_read(&clone->hydrations_in_flight);
1100 if (current_volume > READ_ONCE(clone->hydration_threshold))
1103 offset = __start_next_hydration(clone, offset, &batch);
1112 clone->hydration_offset = offset;
1114 if (atomic_dec_and_test(&clone->hydrations_in_flight))
1115 wakeup_hydration_waiters(clone);
1120 static bool need_commit_due_to_time(struct clone *clone)
1122 return !time_in_range(jiffies, clone->last_commit_jiffies,
1123 clone->last_commit_jiffies + COMMIT_PERIOD);
1129 static int commit_metadata(struct clone *clone, bool *dest_dev_flushed)
1136 mutex_lock(&clone->commit_lock);
1138 if (!dm_clone_changed_this_transaction(clone->cmd))
1141 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY)) {
1146 r = dm_clone_metadata_pre_commit(clone->cmd);
1148 __metadata_operation_failed(clone, "dm_clone_metadata_pre_commit", r);
1152 r = blkdev_issue_flush(clone->dest_dev->bdev);
1154 __metadata_operation_failed(clone, "flush destination device", r);
1161 r = dm_clone_metadata_commit(clone->cmd);
1163 __metadata_operation_failed(clone, "dm_clone_metadata_commit", r);
1167 if (dm_clone_is_hydration_done(clone->cmd))
1168 dm_table_event(clone->ti->table);
1170 mutex_unlock(&clone->commit_lock);
1175 static void process_deferred_discards(struct clone *clone)
1183 spin_lock_irq(&clone->lock);
1184 bio_list_merge(&discards, &clone->deferred_discard_bios);
1185 bio_list_init(&clone->deferred_discard_bios);
1186 spin_unlock_irq(&clone->lock);
1191 if (unlikely(get_clone_mode(clone) >= CM_READ_ONLY))
1196 bio_region_range(clone, bio, &rs, &nr_regions);
1202 r = dm_clone_cond_set_range(clone->cmd, rs, nr_regions);
1209 complete_discard_bio(clone, bio, r == 0);
1213 static void process_deferred_bios(struct clone *clone)
1217 spin_lock_irq(&clone->lock);
1218 bio_list_merge(&bios, &clone->deferred_bios);
1219 bio_list_init(&clone->deferred_bios);
1220 spin_unlock_irq(&clone->lock);
1228 static void process_deferred_flush_bios(struct clone *clone)
1239 spin_lock_irq(&clone->lock);
1240 bio_list_merge(&bios, &clone->deferred_flush_bios);
1241 bio_list_init(&clone->deferred_flush_bios);
1243 bio_list_merge(&bio_completions, &clone->deferred_flush_completions);
1244 bio_list_init(&clone->deferred_flush_completions);
1245 spin_unlock_irq(&clone->lock);
1248 !(dm_clone_changed_this_transaction(clone->cmd) && need_commit_due_to_time(clone)))
1251 if (commit_metadata(clone, &dest_dev_flushed)) {
1260 clone->last_commit_jiffies = jiffies;
1280 struct clone *clone = container_of(work, typeof(*clone), worker);
1282 process_deferred_bios(clone);
1283 process_deferred_discards(clone);
1294 process_deferred_flush_bios(clone);
1297 do_hydration(clone);
1307 struct clone *clone = container_of(to_delayed_work(work), struct clone, waker);
1309 wake_worker(clone);
1310 queue_delayed_work(clone->wq, &clone->waker, COMMIT_PERIOD);
1320 struct clone *clone = ti->private;
1323 atomic_inc(&clone->ios_in_flight);
1325 if (unlikely(get_clone_mode(clone) == CM_FAIL))
1336 remap_and_issue(clone, bio);
1343 * dm-clone interprets discards and performs a fast hydration of the
1348 process_discard_bio(clone, bio);
1362 region_nr = bio_to_region(clone, bio);
1363 if (dm_clone_is_region_hydrated(clone->cmd, region_nr)) {
1364 remap_and_issue(clone, bio);
1367 remap_to_source(clone, bio);
1371 remap_to_dest(clone, bio);
1372 hydrate_bio_region(clone, bio);
1379 struct clone *clone = ti->private;
1381 atomic_dec(&clone->ios_in_flight);
1386 static void emit_flags(struct clone *clone, char *result, unsigned int maxlen,
1392 count = !test_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags);
1393 count += !test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
1397 if (!test_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags))
1400 if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags))
1406 static void emit_core_args(struct clone *clone, char *result,
1413 READ_ONCE(clone->hydration_threshold),
1414 READ_ONCE(clone->hydration_batch_size));
1423 * <clone region size> <#hydrated regions>/<#total regions> <#hydrating regions>
1424 * <#features> <features>* <#core args> <core args>* <clone metadata mode>
1436 struct clone *clone = ti->private;
1440 if (get_clone_mode(clone) == CM_FAIL) {
1447 (void) commit_metadata(clone, NULL);
1449 r = dm_clone_get_free_metadata_block_count(clone->cmd, &nr_free_metadata_blocks);
1453 clone_device_name(clone), r);
1457 r = dm_clone_get_metadata_dev_size(clone->cmd, &nr_metadata_blocks);
1461 clone_device_name(clone), r);
1469 (unsigned long long)clone->region_size,
1470 dm_clone_nr_of_hydrated_regions(clone->cmd),
1471 clone->nr_regions,
1472 atomic_read(&clone->hydrations_in_flight));
1474 emit_flags(clone, result, maxlen, &sz);
1475 emit_core_args(clone, result, maxlen, &sz);
1477 switch (get_clone_mode(clone)) {
1491 format_dev_t(buf, clone->metadata_dev->bdev->bd_dev);
1494 format_dev_t(buf, clone->dest_dev->bdev->bd_dev);
1497 format_dev_t(buf, clone->source_dev->bdev->bd_dev);
1500 for (i = 0; i < clone->nr_ctr_args; i++)
1501 DMEMIT(" %s", clone->ctr_args[i]);
1523 * Construct a clone device mapping:
1525 * clone <metadata dev> <destination dev> <source dev> <region size>
1529 * destination dev: The destination device, which will become a clone of the
1532 * region size: dm-clone unit size in sectors
1541 static int parse_feature_args(struct dm_arg_set *as, struct clone *clone)
1546 struct dm_target *ti = clone->ti;
1567 __clear_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags);
1569 __clear_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
1579 static int parse_core_args(struct dm_arg_set *as, struct clone *clone)
1585 struct dm_target *ti = clone->ti;
1594 clone->hydration_batch_size = DEFAULT_HYDRATION_BATCH_SIZE;
1595 clone->hydration_threshold = DEFAULT_HYDRATION_THRESHOLD;
1619 clone->hydration_threshold = value;
1625 clone->hydration_batch_size = value;
1635 static int parse_region_size(struct clone *clone, struct dm_arg_set *as, char **error)
1656 if (region_size % (bdev_logical_block_size(clone->source_dev->bdev) >> 9) ||
1657 region_size % (bdev_logical_block_size(clone->dest_dev->bdev) >> 9)) {
1662 clone->region_size = region_size;
1681 static int parse_metadata_dev(struct clone *clone, struct dm_arg_set *as, char **error)
1686 r = dm_get_device(clone->ti, dm_shift_arg(as),
1687 BLK_OPEN_READ | BLK_OPEN_WRITE, &clone->metadata_dev);
1693 metadata_dev_size = get_dev_size(clone->metadata_dev);
1696 clone->metadata_dev->bdev, DM_CLONE_METADATA_MAX_SECTORS);
1701 static int parse_dest_dev(struct clone *clone, struct dm_arg_set *as, char **error)
1706 r = dm_get_device(clone->ti, dm_shift_arg(as),
1707 BLK_OPEN_READ | BLK_OPEN_WRITE, &clone->dest_dev);
1713 dest_dev_size = get_dev_size(clone->dest_dev);
1714 if (dest_dev_size < clone->ti->len) {
1715 dm_put_device(clone->ti, clone->dest_dev);
1723 static int parse_source_dev(struct clone *clone, struct dm_arg_set *as, char **error)
1728 r = dm_get_device(clone->ti, dm_shift_arg(as), BLK_OPEN_READ,
1729 &clone->source_dev);
1735 source_dev_size = get_dev_size(clone->source_dev);
1736 if (source_dev_size < clone->ti->len) {
1737 dm_put_device(clone->ti, clone->source_dev);
1745 static int copy_ctr_args(struct clone *clone, int argc, const char **argv, char **error)
1765 clone->nr_ctr_args = argc;
1766 clone->ctr_args = copy;
1778 struct clone *clone;
1789 clone = kzalloc(sizeof(*clone), GFP_KERNEL);
1790 if (!clone) {
1791 ti->error = "Failed to allocate clone structure";
1795 clone->ti = ti;
1797 /* Initialize dm-clone flags */
1798 __set_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags);
1799 __set_bit(DM_CLONE_HYDRATION_SUSPENDED, &clone->flags);
1800 __set_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
1802 r = parse_metadata_dev(clone, &as, &ti->error);
1806 r = parse_dest_dev(clone, &as, &ti->error);
1810 r = parse_source_dev(clone, &as, &ti->error);
1814 r = parse_region_size(clone, &as, &ti->error);
1818 clone->region_shift = __ffs(clone->region_size);
1819 nr_regions = dm_sector_div_up(ti->len, clone->region_size);
1828 clone->nr_regions = nr_regions;
1830 r = validate_nr_regions(clone->nr_regions, &ti->error);
1834 r = dm_set_target_max_io_len(ti, clone->region_size);
1840 r = parse_feature_args(&as, clone);
1844 r = parse_core_args(&as, clone);
1849 clone->cmd = dm_clone_metadata_open(clone->metadata_dev->bdev, ti->len,
1850 clone->region_size);
1851 if (IS_ERR(clone->cmd)) {
1853 r = PTR_ERR(clone->cmd);
1857 __set_clone_mode(clone, CM_WRITE);
1859 if (get_clone_mode(clone) != CM_WRITE) {
1865 clone->last_commit_jiffies = jiffies;
1868 r = hash_table_init(clone);
1874 atomic_set(&clone->ios_in_flight, 0);
1875 init_waitqueue_head(&clone->hydration_stopped);
1876 spin_lock_init(&clone->lock);
1877 bio_list_init(&clone->deferred_bios);
1878 bio_list_init(&clone->deferred_discard_bios);
1879 bio_list_init(&clone->deferred_flush_bios);
1880 bio_list_init(&clone->deferred_flush_completions);
1881 clone->hydration_offset = 0;
1882 atomic_set(&clone->hydrations_in_flight, 0);
1884 clone->wq = alloc_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM, 0);
1885 if (!clone->wq) {
1891 INIT_WORK(&clone->worker, do_worker);
1892 INIT_DELAYED_WORK(&clone->waker, do_waker);
1894 clone->kcopyd_client = dm_kcopyd_client_create(&dm_kcopyd_throttle);
1895 if (IS_ERR(clone->kcopyd_client)) {
1896 r = PTR_ERR(clone->kcopyd_client);
1900 r = mempool_init_slab_pool(&clone->hydration_pool, MIN_HYDRATIONS,
1908 r = copy_ctr_args(clone, argc - 3, (const char **)argv + 3, &ti->error);
1912 mutex_init(&clone->commit_lock);
1922 ti->private = clone;
1927 mempool_exit(&clone->hydration_pool);
1929 dm_kcopyd_client_destroy(clone->kcopyd_client);
1931 destroy_workqueue(clone->wq);
1933 hash_table_exit(clone);
1935 dm_clone_metadata_close(clone->cmd);
1937 dm_put_device(ti, clone->source_dev);
1939 dm_put_device(ti, clone->dest_dev);
1941 dm_put_device(ti, clone->metadata_dev);
1943 kfree(clone);
1951 struct clone *clone = ti->private;
1953 mutex_destroy(&clone->commit_lock);
1955 for (i = 0; i < clone->nr_ctr_args; i++)
1956 kfree(clone->ctr_args[i]);
1957 kfree(clone->ctr_args);
1959 mempool_exit(&clone->hydration_pool);
1960 dm_kcopyd_client_destroy(clone->kcopyd_client);
1961 cancel_delayed_work_sync(&clone->waker);
1962 destroy_workqueue(clone->wq);
1963 hash_table_exit(clone);
1964 dm_clone_metadata_close(clone->cmd);
1965 dm_put_device(ti, clone->source_dev);
1966 dm_put_device(ti, clone->dest_dev);
1967 dm_put_device(ti, clone->metadata_dev);
1969 kfree(clone);
1976 struct clone *clone = ti->private;
1993 cancel_delayed_work_sync(&clone->waker);
1995 set_bit(DM_CLONE_HYDRATION_SUSPENDED, &clone->flags);
2006 wait_event(clone->hydration_stopped, !atomic_read(&clone->hydrations_in_flight));
2007 flush_workqueue(clone->wq);
2009 (void) commit_metadata(clone, NULL);
2014 struct clone *clone = ti->private;
2016 clear_bit(DM_CLONE_HYDRATION_SUSPENDED, &clone->flags);
2017 do_waker(&clone->waker.work);
2024 static void disable_passdown_if_not_supported(struct clone *clone)
2026 struct block_device *dest_dev = clone->dest_dev->bdev;
2030 if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags))
2035 else if (dest_limits->max_discard_sectors < clone->region_size)
2041 clear_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
2045 static void set_discard_limits(struct clone *clone, struct queue_limits *limits)
2047 struct block_device *dest_bdev = clone->dest_dev->bdev;
2050 if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags)) {
2052 limits->discard_granularity = clone->region_size << SECTOR_SHIFT;
2053 limits->max_discard_sectors = round_down(UINT_MAX >> SECTOR_SHIFT, clone->region_size);
2072 struct clone *clone = ti->private;
2077 * dm-clone's region size (io_opt is a factor) do not override them.
2079 if (io_opt_sectors < clone->region_size ||
2080 do_div(io_opt_sectors, clone->region_size)) {
2081 blk_limits_io_min(limits, clone->region_size << SECTOR_SHIFT);
2082 blk_limits_io_opt(limits, clone->region_size << SECTOR_SHIFT);
2085 disable_passdown_if_not_supported(clone);
2086 set_discard_limits(clone, limits);
2093 struct clone *clone = ti->private;
2094 struct dm_dev *dest_dev = clone->dest_dev;
2095 struct dm_dev *source_dev = clone->source_dev;
2104 * dm-clone message functions.
2106 static void set_hydration_threshold(struct clone *clone, unsigned int nr_regions)
2108 WRITE_ONCE(clone->hydration_threshold, nr_regions);
2115 wake_worker(clone);
2118 static void set_hydration_batch_size(struct clone *clone, unsigned int nr_regions)
2120 WRITE_ONCE(clone->hydration_batch_size, nr_regions);
2123 static void enable_hydration(struct clone *clone)
2125 if (!test_and_set_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags))
2126 wake_worker(clone);
2129 static void disable_hydration(struct clone *clone)
2131 clear_bit(DM_CLONE_HYDRATION_ENABLED, &clone->flags);
2137 struct clone *clone = ti->private;
2144 enable_hydration(clone);
2149 disable_hydration(clone);
2160 set_hydration_threshold(clone, value);
2169 set_hydration_batch_size(clone, value);
2174 DMERR("%s: Unsupported message `%s'", clone_device_name(clone), argv[0]);
2179 .name = "clone",
2226 MODULE_DESCRIPTION(DM_NAME " clone target");