mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Add -tpool layer in activation tree
Let's put the overlay device over real thin pool device. So we can get the proper locking on cluster. Overwise the pool LV would be activate once implicitely and in other case explicitely, confusing locking mechanism. This patch make the activation of pool LV independent on activation of thin LV since they will both implicitely use real -thin pool device.
This commit is contained in:
parent
2e732e9628
commit
a0c4e85c48
@ -34,6 +34,7 @@ struct lv_activate_opts {
|
|||||||
int exclusive;
|
int exclusive;
|
||||||
int origin_only;
|
int origin_only;
|
||||||
int no_merging;
|
int no_merging;
|
||||||
|
int real_pool;
|
||||||
unsigned revert;
|
unsigned revert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1100,13 +1100,16 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
|||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (lv_is_thin_pool(lv)) {
|
if (lv_is_thin_pool(lv)) {
|
||||||
if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_metadata_lv, origin_only))
|
if (!_add_dev_to_dtree(dm, dtree, lv, "tpool"))
|
||||||
return_0;
|
return_0;
|
||||||
if (!_add_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), origin_only))
|
if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_metadata_lv, origin_only))
|
||||||
return_0;
|
return_0;
|
||||||
|
/* FIXME code from _create_partial_dtree() should be moved here */
|
||||||
|
if (!_add_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), origin_only))
|
||||||
|
return_0;
|
||||||
} else if (lv_is_thin_volume(lv)) {
|
} else if (lv_is_thin_volume(lv)) {
|
||||||
if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_lv, origin_only))
|
if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_lv, origin_only))
|
||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1451,6 +1454,7 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
|
|||||||
struct dm_list *snh;
|
struct dm_list *snh;
|
||||||
struct lv_segment *seg_present;
|
struct lv_segment *seg_present;
|
||||||
const char *target_name;
|
const char *target_name;
|
||||||
|
struct lv_activate_opts lva;
|
||||||
|
|
||||||
/* Ensure required device-mapper targets are loaded */
|
/* Ensure required device-mapper targets are loaded */
|
||||||
seg_present = find_cow(seg->lv) ? : seg;
|
seg_present = find_cow(seg->lv) ? : seg;
|
||||||
@ -1495,13 +1499,18 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
|
|||||||
} else if (lv_is_cow(seg->lv) && !layer) {
|
} else if (lv_is_cow(seg->lv) && !layer) {
|
||||||
if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow"))
|
if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow"))
|
||||||
return_0;
|
return_0;
|
||||||
} else if (lv_is_thin_volume(seg->lv)) {
|
} else if (!layer && (lv_is_thin_pool(seg->lv) ||
|
||||||
if (!_add_new_lv_to_dtree(dm, dtree, seg->pool_lv, laopts, NULL))
|
lv_is_thin_volume(seg->lv))) {
|
||||||
|
lva = *laopts;
|
||||||
|
lva.real_pool = 1;
|
||||||
|
if (!_add_new_lv_to_dtree(dm, dtree, lv_is_thin_pool(seg->lv) ?
|
||||||
|
seg->lv : seg->pool_lv, &lva, "tpool"))
|
||||||
return_0;
|
return_0;
|
||||||
} else {
|
} else {
|
||||||
if (lv_is_thin_pool(seg->lv) &&
|
if (lv_is_thin_pool(seg->lv) &&
|
||||||
!_add_new_lv_to_dtree(dm, dtree, seg->pool_metadata_lv, laopts, NULL))
|
!_add_new_lv_to_dtree(dm, dtree, seg->pool_metadata_lv, laopts, NULL))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* Add any LVs used by this segment */
|
/* Add any LVs used by this segment */
|
||||||
for (s = 0; s < seg->area_count; s++) {
|
for (s = 0; s < seg->area_count; s++) {
|
||||||
if ((seg_type(seg, s) == AREA_LV) &&
|
if ((seg_type(seg, s) == AREA_LV) &&
|
||||||
|
@ -223,6 +223,21 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
|
|||||||
char *metadata_dlid, *pool_dlid;
|
char *metadata_dlid, *pool_dlid;
|
||||||
const struct lv_thin_message *lmsg;
|
const struct lv_thin_message *lmsg;
|
||||||
|
|
||||||
|
if (!laopts->real_pool) {
|
||||||
|
if (!(pool_dlid = build_dm_uuid(mem, seg->lv->lvid.s, "tpool"))) {
|
||||||
|
log_error("Failed to build uuid for thin pool LV %s.", seg->pool_lv->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (!dm_tree_node_add_thin_target(node, len, pool_dlid,
|
||||||
|
// DM_THIN_ERROR_DEVICE_ID))
|
||||||
|
if (!dm_tree_node_add_linear_target(node, len) ||
|
||||||
|
!dm_tree_node_add_target_area(node, NULL, pool_dlid, 0))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) {
|
if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) {
|
||||||
log_error("Failed to build uuid for metadata LV %s.",
|
log_error("Failed to build uuid for metadata LV %s.",
|
||||||
seg->pool_metadata_lv->name);
|
seg->pool_metadata_lv->name);
|
||||||
@ -356,14 +371,29 @@ static int _thin_add_target_line(struct dev_manager *dm,
|
|||||||
struct dm_tree_node *node, uint64_t len,
|
struct dm_tree_node *node, uint64_t len,
|
||||||
uint32_t *pvmove_mirror_count __attribute__((unused)))
|
uint32_t *pvmove_mirror_count __attribute__((unused)))
|
||||||
{
|
{
|
||||||
char *thin_pool_dlid;
|
char *pool_dlid;
|
||||||
|
uint32_t device_id = seg->device_id;
|
||||||
|
|
||||||
if (!(thin_pool_dlid = build_dm_uuid(mem, seg->pool_lv->lvid.s, NULL))) {
|
if (!(pool_dlid = build_dm_uuid(mem, seg->pool_lv->lvid.s, "tpool"))) {
|
||||||
log_error("Failed to build uuid for thin pool LV %s.", seg->pool_lv->name);
|
log_error("Failed to build uuid for pool LV %s.",
|
||||||
|
seg->pool_lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_tree_node_add_thin_target(node, len, thin_pool_dlid, seg->device_id))
|
#if 0
|
||||||
|
{
|
||||||
|
/* If we would need to activate 'to be deleted' thin LVs */
|
||||||
|
struct lv_thin_message *tmsg;
|
||||||
|
dm_list_iterate_items(tmsg, &first_seg(seg->pool_lv)->thin_messages)
|
||||||
|
/* If this node is going to be deleted - use the error target */
|
||||||
|
if ((tmsg->type == DM_THIN_MESSAGE_DELETE) &&
|
||||||
|
(tmsg->u.delete_id == seg->device_id)) {
|
||||||
|
device_id = DM_THIN_ERROR_DEVICE_ID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!dm_tree_node_add_thin_target(node, len, pool_dlid, device_id))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user