1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Don't create backup and archive dirs till needed.

This commit is contained in:
Alasdair Kergon 2005-05-03 17:31:56 +00:00
parent 15db9fcfbf
commit abe198c0e8
4 changed files with 22 additions and 27 deletions

View File

@ -1,5 +1,6 @@
Version 2.01.10 - Version 2.01.10 -
================================ ================================
Don't create backup and archive dirs till needed.
Reinstate full PV size when removing from VG. Reinstate full PV size when removing from VG.
Support loopfiles for testing. Support loopfiles for testing.
Tidy lv_segment interface. Tidy lv_segment interface.

View File

@ -49,7 +49,6 @@ static struct {
} _cache; } _cache;
#define _alloc(x) pool_zalloc(_cache.mem, (x)) #define _alloc(x) pool_zalloc(_cache.mem, (x))
#define _strdup(x) pool_strdup(_cache.mem, (x))
#define _free(x) pool_free(_cache.mem, (x)) #define _free(x) pool_free(_cache.mem, (x))
static int _insert(const char *path, int rec); static int _insert(const char *path, int rec);
@ -70,14 +69,7 @@ struct device *dev_create_file(const char *filename, struct device *dev,
dbg_free(dev); dbg_free(dev);
return NULL; return NULL;
} }
if (!(alias->str = dbg_strdup(filename))) {
log_error("filename strdup failed");
if (allocate) {
dbg_free(dev);
dbg_free(alias);
}
return NULL;
}
dev->flags = DEV_ALLOCED; dev->flags = DEV_ALLOCED;
} else { } else {
if (!(dev = _alloc(sizeof(*dev)))) { if (!(dev = _alloc(sizeof(*dev)))) {
@ -86,19 +78,21 @@ struct device *dev_create_file(const char *filename, struct device *dev,
} }
if (!(alias = _alloc(sizeof(*alias)))) { if (!(alias = _alloc(sizeof(*alias)))) {
log_error("struct str_list allocation failed"); log_error("struct str_list allocation failed");
dbg_free(dev); _free(dev);
return NULL;
}
if (!(alias->str = _strdup(filename))) {
log_error("filename strdup failed");
if (allocate) {
dbg_free(dev);
dbg_free(alias);
}
return NULL; return NULL;
} }
} }
} }
if (!(alias->str = dbg_strdup(filename))) {
log_error("filename strdup failed");
if (allocate && use_malloc) {
dbg_free(dev);
dbg_free(alias);
}
return NULL;
}
dev->flags |= DEV_REGULAR; dev->flags |= DEV_REGULAR;
list_init(&dev->aliases); list_init(&dev->aliases);
list_add(&dev->aliases, &alias->list); list_add(&dev->aliases, &alias->list);

View File

@ -148,7 +148,7 @@ static struct list *_scan_archive(struct pool *mem,
/* Sort fails beyond 5-digit indexes */ /* Sort fails beyond 5-digit indexes */
if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) { if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
log_err("Couldn't scan archive directory."); log_err("Couldn't scan the archive directory (%s).", dir);
return 0; return 0;
} }
@ -273,7 +273,7 @@ int archive_vg(struct volume_group *vg,
* Now we want to rename this file to <vg>_index.vg. * Now we want to rename this file to <vg>_index.vg.
*/ */
if (!(archives = _scan_archive(vg->cmd->mem, vg->name, dir))) { if (!(archives = _scan_archive(vg->cmd->mem, vg->name, dir))) {
log_err("Couldn't scan the archive directory (%s).", dir); stack;
return 0; return 0;
} }
@ -349,7 +349,7 @@ int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
struct archive_file *af; struct archive_file *af;
if (!(archives = _scan_archive(cmd->mem, vgname, dir))) { if (!(archives = _scan_archive(cmd->mem, vgname, dir))) {
log_err("Couldn't scan the archive directory (%s).", dir); stack;
return 0; return 0;
} }

View File

@ -36,9 +36,6 @@ int archive_init(const char *dir, unsigned int keep_days, unsigned int keep_min)
if (!*dir) if (!*dir)
return 1; return 1;
if (!create_dir(dir))
return 0;
if (!(_archive_params.dir = dbg_strdup(dir))) { if (!(_archive_params.dir = dbg_strdup(dir))) {
log_error("Couldn't copy archive directory name."); log_error("Couldn't copy archive directory name.");
return 0; return 0;
@ -106,6 +103,9 @@ int archive(struct volume_group *vg)
return 1; return 1;
} }
if (!create_dir(_archive_params.dir))
return 0;
log_verbose("Archiving volume group \"%s\" metadata.", vg->name); log_verbose("Archiving volume group \"%s\" metadata.", vg->name);
if (!__archive(vg)) { if (!__archive(vg)) {
log_error("Volume group \"%s\" metadata archive failed.", log_error("Volume group \"%s\" metadata archive failed.",
@ -134,9 +134,6 @@ int backup_init(const char *dir)
if (!*dir) if (!*dir)
return 1; return 1;
if (!create_dir(dir))
return 0;
if (!(_backup_params.dir = dbg_strdup(dir))) { if (!(_backup_params.dir = dbg_strdup(dir))) {
log_error("Couldn't copy backup directory name."); log_error("Couldn't copy backup directory name.");
return 0; return 0;
@ -189,6 +186,9 @@ int backup(struct volume_group *vg)
return 1; return 1;
} }
if (!create_dir(_backup_params.dir))
return 0;
if (!__backup(vg)) { if (!__backup(vg)) {
log_error("Backup of volume group %s metadata failed.", log_error("Backup of volume group %s metadata failed.",
vg->name); vg->name);