diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index a48aef2a0..94e8ebf2f 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -119,8 +119,10 @@ #define LV_PENDING_DELETE UINT64_C(0x0004000000000000) /* LV - Internal use only */ #define LV_ERROR_WHEN_FULL UINT64_C(0x0008000000000000) /* LV - error when full */ - -/* Next unused flag: UINT64_C(0x0010000000000000) */ +#define PV_ALLOCATION_PROHIBITED UINT64_C(0x0010000000000000) /* PV - internal use only - allocation prohibited + e.g. to prohibit allocation of a RAID image + on a PV already holing an image of the RAID set */ +/* Next unused flag: UINT64_C(0x0020000000000000) */ /* Format features flags */ #define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */ diff --git a/lib/metadata/pv_map.c b/lib/metadata/pv_map.c index 4423a7d1f..b6cf31e97 100644 --- a/lib/metadata/pv_map.c +++ b/lib/metadata/pv_map.c @@ -133,8 +133,11 @@ static int _create_maps(struct dm_pool *mem, struct dm_list *pvs, struct dm_list struct pv_list *pvl; dm_list_iterate_items(pvl, pvs) { - if (!(pvl->pv->status & ALLOCATABLE_PV)) + if (!(pvl->pv->status & ALLOCATABLE_PV) || + (pvl->pv->status & PV_ALLOCATION_PROHIBITED)) { + pvl->pv->status &= ~PV_ALLOCATION_PROHIBITED; continue; + } if (is_missing_pv(pvl->pv)) continue; assert(pvl->pv->dev); diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index cb0366f8e..d50237926 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -1553,14 +1553,15 @@ static int _avoid_pvs_of_lv(struct logical_volume *lv, void *data) dm_list_iterate_items(pvl, allocate_pvs) if (!(lv->status & PARTIAL_LV) && lv_is_on_pv(lv, pvl->pv)) - pvl->pv->status &= ~ALLOCATABLE_PV; + pvl->pv->status |= PV_ALLOCATION_PROHIBITED; return 1; } /* - * Prevent any PVs holding other image components of @lv from being used for allocation, - * I.e. reset ALLOCATABLE_PV on respective PVs listed on @allocatable_pvs + * Prevent any PVs holding other image components of @lv from being used for allocation + * by setting the internal PV_ALLOCATION_PROHIBITED flag to use it to avoid generating + * pv maps for those PVs. */ static void _avoid_pvs_with_other_images_of_lv(struct logical_volume *lv, struct dm_list *allocate_pvs) {