mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
o lv_reduce
o pv_maps wasn't taking a list of acceptable pvs
This commit is contained in:
parent
ed0502e98b
commit
15e35a737c
@ -44,8 +44,10 @@ static int _alloc_area(struct logical_volume *lv, uint32_t index,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _alloc_striped(struct logical_volume *lv, struct list *pvms)
|
static int _alloc_striped(struct logical_volume *lv,
|
||||||
|
struct list *pvms, uint32_t allocated)
|
||||||
{
|
{
|
||||||
|
/* FIXME: finish */
|
||||||
log_err("striped allocation not implemented yet.");
|
log_err("striped allocation not implemented yet.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -55,12 +57,12 @@ static int _alloc_striped(struct logical_volume *lv, struct list *pvms)
|
|||||||
* for the biggest area, or the first area that
|
* for the biggest area, or the first area that
|
||||||
* can complete the allocation.
|
* can complete the allocation.
|
||||||
*/
|
*/
|
||||||
static int _alloc_contiguous(struct logical_volume *lv, struct list *pvms)
|
static int _alloc_contiguous(struct logical_volume *lv,
|
||||||
|
struct list *pvms, uint32_t allocated)
|
||||||
{
|
{
|
||||||
struct list *tmp1, *tmp2;
|
struct list *tmp1, *tmp2;
|
||||||
struct pv_map *pvm;
|
struct pv_map *pvm;
|
||||||
struct pv_area *pva, *biggest;
|
struct pv_area *pva, *biggest;
|
||||||
uint32_t allocated = 0;
|
|
||||||
|
|
||||||
list_iterate (tmp1, pvms) {
|
list_iterate (tmp1, pvms) {
|
||||||
pvm = list_item(tmp1, struct pv_map);
|
pvm = list_item(tmp1, struct pv_map);
|
||||||
@ -94,12 +96,12 @@ static int _alloc_contiguous(struct logical_volume *lv, struct list *pvms)
|
|||||||
* Areas just get allocated in order until the lv
|
* Areas just get allocated in order until the lv
|
||||||
* is full.
|
* is full.
|
||||||
*/
|
*/
|
||||||
static int _alloc_simple(struct logical_volume *lv, struct list *pvms)
|
static int _alloc_simple(struct logical_volume *lv,
|
||||||
|
struct list *pvms, uint32_t allocated)
|
||||||
{
|
{
|
||||||
struct list *tmp1, *tmp2;
|
struct list *tmp1, *tmp2;
|
||||||
struct pv_map *pvm;
|
struct pv_map *pvm;
|
||||||
struct pv_area *pva;
|
struct pv_area *pva;
|
||||||
uint32_t allocated = 0;
|
|
||||||
|
|
||||||
list_iterate (tmp1, pvms) {
|
list_iterate (tmp1, pvms) {
|
||||||
pvm = list_item(tmp1, struct pv_map);
|
pvm = list_item(tmp1, struct pv_map);
|
||||||
@ -132,7 +134,7 @@ struct logical_volume *lv_create(struct io_space *ios,
|
|||||||
uint32_t stripe_size,
|
uint32_t stripe_size,
|
||||||
uint32_t extents,
|
uint32_t extents,
|
||||||
struct volume_group *vg,
|
struct volume_group *vg,
|
||||||
struct pv_list *acceptable_pvs)
|
struct list *acceptable_pvs)
|
||||||
{
|
{
|
||||||
struct lv_list *ll = NULL;
|
struct lv_list *ll = NULL;
|
||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
@ -191,19 +193,19 @@ struct logical_volume *lv_create(struct io_space *ios,
|
|||||||
* Build the sets of available areas on
|
* Build the sets of available areas on
|
||||||
* the pv's.
|
* the pv's.
|
||||||
*/
|
*/
|
||||||
if (!(pvms = create_pv_maps(scratch, vg))) {
|
if (!(pvms = create_pv_maps(scratch, vg, acceptable_pvs))) {
|
||||||
log_err("couldn't create extent mappings");
|
log_err("couldn't create extent mappings");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripes > 1)
|
if (stripes > 1)
|
||||||
r = _alloc_striped(lv, pvms);
|
r = _alloc_striped(lv, pvms, 0u);
|
||||||
|
|
||||||
else if (status & ALLOC_CONTIGUOUS)
|
else if (status & ALLOC_CONTIGUOUS)
|
||||||
r = _alloc_contiguous(lv, pvms);
|
r = _alloc_contiguous(lv, pvms, 0u);
|
||||||
|
|
||||||
else
|
else
|
||||||
r = _alloc_simple(lv, pvms);
|
r = _alloc_simple(lv, pvms, 0u);
|
||||||
|
|
||||||
if (!r) {
|
if (!r) {
|
||||||
log_err("Extent allocation failed.");
|
log_err("Extent allocation failed.");
|
||||||
@ -224,3 +226,32 @@ struct logical_volume *lv_create(struct io_space *ios,
|
|||||||
pool_destroy(scratch);
|
pool_destroy(scratch);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lv_reduce(struct io_space *ios,
|
||||||
|
struct logical_volume *lv, uint32_t extents)
|
||||||
|
{
|
||||||
|
if (extents % lv->stripes) {
|
||||||
|
log_err("For a striped volume you must reduce by a "
|
||||||
|
"multiple of the number of stripes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lv->le_count <= extents) {
|
||||||
|
log_err("Attempt to reduce by too many extents, "
|
||||||
|
"there would be nothing left of the logical volume.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hmmm ... I think all we need to do is ... */
|
||||||
|
lv->le_count -= extents;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lv_extend(struct io_space *ios,
|
||||||
|
struct logical_volume *lv, uint32_t extents,
|
||||||
|
struct list *allocatable_pvs)
|
||||||
|
{
|
||||||
|
/* FIXME: finish */
|
||||||
|
log_err("not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -219,7 +219,14 @@ struct logical_volume *lv_create(struct io_space *ios,
|
|||||||
uint32_t stripe_size,
|
uint32_t stripe_size,
|
||||||
uint32_t extents,
|
uint32_t extents,
|
||||||
struct volume_group *vg,
|
struct volume_group *vg,
|
||||||
struct pv_list *acceptable_pvs);
|
struct list *acceptable_pvs);
|
||||||
|
|
||||||
|
int lv_reduce(struct io_space *ios,
|
||||||
|
struct logical_volume *lv,
|
||||||
|
uint32_t extents);
|
||||||
|
|
||||||
|
int lv_extend(struct io_space *ios, struct logical_volume *lv,
|
||||||
|
uint32_t extents, struct list *allocatable_pvs);
|
||||||
|
|
||||||
int vg_extend(struct io_space *ios, struct volume_group *vg, int pv_count,
|
int vg_extend(struct io_space *ios, struct volume_group *vg, int pv_count,
|
||||||
char **pv_names);
|
char **pv_names);
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
static int _create_maps(struct pool *mem, struct volume_group *vg,
|
static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
|
||||||
struct list *maps)
|
|
||||||
{
|
{
|
||||||
struct list *tmp;
|
struct list *tmp;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
struct pv_map *pvm;
|
struct pv_map *pvm;
|
||||||
|
|
||||||
list_iterate(tmp, &vg->pvs) {
|
list_iterate(tmp, pvs) {
|
||||||
pv = &(list_item(tmp, struct pv_list)->pv);
|
pv = &(list_item(tmp, struct pv_list)->pv);
|
||||||
|
|
||||||
if (!(pvm = pool_zalloc(mem, sizeof(*pvm)))) {
|
if (!(pvm = pool_zalloc(mem, sizeof(*pvm)))) {
|
||||||
@ -63,11 +62,9 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pvmh == maps) {
|
/* not all pvs are necc. in the list */
|
||||||
log_err("couldn't find pv specified "
|
if (pvmh == maps)
|
||||||
"in extent map !");
|
continue;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bit_set(pvm->allocated_extents, pes->pe);
|
bit_set(pvm->allocated_extents, pes->pe);
|
||||||
}
|
}
|
||||||
@ -138,7 +135,8 @@ static int _create_all_areas(struct pool *mem, struct list *maps)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct list *create_pv_maps(struct pool *mem, struct volume_group *vg)
|
struct list *create_pv_maps(struct pool *mem, struct volume_group *vg,
|
||||||
|
struct list *pvs)
|
||||||
{
|
{
|
||||||
struct list *maps = pool_zalloc(mem, sizeof(*maps));
|
struct list *maps = pool_zalloc(mem, sizeof(*maps));
|
||||||
|
|
||||||
@ -149,7 +147,7 @@ struct list *create_pv_maps(struct pool *mem, struct volume_group *vg)
|
|||||||
|
|
||||||
list_init(maps);
|
list_init(maps);
|
||||||
|
|
||||||
if (!_create_maps(mem, vg, maps)) {
|
if (!_create_maps(mem, pvs, maps)) {
|
||||||
log_err("couldn't create pv maps.");
|
log_err("couldn't create pv maps.");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ struct pv_map {
|
|||||||
struct list list;
|
struct list list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct list *create_pv_maps(struct pool *mem, struct volume_group *vg);
|
struct list *create_pv_maps(struct pool *mem,
|
||||||
|
struct volume_group *vg, struct list *pvs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user