• Home
  • Raw
  • Download

Lines Matching full:era

15 #define DM_MSG_PREFIX "era"
45 * after digesting into the era array.
208 DMERR("Era metadata version %u found, but only versions between %u and %u supported.", in check_metadata_version()
273 * We preallocate 2 writesets. When an era rolls over we
452 DMERR("couldn't create era array"); in create_fresh_metadata()
658 * Writesets get 'digested' into the main era array.
665 uint32_t era; member
681 uint64_t key = d->era; in metadata_digest_remove_writeset()
742 d->era = key; in metadata_digest_lookup_writeset()
943 DMERR("%s: new era failed", __func__); in metadata_era_rollover()
1011 * Metadata snapshots allow userland to access era data.
1025 DMERR("%s: era rollover failed", __func__); in metadata_take_snap()
1059 DMERR("%s: couldn't inc era tree root", __func__); in metadata_take_snap()
1107 DMERR("%s: error deleting era array clone", __func__); in metadata_drop_snap()
1122 uint32_t era; member
1146 s->era = md->current_era; in metadata_get_stats()
1153 struct era { struct
1191 static bool block_size_is_power_of_two(struct era *era) in block_size_is_power_of_two() argument
1193 return era->sectors_per_block_shift >= 0; in block_size_is_power_of_two()
1196 static dm_block_t get_block(struct era *era, struct bio *bio) in get_block() argument
1200 if (!block_size_is_power_of_two(era)) in get_block()
1201 (void) sector_div(block_nr, era->sectors_per_block); in get_block()
1203 block_nr >>= era->sectors_per_block_shift; in get_block()
1208 static void remap_to_origin(struct era *era, struct bio *bio) in remap_to_origin() argument
1210 bio_set_dev(bio, era->origin_dev->bdev); in remap_to_origin()
1216 static void wake_worker(struct era *era) in wake_worker() argument
1218 if (!atomic_read(&era->suspended)) in wake_worker()
1219 queue_work(era->wq, &era->worker); in wake_worker()
1222 static void process_old_eras(struct era *era) in process_old_eras() argument
1226 if (!era->digest.step) in process_old_eras()
1229 r = era->digest.step(era->md, &era->digest); in process_old_eras()
1232 era->digest.step = NULL; in process_old_eras()
1234 } else if (era->digest.step) in process_old_eras()
1235 wake_worker(era); in process_old_eras()
1238 static void process_deferred_bios(struct era *era) in process_deferred_bios() argument
1246 struct writeset *ws = era->md->current_writeset; in process_deferred_bios()
1251 spin_lock(&era->deferred_lock); in process_deferred_bios()
1252 bio_list_merge(&deferred_bios, &era->deferred_bios); in process_deferred_bios()
1253 bio_list_init(&era->deferred_bios); in process_deferred_bios()
1254 spin_unlock(&era->deferred_lock); in process_deferred_bios()
1260 r = writeset_test_and_set(&era->md->bitset_info, ws, in process_deferred_bios()
1261 get_block(era, bio)); in process_deferred_bios()
1275 r = metadata_commit(era->md); in process_deferred_bios()
1291 set_bit(get_block(era, bio), ws->bits); in process_deferred_bios()
1298 static void process_rpc_calls(struct era *era) in process_rpc_calls() argument
1306 spin_lock(&era->rpc_lock); in process_rpc_calls()
1307 list_splice_init(&era->rpc_calls, &calls); in process_rpc_calls()
1308 spin_unlock(&era->rpc_lock); in process_rpc_calls()
1311 rpc->result = rpc->fn0 ? rpc->fn0(era->md) : rpc->fn1(era->md, rpc->arg); in process_rpc_calls()
1316 r = metadata_commit(era->md); in process_rpc_calls()
1326 static void kick_off_digest(struct era *era) in kick_off_digest() argument
1328 if (era->md->archived_writesets) { in kick_off_digest()
1329 era->md->archived_writesets = false; in kick_off_digest()
1330 metadata_digest_start(era->md, &era->digest); in kick_off_digest()
1336 struct era *era = container_of(ws, struct era, worker); in do_work() local
1338 kick_off_digest(era); in do_work()
1339 process_old_eras(era); in do_work()
1340 process_deferred_bios(era); in do_work()
1341 process_rpc_calls(era); in do_work()
1344 static void defer_bio(struct era *era, struct bio *bio) in defer_bio() argument
1346 spin_lock(&era->deferred_lock); in defer_bio()
1347 bio_list_add(&era->deferred_bios, bio); in defer_bio()
1348 spin_unlock(&era->deferred_lock); in defer_bio()
1350 wake_worker(era); in defer_bio()
1356 static int perform_rpc(struct era *era, struct rpc *rpc) in perform_rpc() argument
1361 spin_lock(&era->rpc_lock); in perform_rpc()
1362 list_add(&rpc->list, &era->rpc_calls); in perform_rpc()
1363 spin_unlock(&era->rpc_lock); in perform_rpc()
1365 wake_worker(era); in perform_rpc()
1371 static int in_worker0(struct era *era, int (*fn)(struct era_metadata *)) in in_worker0() argument
1377 return perform_rpc(era, &rpc); in in_worker0()
1380 static int in_worker1(struct era *era, in in_worker1() argument
1388 return perform_rpc(era, &rpc); in in_worker1()
1391 static void start_worker(struct era *era) in start_worker() argument
1393 atomic_set(&era->suspended, 0); in start_worker()
1396 static void stop_worker(struct era *era) in stop_worker() argument
1398 atomic_set(&era->suspended, 1); in stop_worker()
1399 drain_workqueue(era->wq); in stop_worker()
1405 static void era_destroy(struct era *era) in era_destroy() argument
1407 if (era->md) in era_destroy()
1408 metadata_close(era->md); in era_destroy()
1410 if (era->wq) in era_destroy()
1411 destroy_workqueue(era->wq); in era_destroy()
1413 if (era->origin_dev) in era_destroy()
1414 dm_put_device(era->ti, era->origin_dev); in era_destroy()
1416 if (era->metadata_dev) in era_destroy()
1417 dm_put_device(era->ti, era->metadata_dev); in era_destroy()
1419 kfree(era); in era_destroy()
1422 static dm_block_t calc_nr_blocks(struct era *era) in calc_nr_blocks() argument
1424 return dm_sector_div_up(era->ti->len, era->sectors_per_block); in calc_nr_blocks()
1442 struct era *era; in era_ctr() local
1450 era = kzalloc(sizeof(*era), GFP_KERNEL); in era_ctr()
1451 if (!era) { in era_ctr()
1452 ti->error = "Error allocating era structure"; in era_ctr()
1456 era->ti = ti; in era_ctr()
1458 r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &era->metadata_dev); in era_ctr()
1461 era_destroy(era); in era_ctr()
1465 r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &era->origin_dev); in era_ctr()
1468 era_destroy(era); in era_ctr()
1472 r = sscanf(argv[2], "%u%c", &era->sectors_per_block, &dummy); in era_ctr()
1475 era_destroy(era); in era_ctr()
1479 r = dm_set_target_max_io_len(ti, era->sectors_per_block); in era_ctr()
1482 era_destroy(era); in era_ctr()
1486 if (!valid_block_size(era->sectors_per_block)) { in era_ctr()
1488 era_destroy(era); in era_ctr()
1491 if (era->sectors_per_block & (era->sectors_per_block - 1)) in era_ctr()
1492 era->sectors_per_block_shift = -1; in era_ctr()
1494 era->sectors_per_block_shift = __ffs(era->sectors_per_block); in era_ctr()
1496 md = metadata_open(era->metadata_dev->bdev, era->sectors_per_block, true); in era_ctr()
1499 era_destroy(era); in era_ctr()
1502 era->md = md; in era_ctr()
1504 era->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM); in era_ctr()
1505 if (!era->wq) { in era_ctr()
1507 era_destroy(era); in era_ctr()
1510 INIT_WORK(&era->worker, do_work); in era_ctr()
1512 spin_lock_init(&era->deferred_lock); in era_ctr()
1513 bio_list_init(&era->deferred_bios); in era_ctr()
1515 spin_lock_init(&era->rpc_lock); in era_ctr()
1516 INIT_LIST_HEAD(&era->rpc_calls); in era_ctr()
1518 ti->private = era; in era_ctr()
1534 struct era *era = ti->private; in era_map() local
1535 dm_block_t block = get_block(era, bio); in era_map()
1540 * block is marked in this era. in era_map()
1542 remap_to_origin(era, bio); in era_map()
1549 !metadata_current_marked(era->md, block)) { in era_map()
1550 defer_bio(era, bio); in era_map()
1560 struct era *era = ti->private; in era_postsuspend() local
1562 r = in_worker0(era, metadata_era_archive); in era_postsuspend()
1564 DMERR("%s: couldn't archive current era", __func__); in era_postsuspend()
1568 stop_worker(era); in era_postsuspend()
1570 r = metadata_commit(era->md); in era_postsuspend()
1580 struct era *era = ti->private; in era_preresume() local
1581 dm_block_t new_size = calc_nr_blocks(era); in era_preresume()
1583 if (era->nr_blocks != new_size) { in era_preresume()
1584 r = metadata_resize(era->md, &new_size); in era_preresume()
1590 r = metadata_commit(era->md); in era_preresume()
1596 era->nr_blocks = new_size; in era_preresume()
1599 start_worker(era); in era_preresume()
1601 r = in_worker0(era, metadata_era_rollover); in era_preresume()
1614 * <current era> <held metadata root | '-'>
1620 struct era *era = ti->private; in era_status() local
1627 r = in_worker1(era, metadata_get_stats, &stats); in era_status()
1635 (unsigned) stats.era); in era_status()
1644 format_dev_t(buf, era->metadata_dev->bdev->bd_dev); in era_status()
1646 format_dev_t(buf, era->origin_dev->bdev->bd_dev); in era_status()
1647 DMEMIT("%s %u", buf, era->sectors_per_block); in era_status()
1660 struct era *era = ti->private; in era_message() local
1668 return in_worker0(era, metadata_checkpoint); in era_message()
1671 return in_worker0(era, metadata_take_snap); in era_message()
1674 return in_worker0(era, metadata_drop_snap); in era_message()
1688 struct era *era = ti->private; in era_iterate_devices() local
1689 return fn(ti, era->origin_dev, 0, get_dev_size(era->origin_dev), data); in era_iterate_devices()
1694 struct era *era = ti->private; in era_io_hints() local
1699 * era device's blocksize (io_opt is a factor) do not override them. in era_io_hints()
1701 if (io_opt_sectors < era->sectors_per_block || in era_io_hints()
1702 do_div(io_opt_sectors, era->sectors_per_block)) { in era_io_hints()
1704 blk_limits_io_opt(limits, era->sectors_per_block << SECTOR_SHIFT); in era_io_hints()
1711 .name = "era",
1731 DMERR("era target registration failed: %d", r); in dm_era_init()
1746 MODULE_DESCRIPTION(DM_NAME " era target");