1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-02 22:42:30 +03:00

o LGPL list implementation

This commit is contained in:
Joe Thornber 2001-10-31 12:47:01 +00:00
parent b892f8ecb6
commit 1b9fcf48b1
41 changed files with 316 additions and 432 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "metadata.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "table-build.c"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include <sys/types.h>

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "bitset.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "btree.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/

View File

@ -1,110 +1,55 @@
/* stolen from the Linux kernel. */
/*
* Copyright (C) 2001 Sistina Software
*
* This file is released under the LGPL.
*/
#ifndef _LVM_LIST_H
#define _LVM_LIST_H
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
#include <assert.h>
struct list_head {
struct list_head *next, *prev;
struct list {
struct list *n, *p;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = { &name, &name }
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
static inline void list_init(struct list *head) {
head->n = head->p = head;
}
/*
* Insert a new entry after the specified head..
*/
static __inline__ void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
static inline void list_add(struct list *head, struct list *elem) {
assert(head->n);
elem->n = head;
elem->p = head->p;
head->p->n = elem;
head->p = elem;
}
/*
* Insert a new entry at the tail
*/
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
static inline void list_add_h(struct list *head, struct list *elem) {
assert(head->n);
elem->n = head->n;
elem->p = head;
head->n->p = elem;
head->n = elem;
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_del(struct list_head * prev,
struct list_head * next)
{
next->prev = prev;
prev->next = next;
static inline void list_del(struct list *elem) {
elem->n->p = elem->p;
elem->p->n = elem->n;
}
static __inline__ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
static inline int list_empty(struct list *head) {
return head->n == head;
}
static __inline__ int list_empty(struct list_head *head)
{
return head->next == head;
}
#define list_iterate(v, head) \
for (v = (head)->n; v != head; v = v->n)
/*
* Splice in "list" into "head"
*/
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
if (first != list) {
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_item(v, t) \
((t *)((char *)(v) - (unsigned int) &((t *) 0)->list))
#endif

View File

@ -25,7 +25,7 @@ typedef __int64_t int64_t;
struct str_list {
struct list_head list;
struct list list;
char *str;
};

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "dev-cache.h"
@ -31,7 +31,7 @@ struct dev_iter {
};
struct dir_list {
struct list_head list;
struct list list;
char dir[0];
};
@ -41,7 +41,7 @@ static struct {
struct btree *devices;
int has_scanned;
struct list_head dirs;
struct list dirs;
} _cache;
@ -60,7 +60,7 @@ static struct device *_create_dev(dev_t d)
return NULL;
}
INIT_LIST_HEAD(&dev->aliases);
list_init(&dev->aliases);
dev->dev = d;
return dev;
}
@ -79,7 +79,7 @@ static int _add_alias(struct device *dev, const char *path)
return 0;
}
list_add(&sl->list, &dev->aliases);
list_add(&dev->aliases, &sl->list);
return 1;
}
@ -254,15 +254,15 @@ static int _insert(const char *path, int rec)
static void _full_scan(void)
{
struct list_head *tmp;
struct list *dh;
if (_cache.has_scanned)
return;
list_for_each(tmp, &_cache.dirs) {
struct dir_list *dl = list_entry(tmp, struct dir_list, list);
list_iterate(dh, &_cache.dirs) {
struct dir_list *dl = list_item(dh, struct dir_list);
_insert_dir(dl->dir);
}
};
_cache.has_scanned = 1;
}
@ -288,7 +288,7 @@ int dev_cache_init(void)
goto bad;
}
INIT_LIST_HEAD(&_cache.dirs);
list_init(&_cache.dirs);
return 1;
@ -324,7 +324,7 @@ int dev_cache_add_dir(const char *path)
return 0;
strcpy(dl->dir, path);
list_add(&dl->list, &_cache.dirs);
list_add(&_cache.dirs, &dl->list);
return 1;
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "device.h"

View File

