mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add devices/preferred_names config regex list for displayed device names.
Free a temporary dir string in fcntl_lock_file() after use. Fix a dm_pool_destroy() in matcher_create(). Introduce goto_bad macro.
This commit is contained in:
parent
867c3249cb
commit
4f2f566b06
22
WHATS_NEW
22
WHATS_NEW
@ -1,15 +1,20 @@
|
|||||||
Version 2.02.25 -
|
Version 2.02.25 -
|
||||||
=================================
|
=================================
|
||||||
Fix warnings on x86_64 involving ptrdiff_t in log_error messages
|
Add devices/preferred_names config regex list for displayed device names.
|
||||||
Update pvck to include text metadata area and record detection
|
Free a temporary dir string in fcntl_lock_file() after use.
|
||||||
Add support functions for analysis of config sections
|
Fix a dm_pool_destroy() in matcher_create().
|
||||||
Update pvck to read labels on disk, with --labelsector parameter
|
Introduce goto_bad macro.
|
||||||
Add count_chars and count_chars_len functions
|
Fix warnings on x86_64 involving ptrdiff_t in log_error messages.
|
||||||
Add /sys/block listings to lvm_dump.sh
|
Update pvck to include text metadata area and record detection.
|
||||||
Make lvm_dump.sh list /dev recursively
|
Add support functions for token counting in config file extracts.
|
||||||
|
Update pvck to read labels on disk, with --labelsector parameter.
|
||||||
|
Add count_chars and count_chars_len functions.
|
||||||
|
Add /sys/block listings to lvm_dump.sh.
|
||||||
|
Make lvm_dump.sh list /dev recursively.
|
||||||
Fix thread race in clvmd.
|
Fix thread race in clvmd.
|
||||||
Add scan_sector param to label_read and _find_labeller.
|
Add scan_sector param to label_read and _find_labeller.
|
||||||
Make clvmd cope with quorum devices on RHEL5
|
Make clvmd cope with quorum devices.
|
||||||
|
Add extra internal error checking to clvmd.
|
||||||
Add dev_read_circular.
|
Add dev_read_circular.
|
||||||
Add pvck command stub.
|
Add pvck command stub.
|
||||||
Update lists of attribute characters in man pages.
|
Update lists of attribute characters in man pages.
|
||||||
@ -17,7 +22,6 @@ Version 2.02.25 -
|
|||||||
Fix creation and conversion of mirrors with tags.
|
Fix creation and conversion of mirrors with tags.
|
||||||
Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
|
Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
|
||||||
Split metadata areas in vgsplit properly.
|
Split metadata areas in vgsplit properly.
|
||||||
Add extra internal error checking to clvmd
|
|
||||||
|
|
||||||
Version 2.02.24 - 19th March 2007
|
Version 2.02.24 - 19th March 2007
|
||||||
=================================
|
=================================
|
||||||
|
@ -19,6 +19,14 @@ devices {
|
|||||||
# to use with LVM2.
|
# to use with LVM2.
|
||||||
scan = [ "/dev" ]
|
scan = [ "/dev" ]
|
||||||
|
|
||||||
|
# If several entries in the scanned directories correspond to the
|
||||||
|
# same block device and the tools need to display a name for device,
|
||||||
|
# all the pathnames are matched against each item in the following
|
||||||
|
# list of regular expressions in turn and the first match is used.
|
||||||
|
preferred_names = [ ]
|
||||||
|
|
||||||
|
# preferred_names = [ "^/dev/mpath/", "^/dev/[hs]d" ]
|
||||||
|
|
||||||
# A filter that tells LVM2 to only use a restricted set of devices.
|
# A filter that tells LVM2 to only use a restricted set of devices.
|
||||||
# The filter consists of an array of regular expressions. These
|
# The filter consists of an array of regular expressions. These
|
||||||
# expressions can be delimited by a character of your choice, and
|
# expressions can be delimited by a character of your choice, and
|
||||||
|
@ -435,10 +435,8 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dm = dm_pool_alloc(mem, sizeof(*dm)))) {
|
if (!(dm = dm_pool_alloc(mem, sizeof(*dm))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
dm->cmd = cmd;
|
dm->cmd = cmd;
|
||||||
dm->mem = mem;
|
dm->mem = mem;
|
||||||
@ -450,10 +448,8 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
|||||||
}
|
}
|
||||||
dm->stripe_filler = stripe_filler;
|
dm->stripe_filler = stripe_filler;
|
||||||
|
|
||||||
if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name))) {
|
if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
dm->target_state = NULL;
|
dm->target_state = NULL;
|
||||||
|
|
||||||
|
@ -465,10 +465,8 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
|||||||
const struct config_node *cn;
|
const struct config_node *cn;
|
||||||
struct config_value *cv;
|
struct config_value *cv;
|
||||||
|
|
||||||
if (!dev_cache_init()) {
|
if (!dev_cache_init(cmd))
|
||||||
stack;
|
return_0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
|
if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
|
||||||
if (!dev_cache_add_dir("/dev")) {
|
if (!dev_cache_add_dir("/dev")) {
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "filter-persistent.h"
|
#include "filter-persistent.h"
|
||||||
|
#include "matcher.h"
|
||||||
|
#include "toolcontext.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -38,6 +40,7 @@ static struct {
|
|||||||
struct dm_pool *mem;
|
struct dm_pool *mem;
|
||||||
struct dm_hash_table *names;
|
struct dm_hash_table *names;
|
||||||
struct btree *devices;
|
struct btree *devices;
|
||||||
|
struct matcher *preferred_names_matcher;
|
||||||
|
|
||||||
int has_scanned;
|
int has_scanned;
|
||||||
struct list dirs;
|
struct list dirs;
|
||||||
@ -129,15 +132,49 @@ static struct device *_dev_create(dev_t d)
|
|||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dev_set_preferred_name(struct str_list *sl, struct device *dev)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Don't interfere with ordering specified in config file.
|
||||||
|
*/
|
||||||
|
if (_cache.preferred_names_matcher)
|
||||||
|
return;
|
||||||
|
|
||||||
|
log_debug("%s: New preferred name", sl->str);
|
||||||
|
list_del(&sl->list);
|
||||||
|
list_add_h(&dev->aliases, &sl->list);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return 1 if we prefer path1 else return 0 */
|
/* Return 1 if we prefer path1 else return 0 */
|
||||||
static int _compare_paths(const char *path0, const char *path1)
|
static int _compare_paths(const char *path0, const char *path1)
|
||||||
{
|
{
|
||||||
int slash0 = 0, slash1 = 0;
|
int slash0 = 0, slash1 = 0;
|
||||||
|
int m0, m1;
|
||||||
const char *p;
|
const char *p;
|
||||||
char p0[PATH_MAX], p1[PATH_MAX];
|
char p0[PATH_MAX], p1[PATH_MAX];
|
||||||
char *s0, *s1;
|
char *s0, *s1;
|
||||||
struct stat stat0, stat1;
|
struct stat stat0, stat1;
|
||||||
|
|
||||||
|
if (_cache.preferred_names_matcher) {
|
||||||
|
m0 = matcher_run(_cache.preferred_names_matcher, path0);
|
||||||
|
m1 = matcher_run(_cache.preferred_names_matcher, path1);
|
||||||
|
|
||||||
|
if (m0 != m1) {
|
||||||
|
if (m0 < 0)
|
||||||
|
return 1;
|
||||||
|
if (m1 < 0)
|
||||||
|
return 0;
|
||||||
|
if (m0 < m1)
|
||||||
|
return 1;
|
||||||
|
if (m1 < m0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Built-in rules.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Return the path with fewer slashes */
|
/* Return the path with fewer slashes */
|
||||||
for (p = path0; p++; p = (const char *) strchr(p, '/'))
|
for (p = path0; p++; p = (const char *) strchr(p, '/'))
|
||||||
slash0++;
|
slash0++;
|
||||||
@ -441,7 +478,65 @@ void dev_cache_scan(int do_scan)
|
|||||||
_full_scan(1);
|
_full_scan(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dev_cache_init(void)
|
static int _init_preferred_names(struct cmd_context *cmd)
|
||||||
|
{
|
||||||
|
const struct config_node *cn;
|
||||||
|
struct config_value *v;
|
||||||
|
struct dm_pool *scratch = NULL;
|
||||||
|
char **regex;
|
||||||
|
unsigned count = 0;
|
||||||
|
int i, r = 0;
|
||||||
|
|
||||||
|
_cache.preferred_names_matcher = NULL;
|
||||||
|
|
||||||
|
if (!(cn = find_config_tree_node(cmd, "devices/preferred_names")) ||
|
||||||
|
cn->v->type == CFG_EMPTY_ARRAY) {
|
||||||
|
log_very_verbose("devices/preferred_names not found in config file: "
|
||||||
|
"using built-in preferences");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (v = cn->v; v; v = v->next) {
|
||||||
|
if (v->type != CFG_STRING) {
|
||||||
|
log_error("preferred_names patterns must be enclosed in quotes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(scratch = dm_pool_create("preferred device name matcher", 1024)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) {
|
||||||
|
log_error("Failed to allocate preferred device name "
|
||||||
|
"pattern list.");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (v = cn->v, i = count - 1; v; v = v->next, i--) {
|
||||||
|
if (!(regex[i] = dm_pool_strdup(scratch, v->v.str))) {
|
||||||
|
log_error("Failed to allocate a preferred device name "
|
||||||
|
"pattern.");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(_cache.preferred_names_matcher =
|
||||||
|
matcher_create(_cache.mem,(const char **) regex, count))) {
|
||||||
|
log_error("Preferred device name pattern matcher creation failed.");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = 1;
|
||||||
|
|
||||||
|
out:
|
||||||
|
dm_pool_destroy(scratch);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dev_cache_init(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
_cache.names = NULL;
|
_cache.names = NULL;
|
||||||
_cache.has_scanned = 0;
|
_cache.has_scanned = 0;
|
||||||
@ -466,6 +561,9 @@ int dev_cache_init(void)
|
|||||||
list_init(&_cache.dirs);
|
list_init(&_cache.dirs);
|
||||||
list_init(&_cache.files);
|
list_init(&_cache.files);
|
||||||
|
|
||||||
|
if (!_init_preferred_names(cmd))
|
||||||
|
goto_bad;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -489,6 +587,9 @@ void dev_cache_exit(void)
|
|||||||
if (_cache.names)
|
if (_cache.names)
|
||||||
_check_for_open_devices();
|
_check_for_open_devices();
|
||||||
|
|
||||||
|
if (_cache.preferred_names_matcher)
|
||||||
|
_cache.preferred_names_matcher = NULL;
|
||||||
|
|
||||||
if (_cache.mem) {
|
if (_cache.mem) {
|
||||||
dm_pool_destroy(_cache.mem);
|
dm_pool_destroy(_cache.mem);
|
||||||
_cache.mem = NULL;
|
_cache.mem = NULL;
|
||||||
|
@ -30,7 +30,8 @@ struct dev_filter {
|
|||||||
/*
|
/*
|
||||||
* The global device cache.
|
* The global device cache.
|
||||||
*/
|
*/
|
||||||
int dev_cache_init(void);
|
struct cmd_context;
|
||||||
|
int dev_cache_init(struct cmd_context *cmd);
|
||||||
void dev_cache_exit(void);
|
void dev_cache_exit(void);
|
||||||
|
|
||||||
/* Trigger(1) or avoid(0) a scan */
|
/* Trigger(1) or avoid(0) a scan */
|
||||||
@ -41,6 +42,8 @@ int dev_cache_add_dir(const char *path);
|
|||||||
int dev_cache_add_loopfile(const char *path);
|
int dev_cache_add_loopfile(const char *path);
|
||||||
struct device *dev_cache_get(const char *name, struct dev_filter *f);
|
struct device *dev_cache_get(const char *name, struct dev_filter *f);
|
||||||
|
|
||||||
|
void dev_set_preferred_name(struct str_list *sl, struct device *dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Object for iterating through the cache.
|
* Object for iterating through the cache.
|
||||||
*/
|
*/
|
||||||
|
@ -301,10 +301,9 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
|
|||||||
}
|
}
|
||||||
memset(pf, 0, sizeof(*pf));
|
memset(pf, 0, sizeof(*pf));
|
||||||
|
|
||||||
if (!(pf->file = dm_malloc(strlen(file) + 1))) {
|
if (!(pf->file = dm_malloc(strlen(file) + 1)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
strcpy(pf->file, file);
|
strcpy(pf->file, file);
|
||||||
pf->real = real;
|
pf->real = real;
|
||||||
|
|
||||||
@ -313,10 +312,8 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(f = dm_malloc(sizeof(*f)))) {
|
if (!(f = dm_malloc(sizeof(*f))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
f->passes_filter = _lookup_p;
|
f->passes_filter = _lookup_p;
|
||||||
f->destroy = _persistent_destroy;
|
f->destroy = _persistent_destroy;
|
||||||
|
@ -98,18 +98,15 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
|
|||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
int i, r = 0;
|
int i, r = 0;
|
||||||
|
|
||||||
if (!(scratch = dm_pool_create("filter matcher", 1024))) {
|
if (!(scratch = dm_pool_create("filter matcher", 1024)))
|
||||||
stack;
|
return_0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* count how many patterns we have.
|
* count how many patterns we have.
|
||||||
*/
|
*/
|
||||||
for (v = val; v; v = v->next) {
|
for (v = val; v; v = v->next) {
|
||||||
|
|
||||||
if (v->type != CFG_STRING) {
|
if (v->type != CFG_STRING) {
|
||||||
log_info("filter patterns must be enclosed in quotes");
|
log_error("filter patterns must be enclosed in quotes");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +116,8 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
|
|||||||
/*
|
/*
|
||||||
* allocate space for them
|
* allocate space for them
|
||||||
*/
|
*/
|
||||||
if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) {
|
if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count)))
|
||||||
stack;
|
goto_out;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create the accept/reject bitset
|
* create the accept/reject bitset
|
||||||
@ -136,7 +131,7 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
|
|||||||
*/
|
*/
|
||||||
for (v = val, i = count - 1; v; v = v->next, i--)
|
for (v = val, i = count - 1; v; v = v->next, i--)
|
||||||
if (!_extract_pattern(scratch, v->v.str, regex, rf->accept, i)) {
|
if (!_extract_pattern(scratch, v->v.str, regex, rf->accept, i)) {
|
||||||
log_info("invalid filter pattern");
|
log_error("invalid filter pattern");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,13 +159,8 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
|
|||||||
|
|
||||||
if (m >= 0) {
|
if (m >= 0) {
|
||||||
if (dm_bit(rf->accept, m)) {
|
if (dm_bit(rf->accept, m)) {
|
||||||
|
if (!first)
|
||||||
if (!first) {
|
dev_set_preferred_name(sl, dev);
|
||||||
log_debug("%s: New preferred name",
|
|
||||||
sl->str);
|
|
||||||
list_del(&sl->list);
|
|
||||||
list_add_h(&dev->aliases, &sl->list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -208,22 +198,16 @@ struct dev_filter *regex_filter_create(struct config_value *patterns)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rf = dm_pool_alloc(mem, sizeof(*rf)))) {
|
if (!(rf = dm_pool_alloc(mem, sizeof(*rf))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
rf->mem = mem;
|
rf->mem = mem;
|
||||||
|
|
||||||
if (!_build_matcher(rf, patterns)) {
|
if (!_build_matcher(rf, patterns))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(f = dm_pool_zalloc(mem, sizeof(*f)))) {
|
if (!(f = dm_pool_zalloc(mem, sizeof(*f))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
f->passes_filter = _accept_p;
|
f->passes_filter = _accept_p;
|
||||||
f->destroy = _regex_destroy;
|
f->destroy = _regex_destroy;
|
||||||
|
@ -284,10 +284,8 @@ struct dev_filter *sysfs_filter_create(const char *proc)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(f = dm_pool_zalloc(mem, sizeof(*f)))) {
|
if (!(f = dm_pool_zalloc(mem, sizeof(*f))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
f->passes_filter = _accept_p;
|
f->passes_filter = _accept_p;
|
||||||
f->destroy = _destroy;
|
f->destroy = _destroy;
|
||||||
|
@ -357,10 +357,8 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
|
|||||||
list_init(&dl->uuids);
|
list_init(&dl->uuids);
|
||||||
list_init(&dl->lvds);
|
list_init(&dl->lvds);
|
||||||
|
|
||||||
if (!_read_pvd(dev, &dl->pvd)) {
|
if (!_read_pvd(dev, &dl->pvd))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* is it an orphan ?
|
* is it an orphan ?
|
||||||
|
@ -131,10 +131,10 @@ static struct volume_group *_build_vg(struct format_instance *fid,
|
|||||||
int partial;
|
int partial;
|
||||||
|
|
||||||
if (!vg)
|
if (!vg)
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (list_empty(pvs))
|
if (list_empty(pvs))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
memset(vg, 0, sizeof(*vg));
|
memset(vg, 0, sizeof(*vg));
|
||||||
|
|
||||||
@ -146,24 +146,24 @@ static struct volume_group *_build_vg(struct format_instance *fid,
|
|||||||
list_init(&vg->tags);
|
list_init(&vg->tags);
|
||||||
|
|
||||||
if (!_check_vgs(pvs, &partial))
|
if (!_check_vgs(pvs, &partial))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
dl = list_item(pvs->n, struct disk_list);
|
dl = list_item(pvs->n, struct disk_list);
|
||||||
|
|
||||||
if (!import_vg(mem, vg, dl, partial))
|
if (!import_vg(mem, vg, dl, partial))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!import_pvs(fid->fmt, mem, vg, pvs, &vg->pvs, &vg->pv_count))
|
if (!import_pvs(fid->fmt, mem, vg, pvs, &vg->pvs, &vg->pv_count))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!import_lvs(mem, vg, pvs))
|
if (!import_lvs(mem, vg, pvs))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!import_extents(fid->fmt->cmd, vg, pvs))
|
if (!import_extents(fid->fmt->cmd, vg, pvs))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!import_snapshots(mem, vg, pvs))
|
if (!import_snapshots(mem, vg, pvs))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
return vg;
|
return vg;
|
||||||
|
|
||||||
@ -191,15 +191,11 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
|
|||||||
vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
|
vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
|
||||||
|
|
||||||
if (!read_pvs_in_vg
|
if (!read_pvs_in_vg
|
||||||
(fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs)) {
|
(fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(vg = _build_vg(fid, &pvs))) {
|
if (!(vg = _build_vg(fid, &pvs)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
dm_pool_destroy(mem);
|
dm_pool_destroy(mem);
|
||||||
@ -415,17 +411,14 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dl = dm_pool_alloc(mem, sizeof(*dl)))) {
|
if (!(dl = dm_pool_alloc(mem, sizeof(*dl))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
dl->mem = mem;
|
dl->mem = mem;
|
||||||
dl->dev = pv->dev;
|
dl->dev = pv->dev;
|
||||||
|
|
||||||
if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) {
|
if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* must be set to be able to zero gap after PV structure in
|
/* must be set to be able to zero gap after PV structure in
|
||||||
dev_write in order to make other disk tools happy */
|
dev_write in order to make other disk tools happy */
|
||||||
@ -434,10 +427,8 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
|
|||||||
dl->pvd.pe_on_disk.base = LVM1_PE_ALIGN << SECTOR_SHIFT;
|
dl->pvd.pe_on_disk.base = LVM1_PE_ALIGN << SECTOR_SHIFT;
|
||||||
|
|
||||||
list_add(&pvs, &dl->list);
|
list_add(&pvs, &dl->list);
|
||||||
if (!write_disks(fmt, &pvs)) {
|
if (!write_disks(fmt, &pvs))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
dm_pool_destroy(mem);
|
dm_pool_destroy(mem);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -59,22 +59,16 @@ static struct dm_hash_table *_create_lv_maps(struct dm_pool *mem,
|
|||||||
if (ll->lv->status & SNAPSHOT)
|
if (ll->lv->status & SNAPSHOT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(lvm = dm_pool_alloc(mem, sizeof(*lvm)))) {
|
if (!(lvm = dm_pool_alloc(mem, sizeof(*lvm))))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
lvm->lv = ll->lv;
|
lvm->lv = ll->lv;
|
||||||
if (!(lvm->map = dm_pool_zalloc(mem, sizeof(*lvm->map)
|
if (!(lvm->map = dm_pool_zalloc(mem, sizeof(*lvm->map)
|
||||||
* ll->lv->le_count))) {
|
* ll->lv->le_count)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_hash_insert(maps, ll->lv->name, lvm)) {
|
if (!dm_hash_insert(maps, ll->lv->name, lvm))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return maps;
|
return maps;
|
||||||
|
@ -660,15 +660,11 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
|||||||
/* eg Set to instance of fmt1 here if reading a format1 backup? */
|
/* eg Set to instance of fmt1 here if reading a format1 backup? */
|
||||||
vg->fid = fid;
|
vg->fid = fid;
|
||||||
|
|
||||||
if (!(vg->name = dm_pool_strdup(mem, vgn->key))) {
|
if (!(vg->name = dm_pool_strdup(mem, vgn->key)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN))) {
|
if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
vgn = vgn->child;
|
vgn = vgn->child;
|
||||||
|
|
||||||
|
@ -138,5 +138,6 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
|||||||
#define return_0 do { stack; return 0; } while (0)
|
#define return_0 do { stack; return 0; } while (0)
|
||||||
#define return_NULL do { stack; return NULL; } while (0)
|
#define return_NULL do { stack; return NULL; } while (0)
|
||||||
#define goto_out do { stack; goto out; } while (0)
|
#define goto_out do { stack; goto out; } while (0)
|
||||||
|
#define goto_bad do { stack; goto bad; } while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -280,10 +280,9 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
|||||||
vg->seqno = 0;
|
vg->seqno = 0;
|
||||||
|
|
||||||
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
|
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
|
||||||
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN))) {
|
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
*vg->system_id = '\0';
|
*vg->system_id = '\0';
|
||||||
|
|
||||||
vg->extent_size = extent_size;
|
vg->extent_size = extent_size;
|
||||||
@ -320,7 +319,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
|||||||
|
|
||||||
/* attach the pv's */
|
/* attach the pv's */
|
||||||
if (!vg_extend(vg->fid, vg, pv_count, pv_names))
|
if (!vg_extend(vg->fid, vg, pv_count, pv_names))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
return vg;
|
return vg;
|
||||||
|
|
||||||
@ -561,10 +560,8 @@ struct physical_volume *pv_create(const struct format_type *fmt,
|
|||||||
|
|
||||||
pv->dev = dev;
|
pv->dev = dev;
|
||||||
|
|
||||||
if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN))) {
|
if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN)))
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
pv->status = ALLOCATABLE_PV;
|
pv->status = ALLOCATABLE_PV;
|
||||||
|
|
||||||
|
@ -273,8 +273,12 @@ int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only)
|
|||||||
if ((c = strrchr(dir, '/')))
|
if ((c = strrchr(dir, '/')))
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
|
||||||
if (!create_dir(dir))
|
if (!create_dir(dir)) {
|
||||||
|
dm_free(dir);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dm_free(dir);
|
||||||
|
|
||||||
log_very_verbose("Locking %s (%s, %hd)", file,
|
log_very_verbose("Locking %s (%s, %hd)", file,
|
||||||
(lock_type == F_WRLCK) ? "F_WRLCK" : "F_RDLCK",
|
(lock_type == F_WRLCK) ? "F_WRLCK" : "F_RDLCK",
|
||||||
|
@ -273,15 +273,12 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
|||||||
struct dm_pool *scratch = dm_pool_create("regex matcher", 10 * 1024);
|
struct dm_pool *scratch = dm_pool_create("regex matcher", 10 * 1024);
|
||||||
struct matcher *m;
|
struct matcher *m;
|
||||||
|
|
||||||
if (!scratch) {
|
if (!scratch)
|
||||||
stack;
|
return_NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(m = dm_pool_alloc(mem, sizeof(*m)))) {
|
if (!(m = dm_pool_alloc(mem, sizeof(*m)))) {
|
||||||
stack;
|
|
||||||
dm_pool_destroy(scratch);
|
dm_pool_destroy(scratch);
|
||||||
return NULL;
|
return_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(m, 0, sizeof(*m));
|
memset(m, 0, sizeof(*m));
|
||||||
@ -292,10 +289,8 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
|||||||
|
|
||||||
ptr = all = dm_pool_alloc(scratch, len + 1);
|
ptr = all = dm_pool_alloc(scratch, len + 1);
|
||||||
|
|
||||||
if (!all) {
|
if (!all)
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
ptr += sprintf(ptr, "(.*(%s)%c)", patterns[i], TARGET_TRANS);
|
ptr += sprintf(ptr, "(.*(%s)%c)", patterns[i], TARGET_TRANS);
|
||||||
@ -314,10 +309,8 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
|||||||
m->num_nodes = _count_nodes(rx);
|
m->num_nodes = _count_nodes(rx);
|
||||||
m->nodes = dm_pool_alloc(scratch, sizeof(*m->nodes) * m->num_nodes);
|
m->nodes = dm_pool_alloc(scratch, sizeof(*m->nodes) * m->num_nodes);
|
||||||
|
|
||||||
if (!m->nodes) {
|
if (!m->nodes)
|
||||||
stack;
|
goto_bad;
|
||||||
goto bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fill_table(m, rx);
|
_fill_table(m, rx);
|
||||||
_create_bitsets(m);
|
_create_bitsets(m);
|
||||||
@ -330,7 +323,7 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
|||||||
|
|
||||||
bad:
|
bad:
|
||||||
dm_pool_destroy(scratch);
|
dm_pool_destroy(scratch);
|
||||||
dm_pool_destroy(mem);
|
dm_pool_free(mem, m);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,30 +827,30 @@ static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
* description for backups.
|
* description for backups.
|
||||||
*/
|
*/
|
||||||
if (!dm_pool_begin_object(cmd->mem, 128))
|
if (!dm_pool_begin_object(cmd->mem, 128))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
space = strchr(argv[i], ' ') ? 1 : 0;
|
space = strchr(argv[i], ' ') ? 1 : 0;
|
||||||
|
|
||||||
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
|
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!dm_pool_grow_object(cmd->mem, argv[i], strlen(argv[i])))
|
if (!dm_pool_grow_object(cmd->mem, argv[i], strlen(argv[i])))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
|
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
if (i < (argc - 1))
|
if (i < (argc - 1))
|
||||||
if (!dm_pool_grow_object(cmd->mem, " ", 1))
|
if (!dm_pool_grow_object(cmd->mem, " ", 1))
|
||||||
goto bad;
|
goto_bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminate.
|
* Terminate.
|
||||||
*/
|
*/
|
||||||
if (!dm_pool_grow_object(cmd->mem, "\0", 1))
|
if (!dm_pool_grow_object(cmd->mem, "\0", 1))
|
||||||
goto bad;
|
goto_bad;
|
||||||
|
|
||||||
return dm_pool_end_object(cmd->mem);
|
return dm_pool_end_object(cmd->mem);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user