1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-30 17:44:21 +03:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Heinz Mauelshagen
976666d216 Zero gap after PV structure on write to disk in order to make non LVM tools happier (AED's idea and patch for LVM1) 2002-01-29 15:52:11 +00:00
Heinz Mauelshagen
9a5bcd4392 fixed div bug in calculation of end in calculate_extent_count 2002-01-29 15:43:04 +00:00
Heinz Mauelshagen
812060a118 Check that vgname doesn't already exits in dev_dir 2002-01-28 16:30:42 +00:00
Joe Thornber
089b5052e6 o There were some alignment problems with pool-debug which I've resolved
by allocating the data block with an additional dbg_malloc.

o  Added an assertion to check that no one is requesting alternate
   alignment for memory allocated from pool.  I can't see us needing this
   for LVM2.
2002-01-28 09:16:09 +00:00
Alasdair Kergon
874e5d72f4 *** empty log message *** 2002-01-27 21:48:05 +00:00
Alasdair Kergon
6b11de1329 Tweak some error message levels. 2002-01-27 21:30:47 +00:00
Alasdair Kergon
2245a7ad8d If lv isn't active, skip reactivation. 2002-01-25 22:58:01 +00:00
18 changed files with 128 additions and 59 deletions

View File

@@ -1 +1 @@
0.95.01-cvs (2002-01-22)
0.95.02-cvs (2002-01-27)

View File

@@ -46,7 +46,8 @@ static int _rm_dir(struct volume_group *vg)
if (!build_vg_path(vg_path, sizeof(vg_path),
vg->cmd->dev_dir, vg->name)) {
log_err("Couldn't remove volume group directory.");
log_error("Couldn't construct name of volume group dir for %s",
vg->name);
return 0;
}
@@ -62,16 +63,16 @@ static int _mk_link(struct logical_volume *lv)
struct stat buf;
if (!build_dm_path(lv_path, sizeof(lv_path), lv->vg->name, lv->name)) {
log_err("Couldn't create destination path for "
"logical volume link.");
log_error("Couldn't create destination pathname for "
"logical volume link for %s", lv->name);
return 0;
}
if (!build_lv_link_path(link_path, sizeof(link_path),
lv->vg->cmd->dev_dir,
lv->vg->name, lv->name)) {
log_err("Couldn't create source path for "
"logical volume link.");
log_error("Couldn't create source pathname for "
"logical volume link %s", lv->name);
return 0;
}
@@ -107,7 +108,7 @@ static int _rm_link(struct logical_volume *lv, const char *lv_name)
if (!build_lv_link_path(link_path, sizeof(link_path),
lv->vg->cmd->dev_dir,
lv->vg->name, lv->name)) {
log_err("Couldn't create link path (in order to remove it.");
log_error("Couldn't determine link pathname.");
return 0;
}

View File

@@ -554,12 +554,12 @@ find_config_str(struct config_node *cn,
struct config_node *n = find_config_node(cn, path, sep);
if (n && n->v->type == CFG_STRING) {
log_debug("Setting %s to %s", path, n->v->v.str);
log_very_verbose("Setting %s to %s", path, n->v->v.str);
return n->v->v.str;
}
if (fail)
log_debug("%s not found in config: defaulting to %s",
log_very_verbose("%s not found in config: defaulting to %s",
path, fail);
return fail;
}
@@ -570,11 +570,12 @@ int find_config_int(struct config_node *cn, const char *path,
struct config_node *n = find_config_node(cn, path, sep);
if (n && n->v->type == CFG_INT) {
log_debug("Setting %s to %d", path, n->v->v.i);
log_very_verbose("Setting %s to %d", path, n->v->v.i);
return n->v->v.i;
}
log_debug("%s not found in config: defaulting to %d", path, fail);
log_very_verbose("%s not found in config: defaulting to %d",
path, fail);
return fail;
}
@@ -584,11 +585,11 @@ float find_config_float(struct config_node *cn, const char *path,
struct config_node *n = find_config_node(cn, path, sep);
if (n && n->v->type == CFG_FLOAT) {
log_debug("Setting %s to %f", path, n->v->v.r);
log_very_verbose("Setting %s to %f", path, n->v->v.r);
return n->v->v.r;
}
log_debug("%s not found in config: defaulting to %f",
log_very_verbose("%s not found in config: defaulting to %f",
path, fail);
return fail;

View File

@@ -5,6 +5,7 @@
*/
#include "disk-rep.h"
#include "dbg_malloc.h"
#include "pool.h"
#include "xlate.h"
#include "log.h"
@@ -134,7 +135,8 @@ static int _munge_formats(struct pv_disk *pvd)
int read_pvd(struct device *dev, struct pv_disk *pvd)
{
if (dev_read(dev, 0, sizeof(*pvd), pvd) != sizeof(*pvd)) {
log_debug("Failed to read PV data from %s", dev_name(dev));
log_very_verbose("Failed to read PV data from %s",
dev_name(dev));
return 0;
}
@@ -168,7 +170,7 @@ static int _read_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
static int _read_vgd(struct disk_list *data)
{
struct vg_disk *vgd = &data->vgd;
unsigned long pos = data->pvd.vg_on_disk.base;
ulong pos = data->pvd.vg_on_disk.base;
if (dev_read(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
fail;
@@ -213,7 +215,7 @@ static inline int _check_lvd(struct lv_disk *lvd)
static int _read_lvs(struct disk_list *data)
{
int i, read = 0;
unsigned long pos;
ulong pos;
struct lvd_list *ll;
struct vg_disk *vgd = &data->vgd;
@@ -241,7 +243,7 @@ static int _read_extents(struct disk_list *data)
{
size_t len = sizeof(struct pe_disk) * data->pvd.pe_total;
struct pe_disk *extents = pool_alloc(data->mem, len);
unsigned long pos = data->pvd.pe_on_disk.base;
ulong pos = data->pvd.pe_on_disk.base;
if (!extents)
fail;
@@ -350,12 +352,13 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
if (!strncmp(data->pvd.pv_uuid, pvd->pv_uuid,
sizeof(pvd->pv_uuid))) {
if (MAJOR(data->dev->dev) != md_major()) {
log_debug("Ignoring duplicate PV %s on %s",
pvd->pv_uuid, dev_name(data->dev));
log_very_verbose("Ignoring duplicate PV %s on "
"%s", pvd->pv_uuid,
dev_name(data->dev));
return;
}
log_debug("Duplicate PV %s - using md %s",
pvd->pv_uuid, dev_name(data->dev));
log_very_verbose("Duplicate PV %s - using md %s",
pvd->pv_uuid, dev_name(data->dev));
list_del(pvdh);
break;
}
@@ -419,7 +422,7 @@ int read_pvs_in_vg(const char *vg_name, struct dev_filter *filter,
static int _write_vgd(struct disk_list *data)
{
struct vg_disk *vgd = &data->vgd;
unsigned long pos = data->pvd.vg_on_disk.base;
ulong pos = data->pvd.vg_on_disk.base;
_xlate_vgd(vgd);
if (dev_write(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
@@ -468,7 +471,7 @@ static int _write_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
static int _write_lvs(struct disk_list *data)
{
struct list *lvh;
unsigned long pos;
ulong pos;
pos = data->pvd.lv_on_disk.base;
@@ -494,7 +497,7 @@ static int _write_extents(struct disk_list *data)
{
size_t len = sizeof(struct pe_disk) * data->pvd.pe_total;
struct pe_disk *extents = data->extents;
unsigned long pos = data->pvd.pe_on_disk.base;
ulong pos = data->pvd.pe_on_disk.base;
_xlate_extents(extents, data->pvd.pe_total);
if (dev_write(data->dev, pos, len, extents) != len)
@@ -507,14 +510,34 @@ static int _write_extents(struct disk_list *data)
static int _write_pvd(struct disk_list *data)
{
struct pv_disk *disk = &data->pvd;
char *buf;
ulong pos = data->pvd.pv_on_disk.base;
ulong size = data->pvd.pv_on_disk.size;
_xlate_pvd(disk);
if (dev_write(data->dev, 0, sizeof(*disk), disk) != sizeof(*disk))
if(size < sizeof(struct pv_disk)) {
log_err("Invalid PV size.");
return 0;
}
/* Make sure that the gap between the PV structure and
the next one is zeroed in order to make non LVM tools
happy (idea from AED) */
buf = dbg_malloc(size);
if(!buf) {
log_err("Couldn't allocate temporary PV buffer.");
return 0;
}
memset(buf, 0, size);
memcpy(buf, &data->pvd, sizeof(struct pv_disk));
_xlate_pvd((struct pv_disk *)buf);
if (dev_write(data->dev, pos, size, buf) != size) {
dbg_free(buf);
fail;
}
_xlate_pvd(disk);
dbg_free(buf);
return 1;
}
@@ -596,7 +619,8 @@ int write_disks(struct list *pvs)
if (!(_write_all_pvd(dl)))
fail;
log_debug("Successfully wrote data to %s", dev_name(dl->dev));
log_very_verbose("Successfully wrote data to %s",
dev_name(dl->dev));
}
return 1;

View File

@@ -29,8 +29,8 @@ static int _check_vgs(struct list *pvs)
first = dl;
else if (memcmp(&first->vgd, &dl->vgd, sizeof(first->vgd))) {
log_err("VG data differs between PVs %s and %s",
dev_name(first->dev), dev_name(dl->dev));
log_error("VG data differs between PVs %s and %s",
dev_name(first->dev), dev_name(dl->dev));
return 0;
}
pv_count++;
@@ -359,8 +359,8 @@ static int _pv_setup(struct format_instance *fi, struct physical_volume *pv,
static int _lv_setup(struct format_instance *fi, struct logical_volume *lv)
{
if (lv->le_count > MAX_LE_TOTAL) {
log_err("Format 1 logical volumes cannot contain more than "
"%d extents.", MAX_LE_TOTAL);
log_error("logical volumes cannot contain more than "
"%d extents.", MAX_LE_TOTAL);
return 0;
}
@@ -401,6 +401,11 @@ static int _pv_write(struct format_instance *fi, struct physical_volume *pv)
goto bad;
}
/* must be set to be able to zero gap after PV structure in
dev_write in order to make other disk tools happy */
dl->pvd.pv_on_disk.base = METADATA_BASE;
dl->pvd.pv_on_disk.size = PV_SIZE;
list_add(&pvs, &dl->list);
if (!write_disks(&pvs)) {
stack;

View File

@@ -140,8 +140,8 @@ int calculate_extent_count(struct physical_volume *pv)
do {
pvd->pe_total--;
_calc_simple_layout(pvd);
end = ((pvd->pe_on_disk.base + pvd->pe_on_disk.size) /
SECTOR_SIZE);
end = ((pvd->pe_on_disk.base + pvd->pe_on_disk.size + \
SECTOR_SIZE - 1) / SECTOR_SIZE);
pvd->pe_start = _round_up(end, PE_ALIGN);

View File

@@ -55,7 +55,7 @@ static void _inc_indent(struct formatter *f)
static void _dec_indent(struct formatter *f)
{
if (!f->indent--) {
log_debug("Indenting seems to have messed up\n");
log_error("Internal error tracking indentation");
f->indent = 0;
}
}

View File

@@ -70,7 +70,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
#define log_err(x...) plog(_LOG_ERR, x)
#define log_fatal(x...) plog(_LOG_FATAL, x)
#define stack log_debug( "s" )
#define stack log_debug( "s" ) /* Backtrace on error */
#define log_error(fmt, args...) log_err(fmt , ## args)
#define log_print(fmt, args...) log_warn(fmt , ## args)

View File

@@ -66,7 +66,7 @@ int _add_pv_to_vg(struct format_instance *fi, struct volume_group *vg,
pv->pe_allocated = 0;
if (!fi->ops->pv_setup(fi, pv, vg)) {
log_debug("Format-specific setup of physical volume '%s' "
log_error("Format-specific setup of physical volume '%s' "
"failed.", pv_name);
return 0;
}

View File

@@ -267,7 +267,7 @@ struct logical_volume *lv_create(struct format_instance *fi,
struct volume_group *vg,
struct list *acceptable_pvs);
int lv_reduce(struct format_instance *fi,
int lv_reduce(struct format_instance *fi,
struct logical_volume *lv, uint32_t extents);
int lv_extend(struct format_instance *fi,

View File

@@ -13,7 +13,7 @@
struct block {
struct block *next;
size_t size;
char data[0];
void *data;
};
struct pool {
@@ -49,6 +49,7 @@ static void _free_blocks(struct block *b)
while (b) {
n = b->next;
dbg_free(b->data);
dbg_free(b);
b = n;
}
@@ -76,12 +77,27 @@ static void _append_block(struct pool *p, struct block *b)
static struct block *_new_block(size_t s, unsigned alignment)
{
static char *_oom = "Out of memory";
/* FIXME: I'm currently ignoring the alignment arg. */
size_t len = sizeof(struct block) + s;
struct block *b = dbg_malloc(len);
/*
* Too lazy to implement alignment for debug version, and
* I don't think LVM will use anything but default
* align.
*/
assert(alignment == DEFAULT_ALIGNMENT);
if (!b) {
log_err("Out of memory. Requested %u bytes.", len);
log_err(_oom);
return NULL;
}
if (!(b->data = dbg_malloc(s))) {
log_err(_oom);
dbg_free(b);
return NULL;
}
@@ -99,7 +115,7 @@ void *pool_alloc_aligned(struct pool *p, size_t s, unsigned alignment)
return NULL;
_append_block(p, b);
return &b->data[0];
return b->data;
}
void pool_empty(struct pool *p)
@@ -113,7 +129,7 @@ void pool_free(struct pool *p, void *ptr)
struct block *b, *prev = NULL;
for (b = p->blocks; b; b = b->next) {
if ((void *) &b->data[0] == ptr)
if (b->data == ptr)
break;
prev = b;
}
@@ -157,7 +173,7 @@ int pool_grow_object(struct pool *p, const void *buffer, size_t delta)
}
if (p->object) {
memcpy(&new->data, &p->object->data, p->object->size);
memcpy(new->data, p->object->data, p->object->size);
dbg_free(p->object);
}
p->object = new;
@@ -172,7 +188,7 @@ void *pool_end_object(struct pool *p)
p->begun = 0;
p->object = NULL;
return &p->tail->data;
return p->tail->data;
}
void pool_abandon_object(struct pool *p)

View File

@@ -125,8 +125,8 @@ void pool_free(struct pool *p, void *ptr)
}
if (!c)
log_debug("pool_free asked to free a pointer "
"that wasn't in the pool, doing nothing");
log_error("Internal error: pool_free asked to free pointer "
"not in pool");
else
p->chunk = c;
}

View File

@@ -128,7 +128,7 @@ static void _calc_functions(struct matcher *m)
break;
default:
log_debug("unknown node type");
log_error("Internal error: Unknown calc node type");
}
/*
@@ -301,7 +301,7 @@ struct matcher *matcher_create(struct pool *mem,
/* parse this expression */
if(!(rx = rx_parse_tok(scratch, all, ptr))) {
log_debug("Couldn't parse the regex");
log_error("Couldn't parse regex");
goto bad;
}

View File

@@ -70,7 +70,7 @@ static int _get_token(struct parse_sp *ps)
range = 1;
ptr++;
if(ptr == ps->rx_end) {
log_info("incomplete charset "
log_error("Incomplete range"
"specification");
return -1;
}
@@ -142,8 +142,8 @@ static int _get_token(struct parse_sp *ps)
/* escaped character */
ptr++;
if(ptr >= ps->rx_end) {
log_info("badly quoted character at end "
"of expression");
log_error("Badly quoted character at end "
"of expression");
ps->type = -1;
return -1;
}
@@ -210,7 +210,7 @@ static struct rx_node *_term(struct parse_sp *ps)
_get_token(ps); /* match '(' */
n = _or_term(ps);
if(ps->type != ')') {
log_debug("missing ')' in regular expression");
log_error("missing ')' in regular expression");
return 0;
}
_get_token(ps); /* match ')' */
@@ -292,7 +292,7 @@ static struct rx_node *_or_term(struct parse_sp *ps)
_get_token(ps); /* match '|' */
if (!(r = _or_term(ps))) {
log_info("badly formed 'or' expression");
log_error("Badly formed 'or' expression");
return NULL;
}
@@ -320,7 +320,7 @@ struct rx_node *rx_parse_tok(struct pool *mem,
_get_token(ps); /* load the first token */
if (!(r = _or_term(ps))) {
log_err("parse error in regex");
log_error("Parse error in regex");
pool_free(mem, ps);
}

View File

@@ -37,6 +37,7 @@ int lvresize(int argc, char **argv)
struct list *pvh, *segh;
struct lv_list *lvl;
int opt = 0;
int active;
enum {
LV_ANY = 0,
@@ -314,6 +315,9 @@ int lvresize(int argc, char **argv)
return ECMD_FAILED;
}
active = lv_active(lv);
/********* FIXME Suspend lv ***********/
/* store vg on disk(s) */
@@ -322,8 +326,7 @@ int lvresize(int argc, char **argv)
backup(vg);
/* FIXME Ensure it always displays errors? */
if (!lv_reactivate(lv))
if (active && !lv_reactivate(lv))
return ECMD_FAILED;
/********* FIXME Resume *********/

View File

@@ -8,6 +8,21 @@
#include <sys/stat.h>
int check_dir(const char *dir)
{
struct stat info;
if (!*dir)
return 1;
if (stat(dir, &info) != -1 ) {
log_error("%s exists", dir);
return 0;
}
return 1;
}
int create_dir(const char *dir)
{
struct stat info;

View File

@@ -31,6 +31,7 @@ int vgcreate(int argc, char **argv)
int max_lv, max_pv;
uint32_t extent_size;
char *vg_name;
char vg_path[PATH_MAX];
struct volume_group *vg;
if (!argc) {
@@ -65,6 +66,9 @@ int vgcreate(int argc, char **argv)
if (!strncmp(vg_name, fid->cmd->dev_dir, strlen(fid->cmd->dev_dir)))
vg_name += strlen(fid->cmd->dev_dir);
snprintf(vg_path, PATH_MAX, "%s%s", fid->cmd->dev_dir, vg_name);
if (!check_dir(vg_path)) return ECMD_FAILED;
if (!is_valid_chars(vg_name)) {
log_error("New volume group name '%s' has invalid characters",
vg_name);

View File

@@ -35,7 +35,7 @@ int vgscan(int argc, char **argv)
log_verbose("Wiping internal cache of PVs in VGs");
vgcache_destroy();
log_print("Reading all physical volumes (this may take a while...)");
log_print("Reading all physical volumes. This may take a while...");
return process_each_vg(argc, argv, &vgscan_single);
}