Version 2.03.06 -
================================
+ No longer store extra UUID for cmeta and cdata cachevol layer.
Enhance activation of cache devices with cachevols.
Add _cvol in list of protected suffixes and start use it with DM UUID.
Rename LV converted to cachevol to use _cvol suffix.
char *name ,*dlid;
union lvid lvid = { 0 };
- /* TODO: Convert to use just CVOL UUID with suffix */
memcpy(&lvid.id[0], &lv->vg->id, sizeof(struct id));
- memcpy(&lvid.id[1], (meta_or_data) ? &lvseg->metadata_id : &lvseg->data_id, sizeof(struct id));
+ /* When ID is provided in form of metadata_id or data_id, otherwise use CVOL ID */
+ memcpy(&lvid.id[1],
+ (meta_or_data && lvseg->metadata_id) ? lvseg->metadata_id :
+ (lvseg->data_id) ? lvseg->data_id : &pool_lv->lvid.id[1], sizeof(struct id));
if (!(dlid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&lvid.s, layer)))
return_0;
memset(&lvid_meta, 0, sizeof(lvid_meta));
memset(&lvid_data, 0, sizeof(lvid_meta));
memcpy(&lvid_meta.id[0], &vg->id, sizeof(struct id));
- memcpy(&lvid_meta.id[1], &lvseg->metadata_id, sizeof(struct id));
+ memcpy(&lvid_meta.id[1], lvseg->metadata_id ? : &pool_lv->lvid.id[1], sizeof(struct id));
memcpy(&lvid_data.id[0], &vg->id, sizeof(struct id));
- memcpy(&lvid_data.id[1], &lvseg->data_id, sizeof(struct id));
+ memcpy(&lvid_data.id[1], lvseg->data_id ? : &pool_lv->lvid.id[1], sizeof(struct id));
if (!(dlid_meta = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_meta.s, "cmeta")))
return_0;
if (!dm_config_get_uint64(sn, "data_len", &seg->data_len))
return SEG_LOG_ERROR("Couldn't read data_len in");
- if (!dm_config_get_str(sn, "metadata_id", &uuid))
- return SEG_LOG_ERROR("Couldn't read metadata_id in");
-
- if (!id_read_format(&seg->metadata_id, uuid))
- return SEG_LOG_ERROR("Couldn't format metadata_id in");
-
- if (!dm_config_get_str(sn, "data_id", &uuid))
- return SEG_LOG_ERROR("Couldn't read data_id in");
+ /* Will use CVOL ID, when metadata_id is not provided */
+ if (dm_config_has_node(sn, "metadata_id")) {
+ if (!(seg->metadata_id = dm_pool_alloc(seg->lv->vg->vgmem, sizeof(*seg->metadata_id))))
+ return SEG_LOG_ERROR("Couldn't allocate metadata_id in");
+ if (!dm_config_get_str(sn, "metadata_id", &uuid))
+ return SEG_LOG_ERROR("Couldn't read metadata_id in");
+ if (!id_read_format(seg->metadata_id, uuid))
+ return SEG_LOG_ERROR("Couldn't format metadata_id in");
+ }
- if (!id_read_format(&seg->data_id, uuid))
- return SEG_LOG_ERROR("Couldn't format data_id in");
+ /* Will use CVOL ID, when data_id is not provided */
+ if (dm_config_has_node(sn, "data_id")) {
+ if (!(seg->data_id = dm_pool_alloc(seg->lv->vg->vgmem, sizeof(*seg->data_id))))
+ return SEG_LOG_ERROR("Couldn't allocate data_id in");
+ if (!dm_config_get_str(sn, "data_id", &uuid))
+ return SEG_LOG_ERROR("Couldn't read data_id in");
+ if (!id_read_format(seg->data_id, uuid))
+ return SEG_LOG_ERROR("Couldn't format data_id in");
+ }
} else {
/* Do not call this when LV is cache_vol. */
/* load order is unknown, could be cache origin or pool LV, so check for both */
outf(f, "data_start = " FMTu64, seg->data_start);
outf(f, "data_len = " FMTu64, seg->data_len);
- if (!id_write_format(&seg->metadata_id, buffer, sizeof(buffer)))
- return_0;
- outf(f, "metadata_id = \"%s\"", buffer);
+ if (seg->metadata_id) {
+ if (!id_write_format(seg->metadata_id, buffer, sizeof(buffer)))
+ return_0;
+ outf(f, "metadata_id = \"%s\"", buffer);
+ }
- if (!id_write_format(&seg->data_id, buffer, sizeof(buffer)))
- return_0;
- outf(f, "data_id = \"%s\"", buffer);
+ if (seg->data_id) {
+ if (!id_write_format(seg->data_id, buffer, sizeof(buffer)))
+ return_0;
+ outf(f, "data_id = \"%s\"", buffer);
+ }
}
return 1;
memset(&metadata_lvid, 0, sizeof(metadata_lvid));
memset(&data_lvid, 0, sizeof(data_lvid));
memcpy(&metadata_lvid.id[0], &seg->lv->vg->id, sizeof(struct id));
- memcpy(&metadata_lvid.id[1], &seg->metadata_id, sizeof(struct id));
+ memcpy(&metadata_lvid.id[1], (seg->metadata_id) ? : &seg->pool_lv->lvid.id[1], sizeof(struct id));
memcpy(&data_lvid.id[0], &seg->lv->vg->id, sizeof(struct id));
- memcpy(&data_lvid.id[1], &seg->data_id, sizeof(struct id));
+ memcpy(&data_lvid.id[1], (seg->data_id) ? : &seg->pool_lv->lvid.id[1], sizeof(struct id));
if (!(metadata_uuid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&metadata_lvid.s, "cmeta")))
return_0;
struct lv_segment *cache_seg = first_seg(cache_lv);
struct logical_volume *corigin_lv;
struct logical_volume *cache_pool_lv;
- const struct id *data_id, *metadata_id;
+ struct id *data_id, *metadata_id;
uint64_t data_len, metadata_len;
cache_mode_t cache_mode;
int is_clear;
/* Preserve currently imortant data from original cache segment.
* TODO: can it be done without this ? */
- data_id = &cache_seg->data_id;
+ data_id = cache_seg->data_id;
data_len = cache_seg->data_len;
- metadata_id = &cache_seg->metadata_id;
+ metadata_id = cache_seg->metadata_id;
metadata_len = cache_seg->metadata_len;
/* Replace 'error' with 'cache' segtype */
/* Restore preserved data into a new cache segment that is going to be removed. */
if ((cache_seg->data_len = data_len)) {
cache_seg->metadata_len = metadata_len;
- memcpy(&cache_seg->data_id, data_id, sizeof(struct id));
- memcpy(&cache_seg->metadata_id, metadata_id, sizeof(struct id));
+ cache_seg->data_id = data_id;
+ cache_seg->metadata_id = metadata_id;
cache_pool_lv->status |= LV_CACHE_VOL;
/* Unused settings set only for passing metadata validation. */
cache_seg->cache_mode = CACHE_MODE_WRITETHROUGH;
cache_seg->cache_metadata_format = format;
cache_seg->policy_name = policy_name;
cache_seg->policy_settings = policy_settings;
- id_create(&cache_seg->metadata_id);
- id_create(&cache_seg->data_id);
+ /* Since we add -cdata and -cmeta to UUID we use CacheVol LV UUID */
+ cache_seg->data_id = cache_seg->metadata_id = NULL;
return 1;
}
uint64_t metadata_len; /* For cache */
uint64_t data_start; /* For cache */
uint64_t data_len; /* For cache */
- struct id metadata_id; /* For cache */
- struct id data_id; /* For cache */
+ struct id *metadata_id; /* For cache, when NULL uses CVOL id */
+ struct id *data_id; /* For cache, when NULL uses CVOL id */
cache_metadata_format_t cache_metadata_format;/* For cache_pool */
cache_mode_t cache_mode; /* For cache_pool */