1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Merge branch 'master' of git+ssh://sourceware.org/git/lvm2

This commit is contained in:
Joe Thornber 2018-06-21 17:12:09 +01:00
commit 18528180d9
6 changed files with 13 additions and 98 deletions

View File

@ -1030,24 +1030,6 @@ static int _init_dev_cache(struct cmd_context *cmd)
}
}
if (!(cn = find_config_tree_array(cmd, devices_loopfiles_CFG, NULL)))
return 1;
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Invalid string in config file: "
"devices/loopfiles");
return 0;
}
if (!dev_cache_add_loopfile(cv->v.str)) {
log_error("Failed to add loopfile %s to internal "
"device cache", cv->v.str);
return 0;
}
}
return 1;
}

View File

@ -226,7 +226,7 @@ cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING,
cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL, 0, NULL,
"Directories containing device nodes to use with LVM.\n")
cfg_array(devices_loopfiles_CFG, "loopfiles", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 2, 0), NULL, 0, NULL, NULL)
cfg_array(devices_loopfiles_CFG, "loopfiles", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 2, 0), NULL, vsn(3, 0, 0), NULL, NULL)
cfg(devices_obtain_device_list_from_udev_CFG, "obtain_device_list_from_udev", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV, vsn(2, 2, 85), NULL, 0, NULL,
"Obtain the list of available devices from udev.\n"

View File

@ -690,18 +690,8 @@ static int _insert_dev(const char *path, dev_t d)
struct device *dev;
struct device *dev_by_devt;
struct device *dev_by_path;
static dev_t loopfile_count = 0;
int loopfile = 0;
char *path_copy;
/* Generate pretend device numbers for loopfiles */
if (!d) {
if (dm_hash_lookup(_cache.names, path))
return 1;
d = ++loopfile_count;
loopfile = 1;
}
dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) d);
dev_by_path = (struct device *) dm_hash_lookup(_cache.names, path);
dev = dev_by_devt;
@ -724,10 +714,7 @@ static int _insert_dev(const char *path, dev_t d)
if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) d))) {
/* create new device */
if (loopfile) {
if (!(dev = dev_create_file(path, NULL, NULL, 0)))
return_0;
} else if (!(dev = _dev_create(d)))
if (!(dev = _dev_create(d)))
return_0;
}
@ -742,7 +729,7 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
if (!loopfile && !_add_alias(dev, path_copy)) {
if (!_add_alias(dev, path_copy)) {
log_error("Couldn't add alias to dev cache.");
return 0;
}
@ -767,7 +754,7 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
if (!loopfile && !_add_alias(dev, path_copy)) {
if (!_add_alias(dev, path_copy)) {
log_error("Couldn't add alias to dev cache.");
return 0;
}
@ -791,10 +778,7 @@ static int _insert_dev(const char *path, dev_t d)
if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) d))) {
/* create new device */
if (loopfile) {
if (!(dev = dev_create_file(path, NULL, NULL, 0)))
return_0;
} else if (!(dev = _dev_create(d)))
if (!(dev = _dev_create(d)))
return_0;
}
@ -809,7 +793,7 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
if (!loopfile && !_add_alias(dev, path_copy)) {
if (!_add_alias(dev, path_copy)) {
log_error("Couldn't add alias to dev cache.");
return 0;
}
@ -839,7 +823,7 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
if (!loopfile && !_add_alias(dev, path_copy)) {
if (!_add_alias(dev, path_copy)) {
log_error("Couldn't add alias to dev cache.");
return 0;
}
@ -919,26 +903,6 @@ static int _insert_dir(const char *dir)
return r;
}
static int _insert_file(const char *path)
{
struct stat info;
if (stat(path, &info) < 0) {
log_sys_very_verbose("stat", path);
return 0;
}
if (!S_ISREG(info.st_mode)) {
log_debug_devs("%s: Not a regular file", path);
return 0;
}
if (!_insert_dev(path, 0))
return_0;
return 1;
}
static int _dev_cache_iterate_devs_for_index(void)
{
struct btree_iter *iter = btree_first(_cache.devices);
@ -1207,8 +1171,6 @@ static int _insert(const char *path, const struct stat *info,
void dev_cache_scan(void)
{
struct dir_list *dl;
log_debug_devs("Creating list of system devices.");
_cache.has_scanned = 1;
@ -1216,9 +1178,6 @@ void dev_cache_scan(void)
_insert_dirs(&_cache.dirs);
(void) dev_cache_index_devs();
dm_list_iterate_items(dl, &_cache.files)
_insert_file(dl->dir);
}
int dev_cache_has_scanned(void)
@ -1317,7 +1276,6 @@ int dev_cache_init(struct cmd_context *cmd)
}
dm_list_init(&_cache.dirs);
dm_list_init(&_cache.files);
if (!_init_preferred_names(cmd))
goto_bad;
@ -1411,32 +1369,6 @@ int dev_cache_add_dir(const char *path)
return 1;
}
int dev_cache_add_loopfile(const char *path)
{
struct dir_list *dl;
struct stat st;
if (stat(path, &st)) {
log_warn("Ignoring %s: %s.", path, strerror(errno));
/* But don't fail */
return 1;
}
if (!S_ISREG(st.st_mode)) {
log_warn("Ignoring %s: Not a regular file.", path);
return 1;
}
if (!(dl = _zalloc(sizeof(*dl) + strlen(path) + 1))) {
log_error("dir_list allocation failed for file");
return 0;
}
strcpy(dl->dir, path);
dm_list_add(&_cache.files, &dl->list);
return 1;
}
/* Check cached device name is still valid before returning it */
/* This should be a rare occurrence */
/* set quiet if the cache is expected to be out-of-date */

View File

@ -51,8 +51,6 @@ void dev_cache_scan(void);
int dev_cache_has_scanned(void);
int dev_cache_add_dir(const char *path);
int dev_cache_add_loopfile(const char *path);
__attribute__((nonnull(1)))
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
const char *dev_cache_filtered_reason(const char *name);

View File

@ -43,12 +43,15 @@ struct pfilter {
* do this.
*/
static int _good_device;
static int _bad_device;
/*
* The hash table holds one of these two states
* against each entry.
*/
#define PF_BAD_DEVICE ((void *) 1)
#define PF_GOOD_DEVICE ((void *) 2)
#define PF_BAD_DEVICE ((void *) &_good_device)
#define PF_GOOD_DEVICE ((void *) &_bad_device)
static int _init_hash(struct pfilter *pf)
{

View File

@ -698,7 +698,7 @@ static int _split_mirror_images(struct logical_volume *lv,
return 0;
}
if (!strcmp(lv->vg->lock_type, "dlm"))
if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "dlm"))
new_lv->lock_args = lv->lock_args;
if (!dm_list_empty(&split_images)) {