@ -15,7 +15,7 @@
* pointer comparisons are valid.
*/
struct device {
struct list_head aliases; /* struct str_list from lvm-types.h */
struct list aliases; /* struct str_list from lvm-types.h */
dev_t dev;
};
@ -31,7 +31,7 @@ int64_t dev_write(struct device *dev,
uint64_t offset, int64_t len, void *buffer);
static inline const char *dev_name(struct device *dev) {
return list_entry(dev->aliases.next, struct str_list, list)->str;
return list_item(dev->aliases.n, struct str_list)->str;
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "filter-composite.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "config.h"
@ -165,15 +165,15 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
{
struct pfilter *pf = (struct pfilter *) f->private;
void *l = hash_lookup(pf->devices, dev_name(dev));
struct list_head *tmp;
struct str_list *sl;
struct list *ah;
if (!l) {
l = pf->real->passes_filter(pf->real, dev) ?
PF_GOOD_DEVICE : PF_BAD_DEVICE;
list_for_each(tmp, &dev->aliases) {
sl = list_entry(tmp, struct str_list, list);
list_iterate(ah, &dev->aliases) {
sl = list_item(ah, struct str_list);
hash_insert(pf->devices, sl->str, l);
}
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "pool.h"
@ -149,13 +149,13 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
static int _accept_p(struct dev_filter *f, struct device *dev)
{
struct list *ah;
int m, first = 1;
struct rfilter *rf = (struct rfilter *) f->private;
struct list_head *tmp;
struct str_list *sl;
list_for_each(tmp, &dev->aliases) {
sl = list_entry(tmp, struct str_list, list);
list_iterate(ah, &dev->aliases) {
sl = list_item(ah, struct str_list);
m = matcher_run(rf->engine, sl->str);
if (m >= 0) {
@ -163,7 +163,7 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
if (!first) {
list_del(&sl->list);
list_add(&sl->list, &dev->aliases);
list_add_h(&dev->aliases, &sl->list);
}
return 1;

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "disk-rep.h"
@ -170,7 +170,7 @@ static int _read_uuids(struct disk_list *data)
memcpy(ul->uuid, buffer, NAME_LEN);
ul->uuid[NAME_LEN] = '\0';
list_add(&ul->list, &data->uuids);
list_add(&data->uuids, &ul->list);
pos += NAME_LEN;
num_read++;
@ -209,7 +209,7 @@ static int _read_lvs(struct disk_list *data)
if (!_check_lv(&ll->lv))
fail;
list_add(&ll->list, &data->lvs);
list_add(&data->lvs, &ll->list);
}
return 1;
@ -241,8 +241,8 @@ struct disk_list *read_pv(struct device *dev, struct pool *mem,
data->dev = dev;
data->mem = mem;
INIT_LIST_HEAD(&data->uuids);
INIT_LIST_HEAD(&data->lvs);
list_init(&data->uuids);
list_init(&data->lvs);
if (!_read_pv(data)) {
log_debug("Failed to read PV data from %s", name);
@ -311,7 +311,7 @@ struct disk_list *read_pv(struct device *dev, struct pool *mem,
* the memory if something goes wrong.
*/
int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter,
struct pool *mem, struct list_head *head)
struct pool *mem, struct list *head)
{
struct dev_iter *iter = dev_iter_create(filter);
struct device *dev;
@ -319,7 +319,7 @@ int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter,
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
if ((data = read_pv(dev, mem, vg_name)))
list_add(&data->list, head);
list_add(head, &data->list);
}
dev_iter_destroy(iter);
@ -347,18 +347,18 @@ static int _write_vg(struct disk_list *data)
static int _write_uuids(struct disk_list *data)
{
struct uuid_list *ul;
struct list_head *tmp;
struct list *uh;
ulong pos = data->pv.pv_uuidlist_on_disk.base;
ulong end = pos + data->pv.pv_uuidlist_on_disk.size;
list_for_each(tmp, &data->uuids) {
list_iterate(uh, &data->uuids) {
if (pos >= end) {
log_error("Too many uuids to fit on %s",
dev_name(data->dev));
return 0;
}
ul = list_entry(tmp, struct uuid_list, list);
ul = list_item(uh, struct uuid_list);
if (dev_write(data->dev, pos, NAME_LEN, ul->uuid) != NAME_LEN)
fail;
@ -381,11 +381,11 @@ static int _write_lv(struct device *dev, ulong pos, struct lv_disk *disk)
static int _write_lvs(struct disk_list *data)
{
struct list_head *tmp;
struct list *lvh;
unsigned long pos;
list_for_each(tmp, &data->lvs) {
struct lvd_list *ll = list_entry(tmp, struct lvd_list, list);
list_iterate(lvh, &data->lvs) {
struct lvd_list *ll = list_item(lvh, struct lvd_list);
pos = data->pv.lv_on_disk.base;
if (!_write_lv(data->dev, pos, &ll->lv))
@ -468,13 +468,13 @@ static int _write_all_pv(struct disk_list *data)
* little sanity checking, so make sure correct
* data is passed to here.
*/
int write_pvs(struct list_head *pvs)
int write_pvs(struct list *pvs)
{
struct list_head *tmp;
struct list *pvh;
struct disk_list *dl;
list_for_each(tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
if (!(_write_all_pv(dl)))
fail;

View File

@ -134,24 +134,24 @@ struct pe_disk {
struct uuid_list {
struct list_head list;
struct list list;
char uuid[NAME_LEN];
};
struct lvd_list {
struct list_head list;
struct list list;
struct lv_disk lv;
};
struct disk_list {
struct pool *mem;
struct device *dev;
struct list_head list;
struct list list;
struct pv_disk pv;
struct vg_disk vg;
struct list_head uuids;
struct list_head lvs;
struct list uuids;
struct list lvs;
struct pe_disk *extents;
};
@ -182,9 +182,9 @@ struct disk_list *read_pv(struct device *dev, struct pool *mem,
const char *vg_name);
int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter,
struct pool *mem, struct list_head *results);
struct pool *mem, struct list *results);
int write_pvs(struct list_head *pvs);
int write_pvs(struct list *pvs);
/*
@ -204,30 +204,29 @@ int import_lv(struct pool *mem, struct logical_volume *lv,
void export_lv(struct lv_disk *lvd, struct volume_group *vg,
struct logical_volume *lv, const char *prefix);
int import_extents(struct pool *mem, struct volume_group *vg,
struct list_head *pvs);
int import_extents(struct pool *mem, struct volume_group *vg, struct list *pvs);
int export_extents(struct disk_list *dl, int lv_num,
struct logical_volume *lv,
struct physical_volume *pv);
int import_pvs(struct pool *mem, struct list_head *pvs,
struct list_head *results, int *count);
int import_pvs(struct pool *mem, struct list *pvs,
struct list *results, int *count);
int import_lvs(struct pool *mem, struct volume_group *vg,
struct list_head *pvs);
struct list *pvs);
int export_lvs(struct disk_list *dl, struct volume_group *vg,
struct physical_volume *pv, const char *prefix);
int export_uuids(struct disk_list *dl, struct volume_group *vg);
void export_numbers(struct list_head *pvs, struct volume_group *vg);
void export_numbers(struct list *pvs, struct volume_group *vg);
void export_pv_act(struct list_head *pvs);
void export_pv_act(struct list *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,
int export_vg_number(struct list *pvs, const char *vg_name,
struct dev_filter *filter);

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "disk-rep.h"
@ -13,17 +13,17 @@
#include "display.h"
/* VG consistency checks */
static int _check_vgs(struct list_head *pvs)
static int _check_vgs(struct list *pvs)
{
struct list_head *tmp;
struct list *pvh;
struct disk_list *dl = NULL;
struct disk_list *first = NULL;
int pv_count = 0;
/* check all the vg's are the same */
list_for_each(tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
if (!first)
first = dl;
@ -45,7 +45,7 @@ static int _check_vgs(struct list_head *pvs)
return 1;
}
static struct volume_group *_build_vg(struct pool *mem, struct list_head *pvs)
static struct volume_group *_build_vg(struct pool *mem, struct list *pvs)
{
struct volume_group *vg = pool_alloc(mem, sizeof(*vg));
struct disk_list *dl;
@ -56,12 +56,12 @@ static struct volume_group *_build_vg(struct pool *mem, struct list_head *pvs)
if (list_empty(pvs))
goto bad;
dl = list_entry(pvs->next, struct disk_list, list);
dl = list_item(pvs->n, struct disk_list);
memset(vg, 0, sizeof(*vg));
INIT_LIST_HEAD(&vg->pvs);
INIT_LIST_HEAD(&vg->lvs);
list_init(&vg->pvs);
list_init(&vg->lvs);
if (!_check_vgs(pvs))
goto bad;
@ -89,9 +89,9 @@ static struct volume_group *_build_vg(struct pool *mem, struct list_head *pvs)
static struct volume_group *_vg_read(struct io_space *is, const char *vg_name)
{
struct pool *mem = pool_create(1024 * 10);
struct list_head pvs;
struct list pvs;
struct volume_group *vg;
INIT_LIST_HEAD(&pvs);
list_init(&pvs);
if (!mem) {
stack;
@ -128,8 +128,8 @@ static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
dl->mem = mem;
dl->dev = pv->dev;
INIT_LIST_HEAD(&dl->uuids);
INIT_LIST_HEAD(&dl->lvs);
list_init(&dl->uuids);
list_init(&dl->lvs);
if (!export_pv(&dl->pv, pv) ||
!export_vg(&dl->vg, vg) ||
@ -145,22 +145,22 @@ static struct disk_list *_flatten_pv(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 *pvs, const char *prefix,
struct dev_filter *filter)
{
struct list_head *tmp;
struct list *pvh;
struct pv_list *pvl;
struct disk_list *data;
list_for_each(tmp, &vg->pvs) {
pvl = list_entry(tmp, struct pv_list, list);
list_iterate(pvh, &vg->pvs) {
pvl = list_item(pvh, struct pv_list);
if (!(data = _flatten_pv(mem, vg, &pvl->pv, prefix))) {
stack;
return 0;
}
list_add(&data->list, pvs);
list_add(pvs, &data->list);
}
export_numbers(pvs, vg);
@ -177,7 +177,7 @@ static int _flatten_vg(struct pool *mem, struct volume_group *vg,
static int _vg_write(struct io_space *is, struct volume_group *vg)
{
struct pool *mem = pool_create(1024 * 10);
struct list_head pvs;
struct list pvs;
int r = 0;
if (!mem) {
@ -185,7 +185,7 @@ static int _vg_write(struct io_space *is, struct volume_group *vg)
return 0;
}
INIT_LIST_HEAD(&pvs);
list_init(&pvs);
r = (_flatten_vg(mem, vg, &pvs, is->prefix, is->filter) &&
write_pvs(&pvs));
@ -201,7 +201,7 @@ static struct physical_volume *_pv_read(struct io_space *is,
struct disk_list *dl;
struct device *dev;
log_very_verbose("Reading physical volume data %s from disk", name);
log_very_verbose("Reading physical volume data %s from disk", name);
if (!mem) {
stack;
@ -236,10 +236,10 @@ static struct physical_volume *_pv_read(struct io_space *is,
return NULL;
}
static struct list_head *_get_pvs(struct io_space *is)
static struct list *_get_pvs(struct io_space *is)
{
struct pool *mem = pool_create(1024 * 10);
struct list_head pvs, *results;
struct list pvs, *results;
uint32_t count;
if (!mem) {
@ -253,8 +253,8 @@ static struct list_head *_get_pvs(struct io_space *is)
return NULL;
}
INIT_LIST_HEAD(&pvs);
INIT_LIST_HEAD(results);
list_init(&pvs);
list_init(results);
if (!read_pvs_in_vg(NULL, is->filter, mem, &pvs)) {
stack;
@ -275,13 +275,13 @@ static struct list_head *_get_pvs(struct io_space *is)
return NULL;
}
static int _find_vg_name(struct list_head *names, const char *vg)
static int _find_vg_name(struct list *names, const char *vg)
{
struct list_head *tmp;
struct list *nh;
struct name_list *nl;
list_for_each(tmp, names) {
nl = list_entry(tmp, struct name_list, list);
list_iterate(nh, names) {
nl = list_item(nh, struct name_list);
if (!strcmp(nl->name, vg))
return 1;
}
@ -289,10 +289,10 @@ static int _find_vg_name(struct list_head *names, const char *vg)
return 0;
}
static struct list_head *_get_vgs(struct io_space *is)
static struct list *_get_vgs(struct io_space *is)
{
struct list_head *tmp, *pvs;
struct list_head *names = pool_alloc(is->mem, sizeof(*names));
struct list *pvh;
struct list *pvs, *names = pool_alloc(is->mem, sizeof(*names));
struct name_list *nl;
if (!names) {
@ -300,17 +300,17 @@ static struct list_head *_get_vgs(struct io_space *is)
return NULL;
}
INIT_LIST_HEAD(names);
list_init(names);
if (!(pvs = _get_pvs(is))) {
stack;
goto bad;
}
list_for_each(tmp, pvs) {
struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
list_iterate(pvh, pvs) {
struct pv_list *pvl = list_item(pvh, struct pv_list);
if (!(*pvl->pv.vg_name) ||
if (!(*pvl->pv.vg_name) ||
_find_vg_name(names, pvl->pv.vg_name))
continue;
@ -324,7 +324,7 @@ static struct list_head *_get_vgs(struct io_space *is)
goto bad;
}
list_add(&nl->list, names);
list_add(names, &nl->list);
}
if (list_empty(names))
@ -355,12 +355,12 @@ static int _pv_write(struct io_space *is, struct physical_volume *pv)
{
struct pool *mem;
struct disk_list *dl;
struct list_head pvs;
struct list pvs;
INIT_LIST_HEAD(&pvs);
list_init(&pvs);
if (*pv->vg_name || pv->pe_allocated ) {
log_error("Assertion failed: can't _pv_write non-orphan PV "
log_error("Assertion failed: can't _pv_write non-orphan PV "
"(in VG %s)", pv->vg_name);
return 0;
}
@ -387,7 +387,7 @@ static int _pv_write(struct io_space *is, struct physical_volume *pv)
goto bad;
}
list_add(&dl->list, &pvs);
list_add(&pvs, &dl->list);
if (!write_pvs(&pvs)) {
stack;
goto bad;
@ -414,7 +414,7 @@ int _vg_setup(struct io_space *is, struct volume_group *vg)
char *dummy, *dummy2;
log_error("Extent size must be between %s and %s",
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)),
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)),
(dummy2 = display_size(MAX_PE_SIZE / 2, SIZE_SHORT)));
dbg_free(dummy);

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "disk-rep.h"
@ -37,12 +37,12 @@ static char *_create_lv_name(struct pool *mem, const char *full_name)
static int _fill_lv_array(struct logical_volume **lvs,
struct volume_group *vg, struct disk_list *dl)
{
struct list_head *tmp;
struct list *lvh;
struct logical_volume *lv;
int i = 0;
list_for_each(tmp, &dl->lvs) {
struct lvd_list *ll = list_entry(tmp, struct lvd_list, list);
list_iterate(lvh, &dl->lvs) {
struct lvd_list *ll = list_item(lvh, struct lvd_list);
if (!(lv = find_lv(vg, ll->lv.lv_name))) {
stack;
@ -317,19 +317,18 @@ void export_lv(struct lv_disk *lvd, struct volume_group *vg,
lvd->lv_allocation = LV_CONTIGUOUS;
}
int import_extents(struct pool *mem, struct volume_group *vg,
struct list_head *pvs)
int import_extents(struct pool *mem, struct volume_group *vg, struct list *pvs)
{
struct list_head *tmp;
struct disk_list *dl;
struct logical_volume *lv, *lvs[MAX_LV];
struct physical_volume *pv;
struct pe_disk *e;
int i;
uint32_t lv_num, le;
struct list *pvh;
list_for_each(tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
pv = _find_pv(vg, dl->dev);
e = dl->extents;
@ -380,16 +379,16 @@ int export_extents(struct disk_list *dl, int lv_num,
return 1;
}
int import_pvs(struct pool *mem, struct list_head *pvs,
struct list_head *results, int *count)
int import_pvs(struct pool *mem, struct list *pvs,
struct list *results, int *count)
{
struct list_head *tmp;
struct list *pvh;
struct disk_list *dl;
struct pv_list *pvl;
*count = 0;
list_for_each(tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
pvl = pool_alloc(mem, sizeof(*pvl));
if (!pvl) {
@ -402,7 +401,7 @@ int import_pvs(struct pool *mem, struct list_head *pvs,
return 0;
}
list_add(&pvl->list, results);
list_add(results, &pvl->list);
(*count)++;
}
@ -427,24 +426,24 @@ static struct logical_volume *_add_lv(struct pool *mem,
return NULL;
}
list_add(&ll->list, &vg->lvs);
list_add(&vg->lvs, &ll->list);
vg->lv_count++;
return lv;
}
int import_lvs(struct pool *mem, struct volume_group *vg,
struct list_head *pvs)
struct list *pvs)
{
struct list_head *tmp, *tmp2;
struct disk_list *dl;
struct lvd_list *ll;
struct lv_disk *lvd;
struct list *pvh, *lvh;
list_for_each(tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_for_each(tmp2, &dl->lvs) {
ll = list_entry(tmp2, struct lvd_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
list_iterate(lvh, &dl->lvs) {
ll = list_item(lvh, struct lvd_list);
lvd = &ll->lv;
if (!find_lv(vg, lvd->lv_name) &&
@ -461,7 +460,7 @@ int import_lvs(struct pool *mem, struct volume_group *vg,
int export_lvs(struct disk_list *dl, struct volume_group *vg,
struct physical_volume *pv, const char *prefix)
{
struct list_head *tmp;
struct list *lvh;
struct lv_list *ll;
struct lvd_list *lvdl;
int lv_num = 1, len;
@ -477,8 +476,8 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
memset(dl->extents, 0, len);
list_for_each(tmp, &vg->lvs) {
ll = list_entry(tmp, struct lv_list, list);
list_iterate(lvh, &vg->lvs) {
ll = list_item(lvh, struct lv_list);
if (!(lvdl = pool_alloc(dl->mem, sizeof(*lvdl)))) {
stack;
return 0;
@ -490,7 +489,7 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
return 0;
}
list_add(&lvdl->list, &dl->lvs);
list_add(&dl->lvs, &lvdl->list);
dl->pv.lv_cur++;
}
return 1;
@ -498,12 +497,12 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
int export_uuids(struct disk_list *dl, struct volume_group *vg)
{
struct list_head *tmp;
struct uuid_list *ul;
struct pv_list *pvl;
struct list *pvh;
list_for_each(tmp, &vg->pvs) {
pvl = list_entry(tmp, struct pv_list, list);
list_iterate(pvh, &vg->pvs) {
pvl = list_item(pvh, struct pv_list);
if (!(ul = pool_alloc(dl->mem, sizeof(*ul)))) {
stack;
return 0;
@ -512,7 +511,7 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg)
memset(ul->uuid, 0, sizeof(ul->uuid));
memcpy(ul->uuid, pvl->pv.id.uuid, ID_LEN);
list_add(&ul->list, &dl->uuids);
list_add(&dl->uuids, &ul->list);
}
return 1;
}
@ -520,12 +519,11 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg)
static int _get_lv_number(struct volume_group *vg, const char *name)
{
/* FIXME: inefficient */
struct list_head *tmp;
struct lv_list *ll;
int r = 0;
struct list *lvh;
list_for_each (tmp, &vg->lvs) {
ll = list_entry(tmp, struct lv_list, list);
list_iterate(lvh, &vg->lvs) {
struct lv_list *ll = list_item(lvh, struct lv_list);
if (!strcmp(ll->lv.name, name))
break;
r++;
@ -539,19 +537,19 @@ static int _get_lv_number(struct volume_group *vg, const char *name)
* lv_number fields used by LVM1. Very
* inefficient code.
*/
void export_numbers(struct list_head *pvs, struct volume_group *vg)
void export_numbers(struct list *pvs, struct volume_group *vg)
{
struct list_head *tmp, *tmp2;
struct list *pvh, *lvh;
struct disk_list *dl;
struct lvd_list *ll;
int pv_num = 1;
list_for_each (tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
dl->pv.pv_number = pv_num++;
list_for_each (tmp2, &dl->lvs) {
ll = list_entry(tmp2, struct lvd_list, list);
list_iterate(lvh, &dl->lvs) {
ll = list_item(lvh, struct lvd_list);
ll->lv.lv_number = _get_lv_number(vg, ll->lv.lv_name);
}
}
@ -560,28 +558,28 @@ void export_numbers(struct list_head *pvs, struct volume_group *vg)
/*
* Calculate vg_disk->pv_act.
*/
void export_pv_act(struct list_head *pvs)
void export_pv_act(struct list *pvs)
{
struct list_head *tmp;
struct list *pvh;
struct disk_list *dl;
int act = 0;
list_for_each (tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
if (dl->pv.pv_status & PV_ACTIVE)
act++;
}
list_for_each (tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
dl->vg.pv_act = act;
}
}
int export_vg_number(struct list_head *pvs, const char *vg_name,
int export_vg_number(struct list *pvs, const char *vg_name,
struct dev_filter *filter)
{
struct list_head *tmp;
struct list *pvh;
struct disk_list *dl;
int vg_num;
@ -590,8 +588,8 @@ int export_vg_number(struct list_head *pvs, const char *vg_name,
return 0;
}
list_for_each (tmp, pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, pvs) {
dl = list_item(pvh, struct disk_list);
dl->vg.vg_number = vg_num;
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "disk-rep.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "log.h"
@ -18,12 +18,13 @@
int get_free_vg_number(struct dev_filter *filter, const char *candidate_vg,
int *result)
{
struct list_head all_pvs, *tmp;
struct list *pvh;
struct list all_pvs;
struct disk_list *dl;
struct pool *mem = pool_create(10 * 1024);
int numbers[MAX_VG], i, r = 0;
INIT_LIST_HEAD(&all_pvs);
list_init(&all_pvs);
if (!mem) {
stack;
@ -37,8 +38,8 @@ int get_free_vg_number(struct dev_filter *filter, const char *candidate_vg,
memset(numbers, 0, sizeof(numbers));
list_for_each (tmp, &all_pvs) {
dl = list_entry(tmp, struct disk_list, list);
list_iterate(pvh, &all_pvs) {
dl = list_item(pvh, struct disk_list);
if (!strcmp(dl->pv.vg_name, candidate_vg))
continue;

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "log.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
* This file is released under the LGPL.
*/
#include "log.h"
@ -91,7 +91,7 @@ int _add_pv_to_vg(struct io_space *ios, struct volume_group *vg,
memcpy(&pvl->pv, pv, sizeof (struct physical_volume));
list_add(&pvl->list, &vg->pvs);
list_add(&vg->pvs, &pvl->list);
vg->pv_count++;
return 1;
@ -154,10 +154,10 @@ struct volume_group *vg_create(struct io_space *ios, const char *vg_name,
vg->max_pv = max_pv;
vg->pv_count = 0;
INIT_LIST_HEAD(&vg->pvs);
list_init(&vg->pvs);
vg->lv_count = 0;
INIT_LIST_HEAD(&vg->lvs);
list_init(&vg->lvs);
if (!ios->vg_setup(ios, vg)) {
log_error("Format specific setup of volume group '%s' failed.",
@ -216,13 +216,13 @@ struct physical_volume *pv_create(struct io_space *ios, const char *name)
return NULL;
}
struct list_head *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
struct list *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
{
struct list_head *pvh;
struct list *pvh;
struct pv_list *pv;
list_for_each(pvh, &vg->pvs) {
pv = list_entry(pvh, struct pv_list, list);
list_iterate(pvh, &vg->pvs) {
pv = list_item(pvh, struct pv_list);
/* FIXME check dev not name */
if (!strcmp(dev_name(pv->pv.dev), pv_name))
return pvh;
@ -232,10 +232,9 @@ struct list_head *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
}
struct list_head *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
struct list *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
{
struct list_head *lvh;