1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvreduce: check LV has segment

Before accessing content make sure LV has segment.
This can be used in case code removes LV without segments
(i.e. on some error path)
This commit is contained in:
Zdenek Kabelac 2017-10-30 14:35:31 +01:00
parent 0424410773
commit 83d5db056b

View File

@ -1315,13 +1315,19 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
*/
static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
{
struct lv_segment *seg = first_seg(lv);;
struct lv_segment *seg = NULL;
uint32_t count = extents;
uint32_t reduction;
struct logical_volume *pool_lv;
struct logical_volume *external_lv = NULL;
int is_raid10 = seg_is_any_raid10(seg) && seg->reshape_len;
uint32_t data_copies = seg->data_copies;
int is_raid10 = 0;
uint32_t data_copies = 0;
if (!dm_list_empty(&lv->segments)) {
seg = first_seg(lv);
is_raid10 = seg_is_any_raid10(seg) && seg->reshape_len;
data_copies = seg->data_copies;
}
if (lv_is_merging_origin(lv)) {
log_debug_metadata("Dropping snapshot merge of %s to removed origin %s.",
@ -7660,8 +7666,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->mirrors,
segtype_is_pool(create_segtype) ? lp->pool_metadata_extents : lp->region_size,
segtype_is_thin_volume(create_segtype) ? lp->virtual_extents : lp->extents,
lp->pvh, lp->alloc, lp->approx_alloc))
lp->pvh, lp->alloc, lp->approx_alloc)) {
unlink_lv_from_vg(lv); /* Keep VG consistent and remove LV without any segment */
return_NULL;
}
/* rhbz1269533: allow for 100%FREE allocation to work with "mirror" and a disk log */
if (segtype_is_mirror(create_segtype) &&