diff options
author | Joe Thornber <ejt@redhat.com> | 2018-06-21 17:54:16 +0100 |
---|---|---|
committer | Joe Thornber <ejt@redhat.com> | 2018-06-21 17:54:16 +0100 |
commit | c00bb876f50d45459efe09fe8b0c6cf0ec70063a (patch) | |
tree | 0aa99b5c34e8ad02a77ddf262f26e47ed73b3ed8 | |
parent | ec6f5ec22a1a8136d5c7b6b0bc28a148d9e08e9f (diff) | |
parent | 254e5c5d119447bcb8b160a4b4e5b0c36e9af5ba (diff) | |
download | lvm2-2018-05-30-bcache-radix-tree.tar.gz |
Merge branch 'master' into 2018-05-30-bcache-radix-tree2018-05-30-bcache-radix-tree
-rw-r--r-- | base/data-struct/radix-tree.c | 12 | ||||
-rw-r--r-- | lib/commands/toolcontext.c | 18 | ||||
-rw-r--r-- | lib/config/config_settings.h | 2 | ||||
-rw-r--r-- | lib/device/dev-cache.c | 80 | ||||
-rw-r--r-- | lib/device/dev-cache.h | 2 | ||||
-rw-r--r-- | lib/filters/filter-persistent.c | 7 | ||||
-rw-r--r-- | lib/metadata/mirror.c | 2 |
7 files changed, 19 insertions, 104 deletions
diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 202d463d2..1d24dadf2 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -626,6 +626,9 @@ static void _erase_elt(void *array, unsigned obj_size, unsigned count, unsigned memmove(((uint8_t *) array) + (obj_size * index), ((uint8_t *) array) + (obj_size * (index + 1)), obj_size * (count - index - 1)); + + // Zero the now unused last elt (set's v.type to UNSET) + memset(((uint8_t *) array) + (count - 1) * obj_size, 0, obj_size); } static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke) @@ -700,7 +703,6 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint } n4->nr_entries--; - n4->values[n4->nr_entries].type = UNSET; if (!n4->nr_entries) { free(n4); root->type = UNSET; @@ -723,7 +725,6 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint } n16->nr_entries--; - n16->values[n16->nr_entries].type = UNSET; if (n16->nr_entries <= 4) { _degrade_to_n4(n16, root); } @@ -745,7 +746,6 @@ static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint n48->keys[j]--; _erase_elt(n48->values, sizeof(*n48->values), n48->nr_entries, i); n48->nr_entries--; - n48->values[n48->nr_entries].type = UNSET; if (n48->nr_entries <= 16) _degrade_to_n16(n48, root); } @@ -1066,7 +1066,7 @@ static bool _check_nodes(struct value *v, unsigned *count) for (i = n4->nr_entries; i < 4; i++) if (n4->values[i].type != UNSET) { - fprintf(stderr, "unused value is not UNSET\n"); + fprintf(stderr, "unused value is not UNSET (n4)\n"); return false; } @@ -1080,7 +1080,7 @@ static bool _check_nodes(struct value *v, unsigned *count) for (i = n16->nr_entries; i < 16; i++) if (n16->values[i].type != UNSET) { - fprintf(stderr, "unused value is not UNSET\n"); + fprintf(stderr, "unused value is not UNSET (n16)\n"); return false; } @@ -1105,7 +1105,7 @@ static bool _check_nodes(struct value *v, unsigned *count) for (i = n48->nr_entries; i < 48; i++) if (n48->values[i].type != UNSET) { - fprintf(stderr, "unused value is not UNSET\n"); + fprintf(stderr, "unused value is not UNSET (n48)\n"); return false; } diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 50474c13a..eb1558171 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -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; } diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h index ac0f0ff5d..7cb266c79 100644 --- a/lib/config/config_settings.h +++ b/lib/config/config_settings.h @@ -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" diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index bd574f6ce..d7d6dd22a 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -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 */ diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 6386ba92f..41c4a9cc7 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -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); diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c index 1782bfa50..130b1e517 100644 --- a/lib/filters/filter-persistent.c +++ b/lib/filters/filter-persistent.c @@ -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) { diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c index 11f2a8f46..58615d854 100644 --- a/lib/metadata/mirror.c +++ b/lib/metadata/mirror.c @@ -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)) { |