mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o a very quick hack to get vg_number right
This commit is contained in:
parent
383d1752fa
commit
6b6a344e09
@ -18,6 +18,7 @@ SOURCES=\
|
|||||||
format1/format1.c \
|
format1/format1.c \
|
||||||
format1/import-export.c \
|
format1/import-export.c \
|
||||||
format1/layout.c \
|
format1/layout.c \
|
||||||
|
format1/vg_number.c \
|
||||||
log/log.c \
|
log/log.c \
|
||||||
mm/dbg_malloc.c \
|
mm/dbg_malloc.c \
|
||||||
mm/pool.c
|
mm/pool.c
|
||||||
|
@ -220,4 +220,11 @@ void export_numbers(struct list_head *pvs, struct volume_group *vg);
|
|||||||
|
|
||||||
void export_pv_act(struct list_head *pvs);
|
void export_pv_act(struct list_head *pvs);
|
||||||
|
|
||||||
|
/* blech */
|
||||||
|
int get_free_vg_number(struct dev_filter *filter, const char *candidate_vg,
|
||||||
|
int *result);
|
||||||
|
int export_vg_number(struct list_head *pvs, const char *vg_name,
|
||||||
|
struct dev_filter *filter);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,7 +133,8 @@ static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int _flatten_vg(struct pool *mem, struct volume_group *vg,
|
static int _flatten_vg(struct pool *mem, struct volume_group *vg,
|
||||||
struct list_head *pvs, const char *prefix)
|
struct list_head *pvs, const char *prefix,
|
||||||
|
struct dev_filter *filter)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
@ -153,6 +154,11 @@ static int _flatten_vg(struct pool *mem, struct volume_group *vg,
|
|||||||
export_numbers(pvs, vg);
|
export_numbers(pvs, vg);
|
||||||
export_pv_act(pvs);
|
export_pv_act(pvs);
|
||||||
|
|
||||||
|
if (!export_vg_number(pvs, vg->name, filter)) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +175,8 @@ static int _vg_write(struct io_space *is, struct volume_group *vg)
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&pvs);
|
INIT_LIST_HEAD(&pvs);
|
||||||
|
|
||||||
r = _flatten_vg(mem, vg, &pvs, is->prefix) && write_pvs(&pvs);
|
r = (_flatten_vg(mem, vg, &pvs, is->prefix, is->filter) &&
|
||||||
|
write_pvs(&pvs));
|
||||||
pool_destroy(mem);
|
pool_destroy(mem);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,6 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
|
|||||||
strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
||||||
|
|
||||||
//pvd->pv_major = MAJOR(pv->dev);
|
//pvd->pv_major = MAJOR(pv->dev);
|
||||||
//pvd->pv_number = ??;
|
|
||||||
|
|
||||||
if (pv->status & ACTIVE)
|
if (pv->status & ACTIVE)
|
||||||
pvd->pv_status |= PV_ACTIVE;
|
pvd->pv_status |= PV_ACTIVE;
|
||||||
@ -607,3 +606,24 @@ void export_pv_act(struct list_head *pvs)
|
|||||||
dl->vg.pv_act = act;
|
dl->vg.pv_act = act;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int export_vg_number(struct list_head *pvs, const char *vg_name,
|
||||||
|
struct dev_filter *filter)
|
||||||
|
{
|
||||||
|
struct list_head *tmp;
|
||||||
|
struct disk_list *dl;
|
||||||
|
int vg_num;
|
||||||
|
|
||||||
|
if (!get_free_vg_number(filter, vg_name, &vg_num)) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_for_each (tmp, pvs) {
|
||||||
|
dl = list_entry(tmp, struct disk_list, list);
|
||||||
|
dl->vg.vg_number = vg_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
57
lib/format1/vg_number.c
Normal file
57
lib/format1/vg_number.c
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||||
|
*
|
||||||
|
* This file is released under the GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "pool.h"
|
||||||
|
#include "disk-rep.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: Quick hack. We can use caching to
|
||||||
|
* prevent a total re-read, even so vg_number
|
||||||
|
* causes the tools to check *every* pv. Yuck.
|
||||||
|
* Put in seperate file so it wouldn't contaminate
|
||||||
|
* other code.
|
||||||
|
*/
|
||||||
|
int get_free_vg_number(struct dev_filter *filter, const char *candidate_vg,
|
||||||
|
int *result)
|
||||||
|
{
|
||||||
|
struct list_head all_pvs, *tmp;
|
||||||
|
struct disk_list *dl;
|
||||||
|
struct pool *mem = pool_create(10 * 1024);
|
||||||
|
int numbers[MAX_VG], i, r = 0;
|
||||||
|
|
||||||
|
if (!mem) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!read_pvs_in_vg(NULL, filter, mem, &all_pvs)) {
|
||||||
|
stack;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(numbers, 0, sizeof(numbers));
|
||||||
|
|
||||||
|
list_for_each (tmp, &all_pvs) {
|
||||||
|
dl = list_entry(tmp, struct disk_list, list);
|
||||||
|
if (!strcmp(dl->pv.vg_name, candidate_vg))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
numbers[dl->vg.vg_number] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_VG; i++) {
|
||||||
|
if (!numbers[i]) {
|
||||||
|
r = 1;
|
||||||
|
*result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
pool_destroy(mem);
|
||||||
|
return r;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user