mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
metadata: add support for interconnection of thin pool LV segment with indirect origin
Add support for making an interconnection between thin LV segment and its indirect origin (which may be historical or live LV) - add a new "indirect_origin" argument to attach_pool_lv function.
This commit is contained in:
parent
c45af2df4e
commit
a61bc70f62
@ -348,7 +348,7 @@ static int _cache_text_import(struct lv_segment *seg,
|
|||||||
|
|
||||||
seg->lv->status |= strstr(seg->lv->name, "_corig") ? LV_PENDING_DELETE : 0;
|
seg->lv->status |= strstr(seg->lv->name, "_corig") ? LV_PENDING_DELETE : 0;
|
||||||
|
|
||||||
if (!attach_pool_lv(seg, pool_lv, NULL, NULL))
|
if (!attach_pool_lv(seg, pool_lv, NULL, NULL, NULL))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!dm_list_empty(&pool_lv->segments) &&
|
if (!dm_list_empty(&pool_lv->segments) &&
|
||||||
|
@ -273,7 +273,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
|
|||||||
seg = first_seg(cache_lv);
|
seg = first_seg(cache_lv);
|
||||||
seg->segtype = segtype;
|
seg->segtype = segtype;
|
||||||
|
|
||||||
if (!attach_pool_lv(seg, pool_lv, NULL, NULL))
|
if (!attach_pool_lv(seg, pool_lv, NULL, NULL, NULL))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
|
|
||||||
return cache_lv;
|
return cache_lv;
|
||||||
@ -424,7 +424,7 @@ int lv_cache_remove(struct logical_volume *cache_lv)
|
|||||||
corigin_lv->status |= LV_PENDING_DELETE;
|
corigin_lv->status |= LV_PENDING_DELETE;
|
||||||
|
|
||||||
/* Reattach cache pool */
|
/* Reattach cache pool */
|
||||||
if (!attach_pool_lv(cache_seg, cache_pool_lv, NULL, NULL))
|
if (!attach_pool_lv(cache_seg, cache_pool_lv, NULL, NULL, NULL))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* Suspend/resume also deactivates deleted LV via support of LV_PENDING_DELETE */
|
/* Suspend/resume also deactivates deleted LV via support of LV_PENDING_DELETE */
|
||||||
|
@ -7335,13 +7335,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
|
|||||||
if (origin_lv && lv_is_thin_volume(origin_lv) &&
|
if (origin_lv && lv_is_thin_volume(origin_lv) &&
|
||||||
(first_seg(origin_lv)->pool_lv == pool_lv)) {
|
(first_seg(origin_lv)->pool_lv == pool_lv)) {
|
||||||
/* For thin snapshot pool must match */
|
/* For thin snapshot pool must match */
|
||||||
if (!attach_pool_lv(seg, pool_lv, origin_lv, NULL))
|
if (!attach_pool_lv(seg, pool_lv, origin_lv, NULL, NULL))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
/* Use the same external origin */
|
/* Use the same external origin */
|
||||||
if (!attach_thin_external_origin(seg, first_seg(origin_lv)->external_lv))
|
if (!attach_thin_external_origin(seg, first_seg(origin_lv)->external_lv))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
} else {
|
} else {
|
||||||
if (!attach_pool_lv(seg, pool_lv, NULL, NULL))
|
if (!attach_pool_lv(seg, pool_lv, NULL, NULL, NULL))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
/* If there is an external origin... */
|
/* If there is an external origin... */
|
||||||
if (!attach_thin_external_origin(seg, origin_lv))
|
if (!attach_thin_external_origin(seg, origin_lv))
|
||||||
|
@ -487,7 +487,9 @@ int fixup_imported_mirrors(struct volume_group *vg);
|
|||||||
* From thin_manip.c
|
* From thin_manip.c
|
||||||
*/
|
*/
|
||||||
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
|
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
|
||||||
struct logical_volume *origin_lv, struct logical_volume *merge_lv);
|
struct logical_volume *origin_lv,
|
||||||
|
struct generic_logical_volume *indirect_origin,
|
||||||
|
struct logical_volume *merge_lv);
|
||||||
int detach_pool_lv(struct lv_segment *seg);
|
int detach_pool_lv(struct lv_segment *seg);
|
||||||
int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
|
int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
|
||||||
struct logical_volume *lv, uint32_t delete_id,
|
struct logical_volume *lv, uint32_t delete_id,
|
||||||
|
@ -90,8 +90,11 @@ int attach_pool_data_lv(struct lv_segment *pool_seg,
|
|||||||
int attach_pool_lv(struct lv_segment *seg,
|
int attach_pool_lv(struct lv_segment *seg,
|
||||||
struct logical_volume *pool_lv,
|
struct logical_volume *pool_lv,
|
||||||
struct logical_volume *origin,
|
struct logical_volume *origin,
|
||||||
|
struct generic_logical_volume *indirect_origin,
|
||||||
struct logical_volume *merge_lv)
|
struct logical_volume *merge_lv)
|
||||||
{
|
{
|
||||||
|
struct glv_list *glvl;
|
||||||
|
|
||||||
if (!seg_is_thin_volume(seg) && !seg_is_cache(seg)) {
|
if (!seg_is_thin_volume(seg) && !seg_is_cache(seg)) {
|
||||||
log_error(INTERNAL_ERROR "Unable to attach pool to %s/%s"
|
log_error(INTERNAL_ERROR "Unable to attach pool to %s/%s"
|
||||||
" that is not cache or thin volume.",
|
" that is not cache or thin volume.",
|
||||||
@ -109,6 +112,18 @@ int attach_pool_lv(struct lv_segment *seg,
|
|||||||
if (origin && !add_seg_to_segs_using_this_lv(origin, seg))
|
if (origin && !add_seg_to_segs_using_this_lv(origin, seg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
if (indirect_origin) {
|
||||||
|
if (!(glvl = get_or_create_glvl(seg->lv->vg->vgmem, seg->lv, NULL)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
seg->indirect_origin = indirect_origin;
|
||||||
|
if (indirect_origin->is_historical)
|
||||||
|
dm_list_add(&indirect_origin->historical->indirect_glvs, &glvl->list);
|
||||||
|
else
|
||||||
|
dm_list_add(&indirect_origin->live->indirect_glvs, &glvl->list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!add_seg_to_segs_using_this_lv(pool_lv, seg))
|
if (!add_seg_to_segs_using_this_lv(pool_lv, seg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
@ -473,6 +473,7 @@ static int _thin_text_import(struct lv_segment *seg,
|
|||||||
{
|
{
|
||||||
const char *lv_name;
|
const char *lv_name;
|
||||||
struct logical_volume *pool_lv, *origin = NULL, *external_lv = NULL, *merge_lv = NULL;
|
struct logical_volume *pool_lv, *origin = NULL, *external_lv = NULL, *merge_lv = NULL;
|
||||||
|
struct generic_logical_volume *indirect_origin = NULL;
|
||||||
|
|
||||||
if (!dm_config_get_str(sn, "thin_pool", &lv_name))
|
if (!dm_config_get_str(sn, "thin_pool", &lv_name))
|
||||||
return SEG_LOG_ERROR("Thin pool must be a string in");
|
return SEG_LOG_ERROR("Thin pool must be a string in");
|
||||||
@ -513,7 +514,7 @@ static int _thin_text_import(struct lv_segment *seg,
|
|||||||
return SEG_LOG_ERROR("Unknown external origin %s in", lv_name);
|
return SEG_LOG_ERROR("Unknown external origin %s in", lv_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attach_pool_lv(seg, pool_lv, origin, merge_lv))
|
if (!attach_pool_lv(seg, pool_lv, origin, indirect_origin, merge_lv))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!attach_thin_external_origin(seg, external_lv))
|
if (!attach_thin_external_origin(seg, external_lv))
|
||||||
|
Loading…
Reference in New Issue
Block a user