mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o get_pvs for format 1
o fix vg_read if vg doesn't exist
This commit is contained in:
parent
67905e0d59
commit
c8ca2a2993
@ -47,18 +47,18 @@ static int _import_vg(struct pool *mem,
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return first ? 1 : 0;
|
||||
}
|
||||
|
||||
static int _import_pvs(struct pool *mem, struct volume_group *vg,
|
||||
struct list_head *pvs)
|
||||
static int _import_pvs(struct pool *mem, struct list_head *pvs,
|
||||
struct list_head *results, int *count)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct disk_list *dl;
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
|
||||
vg->pv_count = 0;
|
||||
*count = 0;
|
||||
list_for_each(tmp, pvs) {
|
||||
dl = list_entry(tmp, struct disk_list, list);
|
||||
pvl = pool_alloc(mem, sizeof(*pvl));
|
||||
@ -89,8 +89,8 @@ static int _import_pvs(struct pool *mem, struct volume_group *vg,
|
||||
pv->pe_count = dl->pv.pe_total;
|
||||
pv->pe_allocated = dl->pv.pe_allocated;
|
||||
|
||||
list_add(&pvl->list, &vg->pvs);
|
||||
vg->pv_count++;
|
||||
list_add(&pvl->list, results);
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -276,7 +276,7 @@ static struct volume_group *_build_vg(struct pool *mem, struct list_head *pvs)
|
||||
if (!_import_vg(mem, vg, pvs))
|
||||
goto bad;
|
||||
|
||||
if (!_import_pvs(mem, vg, pvs))
|
||||
if (!_import_pvs(mem, pvs, &vg->pvs, &vg->pv_count))
|
||||
goto bad;
|
||||
|
||||
if (!_import_lvs(mem, vg, pvs))
|
||||
@ -362,6 +362,44 @@ static int _vg_write(struct io_space *is, struct volume_group *vg)
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct list_head *_get_pvs(struct io_space *is)
|
||||
{
|
||||
struct pool *mem = pool_create(1024 * 10);
|
||||
struct list_head pvs, *results;
|
||||
uint32_t count;
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(results = pool_alloc(is->mem, sizeof(*results)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&pvs);
|
||||
INIT_LIST_HEAD(results);
|
||||
|
||||
if (!read_pvs_in_vg(NULL, is->filter, mem, &pvs)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!_import_pvs(mem, &pvs, results, &count)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
pool_destroy(mem);
|
||||
return results;
|
||||
|
||||
bad:
|
||||
pool_destroy(mem);
|
||||
pool_free(mem, results);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _destroy(struct io_space *ios)
|
||||
{
|
||||
dbg_free(ios->prefix);
|
||||
@ -373,7 +411,7 @@ struct io_space *create_lvm1_format(const char *prefix, struct pool *mem,
|
||||
{
|
||||
struct io_space *ios = dbg_malloc(sizeof(*ios));
|
||||
|
||||
ios->get_vgs = NULL;
|
||||
ios->get_vgs = _get_pvs;
|
||||
ios->get_pvs = NULL;
|
||||
ios->pv_read = NULL;
|
||||
ios->pv_write = NULL;
|
||||
|
@ -124,11 +124,11 @@ struct lv_list {
|
||||
struct io_space {
|
||||
/* Returns list of names of all vgs - vg
|
||||
component only, not full path*/
|
||||
struct name_list *(*get_vgs)(struct io_space *is);
|
||||
struct list_head *(*get_vgs)(struct io_space *is);
|
||||
|
||||
/* Returns list of fully-populated pv
|
||||
/* Returns list of fully-populated pv_list
|
||||
structures */
|
||||
struct pv_list *(*get_pvs)(struct io_space *is);
|
||||
struct list_head *(*get_pvs)(struct io_space *is);
|
||||
|
||||
/* Return PV with given name (may be full
|
||||
or relative path) */
|
||||
|
@ -37,7 +37,8 @@ static void _dump_lv(struct logical_volume *lv, FILE *fp)
|
||||
for (i = 0; i < lv->le_count; i++) {
|
||||
struct physical_volume *pv = lv->map[i].pv;
|
||||
|
||||
fprintf(fp, "\t\tpv = '%s', ", pv ? pv->dev->name : "null ???");
|
||||
fprintf(fp, "\t\tpv = '%s', ",
|
||||
pv ? pv->dev->name : "null ???");
|
||||
fprintf(fp, "\textent = %u\n", lv->map[i].pe);
|
||||
}
|
||||
fprintf(fp, "\t}\n}\n\n");
|
||||
|
Loading…
Reference in New Issue
Block a user