1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Perform high-level free space check before each allocation attempt.

This commit is contained in:
Alasdair Kergon 2006-10-23 15:54:51 +00:00
parent 949a835f4a
commit 5bb8efa41f
4 changed files with 27 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.13 -
===================================
Perform high-level free space check before each allocation attempt.
Don't allow a node to remove an LV that's exclusively active on anther node.
Cope if same PV is included more than once in cmdline PE range list.
Set PV size to current device size if it is found to be zero.

View File

@ -890,8 +890,17 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
uint32_t next_le;
struct seg_pvs *spvs;
struct list *parallel_pvs;
uint32_t free_pes;
/* Is there enough total space? */
free_pes = pv_maps_size(pvms);
if (needed > free_pes) {
log_error("Insufficient free space: %" PRIu32 " extents needed,"
" but only %" PRIu32 " available", needed,
free_pes);
return 0;
}
/* FIXME Do calculations on free extent counts before selecting space */
/* FIXME Select log PV appropriately if there isn't one yet */
/* Are there any preceding segments we must follow on from? */

View File

@ -32,6 +32,7 @@ static void _insert_area(struct list *head, struct pv_area *a)
}
list_add(&pva->list, &a->list);
a->map->pe_count += a->count;
}
static int _create_single_area(struct dm_pool *mem, struct pv_map *pvm,
@ -191,6 +192,7 @@ struct list *create_pv_maps(struct dm_pool *mem, struct volume_group *vg,
void consume_pv_area(struct pv_area *pva, uint32_t to_go)
{
list_del(&pva->list);
pva->map->pe_count -= pva->count;
assert(to_go <= pva->count);
@ -201,3 +203,14 @@ void consume_pv_area(struct pv_area *pva, uint32_t to_go)
_insert_area(&pva->map->areas, pva);
}
}
uint32_t pv_maps_size(struct list *pvms)
{
struct pv_map *pvm;
uint32_t pe_count = 0;
list_iterate_items(pvm, pvms)
pe_count += pvm->pe_count;
return pe_count;
}

View File

@ -37,6 +37,7 @@ struct pv_area {
struct pv_map {
struct physical_volume *pv;
struct list areas; /* struct pv_areas */
uint32_t pe_count; /* Total number of PEs */
struct list list;
};
@ -49,4 +50,6 @@ struct list *create_pv_maps(struct dm_pool *mem, struct volume_group *vg,
void consume_pv_area(struct pv_area *area, uint32_t to_go);
uint32_t pv_maps_size(struct list *pvms);
#endif