mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
raid: add reshape segtype flag support
Prohibit activation of reshaping RaidLVs on incompatible lvm2 runtime by storing e.g. 'raid5+RESHAPE' segment type strings in the lvm2 metadata. Incompatible runtime not supporting reshaping won't be able to activate those thus avoiding potential data corruption. Any new non-reshaping lvconvert command will reset the segment type string from 'raid5+RESHAPE' to 'raid5'. See commits0299a7af1e
and4141409eb0
for segtype flag support.
This commit is contained in:
parent
3055131784
commit
1c916ec5ff
@ -62,6 +62,7 @@ static const struct flag _lv_flags[] = {
|
|||||||
{LOCKED, "LOCKED", STATUS_FLAG},
|
{LOCKED, "LOCKED", STATUS_FLAG},
|
||||||
{LV_NOTSYNCED, "NOTSYNCED", STATUS_FLAG},
|
{LV_NOTSYNCED, "NOTSYNCED", STATUS_FLAG},
|
||||||
{LV_REBUILD, "REBUILD", STATUS_FLAG},
|
{LV_REBUILD, "REBUILD", STATUS_FLAG},
|
||||||
|
{LV_RESHAPE, "RESHAPE", SEGTYPE_FLAG},
|
||||||
{LV_RESHAPE_DELTA_DISKS_PLUS, "RESHAPE_DELTA_DISKS_PLUS", STATUS_FLAG},
|
{LV_RESHAPE_DELTA_DISKS_PLUS, "RESHAPE_DELTA_DISKS_PLUS", STATUS_FLAG},
|
||||||
{LV_RESHAPE_DELTA_DISKS_MINUS, "RESHAPE_DELTA_DISKS_MINUS", STATUS_FLAG},
|
{LV_RESHAPE_DELTA_DISKS_MINUS, "RESHAPE_DELTA_DISKS_MINUS", STATUS_FLAG},
|
||||||
{LV_REMOVE_AFTER_RESHAPE, "REMOVE_AFTER_RESHAPE", STATUS_FLAG},
|
{LV_REMOVE_AFTER_RESHAPE, "REMOVE_AFTER_RESHAPE", STATUS_FLAG},
|
||||||
|
@ -142,7 +142,10 @@
|
|||||||
|
|
||||||
#define LV_REMOVE_AFTER_RESHAPE UINT64_C(0x0400000000000000) /* LV needs to be removed after a shrinking reshape */
|
#define LV_REMOVE_AFTER_RESHAPE UINT64_C(0x0400000000000000) /* LV needs to be removed after a shrinking reshape */
|
||||||
#define LV_METADATA_FORMAT UINT64_C(0x0800000000000000) /* LV has segments with metadata format */
|
#define LV_METADATA_FORMAT UINT64_C(0x0800000000000000) /* LV has segments with metadata format */
|
||||||
/* Next unused flag: UINT64_C(0x1000000000000000) */
|
|
||||||
|
#define LV_RESHAPE UINT64_C(0x1000000000000000) /* Ongoing reshape (number of stripes, stripesize or raid algorithm change):
|
||||||
|
used as SEGTYPE_FLAG to prevent activation on old runtime */
|
||||||
|
/* Next unused flag: UINT64_C(0x2000000000000000) */
|
||||||
|
|
||||||
/* Format features flags */
|
/* Format features flags */
|
||||||
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
|
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
|
||||||
|
@ -1637,6 +1637,8 @@ static int _lv_free_reshape_space_with_status(struct logical_volume *lv, enum al
|
|||||||
} else if (where_it_was)
|
} else if (where_it_was)
|
||||||
*where_it_was = alloc_none;
|
*where_it_was = alloc_none;
|
||||||
|
|
||||||
|
lv->status &= ~LV_RESHAPE;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1844,6 +1846,9 @@ static int _raid_reshape_add_images(struct logical_volume *lv,
|
|||||||
|
|
||||||
seg->stripe_size = new_stripe_size;
|
seg->stripe_size = new_stripe_size;
|
||||||
|
|
||||||
|
/* Define image adding reshape (used as SEGTYPE_FLAG to avoid incompatible activations on old runtime) */
|
||||||
|
lv->status |= LV_RESHAPE;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1943,6 +1948,8 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
|
|||||||
if (seg_is_any_raid5(seg) && new_image_count == 2)
|
if (seg_is_any_raid5(seg) && new_image_count == 2)
|
||||||
seg->data_copies = 2;
|
seg->data_copies = 2;
|
||||||
|
|
||||||
|
/* Define image removing reshape (used as SEGTYPE_FLAG to avoid incompatible activations on old runtime) */
|
||||||
|
lv ->status |= LV_RESHAPE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
@ -1981,7 +1988,6 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
seg->area_count = new_image_count;
|
seg->area_count = new_image_count;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2054,6 +2060,9 @@ static int _raid_reshape_keep_images(struct logical_volume *lv,
|
|||||||
|
|
||||||
seg->segtype = new_segtype;
|
seg->segtype = new_segtype;
|
||||||
|
|
||||||
|
/* Define stripesize/raid algorithm reshape (used as SEGTYPE_FLAG to avoid incompatible activations on old runtime) */
|
||||||
|
lv->status |= LV_RESHAPE;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2237,6 +2246,8 @@ static int _raid_reshape(struct logical_volume *lv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv->status &= ~LV_RESHAPE; /* Reset any reshaping segtype flag */
|
||||||
|
|
||||||
dm_list_init(&removal_lvs);
|
dm_list_init(&removal_lvs);
|
||||||
|
|
||||||
/* No change in layout requested ? */
|
/* No change in layout requested ? */
|
||||||
@ -6040,6 +6051,8 @@ static int _region_size_change_requested(struct logical_volume *lv, int yes, con
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv->status &= ~LV_RESHAPE;
|
||||||
|
|
||||||
if (!lv_update_and_reload_origin(lv))
|
if (!lv_update_and_reload_origin(lv))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
@ -6291,6 +6304,8 @@ int lv_raid_convert(struct logical_volume *lv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv->status &= ~LV_RESHAPE;
|
||||||
|
|
||||||
return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, new_stripes, stripe_size,
|
return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, new_stripes, stripe_size,
|
||||||
region_size, allocate_pvs);
|
region_size, allocate_pvs);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user