mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o These now compile.
This commit is contained in:
parent
adbc44560b
commit
39497a4479
@ -89,7 +89,7 @@ int lv_open_count(struct logical_volume *lv)
|
||||
static int _emit_target(struct dm_task *dmt, struct stripe_segment *seg)
|
||||
{
|
||||
char params[1024];
|
||||
uint64_t esize = lv->vg->extent_size;
|
||||
uint64_t esize = seg->lv->vg->extent_size;
|
||||
uint32_t s, stripes = seg->stripes;
|
||||
int w, tw;
|
||||
|
||||
@ -108,14 +108,13 @@ static int _emit_target(struct dm_task *dmt, struct stripe_segment *seg)
|
||||
}
|
||||
}
|
||||
|
||||
if (!dm_task_add_target(dmt, esize * le, esize * seg->len,
|
||||
if (!dm_task_add_target(dmt, esize * seg->le, esize * seg->len,
|
||||
stripes == 1 ? "linear" : "striped",
|
||||
params)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ple = i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ static void _get_extents(struct stripe_segment *seg)
|
||||
int s, count;
|
||||
struct physical_volume *pv;
|
||||
|
||||
for (s = 0; i < seg->stripes; s++) {
|
||||
pv = seg->area[i % seg->stripes].pv;
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
pv = seg->area[s % seg->stripes].pv;
|
||||
count = seg->len / seg->stripes;
|
||||
pv->pe_allocated += count;
|
||||
}
|
||||
@ -31,8 +31,8 @@ static void _put_extents(struct stripe_segment *seg)
|
||||
int s, count;
|
||||
struct physical_volume *pv;
|
||||
|
||||
for (s = 0; i < seg->stripes; s++) {
|
||||
pv = seg->area[i % seg->stripes].pv;
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
pv = seg->area[s % seg->stripes].pv;
|
||||
count = seg->len / seg->stripes;
|
||||
|
||||
assert(pv->pe_allocated >= count);
|
||||
@ -50,7 +50,7 @@ static void _put_extents(struct stripe_segment *seg)
|
||||
static int _alloc_linear_area(struct logical_volume *lv, uint32_t *index,
|
||||
struct physical_volume *pv, struct pv_area *pva)
|
||||
{
|
||||
uint32_t count, remaining, i, start;
|
||||
uint32_t count, remaining, start;
|
||||
struct stripe_segment *seg;
|
||||
|
||||
start = pva->start;
|
||||
@ -93,7 +93,8 @@ static int _alloc_linear_area(struct logical_volume *lv, uint32_t *index,
|
||||
}
|
||||
|
||||
static int _alloc_striped(struct logical_volume *lv,
|
||||
struct list *pvms, uint32_t allocated)
|
||||
struct list *pvms, uint32_t allocated,
|
||||
uint32_t stripes, uint32_t stripe_size)
|
||||
{
|
||||
/* FIXME: finish */
|
||||
log_error("Striped allocation not implemented yet in LVM2.");
|
||||
@ -182,11 +183,12 @@ static int _alloc_simple(struct logical_volume *lv,
|
||||
* Chooses a correct allocation policy.
|
||||
*/
|
||||
static int _allocate(struct volume_group *vg, struct logical_volume *lv,
|
||||
struct list *acceptable_pvs, uint32_t allocated)
|
||||
struct list *acceptable_pvs, uint32_t allocated,
|
||||
uint32_t stripes, uint32_t stripe_size)
|
||||
{
|
||||
int r = 0;
|
||||
struct pool *scratch;
|
||||
struct list *pvms, *old_tail = lv->segments->p;
|
||||
struct list *pvms, *old_tail = lv->segments.p, *segh;
|
||||
|
||||
if (!(scratch = pool_create(1024))) {
|
||||
stack;
|
||||
@ -201,8 +203,8 @@ static int _allocate(struct volume_group *vg, struct logical_volume *lv,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (lv->stripes > 1)
|
||||
r = _alloc_striped(lv, pvms, allocated);
|
||||
if (stripes > 1)
|
||||
r = _alloc_striped(lv, pvms, allocated, stripes, stripe_size);
|
||||
|
||||
else if (lv->status & ALLOC_CONTIGUOUS)
|
||||
r = _alloc_contiguous(lv, pvms, allocated);
|
||||
@ -270,7 +272,6 @@ struct logical_volume *lv_create(const char *name,
|
||||
struct lv_list *ll = NULL;
|
||||
struct logical_volume *lv;
|
||||
char dname[32];
|
||||
int i;
|
||||
|
||||
if (!extents) {
|
||||
log_error("Unable to create logical volume %s with no extents",
|
||||
@ -316,12 +317,11 @@ struct logical_volume *lv_create(const char *name,
|
||||
|
||||
lv->status = status;
|
||||
lv->read_ahead = 0;
|
||||
lv->stripes = stripes;
|
||||
lv->size = extents * vg->extent_size;
|
||||
lv->le_count = extents;
|
||||
list_init(&lv->segments);
|
||||
|
||||
if (!_allocate(vg, lv, acceptable_pvs, 0u)) {
|
||||
if (!_allocate(vg, lv, acceptable_pvs, 0u, stripes, stripe_size)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
@ -370,7 +370,9 @@ int lv_reduce(struct logical_volume *lv, uint32_t extents)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lv_extend(struct logical_volume *lv, uint32_t extents,
|
||||
int lv_extend(struct logical_volume *lv,
|
||||
uint32_t stripes, uint32_t stripe_size,
|
||||
uint32_t extents,
|
||||
struct list *acceptable_pvs)
|
||||
{
|
||||
uint32_t old_le_count = lv->le_count;
|
||||
@ -379,9 +381,10 @@ int lv_extend(struct logical_volume *lv, uint32_t extents,
|
||||
lv->le_count += extents;
|
||||
lv->size += extents * lv->vg->extent_size;
|
||||
|
||||
if (!_allocate(lv->vg, lv, acceptable_pvs, old_le_count)) {
|
||||
if (!_allocate(lv->vg, lv, acceptable_pvs, old_le_count,
|
||||
stripes, stripe_size)) {
|
||||
lv->le_count = old_le_count;
|
||||
lv->size = old_lv_size;
|
||||
lv->size = old_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -390,9 +393,7 @@ int lv_extend(struct logical_volume *lv, uint32_t extents,
|
||||
|
||||
int lv_remove(struct volume_group *vg, struct logical_volume *lv)
|
||||
{
|
||||
int i;
|
||||
struct list *segh;
|
||||
struct stripe_segment *seg;
|
||||
|
||||
/* iterate through the lv's segments freeing off the pe's */
|
||||
list_iterate (segh, &lv->segments)
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "pv_map.h"
|
||||
#include "log.h"
|
||||
#include "hash.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@ -56,13 +57,14 @@ static int _set_allocated(struct hash_table *hash,
|
||||
|
||||
static int _fill_bitsets(struct volume_group *vg, struct list *maps)
|
||||
{
|
||||
struct list *lvh, *pvmh;
|
||||
struct list *lvh, *pvmh, *segh;
|
||||
struct logical_volume *lv;
|
||||
struct pv_map *pvm;
|
||||
uint32_t i, r = 0;
|
||||
struct hash_table *hash;
|
||||
struct stripe_segment *seg;
|
||||
|
||||
if (!(hash = hash_table_create(128))) {
|
||||
if (!(hash = hash_create(128))) {
|
||||
log_err("Couldn't create hash table for pv maps.");
|
||||
return 0;
|
||||
}
|
||||
@ -87,7 +89,7 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps)
|
||||
if (!_set_allocated(hash,
|
||||
seg->area[i % seg->stripes].pv,
|
||||
seg->area[i % seg->stripes].pe +
|
||||
(i / stripes))) {
|
||||
(i / seg->stripes))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
@ -97,7 +99,7 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps)
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
hash_table_destroy(hash);
|
||||
hash_destroy(hash);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user