diff --git a/lib/thin/thin.c b/lib/thin/thin.c index cbea94435..f3f10be54 100644 --- a/lib/thin/thin.c +++ b/lib/thin/thin.c @@ -92,34 +92,35 @@ static int _thin_pool_text_import(struct lv_segment *seg, const char *lv_name; struct logical_volume *pool_data_lv, *pool_metadata_lv; - if (!dm_config_get_str(sn, "pool", &lv_name)) - return SEG_LOG_ERROR("Pool must be a string in"); - - if (!(pool_data_lv = find_lv(seg->lv->vg, lv_name))) - return SEG_LOG_ERROR("Unknown pool %s in", lv_name); - if (!dm_config_get_str(sn, "metadata", &lv_name)) return SEG_LOG_ERROR("Metadata must be a string in"); if (!(pool_metadata_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown metadata %s in", lv_name); - if (!attach_pool_data_lv(seg, pool_data_lv)) + if (!dm_config_get_str(sn, "pool", &lv_name)) + return SEG_LOG_ERROR("Pool must be a string in"); + + if (!(pool_data_lv = find_lv(seg->lv->vg, lv_name))) + return SEG_LOG_ERROR("Unknown pool %s in", lv_name); + + seg->lv->status |= THIN_POOL; + if (!attach_pool_metadata_lv(seg, pool_metadata_lv)) return_0; - if (!attach_pool_metadata_lv(seg, pool_metadata_lv)) + if (!attach_pool_data_lv(seg, pool_data_lv)) return_0; if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) return SEG_LOG_ERROR("Could not read transaction_id for"); + if (!dm_config_get_uint32(sn, "data_block_size", &seg->data_block_size)) + return SEG_LOG_ERROR("Could not read data_block_size"); + if (dm_config_has_node(sn, "low_water_mark") && !dm_config_get_uint64(sn, "low_water_mark", &seg->low_water_mark)) return SEG_LOG_ERROR("Could not read low_water_mark"); - if (!dm_config_get_uint32(sn, "data_block_size", &seg->data_block_size)) - return SEG_LOG_ERROR("Could not read data_block_size"); - if ((seg->data_block_size < DM_THIN_MIN_DATA_BLOCK_SIZE) || (seg->data_block_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) return SEG_LOG_ERROR("Unsupported value %u for data_block_size", @@ -129,8 +130,6 @@ static int _thin_pool_text_import(struct lv_segment *seg, !dm_config_get_uint32(sn, "zero_new_blocks", &seg->zero_new_blocks)) return SEG_LOG_ERROR("Could not read zero_new_blocks for"); - seg->lv->status |= THIN_POOL; - /* Read messages */ for (; sn; sn = sn->sib) if (!(sn->v) && !_thin_pool_add_message(seg, sn->key, sn->child)) @@ -152,9 +151,10 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter unsigned cnt = 0; const struct lv_thin_message *tmsg; - outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name); outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name); + outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); +// FIXME maybe switch to use chunksize (as with snapshot ??) outf(f, "data_block_size = %u", seg->data_block_size); if (seg->low_water_mark)