From 64dd656ef7943f9991c83802dfa5f762c902e1fb Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 16 May 2018 15:27:52 +0100 Subject: [PATCH 01/81] scripts: add a little scripts to show git history for the last 2 weeks. --- scripts/code-stats.rb | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 scripts/code-stats.rb diff --git a/scripts/code-stats.rb b/scripts/code-stats.rb new file mode 100755 index 000000000..e87de26a9 --- /dev/null +++ b/scripts/code-stats.rb @@ -0,0 +1,80 @@ +#! /usr/bin/env ruby + +require 'date' +require 'pp' + +REGEX = /(\w+)\s+'(.+)'\s+(.*)/ + +Commit = Struct.new(:hash, :time, :author, :stats) +CommitStats = Struct.new(:nr_files, :nr_added, :nr_deleted) + +def calc_stats(diff) + changed = 0 + added = 0 + deleted = 0 + + diff.lines.each do |l| + case l + when /^\+\+\+/ + changed = changed + 1 + when /^\+/ + added = added + 1 + when /^---/ + # do nothing + when /^\-/ + deleted = deleted + 1 + end + end + + CommitStats.new(changed, added, deleted) +end + +def select_commits(&block) + commits = [] + + input = `git log --format="%h '%aI' %an"` + input.lines.each do |l| + m = REGEX.match(l) + + raise "couldn't parse: ${l}" unless m + + hash = m[1] + time = DateTime.iso8601(m[2]) + author = m[3] + + if block.call(hash, time, author) + diff = `git log -1 -p #{hash} | filterdiff -X configure` + commits << Commit.new(hash, time, author, calc_stats(diff)) + end + end + + commits +end + +def since(date) + lambda do |hash, time, author| + time >= date + end +end + +def pad(str, col) + str + (' ' * (col - str.size)) +end + +#----------------------------------- + +commits = select_commits(&since(DateTime.now - 14)) + +authors = Hash.new {|hash, key| hash[key] = CommitStats.new(0, 0, 0)} + +commits.each do |c| + author_stats = authors[c.author] + author_stats.nr_files = author_stats.nr_files + c.stats.nr_files + author_stats.nr_added = author_stats.nr_added + c.stats.nr_added + author_stats.nr_deleted = author_stats.nr_deleted + c.stats.nr_deleted +end + +puts "#{pad("Author", 20)}\tChanged files\tInsertions\tDeletions" +authors.each_pair do |k, v| + puts "#{pad(k, 20)}\t#{v.nr_files}\t\t#{v.nr_added}\t\t#{v.nr_deleted}" +end From 28d35e5c590a01a196ce5a9a1239921921519809 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 16 May 2018 13:24:00 -0500 Subject: [PATCH 02/81] scan: fix missing close in lib lib was using dev_test_excl which wasn't closing the device. Switch code to new io layer with excl open. Also use exclusive open in some other places. --- lib/label/label.c | 8 +++++++- lib/label/label.h | 1 + lib/metadata/metadata-liblvm.c | 13 +------------ lib/metadata/metadata.c | 2 +- tools/toollib.c | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/label/label.c b/lib/label/label.c index 40537d130..b9227f54f 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -114,7 +114,7 @@ int label_remove(struct device *dev) log_very_verbose("Scanning for labels to wipe from %s", dev_name(dev)); - if (!label_scan_open(dev)) { + if (!label_scan_open_excl(dev)) { log_error("Failed to open device %s", dev_name(dev)); return 0; } @@ -977,6 +977,12 @@ int label_scan_open(struct device *dev) return 1; } +int label_scan_open_excl(struct device *dev) +{ + dev->flags |= DEV_BCACHE_EXCL; + return label_scan_open(dev); +} + bool dev_read_bytes(struct device *dev, uint64_t start, size_t len, void *data) { if (!scan_bcache) { diff --git a/lib/label/label.h b/lib/label/label.h index 0ef1d8369..3d8882f2e 100644 --- a/lib/label/label.h +++ b/lib/label/label.h @@ -114,6 +114,7 @@ int label_read_sector(struct device *dev, uint64_t scan_sector); void label_scan_confirm(struct device *dev); int label_scan_setup_bcache(void); int label_scan_open(struct device *dev); +int label_scan_open_excl(struct device *dev); /* * Wrappers around bcache equivalents. diff --git a/lib/metadata/metadata-liblvm.c b/lib/metadata/metadata-liblvm.c index df4fdd969..ffd07a53a 100644 --- a/lib/metadata/metadata-liblvm.c +++ b/lib/metadata/metadata-liblvm.c @@ -227,13 +227,12 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name, /* * This test will fail if the device belongs to an MD array. */ - if (!dev_test_excl(dev)) { + if (!label_scan_open_excl(dev)) { /* FIXME Detect whether device-mapper itself is still using it */ log_error("Can't open %s exclusively. Mounted filesystem?", name); goto out; } - dev_close(dev); if (!wipe_known_signatures(cmd, dev, name, TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER, @@ -578,16 +577,6 @@ static int _pvremove_single(struct cmd_context *cmd, const char *pv_name, goto out; } - // FIXME: why is this called if info is not used? - //info = lvmcache_info_from_pvid(dev->pvid, dev, 0); - - if (!dev_test_excl(dev)) { - /* FIXME Detect whether device-mapper is still using the device */ - log_error("Can't open %s exclusively - not removing. " - "Mounted filesystem?", dev_name(dev)); - goto out; - } - /* Wipe existing label(s) */ if (!label_remove(dev)) { log_error("Failed to wipe existing label(s) on %s", pv_name); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 163602663..1cbaf958e 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1413,7 +1413,7 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw) struct device *dev = pv->dev; const char *pv_name = dev_name(dev); - if (!label_scan_open(dev)) { + if (!label_scan_open_excl(dev)) { log_error("%s not opened: device not written", pv_name); return 0; } diff --git a/tools/toollib.c b/tools/toollib.c index afd80608a..0fc86cff5 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -5785,7 +5785,7 @@ do_command: pv_name = pd->name; - label_scan_open(pd->dev); + label_scan_open_excl(pd->dev); log_debug("Creating a new PV on %s.", pv_name); From 8c453e2e5e5a660b1923629365c8bb87ef017a8f Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Wed, 16 May 2018 17:53:38 -0400 Subject: [PATCH 03/81] cleanup: fix grammar in output - less then -> less than This minor patch fixes grammar in a few messages which get printed to users. It also fixes the same grammar mistake in several comments. Signed-off-by: Rick Elrod -- --- lib/metadata/cache_manip.c | 4 ++-- lib/metadata/metadata.c | 2 +- lib/metadata/thin_manip.c | 2 +- test/shell/lvconvert-repair-mirror.sh | 2 +- test/shell/lvextend-thin-metadata-dmeventd.sh | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index 2a54682e7..3ed8ce8b7 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -184,7 +184,7 @@ int update_cache_pool_params(struct cmd_context *cmd, * keep user informed he might be using things in untintended direction */ log_print_unless_silent("Using %s chunk size instead of default %s, " - "so cache pool has less then " FMTu64 " chunks.", + "so cache pool has less than " FMTu64 " chunks.", display_size(cmd, min_chunk_size), display_size(cmd, *chunk_size), max_chunks); @@ -193,7 +193,7 @@ int update_cache_pool_params(struct cmd_context *cmd, log_verbose("Setting chunk size to %s.", display_size(cmd, *chunk_size)); } else if (*chunk_size < min_chunk_size) { - log_error("Chunk size %s is less then required minimal chunk size %s " + log_error("Chunk size %s is less than required minimal chunk size %s " "for a cache pool of %s size and limit " FMTu64 " chunks.", display_size(cmd, *chunk_size), display_size(cmd, min_chunk_size), diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 1cbaf958e..260984056 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1050,7 +1050,7 @@ uint32_t extents_from_size(struct cmd_context *cmd, uint64_t size, if (size > (uint64_t) MAX_EXTENT_COUNT * extent_size) { log_error("Volume too large (%s) for extent size %s. " - "Upper limit is less then %s.", + "Upper limit is less than %s.", display_size(cmd, size), display_size(cmd, (uint64_t) extent_size), display_size(cmd, (uint64_t) MAX_EXTENT_COUNT * diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c index 3dfbcc11f..d2d1384bf 100644 --- a/lib/metadata/thin_manip.c +++ b/lib/metadata/thin_manip.c @@ -228,7 +228,7 @@ int pool_metadata_min_threshold(const struct lv_segment *pool_seg) * * In the metadata LV there should be minimum from either 4MiB of free space * or at least 25% of free space, which applies when the size of thin pool's - * metadata is less then 16MiB. + * metadata is less than 16MiB. */ const dm_percent_t meta_min = DM_PERCENT_1 * 25; dm_percent_t meta_free = dm_make_percent(((4096 * 1024) >> SECTOR_SHIFT), diff --git a/test/shell/lvconvert-repair-mirror.sh b/test/shell/lvconvert-repair-mirror.sh index 02772213c..b0c199df0 100644 --- a/test/shell/lvconvert-repair-mirror.sh +++ b/test/shell/lvconvert-repair-mirror.sh @@ -54,7 +54,7 @@ dd if=/dev/zero of=mnt/zero bs=4K count=100 conv=fdatasync 2>err & PERCENT=$(get lv_field $vg/$lv1 copy_percent) PERCENT=${PERCENT%%\.*} # cut decimal -# and check less then 50% mirror is in sync (could be unusable delay_dev ?) +# and check less than 50% mirror is in sync (could be unusable delay_dev ?) test "$PERCENT" -lt 50 || skip #lvs -a -o+devices $vg diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh index 212df4b38..3731bf6bf 100644 --- a/test/shell/lvextend-thin-metadata-dmeventd.sh +++ b/test/shell/lvextend-thin-metadata-dmeventd.sh @@ -75,7 +75,7 @@ lvcreate -L32M -n $lv3 $vg lvchange -an $vg/thin $vg/thin2 $vg/pool # Filling 2M metadata volume -# (Test for less then 25% free space in metadata) +# (Test for less than 25% free space in metadata) fake_metadata_ 400 2 >data "$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1" @@ -89,7 +89,7 @@ fail lvcreate -V20 $vg/pool lvchange -an $vg/pool # Consume more then (100% - 4MiB) out of 32MiB metadata volume (>87.5%) -# (Test for less then 4MiB free space in metadata, which is less then 25%) +# (Test for less than 4MiB free space in metadata, which is less than 25%) fake_metadata_ 7400 2 >data "$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv2" # Swap volume with restored fake metadata From c6ca81a38d7012ec9d18a9ea00eff321ff2c47d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Wed, 16 May 2018 21:19:03 +0100 Subject: [PATCH 04/81] bcache: don't use PAGE_SIZE compile const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PAGE_SIZE is not a compile time constant. Use sysconf instead like elsewhere in the code. Signed-off-by: Alex Bennée --- lib/device/bcache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/device/bcache.c b/lib/device/bcache.c index 30df54a90..3f5a45e54 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -162,8 +162,9 @@ static bool _async_issue(struct io_engine *ioe, enum dir d, int fd, struct iocb *cb_array[1]; struct control_block *cb; struct async_engine *e = _to_async(ioe); + long pgsize = sysconf(_SC_PAGESIZE); - if (((uintptr_t) data) & (PAGE_SIZE - 1)) { + if (((uintptr_t) data) & (pgsize - 1)) { log_warn("misaligned data buffer"); return false; } @@ -547,8 +548,9 @@ static bool _init_free_list(struct bcache *cache, unsigned count) { unsigned i; size_t block_size = cache->block_sectors << SECTOR_SHIFT; + long pgsize = sysconf(_SC_PAGESIZE); unsigned char *data = - (unsigned char *) _alloc_aligned(count * block_size, PAGE_SIZE); + (unsigned char *) _alloc_aligned(count * block_size, pgsize); /* Allocate the data for each block. We page align the data. */ if (!data) @@ -899,6 +901,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, { struct bcache *cache; unsigned max_io = engine->max_io(engine); + long pgsize = sysconf(_SC_PAGESIZE); if (!nr_cache_blocks) { log_warn("bcache must have at least one cache block"); @@ -910,7 +913,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, return NULL; } - if (block_sectors & ((PAGE_SIZE >> SECTOR_SHIFT) - 1)) { + if (block_sectors & ((pgsize >> SECTOR_SHIFT) - 1)) { log_warn("bcache block size must be a multiple of page size"); return NULL; } From 3417d6229dcdcb2e1c9595026a8f97d10f25804a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 17 May 2018 09:52:13 +0100 Subject: [PATCH 05/81] scripts/code-stats.rb: count files better, handle bad utf8 --- scripts/code-stats.rb | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/code-stats.rb b/scripts/code-stats.rb index e87de26a9..d73343be9 100755 --- a/scripts/code-stats.rb +++ b/scripts/code-stats.rb @@ -2,21 +2,22 @@ require 'date' require 'pp' +require 'set' REGEX = /(\w+)\s+'(.+)'\s+(.*)/ Commit = Struct.new(:hash, :time, :author, :stats) -CommitStats = Struct.new(:nr_files, :nr_added, :nr_deleted) +CommitStats = Struct.new(:files, :nr_added, :nr_deleted) def calc_stats(diff) - changed = 0 + changed = Set.new added = 0 deleted = 0 diff.lines.each do |l| - case l - when /^\+\+\+/ - changed = changed + 1 + case l.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') + when /^\+\+\+ (\S+)/ + changed << $1 when /^\+/ added = added + 1 when /^---/ @@ -61,20 +62,29 @@ def pad(str, col) str + (' ' * (col - str.size)) end +def code_delta(s) + s.nr_added + s.nr_deleted +end + +def cmp_stats(lhs, rhs) + code_delta(rhs) <=> code_delta(lhs) +end + #----------------------------------- commits = select_commits(&since(DateTime.now - 14)) -authors = Hash.new {|hash, key| hash[key] = CommitStats.new(0, 0, 0)} +authors = Hash.new {|hash, key| hash[key] = CommitStats.new(Set.new, 0, 0)} commits.each do |c| author_stats = authors[c.author] - author_stats.nr_files = author_stats.nr_files + c.stats.nr_files + author_stats.files.merge(c.stats.files) author_stats.nr_added = author_stats.nr_added + c.stats.nr_added author_stats.nr_deleted = author_stats.nr_deleted + c.stats.nr_deleted end puts "#{pad("Author", 20)}\tChanged files\tInsertions\tDeletions" -authors.each_pair do |k, v| - puts "#{pad(k, 20)}\t#{v.nr_files}\t\t#{v.nr_added}\t\t#{v.nr_deleted}" +authors.keys.sort {|a1, a2| cmp_stats(authors[a1], authors[a2])}.each do |k| + v = authors[k] + puts "#{pad(k, 20)}\t#{v.files.size}\t\t#{v.nr_added}\t\t#{v.nr_deleted}" end From 5052970da3bdf3ef702fa0f54a25cc2a44d0829e Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 17 May 2018 10:05:10 +0100 Subject: [PATCH 06/81] bcache: Don't call sysconf for every io --- lib/device/bcache.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/device/bcache.c b/lib/device/bcache.c index 3f5a45e54..9e94fccf5 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -133,6 +133,7 @@ struct async_engine { struct io_engine e; io_context_t aio_context; struct cb_set *cbs; + unsigned page_mask; }; static struct async_engine *_to_async(struct io_engine *e) @@ -162,9 +163,8 @@ static bool _async_issue(struct io_engine *ioe, enum dir d, int fd, struct iocb *cb_array[1]; struct control_block *cb; struct async_engine *e = _to_async(ioe); - long pgsize = sysconf(_SC_PAGESIZE); - if (((uintptr_t) data) & (pgsize - 1)) { + if (((uintptr_t) data) & e->page_mask) { log_warn("misaligned data buffer"); return false; } @@ -276,6 +276,8 @@ struct io_engine *create_async_io_engine(void) return NULL; } + e->page_mask = sysconf(_SC_PAGESIZE) - 1; + return &e->e; } @@ -544,11 +546,10 @@ static void _hash_table_exit(struct bcache *cache) //---------------------------------------------------------------- -static bool _init_free_list(struct bcache *cache, unsigned count) +static bool _init_free_list(struct bcache *cache, unsigned count, unsigned pgsize) { unsigned i; size_t block_size = cache->block_sectors << SECTOR_SHIFT; - long pgsize = sysconf(_SC_PAGESIZE); unsigned char *data = (unsigned char *) _alloc_aligned(count * block_size, pgsize); @@ -949,7 +950,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, cache->write_misses = 0; cache->prefetches = 0; - if (!_init_free_list(cache, nr_cache_blocks)) { + if (!_init_free_list(cache, nr_cache_blocks, pgsize)) { cache->engine->destroy(cache->engine); _hash_table_exit(cache); dm_free(cache); From a39eaea27dcd2fd895740193e82ca6d0683eb3ad Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Thu, 17 May 2018 14:40:17 +0200 Subject: [PATCH 07/81] tests: fix kernal_at_least argument in aux.sh --- test/lib/aux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 5b2aebff5..f6206cedd 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -843,7 +843,7 @@ prepare_backing_dev() { return 0 elif test "${LVM_TEST_PREFER_BRD-1}" = "1" && \ test ! -d /sys/block/ram0 && \ - kernel_at_least 4 16 && \ + kernel_at_least 4 16 0 && \ test "$size" -lt 16384; then # try to use ramdisk if possible, but for # big allocs (>16G) do not try to use ramdisk From 286c9c78b49f3b52bb05cef93659bb91e4249dc9 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 17 May 2018 15:18:11 -0500 Subject: [PATCH 08/81] liblvm2app: fix valgrind memory warning --- lib/metadata/metadata.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 260984056..2f84d5fc0 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -4830,7 +4830,7 @@ static int _get_pvs(struct cmd_context *cmd, uint32_t warn_flags, struct dm_list *pvslist, struct dm_list *vgslist) { struct dm_str_list *strl; - const char *vgname, *vgid; + const char *vgname, *name, *vgid; struct pv_list *pvl, *pvl_copy; struct dm_list *vgids; struct volume_group *vg; @@ -4856,11 +4856,13 @@ static int _get_pvs(struct cmd_context *cmd, uint32_t warn_flags, if (!vgid) continue; /* FIXME Unnecessary? */ consistent = 0; - if (!(vgname = lvmcache_vgname_from_vgid(NULL, vgid))) { + if (!(name = lvmcache_vgname_from_vgid(NULL, vgid))) { stack; continue; } + vgname = dm_pool_strdup(cmd->mem, name); + /* * When we are retrieving a list to return toliblvm we need * that list to contain VGs that are modifiable as we are using From f7435cd8c7bf4c245c9efabbae1274989d2e49ed Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 17 May 2018 15:55:44 -0500 Subject: [PATCH 09/81] liblvm2app: add a couple tests trivial sanity-check programs using liblvm2app --- liblvm/test/vgadd.c | 90 +++++++++++++++++++++++++++++++++++++++++ liblvm/test/vgshow.c | 95 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 liblvm/test/vgadd.c create mode 100644 liblvm/test/vgshow.c diff --git a/liblvm/test/vgadd.c b/liblvm/test/vgadd.c new file mode 100644 index 000000000..c96baa7e9 --- /dev/null +++ b/liblvm/test/vgadd.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include "lvm2app.h" + +int main(int argc, char *argv[]) +{ + char *vgname = NULL; + lvm_t handle; + vg_t vg; + lv_t lv; + lvm_str_list_t *sl; + pv_list_t *pvl; + lv_list_t *lvl; + struct dm_list *vgnames; + struct dm_list *vgids; + struct dm_list *pvlist; + struct dm_list *lvlist; + int added = 0; + int ret; + int i; + + vgname = argv[1]; + + handle = lvm_init(NULL); + if (!handle) { + printf("lvm_init failed\n"); + return -1; + } + + vg = lvm_vg_create(handle, vgname); + + for (i = 2; i < argc; i++) { + printf("adding %s to vg\n", argv[i]); + ret = lvm_vg_extend(vg, argv[i]); + + if (ret) { + printf("Failed to add %s to vg\n", argv[i]); + goto out; + } + + added++; + } + + if (!added) { + printf("No PVs added, not writing VG.\n"); + goto out; + } + + printf("writing vg\n"); + ret = lvm_vg_write(vg); + + lvm_vg_close(vg); + + sleep(1); + + vg = lvm_vg_open(handle, vgname, "w", 0); + if (!vg) { + printf("vg open %s failed\n", vgname); + goto out; + } + + lv = lvm_vg_create_lv_linear(vg, "lv0", 1024*1024); + if (!lv) { + printf("lv create failed\n"); + goto out; + } + + lvm_vg_close(vg); +out: + lvm_quit(handle); + + return 0; +} diff --git a/liblvm/test/vgshow.c b/liblvm/test/vgshow.c new file mode 100644 index 000000000..519f3dd49 --- /dev/null +++ b/liblvm/test/vgshow.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include "lvm2app.h" + +int main(int argc, char *argv[]) +{ + char *vgname = NULL; + lvm_t handle; + vg_t vg; + lvm_str_list_t *sl; + pv_list_t *pvl; + lv_list_t *lvl; + struct dm_list *vgnames; + struct dm_list *vgids; + struct dm_list *pvlist; + struct dm_list *lvlist; + uint64_t val; + + vgname = argv[1]; + + handle = lvm_init(NULL); + if (!handle) { + printf("lvm_init failed\n"); + return -1; + } + + vgnames = lvm_list_vg_names(handle); + + dm_list_iterate_items(sl, vgnames) + printf("vg name %s\n", sl->str); + + vgids = lvm_list_vg_uuids(handle); + + dm_list_iterate_items(sl, vgids) + printf("vg uuid %s\n", sl->str); + + if (!vgname) { + printf("No vg name arg\n"); + goto out; + } + + vg = lvm_vg_open(handle, vgname, "r", 0); + + if (!vg) { + printf("vg open %s failed\n", vgname); + goto out; + } + + val = lvm_vg_get_seqno(vg); + + printf("vg seqno %llu\n", (unsigned long long)val); + + pvlist = lvm_vg_list_pvs(vg); + + dm_list_iterate_items(pvl, pvlist) { + printf("vg pv name %s\n", lvm_pv_get_name(pvl->pv)); + + val = lvm_pv_get_dev_size(pvl->pv); + + printf("vg pv size %llu\n", (unsigned long long)val); + } + + lvlist = lvm_vg_list_lvs(vg); + + dm_list_iterate_items(lvl, lvlist) { + printf("vg lv name %s\n", lvm_lv_get_name(lvl->lv)); + + val = lvm_lv_get_size(lvl->lv); + + printf("vg lv size %llu\n", (unsigned long long)val); + } + + lvm_vg_close(vg); +out: + lvm_quit(handle); + + return 0; +} From 5b86b0e3dca804fce7c3e6adcd636c0a6d341a9b Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 18 May 2018 16:15:25 +0200 Subject: [PATCH 10/81] build: set clean vars earlier For better cleaning of test dirs. --- daemons/lvmdbusd/Makefile.in | 2 ++ test/Makefile.in | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/daemons/lvmdbusd/Makefile.in b/daemons/lvmdbusd/Makefile.in index 7cd7724de..7b62e7ea7 100644 --- a/daemons/lvmdbusd/Makefile.in +++ b/daemons/lvmdbusd/Makefile.in @@ -44,6 +44,8 @@ LVMDBUS_BUILDDIR_FILES = \ LVMDBUSD = lvmdbusd +CLEAN_DIRS += __pycache__ + include $(top_builddir)/make.tmpl .PHONY: install_lvmdbusd diff --git a/test/Makefile.in b/test/Makefile.in index 407babd02..f6345a54c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -32,6 +32,18 @@ SOURCES = lib/not.c lib/harness.c CXXSOURCES = lib/runner.cpp CXXFLAGS += $(EXTRA_EXEC_CFLAGS) +CLEAN_DIRS += dbus/__pycache__ $(LVM_TEST_RESULTS) +ifneq (.,$(firstword $(srcdir))) +CLEAN_TARGETS += $(RUN_BASE) $(addprefix lib/,$(LIB_LVMLOCKD_CONF)) +endif + +CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,\ + $(CMDS) clvmd dmeventd dmsetup dmstats lvmetad lvmpolld \ + harness lvmdbusd.profile thin-performance.profile fsadm \ + dm-version-expected version-expected \ + paths-installed paths-installed-t paths-common paths-common-t) + + include $(top_builddir)/make.tmpl T ?= . @@ -352,17 +364,6 @@ LIB = $(addprefix lib/, $(LIB_SHARED) $(LIB_LOCAL) $(LIB_NOT) $(LIB_LINK_NOT) $( $(LN_S) -f $(abs_top_srcdir)/test/lib/$$i lib/; done touch $@ -CLEAN_DIRS += $(LVM_TEST_RESULTS) -ifneq (.,$(firstword $(srcdir))) -CLEAN_TARGETS += $(RUN_BASE) $(addprefix lib/,$(LIB_LVMLOCKD_CONF)) -endif - -CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,\ - $(CMDS) clvmd dmeventd dmsetup dmstats lvmetad lvmpolld \ - harness lvmdbusd.profile thin-performance.profile fsadm \ - dm-version-expected version-expected \ - paths-installed paths-installed-t paths-common paths-common-t) - Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ From 43fb32e761a2c4d1ebaec5eff9d9f0f372563cf9 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 17 May 2018 23:03:36 +0200 Subject: [PATCH 11/81] python: use python3 paths directly Do not use /usr/bin/env for path of python3 as this is seen as 'unwanted' and should be avoided. --- test/dbus/lvmdbustest.py | 2 +- test/dbus/testlib.py | 2 +- test/dbus/validatestate.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py index 0914b7a52..bab998610 100755 --- a/test/dbus/lvmdbustest.py +++ b/test/dbus/lvmdbustest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 # Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved. # diff --git a/test/dbus/testlib.py b/test/dbus/testlib.py index 34ff33aab..08f612cde 100644 --- a/test/dbus/testlib.py +++ b/test/dbus/testlib.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 # Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved. # diff --git a/test/dbus/validatestate.py b/test/dbus/validatestate.py index faa2083ac..ae999ad17 100755 --- a/test/dbus/validatestate.py +++ b/test/dbus/validatestate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 # Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved. # From fbf64fe730ffa27ee94867017742174f270d3fa0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 18 May 2018 16:16:09 +0200 Subject: [PATCH 12/81] tests; make sure python_lvm_unit.py is executable --- test/api/Makefile.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/api/Makefile.in b/test/api/Makefile.in index e953675a0..1659b872c 100644 --- a/test/api/Makefile.in +++ b/test/api/Makefile.in @@ -38,6 +38,8 @@ SOURCES2 = \ endif +PYTEST = python_lvm_unit.py + include $(top_builddir)/make.tmpl DEFS += -D_REENTRANT @@ -48,6 +50,9 @@ LIBS += @LVM2APP_LIB@ $(DMEVENT_LIBS) -ldevmapper %.t: %.o $(DEPLIBS) $(CC) -o $@ $(<) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS) +all: + test -x $(PYTEST) || chmod 755 $(PYTEST) + test: $(OBJECTS) $(DEPLIBS) $(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS) $(READLINE_LIBS) From 3bbdde808a9dcb55a9ffd092e931dff80814daa7 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 18 May 2018 16:16:40 +0200 Subject: [PATCH 13/81] tests: pick either python2 or python3 .so Use matching PYTHON library implementation. --- test/api/pytest.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/api/pytest.sh b/test/api/pytest.sh index bf31b39ca..ed9df5e70 100644 --- a/test/api/pytest.sh +++ b/test/api/pytest.sh @@ -31,7 +31,11 @@ aux prepare_dmeventd #Locate the python binding library to use. if [[ -n "${abs_top_builddir+varset}" ]]; then - python_lib=($(find "$abs_top_builddir" -name lvm*.so)) + # For python2 look for lvm.so, python3 uses some lengthy names + case "$(head -1 $(which python_lvm_unit.py) )" in + *2) python_lib=($(find "$abs_top_builddir" -name lvm.so)) ;; + *) python_lib=($(find "$abs_top_builddir" -name lvm*gnu.so)) ;; + esac if [[ ${#python_lib[*]} -ne 1 ]]; then if [[ ${#python_lib[*]} -gt 1 ]]; then # Unable to test python bindings if multiple libraries found: @@ -58,9 +62,9 @@ aux prepare_pvs 6 PY_UNIT_PVS=$(cat DEVICES) export PY_UNIT_PVS -python_lvm_unit.py -v -f TestLvm.test_lv_persistence -exit -#python_lvm_unit.py -v -f +#When needed to run 1 single individual python test +#python_lvm_unit.py -v -f TestLvm.test_lv_persistence +#exit # Run individual tests for shorter error trace for i in \ From b2574c2f3a4a35b7ea3f51dc776cc64ebbe88ba8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 18 May 2018 16:23:10 +0200 Subject: [PATCH 14/81] python: use // for integer division --- daemons/lvmdbusd/lv.py | 2 +- test/api/python_lvm_unit.py.in | 10 +++++----- test/dbus/lvmdbustest.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py index d73d3d2f7..ba9499f64 100644 --- a/daemons/lvmdbusd/lv.py +++ b/daemons/lvmdbusd/lv.py @@ -497,7 +497,7 @@ class Lv(LvCommon): # it is a thin lv if not dbo.IsThinVolume: if optional_size == 0: - space = dbo.SizeBytes / 80 + space = dbo.SizeBytes // 80 remainder = space % 512 optional_size = space + 512 - remainder diff --git a/test/api/python_lvm_unit.py.in b/test/api/python_lvm_unit.py.in index 2f9cbb515..78ced7e31 100755 --- a/test/api/python_lvm_unit.py.in +++ b/test/api/python_lvm_unit.py.in @@ -112,7 +112,7 @@ class TestLvm(unittest.TestCase): for d in device_list: vg.extend(d) - vg.createLvLinear(name, vg.getSize() / 2) + vg.createLvLinear(name, vg.getSize() // 2) vg.close() vg = None @@ -124,14 +124,14 @@ class TestLvm(unittest.TestCase): vg.extend(d) vg.createLvThinpool( - pool_name, vg.getSize() / 2, 0, 0, lvm.THIN_DISCARDS_PASSDOWN, 1) + pool_name, vg.getSize() // 2, 0, 0, lvm.THIN_DISCARDS_PASSDOWN, 1) return vg @staticmethod def _create_thin_lv(pv_devices, name): thin_pool_name = 'thin_vg_pool_' + rs(4) vg = TestLvm._create_thin_pool(pv_devices, thin_pool_name) - vg.createLvThin(thin_pool_name, name, vg.getSize() / 8) + vg.createLvThin(thin_pool_name, name, vg.getSize() // 8) vg.close() vg = None @@ -231,7 +231,7 @@ class TestLvm(unittest.TestCase): curr_size = pv.getSize() dev_size = pv.getDevSize() self.assertTrue(curr_size == dev_size) - pv.resize(curr_size / 2) + pv.resize(curr_size // 2) with AllowedPVS() as pvs: pv = pvs[0] resized_size = pv.getSize() @@ -718,7 +718,7 @@ class TestLvm(unittest.TestCase): def test_percent_to_float(self): self.assertEqual(lvm.percentToFloat(0), 0.0) self.assertEqual(lvm.percentToFloat(1000000), 1.0) - self.assertEqual(lvm.percentToFloat(1000000 / 2), 0.5) + self.assertEqual(lvm.percentToFloat(1000000 // 2), 0.5) def test_scan(self): self.assertEqual(lvm.scan(), None) diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py index bab998610..5f348471e 100755 --- a/test/dbus/lvmdbustest.py +++ b/test/dbus/lvmdbustest.py @@ -1027,7 +1027,7 @@ class TestDbusService(unittest.TestCase): vg.Move( dbus.ObjectPath(location), dbus.Struct((0, 0), signature='tt'), - dbus.Array([(dst, pv.PeCount / 2, 0), ], '(ott)'), + dbus.Array([(dst, pv.PeCount // 2, 0), ], '(ott)'), dbus.Int32(g_tmo), EOD)) self.assertEqual(job, '/') @@ -1320,7 +1320,7 @@ class TestDbusService(unittest.TestCase): original_size = pv.SizeBytes - new_size = original_size / 2 + new_size = original_size // 2 self.handle_return( pv.ReSize( @@ -1454,7 +1454,7 @@ class TestDbusService(unittest.TestCase): @staticmethod def _write_some_data(device_path, size): - blocks = int(size / 512) + blocks = int(size // 512) block = bytearray(512) for i in range(0, 512): block[i] = i % 255 @@ -1481,7 +1481,7 @@ class TestDbusService(unittest.TestCase): interfaces=(LV_COMMON_INT, LV_INT, SNAPSHOT_INT, )) # Write some data to snapshot so merge takes some time - TestDbusService._write_some_data(ss.LvCommon.Path, ss_size / 2) + TestDbusService._write_some_data(ss.LvCommon.Path, ss_size // 2) job_path = self.handle_return( ss.Snapshot.Merge( From 0253f5a21dc0b9ee8641228739d3d1036212ba80 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 18 May 2018 13:41:20 -0500 Subject: [PATCH 15/81] fix id_write_format on non-uuid string orphan vgs using the vgname "#orphans" as the vgid, and valgrind complains about calling id_write_format on that invalid uuid. --- lib/metadata/metadata.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 2f84d5fc0..3f6c2e47a 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -3765,13 +3765,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, struct cached_vg_fmtdata *vg_fmtdata = NULL; /* Additional format-specific data about the vg */ unsigned use_previous_vg; - uuid[0] = '\0'; - if (vgid && !id_write_format((const struct id*)vgid, uuid, sizeof(uuid))) - stack; - - log_very_verbose("Reading VG %s %s", vgname ?: "", vgid ? uuid : ""); - if (is_orphan_vg(vgname)) { + log_very_verbose("Reading VG %s", vgname); + if (use_precommitted) { log_error(INTERNAL_ERROR "vg_read_internal requires vgname " "with pre-commit."); @@ -3780,6 +3776,12 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, return _vg_read_orphans(cmd, warn_flags, vgname, consistent); } + uuid[0] = '\0'; + if (vgid && !id_write_format((const struct id*)vgid, uuid, sizeof(uuid))) + stack; + + log_very_verbose("Reading VG %s %s", vgname ?: "", vgid ? uuid : ""); + if (lvmetad_used() && !use_precommitted) { if ((correct_vg = lvmetad_vg_lookup(cmd, vgname, vgid))) { dm_list_iterate_items(pvl, &correct_vg->pvs) From bc275bcddf3fac6ea691e2dfda0ca3531c4b3c0c Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 18 May 2018 14:26:32 -0500 Subject: [PATCH 16/81] fullreport: fix with lvmetad and only orphan PVs are visible The report uses process_each_vg() which populates lvmcache based on a VG list from lvmetad. If there are no VGs, but only orphan PVs, the orphans are not shown. Add an explicit call to populate lvmcache with PV info from lvmetad. --- tools/reporter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/reporter.c b/tools/reporter.c index 98e3d12f0..2d8342151 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -1421,6 +1421,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t return ECMD_FAILED; } + lvmcache_seed_infos_from_lvmetad(cmd); + if (single_args->report_type == FULL) { handle->custom_handle = &args; r = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 1, handle, &_full_report_single); From a9f2c1e1f568d7fc7ffba7ec702b584f34f678c6 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 18 May 2018 16:00:54 -0500 Subject: [PATCH 17/81] lvmlockd: suppress error messages related to lvmetad Log lvmetad related messages as debug, not as errors, when using lvmlockd without lvmetad. --- daemons/lvmlockd/lvmlockd-core.c | 38 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index df6e214e7..861fb4ace 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -1009,6 +1009,8 @@ static void add_work_action(struct action *act) pthread_mutex_unlock(&worker_mutex); } +#define ERR_LVMETAD_NOT_RUNNING -200 + static daemon_reply send_lvmetad(const char *id, ...) { daemon_reply reply; @@ -1029,9 +1031,9 @@ retry: if (lvmetad_handle.error || lvmetad_handle.socket_fd < 0) { err = lvmetad_handle.error ?: lvmetad_handle.socket_fd; pthread_mutex_unlock(&lvmetad_mutex); - log_error("lvmetad_open reconnect error %d", err); + log_debug("lvmetad_open reconnect error %d", err); memset(&reply, 0, sizeof(reply)); - reply.error = err; + reply.error = ERR_LVMETAD_NOT_RUNNING; va_end(ap); return reply; } else { @@ -1265,6 +1267,15 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act * caches, and tell lvmetad to set global invalid to 0. */ + /* + * lvmetad not running: + * Even if we have not previously found lvmetad running, + * we attempt to connect and invalidate in case it has + * been started while lvmlockd is running. We don't + * want to allow lvmetad to be used with invalid data if + * it happens to be enabled and started after lvmlockd. + */ + if (inval_meta && (r->type == LD_RT_VG)) { daemon_reply reply; char *uuid; @@ -1284,8 +1295,10 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act "version = " FMTd64, (int64_t)new_version, NULL); - if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) - log_error("set_vg_info in lvmetad failed %d", reply.error); + if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) { + if (reply.error != ERR_LVMETAD_NOT_RUNNING) + log_error("set_vg_info in lvmetad failed %d", reply.error); + } daemon_reply_destroy(reply); } @@ -1300,8 +1313,10 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act "global_invalid = " FMTd64, INT64_C(1), NULL); - if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) - log_error("set_global_info in lvmetad failed %d", reply.error); + if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) { + if (reply.error != ERR_LVMETAD_NOT_RUNNING) + log_error("set_global_info in lvmetad failed %d", reply.error); + } daemon_reply_destroy(reply); } @@ -5848,7 +5863,7 @@ static int main_loop(daemon_state *ds_arg) pthread_mutex_init(&lvmetad_mutex, NULL); lvmetad_handle = lvmetad_open(NULL); if (lvmetad_handle.error || lvmetad_handle.socket_fd < 0) - log_error("lvmetad_open error %d", lvmetad_handle.error); + log_debug("lvmetad_open error %d", lvmetad_handle.error); else lvmetad_connected = 1; @@ -5856,8 +5871,13 @@ static int main_loop(daemon_state *ds_arg) * Attempt to rejoin lockspaces and adopt locks from a previous * instance of lvmlockd that left behind lockspaces/locks. */ - if (adopt_opt) - adopt_locks(); + if (adopt_opt) { + /* FIXME: implement this without lvmetad */ + if (!lvmetad_connected) + log_error("Cannot adopt locks without lvmetad running."); + else + adopt_locks(); + } while (1) { rv = poll(pollfd, pollfd_maxi + 1, -1); From 25a66737e3c9fee218c84a659d5d9b7a34347e47 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 21 May 2018 11:56:45 +0200 Subject: [PATCH 18/81] tests: use 4K extent size To work with for 4k backend devices. --- test/api/vgtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api/vgtest.c b/test/api/vgtest.c index da04dda8d..97f0d2c02 100644 --- a/test/api/vgtest.c +++ b/test/api/vgtest.c @@ -28,7 +28,7 @@ vg_t vg; const char *vg_name; #define MAX_DEVICES 16 const char *device[MAX_DEVICES]; -uint64_t size = 1024; +uint64_t size = 4096; #define vg_create(vg_name) \ printf("Creating VG %s\n", vg_name); \ From 6029d6d8d8198aee17ec8972c333477f2c581bff Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 19 May 2018 12:08:23 +0200 Subject: [PATCH 19/81] tests: disable symlink test It's quite unclear what the test is meant to do - disable it just like within python test. --- test/dbus/lvmdbustest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py index 5f348471e..d633aa38a 100755 --- a/test/dbus/lvmdbustest.py +++ b/test/dbus/lvmdbustest.py @@ -1873,10 +1873,14 @@ class TestDbusService(unittest.TestCase): # when run from lvm2 testsuite. See dbustest.sh. pv_object_path = self.objs[PV_INT][0].object_path + if not pv_object_path.startswith("/dev"): + std_err_print('Skipping test not running in /dev') + return + for i in range(0, 5): pv_object_path = self._create_nested(pv_object_path) - def test_pv_symlinks(self): + def DISABLED_test_pv_symlinks(self): # Lets take one of our test PVs, pvremove it, find a symlink to it # and re-create using the symlink to ensure we return an object # path to it. Additionally, we will take the symlink and do a lookup From 73ae68e1c4308c3391fe3b21f2c721f659343f98 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 21 May 2018 16:26:49 -0500 Subject: [PATCH 20/81] man vgexport: expand description --- man/vgexport.8_des | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/man/vgexport.8_des b/man/vgexport.8_des index 66d3af39b..9f276afa7 100644 --- a/man/vgexport.8_des +++ b/man/vgexport.8_des @@ -1,8 +1,19 @@ -vgexport makes inactive VGs unknown to the system. In this state, all the -PVs in the VG can be moved to a different system, from which -\fBvgimport\fP(8) can then be run. +vgexport changes a VG into the exported state, which ensures that the VG +and its disks are not being used, and cannot be used until the VG is +imported by \fBvgimport\fP(8). Putting a VG into an unusable, offline +state can be useful when doing things like moving a VG's disks to another +system. Exporting a VG provides some protection from its LVs being +accidentally used, or being used by an automated system before it's ready. -Most LVM tools ignore exported VGs. +A VG cannot be exported until all of its LVs are inactive. + +LVM commands will ignore an exported VG or report an error if a command +tries to use it. + +For an exported VG, the vgs command will display \"x\" in the third VG +attribute, and the pvs command will display \"x\" in the second PV +attribute. Both vgs and pvs will display \"exported\" from the export +report field. vgexport clears the VG system ID, and vgimport sets the VG system ID to match the host running vgimport (if the host has a system ID). From 3c9ed33f83c90aa15e57ba6dc12d8f1a80afab6d Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 21 May 2018 14:20:19 -0500 Subject: [PATCH 21/81] scan: move warnings about duplicate devices We have been warning about duplicate devices (and disabling lvmetad) immediately when the dup was detected (during label_scan). Move the warnings (and the disabling) to happen later, after label_scan is finished. This lets us avoid an unwanted warning message about duplicates in the special case were md components are eliminated during the duplicate device resolution. --- lib/cache/lvmcache.c | 125 ++++++++++++++++++++--- lib/cache/lvmcache.h | 2 + lib/cache/lvmetad.c | 2 + lib/device/device.h | 1 + test/shell/process-each-duplicate-pvs.sh | 22 ++-- test/shell/pv-duplicate-uuid.sh | 5 +- 6 files changed, 126 insertions(+), 31 deletions(-) diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 991299561..c306a3aa9 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -981,11 +981,25 @@ int lvmcache_dev_is_unchosen_duplicate(struct device *dev) * The actual filters are evaluated too early, before a complete * picture of all PVs is available, to eliminate these duplicates. * - * By removing the filtered duplicates from unused_duplicate_devs, we remove + * By removing some duplicates from unused_duplicate_devs here, we remove * the restrictions that are placed on using duplicate devs or VGs with * duplicate devs. * - * There may other kinds of duplicates that we want to ignore. + * In cases where we know that two duplicates refer to the same underlying + * storage, and we know which dev path to use, it's best for us to just + * use that one preferred device path and ignore the others. It is the cases + * where we are unsure whether dups refer to the same underlying storage where + * we need to keep the unused duplicate referenced in the + * unused_duplicate_devs list, and restrict what we allow done with it. + * + * In the case of md components, we usually filter these out in filter-md, + * but in the special case of md superblocks <= 1.0 where the superblock + * is at the end of the device, filter-md doesn't always eliminate them + * first, so we eliminate them here. + * + * There may other kinds of duplicates that we want to eliminate at + * this point (using the knowledge from the scan) that we couldn't + * eliminate in the filters prior to the scan. */ static void _filter_duplicate_devs(struct cmd_context *cmd) @@ -1004,6 +1018,34 @@ static void _filter_duplicate_devs(struct cmd_context *cmd) dm_free(devl); } } + + if (dm_list_empty(&_unused_duplicate_devs)) + _found_duplicate_pvs = 0; +} + +static void _warn_duplicate_devs(struct cmd_context *cmd) +{ + char uuid[64] __attribute__((aligned(8))); + struct lvmcache_info *info; + struct device_list *devl, *devl2; + + dm_list_iterate_items_safe(devl, devl2, &_unused_duplicate_devs) { + if (!id_write_format((const struct id *)devl->dev->pvid, uuid, sizeof(uuid))) + stack; + + log_warn("WARNING: Not using device %s for PV %s.", dev_name(devl->dev), uuid); + } + + dm_list_iterate_items_safe(devl, devl2, &_unused_duplicate_devs) { + /* info for the preferred device that we're actually using */ + info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0); + + if (!id_write_format((const struct id *)info->dev->pvid, uuid, sizeof(uuid))) + stack; + + log_warn("WARNING: PV %s prefers device %s because %s.", + uuid, dev_name(info->dev), info->dev->duplicate_prefer_reason); + } } /* @@ -1028,7 +1070,6 @@ static void _choose_preferred_devs(struct cmd_context *cmd, struct dm_list *del_cache_devs, struct dm_list *add_cache_devs) { - char uuid[64] __attribute__((aligned(8))); const char *reason; struct dm_list altdevs; struct dm_list new_unused; @@ -1229,9 +1270,7 @@ next: alt = devl; } - if (!id_write_format((const struct id *)dev1->pvid, uuid, sizeof(uuid))) - stack; - log_warn("WARNING: PV %s prefers device %s because %s.", uuid, dev_name(dev1), reason); + dev1->duplicate_prefer_reason = reason; } if (dev1 != info->dev) { @@ -1480,11 +1519,21 @@ int lvmcache_label_scan(struct cmd_context *cmd) dm_list_splice(&_unused_duplicate_devs, &del_cache_devs); /* - * We might want to move the duplicate device warnings until - * after this filtering so that we can skip warning about - * duplicates that we are filtering out. + * This may remove some entries from the unused_duplicates list for + * devs that we know are the same underlying dev. */ _filter_duplicate_devs(cmd); + + /* + * Warn about remaining duplicates that may actually be separate copies of + * the same device. + */ + _warn_duplicate_devs(cmd); + + if (!_found_duplicate_pvs && lvmetad_used()) { + log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs."); + lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_DUPLICATES); + } } /* Perform any format-specific scanning e.g. text files */ @@ -1509,6 +1558,53 @@ int lvmcache_label_scan(struct cmd_context *cmd) return r; } +/* + * When not using lvmetad, lvmcache_label_scan() detects duplicates in + * the basic label_scan(), then filters out some dups, and chooses + * preferred duplicates to use. + * + * When using lvmetad, pvscan --cache does not use lvmcache_label_scan(), + * only label_scan() which detects the duplicates. This function is used + * after pvscan's label_scan() to filter out some dups, print any warnings, + * and disable lvmetad if any dups are left. + */ + +void lvmcache_pvscan_duplicate_check(struct cmd_context *cmd) +{ + struct device_list *devl; + + /* Check if label_scan() detected any dups. */ + if (!_found_duplicate_pvs) + return; + + /* + * Once all the dups are identified, they are moved from the + * "found" list to the "unused" list to sort out. + */ + dm_list_splice(&_unused_duplicate_devs, &_found_duplicate_devs); + + /* + * Remove items from the dups list that we know are the same + * underlying dev, e.g. md components, that we want to just ignore. + */ + _filter_duplicate_devs(cmd); + + /* + * If no more dups after ignoring some, then we can use lvmetad. + */ + if (!_found_duplicate_pvs) + return; + + /* Duplicates are found where we would have to pick one, so disable lvmetad. */ + + dm_list_iterate_items(devl, &_unused_duplicate_devs) + log_warn("WARNING: found device with duplicate %s", dev_name(devl->dev)); + + log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs."); + lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_DUPLICATES); + lvmetad_make_unused(cmd); +} + int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal, struct dm_list *vgnameids) { @@ -2303,14 +2399,8 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, */ if (!created) { if (info->dev != dev) { - log_warn("WARNING: PV %s on %s was already found on %s.", - uuid, dev_name(dev), dev_name(info->dev)); - - if (!_found_duplicate_pvs && lvmetad_used()) { - log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs."); - lvmetad_set_disabled(labeller->fmt->cmd, LVMETAD_DISABLE_REASON_DUPLICATES); - } - _found_duplicate_pvs = 1; + log_debug_cache("PV %s on %s was already found on %s.", + uuid, dev_name(dev), dev_name(info->dev)); strncpy(dev->pvid, pvid_s, sizeof(dev->pvid)); @@ -2328,6 +2418,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, devl->dev = dev; dm_list_add(&_found_duplicate_devs, &devl->list); + _found_duplicate_pvs = 1; return NULL; } diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h index a2a7f07e6..b988be66c 100644 --- a/lib/cache/lvmcache.h +++ b/lib/cache/lvmcache.h @@ -188,6 +188,8 @@ uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info); int lvmcache_found_duplicate_pvs(void); +void lvmcache_pvscan_duplicate_check(struct cmd_context *cmd); + int lvmcache_get_unused_duplicate_devs(struct cmd_context *cmd, struct dm_list *head); int vg_has_duplicate_pvs(struct volume_group *vg); diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index 235f72b6f..a1ab41aab 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -2350,6 +2350,8 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait) label_scan(cmd); + lvmcache_pvscan_duplicate_check(cmd); + if (lvmcache_found_duplicate_pvs()) { log_warn("WARNING: Scan found duplicate PVs."); return 0; diff --git a/lib/device/device.h b/lib/device/device.h index 42659cd0f..c8ccd73d9 100644 --- a/lib/device/device.h +++ b/lib/device/device.h @@ -75,6 +75,7 @@ struct device { uint64_t size; uint64_t end; struct dev_ext ext; + const char *duplicate_prefer_reason; const char *vgid; /* if device is an LV */ const char *lvid; /* if device is an LV */ diff --git a/test/shell/process-each-duplicate-pvs.sh b/test/shell/process-each-duplicate-pvs.sh index 98dd285da..9ce4e142b 100644 --- a/test/shell/process-each-duplicate-pvs.sh +++ b/test/shell/process-each-duplicate-pvs.sh @@ -72,7 +72,7 @@ not grep duplicate main not grep $vg2 main not grep $UUID2 main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn # Find which is the preferred dev and which is the duplicate. @@ -119,7 +119,7 @@ grep "$dev2" main | grep $vg1 grep "$dev1" main | grep $UUID1 grep "$dev2" main | grep $UUID1 -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn # @@ -136,7 +136,7 @@ grep "$dev1" main not grep "$dev2" main grep "$UUID1" main grep "$vg1" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn pvs -o+uuid "$dev2" 2>&1 | tee out @@ -149,7 +149,7 @@ grep "$dev2" main not grep "$dev1" main grep "$UUID1" main grep "$vg1" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn pvs -o+uuid,duplicate "$dev1" "$dev2" 2>&1 | tee out @@ -225,7 +225,7 @@ grep -v WARNING out > main || true not grep "$dev1" main grep "$dev2" main -not grep "was already found on" warn +not grep "Not using device" warn not grep "prefers device" warn @@ -238,7 +238,7 @@ grep -v WARNING out > main || true grep "$dev1" main not grep "$dev2" main -not grep "was already found on" warn +not grep "Not using device" warn not grep "prefers device" warn # PV size and minor is still reported correctly for each. @@ -306,7 +306,7 @@ grep -v WARNING out > main || true test "$(grep -c "$UUID3" main)" -eq 1 not grep "$UUID4" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn # Both appear with 'pvs -a' @@ -325,7 +325,7 @@ grep "$dev4" main grep $UUID3 main not grep $UUID4 main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn # Show each dev individually and both together @@ -339,7 +339,7 @@ grep -v WARNING out > main || true grep "$dev3" main not grep "$dev4" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn pvs -o+uuid "$dev4" 2>&1 | tee out @@ -351,7 +351,7 @@ grep -v WARNING out > main || true not grep "$dev3" main grep "$dev4" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn pvs -o+uuid "$dev3" "$dev4" 2>&1 | tee out @@ -363,7 +363,7 @@ grep -v WARNING out > main || true grep "$dev3" main grep "$dev4" main -grep "was already found on" warn +grep "Not using device" warn grep "prefers device" warn # Same sizes shown. diff --git a/test/shell/pv-duplicate-uuid.sh b/test/shell/pv-duplicate-uuid.sh index 43eb830b7..2c121d747 100644 --- a/test/shell/pv-duplicate-uuid.sh +++ b/test/shell/pv-duplicate-uuid.sh @@ -26,7 +26,6 @@ pvcreate --config "devices{filter=[\"a|$dev3|\",\"r|.*|\"]} global/use_lvmetad=0 pvscan --cache 2>&1 | tee out if test -e LOCAL_LVMETAD; then - grep "was already found" out grep "WARNING: Disabling lvmetad cache which does not support duplicate PVs." out fi @@ -37,7 +36,7 @@ grep -v WARNING out > main || true test "$(grep -c $UUID1 main)" -eq 1 -COUNT=$(grep --count "was already found" warn) +COUNT=$(grep --count "Not using device" warn) [ "$COUNT" -eq 2 ] pvs -o+uuid --config "devices{filter=[\"a|$dev2|\",\"r|.*|\"]}" 2>&1 | tee out @@ -50,5 +49,5 @@ not grep "$dev1" main grep "$dev2" main not grep "$dev3" main -not grep "was already found" warn +not grep "Not using device" warn From a60416a13fbfdf053c327709c9997239f2ec1c71 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 22 May 2018 09:46:59 +0100 Subject: [PATCH 22/81] WHATS_NEW: typo --- WHATS_NEW | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 84805a947..3d722da8c 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -18,7 +18,7 @@ Version 2.02.178 - Fix evaluation of maximal region size for mirror log. Enhance mirror log size estimation and use smaller size when possible. Fix incorrect mirror log size calculation on 32bit arch. - Enhnace preloading tree creating. + Enhance preloading tree creating. Fix regression on acceptance of any LV on lvconvert. Restore usability of thin LV to be again external origin for another thin. Keep systemd vars on change event in 69-dm-lvm-metad.rules for systemd reload. From 61583281e5703f8b923654d0ff1576d6093d2ead Mon Sep 17 00:00:00 2001 From: David Teigland Date: Tue, 22 May 2018 14:07:13 -0500 Subject: [PATCH 23/81] filters: clarify some parts of md filter Rename some functions to be consistent with the return values, and add some comments about how it works. --- lib/filters/filter-md.c | 89 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c index bb8a7cf42..ab97b5946 100644 --- a/lib/filters/filter-md.c +++ b/lib/filters/filter-md.c @@ -20,13 +20,77 @@ #define MSG_SKIPPING "%s: Skipping md component device" -static int _ignore_md(struct device *dev, int full) +/* + * The purpose of these functions is to ignore md component devices, + * e.g. if /dev/md0 is a raid1 composed of /dev/loop0 and /dev/loop1, + * lvm wants to deal with md0 and ignore loop0 and loop1. md0 should + * pass the filter, and loop0,loop1 should not pass the filter so lvm + * will ignore them. + * + * (This is assuming lvm.conf md_component_detection=1.) + * + * If lvm does *not* ignore the components, then lvm will read lvm + * labels from the md dev and from the component devs, and will see + * them all as duplicates of each other. LVM duplicate resolution + * will then kick in and keep the md dev around to use and ignore + * the components. + * + * It is better to exclude the components as early as possible during + * lvm processing, ideally before lvm even looks for labels on the + * components, so that duplicate resolution can be avoided. There are + * a number of ways that md components can be excluded earlier than + * the duplicate resolution phase: + * + * - When external_device_info_source="udev", lvm discovers a device is + * an md component by asking udev during the initial filtering phase. + * However, lvm's default is to not use udev for this. The + * alternative is "native" detection in which lvm tries to detect + * md components itself. + * + * - When using native detection, lvm's md filter looks for the md + * superblock at the start of devices. It will see the md superblock + * on the components, exclude them in the md filter, and avoid + * handling them later in duplicate resolution. + * + * - When using native detection, lvm's md filter will not detect + * components when the md device has an older superblock version that + * places the superblock at the end of the device. This case will + * fall back to duplicate resolution to exclude components. + * + * A variation of the description above occurs for lvm commands that + * intend to create new PVs on devices (pvcreate, vgcreate, vgextend). + * For these commands, the native md filter also reads the end of all + * devices to check for the odd md superblocks. + * + * (The reason that external_device_info_source is not set to udev by + * default is that there have be issues with udev not being promptly + * or reliably updated about md state changes, causing the udev info + * that lvm uses to be occasionally wrong.) + */ + +/* + * Returns 0 if: + * the device is an md component and it should be ignored. + * + * Returns 1 if: + * the device is not md component and should not be ignored. + * + * The actual md device will pass this filter and should be used, + * it is the md component devices that we are trying to exclude + * that will not pass. + */ + +static int _passes_md_filter(struct device *dev, int full) { int ret; - + + /* + * When md_component_dectection=0, don't even try to skip md + * components. + */ if (!md_filtering()) return 1; - + ret = dev_is_md(dev, NULL, full); if (ret == -EAGAIN) { @@ -36,6 +100,9 @@ static int _ignore_md(struct device *dev, int full) return 1; } + if (ret == 0) + return 1; + if (ret == 1) { if (dev->ext.src == DEV_EXT_NONE) log_debug_devs(MSG_SKIPPING, dev_name(dev)); @@ -54,16 +121,16 @@ static int _ignore_md(struct device *dev, int full) return 1; } -static int _ignore_md_lite(struct dev_filter *f __attribute__((unused)), - struct device *dev) +static int _passes_md_filter_lite(struct dev_filter *f __attribute__((unused)), + struct device *dev) { - return _ignore_md(dev, 0); + return _passes_md_filter(dev, 0); } -static int _ignore_md_full(struct dev_filter *f __attribute__((unused)), - struct device *dev) +static int _passes_md_filter_full(struct dev_filter *f __attribute__((unused)), + struct device *dev) { - return _ignore_md(dev, 1); + return _passes_md_filter(dev, 1); } static void _destroy(struct dev_filter *f) @@ -91,9 +158,9 @@ struct dev_filter *md_filter_create(struct cmd_context *cmd, struct dev_types *d */ if (cmd->use_full_md_check) - f->passes_filter = _ignore_md_full; + f->passes_filter = _passes_md_filter_full; else - f->passes_filter = _ignore_md_lite; + f->passes_filter = _passes_md_filter_lite; f->destroy = _destroy; f->use_count = 0; From b7fd8ac8ebf07f7a8119aae723f40ef6f85273ce Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 23 May 2018 12:48:06 +0100 Subject: [PATCH 24/81] radix_tree: add remove method --- base/data-struct/radix-tree.c | 185 +++++++++++++++++++++++++++++++++- base/data-struct/radix-tree.h | 2 +- test/unit/radix_tree_t.c | 112 +++++++++++++++++++- 3 files changed, 289 insertions(+), 10 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index b4b6791dd..a359aaa78 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -68,6 +68,7 @@ struct node48 { }; struct node256 { + uint32_t nr_entries; struct value values[256]; }; @@ -397,10 +398,13 @@ static bool _insert_node48(struct value *v, uint8_t *kb, uint8_t *ke, union radi static bool _insert_node256(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct node256 *n256 = v->value.ptr; - if (!_insert(n256->values + *kb, kb + 1, ke, rv)) { - n256->values[*kb].type = UNSET; + bool was_unset = n256->values[*kb].type == UNSET; + + if (!_insert(n256->values + *kb, kb + 1, ke, rv)) return false; - } + + if (was_unset) + n256->nr_entries++; return true; } @@ -538,9 +542,180 @@ bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union ra return false; } -void radix_tree_delete(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end) +// Note the degrade functions also free the original node. +static void _degrade_to_n4(struct node16 *n16, struct value *result) { - assert(0); + struct node4 *n4 = zalloc(sizeof(*n4)); + + n4->nr_entries = n16->nr_entries; + memcpy(n4->keys, n16->keys, n16->nr_entries * sizeof(*n4->keys)); + memcpy(n4->values, n16->values, n16->nr_entries * sizeof(*n4->values)); + free(n16); + + result->type = NODE4; + result->value.ptr = n4; +} + +static void _degrade_to_n16(struct node48 *n48, struct value *result) +{ + struct node4 *n16 = zalloc(sizeof(*n16)); + + n16->nr_entries = n48->nr_entries; + memcpy(n16->keys, n48->keys, n48->nr_entries * sizeof(*n16->keys)); + memcpy(n16->values, n48->values, n48->nr_entries * sizeof(*n16->values)); + free(n48); + + result->type = NODE16; + result->value.ptr = n16; +} + +static void _degrade_to_n48(struct node256 *n256, struct value *result) +{ + unsigned i, count = 0; + struct node4 *n48 = zalloc(sizeof(*n48)); + + n48->nr_entries = n256->nr_entries; + for (i = 0; i < 256; i++) { + if (n256->values[i].type == UNSET) + continue; + + n48->keys[count] = i; + n48->values[count] = n256->values[i]; + count++; + } + free(n256); + + result->type = NODE48; + result->value.ptr = n48; +} + +static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) +{ + bool r; + unsigned i; + struct value_chain *vc; + struct prefix_chain *pc; + struct node4 *n4; + struct node16 *n16; + struct node48 *n48; + struct node256 *n256; + + if (kb == ke) { + if (root->type == VALUE) { + root->type = UNSET; + return true; + + } else if (root->type == VALUE_CHAIN) { + vc = root->value.ptr; + memcpy(root, &vc->child, sizeof(*root)); + free(vc); + return true; + + } else + return false; + } + + switch (root->type) { + case UNSET: + case VALUE: + // this is a value for a prefix of the key + return false; + + case VALUE_CHAIN: + vc = root->value.ptr; + r = _remove(&vc->child, kb, ke); + if (r && (vc->child.type == UNSET)) { + memcpy(root, &vc->child, sizeof(*root)); + free(vc); + } + return r; + + case PREFIX_CHAIN: + pc = root->value.ptr; + if (ke - kb < pc->len) + return false; + + for (i = 0; i < pc->len; i++) + if (kb[i] != pc->prefix[i]) + return false; + + return _remove(&pc->child, kb + pc->len, ke); + + case NODE4: + n4 = root->value.ptr; + for (i = 0; i < n4->nr_entries; i++) { + if (n4->keys[i] == *kb) { + r = _remove(n4->values + i, kb + 1, ke); + if (r && n4->values[i].type == UNSET) { + n4->nr_entries--; + if (i < n4->nr_entries) + // slide the entries down + memmove(n4->keys + i, n4->keys + i + 1, + sizeof(*n4->keys) * (n4->nr_entries - i)); + if (!n4->nr_entries) + root->type = UNSET; + } + return r; + } + } + return false; + + case NODE16: + n16 = root->value.ptr; + for (i = 0; i < n16->nr_entries; i++) { + if (n16->keys[i] == *kb) { + r = _remove(n16->values + i, kb + 1, ke); + if (r && n16->values[i].type == UNSET) { + n16->nr_entries--; + if (i < n16->nr_entries) + // slide the entries down + memmove(n16->keys + i, n16->keys + i + 1, + sizeof(*n16->keys) * (n16->nr_entries - i)); + if (n16->nr_entries <= 4) + _degrade_to_n4(n16, root); + } + return r; + } + } + return false; + + case NODE48: + n48 = root->value.ptr; + i = n48->keys[*kb]; + if (i < 48) { + r = _remove(n48->values + i, kb + 1, ke); + if (r && n48->values[i].type == UNSET) { + n48->keys[*kb] = 48; + n48->nr_entries--; + if (n48->nr_entries <= 16) + _degrade_to_n16(n48, root); + } + return r; + } + return false; + + case NODE256: + n256 = root->value.ptr; + r = _remove(n256->values + (*kb), kb + 1, ke); + if (r && n256->values[*kb].type == UNSET) { + n256->nr_entries--; + if (n256->nr_entries <= 48) + _degrade_to_n48(n256, root); + } + return r; + } + + return false; +} + +bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end) +{ + if (_remove(&rt->root, key_begin, key_end)) { + rt->nr_entries--; + return true; + } + + return false; } bool radix_tree_lookup(struct radix_tree *rt, diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h index d84e3c54e..983b5fa24 100644 --- a/base/data-struct/radix-tree.h +++ b/base/data-struct/radix-tree.h @@ -34,7 +34,7 @@ void radix_tree_destroy(struct radix_tree *rt, radix_value_dtr dtr, void *contex unsigned radix_tree_size(struct radix_tree *rt); bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v); -void radix_tree_delete(struct radix_tree *rt, uint8_t *kb, uint8_t *ke); +bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke); bool radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result); diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index 4455f2b04..9f2ba073d 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -152,22 +152,122 @@ static void test_prefix_keys_reversed(void *fixture) T_ASSERT_EQUAL(v.n, 2345); } +static void _gen_key(uint8_t *b, uint8_t *e) +{ + for (; b != e; b++) + *b = rand() % 256; +} + static void test_sparse_keys(void *fixture) { - unsigned i, n; + unsigned n; struct radix_tree *rt = fixture; union radix_value v; uint8_t k[32]; for (n = 0; n < 100000; n++) { - for (i = 0; i < 32; i++) - k[i] = rand() % 256; - + _gen_key(k, k + sizeof(k)); v.n = 1234; T_ASSERT(radix_tree_insert(rt, k, k + 32, v)); } } +static void test_remove_one(void *fixture) +{ + struct radix_tree *rt = fixture; + uint8_t k[4]; + union radix_value v; + + _gen_key(k, k + sizeof(k)); + v.n = 1234; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k))); + T_ASSERT(!radix_tree_lookup(rt, k, k + sizeof(k), &v)); +} + +static void test_remove_one_byte_keys(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, j; + uint8_t k[1]; + union radix_value v; + + for (i = 0; i < 256; i++) { + k[0] = i; + v.n = i + 1000; + T_ASSERT(radix_tree_insert(rt, k, k + 1, v)); + } + + for (i = 0; i < 256; i++) { + k[0] = i; + T_ASSERT(radix_tree_remove(rt, k, k + 1)); + + for (j = i + 1; j < 256; j++) { + k[0] = j; + T_ASSERT(radix_tree_lookup(rt, k, k + 1, &v)); + T_ASSERT_EQUAL(v.n, j + 1000); + } + } + + for (i = 0; i < 256; i++) { + k[0] = i; + T_ASSERT(!radix_tree_lookup(rt, k, k + 1, &v)); + } +} + +static void test_remove_prefix_keys(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, j; + uint8_t k[32]; + union radix_value v; + + _gen_key(k, k + sizeof(k)); + + for (i = 0; i < 32; i++) { + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + i, v)); + } + + for (i = 0; i < 32; i++) { + T_ASSERT(radix_tree_remove(rt, k, k + i)); + for (j = i + 1; j < 32; j++) { + T_ASSERT(radix_tree_lookup(rt, k, k + j, &v)); + T_ASSERT_EQUAL(v.n, j); + } + } + + for (i = 0; i < 32; i++) + T_ASSERT(!radix_tree_lookup(rt, k, k + i, &v)); +} + +static void test_remove_prefix_keys_reversed(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, j; + uint8_t k[32]; + union radix_value v; + + _gen_key(k, k + sizeof(k)); + + for (i = 0; i < 32; i++) { + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + i, v)); + } + + for (i = 0; i < 32; i++) { + fprintf(stderr, "removing %u\n", i); + T_ASSERT(radix_tree_remove(rt, k, k + (31 - i))); + for (j = 0; j < 31 - i; j++) { + T_ASSERT(radix_tree_lookup(rt, k, k + j, &v)); + T_ASSERT_EQUAL(v.n, j); + } + } + + for (i = 0; i < 32; i++) + T_ASSERT(!radix_tree_lookup(rt, k, k + i, &v)); +} + //---------------------------------------------------------------- #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) @@ -188,6 +288,10 @@ void radix_tree_tests(struct dm_list *all_tests) T("prefix-keys", "prefixes of other keys are valid keys", test_prefix_keys); T("prefix-keys-reversed", "prefixes of other keys are valid keys", test_prefix_keys_reversed); T("sparse-keys", "see what the memory usage is for sparsely distributed keys", test_sparse_keys); + T("remove-one", "remove one entry", test_remove_one); + T("remove-one-byte-keys", "remove many one byte keys", test_remove_one_byte_keys); + T("remove-prefix-keys", "remove a set of keys that have common prefixes", test_remove_prefix_keys); + T("remove-prefix-keys-reversed", "remove a set of keys that have common prefixes (reversed)", test_remove_prefix_keys_reversed); dm_list_add(all_tests, &ts->list); } From 6cd798f556b34c4c4171d536298d8f718f8aef62 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 23 May 2018 12:54:02 +0100 Subject: [PATCH 25/81] radix_tree_t: knock out some debug --- test/unit/radix_tree_t.c | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index 9f2ba073d..4cf394ff5 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -256,7 +256,6 @@ static void test_remove_prefix_keys_reversed(void *fixture) } for (i = 0; i < 32; i++) { - fprintf(stderr, "removing %u\n", i); T_ASSERT(radix_tree_remove(rt, k, k + (31 - i))); for (j = 0; j < 31 - i; j++) { T_ASSERT(radix_tree_lookup(rt, k, k + j, &v)); From c35d3242a8897c054c993dc59ad6e1cfff658061 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 22 May 2018 13:45:21 +0200 Subject: [PATCH 26/81] gitignore --- .gitignore | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 30385240c..f51bb67fc 100644 --- a/.gitignore +++ b/.gitignore @@ -79,5 +79,55 @@ test/lib/vgrename test/lib/vgs test/lib/vgscan test/lib/vgsplit - +test/api/lvtest.t +test/api/pe_start.t +test/api/percent.t +test/api/python_lvm_unit.py +test/api/test +test/api/thin_percent.t +test/api/vglist.t +test/api/vgtest.t +test/lib/aux +test/lib/check +test/lib/clvmd +test/lib/dm-version-expected +test/lib/dmeventd +test/lib/dmsetup +test/lib/dmstats +test/lib/fail +test/lib/flavour-ndev-cluster +test/lib/flavour-ndev-cluster-lvmpolld +test/lib/flavour-ndev-lvmetad +test/lib/flavour-ndev-lvmetad-lvmpolld +test/lib/flavour-ndev-lvmpolld +test/lib/flavour-ndev-vanilla +test/lib/flavour-udev-cluster +test/lib/flavour-udev-cluster-lvmpolld +test/lib/flavour-udev-lvmetad +test/lib/flavour-udev-lvmetad-lvmpolld +test/lib/flavour-udev-lvmlockd-dlm +test/lib/flavour-udev-lvmlockd-sanlock +test/lib/flavour-udev-lvmlockd-test +test/lib/flavour-udev-lvmpolld +test/lib/flavour-udev-vanilla +test/lib/fsadm +test/lib/get +test/lib/inittest +test/lib/invalid +test/lib/lvm +test/lib/lvm-wrapper +test/lib/lvmchange +test/lib/lvmdbusd.profile +test/lib/lvmetad +test/lib/lvmpolld +test/lib/not +test/lib/paths +test/lib/paths-common +test/lib/runner +test/lib/should +test/lib/test +test/lib/thin-performance.profile +test/lib/utils +test/lib/version-expected +test/unit/dmraid_t.c test/unit/unit-test From 4be1ec3da4eaa4ae315ca7c33265828dda37c58c Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 23 May 2018 19:45:53 +0200 Subject: [PATCH 27/81] man: fix cut and paste bug Fixing missing 'META' in DMEVENTD_THIN_POOL_METADATA. --- man/dmeventd.8_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/dmeventd.8_main b/man/dmeventd.8_main index 7e3f9a205..98b1b98d3 100644 --- a/man/dmeventd.8_main +++ b/man/dmeventd.8_main @@ -134,7 +134,7 @@ Variable is set by thin plugin and is available to executed program. Value prese actual usage of thin pool data volume. Variable is not set when error event is processed. .TP -.B DMEVENTD_THIN_POOL_DATA +.B DMEVENTD_THIN_POOL_METADATA Variable is set by thin plugin and is available to executed program. Value present actual usage of thin pool metadata volume. Variable is not set when error event is processed. From c46dbfb14e00beaa143871dbcefc23612a63f4e0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 23 May 2018 19:46:47 +0200 Subject: [PATCH 28/81] man: make generate --- man/vgexport.8_pregen | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/man/vgexport.8_pregen b/man/vgexport.8_pregen index 74aa59733..1dd715e67 100644 --- a/man/vgexport.8_pregen +++ b/man/vgexport.8_pregen @@ -8,11 +8,22 @@ vgexport - Unregister volume group(s) from the system [ \fIoption_args\fP ] .br .SH DESCRIPTION -vgexport makes inactive VGs unknown to the system. In this state, all the -PVs in the VG can be moved to a different system, from which -\fBvgimport\fP(8) can then be run. +vgexport changes a VG into the exported state, which ensures that the VG +and its disks are not being used, and cannot be used until the VG is +imported by \fBvgimport\fP(8). Putting a VG into an unusable, offline +state can be useful when doing things like moving a VG's disks to another +system. Exporting a VG provides some protection from its LVs being +accidentally used, or being used by an automated system before it's ready. -Most LVM tools ignore exported VGs. +A VG cannot be exported until all of its LVs are inactive. + +LVM commands will ignore an exported VG or report an error if a command +tries to use it. + +For an exported VG, the vgs command will display \"x\" in the third VG +attribute, and the pvs command will display \"x\" in the second PV +attribute. Both vgs and pvs will display \"exported\" from the export +report field. vgexport clears the VG system ID, and vgimport sets the VG system ID to match the host running vgimport (if the host has a system ID). From 76a45424a7b4d2e903bcb41b45b4f8cf131183ce Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 11:03:47 +0200 Subject: [PATCH 29/81] tests: aux improve for mdadm support Correcting some symlink handling. --- test/lib/aux.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index f6206cedd..bf766f204 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -755,11 +755,14 @@ prepare_md_dev() { local coption="--chunk" local maj local mddev + local mddir="md/" + local mdname + local mddevdir maj=$(mdadm --version 2>&1) || skip "mdadm tool is missing!" cleanup_md_dev - rm -f debug.log strace.log MD_DEV MD_DEV_PV MD_DEVICES + rm -f debug.log strace.log case "$level" in "1") coption="--bitmap-chunk" ;; @@ -770,9 +773,11 @@ prepare_md_dev() { # - newer mdadm _completely_ defers to udev to create the associated device node maj=${maj##*- v} maj=${maj%%.*} - [ "$maj" -ge 3 ] && \ - mddev=/dev/md/md_lvm_test0 || \ - mddev=/dev/md_lvm_test0 + [ "$maj" -ge 3 ] || mddir="" + + mdname="md_lvm_test0" + mddev="/dev/${mddir}$mdname" + mddevdir="$DM_DEV_DIR/$mddir" mdadm --create --metadata=1.0 "$mddev" --auto=md --level "$level" $with_bitmap "$coption"="$rchunk" --raid-devices="$rdevs" "${@:4}" || { # Some older 'mdadm' version managed to open and close devices internaly @@ -791,10 +796,11 @@ prepare_md_dev() { # LVM/DM will see this device case "$DM_DEV_DIR" in - "/dev") readlink -f "$mddev" ;; - *) cp -LR "$mddev" "$DM_DEV_DIR" - echo "$DM_DEV_DIR/md_lvm_test0" ;; - esac > MD_DEV_PV + "/dev") readlink -f "$mddev" > MD_DEV_PV ;; + *) mkdir -p "$mddevdir" + cp -LR "$mddev" "$mddevdir" + echo "${mddevdir}${mdname}" > MD_DEV_PV ;; + esac echo "$mddev" > MD_DEV notify_lvmetad "$(< MD_DEV_PV)" printf "%s\n" "${@:4}" > MD_DEVICES @@ -809,12 +815,14 @@ cleanup_md_dev() { local IFS=$IFS_NL local dev local mddev + local mddev_pv mddev=$(< MD_DEV) + mddev_pv=$(< MD_DEV_PV) udev_wait mdadm --stop "$mddev" || true - test "$DM_DEV_DIR" != "/dev" && rm -f "$DM_DEV_DIR/$(basename "$mddev")" - notify_lvmetad "$(< MD_DEV_PV)" + notify_lvmetad "$mddev_pv" udev_wait # wait till events are process, not zeroing to early + test "$DM_DEV_DIR" != "/dev" && rm -rf "${mddev_pv%/*}" for dev in $(< MD_DEVICES); do mdadm --zero-superblock "$dev" || true notify_lvmetad "$dev" From 89f34eaf0cc2d3916f9aa640e3a660c6c18fd3b8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 11:04:38 +0200 Subject: [PATCH 30/81] tests: correcting symlink manipulation Fix symlink and add 'verbose' pvs for a while for checking scanning correctness. --- test/shell/pvcreate-operation-md.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh index d228ada72..359113daa 100644 --- a/test/shell/pvcreate-operation-md.sh +++ b/test/shell/pvcreate-operation-md.sh @@ -83,7 +83,7 @@ EOF if aux kernel_at_least 2 6 33 ; then # in case the system is running without devtmpfs /dev # wait here for created device node on tmpfs - test "$DM_DEV_DIR" != "/dev" && cp -LR "${mddev}p1" "$DM_DEV_DIR" + test "$DM_DEV_DIR" = "/dev" || cp -LR "${mddev}p1" "${pvdev%/*}" pvcreate --metadatasize 128k "${pvdev}p1" @@ -100,20 +100,25 @@ EOF check pv_field "${pvdev}p1" pe_start $pv_align --units b --nosuffix pvremove "${pvdev}p1" - test "$DM_DEV_DIR" != "/dev" && rm -f "$DM_DEV_DIR/${mddev}p1" + test "$DM_DEV_DIR" = "/dev" || rm -f "${pvdev}p1" fi fi # Test newer topology-aware alignment detection w/ --dataalignment override if aux kernel_at_least 2 6 33 ; then # make sure we're clean for another test - dd if=/dev/zero of="$mddev" bs=512 count=1 + dd if=/dev/zero of="$mddev" bs=512 count=4 conv=fdatasync + partprobe -s "$mddev" aux prepare_md_dev 0 1024 2 "$dev1" "$dev2" pvdev=$(< MD_DEV_PV) # optimal_io_size=2097152, minimum_io_size=1048576 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' "$pvdev" + + # to see the processing of scanning + pvs -vvvv + check pv_field "$pvdev" pe_start "2.00m" # now verify pe_start alignment override using --dataalignment From f865e1bf87b474a0795e5b38456ebbeef406351c Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 11:12:17 +0200 Subject: [PATCH 31/81] tests: passthrough args with extend_filter_LVMTEST Don't rebuild config twice. --- test/lib/aux.sh | 2 +- test/shell/lvmetad-pvscan-md.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index bf766f204..b47ce1f3f 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -1175,7 +1175,7 @@ extend_filter() { } extend_filter_LVMTEST() { - extend_filter "a|$DM_DEV_DIR/$PREFIX|" + extend_filter "a|$DM_DEV_DIR/$PREFIX|" "$@" } hide_dev() { diff --git a/test/shell/lvmetad-pvscan-md.sh b/test/shell/lvmetad-pvscan-md.sh index 4d4dae2a4..5fb4d502d 100644 --- a/test/shell/lvmetad-pvscan-md.sh +++ b/test/shell/lvmetad-pvscan-md.sh @@ -25,8 +25,7 @@ aux prepare_devs 2 aux prepare_md_dev 0 64 2 "$dev1" "$dev2" aux lvmconf 'devices/md_component_detection = 1' -aux extend_filter_LVMTEST -aux extend_filter "a|/dev/md.*|" +aux extend_filter_LVMTEST "a|/dev/md|" pvdev=$(< MD_DEV_PV) From a90de76fd8502644e8b42daf88fe055c82fb2abc Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 11:21:49 +0200 Subject: [PATCH 32/81] tests: checking scanning correctness --- test/shell/pvcreate-md-fake-hdr.sh | 93 ++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 test/shell/pvcreate-md-fake-hdr.sh diff --git a/test/shell/pvcreate-md-fake-hdr.sh b/test/shell/pvcreate-md-fake-hdr.sh new file mode 100644 index 000000000..acd6785cb --- /dev/null +++ b/test/shell/pvcreate-md-fake-hdr.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +# Copyright (C) 2018 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +# TODO: once code get fixed, add matching 'check' calls +SKIP_WITH_LVMLOCKD=1 +SKIP_WITH_LVMPOLLD=1 + +. lib/inittest + +test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \ + modprobe raid1 || skip + +aux lvmconf 'devices/md_component_detection = 1' +aux extend_filter_LVMTEST "a|/dev/md|" + +aux prepare_devs 4 + +vgcreate $vg "$dev3" "$dev4" + +# create 2 disk MD raid1 array +# by default using metadata format 1.0 with data at the end of device +aux prepare_md_dev 1 64 2 "$dev1" "$dev2" + +mddev=$(< MD_DEV) +pvdev=$(< MD_DEV_PV) + +mdadm --stop "$mddev" + +# copy fake PV/VG header PV3 -> PV2 (which is however md raid1 leg) +dd if="$dev3" of="$dev2" bs=64k count=1 conv=fdatasync + +# remove VG on PV3 & PV4 +vgremove -f $vg + +sleep 3 +aux udev_wait +# too bad 'dd' wakes up md array reassembling +should not mdadm --detail "$mddev" +should not mdadm --stop "$mddev" +sleep 3 + +# print what blkid thinks about each PV +for i in "$dev1" "$dev2" "$dev3" "$dev4" +do + blkid "$i" +done + +# expect open count for each PV to be 0 +dmsetup info -c + +pvs -vvvv "$dev2" "$dev3" || true + +# still expect open count for each PV to be 0 +dmsetup info -c + +pvs -vvvv "$dev3" "$dev2" || true + +# and again we expect open count for each PV to be 0 +dmsetup info -c +dmsetup table + +# even after 3 second of possible hidden raid array assembling +sleep 3 +dmsetup info -c + +# if for any reason array went up - stop it again +mdadm --detail "$mddev" && { + mdadm --stop "$mddev" + aux udev_wait + should not mdadm --detail "$mddev" +} + +# now reassemble array from PV1 & PV2 +mdadm --assemble --verbose "$mddev" "$dev1" "$dev2" +aux udev_wait +sleep 1 + +# and let 'fake hdr' to be fixed from master/primary leg +mdadm --action=repair "$mddev" +sleep 1 + +# should be showing correctly PV3 & PV4 +pvs From 9337ff48bcf5ed60a06c8cea8daafc855653e493 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 24 May 2018 12:18:03 +0100 Subject: [PATCH 33/81] release note: 2.02.178 --- doc/release-notes/2.02.178 | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 doc/release-notes/2.02.178 diff --git a/doc/release-notes/2.02.178 b/doc/release-notes/2.02.178 new file mode 100644 index 000000000..3a53eaba6 --- /dev/null +++ b/doc/release-notes/2.02.178 @@ -0,0 +1,53 @@ +Version 2.02.178 +================ + +There are going to be some large changes to the lvm2 codebase +over the next year or so. Starting with this release. These +changes should be internal rather than having a big effect on +the command line. Inevitably these changes will increase the +chance of bugs, so please be on the alert. + + +Remove support for obsolete metadata formats +-------------------------------------------- + +Support for the GFS pool format, and format used by the +original 1990's version of LVM1 have been removed. + +Use asynchronous IO +------------------- + +Almost all IO uses libaio now. + +Rewrite label scanning +---------------------- + +Dave Tiegland has reworked the label scanning and metadata reading +logic to minimise the amount a IOs issued. Combined with the aio changes +this can greatly improve scanning speed for some systems. + +./configure options +------------------- + +We're going to try and remove as many options from ./configure as we +can. Each option multiplies the number of possible configurations +that we should test (this testing is currently not occuring). + +The first batch to be removed are: + + --enable-testing switch for ./configure has been removed. + --with-snapshots switch for ./configure has been removed. + --with-mirrors switch for ./configure has been removed. + --with-raid switch for ./configure has been removed. + --with-thin switch for ./configure has been removed. + --with-cache switch for ./configure has been removed. + +Stable targets that are in the upstream kernel will just be supported. + +In future optional target flags will be given in two situations: + +1) The target is experimental, or not upstream at all (eg, vdo). +2) The target is deprecated and support will be removed at some future date. + +This decision could well be contentious, so could distro maintainers feel +free to comment. From fab063cfcbbe2e3801ba2af7d061059eb37a7eaa Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 24 May 2018 12:26:34 +0100 Subject: [PATCH 34/81] release note: typo --- doc/release-notes/2.02.178 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/release-notes/2.02.178 b/doc/release-notes/2.02.178 index 3a53eaba6..f986d1d70 100644 --- a/doc/release-notes/2.02.178 +++ b/doc/release-notes/2.02.178 @@ -22,7 +22,7 @@ Almost all IO uses libaio now. Rewrite label scanning ---------------------- -Dave Tiegland has reworked the label scanning and metadata reading +Dave Teigland has reworked the label scanning and metadata reading logic to minimise the amount a IOs issued. Combined with the aio changes this can greatly improve scanning speed for some systems. From 7e85361c34ec539880fe8e764e4b49fc55f78a09 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 24 May 2018 12:32:16 +0100 Subject: [PATCH 35/81] release note: typos --- doc/release-notes/2.02.178 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/release-notes/2.02.178 b/doc/release-notes/2.02.178 index f986d1d70..5b4319e13 100644 --- a/doc/release-notes/2.02.178 +++ b/doc/release-notes/2.02.178 @@ -23,7 +23,7 @@ Rewrite label scanning ---------------------- Dave Teigland has reworked the label scanning and metadata reading -logic to minimise the amount a IOs issued. Combined with the aio changes +logic to minimise the amount of IOs issued. Combined with the aio changes this can greatly improve scanning speed for some systems. ./configure options @@ -31,16 +31,16 @@ this can greatly improve scanning speed for some systems. We're going to try and remove as many options from ./configure as we can. Each option multiplies the number of possible configurations -that we should test (this testing is currently not occuring). +that we should test (this testing is currently not occurring). The first batch to be removed are: - --enable-testing switch for ./configure has been removed. - --with-snapshots switch for ./configure has been removed. - --with-mirrors switch for ./configure has been removed. - --with-raid switch for ./configure has been removed. - --with-thin switch for ./configure has been removed. - --with-cache switch for ./configure has been removed. + --enable-testing + --with-snapshots + --with-mirrors + --with-raid + --with-thin + --with-cache Stable targets that are in the upstream kernel will just be supported. From adae8ee1c2926d59c85dc9fc253375f07f262819 Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Thu, 24 May 2018 15:13:10 +0200 Subject: [PATCH 36/81] pre-release --- VERSION | 2 +- VERSION_DM | 2 +- WHATS_NEW | 21 ++++++++------------- WHATS_NEW_DM | 4 ++-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index 586bf0fba..1594f3246 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.02.178(2)-git (2017-12-18) +2.02.178(2)-rc1 (2018-05-24) diff --git a/VERSION_DM b/VERSION_DM index d55b61b47..e95d765e4 100644 --- a/VERSION_DM +++ b/VERSION_DM @@ -1 +1 @@ -1.02.147-git (2017-12-18) +1.02.147-rc1 (2018-05-24) diff --git a/WHATS_NEW b/WHATS_NEW index 3d722da8c..620c9d539 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,16 +1,18 @@ -Version 2.02.178 - -===================================== +Version 2.02.178-rc1 - 24th May 2018 +==================================== + Add libaio dependency for build. Remove lvm1 and pool format handling and add filter to ignore them. Move some filter checks to after disks are read. Rework disk scanning and when it is used. Add new io layer and shift code to using it. - lvconvert: don't return success on degraded -m raid1 conversion + Fix lvconvert's return code on degraded -m raid1 conversion. --enable-testing switch for ./configure has been removed. --with-snapshots switch for ./configure has been removed. --with-mirrors switch for ./configure has been removed. --with-raid switch for ./configure has been removed. --with-thin switch for ./configure has been removed. --with-cache switch for ./configure has been removed. + Include new unit-test framework and unit tests. Extend validation of region_size for mirror segment. Reload whole device stack when reinitilizing mirror log. Mirrors without monitoring are WARNING and not blocking on error. @@ -34,8 +36,8 @@ Version 2.02.178 - Enhance mirror log initialization for old mirror target. Skip private crypto and stratis devices. Skip frozen raid devices from scanning. - Activate RAID SubLVs on read_only_volume_list readwrite - Offer convenience type raid5_n converting to raid10 + Activate RAID SubLVs on read_only_volume_list readwrite. + Offer convenience type raid5_n converting to raid10. Automatically avoid reading invalid snapshots during device scan. Ensure COW device is writable even for read-only thick snapshots. Support activation of component LVs in read-only mode. @@ -53,20 +55,13 @@ Version 2.02.178 - Improve validation of created strings in vgimportclone. Add missing initialisation of mem pool in systemd generator. Do not reopen output streams for multithreaded users of liblvm. - Use versionsort to fix archive file expiry beyond 100000 files. - Add devices/use_aio, aio_max, aio_memory to configure AIO limits. - Support asynchronous I/O when scanning devices. - Detect asynchronous I/O capability in configure or accept --disable-aio. - Add AIO_SUPPORTED_CODE_PATH to indicate whether AIO may be used. Configure ensures /usr/bin dir is checked for dmpd tools. Restore pvmove support for wide-clustered active volumes (2.02.177). Avoid non-exclusive activation of exclusive segment types. Fix trimming sibling PVs when doing a pvmove of raid subLVs. Preserve exclusive activation during thin snaphost merge. - Suppress some repeated reads of the same disk data at the device layer. Avoid exceeding array bounds in allocation tag processing. - Refactor metadata reading code to use callback functions. - Move memory allocation for the key dev_reads into the device layer. + Add --lockopt to common options and add option to skip selected locks. Version 2.02.177 - 18th December 2017 ===================================== diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 8fc3230be..a40ca4e85 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,5 @@ -Version 1.02.147 - -===================================== +Version 1.02.147-rc1 - 24th May 2018 +==================================== Reuse uname() result for mirror target. Recognize also mounted btrfs through dm_device_has_mounted_fs(). Add missing log_error() into dm_stats_populate() returning 0. From 264077907e7faa504ffa9fb3baa52b876cddc831 Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Thu, 24 May 2018 15:23:08 +0200 Subject: [PATCH 37/81] post-release --- VERSION | 2 +- VERSION_DM | 2 +- WHATS_NEW | 3 +++ WHATS_NEW_DM | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 1594f3246..51e0d33c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.02.178(2)-rc1 (2018-05-24) +2.02.178(2)-git (2018-05-24) diff --git a/VERSION_DM b/VERSION_DM index e95d765e4..1c2b36c53 100644 --- a/VERSION_DM +++ b/VERSION_DM @@ -1 +1 @@ -1.02.147-rc1 (2018-05-24) +1.02.147-git (2018-05-24) diff --git a/WHATS_NEW b/WHATS_NEW index 620c9d539..35695ab79 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,3 +1,6 @@ +Version 2.02.178 - +==================================== + Version 2.02.178-rc1 - 24th May 2018 ==================================== Add libaio dependency for build. diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index a40ca4e85..7a9401627 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,3 +1,6 @@ +Version 1.02.147 - +==================================== + Version 1.02.147-rc1 - 24th May 2018 ==================================== Reuse uname() result for mirror target. From d6f244599623ef547fe2c5f70e21abf4cce9a49d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 15:01:52 +0200 Subject: [PATCH 38/81] man: another missed typo for thin plugin --- man/dmeventd.8_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/dmeventd.8_main b/man/dmeventd.8_main index 98b1b98d3..06f8f58c5 100644 --- a/man/dmeventd.8_main +++ b/man/dmeventd.8_main @@ -123,7 +123,7 @@ Command is executed with environmental variable in this environment will not try to interact with dmeventd. To see the fullness of a thin pool command may check these two environmental variables -\fBDMEVENTD_THIN_POOL_DATA\fP and \fBDMEVENTD_THIN_POOL_DATA\fP. +\fBDMEVENTD_THIN_POOL_DATA\fP and \fBDMEVENTD_THIN_POOL_METADATA\fP. Command can also read status with tools like \fBlvs\fP(8). . .SH ENVIRONMENT VARIABLES From 3702f39ef3e1bb7811427df3fe92235890228fc0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 24 May 2018 15:20:22 +0200 Subject: [PATCH 39/81] tests: improve usability on older systems --- test/shell/pvcreate-md-fake-hdr.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/shell/pvcreate-md-fake-hdr.sh b/test/shell/pvcreate-md-fake-hdr.sh index acd6785cb..50a5b1495 100644 --- a/test/shell/pvcreate-md-fake-hdr.sh +++ b/test/shell/pvcreate-md-fake-hdr.sh @@ -33,7 +33,7 @@ aux prepare_md_dev 1 64 2 "$dev1" "$dev2" mddev=$(< MD_DEV) pvdev=$(< MD_DEV_PV) - +sleep 3 mdadm --stop "$mddev" # copy fake PV/VG header PV3 -> PV2 (which is however md raid1 leg) @@ -52,7 +52,7 @@ sleep 3 # print what blkid thinks about each PV for i in "$dev1" "$dev2" "$dev3" "$dev4" do - blkid "$i" + blkid -c /dev/null -w /dev/null "$i" || echo "Unknown signature" done # expect open count for each PV to be 0 @@ -74,20 +74,21 @@ sleep 3 dmsetup info -c # if for any reason array went up - stop it again -mdadm --detail "$mddev" && { +if mdadm --detail "$mddev" ; then mdadm --stop "$mddev" aux udev_wait should not mdadm --detail "$mddev" -} +fi -# now reassemble array from PV1 & PV2 +# now reassemble array from PV1 & PV2 mdadm --assemble --verbose "$mddev" "$dev1" "$dev2" aux udev_wait sleep 1 # and let 'fake hdr' to be fixed from master/primary leg -mdadm --action=repair "$mddev" -sleep 1 - -# should be showing correctly PV3 & PV4 -pvs +# (when mdadm supports repair) +if mdadm --action=repair "$mddev" ; then + sleep 1 + # should be showing correctly PV3 & PV4 + pvs +fi From 9a730233c935085ec5de9440796daa0d416ba4ba Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 9 Feb 2018 01:08:55 +0000 Subject: [PATCH 40/81] format_text: Use versionsort to sort archive files Ensure that vg_100000-* follows vg_99999-* so that the expiry logic doesn't stop too early. https://bugzilla.redhat.com/1481085 --- WHATS_NEW | 1 + lib/format_text/archive.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 35695ab79..25707ab84 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.178 - ==================================== + Use versionsort to fix archive file expiry beyond 100000 files. Version 2.02.178-rc1 - 24th May 2018 ==================================== diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c index 690bc7408..533e91ce6 100644 --- a/lib/format_text/archive.c +++ b/lib/format_text/archive.c @@ -135,8 +135,8 @@ static struct dm_list *_scan_archive(struct dm_pool *mem, dm_list_init(results); - /* Sort fails beyond 5-digit indexes */ - if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) { + /* Use versionsort to handle numbers beyond 5 digits */ + if ((count = scandir(dir, &dirent, NULL, versionsort)) < 0) { log_error("Couldn't scan the archive directory (%s).", dir); return 0; } From 28c8e95d197bf512a39b561281162ff4d93a598e Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 11:14:12 -0500 Subject: [PATCH 41/81] scan: refresh paths and retry open If scanning fails to open any devices, refresh the device paths in dev cache, and retry the opens. --- lib/device/dev-cache.c | 2 + lib/label/label.c | 115 +++++++++++++++++++++++++--- test/shell/pvcreate-operation-md.sh | 6 ++ 3 files changed, 112 insertions(+), 11 deletions(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 975fc125a..dd0155808 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -1079,6 +1079,8 @@ 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; diff --git a/lib/label/label.c b/lib/label/label.c index b9227f54f..8ecaa6165 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -427,7 +427,11 @@ static int _process_block(struct cmd_context *cmd, struct dev_filter *f, static int _scan_dev_open(struct device *dev) { + struct dm_list *name_list; + struct dm_str_list *name_sl; const char *name; + struct stat sbuf; + int retried = 0; int flags = 0; int fd; @@ -435,20 +439,30 @@ static int _scan_dev_open(struct device *dev) return 0; if (dev->flags & DEV_IN_BCACHE) { - log_error("scan_dev_open %s DEV_IN_BCACHE already set", dev_name(dev)); + /* Shouldn't happen */ + log_error("Device open %s has DEV_IN_BCACHE already set", dev_name(dev)); dev->flags &= ~DEV_IN_BCACHE; } if (dev->bcache_fd > 0) { - log_error("scan_dev_open %s already open with fd %d", + /* Shouldn't happen */ + log_error("Device open %s already open with fd %d", dev_name(dev), dev->bcache_fd); return 0; } - if (!(name = dev_name_confirmed(dev, 1))) { - log_error("scan_dev_open %s no name", dev_name(dev)); + /* + * All the names for this device (major:minor) are kept on + * dev->aliases, the first one is the primary/preferred name. + */ + if (!(name_list = dm_list_first(&dev->aliases))) { + /* Shouldn't happen */ + log_error("Device open %s %d:%d has no path names.", + dev_name(dev), (int)MAJOR(dev->dev), (int)MINOR(dev->dev)); return 0; } + name_sl = dm_list_item(name_list, struct dm_str_list); + name = name_sl->str; flags |= O_RDWR; flags |= O_DIRECT; @@ -457,6 +471,8 @@ static int _scan_dev_open(struct device *dev) if (dev->flags & DEV_BCACHE_EXCL) flags |= O_EXCL; +retry_open: + fd = open(name, flags, 0777); if (fd < 0) { @@ -464,7 +480,48 @@ static int _scan_dev_open(struct device *dev) log_error("Can't open %s exclusively. Mounted filesystem?", dev_name(dev)); } else { - log_error("scan_dev_open %s failed errno %d", dev_name(dev), errno); + int major, minor; + + /* + * Shouldn't happen, if it does, print stat info to help figure + * out what's wrong. + */ + + major = (int)MAJOR(dev->dev); + minor = (int)MINOR(dev->dev); + + log_error("Device open %s %d:%d failed errno %d", name, major, minor, errno); + + if (stat(name, &sbuf)) { + log_debug_devs("Device open %s %d:%d stat failed errno %d", + name, major, minor, errno); + } else if (sbuf.st_rdev != dev->dev) { + log_debug_devs("Device open %s %d:%d stat %d:%d does not match.", + name, major, minor, + (int)MAJOR(sbuf.st_rdev), (int)MINOR(sbuf.st_rdev)); + } + + /* + * FIXME: do we want to try opening this device using + * one of the other path aliases for the same + * major:minor from dev->aliases? We could iterate + * through those aliases to try opening each of them to + * find one that works. What are the consequences of + * using a different, non-preferred alias to a device? + */ + + if (!retried) { + /* + * FIXME: remove this, the theory for this retry is that + * there may be a udev race that we can sometimes mask by + * retrying. This is here until we can figure out if it's + * needed and if so fix the real problem. + */ + usleep(5000); + log_debug_devs("Device open %s retry", dev_name(dev)); + retried = 1; + goto retry_open; + } } return 0; } @@ -509,9 +566,10 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, { struct dm_list wait_devs; struct dm_list done_devs; + struct dm_list reopen_devs; struct device_list *devl, *devl2; struct block *bb; - int scan_open_errors = 0; + int retried_open = 0; int scan_read_errors = 0; int scan_process_errors = 0; int scan_failed_count = 0; @@ -524,6 +582,7 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, dm_list_init(&wait_devs); dm_list_init(&done_devs); + dm_list_init(&reopen_devs); log_debug_devs("Scanning %d devices for VG info", dm_list_size(devs)); @@ -547,9 +606,7 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, if (!_scan_dev_open(devl->dev)) { log_debug_devs("Scan failed to open %s.", dev_name(devl->dev)); dm_list_del(&devl->list); - dm_list_add(&done_devs, &devl->list); - scan_open_errors++; - scan_failed_count++; + dm_list_add(&reopen_devs, &devl->list); continue; } } @@ -612,8 +669,44 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, if (!dm_list_empty(devs)) goto scan_more; - log_debug_devs("Scanned devices: open errors %d read errors %d process errors %d", - scan_open_errors, scan_read_errors, scan_process_errors); + /* + * We're done scanning all the devs. If we failed to open any of them + * the first time through, refresh device paths and retry. We failed + * to open the devs on the reopen_devs list. + * + * FIXME: it's not clear if or why this helps. + * + * FIXME: should we delete the first path name from dev->aliases that + * we failed to open the first time before retrying? If that path + * still exists on the system, dev_cache_scan should put it back, but + * if it doesn't exist we don't want to try using it again. + */ + if (!dm_list_empty(&reopen_devs)) { + if (retried_open) { + /* Don't try again. */ + scan_failed_count += dm_list_size(&reopen_devs); + dm_list_splice(&done_devs, &reopen_devs); + goto out; + } + retried_open = 1; + + /* + * This will search the system's /dev for new path names and + * could help us reopen the device if it finds a new preferred + * path name for this dev's major:minor. It does that by + * inserting a new preferred path name on dev->aliases. open + * uses the first name from that list. + */ + log_debug_devs("Scanning refreshing device paths."); + dev_cache_scan(); + + /* Put devs that failed to open back on the original list to retry. */ + dm_list_splice(devs, &reopen_devs); + goto scan_more; + } +out: + log_debug_devs("Scanned devices: read errors %d process errors %d failed %d", + scan_read_errors, scan_process_errors, scan_failed_count); if (failed) *failed = scan_failed_count; diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh index 359113daa..f5347850e 100644 --- a/test/shell/pvcreate-operation-md.sh +++ b/test/shell/pvcreate-operation-md.sh @@ -90,6 +90,12 @@ EOF maj=$(($(stat -L --printf=0x%t "${mddev}p1"))) min=$(($(stat -L --printf=0x%T "${mddev}p1"))) + ls /sys/dev/block/$maj:$min/ + ls /sys/dev/block/$maj:$min/holders/ + cat /sys/dev/block/$maj:$min/dev + cat /sys/dev/block/$maj:$min/stat + cat /sys/dev/block/$maj:$min/size + sysfs_alignment_offset="/sys/dev/block/$maj:$min/alignment_offset" [ -f "$sysfs_alignment_offset" ] && \ alignment_offset=$(< "$sysfs_alignment_offset") || \ From 033df741e2e771b3abda3e190ed9c359d579ce4a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 May 2018 11:03:10 +0100 Subject: [PATCH 42/81] data-struct/radix-tree: pass the value dtr into create. Rather than having to pass it into every method that removes items. --- base/data-struct/radix-tree.c | 10 +++++++--- base/data-struct/radix-tree.h | 7 +++---- test/unit/radix_tree_t.c | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index b4b6791dd..c50bd43f8 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -74,17 +74,21 @@ struct node256 { struct radix_tree { unsigned nr_entries; struct value root; + radix_value_dtr dtr; + void *dtr_context; }; //---------------------------------------------------------------- -struct radix_tree *radix_tree_create(void) +struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context) { struct radix_tree *rt = malloc(sizeof(*rt)); if (rt) { rt->nr_entries = 0; rt->root.type = UNSET; + rt->dtr = dtr; + rt->dtr_context = dtr_context; } return rt; @@ -153,9 +157,9 @@ static void _free_node(struct value v, radix_value_dtr dtr, void *context) } } -void radix_tree_destroy(struct radix_tree *rt, radix_value_dtr dtr, void *context) +void radix_tree_destroy(struct radix_tree *rt) { - _free_node(rt->root, dtr, context); + _free_node(rt->root, rt->dtr, rt->dtr_context); free(rt); } diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h index d84e3c54e..13ab4cde9 100644 --- a/base/data-struct/radix-tree.h +++ b/base/data-struct/radix-tree.h @@ -25,12 +25,11 @@ union radix_value { uint64_t n; }; -struct radix_tree *radix_tree_create(void); - typedef void (*radix_value_dtr)(void *context, union radix_value v); -// dtr may be NULL -void radix_tree_destroy(struct radix_tree *rt, radix_value_dtr dtr, void *context); +// dtr will be called on any deleted entries. dtr may be NULL. +struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context); +void radix_tree_destroy(struct radix_tree *rt); unsigned radix_tree_size(struct radix_tree *rt); bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v); diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index 4455f2b04..245ec8d8a 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -21,14 +21,14 @@ static void *rt_init(void) { - struct radix_tree *rt = radix_tree_create(); + struct radix_tree *rt = radix_tree_create(NULL, NULL); T_ASSERT(rt); return rt; } static void rt_exit(void *fixture) { - radix_tree_destroy(fixture, NULL, NULL); + radix_tree_destroy(fixture); } static void test_create_destroy(void *fixture) From 9b41efae826257ecfd9400d6a9d17d7e98e822dc Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 May 2018 11:23:36 +0100 Subject: [PATCH 43/81] radix-tree: call the value dtr when removing an entry. --- base/data-struct/radix-tree.c | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 3df85e77b..26748e306 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -95,7 +95,13 @@ struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context) return rt; } -static void _free_node(struct value v, radix_value_dtr dtr, void *context) +static inline void _dtr(struct radix_tree *rt, union radix_value v) +{ + if (rt->dtr) + rt->dtr(rt->dtr_context, v); +} + +static void _free_node(struct radix_tree *rt, struct value v) { unsigned i; struct value_chain *vc; @@ -110,49 +116,47 @@ static void _free_node(struct value v, radix_value_dtr dtr, void *context) break; case VALUE: - if (dtr) - dtr(context, v.value); + _dtr(rt, v.value); break; case VALUE_CHAIN: vc = v.value.ptr; - if (dtr) - dtr(context, vc->value); - _free_node(vc->child, dtr, context); + _dtr(rt, vc->value); + _free_node(rt, vc->child); free(vc); break; case PREFIX_CHAIN: pc = v.value.ptr; - _free_node(pc->child, dtr, context); + _free_node(rt, pc->child); free(pc); break; case NODE4: n4 = (struct node4 *) v.value.ptr; for (i = 0; i < n4->nr_entries; i++) - _free_node(n4->values[i], dtr, context); + _free_node(rt, n4->values[i]); free(n4); break; case NODE16: n16 = (struct node16 *) v.value.ptr; for (i = 0; i < n16->nr_entries; i++) - _free_node(n16->values[i], dtr, context); + _free_node(rt, n16->values[i]); free(n16); break; case NODE48: n48 = (struct node48 *) v.value.ptr; for (i = 0; i < n48->nr_entries; i++) - _free_node(n48->values[i], dtr, context); + _free_node(rt, n48->values[i]); free(n48); break; case NODE256: n256 = (struct node256 *) v.value.ptr; for (i = 0; i < 256; i++) - _free_node(n256->values[i], dtr, context); + _free_node(rt, n256->values[i]); free(n256); break; } @@ -160,7 +164,7 @@ static void _free_node(struct value v, radix_value_dtr dtr, void *context) void radix_tree_destroy(struct radix_tree *rt) { - _free_node(rt->root, rt->dtr, rt->dtr_context); + _free_node(rt, rt->root); free(rt); } @@ -593,7 +597,7 @@ static void _degrade_to_n48(struct node256 *n256, struct value *result) result->value.ptr = n48; } -static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) +static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke) { bool r; unsigned i; @@ -607,10 +611,12 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) if (kb == ke) { if (root->type == VALUE) { root->type = UNSET; + _dtr(rt, root->value); return true; } else if (root->type == VALUE_CHAIN) { vc = root->value.ptr; + _dtr(rt, vc->value); memcpy(root, &vc->child, sizeof(*root)); free(vc); return true; @@ -627,7 +633,7 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) case VALUE_CHAIN: vc = root->value.ptr; - r = _remove(&vc->child, kb, ke); + r = _remove(rt, &vc->child, kb, ke); if (r && (vc->child.type == UNSET)) { memcpy(root, &vc->child, sizeof(*root)); free(vc); @@ -643,13 +649,13 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) if (kb[i] != pc->prefix[i]) return false; - return _remove(&pc->child, kb + pc->len, ke); + return _remove(rt, &pc->child, kb + pc->len, ke); case NODE4: n4 = root->value.ptr; for (i = 0; i < n4->nr_entries; i++) { if (n4->keys[i] == *kb) { - r = _remove(n4->values + i, kb + 1, ke); + r = _remove(rt, n4->values + i, kb + 1, ke); if (r && n4->values[i].type == UNSET) { n4->nr_entries--; if (i < n4->nr_entries) @@ -668,7 +674,7 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) n16 = root->value.ptr; for (i = 0; i < n16->nr_entries; i++) { if (n16->keys[i] == *kb) { - r = _remove(n16->values + i, kb + 1, ke); + r = _remove(rt, n16->values + i, kb + 1, ke); if (r && n16->values[i].type == UNSET) { n16->nr_entries--; if (i < n16->nr_entries) @@ -687,7 +693,7 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) n48 = root->value.ptr; i = n48->keys[*kb]; if (i < 48) { - r = _remove(n48->values + i, kb + 1, ke); + r = _remove(rt, n48->values + i, kb + 1, ke); if (r && n48->values[i].type == UNSET) { n48->keys[*kb] = 48; n48->nr_entries--; @@ -700,7 +706,7 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) case NODE256: n256 = root->value.ptr; - r = _remove(n256->values + (*kb), kb + 1, ke); + r = _remove(rt, n256->values + (*kb), kb + 1, ke); if (r && n256->values[*kb].type == UNSET) { n256->nr_entries--; if (n256->nr_entries <= 48) @@ -714,7 +720,7 @@ static bool _remove(struct value *root, uint8_t *kb, uint8_t *ke) bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end) { - if (_remove(&rt->root, key_begin, key_end)) { + if (_remove(rt, &rt->root, key_begin, key_end)) { rt->nr_entries--; return true; } From c2a8bbed3bc8c5c4f505a7cecc4db0b94e7243bc Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 May 2018 13:25:59 +0100 Subject: [PATCH 44/81] radix-tree: radix_tree_remove_prefix() --- base/data-struct/radix-tree.c | 33 +++++++++++++++++++++++++-------- base/data-struct/radix-tree.h | 4 ++++ test/unit/radix_tree_t.c | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 26748e306..5688decb6 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -101,9 +101,10 @@ static inline void _dtr(struct radix_tree *rt, union radix_value v) rt->dtr(rt->dtr_context, v); } -static void _free_node(struct radix_tree *rt, struct value v) +// Returns the number of values removed +static unsigned _free_node(struct radix_tree *rt, struct value v) { - unsigned i; + unsigned i, nr = 0; struct value_chain *vc; struct prefix_chain *pc; struct node4 *n4; @@ -117,49 +118,52 @@ static void _free_node(struct radix_tree *rt, struct value v) case VALUE: _dtr(rt, v.value); + nr = 1; break; case VALUE_CHAIN: vc = v.value.ptr; _dtr(rt, vc->value); - _free_node(rt, vc->child); + nr = 1 + _free_node(rt, vc->child); free(vc); break; case PREFIX_CHAIN: pc = v.value.ptr; - _free_node(rt, pc->child); + nr = _free_node(rt, pc->child); free(pc); break; case NODE4: n4 = (struct node4 *) v.value.ptr; for (i = 0; i < n4->nr_entries; i++) - _free_node(rt, n4->values[i]); + nr += _free_node(rt, n4->values[i]); free(n4); break; case NODE16: n16 = (struct node16 *) v.value.ptr; for (i = 0; i < n16->nr_entries; i++) - _free_node(rt, n16->values[i]); + nr += _free_node(rt, n16->values[i]); free(n16); break; case NODE48: n48 = (struct node48 *) v.value.ptr; for (i = 0; i < n48->nr_entries; i++) - _free_node(rt, n48->values[i]); + nr += _free_node(rt, n48->values[i]); free(n48); break; case NODE256: n256 = (struct node256 *) v.value.ptr; for (i = 0; i < 256; i++) - _free_node(rt, n256->values[i]); + nr += _free_node(rt, n256->values[i]); free(n256); break; } + + return nr; } void radix_tree_destroy(struct radix_tree *rt) @@ -728,6 +732,19 @@ bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_e return false; } +unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke) +{ + unsigned count = 0; + struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); + if (lr.kb == ke) { + count = _free_node(rt, *lr.v); + lr.v->type = UNSET; + } + + rt->nr_entries -= count; + return count; +} + bool radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result) { diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h index 8560b3495..ad8a952a5 100644 --- a/base/data-struct/radix-tree.h +++ b/base/data-struct/radix-tree.h @@ -34,6 +34,10 @@ void radix_tree_destroy(struct radix_tree *rt); unsigned radix_tree_size(struct radix_tree *rt); bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v); bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke); + +// Returns the number of values removed +unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *prefix_b, uint8_t *prefix_e); + bool radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result); diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index d2b0adc87..eb3577340 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -267,6 +267,27 @@ static void test_remove_prefix_keys_reversed(void *fixture) T_ASSERT(!radix_tree_lookup(rt, k, k + i, &v)); } +static void test_remove_prefix(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, count = 0; + uint8_t k[4]; + union radix_value v; + + // populate some random 32bit keys + for (i = 0; i < 100000; i++) { + _gen_key(k, k + sizeof(k)); + if (k[0] == 21) + count++; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + // remove keys in a sub range + k[0] = 21; + T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 1), count); +} + //---------------------------------------------------------------- #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) @@ -291,6 +312,7 @@ void radix_tree_tests(struct dm_list *all_tests) T("remove-one-byte-keys", "remove many one byte keys", test_remove_one_byte_keys); T("remove-prefix-keys", "remove a set of keys that have common prefixes", test_remove_prefix_keys); T("remove-prefix-keys-reversed", "remove a set of keys that have common prefixes (reversed)", test_remove_prefix_keys_reversed); + T("remove-prefix", "remove a subrange", test_remove_prefix); dm_list_add(all_tests, &ts->list); } From 1924426ad1e8a569c168e3d85c368ed531f382fe Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 May 2018 17:58:58 +0100 Subject: [PATCH 45/81] radix-tree: radix_tree_iterate() --- base/data-struct/radix-tree.c | 142 +++++++++++++++++++++++++--------- base/data-struct/radix-tree.h | 12 +++ test/unit/radix_tree_t.c | 82 ++++++++++++++++++++ 3 files changed, 201 insertions(+), 35 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 5688decb6..8e8ac9004 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -172,9 +172,14 @@ void radix_tree_destroy(struct radix_tree *rt) free(rt); } -static bool _insert(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv); +unsigned radix_tree_size(struct radix_tree *rt) +{ + return rt->nr_entries; +} -static bool _insert_unset(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv); + +static bool _insert_unset(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { unsigned len = ke - kb; @@ -182,6 +187,7 @@ static bool _insert_unset(struct value *v, uint8_t *kb, uint8_t *ke, union radix // value v->type = VALUE; v->value = rv; + rt->nr_entries++; } else { // prefix -> value struct prefix_chain *pc = zalloc(sizeof(*pc) + len); @@ -194,12 +200,13 @@ static bool _insert_unset(struct value *v, uint8_t *kb, uint8_t *ke, union radix memcpy(pc->prefix, kb, len); v->type = PREFIX_CHAIN; v->value.ptr = pc; + rt->nr_entries++; } return true; } -static bool _insert_value(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_value(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { unsigned len = ke - kb; @@ -214,7 +221,7 @@ static bool _insert_value(struct value *v, uint8_t *kb, uint8_t *ke, union radix return false; vc->value = v->value; - if (!_insert(&vc->child, kb, ke, rv)) { + if (!_insert(rt, &vc->child, kb, ke, rv)) { free(vc); return false; } @@ -226,10 +233,10 @@ static bool _insert_value(struct value *v, uint8_t *kb, uint8_t *ke, union radix return true; } -static bool _insert_value_chain(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_value_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct value_chain *vc = v->value.ptr; - return _insert(&vc->child, kb, ke, rv); + return _insert(rt, &vc->child, kb, ke, rv); } static unsigned min(unsigned lhs, unsigned rhs) @@ -240,7 +247,7 @@ static unsigned min(unsigned lhs, unsigned rhs) return rhs; } -static bool _insert_prefix_chain(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct prefix_chain *pc = v->value.ptr; @@ -264,7 +271,7 @@ static bool _insert_prefix_chain(struct value *v, uint8_t *kb, uint8_t *ke, unio pc->child.value.ptr = pc2; pc->len = i; - if (!_insert(&pc->child, kb + i, ke, rv)) { + if (!_insert(rt, &pc->child, kb + i, ke, rv)) { free(pc2); return false; } @@ -276,7 +283,7 @@ static bool _insert_prefix_chain(struct value *v, uint8_t *kb, uint8_t *ke, unio return false; n4->keys[0] = *kb; - if (!_insert(n4->values, kb + 1, ke, rv)) { + if (!_insert(rt, n4->values, kb + 1, ke, rv)) { free(n4); return false; } @@ -302,7 +309,7 @@ static bool _insert_prefix_chain(struct value *v, uint8_t *kb, uint8_t *ke, unio return true; } -static bool _insert_node4(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_node4(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct node4 *n4 = v->value.ptr; if (n4->nr_entries == 4) { @@ -315,7 +322,7 @@ static bool _insert_node4(struct value *v, uint8_t *kb, uint8_t *ke, union radix memcpy(n16->values, n4->values, sizeof(n4->values)); n16->keys[4] = *kb; - if (!_insert(n16->values + 4, kb + 1, ke, rv)) { + if (!_insert(rt, n16->values + 4, kb + 1, ke, rv)) { free(n16); return false; } @@ -324,7 +331,7 @@ static bool _insert_node4(struct value *v, uint8_t *kb, uint8_t *ke, union radix v->value.ptr = n16; } else { n4 = v->value.ptr; - if (!_insert(n4->values + n4->nr_entries, kb + 1, ke, rv)) + if (!_insert(rt, n4->values + n4->nr_entries, kb + 1, ke, rv)) return false; n4->keys[n4->nr_entries] = *kb; @@ -333,7 +340,7 @@ static bool _insert_node4(struct value *v, uint8_t *kb, uint8_t *ke, union radix return true; } -static bool _insert_node16(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct node16 *n16 = v->value.ptr; @@ -353,7 +360,7 @@ static bool _insert_node16(struct value *v, uint8_t *kb, uint8_t *ke, union radi } n48->keys[*kb] = 16; - if (!_insert(n48->values + 16, kb + 1, ke, rv)) { + if (!_insert(rt, n48->values + 16, kb + 1, ke, rv)) { free(n48); return false; } @@ -362,7 +369,7 @@ static bool _insert_node16(struct value *v, uint8_t *kb, uint8_t *ke, union radi v->type = NODE48; v->value.ptr = n48; } else { - if (!_insert(n16->values + n16->nr_entries, kb + 1, ke, rv)) + if (!_insert(rt, n16->values + n16->nr_entries, kb + 1, ke, rv)) return false; n16->keys[n16->nr_entries] = *kb; n16->nr_entries++; @@ -371,7 +378,7 @@ static bool _insert_node16(struct value *v, uint8_t *kb, uint8_t *ke, union radi return true; } -static bool _insert_node48(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_node48(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct node48 *n48 = v->value.ptr; if (n48->nr_entries == 48) { @@ -387,7 +394,7 @@ static bool _insert_node48(struct value *v, uint8_t *kb, uint8_t *ke, union radi n256->values[i] = n48->values[n48->keys[i]]; } - if (!_insert(n256->values + *kb, kb + 1, ke, rv)) { + if (!_insert(rt, n256->values + *kb, kb + 1, ke, rv)) { free(n256); return false; } @@ -397,7 +404,7 @@ static bool _insert_node48(struct value *v, uint8_t *kb, uint8_t *ke, union radi v->value.ptr = n256; } else { - if (!_insert(n48->values + n48->nr_entries, kb + 1, ke, rv)) + if (!_insert(rt, n48->values + n48->nr_entries, kb + 1, ke, rv)) return false; n48->keys[*kb] = n48->nr_entries; @@ -407,12 +414,12 @@ static bool _insert_node48(struct value *v, uint8_t *kb, uint8_t *ke, union radi return true; } -static bool _insert_node256(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert_node256(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct node256 *n256 = v->value.ptr; bool was_unset = n256->values[*kb].type == UNSET; - if (!_insert(n256->values + *kb, kb + 1, ke, rv)) + if (!_insert(rt, n256->values + *kb, kb + 1, ke, rv)) return false; if (was_unset) @@ -422,12 +429,13 @@ static bool _insert_node256(struct value *v, uint8_t *kb, uint8_t *ke, union rad } // FIXME: the tree should not be touched if insert fails (eg, OOM) -static bool _insert(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) +static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv) { if (kb == ke) { if (v->type == UNSET) { v->type = VALUE; v->value = rv; + rt->nr_entries++; } else if (v->type == VALUE) { v->value = rv; @@ -441,34 +449,35 @@ static bool _insert(struct value *v, uint8_t *kb, uint8_t *ke, union radix_value vc->child = *v; v->type = VALUE_CHAIN; v->value.ptr = vc; + rt->nr_entries++; } return true; } switch (v->type) { case UNSET: - return _insert_unset(v, kb, ke, rv); + return _insert_unset(rt, v, kb, ke, rv); case VALUE: - return _insert_value(v, kb, ke, rv); + return _insert_value(rt, v, kb, ke, rv); case VALUE_CHAIN: - return _insert_value_chain(v, kb, ke, rv); + return _insert_value_chain(rt, v, kb, ke, rv); case PREFIX_CHAIN: - return _insert_prefix_chain(v, kb, ke, rv); + return _insert_prefix_chain(rt, v, kb, ke, rv); case NODE4: - return _insert_node4(v, kb, ke, rv); + return _insert_node4(rt, v, kb, ke, rv); case NODE16: - return _insert_node16(v, kb, ke, rv); + return _insert_node16(rt, v, kb, ke, rv); case NODE48: - return _insert_node48(v, kb, ke, rv); + return _insert_node48(rt, v, kb, ke, rv); case NODE256: - return _insert_node256(v, kb, ke, rv); + return _insert_node256(rt, v, kb, ke, rv); } // can't get here @@ -546,12 +555,7 @@ static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value rv) { struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); - if (_insert(lr.v, lr.kb, ke, rv)) { - rt->nr_entries++; - return true; - } - - return false; + return _insert(rt, lr.v, lr.kb, ke, rv); } // Note the degrade functions also free the original node. @@ -769,4 +773,72 @@ bool radix_tree_lookup(struct radix_tree *rt, return false; } +// FIXME: build up the keys too +static bool _iterate(struct value *v, struct radix_tree_iterator *it) +{ + unsigned i; + struct value_chain *vc; + struct prefix_chain *pc; + struct node4 *n4; + struct node16 *n16; + struct node48 *n48; + struct node256 *n256; + + switch (v->type) { + case UNSET: + // can't happen + break; + + case VALUE: + return it->visit(it, NULL, NULL, v->value); + + case VALUE_CHAIN: + vc = v->value.ptr; + return it->visit(it, NULL, NULL, vc->value) && _iterate(&vc->child, it); + + case PREFIX_CHAIN: + pc = v->value.ptr; + return _iterate(&pc->child, it); + + case NODE4: + n4 = (struct node4 *) v->value.ptr; + for (i = 0; i < n4->nr_entries; i++) + if (!_iterate(n4->values + i, it)) + return false; + return true; + + case NODE16: + n16 = (struct node16 *) v->value.ptr; + for (i = 0; i < n16->nr_entries; i++) + if (!_iterate(n16->values + i, it)) + return false; + return true; + + case NODE48: + n48 = (struct node48 *) v->value.ptr; + for (i = 0; i < n48->nr_entries; i++) + if (!_iterate(n48->values + i, it)) + return false; + return true; + + case NODE256: + n256 = (struct node256 *) v->value.ptr; + for (i = 0; i < 256; i++) + if (n256->values[i].type != UNSET && !_iterate(n256->values + i, it)) + return false; + return true; + } + + // can't get here + return false; +} + +void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, + struct radix_tree_iterator *it) +{ + struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); + if (lr.kb == ke) + _iterate(lr.v, it); +} + //---------------------------------------------------------------- diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h index ad8a952a5..1b6aee8f0 100644 --- a/base/data-struct/radix-tree.h +++ b/base/data-struct/radix-tree.h @@ -41,6 +41,18 @@ unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *prefix_b, uint bool radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result); +// The radix tree stores entries in lexicographical order. Which means +// we can iterate entries, in order. Or iterate entries with a particular +// prefix. +struct radix_tree_iterator { + // Returns false if the iteration should end. + bool (*visit)(struct radix_tree_iterator *it, + uint8_t *kb, uint8_t *ke, union radix_value v); +}; + +void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, + struct radix_tree_iterator *it); + //---------------------------------------------------------------- #endif diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index eb3577340..ba0d5e18e 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -11,6 +11,7 @@ // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "base/data-struct/radix-tree.h" +#include "base/memory/container_of.h" #include "units.h" @@ -288,6 +289,84 @@ static void test_remove_prefix(void *fixture) T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 1), count); } +static void test_size(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, dup_count = 0; + uint8_t k[2]; + union radix_value v; + + // populate some random 16bit keys + for (i = 0; i < 10000; i++) { + _gen_key(k, k + sizeof(k)); + if (radix_tree_lookup(rt, k, k + sizeof(k), &v)) + dup_count++; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + T_ASSERT_EQUAL(radix_tree_size(rt), 10000 - dup_count); +} + +struct visitor { + struct radix_tree_iterator it; + unsigned count; +}; + +static bool _visit(struct radix_tree_iterator *it, + uint8_t *kb, uint8_t *ke, union radix_value v) +{ + struct visitor *vt = container_of(it, struct visitor, it); + vt->count++; + return true; +} + +static void test_iterate_all(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i; + uint8_t k[4]; + union radix_value v; + struct visitor vt; + + // populate some random 32bit keys + for (i = 0; i < 100000; i++) { + _gen_key(k, k + sizeof(k)); + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + vt.count = 0; + vt.it.visit = _visit; + radix_tree_iterate(rt, NULL, NULL, &vt.it); + T_ASSERT_EQUAL(vt.count, radix_tree_size(rt)); +} + +static void test_iterate_subset(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i, subset_count = 0; + uint8_t k[3]; + union radix_value v; + struct visitor vt; + + // populate some random 32bit keys + for (i = 0; i < 100000; i++) { + _gen_key(k, k + sizeof(k)); + if (k[0] == 21 && k[1] == 12) + subset_count++; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + vt.count = 0; + vt.it.visit = _visit; + k[0] = 21; + k[1] = 12; + radix_tree_iterate(rt, k, k + 2, &vt.it); + T_ASSERT_EQUAL(vt.count, subset_count); +} + //---------------------------------------------------------------- #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) @@ -313,6 +392,9 @@ void radix_tree_tests(struct dm_list *all_tests) T("remove-prefix-keys", "remove a set of keys that have common prefixes", test_remove_prefix_keys); T("remove-prefix-keys-reversed", "remove a set of keys that have common prefixes (reversed)", test_remove_prefix_keys_reversed); T("remove-prefix", "remove a subrange", test_remove_prefix); + T("size-spots-duplicates", "duplicate entries aren't counted twice", test_size); + T("iterate-all", "iterate all entries in tree", test_iterate_all); + T("iterate-subset", "iterate a subset of entries in tree", test_iterate_subset); dm_list_add(all_tests, &ts->list); } From 272ec3fa73c92764ef6fe5466fc367fed66dd7f9 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 30 May 2018 14:14:59 +0100 Subject: [PATCH 46/81] radix-tree: fix some bugs in remove_prefix and iterate These weren't working if the prefix key was part of a prefix_chain. --- base/data-struct/radix-tree.c | 22 ++++++++++++-- test/unit/radix_tree_t.c | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 8e8ac9004..222b35047 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -736,11 +736,29 @@ bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_e return false; } +static bool _prefix_chain_matches(struct lookup_result *lr, uint8_t *ke) +{ + // It's possible the top node is a prefix chain, and + // the remaining key matches part of it. + if (lr->v->type == PREFIX_CHAIN) { + unsigned i, rlen = ke - lr->kb; + struct prefix_chain *pc = lr->v->value.ptr; + if (rlen < pc->len) { + for (i = 0; i < rlen; i++) + if (pc->prefix[i] != lr->kb[i]) + return false; + return true; + } + } + + return false; +} + unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke) { unsigned count = 0; struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); - if (lr.kb == ke) { + if (lr.kb == ke || _prefix_chain_matches(&lr, ke)) { count = _free_node(rt, *lr.v); lr.v->type = UNSET; } @@ -837,7 +855,7 @@ void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, struct radix_tree_iterator *it) { struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); - if (lr.kb == ke) + if (lr.kb == ke || _prefix_chain_matches(&lr, ke)) _iterate(lr.v, it); } diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index ba0d5e18e..7266a8a46 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -289,6 +289,18 @@ static void test_remove_prefix(void *fixture) T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 1), count); } +static void test_remove_prefix_single(void *fixture) +{ + struct radix_tree *rt = fixture; + uint8_t k[4]; + union radix_value v; + + _gen_key(k, k + sizeof(k)); + v.n = 1234; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 2), 1); +} + static void test_size(void *fixture) { struct radix_tree *rt = fixture; @@ -367,6 +379,47 @@ static void test_iterate_subset(void *fixture) T_ASSERT_EQUAL(vt.count, subset_count); } +static void test_iterate_single(void *fixture) +{ + struct radix_tree *rt = fixture; + uint8_t k[6]; + union radix_value v; + struct visitor vt; + + _gen_key(k, k + sizeof(k)); + v.n = 1234; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + + vt.count = 0; + vt.it.visit = _visit; + radix_tree_iterate(rt, k, k + 3, &vt.it); + T_ASSERT_EQUAL(vt.count, 1); +} + +static void test_iterate_vary_middle(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i; + uint8_t k[6]; + union radix_value v; + struct visitor vt; + + _gen_key(k, k + sizeof(k)); + for (i = 0; i < 16; i++) { + k[3] = i; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + vt.it.visit = _visit; + for (i = 0; i < 16; i++) { + vt.count = 0; + k[3] = i; + radix_tree_iterate(rt, k, k + 4, &vt.it); + T_ASSERT_EQUAL(vt.count, 1); + } +} + //---------------------------------------------------------------- #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) @@ -392,9 +445,12 @@ void radix_tree_tests(struct dm_list *all_tests) T("remove-prefix-keys", "remove a set of keys that have common prefixes", test_remove_prefix_keys); T("remove-prefix-keys-reversed", "remove a set of keys that have common prefixes (reversed)", test_remove_prefix_keys_reversed); T("remove-prefix", "remove a subrange", test_remove_prefix); + T("remove-prefix-single", "remove a subrange with a single entry", test_remove_prefix_single); T("size-spots-duplicates", "duplicate entries aren't counted twice", test_size); T("iterate-all", "iterate all entries in tree", test_iterate_all); T("iterate-subset", "iterate a subset of entries in tree", test_iterate_subset); + T("iterate-single", "iterate a subset that contains a single entry", test_iterate_single); + T("iterate-vary-middle", "iterate keys that vary in the middle", test_iterate_vary_middle); dm_list_add(all_tests, &ts->list); } From 7635df8cce131b07b45024e690e4e6917cceb198 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 30 May 2018 14:17:26 +0100 Subject: [PATCH 47/81] bcache: switch to storing blocks in a radix tree. Rather than a hash table. This will make invalidate_fd() more efficient since we can iterate just those blocks that are on a particular dev. --- lib/Makefile.in | 1 + lib/device/bcache.c | 232 ++++++++++++++++++++++++-------------------- make.tmpl.in | 2 +- 3 files changed, 127 insertions(+), 108 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index 1d422354c..4fb4fcf28 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -21,6 +21,7 @@ ifeq ("@CLUSTER@", "shared") endif SOURCES =\ + ../base/data-struct/radix-tree.c \ activate/activate.c \ cache/lvmcache.c \ cache_segtype/cache.c \ diff --git a/lib/device/bcache.c b/lib/device/bcache.c index 9e94fccf5..d9bacf8bb 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -15,6 +15,8 @@ #define _GNU_SOURCE #include "bcache.h" + +#include "base/data-struct/radix-tree.h" #include "lvm-logging.h" #include "log.h" @@ -453,12 +455,7 @@ struct bcache { struct dm_list clean; struct dm_list io_pending; - /* - * Hash table. - */ - unsigned nr_buckets; - unsigned hash_mask; - struct dm_list *buckets; + struct radix_tree *rtree; /* * Statistics @@ -473,75 +470,50 @@ struct bcache { //---------------------------------------------------------------- -/* 2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */ -#define GOLDEN_RATIO_PRIME_64 0x9e37fffffffc0001ULL +struct key_parts { + uint32_t fd; + uint64_t b; +} __attribute__ ((packed)); -static unsigned _hash(struct bcache *cache, int fd, uint64_t i) +union key { + struct key_parts parts; + uint8_t bytes[12]; +}; + +static struct block *_block_lookup(struct bcache *cache, int fd, uint64_t i) { - uint64_t h = (i << 10) & fd; - h *= GOLDEN_RATIO_PRIME_64; - return h & cache->hash_mask; -} + union key k; + union radix_value v; -static struct block *_hash_lookup(struct bcache *cache, int fd, uint64_t i) -{ - struct block *b; - unsigned h = _hash(cache, fd, i); + k.parts.fd = fd; + k.parts.b = i; - dm_list_iterate_items_gen (b, cache->buckets + h, hash) - if (b->fd == fd && b->index == i) - return b; + if (radix_tree_lookup(cache->rtree, k.bytes, k.bytes + sizeof(k.bytes), &v)) + return v.ptr; return NULL; } -static void _hash_insert(struct block *b) +static bool _block_insert(struct block *b) { - unsigned h = _hash(b->cache, b->fd, b->index); - dm_list_add_h(b->cache->buckets + h, &b->hash); + union key k; + union radix_value v; + + k.parts.fd = b->fd; + k.parts.b = b->index; + v.ptr = b; + + return radix_tree_insert(b->cache->rtree, k.bytes, k.bytes + sizeof(k.bytes), v); } -static inline void _hash_remove(struct block *b) +static void _block_remove(struct block *b) { - dm_list_del(&b->hash); -} + union key k; -/* - * Must return a power of 2. - */ -static unsigned _calc_nr_buckets(unsigned nr_blocks) -{ - unsigned r = 8; - unsigned n = nr_blocks / 4; + k.parts.fd = b->fd; + k.parts.b = b->index; - if (n < 8) - n = 8; - - while (r < n) - r <<= 1; - - return r; -} - -static bool _hash_table_init(struct bcache *cache, unsigned nr_entries) -{ - unsigned i; - - cache->nr_buckets = _calc_nr_buckets(nr_entries); - cache->hash_mask = cache->nr_buckets - 1; - cache->buckets = dm_malloc(cache->nr_buckets * sizeof(*cache->buckets)); - if (!cache->buckets) - return false; - - for (i = 0; i < cache->nr_buckets; i++) - dm_list_init(cache->buckets + i); - - return true; -} - -static void _hash_table_exit(struct bcache *cache) -{ - dm_free(cache->buckets); + radix_tree_remove(b->cache->rtree, k.bytes, k.bytes + sizeof(k.bytes)); } //---------------------------------------------------------------- @@ -587,6 +559,11 @@ static struct block *_alloc_block(struct bcache *cache) return dm_list_struct_base(_list_pop(&cache->free), struct block, list); } +static void _free_block(struct block *b) +{ + dm_list_add(&b->cache->free, &b->list); +} + /*---------------------------------------------------------------- * Clean/dirty list management. * Always use these methods to ensure nr_dirty_ is correct. @@ -742,7 +719,7 @@ static struct block *_find_unused_clean_block(struct bcache *cache) dm_list_iterate_items (b, &cache->clean) { if (!b->ref_count) { _unlink_block(b); - _hash_remove(b); + _block_remove(b); return b; } } @@ -779,23 +756,13 @@ static struct block *_new_block(struct bcache *cache, int fd, block_address i, b b->ref_count = 0; b->error = 0; - _hash_insert(b); + if (!_block_insert(b)) { + log_error("bcache unable to insert block in radix tree (OOM?)"); + _free_block(b); + return NULL; + } } -#if 0 - if (!b) { - log_error("bcache no new blocks for fd %d index %u " - "clean %u free %u dirty %u pending %u nr_data_blocks %u nr_cache_blocks %u", - fd, (uint32_t) i, - dm_list_size(&cache->clean), - dm_list_size(&cache->free), - dm_list_size(&cache->dirty), - dm_list_size(&cache->io_pending), - (uint32_t)cache->nr_data_blocks, - (uint32_t)cache->nr_cache_blocks); - } -#endif - return b; } @@ -833,7 +800,7 @@ static struct block *_lookup_or_read_block(struct bcache *cache, int fd, block_address i, unsigned flags) { - struct block *b = _hash_lookup(cache, fd, i); + struct block *b = _block_lookup(cache, fd, i); if (b) { // FIXME: this is insufficient. We need to also catch a read @@ -937,7 +904,8 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, dm_list_init(&cache->clean); dm_list_init(&cache->io_pending); - if (!_hash_table_init(cache, nr_cache_blocks)) { + cache->rtree = radix_tree_create(NULL, NULL); + if (!cache->rtree) { cache->engine->destroy(cache->engine); dm_free(cache); return NULL; @@ -952,7 +920,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, if (!_init_free_list(cache, nr_cache_blocks, pgsize)) { cache->engine->destroy(cache->engine); - _hash_table_exit(cache); + radix_tree_destroy(cache->rtree); dm_free(cache); return NULL; } @@ -968,7 +936,7 @@ void bcache_destroy(struct bcache *cache) bcache_flush(cache); _wait_all(cache); _exit_free_list(cache); - _hash_table_exit(cache); + radix_tree_destroy(cache->rtree); cache->engine->destroy(cache->engine); dm_free(cache); } @@ -990,7 +958,7 @@ unsigned bcache_max_prefetches(struct bcache *cache) void bcache_prefetch(struct bcache *cache, int fd, block_address i) { - struct block *b = _hash_lookup(cache, fd, i); + struct block *b = _block_lookup(cache, fd, i); if (!b) { if (cache->nr_io_pending < cache->max_io) { @@ -1003,11 +971,13 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address i) } } +//---------------------------------------------------------------- + static void _recycle_block(struct bcache *cache, struct block *b) { _unlink_block(b); - _hash_remove(b); - dm_list_add(&cache->free, &b->list); + _block_remove(b); + _free_block(b); } bool bcache_get(struct bcache *cache, int fd, block_address i, @@ -1041,6 +1011,8 @@ bool bcache_get(struct bcache *cache, int fd, block_address i, return false; } +//---------------------------------------------------------------- + static void _put_ref(struct block *b) { if (!b->ref_count) { @@ -1061,6 +1033,8 @@ void bcache_put(struct block *b) _preemptive_writeback(b->cache); } +//---------------------------------------------------------------- + bool bcache_flush(struct bcache *cache) { // Only dirty data is on the errored list, since bad read blocks get @@ -1083,6 +1057,7 @@ bool bcache_flush(struct bcache *cache) return dm_list_empty(&cache->errored); } +//---------------------------------------------------------------- /* * You can safely call this with a NULL block. */ @@ -1115,29 +1090,72 @@ static bool _invalidate_block(struct bcache *cache, struct block *b) bool bcache_invalidate(struct bcache *cache, int fd, block_address i) { - return _invalidate_block(cache, _hash_lookup(cache, fd, i)); -} - -// FIXME: switch to a trie, or maybe 1 hash table per fd? To save iterating -// through the whole cache. -bool bcache_invalidate_fd(struct bcache *cache, int fd) -{ - struct block *b, *tmp; - bool r = true; - - // Start writing back any dirty blocks on this fd. - dm_list_iterate_items_safe (b, tmp, &cache->dirty) - if (b->fd == fd) - _issue_write(b); - - _wait_all(cache); - - // Everything should be in the clean list now. - dm_list_iterate_items_safe (b, tmp, &cache->clean) - if (b->fd == fd) - r = _invalidate_block(cache, b) && r; - - return r; + return _invalidate_block(cache, _block_lookup(cache, fd, i)); +} + +//---------------------------------------------------------------- + +struct invalidate_iterator { + bool success; + struct radix_tree_iterator it; +}; + +static bool _writeback_v(struct radix_tree_iterator *it, + uint8_t *kb, uint8_t *ke, union radix_value v) +{ + struct block *b = v.ptr; + + if (_test_flags(b, BF_DIRTY)) + _issue_write(b); + + return true; +} + +static bool _invalidate_v(struct radix_tree_iterator *it, + uint8_t *kb, uint8_t *ke, union radix_value v) +{ + struct block *b = v.ptr; + struct invalidate_iterator *iit = container_of(it, struct invalidate_iterator, it); + + if (b->error || _test_flags(b, BF_DIRTY)) { + log_warn("bcache_invalidate: block (%d, %llu) still dirty", + b->fd, (unsigned long long) b->index); + iit->success = false; + return true; + } + + if (b->ref_count) { + log_warn("bcache_invalidate: block (%d, %llu) still held", + b->fd, (unsigned long long) b->index); + iit->success = false; + return true; + } + + _unlink_block(b); + _free_block(b); + + // We can't remove the block from the radix tree yet because + // we're in the middle of an iteration. + return true; +} + +bool bcache_invalidate_fd(struct bcache *cache, int fd) +{ + union key k; + struct invalidate_iterator it; + + k.parts.fd = fd; + + it.it.visit = _writeback_v; + radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd), &it.it); + + _wait_all(cache); + + it.success = true; + it.it.visit = _invalidate_v; + radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd), &it.it); + radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd)); + return it.success; } //---------------------------------------------------------------- diff --git a/make.tmpl.in b/make.tmpl.in index 9d5d36757..1f999ec69 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -306,7 +306,7 @@ LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir) LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_srcdir)/VERSION) -INCLUDES += -I$(srcdir) -I$(top_builddir)/include +INCLUDES += -I$(top_srcdir) -I$(srcdir) -I$(top_builddir)/include INC_LNS = $(top_builddir)/include/.symlinks_created From 06c789eda19445d5e59a9c8044d91300fa1d2000 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 30 May 2018 14:14:59 +0100 Subject: [PATCH 48/81] radix-tree: fix some bugs in remove_prefix and iterate These weren't working if the prefix key was part of a prefix_chain. --- base/data-struct/radix-tree.c | 22 ++++++++++++-- test/unit/radix_tree_t.c | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/base/data-struct/radix-tree.c b/base/data-struct/radix-tree.c index 8e8ac9004..222b35047 100644 --- a/base/data-struct/radix-tree.c +++ b/base/data-struct/radix-tree.c @@ -736,11 +736,29 @@ bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_e return false; } +static bool _prefix_chain_matches(struct lookup_result *lr, uint8_t *ke) +{ + // It's possible the top node is a prefix chain, and + // the remaining key matches part of it. + if (lr->v->type == PREFIX_CHAIN) { + unsigned i, rlen = ke - lr->kb; + struct prefix_chain *pc = lr->v->value.ptr; + if (rlen < pc->len) { + for (i = 0; i < rlen; i++) + if (pc->prefix[i] != lr->kb[i]) + return false; + return true; + } + } + + return false; +} + unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke) { unsigned count = 0; struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); - if (lr.kb == ke) { + if (lr.kb == ke || _prefix_chain_matches(&lr, ke)) { count = _free_node(rt, *lr.v); lr.v->type = UNSET; } @@ -837,7 +855,7 @@ void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, struct radix_tree_iterator *it) { struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke); - if (lr.kb == ke) + if (lr.kb == ke || _prefix_chain_matches(&lr, ke)) _iterate(lr.v, it); } diff --git a/test/unit/radix_tree_t.c b/test/unit/radix_tree_t.c index ba0d5e18e..7266a8a46 100644 --- a/test/unit/radix_tree_t.c +++ b/test/unit/radix_tree_t.c @@ -289,6 +289,18 @@ static void test_remove_prefix(void *fixture) T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 1), count); } +static void test_remove_prefix_single(void *fixture) +{ + struct radix_tree *rt = fixture; + uint8_t k[4]; + union radix_value v; + + _gen_key(k, k + sizeof(k)); + v.n = 1234; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 2), 1); +} + static void test_size(void *fixture) { struct radix_tree *rt = fixture; @@ -367,6 +379,47 @@ static void test_iterate_subset(void *fixture) T_ASSERT_EQUAL(vt.count, subset_count); } +static void test_iterate_single(void *fixture) +{ + struct radix_tree *rt = fixture; + uint8_t k[6]; + union radix_value v; + struct visitor vt; + + _gen_key(k, k + sizeof(k)); + v.n = 1234; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + + vt.count = 0; + vt.it.visit = _visit; + radix_tree_iterate(rt, k, k + 3, &vt.it); + T_ASSERT_EQUAL(vt.count, 1); +} + +static void test_iterate_vary_middle(void *fixture) +{ + struct radix_tree *rt = fixture; + unsigned i; + uint8_t k[6]; + union radix_value v; + struct visitor vt; + + _gen_key(k, k + sizeof(k)); + for (i = 0; i < 16; i++) { + k[3] = i; + v.n = i; + T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v)); + } + + vt.it.visit = _visit; + for (i = 0; i < 16; i++) { + vt.count = 0; + k[3] = i; + radix_tree_iterate(rt, k, k + 4, &vt.it); + T_ASSERT_EQUAL(vt.count, 1); + } +} + //---------------------------------------------------------------- #define T(path, desc, fn) register_test(ts, "/base/data-struct/radix-tree/" path, desc, fn) @@ -392,9 +445,12 @@ void radix_tree_tests(struct dm_list *all_tests) T("remove-prefix-keys", "remove a set of keys that have common prefixes", test_remove_prefix_keys); T("remove-prefix-keys-reversed", "remove a set of keys that have common prefixes (reversed)", test_remove_prefix_keys_reversed); T("remove-prefix", "remove a subrange", test_remove_prefix); + T("remove-prefix-single", "remove a subrange with a single entry", test_remove_prefix_single); T("size-spots-duplicates", "duplicate entries aren't counted twice", test_size); T("iterate-all", "iterate all entries in tree", test_iterate_all); T("iterate-subset", "iterate a subset of entries in tree", test_iterate_subset); + T("iterate-single", "iterate a subset that contains a single entry", test_iterate_single); + T("iterate-vary-middle", "iterate keys that vary in the middle", test_iterate_vary_middle); dm_list_add(all_tests, &ts->list); } From 6d14d5d16b92c520b5f4ee464f171684cac40735 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Tue, 29 May 2018 17:02:27 -0500 Subject: [PATCH 49/81] scan: removed failed paths for devices Drop a device path when the scan fails to open it. --- lib/device/dev-cache.c | 187 +++++++++++++++++++++++++++----- lib/device/dev-cache.h | 2 + lib/filters/filter-persistent.c | 10 +- lib/label/label.c | 65 ++++++++--- 4 files changed, 219 insertions(+), 45 deletions(-) diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index dd0155808..c866ff903 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -333,10 +333,8 @@ static int _add_alias(struct device *dev, const char *path) /* Is name already there? */ dm_list_iterate_items(strl, &dev->aliases) { - if (!strcmp(strl->str, path)) { - log_debug_devs("%s: Already in device cache", path); + if (!strcmp(strl->str, path)) return 1; - } } sl->str = path; @@ -344,13 +342,7 @@ static int _add_alias(struct device *dev, const char *path) if (!dm_list_empty(&dev->aliases)) { oldpath = dm_list_item(dev->aliases.n, struct dm_str_list)->str; prefer_old = _compare_paths(path, oldpath); - log_debug_devs("%s: Aliased to %s in device cache%s (%d:%d)", - path, oldpath, prefer_old ? "" : " (preferred name)", - (int) MAJOR(dev->dev), (int) MINOR(dev->dev)); - - } else - log_debug_devs("%s: Added to device cache (%d:%d)", path, - (int) MAJOR(dev->dev), (int) MINOR(dev->dev)); + } if (prefer_old) dm_list_add(&dev->aliases, &sl->list); @@ -666,6 +658,29 @@ struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid) return dm_hash_lookup(_cache.lvid_index, lvid); } +/* + * Scanning code calls this when it fails to open a device using + * this path. The path is dropped from dev-cache. In the next + * dev_cache_scan it may be added again, but it could be for a + * different device. + */ + +void dev_cache_failed_path(struct device *dev, const char *path) +{ + struct device *dev_by_path; + struct dm_str_list *strl; + + if ((dev_by_path = (struct device *) dm_hash_lookup(_cache.names, path))) + dm_hash_remove(_cache.names, path); + + dm_list_iterate_items(strl, &dev->aliases) { + if (!strcmp(strl->str, path)) { + dm_list_del(&strl->list); + break; + } + } +} + /* * Either creates a new dev, or adds an alias to * an existing dev. @@ -673,6 +688,8 @@ struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid) 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; @@ -685,8 +702,26 @@ static int _insert_dev(const char *path, dev_t d) loopfile = 1; } - /* is this device already registered ? */ - if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) d))) { + 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; + + /* + * Existing device, existing path points to the same device. + */ + if (dev_by_devt && dev_by_path && (dev_by_devt == dev_by_path)) { + log_debug_devs("Found dev %d:%d %s - exists. %.8s", + (int)MAJOR(d), (int)MINOR(d), path, dev->pvid); + return 1; + } + + /* + * No device or path found, add devt to cache.devices, add name to cache.names. + */ + if (!dev_by_devt && !dev_by_path) { + log_debug_devs("Found dev %d:%d %s - new.", + (int)MAJOR(d), (int)MINOR(d), path); + if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) d))) { /* create new device */ if (loopfile) { @@ -701,30 +736,126 @@ static int _insert_dev(const char *path, dev_t d) _free(dev); return 0; } - } - if (dm_hash_lookup(_cache.names, path) == dev) { - /* Hash already has matching entry present */ - log_debug("%s: Path already cached.", path); + if (!(path_copy = dm_pool_strdup(_cache.mem, path))) { + log_error("Failed to duplicate path string."); + return 0; + } + + if (!loopfile && !_add_alias(dev, path_copy)) { + log_error("Couldn't add alias to dev cache."); + return 0; + } + + if (!dm_hash_insert(_cache.names, path_copy, dev)) { + log_error("Couldn't add name to hash in dev cache."); + return 0; + } + return 1; } - if (!(path_copy = dm_pool_strdup(_cache.mem, path))) { - log_error("Failed to duplicate path string."); - return 0; + /* + * Existing device, path is new, add path as a new alias for the device. + */ + if (dev_by_devt && !dev_by_path) { + log_debug_devs("Found dev %d:%d %s - new alias.", + (int)MAJOR(d), (int)MINOR(d), path); + + if (!(path_copy = dm_pool_strdup(_cache.mem, path))) { + log_error("Failed to duplicate path string."); + return 0; + } + + if (!loopfile && !_add_alias(dev, path_copy)) { + log_error("Couldn't add alias to dev cache."); + return 0; + } + + if (!dm_hash_insert(_cache.names, path_copy, dev)) { + log_error("Couldn't add name to hash in dev cache."); + return 0; + } + + return 1; } - if (!loopfile && !_add_alias(dev, path_copy)) { - log_error("Couldn't add alias to dev cache."); - return 0; + /* + * No existing device, but path exists and previously pointed + * to a different device. + */ + if (!dev_by_devt && dev_by_path) { + log_debug_devs("Found dev %d:%d %s - new device, path was previously %d:%d.", + (int)MAJOR(d), (int)MINOR(d), path, + (int)MAJOR(dev_by_path->dev), (int)MINOR(dev_by_path->dev)); + + 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))) + return_0; + } + + if (!(btree_insert(_cache.devices, (uint32_t) d, dev))) { + log_error("Couldn't insert device into binary tree."); + _free(dev); + return 0; + } + + if (!(path_copy = dm_pool_strdup(_cache.mem, path))) { + log_error("Failed to duplicate path string."); + return 0; + } + + if (!loopfile && !_add_alias(dev, path_copy)) { + log_error("Couldn't add alias to dev cache."); + return 0; + } + + dm_hash_remove(_cache.names, path); + + if (!dm_hash_insert(_cache.names, path_copy, dev)) { + log_error("Couldn't add name to hash in dev cache."); + return 0; + } + + return 1; + } - if (!dm_hash_insert(_cache.names, path_copy, dev)) { - log_error("Couldn't add name to hash in dev cache."); - return 0; + /* + * Existing device, and path exists and previously pointed to + * a different device. + */ + if (dev_by_devt && dev_by_path) { + log_debug_devs("Found dev %d:%d %s - existing device, path was previously %d:%d.", + (int)MAJOR(d), (int)MINOR(d), path, + (int)MAJOR(dev_by_path->dev), (int)MINOR(dev_by_path->dev)); + + if (!(path_copy = dm_pool_strdup(_cache.mem, path))) { + log_error("Failed to duplicate path string."); + return 0; + } + + if (!loopfile && !_add_alias(dev, path_copy)) { + log_error("Couldn't add alias to dev cache."); + return 0; + } + + dm_hash_remove(_cache.names, path); + + if (!dm_hash_insert(_cache.names, path_copy, dev)) { + log_error("Couldn't add name to hash in dev cache."); + return 0; + } + + return 1; } - return 1; + log_error("Found dev %d:%d %s - failed to use.", (int)MAJOR(d), (int)MINOR(d), path); + return 0; } static char *_join(const char *dir, const char *name) @@ -1064,10 +1195,8 @@ static int _insert(const char *path, const struct stat *info, if (rec && !_insert_dir(path)) return_0; } else { /* add a device */ - if (!S_ISBLK(info->st_mode)) { - log_debug_devs("%s: Not a block device", path); + if (!S_ISBLK(info->st_mode)) return 1; - } if (!_insert_dev(path, info->st_rdev)) return_0; diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 479727473..df6ba0e73 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -70,4 +70,6 @@ struct device *dev_iter_get(struct dev_iter *iter); void dev_reset_error_count(struct cmd_context *cmd); +void dev_cache_failed_path(struct device *dev, const char *path); + #endif diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c index 3fa57f191..e4659aa99 100644 --- a/lib/filters/filter-persistent.c +++ b/lib/filters/filter-persistent.c @@ -286,10 +286,18 @@ out: static int _lookup_p(struct dev_filter *f, struct device *dev) { struct pfilter *pf = (struct pfilter *) f->private; - void *l = dm_hash_lookup(pf->devices, dev_name(dev)); + void *l; struct dm_str_list *sl; int pass = 1; + if (dm_list_empty(&dev->aliases)) { + log_debug_devs("%d:%d: filter cache skipping (no name)", + (int)MAJOR(dev->dev), (int)MINOR(dev->dev)); + return 0; + } + + l = dm_hash_lookup(pf->devices, dev_name(dev)); + /* Cached bad, skip dev */ if (l == PF_BAD_DEVICE) { log_debug_devs("%s: filter cache skipping (cached bad)", dev_name(dev)); diff --git a/lib/label/label.c b/lib/label/label.c index 8ecaa6165..97a43599c 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -501,15 +501,6 @@ retry_open: (int)MAJOR(sbuf.st_rdev), (int)MINOR(sbuf.st_rdev)); } - /* - * FIXME: do we want to try opening this device using - * one of the other path aliases for the same - * major:minor from dev->aliases? We could iterate - * through those aliases to try opening each of them to - * find one that works. What are the consequences of - * using a different, non-preferred alias to a device? - */ - if (!retried) { /* * FIXME: remove this, the theory for this retry is that @@ -550,6 +541,37 @@ static int _scan_dev_close(struct device *dev) return 1; } +static void _drop_bad_aliases(struct device *dev) +{ + struct dm_str_list *strl, *strl2; + const char *name; + struct stat sbuf; + int major = (int)MAJOR(dev->dev); + int minor = (int)MINOR(dev->dev); + int bad; + + dm_list_iterate_items_safe(strl, strl2, &dev->aliases) { + name = strl->str; + bad = 0; + + if (stat(name, &sbuf)) { + bad = 1; + log_debug_devs("Device path check %d:%d %s stat failed errno %d", + major, minor, name, errno); + } else if (sbuf.st_rdev != dev->dev) { + bad = 1; + log_debug_devs("Device path check %d:%d %s stat %d:%d does not match.", + major, minor, name, + (int)MAJOR(sbuf.st_rdev), (int)MINOR(sbuf.st_rdev)); + } + + if (bad) { + log_debug_devs("Device path check %d:%d dropping path %s.", major, minor, name); + dev_cache_failed_path(dev, name); + } + } +} + /* * Read or reread label/metadata from selected devs. * @@ -635,7 +657,11 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, scan_failed_count++; lvmcache_del_dev(devl->dev); } else { - log_debug_devs("Processing data from device %s fd %d block %p", dev_name(devl->dev), devl->dev->bcache_fd, bb); + log_debug_devs("Processing data from device %s %d:%d fd %d block %p", + dev_name(devl->dev), + (int)MAJOR(devl->dev->dev), + (int)MINOR(devl->dev->dev), + devl->dev->bcache_fd, bb); ret = _process_block(cmd, f, devl->dev, bb, 0, 0, &is_lvm_device); @@ -675,11 +701,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, * to open the devs on the reopen_devs list. * * FIXME: it's not clear if or why this helps. - * - * FIXME: should we delete the first path name from dev->aliases that - * we failed to open the first time before retrying? If that path - * still exists on the system, dev_cache_scan should put it back, but - * if it doesn't exist we don't want to try using it again. */ if (!dm_list_empty(&reopen_devs)) { if (retried_open) { @@ -690,6 +711,20 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f, } retried_open = 1; + dm_list_iterate_items_safe(devl, devl2, &reopen_devs) { + _drop_bad_aliases(devl->dev); + + if (dm_list_empty(&devl->dev->aliases)) { + log_warn("WARNING: Scan ignoring device %d:%d with no paths.", + (int)MAJOR(devl->dev->dev), + (int)MINOR(devl->dev->dev)); + + dm_list_del(&devl->list); + lvmcache_del_dev(devl->dev); + scan_failed_count++; + } + } + /* * This will search the system's /dev for new path names and * could help us reopen the device if it finds a new preferred From 5ac9f8d631cc6b340f4d3ad2cc35021e42d36ef6 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 23 May 2018 12:56:33 -0500 Subject: [PATCH 50/81] tests: fix skipping logic for lvmpolld and lvmlockd --- test/lib/inittest.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh index 5e900c086..c48ea132d 100644 --- a/test/lib/inittest.sh +++ b/test/lib/inittest.sh @@ -59,7 +59,7 @@ test -n "$SKIP_WITH_CLVMD" && test "$LVM_TEST_LOCKING" = 3 && initskip test -n "$SKIP_WITHOUT_LVMETAD" && test -z "$LVM_TEST_LVMETAD" && initskip test -n "$SKIP_WITH_LVMETAD" && test -n "$LVM_TEST_LVMETAD" && initskip -test -n "$SKIP_WITH_LVMPOLLD" && test -n "$LVM_TEST_LVMPOLLD" && initskip +test -n "$SKIP_WITH_LVMPOLLD" && test -n "$LVM_TEST_LVMPOLLD" && test -z "$LVM_TEST_LVMLOCKD" && initskip test -n "$SKIP_WITH_LVMLOCKD" && test -n "$LVM_TEST_LVMLOCKD" && initskip @@ -172,6 +172,8 @@ test -n "$LVM_TEST_LVMPOLLD" && { aux prepare_lvmpolld } +export SHARED="" + if test -n "$LVM_TEST_LVMLOCKD" ; then if test -n "$LVM_TEST_LOCK_TYPE_SANLOCK" ; then aux lvmconf 'local/host_id = 1' From 6a44dceb4895fc3e1b89cad0050bc766250d91a4 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 23 May 2018 13:04:47 -0500 Subject: [PATCH 51/81] tests: some missed skip with lvmlockd --- test/shell/dmstats-create.sh | 1 + test/shell/dmstats-report.sh | 1 + test/shell/lv-ancestry.sh | 1 + test/shell/lvconvert-repair-cache.sh | 1 + test/shell/process-each-lv.sh | 2 ++ test/shell/pv-ext-update.sh | 1 + test/shell/relative-sign-options.sh | 1 + test/shell/vg-check-devs-used.sh | 1 + 8 files changed, 9 insertions(+) diff --git a/test/shell/dmstats-create.sh b/test/shell/dmstats-create.sh index c16f26f70..03406aeff 100644 --- a/test/shell/dmstats-create.sh +++ b/test/shell/dmstats-create.sh @@ -11,6 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/dmstats-report.sh b/test/shell/dmstats-report.sh index 031214901..bd72f1a61 100644 --- a/test/shell/dmstats-report.sh +++ b/test/shell/dmstats-report.sh @@ -11,6 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/lv-ancestry.sh b/test/shell/lv-ancestry.sh index 732499fa5..c36f366f8 100644 --- a/test/shell/lv-ancestry.sh +++ b/test/shell/lv-ancestry.sh @@ -11,6 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-cache.sh b/test/shell/lvconvert-repair-cache.sh index 4b9d8b824..6afb7ea3b 100644 --- a/test/shell/lvconvert-repair-cache.sh +++ b/test/shell/lvconvert-repair-cache.sh @@ -13,6 +13,7 @@ # Test repairing of broken cached LV SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/process-each-lv.sh b/test/shell/process-each-lv.sh index e9cea8157..9482a0847 100644 --- a/test/shell/process-each-lv.sh +++ b/test/shell/process-each-lv.sh @@ -11,6 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise toollib process_each_lv' + SKIP_WITH_LVMPOLLD=1 # disable lvmetad logging as it bogs down test systems @@ -18,6 +19,7 @@ export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} . lib/inittest + aux prepare_devs 10 # diff --git a/test/shell/pv-ext-update.sh b/test/shell/pv-ext-update.sh index cfaece7f6..44f301e1d 100644 --- a/test/shell/pv-ext-update.sh +++ b/test/shell/pv-ext-update.sh @@ -12,6 +12,7 @@ # lvmetad does not handle pool labels so skip test. SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/relative-sign-options.sh b/test/shell/relative-sign-options.sh index 2db281ad4..2a36f1f8e 100644 --- a/test/shell/relative-sign-options.sh +++ b/test/shell/relative-sign-options.sh @@ -12,6 +12,7 @@ test_description='Exercise toollib process_each_lv' SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 # disable lvmetad logging as it bogs down test systems export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} diff --git a/test/shell/vg-check-devs-used.sh b/test/shell/vg-check-devs-used.sh index 7d4481204..9b99ef70a 100644 --- a/test/shell/vg-check-devs-used.sh +++ b/test/shell/vg-check-devs-used.sh @@ -11,6 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 . lib/inittest From 0c1d3db8dbe45df9f4311f5c19014680ecf26613 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 23 May 2018 13:16:48 -0500 Subject: [PATCH 52/81] lvmlockd: accept repeated global lock requests It's not an error if a command requests the global lock when it has already acquired it. It shouldn't happen, but there could be cases we've not found. --- lib/locking/lvmlockd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index d78b35c88..bf9b7a946 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -1547,6 +1547,16 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags) } } + if (result == -EALREADY) { + /* + * This should generally not happen because commands should be coded + * to avoid reacquiring the global lock. If there is a case that's + * missed which causes the command to request the gl when it's already + * held, it's not a problem, so let it go. + */ + log_debug("lockd global mode %s already held.", mode); + return 1; + } if (!strcmp(mode, "un")) return 1; From cd369d8a7fc5324f66d9965528ef9b92828b1a19 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 23 May 2018 13:56:49 -0500 Subject: [PATCH 53/81] tests: separate lvmlockd tests with or without lvmetad --- test/Makefile.in | 9 +++++++++ test/lib/flavour-udev-lvmlockd-dlm.sh | 1 - test/lib/flavour-udev-lvmlockd-sanlock.sh | 1 - test/lib/flavour-udev-lvmlockd-test.sh | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index f6345a54c..2b115b478 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -95,6 +95,7 @@ help: @echo " check_lvmlockd_sanlock Run tests with lvmlockd and sanlock." @echo " check_lvmlockd_dlm Run tests with lvmlockd and dlm." @echo " check_lvmlockd_test Run tests with lvmlockd --test." + @echo " check_lvmlockd_test_lvmetad Run tests with lvmlockd --test and lvmetad." @echo " run-unit-test Run only unit tests (root not needed)." @echo " clean Clean dir." @echo " help Display callable targets." @@ -203,6 +204,13 @@ check_lvmlockd_test: .tests-stamp --flavours udev-lvmlockd-test --only $(T) --skip $(S) endif +ifeq ("@BUILD_LVMLOCKD@", "yes") +check_lvmlockd_test_lvmetad: .tests-stamp + VERBOSE=$(VERBOSE) ./lib/runner \ + --testdir . --outdir results \ + --flavours udev-lvmlockd-test-lvmetad --only $(T) --skip $(S) +endif + run-unit-test unit-test: $(MAKE) -C unit $(@) @@ -224,6 +232,7 @@ LIB_FLAVOURS = \ flavour-udev-lvmlockd-sanlock\ flavour-udev-lvmlockd-dlm\ flavour-udev-lvmlockd-test\ + flavour-udev-lvmlockd-test-lvmetad\ flavour-udev-vanilla LIB_LVMLOCKD_CONF = \ diff --git a/test/lib/flavour-udev-lvmlockd-dlm.sh b/test/lib/flavour-udev-lvmlockd-dlm.sh index 5bd274911..198ec563b 100644 --- a/test/lib/flavour-udev-lvmlockd-dlm.sh +++ b/test/lib/flavour-udev-lvmlockd-dlm.sh @@ -1,5 +1,4 @@ export LVM_TEST_LOCKING=1 -export LVM_TEST_LVMETAD=1 export LVM_TEST_LVMPOLLD=1 export LVM_TEST_LVMLOCKD=1 export LVM_TEST_LOCK_TYPE_DLM=1 diff --git a/test/lib/flavour-udev-lvmlockd-sanlock.sh b/test/lib/flavour-udev-lvmlockd-sanlock.sh index 859ee2e66..52f3cea32 100644 --- a/test/lib/flavour-udev-lvmlockd-sanlock.sh +++ b/test/lib/flavour-udev-lvmlockd-sanlock.sh @@ -1,5 +1,4 @@ export LVM_TEST_LOCKING=1 -export LVM_TEST_LVMETAD=1 export LVM_TEST_LVMPOLLD=1 export LVM_TEST_LVMLOCKD=1 export LVM_TEST_LOCK_TYPE_SANLOCK=1 diff --git a/test/lib/flavour-udev-lvmlockd-test.sh b/test/lib/flavour-udev-lvmlockd-test.sh index d2a7b4af1..f9cd5271c 100644 --- a/test/lib/flavour-udev-lvmlockd-test.sh +++ b/test/lib/flavour-udev-lvmlockd-test.sh @@ -1,5 +1,4 @@ export LVM_TEST_LOCKING=1 -export LVM_TEST_LVMETAD=1 export LVM_TEST_LVMPOLLD=1 export LVM_TEST_LVMLOCKD=1 export LVM_TEST_LVMLOCKD_TEST=1 From 7f7ec769d98cfe7af47b202189b279f354763b5a Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 24 May 2018 11:41:14 -0500 Subject: [PATCH 54/81] lvmlockd: do not use an LV lock for some lvchange options Some lvchange options can be used even if the LV is active. --- lib/locking/lvmlockd.c | 5 +++-- tools/lvchange.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index bf9b7a946..7f4fb2efe 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -2105,8 +2105,9 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg, if (result == -EEXIST) { /* - * This happens if lvchange tries to modify the LV with an ex - * LV lock when the LV is already active with a sh LV lock. + * This happens if a command like lvchange tries to modify the + * LV with an ex LV lock when the LV is already active with a + * sh LV lock. */ log_error("LV is already locked with incompatible mode: %s/%s", vg->name, lv_name); return 0; diff --git a/tools/lvchange.c b/tools/lvchange.c index 0aac5ac19..6144852b6 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -1056,9 +1056,11 @@ static int _lvchange_properties_single(struct cmd_context *cmd, int i, opt_enum; uint32_t mr = 0; - /* If LV is inactive here, ensure it's not active elsewhere. */ - if (!lockd_lv(cmd, lv, "ex", 0)) - return_ECMD_FAILED; + /* + * We do not acquire an lvmlockd lock on the LV here because these are + * VG metadata changes that do not conflict with the LV being active on + * another host. + */ /* First group of options which allow for one metadata commit/update for the whole group */ for (i = 0; i < cmd->command->ro_count; i++) { From 3a4fe54ca12daf0af142e47092968cadb279d10b Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 23 May 2018 10:15:39 -0500 Subject: [PATCH 55/81] config: revert to normal locking when no cluster and suggest lvmlockd --- lib/locking/locking.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 105419af4..258422708 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -148,11 +148,11 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages) } #endif -#ifdef CLUSTER_LOCKING_INTERNAL log_very_verbose("Falling back to internal clustered locking."); /* Fall through */ case 3: +#ifdef CLUSTER_LOCKING_INTERNAL log_very_verbose("Cluster locking selected."); if (!init_cluster_locking(&_locking, cmd, suppress_messages)) { log_error_suppress(suppress_messages, @@ -160,6 +160,20 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages) break; } return 1; +#else + log_warn("WARNING: Using locking_type=1, ignoring locking_type=3."); + log_warn("WARNING: See lvmlockd(8) for information on using cluster/clvm VGs."); + type = 1; + + log_very_verbose("%sFile-based locking selected.", + _blocking_supported ? "" : "Non-blocking "); + + if (!init_file_locking(&_locking, cmd, suppress_messages)) { + log_error_suppress(suppress_messages, + "File-based locking initialisation failed."); + break; + } + return 1; #endif case 4: From db8d3bdfa93bb08a85953f2f3150ee27dffaa5fe Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 24 May 2018 15:02:35 -0500 Subject: [PATCH 56/81] lvmlockd: enable mirror split and merge with dlm lock_type --- lib/metadata/mirror.c | 8 ++++++++ lib/metadata/raid_manip.c | 20 +++++++++++++++++--- man/lvmlockd.8_main | 5 ++++- tools/lvconvert.c | 4 ++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c index 054ca9995..25948ad45 100644 --- a/lib/metadata/mirror.c +++ b/lib/metadata/mirror.c @@ -424,6 +424,11 @@ revert_new_lv: static int _activate_lv_like_model(struct logical_volume *model, struct logical_volume *lv) { + /* FIXME: run all cases through lv_active_change when clvm variants are gone. */ + + if (is_lockd_type(lv->vg->lock_type)) + return lv_active_change(lv->vg->cmd, lv, CHANGE_AEY, 0); + if (lv_is_active_exclusive(model)) { if (!activate_lv_excl(lv->vg->cmd, lv)) return_0; @@ -705,6 +710,9 @@ static int _split_mirror_images(struct logical_volume *lv, return 0; } + if (!strcmp(lv->vg->lock_type, "dlm")) + new_lv->lock_args = lv->lock_args; + if (!dm_list_empty(&split_images)) { /* * A number of images have been split and diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 703f28547..0c631b481 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -21,6 +21,7 @@ #include "activate.h" #include "lv_alloc.h" #include "lvm-string.h" +#include "lvmlockd.h" typedef int (*fn_on_lv_t)(struct logical_volume *lv, void *data); static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg, @@ -3315,7 +3316,7 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name, dm_list_init(&removal_lvs); dm_list_init(&data_list); - if (is_lockd_type(lv->vg->lock_type)) { + if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock")) { log_error("Splitting raid image is not allowed with lock_type %s.", lv->vg->lock_type); return 0; @@ -3394,6 +3395,9 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name, lvl->lv->name = split_name; + if (!strcmp(lv->vg->lock_type, "dlm")) + lvl->lv->lock_args = lv->lock_args; + if (!vg_write(lv->vg)) { log_error("Failed to write changes for %s.", display_lvname(lv)); @@ -3419,7 +3423,13 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name, * the original RAID LV having possibly had sub-LVs that have been * shifted and renamed. */ - if (!activate_lv_excl_local(cmd, lvl->lv)) + + /* FIXME: run all cases through lv_active_change when clvm variants are gone. */ + + if (is_lockd_type(lvl->lv->vg->lock_type)) { + if (!lv_active_change(lv->vg->cmd, lvl->lv, CHANGE_AEY, 0)) + return_0; + } else if (!activate_lv_excl_local(cmd, lvl->lv)) return_0; dm_list_iterate_items(lvl, &removal_lvs) @@ -3473,7 +3483,7 @@ int lv_raid_split_and_track(struct logical_volume *lv, int s; struct lv_segment *seg = first_seg(lv); - if (is_lockd_type(lv->vg->lock_type)) { + if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock")) { log_error("Splitting raid image is not allowed with lock_type %s.", lv->vg->lock_type); return 0; @@ -3574,6 +3584,10 @@ int lv_raid_merge(struct logical_volume *image_lv) return 0; } + /* Ensure primary LV is not active elsewhere. */ + if (!lockd_lv(vg->cmd, lvl->lv, "ex", 0)) + return_0; + lv = lvl->lv; seg = first_seg(lv); for (s = 0; s < seg->area_count; ++s) diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main index 6f982bd19..90a07c70b 100644 --- a/man/lvmlockd.8_main +++ b/man/lvmlockd.8_main @@ -852,7 +852,10 @@ using lvcreate to create cache pools or cache LVs (use lvconvert) using external origins for thin LVs .br \[bu] -splitting mirrors and snapshots from LVs +splitting snapshots from LVs +.br +\[bu] +splitting mirrors in sanlock VGs .br \[bu] pvmove of entire PVs, or under LVs activated with shared locks diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 72f840ab0..e59a772b9 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -716,8 +716,8 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd, *old_mimage_count = lv_mirror_count(lv); *old_log_count = _get_log_count(lv); - if (is_lockd_type(lv->vg->lock_type) && lp->keep_mimages) { - /* FIXME: we need to create a lock for the new LV. */ + if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock") && lp->keep_mimages) { + /* FIXME: we need to create a sanlock lock on disk for the new LV. */ log_error("Unable to split mirrors in VG with lock_type %s", lv->vg->lock_type); return 0; } From 948f2d997990048ad6759bfb25f042a4ddbb6a83 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 12:53:53 -0500 Subject: [PATCH 57/81] lvmlockd: enable lvcreate of thin pool and thin lv in one command Previously, thin pools and thin lvs need needed to be created with separate commands, now the combined command is permitted. --- lib/metadata/lv_manip.c | 6 ++++++ tools/lvcreate.c | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 8c76a38f2..4aefea06f 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -8025,8 +8025,14 @@ struct logical_volume *lv_create_single(struct volume_group *vg, if (!(lp->segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_THIN_POOL))) return_NULL; + /* We want a lockd lock for the new thin pool, but not the thin lv. */ + lp->needs_lockd_init = 1; + if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name))) return_NULL; + + lp->needs_lockd_init = 0; + } else if (seg_is_cache(lp)) { if (!lp->origin_name) { /* Until we have --pooldatasize we are lost */ diff --git a/tools/lvcreate.c b/tools/lvcreate.c index e901968d7..39170dd4f 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -1638,8 +1638,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name, lp->snapshot ? lp->origin_name : "", lp->segtype->name); if (is_lockd_type(vg->lock_type)) { - if (cmd->command->command_enum == lvcreate_thin_vol_and_thinpool_CMD || - cmd->command->command_enum == lvcreate_cachepool_CMD || + if (cmd->command->command_enum == lvcreate_cachepool_CMD || cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD || cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD || cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) { From 403c87c1aa7b759c95c0d3e86eb919229b4fc242 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 13:26:16 -0500 Subject: [PATCH 58/81] lvmlockd: enable creation of cache pool with lvcreate Previously, cache pools needed to be created with lvconvert. --- lib/locking/lvmlockd.c | 16 +++++++++++----- tools/lvcreate.c | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index 7f4fb2efe..be37dc287 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -2416,10 +2416,6 @@ int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg, * an LV with no lock_args will do nothing (unless the LV type causes the lock * request to be directed to another LV with a lock, e.g. to the thin pool LV * for thin LVs.) - * - * Current limitations: - * - cache-type LV's in a lockd VG must be created with lvconvert. - * - creating a thin pool and thin lv in one command is not allowed. */ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv, @@ -2448,7 +2444,17 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic /* needs_lock_init is set for LVs that need a lockd lock. */ return 1; - } else if (seg_is_cache(lp) || seg_is_cache_pool(lp)) { + } else if (seg_is_cache_pool(lp)) { + /* + * A cache pool does not use a lockd lock because it cannot be + * used by itself. When a cache pool is attached to an actual + * LV, the lockd lock for that LV covers the LV and the cache + * pool attached to it. + */ + lv->lock_args = NULL; + return 1; + + } else if (seg_is_cache(lp)) { /* * This should not happen because the command defs are * checked and excluded for shared VGs early in lvcreate. diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 39170dd4f..ee6df02ab 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -1638,8 +1638,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name, lp->snapshot ? lp->origin_name : "", lp->segtype->name); if (is_lockd_type(vg->lock_type)) { - if (cmd->command->command_enum == lvcreate_cachepool_CMD || - cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD || + if (cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD || cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD || cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) { log_error("Use lvconvert to create thin pools and cache pools in a shared VG."); From 595196bc29e97cded7b4654db6824c5276f25eee Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 24 May 2018 09:49:48 -0500 Subject: [PATCH 59/81] tests: enable lvmlockd for passing tests --- test/lib/aux.sh | 2 +- test/shell/000-basic.sh | 2 +- test/shell/activate-minor.sh | 2 +- test/shell/activate-missing-segment.sh | 2 +- test/shell/activate-missing.sh | 2 +- test/shell/activate-partial.sh | 2 +- test/shell/activation-skip.sh | 2 +- test/shell/backup-read-only.sh | 2 +- test/shell/component-raid.sh | 2 +- test/shell/covercmd.sh | 4 ++-- test/shell/discards-thin.sh | 6 ++--- test/shell/dmeventd-restart.sh | 2 +- test/shell/dmstats-create.sh | 2 +- test/shell/dmstats-report.sh | 2 +- test/shell/dumpconfig.sh | 2 +- test/shell/error-usage.sh | 2 +- test/shell/fsadm-crypt.sh | 2 +- test/shell/fsadm-renamed.sh | 2 +- test/shell/fsadm.sh | 2 +- test/shell/listings.sh | 9 ++++---- test/shell/lock-blocking.sh | 6 ++--- test/shell/lock-parallel.sh | 2 +- test/shell/losetup-partscan.sh | 6 ++--- test/shell/lv-ancestry.sh | 4 ++-- test/shell/lvchange-cache-syncaction-raid.sh | 2 +- test/shell/lvchange-mirror.sh | 2 +- test/shell/lvchange-partial-raid10.sh | 2 +- .../shell/lvchange-raid-transient-failures.sh | 2 +- test/shell/lvchange-raid.sh | 2 +- test/shell/lvchange-raid1-writemostly.sh | 2 +- test/shell/lvchange-rebuild-raid.sh | 2 +- test/shell/lvchange-syncaction-raid.sh | 2 +- test/shell/lvchange-thin.sh | 6 ++--- test/shell/lvconvert-cache-chunks.sh | 2 +- test/shell/lvconvert-m-raid1-degraded.sh | 2 +- test/shell/lvconvert-mirror-basic.sh | 2 +- test/shell/lvconvert-mirror-updown.sh | 4 ++-- test/shell/lvconvert-mirror.sh | 4 ++-- test/shell/lvconvert-raid-regionsize.sh | 2 +- ...vconvert-raid-reshape-linear_to_striped.sh | 1 - ...vconvert-raid-reshape-striped_to_linear.sh | 2 +- .../lvconvert-raid-takeover-alloc-failure.sh | 2 +- test/shell/lvconvert-raid-takeover-thin.sh | 2 +- test/shell/lvconvert-raid-takeover.sh | 2 +- test/shell/lvconvert-raid.sh | 3 +-- test/shell/lvconvert-raid0_to_raid10.sh | 4 ++-- test/shell/lvconvert-raid10.sh | 4 ++-- test/shell/lvconvert-raid456.sh | 2 +- test/shell/lvconvert-repair-raid.sh | 2 +- test/shell/lvconvert-repair-thin-raid.sh | 2 +- test/shell/lvconvert-thin-raid.sh | 1 - test/shell/lvconvert-twostep.sh | 2 +- test/shell/lvcreate-cache-fail.sh | 4 ++-- test/shell/lvcreate-mirror.sh | 2 +- test/shell/lvcreate-missing.sh | 2 +- test/shell/lvcreate-operation.sh | 4 ++-- test/shell/lvcreate-raid-nosync.sh | 2 +- test/shell/lvcreate-raid-volume_list.sh | 4 ++-- test/shell/lvcreate-raid.sh | 4 ++-- test/shell/lvcreate-raid10.sh | 2 +- test/shell/lvcreate-signature-wiping.sh | 2 +- test/shell/lvcreate-small-snap.sh | 4 ++-- test/shell/lvcreate-striped-mirror.sh | 2 +- test/shell/lvcreate-thin-big.sh | 4 ++-- test/shell/lvcreate-thin-external-size.sh | 4 ++-- test/shell/lvcreate-thin-external.sh | 4 ++-- test/shell/lvcreate-thin-power2.sh | 4 ++-- test/shell/lvcreate-thin-snap.sh | 4 ++-- test/shell/lvcreate-thin.sh | 4 ++-- test/shell/lvcreate-usage.sh | 10 ++++++--- test/shell/lvextend-percent-extents.sh | 4 ++-- test/shell/lvextend-snapshot-policy.sh | 2 +- test/shell/lvextend-thin-data-dmeventd.sh | 4 ++-- test/shell/lvextend-thin-raid.sh | 2 +- test/shell/lvextend-thin.sh | 2 +- test/shell/lvm-init.sh | 2 +- test/shell/lvmetad-pvs.sh | 2 +- test/shell/lvmlockd-hello-world.sh | 2 +- test/shell/lvrename-cache-thin.sh | 2 +- test/shell/lvresize-full.sh | 2 +- test/shell/lvresize-mirror.sh | 2 +- test/shell/lvresize-raid.sh | 4 ++-- test/shell/lvresize-raid10.sh | 2 +- test/shell/lvresize-rounding.sh | 6 ++--- test/shell/lvresize-thin-metadata.sh | 2 +- test/shell/lvresize-usage.sh | 2 +- test/shell/metadata-dirs.sh | 14 ++++++------ test/shell/metadata.sh | 7 +++--- test/shell/mirror-vgreduce-removemissing.sh | 4 ++-- test/shell/name-mangling.sh | 2 +- test/shell/nomda-missing.sh | 4 ++-- test/shell/nomda-restoremissing.sh | 2 +- test/shell/orphan-ondisk.sh | 2 +- test/shell/pool-labels.sh | 2 +- test/shell/process-each-pv-nomda.sh | 2 +- test/shell/process-each-pvresize.sh | 8 +++---- test/shell/process-each-vgreduce.sh | 16 +++++++------- test/shell/profiles-thin.sh | 6 ++--- test/shell/profiles.sh | 4 ++-- test/shell/pv-check-dev-size.sh | 8 +++---- test/shell/pv-duplicate-uuid.sh | 2 +- test/shell/pv-ext-update.sh | 2 +- test/shell/pv-min-size.sh | 2 +- test/shell/pv-range-overflow.sh | 2 +- test/shell/pvchange-usage.sh | 10 ++++----- test/shell/pvcreate-bootloaderarea.sh | 4 ++-- test/shell/pvcreate-metadata0.sh | 4 ++-- test/shell/pvcreate-operation.sh | 16 +++++++------- test/shell/pvcreate-usage.sh | 18 +++++++-------- test/shell/pvremove-thin.sh | 2 +- test/shell/pvremove-usage.sh | 6 ++--- test/shell/pvremove-warnings.sh | 4 ++-- test/shell/pvresize-mdas.sh | 2 +- test/shell/read-ahead.sh | 2 +- test/shell/relative-sign-options.sh | 2 +- test/shell/report-fields.sh | 2 +- test/shell/report-hidden.sh | 2 +- test/shell/select-report.sh | 8 +++---- test/shell/select-tools-thin.sh | 4 ++-- test/shell/select-tools.sh | 6 ++--- test/shell/snapshot-autoumount-dmeventd.sh | 2 +- test/shell/snapshot-cluster.sh | 2 +- test/shell/snapshot-maxsize.sh | 4 ++-- test/shell/snapshot-merge-stack.sh | 2 +- test/shell/snapshot-merge.sh | 2 +- test/shell/snapshot-reactivate.sh | 2 +- test/shell/snapshot-rename.sh | 2 +- test/shell/snapshots-of-mirrors.sh | 2 +- test/shell/stray-device-node.sh | 4 ++-- test/shell/system_id.sh | 2 ++ test/shell/tags.sh | 16 +++++++------- test/shell/test-partition.sh | 2 +- test/shell/thin-autoumount-dmeventd.sh | 2 +- test/shell/thin-defaults.sh | 2 +- test/shell/thin-dmeventd-warns.sh | 2 +- test/shell/thin-foreign-dmeventd.sh | 2 +- test/shell/thin-merge.sh | 2 +- test/shell/thin-overprovisioning.sh | 2 +- test/shell/thin-resize-match.sh | 2 +- test/shell/thin-restore.sh | 2 +- test/shell/thin-vglock.sh | 2 +- test/shell/thin-volume-list.sh | 2 +- test/shell/topology-support.sh | 8 +++---- test/shell/unknown-segment.sh | 2 +- test/shell/vg-check-devs-used.sh | 4 ++-- test/shell/vg-name-from-env.sh | 6 ++--- test/shell/vgcfgbackup-lvm1.sh | 4 ++-- test/shell/vgcfgbackup-usage.sh | 8 +++---- test/shell/vgchange-many.sh | 4 ++-- test/shell/vgchange-maxlv.sh | 6 ++--- test/shell/vgchange-partial.sh | 2 +- test/shell/vgchange-sysinit.sh | 10 ++++++--- test/shell/vgck.sh | 2 +- test/shell/vgcreate-many-pvs.sh | 6 ++--- test/shell/vgextend-usage.sh | 22 +++++++++---------- test/shell/vgremove-corrupt-vg.sh | 2 +- test/shell/vgsplit-stacked.sh | 6 ++--- test/shell/zero-usage.sh | 2 +- 158 files changed, 294 insertions(+), 289 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index b47ce1f3f..bd42f300a 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -1161,7 +1161,7 @@ prepare_vg() { teardown_devs prepare_devs "$@" - vgcreate -s 512K "$vg" "${DEVICES[@]}" + vgcreate $SHARED -s 512K "$vg" "${DEVICES[@]}" } extend_filter() { diff --git a/test/shell/000-basic.sh b/test/shell/000-basic.sh index c4a1f4abc..1e511d1f0 100644 --- a/test/shell/000-basic.sh +++ b/test/shell/000-basic.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/activate-minor.sh b/test/shell/activate-minor.sh index e2db1c0cd..1b1ea8bda 100644 --- a/test/shell/activate-minor.sh +++ b/test/shell/activate-minor.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/activate-missing-segment.sh b/test/shell/activate-missing-segment.sh index 777a1bf04..f066e587a 100644 --- a/test/shell/activate-missing-segment.sh +++ b/test/shell/activate-missing-segment.sh @@ -17,7 +17,7 @@ # instead lvconvert --repair them?) # - linear LVs with bits missing are not activated -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/activate-missing.sh b/test/shell/activate-missing.sh index 6b6211534..c1c02d8fd 100644 --- a/test/shell/activate-missing.sh +++ b/test/shell/activate-missing.sh @@ -17,7 +17,7 @@ # instead lvconvert --repair them?) # - linear LVs with bits missing are not activated -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/activate-partial.sh b/test/shell/activate-partial.sh index be21d7ca0..70c50bc96 100644 --- a/test/shell/activate-partial.sh +++ b/test/shell/activate-partial.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/activation-skip.sh b/test/shell/activation-skip.sh index 7aca44c6d..b0b320657 100644 --- a/test/shell/activation-skip.sh +++ b/test/shell/activation-skip.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/backup-read-only.sh b/test/shell/backup-read-only.sh index f7033cb57..331e8464c 100644 --- a/test/shell/backup-read-only.sh +++ b/test/shell/backup-read-only.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/component-raid.sh b/test/shell/component-raid.sh index 4ef960080..bff56d4dd 100644 --- a/test/shell/component-raid.sh +++ b/test/shell/component-raid.sh @@ -12,7 +12,7 @@ # Exercise activation of raid component devices -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/covercmd.sh b/test/shell/covercmd.sh index 711ca13f6..16b2e6c37 100644 --- a/test/shell/covercmd.sh +++ b/test/shell/covercmd.sh @@ -15,7 +15,7 @@ # to improve code coverage # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -29,7 +29,7 @@ pvcreate --metadatacopies 0 "$dev3" # FIXME takes very long time #pvck "$dev1" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -l 5 -i5 -I256 -n $lv $vg lvcreate -aey -l 5 -n $lv1 $vg diff --git a/test/shell/discards-thin.sh b/test/shell/discards-thin.sh index 92df211d1..f27d4c3d1 100644 --- a/test/shell/discards-thin.sh +++ b/test/shell/discards-thin.sh @@ -13,7 +13,7 @@ # test support of thin discards # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -80,10 +80,10 @@ vgremove -ff $vg # device below does not support it, the kernel value # of discards actually used will be "nopassdown". # This is why we have "-o discards" and "-o kernel_discards". -vgcreate -s 1m "${vg}_1" "${DEVICES[@]}" +vgcreate $SHARED -s 1m "${vg}_1" "${DEVICES[@]}" lvcreate -l 10 -T ${vg}_1/pool --discards ignore lvcreate -V 9m -T ${vg}_1/pool -n device_with_ignored_discards -vgcreate -s 1m ${vg}_2 "$DM_DEV_DIR/${vg}_1/device_with_ignored_discards" +vgcreate $SHARED -s 1m ${vg}_2 "$DM_DEV_DIR/${vg}_1/device_with_ignored_discards" lvcreate -l 1 -T ${vg}_2/pool --discards passdown lvcreate -V 1 -T ${vg}_2/pool check lv_field ${vg}_1/pool discards "ignore" diff --git a/test/shell/dmeventd-restart.sh b/test/shell/dmeventd-restart.sh index 58575fc71..65f1655d9 100644 --- a/test/shell/dmeventd-restart.sh +++ b/test/shell/dmeventd-restart.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/dmstats-create.sh b/test/shell/dmstats-create.sh index 03406aeff..e28c9ef9d 100644 --- a/test/shell/dmstats-create.sh +++ b/test/shell/dmstats-create.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/dmstats-report.sh b/test/shell/dmstats-report.sh index bd72f1a61..965fca80e 100644 --- a/test/shell/dmstats-report.sh +++ b/test/shell/dmstats-report.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/dumpconfig.sh b/test/shell/dumpconfig.sh index ae4028cd5..abd4b6275 100644 --- a/test/shell/dumpconfig.sh +++ b/test/shell/dumpconfig.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/error-usage.sh b/test/shell/error-usage.sh index d75eacfd8..59502480c 100644 --- a/test/shell/error-usage.sh +++ b/test/shell/error-usage.sh @@ -12,7 +12,7 @@ # Basic usage of zero target -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/fsadm-crypt.sh b/test/shell/fsadm-crypt.sh index 77bda3591..d90413d88 100644 --- a/test/shell/fsadm-crypt.sh +++ b/test/shell/fsadm-crypt.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise fsadm filesystem resize on crypt devices' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 # FIXME: cannot use brd (ramdisk) - lsblk is NOT listing it diff --git a/test/shell/fsadm-renamed.sh b/test/shell/fsadm-renamed.sh index beec6becf..321893925 100644 --- a/test/shell/fsadm-renamed.sh +++ b/test/shell/fsadm-renamed.sh @@ -11,7 +11,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA test_description='Exercise fsadm operation on renamed device' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/fsadm.sh b/test/shell/fsadm.sh index 62eb7d351..fa9da355c 100644 --- a/test/shell/fsadm.sh +++ b/test/shell/fsadm.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise fsadm filesystem resize' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/listings.sh b/test/shell/listings.sh index 8de94904a..0c614d005 100644 --- a/test/shell/listings.sh +++ b/test/shell/listings.sh @@ -14,7 +14,6 @@ # tests functionality of lvs, pvs, vgs, *display tools # -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -40,7 +39,7 @@ pvdisplay #COMM pvs with segment attributes works even for orphans test "$(pvs --noheadings -o seg_all,pv_all,lv_all,vg_all "${DEVICES[@]}" | wc -l)" -eq 5 -vgcreate $vg "${DEVICES[@]}" +vgcreate $SHARED $vg "${DEVICES[@]}" check pv_field "$dev1" pv_uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE @@ -202,17 +201,17 @@ vgremove -ff $vg # all LVs active - VG considered active pvcreate "$dev1" "$dev2" "$dev3" -vgcreate $vg1 "$dev1" +vgcreate $SHARED $vg1 "$dev1" lvcreate -l1 $vg1 lvcreate -l1 $vg1 # at least one LV active - VG considered active -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg2 "$dev2" lvcreate -l1 $vg2 lvcreate -l1 -an -Zn $vg2 # no LVs active - VG considered inactive -vgcreate $vg3 "$dev3" +vgcreate $SHARED $vg3 "$dev3" lvcreate -l1 -an -Zn $vg3 lvcreate -l1 -an -Zn $vg3 diff --git a/test/shell/lock-blocking.sh b/test/shell/lock-blocking.sh index 85f7a1015..5f69a1ac2 100644 --- a/test/shell/lock-blocking.sh +++ b/test/shell/lock-blocking.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='test some blocking / non-blocking multi-vg operations' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 @@ -19,7 +19,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_devs 3 pvcreate "$dev1" "$dev2" -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" # if wait_for_locks set, vgremove should wait for orphan lock # flock process should have exited by the time first vgremove completes @@ -33,7 +33,7 @@ test ! -f "$TESTDIR/var/lock/lvm/P_orphans" # if wait_for_locks not set, vgremove should fail on non-blocking lock # we must wait for flock process at the end - vgremove won't wait -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" flock -w 5 "$TESTDIR/var/lock/lvm/P_orphans" sleep 10 & while ! test -f "$TESTDIR/var/lock/lvm/P_orphans" ; do sleep .1 ; done diff --git a/test/shell/lock-parallel.sh b/test/shell/lock-parallel.sh index 89fb397e8..5526b62e0 100644 --- a/test/shell/lock-parallel.sh +++ b/test/shell/lock-parallel.sh @@ -13,7 +13,7 @@ # Test parallel use of lvm commands and check locks aren't dropped # RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1049296 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/losetup-partscan.sh b/test/shell/losetup-partscan.sh index df32b61f6..98b2677f8 100644 --- a/test/shell/losetup-partscan.sh +++ b/test/shell/losetup-partscan.sh @@ -12,7 +12,7 @@ # Check how lvm2 handles partitions over losetup -P devices -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -37,7 +37,7 @@ aux extend_filter "a|$LOOP|" # creation should fail for 'partitioned' loop device not pvcreate -y "$LOOP" -not vgcreate vg "$LOOP" +not vgcreate $SHARED vg "$LOOP" aux teardown_devs @@ -61,4 +61,4 @@ aux extend_filter "a|$LOOP|" # creation should pass for 'non-partitioned' loop device pvcreate -y "$LOOP" -vgcreate vg "$LOOP" +vgcreate $SHARED vg "$LOOP" diff --git a/test/shell/lv-ancestry.sh b/test/shell/lv-ancestry.sh index c36f366f8..b786d2e54 100644 --- a/test/shell/lv-ancestry.sh +++ b/test/shell/lv-ancestry.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + . lib/inittest @@ -21,7 +21,7 @@ get_devs aux lvmconf "metadata/record_lvs_history=1" -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" lvcreate -l100%FREE -T ${vg}/pool diff --git a/test/shell/lvchange-cache-syncaction-raid.sh b/test/shell/lvchange-cache-syncaction-raid.sh index 206c750d2..bd4500d5d 100644 --- a/test/shell/lvchange-cache-syncaction-raid.sh +++ b/test/shell/lvchange-cache-syncaction-raid.sh @@ -12,7 +12,7 @@ # test activation race for raid's --syncaction check -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/lvchange-mirror.sh b/test/shell/lvchange-mirror.sh index 8120dbea3..f21a0fa2b 100644 --- a/test/shell/lvchange-mirror.sh +++ b/test/shell/lvchange-mirror.sh @@ -12,7 +12,7 @@ # FIXME RESYNC doesn't work in cluster with exclusive activation # seriously broken! -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/lvchange-partial-raid10.sh b/test/shell/lvchange-partial-raid10.sh index caec3a3a8..2c961082d 100644 --- a/test/shell/lvchange-partial-raid10.sh +++ b/test/shell/lvchange-partial-raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-raid-transient-failures.sh b/test/shell/lvchange-raid-transient-failures.sh index 2ac14b072..35b489802 100644 --- a/test/shell/lvchange-raid-transient-failures.sh +++ b/test/shell/lvchange-raid-transient-failures.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh index e6626d187..1972a68e2 100644 --- a/test/shell/lvchange-raid.sh +++ b/test/shell/lvchange-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-raid1-writemostly.sh b/test/shell/lvchange-raid1-writemostly.sh index 6e508c48e..039429a41 100644 --- a/test/shell/lvchange-raid1-writemostly.sh +++ b/test/shell/lvchange-raid1-writemostly.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-rebuild-raid.sh b/test/shell/lvchange-rebuild-raid.sh index 55791068d..913a88d33 100644 --- a/test/shell/lvchange-rebuild-raid.sh +++ b/test/shell/lvchange-rebuild-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-syncaction-raid.sh b/test/shell/lvchange-syncaction-raid.sh index 84961ed89..73270f09e 100644 --- a/test/shell/lvchange-syncaction-raid.sh +++ b/test/shell/lvchange-syncaction-raid.sh @@ -12,7 +12,7 @@ # test activation race for raid's --syncaction check -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/lvchange-thin.sh b/test/shell/lvchange-thin.sh index 99215d96e..992ed7145 100644 --- a/test/shell/lvchange-thin.sh +++ b/test/shell/lvchange-thin.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -21,8 +21,8 @@ aux have_thin 1 0 0 || skip aux prepare_pvs 3 -vgcreate -s 128k $vg "$dev1" "$dev2" -vgcreate -s 128k $vg2 "$dev3" +vgcreate $SHARED -s 128k $vg "$dev1" "$dev2" +vgcreate $SHARED -s 128k $vg2 "$dev3" lvcreate -L10M -T $vg/pool diff --git a/test/shell/lvconvert-cache-chunks.sh b/test/shell/lvconvert-cache-chunks.sh index 404672271..72a64de02 100644 --- a/test/shell/lvconvert-cache-chunks.sh +++ b/test/shell/lvconvert-cache-chunks.sh @@ -13,7 +13,7 @@ # Exercise number of cache chunks in cache pool # Skips creation of real cached device for older cache targets... -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-m-raid1-degraded.sh b/test/shell/lvconvert-m-raid1-degraded.sh index f8a65d962..05c3e893c 100644 --- a/test/shell/lvconvert-m-raid1-degraded.sh +++ b/test/shell/lvconvert-m-raid1-degraded.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh index 06b345054..2378d48ff 100644 --- a/test/shell/lvconvert-mirror-basic.sh +++ b/test/shell/lvconvert-mirror-basic.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + # disable lvmetad logging as it bogs down test systems export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} diff --git a/test/shell/lvconvert-mirror-updown.sh b/test/shell/lvconvert-mirror-updown.sh index d5059c242..fd7a45ecd 100644 --- a/test/shell/lvconvert-mirror-updown.sh +++ b/test/shell/lvconvert-mirror-updown.sh @@ -12,14 +12,14 @@ # Demonstrate problem when upconverting and cutting leg in clvmd -SKIP_WITH_LVMLOCKD=1 + . lib/inittest aux prepare_pvs 3 100 get_devs -vgcreate -s 64k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64k "$vg" "${DEVICES[@]}" # Use zero devices for big mirror legs aux zero_dev "$dev2" $(get first_extent_sector "$dev2"): diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh index 3fd4822a8..87993dab1 100644 --- a/test/shell/lvconvert-mirror.sh +++ b/test/shell/lvconvert-mirror.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + # disable lvmetad logging as it bogs down test systems export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} @@ -22,7 +22,7 @@ get_devs # proper DEVRANGE needs to be set according to extent size DEVRANGE="0-32" -vgcreate -s 32k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 32k "$vg" "${DEVICES[@]}" # convert from linear to 2-way mirror ("mirror" default type) lvcreate -aey -l2 -n $lv1 $vg "$dev1" diff --git a/test/shell/lvconvert-raid-regionsize.sh b/test/shell/lvconvert-raid-regionsize.sh index 893c158ba..cba04cc8d 100644 --- a/test/shell/lvconvert-raid-regionsize.sh +++ b/test/shell/lvconvert-raid-regionsize.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh index 0be8777b3..55d4c18eb 100644 --- a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh +++ b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh index 5230b2b92..ed3769d39 100644 --- a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh +++ b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-takeover-alloc-failure.sh b/test/shell/lvconvert-raid-takeover-alloc-failure.sh index e0e36cc1e..21d051100 100644 --- a/test/shell/lvconvert-raid-takeover-alloc-failure.sh +++ b/test/shell/lvconvert-raid-takeover-alloc-failure.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-takeover-thin.sh b/test/shell/lvconvert-raid-takeover-thin.sh index 580c1be35..8bea24495 100644 --- a/test/shell/lvconvert-raid-takeover-thin.sh +++ b/test/shell/lvconvert-raid-takeover-thin.sh @@ -13,7 +13,7 @@ # check we may convert thin-pool to raid1/raid10 and back # RHBZ#1365286 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-takeover.sh b/test/shell/lvconvert-raid-takeover.sh index c8591be0e..d1c5d305b 100644 --- a/test/shell/lvconvert-raid-takeover.sh +++ b/test/shell/lvconvert-raid-takeover.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh index c5e61593e..ce60b6b0d 100644 --- a/test/shell/lvconvert-raid.sh +++ b/test/shell/lvconvert-raid.sh @@ -12,7 +12,6 @@ # disable lvmetad logging as it bogs down test systems -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} @@ -36,7 +35,7 @@ aux prepare_pvs 9 get_devs # vgcreate -s 256k "$vg" "${DEVICES[@]}" -vgcreate -s 2m "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 2m "$vg" "${DEVICES[@]}" ########################################### # RAID1 convert tests diff --git a/test/shell/lvconvert-raid0_to_raid10.sh b/test/shell/lvconvert-raid0_to_raid10.sh index d1e1fa046..03c8d6d58 100644 --- a/test/shell/lvconvert-raid0_to_raid10.sh +++ b/test/shell/lvconvert-raid0_to_raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -22,7 +22,7 @@ aux have_raid 1 12 0 || skip # 8 PVs needed for RAID10 testing (4-stripes/2-mirror) aux prepare_pvs 8 64 get_devs -vgcreate -s 256k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 256k "$vg" "${DEVICES[@]}" lvcreate -y --ty raid0 -R32.00k -i 4 -n $lv1 -L 64M $vg lvcreate -y -i4 -l4 -n $lv2 $vg diff --git a/test/shell/lvconvert-raid10.sh b/test/shell/lvconvert-raid10.sh index e37d73a68..c41293575 100644 --- a/test/shell/lvconvert-raid10.sh +++ b/test/shell/lvconvert-raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -34,7 +34,7 @@ aux have_raid 1 3 1 || skip aux prepare_pvs 9 80 get_devs -vgcreate -s 256k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 256k "$vg" "${DEVICES[@]}" lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv1 $vg aux wait_for_sync $vg $lv1 diff --git a/test/shell/lvconvert-raid456.sh b/test/shell/lvconvert-raid456.sh index 5797403da..5198753e3 100644 --- a/test/shell/lvconvert-raid456.sh +++ b/test/shell/lvconvert-raid456.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-raid.sh b/test/shell/lvconvert-repair-raid.sh index d29b72d15..2f417603d 100644 --- a/test/shell/lvconvert-repair-raid.sh +++ b/test/shell/lvconvert-repair-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-thin-raid.sh b/test/shell/lvconvert-repair-thin-raid.sh index 3d8964792..b97c5b405 100644 --- a/test/shell/lvconvert-repair-thin-raid.sh +++ b/test/shell/lvconvert-repair-thin-raid.sh @@ -12,7 +12,7 @@ # Test repairing of broken thin pool on raid -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-thin-raid.sh b/test/shell/lvconvert-thin-raid.sh index 8efafbce3..c021e3b77 100644 --- a/test/shell/lvconvert-thin-raid.sh +++ b/test/shell/lvconvert-thin-raid.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/lvconvert-twostep.sh b/test/shell/lvconvert-twostep.sh index cbdf8624d..44527f0bd 100644 --- a/test/shell/lvconvert-twostep.sh +++ b/test/shell/lvconvert-twostep.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/lvcreate-cache-fail.sh b/test/shell/lvcreate-cache-fail.sh index dc7c53a02..39a827395 100644 --- a/test/shell/lvcreate-cache-fail.sh +++ b/test/shell/lvcreate-cache-fail.sh @@ -13,7 +13,7 @@ # Exercise creation of cache and cache pool volumes and failure path # https://bugzilla.redhat.com/1355923 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -21,7 +21,7 @@ SKIP_WITH_LVMPOLLD=1 aux have_cache 1 3 0 || skip #aux prepare_pvs 1 4707950 -#vgcreate $vg "$dev1" +#vgcreate $SHARED $vg "$dev1" #lvcreate -L4T -n $lv1 $vg #lvcreate -H -L500G -n cache $vg/$lv1 #fail lvcreate -H -l 127999 -n cache $vg/$lv1 diff --git a/test/shell/lvcreate-mirror.sh b/test/shell/lvcreate-mirror.sh index e9ffd3eb2..0e9237d1f 100644 --- a/test/shell/lvcreate-mirror.sh +++ b/test/shell/lvcreate-mirror.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-missing.sh b/test/shell/lvcreate-missing.sh index fda62c6fc..18c979f20 100644 --- a/test/shell/lvcreate-missing.sh +++ b/test/shell/lvcreate-missing.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-operation.sh b/test/shell/lvcreate-operation.sh index 38d50cd6b..5faa39fd3 100644 --- a/test/shell/lvcreate-operation.sh +++ b/test/shell/lvcreate-operation.sh @@ -12,7 +12,7 @@ # 'Exercise some lvcreate diagnostics' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -27,7 +27,7 @@ aux prepare_pvs 2 get_devs aux pvcreate --metadatacopies 0 "$dev1" -aux vgcreate "$vg" "${DEVICES[@]}" +aux vgcreate $SHARED "$vg" "${DEVICES[@]}" # --- # Create snapshots of LVs on --metadatacopies 0 PV (bz450651) diff --git a/test/shell/lvcreate-raid-nosync.sh b/test/shell/lvcreate-raid-nosync.sh index c0e23bb25..dcc248e0c 100644 --- a/test/shell/lvcreate-raid-nosync.sh +++ b/test/shell/lvcreate-raid-nosync.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-raid-volume_list.sh b/test/shell/lvcreate-raid-volume_list.sh index a47b9614d..052cf19b0 100644 --- a/test/shell/lvcreate-raid-volume_list.sh +++ b/test/shell/lvcreate-raid-volume_list.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 # bz1161347 - When raid creation is aborted, left-over devices appear @@ -24,7 +24,7 @@ aux have_raid 1 3 0 || skip aux prepare_pvs 2 # 2 devices for RAID1 get_devs -vgcreate -s 512k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 512k "$vg" "${DEVICES[@]}" aux lvmconf "activation/volume_list = [ \"vg_not_exist\" ]" diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh index f29e7888b..b60544363 100644 --- a/test/shell/lvcreate-raid.sh +++ b/test/shell/lvcreate-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -30,7 +30,7 @@ aux have_raid4 && RAID4=raid4 aux prepare_pvs 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test get_devs -vgcreate -s 512k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 512k "$vg" "${DEVICES[@]}" ########################################### # Create, wait for sync, remove tests diff --git a/test/shell/lvcreate-raid10.sh b/test/shell/lvcreate-raid10.sh index 4bb785d9e..39069afa3 100644 --- a/test/shell/lvcreate-raid10.sh +++ b/test/shell/lvcreate-raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh index d70d85af2..73fea54fd 100644 --- a/test/shell/lvcreate-signature-wiping.sh +++ b/test/shell/lvcreate-signature-wiping.sh @@ -12,7 +12,7 @@ # 'Exercise signature wiping during lvcreate' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-small-snap.sh b/test/shell/lvcreate-small-snap.sh index 08872fdee..09237ec63 100644 --- a/test/shell/lvcreate-small-snap.sh +++ b/test/shell/lvcreate-small-snap.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -18,7 +18,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_pvs get_devs -vgcreate -s 4k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 4k "$vg" "${DEVICES[@]}" # 3 Chunks lvcreate -aey -n one -l 10 $vg diff --git a/test/shell/lvcreate-striped-mirror.sh b/test/shell/lvcreate-striped-mirror.sh index eb40bfad3..b9605220d 100644 --- a/test/shell/lvcreate-striped-mirror.sh +++ b/test/shell/lvcreate-striped-mirror.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-thin-big.sh b/test/shell/lvcreate-thin-big.sh index 46e017a0f..0625a598c 100644 --- a/test/shell/lvcreate-thin-big.sh +++ b/test/shell/lvcreate-thin-big.sh @@ -13,7 +13,7 @@ # test currently needs to drop # 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using " -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -27,7 +27,7 @@ aux have_thin 1 0 0 || skip aux prepare_pvs 10 16500 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" # Size 0 is not valid invalid lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg/pool1 2>out diff --git a/test/shell/lvcreate-thin-external-size.sh b/test/shell/lvcreate-thin-external-size.sh index c744150a3..862dd159c 100644 --- a/test/shell/lvcreate-thin-external-size.sh +++ b/test/shell/lvcreate-thin-external-size.sh @@ -12,7 +12,7 @@ # Test unaligned size of external origin and thin pool chunk size -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -32,7 +32,7 @@ aux prepare_pvs 2 640 get_devs # Use 8K extent size -vgcreate -s 8K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 8K "$vg" "${DEVICES[@]}" # Prepare some numeric pattern with ~64K size seq -s ' ' -w 0 10922 > 64K diff --git a/test/shell/lvcreate-thin-external.sh b/test/shell/lvcreate-thin-external.sh index e94ffe3a0..20f0577ba 100644 --- a/test/shell/lvcreate-thin-external.sh +++ b/test/shell/lvcreate-thin-external.sh @@ -12,7 +12,7 @@ # Test creation of thin snapshots using external origin -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -30,7 +30,7 @@ aux have_thin 1 3 0 || skip aux prepare_pvs 2 64 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" # Newer thin-pool target (>= 1.13) supports unaligned external origin # But this test is written to test and expect older behavior diff --git a/test/shell/lvcreate-thin-power2.sh b/test/shell/lvcreate-thin-power2.sh index 18b285341..ec9755ae4 100644 --- a/test/shell/lvcreate-thin-power2.sh +++ b/test/shell/lvcreate-thin-power2.sh @@ -13,7 +13,7 @@ # test support for non-power-of-2 thin chunk size # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -28,7 +28,7 @@ aux have_thin 1 4 0 || skip aux prepare_pvs 2 64 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" # create non-power-of-2 pool lvcreate -l100 -c 192 -T $vg/pool diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh index ac603d875..6e6410cc1 100644 --- a/test/shell/lvcreate-thin-snap.sh +++ b/test/shell/lvcreate-thin-snap.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -37,7 +37,7 @@ which mkfs.ext4 || skip aux prepare_pvs 2 64 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" lvcreate -L10M -V10M -T $vg/pool --name $lv1 mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1" diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh index 27cce2225..8e04c9e64 100644 --- a/test/shell/lvcreate-thin.sh +++ b/test/shell/lvcreate-thin.sh @@ -13,7 +13,7 @@ # test currently needs to drop # 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using " -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -39,7 +39,7 @@ which mkfs.ext4 || skip aux prepare_pvs 2 64 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" # Create named pool only lvcreate -l1 -T $vg/pool1 diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh index 4b5c2b6f2..6d424014e 100644 --- a/test/shell/lvcreate-usage.sh +++ b/test/shell/lvcreate-usage.sh @@ -12,15 +12,13 @@ # 'Exercise some lvcreate diagnostics' -SKIP_WITH_LVMLOCKD=1 - . lib/inittest aux prepare_pvs 4 get_devs aux pvcreate --metadatacopies 0 "$dev1" -aux vgcreate "$vg" "${DEVICES[@]}" +aux vgcreate $SHARED "$vg" "${DEVICES[@]}" invalid lvcreate --type free -l1 -n $lv1 $vg 2>err grep "Invalid argument for --type" err @@ -146,6 +144,10 @@ grep "Redundant" err check lv_field $vg/$lv1 segtype "linear" lvremove -ff $vg +if test -n "$LVM_TEST_LVMLOCKD"; then +echo "skip snapshot without origin" +else + # Old --type snapshot works with -s lvcreate --type snapshot -s -V64 -L32 -n $lv1 $vg check lv_field $vg/$lv1 segtype "linear" @@ -162,6 +164,8 @@ lvchange -a n $vg/$lv1 lvremove -ff $vg/$lv1 lvremove -ff $vg +fi + # readahead default (auto), none, #, auto lvcreate -L 8 -n $lv1 $vg check lv_field $vg/$lv1 lv_read_ahead "auto" diff --git a/test/shell/lvextend-percent-extents.sh b/test/shell/lvextend-percent-extents.sh index c73731026..5d4946d89 100644 --- a/test/shell/lvextend-percent-extents.sh +++ b/test/shell/lvextend-percent-extents.sh @@ -12,7 +12,7 @@ # 'Check extents percentage arguments' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -20,7 +20,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_pvs 2 128 get_devs -aux vgcreate "$vg" "${DEVICES[@]}" +aux vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -L64 -n $lv $vg diff --git a/test/shell/lvextend-snapshot-policy.sh b/test/shell/lvextend-snapshot-policy.sh index 47def9374..c49cbb398 100644 --- a/test/shell/lvextend-snapshot-policy.sh +++ b/test/shell/lvextend-snapshot-policy.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvextend-thin-data-dmeventd.sh b/test/shell/lvextend-thin-data-dmeventd.sh index dce7e8c39..7dfec4acc 100644 --- a/test/shell/lvextend-thin-data-dmeventd.sh +++ b/test/shell/lvextend-thin-data-dmeventd.sh @@ -12,7 +12,7 @@ # Test autoextension of thin data volume -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -38,7 +38,7 @@ aux lvmconf "activation/thin_pool_autoextend_percent = 10" \ aux prepare_pvs 3 256 get_devs -vgcreate -s 256K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 256K "$vg" "${DEVICES[@]}" lvcreate -L1M -c 64k -T $vg/pool lvcreate -V1M $vg/pool -n $lv1 diff --git a/test/shell/lvextend-thin-raid.sh b/test/shell/lvextend-thin-raid.sh index a623bb8d6..afbc63027 100644 --- a/test/shell/lvextend-thin-raid.sh +++ b/test/shell/lvextend-thin-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/lvextend-thin.sh b/test/shell/lvextend-thin.sh index 82d898381..3e39ea3eb 100644 --- a/test/shell/lvextend-thin.sh +++ b/test/shell/lvextend-thin.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/lvm-init.sh b/test/shell/lvm-init.sh index 92e050be6..7af3ef90e 100644 --- a/test/shell/lvm-init.sh +++ b/test/shell/lvm-init.sh @@ -14,7 +14,7 @@ # tests lvm initialization, and especially negative tests of error paths # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvmetad-pvs.sh b/test/shell/lvmetad-pvs.sh index 43895286d..dc4189d95 100644 --- a/test/shell/lvmetad-pvs.sh +++ b/test/shell/lvmetad-pvs.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvmlockd-hello-world.sh b/test/shell/lvmlockd-hello-world.sh index 194b9979d..43946a54b 100644 --- a/test/shell/lvmlockd-hello-world.sh +++ b/test/shell/lvmlockd-hello-world.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -test_description='Hello world for vgcreate with lvmlockd and sanlock' +test_description='Hello world for vgcreate $SHARED with lvmlockd and sanlock' . lib/inittest diff --git a/test/shell/lvrename-cache-thin.sh b/test/shell/lvrename-cache-thin.sh index eb1b72672..8e9bd78bc 100644 --- a/test/shell/lvrename-cache-thin.sh +++ b/test/shell/lvrename-cache-thin.sh @@ -12,7 +12,7 @@ # Check rename of stacked thin over cached LV -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvresize-full.sh b/test/shell/lvresize-full.sh index c49778149..3cab52275 100644 --- a/test/shell/lvresize-full.sh +++ b/test/shell/lvresize-full.sh @@ -13,7 +13,7 @@ # Excersize resize of filesystem when size of LV already matches # https://bugzilla.redhat.com/1354396 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvresize-mirror.sh b/test/shell/lvresize-mirror.sh index 8489b63df..61e4491bd 100644 --- a/test/shell/lvresize-mirror.sh +++ b/test/shell/lvresize-mirror.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh index fd210a042..4260de88d 100644 --- a/test/shell/lvresize-raid.sh +++ b/test/shell/lvresize-raid.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -24,7 +24,7 @@ aux have_raid 1 7 0 && levels="0 0_meta $levels" aux prepare_pvs 6 get_devs -vgcreate -s 256K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 256K "$vg" "${DEVICES[@]}" for deactivate in true false; do diff --git a/test/shell/lvresize-raid10.sh b/test/shell/lvresize-raid10.sh index 5f400acf0..e28b684f4 100644 --- a/test/shell/lvresize-raid10.sh +++ b/test/shell/lvresize-raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvresize-rounding.sh b/test/shell/lvresize-rounding.sh index 9a917ce18..0cdce558f 100644 --- a/test/shell/lvresize-rounding.sh +++ b/test/shell/lvresize-rounding.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -18,7 +18,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_pvs 3 22 get_devs -vgcreate -s 32K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 32K "$vg" "${DEVICES[@]}" lvcreate -an -Zn -l4 -i3 -I64 $vg @@ -55,7 +55,7 @@ check vg_field $vg vg_free_count 2 lvreduce -f -l50%LV $vg/$lv1 vgremove -f $vg -vgcreate -s 4M $vg "$dev1" "$dev2" "$dev3" +vgcreate $SHARED -s 4M $vg "$dev1" "$dev2" "$dev3" # Expect to play with 15 extents check vg_field $vg vg_free_count 15 diff --git a/test/shell/lvresize-thin-metadata.sh b/test/shell/lvresize-thin-metadata.sh index 54142ce23..f27934b3b 100644 --- a/test/shell/lvresize-thin-metadata.sh +++ b/test/shell/lvresize-thin-metadata.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/lvresize-usage.sh b/test/shell/lvresize-usage.sh index 23f73aed6..a7e154477 100644 --- a/test/shell/lvresize-usage.sh +++ b/test/shell/lvresize-usage.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/metadata-dirs.sh b/test/shell/metadata-dirs.sh index d30e3c77f..2a433403e 100644 --- a/test/shell/metadata-dirs.sh +++ b/test/shell/metadata-dirs.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -19,30 +19,30 @@ aux prepare_devs 3 get_devs pvcreate --metadatacopies 0 "${DEVICES[@]}" -not vgcreate "$vg" "${DEVICES[@]}" +not vgcreate $SHARED "$vg" "${DEVICES[@]}" aux lvmconf "metadata/dirs = [ \"$TESTDIR/mda\" ]" -vgcreate $vg "$dev1" +vgcreate $SHARED $vg "$dev1" check vg_field $vg vg_mda_count 1 vgremove -ff $vg -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" check vg_field $vg vg_mda_count 1 vgremove -ff $vg pvcreate --metadatacopies 1 --metadataignore y "$dev1" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" check vg_field $vg vg_mda_count 2 vgremove -ff $vg pvcreate --metadatacopies 1 --metadataignore n "$dev1" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" check vg_field $vg vg_mda_count 2 vgremove -ff $vg pvcreate --metadatacopies 0 "$dev1" aux lvmconf "metadata/dirs = [ \"$TESTDIR/mda\", \"$TESTDIR/mda2\" ]" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" check vg_field $vg vg_mda_count 2 vgremove -ff $vg diff --git a/test/shell/metadata.sh b/test/shell/metadata.sh index 9492bdcdc..aae749ae4 100644 --- a/test/shell/metadata.sh +++ b/test/shell/metadata.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -24,7 +23,7 @@ pvcreate --metadatacopies 0 "$dev3" pvcreate "$dev4" pvcreate --metadatacopies 0 "$dev5" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -n $lv -l 1 -i5 -I256 $vg pvchange -x n "$dev1" @@ -38,7 +37,7 @@ vgremove -f $vg for mdacp in 1 0; do pvcreate --metadatacopies "$mdacp" "${DEVICES[@]}" pvcreate "$dev1" - vgcreate "$vg" "${DEVICES[@]}" + vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -n $lv1 -l 2 -i5 -I256 $vg lvcreate -aey -n $lv2 --type mirror -m2 -l 2 $vg lvchange -an $vg/$lv1 $vg/$lv2 @@ -53,7 +52,7 @@ if test -n "$LVM_TEST_LVM1" ; then pvcreate -M1 "$dev1" "$dev2" "$dev3" pv3_uuid=$(get pv_field "$dev3" pv_uuid) -vgcreate -M1 $vg "$dev1" "$dev2" "$dev3" +vgcreate $SHARED -M1 $vg "$dev1" "$dev2" "$dev3" pvchange --uuid "$dev1" # verify pe_start of all M1 PVs diff --git a/test/shell/mirror-vgreduce-removemissing.sh b/test/shell/mirror-vgreduce-removemissing.sh index c8f641173..69d9fe872 100644 --- a/test/shell/mirror-vgreduce-removemissing.sh +++ b/test/shell/mirror-vgreduce-removemissing.sh @@ -12,7 +12,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description="ensure that 'vgreduce --removemissing' works on mirrored LV" -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 # disable lvmetad logging as it bogs down test systems @@ -104,7 +104,7 @@ rest_pvs_() aux prepare_pvs 5 80 get_devs -vgcreate -s 64k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64k "$vg" "${DEVICES[@]}" BLOCKS=0-7 BLOCKS1=8-15 # --------------------------------------------------------------------- diff --git a/test/shell/name-mangling.sh b/test/shell/name-mangling.sh index 66c0aebce..8382ad1ef 100644 --- a/test/shell/name-mangling.sh +++ b/test/shell/name-mangling.sh @@ -12,7 +12,7 @@ # This test is not using any lvm command # so skip duplicate CLMVD and lvmetad test -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_CLVMD=1 SKIP_WITH_LVMETAD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/nomda-missing.sh b/test/shell/nomda-missing.sh index bb92fe752..dd5786702 100644 --- a/test/shell/nomda-missing.sh +++ b/test/shell/nomda-missing.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -18,7 +18,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_devs 4 pvcreate "$dev1" "$dev2" pvcreate --metadatacopies 0 "$dev3" "$dev4" -vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" lvcreate -l1 -n linear1 $vg "$dev1" lvcreate -l1 -n linear2 $vg "$dev2" diff --git a/test/shell/nomda-restoremissing.sh b/test/shell/nomda-restoremissing.sh index a14f58dfb..fb3f93053 100644 --- a/test/shell/nomda-restoremissing.sh +++ b/test/shell/nomda-restoremissing.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/orphan-ondisk.sh b/test/shell/orphan-ondisk.sh index 4c8dabd06..507b4820a 100644 --- a/test/shell/orphan-ondisk.sh +++ b/test/shell/orphan-ondisk.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/pool-labels.sh b/test/shell/pool-labels.sh index 7ae203dde..3f9b9424d 100644 --- a/test/shell/pool-labels.sh +++ b/test/shell/pool-labels.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # lvmetad does not handle pool labels so skip test. -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMETAD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/process-each-pv-nomda.sh b/test/shell/process-each-pv-nomda.sh index 8f09129ff..2185ce4c9 100644 --- a/test/shell/process-each-pv-nomda.sh +++ b/test/shell/process-each-pv-nomda.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Test process_each_pv with zero mda' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/process-each-pvresize.sh b/test/shell/process-each-pvresize.sh index 26b65d405..b2287b445 100644 --- a/test/shell/process-each-pvresize.sh +++ b/test/shell/process-each-pvresize.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise toollib process_each_pv' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -34,9 +34,9 @@ aux prepare_devs 14 # dev1 matchines dev10,dev11,etc # -vgcreate $vg1 "$dev10" -vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5" -vgcreate $vg3 "$dev6" "$dev7" "$dev8" "$dev9" +vgcreate $SHARED $vg1 "$dev10" +vgcreate $SHARED $vg2 "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate $SHARED $vg3 "$dev6" "$dev7" "$dev8" "$dev9" pvchange --addtag V2D3 "$dev3" pvchange --addtag V2D4 "$dev4" diff --git a/test/shell/process-each-vgreduce.sh b/test/shell/process-each-vgreduce.sh index 3cec6c8dd..23584bff4 100644 --- a/test/shell/process-each-vgreduce.sh +++ b/test/shell/process-each-vgreduce.sh @@ -12,7 +12,7 @@ test_description='Exercise toollib process_each_pv with vgreduce' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -31,9 +31,9 @@ aux prepare_devs 14 # dev1 matchines dev10,dev11,etc # -vgcreate $vg1 "$dev10" -vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5" -vgcreate $vg3 "$dev6" "$dev7" "$dev8" "$dev9" +vgcreate $SHARED $vg1 "$dev10" +vgcreate $SHARED $vg2 "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate $SHARED $vg3 "$dev6" "$dev7" "$dev8" "$dev9" pvchange --addtag V2D3 "$dev3" pvchange --addtag V2D4 "$dev4" @@ -190,7 +190,7 @@ pvchange --addtag V2D45 "$dev5" not vgreduce -a $vg2 # reset vgremove $vg2 -vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate $SHARED $vg2 "$dev2" "$dev3" "$dev4" "$dev5" pvchange --addtag V2D3 "$dev3" pvchange --addtag V2D4 "$dev4" pvchange --addtag V2D45 "$dev4" @@ -258,9 +258,9 @@ pvcreate "$dev14" --metadatacopies 0 # dev12 # dev13 -vgcreate $vg1 "$dev10" -vgcreate $vg2 "$dev2" "$dev3" "$dev4" "$dev5" -vgcreate $vg3 "$dev6" "$dev7" "$dev8" "$dev9" +vgcreate $SHARED $vg1 "$dev10" +vgcreate $SHARED $vg2 "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate $SHARED $vg3 "$dev6" "$dev7" "$dev8" "$dev9" pvchange --addtag V2D3 "$dev3" pvchange --addtag V2D4 "$dev4" diff --git a/test/shell/profiles-thin.sh b/test/shell/profiles-thin.sh index df6fd7306..40059becc 100644 --- a/test/shell/profiles-thin.sh +++ b/test/shell/profiles-thin.sh @@ -13,7 +13,7 @@ # test thin profile functionality # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -38,7 +38,7 @@ aux prepare_pvs 1 "$DEV_SIZE" SHOULD="" check sysfs "$dev1" queue/optimal_io_size "$EXPECT" || SHOULD=should -vgcreate $vg "$dev1" +vgcreate $SHARED $vg "$dev1" # By default, "generic" policy is used to # calculate chunk size which is 64KiB by default @@ -68,7 +68,7 @@ fi # The profile must be also applied if using the profile # for the whole VG - any LVs inherit this profile then. -vgcreate --profile thin-performance $vg "$dev1" +vgcreate $SHARED --profile thin-performance $vg "$dev1" lvcreate -L8m -T $vg/pool_performance_inherited # ...the LV does not have the profile attached, but VG does! check vg_field $vg profile "thin-performance" diff --git a/test/shell/profiles.sh b/test/shell/profiles.sh index cecb6e879..be720c880 100644 --- a/test/shell/profiles.sh +++ b/test/shell/profiles.sh @@ -13,7 +13,7 @@ # test basic profile functionality # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -100,7 +100,7 @@ not grep "$MSG_IGNORING_INVALID_MDA_PROFILE" msg # attaching/detaching profiles to VG/LV aux prepare_pvs 1 8 pvcreate "$dev1" -vgcreate $vg1 "$dev1" +vgcreate $SHARED $vg1 "$dev1" check vg_field $vg1 vg_profile "" lvcreate -l 1 -n $lv1 $vg1 check lv_field $vg1/$lv1 lv_profile "" diff --git a/test/shell/pv-check-dev-size.sh b/test/shell/pv-check-dev-size.sh index 58207c3b9..f9d31a171 100644 --- a/test/shell/pv-check-dev-size.sh +++ b/test/shell/pv-check-dev-size.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -21,7 +21,7 @@ aux lvmconf 'metadata/check_pv_device_sizes = 1' CHECK_MSG="smaller than corresponding PV size" -vgcreate "$vg" "$dev1" 2>err +vgcreate $SHARED "$vg" "$dev1" 2>err not grep "$CHECK_MSG" err pvs 2>err not grep "$CHECK_MSG" err @@ -29,7 +29,7 @@ vgremove -ff $vg # set PV size to 2x dev size pvcreate --yes --setphysicalvolumesize 16m "$dev1" -vgcreate "$vg" "$dev1" 2>err +vgcreate $SHARED "$vg" "$dev1" 2>err grep "$CHECK_MSG" err pvs 2>err grep "$CHECK_MSG" err @@ -38,7 +38,7 @@ vgremove -ff $vg # should be quiet if requested aux lvmconf 'metadata/check_pv_device_sizes = 0' pvcreate --yes --setphysicalvolumesize 16m "$dev1" -vgcreate "$vg" "$dev1" 2>err +vgcreate $SHARED "$vg" "$dev1" 2>err not grep "$CHECK_MSG" err pvs 2>err not grep "$CHECK_MSG" err diff --git a/test/shell/pv-duplicate-uuid.sh b/test/shell/pv-duplicate-uuid.sh index 2c121d747..a07681213 100644 --- a/test/shell/pv-duplicate-uuid.sh +++ b/test/shell/pv-duplicate-uuid.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Test 'Found duplicate' is shown -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/pv-ext-update.sh b/test/shell/pv-ext-update.sh index 44f301e1d..9059a226c 100644 --- a/test/shell/pv-ext-update.sh +++ b/test/shell/pv-ext-update.sh @@ -12,7 +12,7 @@ # lvmetad does not handle pool labels so skip test. SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/pv-min-size.sh b/test/shell/pv-min-size.sh index 3d3d5e9a6..574dce7e5 100644 --- a/test/shell/pv-min-size.sh +++ b/test/shell/pv-min-size.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/pv-range-overflow.sh b/test/shell/pv-range-overflow.sh index 08401db2e..f880a1311 100644 --- a/test/shell/pv-range-overflow.sh +++ b/test/shell/pv-range-overflow.sh @@ -12,7 +12,7 @@ # 'Ensure that pvmove diagnoses PE-range values 2^32 and larger.' -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/pvchange-usage.sh b/test/shell/pvchange-usage.sh index 383986e9b..1f1348d3a 100644 --- a/test/shell/pvchange-usage.sh +++ b/test/shell/pvchange-usage.sh @@ -12,7 +12,7 @@ # 'Test pvchange option values' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -26,7 +26,7 @@ aux prepare_pvs 4 # check 'allocatable' pv attribute pvcreate "$dev1" check pv_field "$dev1" pv_attr --- -vgcreate $vg1 "$dev1" +vgcreate $SHARED $vg1 "$dev1" check pv_field "$dev1" pv_attr a-- pvchange --allocatable n "$dev1" check pv_field "$dev1" pv_attr u-- @@ -41,7 +41,7 @@ do # cannot change allocatability for orphan PVs fail pvchange "$dev1" -x y fail pvchange "$dev1" -x n - vgcreate $vg1 "$dev4" "$dev1" + vgcreate $SHARED $vg1 "$dev4" "$dev1" # "pvchange adds/dels tag to pvs with metadatacopies = $mda " pvchange "$dev1" --addtag test$mda @@ -72,7 +72,7 @@ done # "pvchange uuid" pvcreate --metadatacopies 0 "$dev1" pvcreate --metadatacopies 2 "$dev2" -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" # Checking for different UUID after pvchange UUID1=$(get pv_field "$dev1" uuid) @@ -117,7 +117,7 @@ fail pvchange "$dev1" --deltag test if test -n "$LVM_TEST_LVM1" ; then # cannot add PV tag to lvm1 format pvcreate -M1 "$dev1" -vgcreate -M1 $vg1 "$dev1" +vgcreate $SHARED -M1 $vg1 "$dev1" fail pvchange "$dev1" --addtag test fi diff --git a/test/shell/pvcreate-bootloaderarea.sh b/test/shell/pvcreate-bootloaderarea.sh index f9e0929c9..2e16a5fb3 100644 --- a/test/shell/pvcreate-bootloaderarea.sh +++ b/test/shell/pvcreate-bootloaderarea.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Test pvcreate bootloader area support' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -45,7 +45,7 @@ grep "Bootloader area with data-aligned start must not exceed device size" err # restoring the PV should also restore the bootloader area correctly pvremove -ff "$dev1" pvcreate --dataalignment 256k --bootloaderareasize 600k "$dev1" -vgcreate $vg "$dev1" +vgcreate $SHARED $vg "$dev1" vgcfgbackup -f "$TESTDIR/vg_with_ba_backup" "$vg" pv_uuid=$(get pv_field "$dev1" pv_uuid) vgremove -ff $vg diff --git a/test/shell/pvcreate-metadata0.sh b/test/shell/pvcreate-metadata0.sh index ce29a5f47..c732a2e97 100644 --- a/test/shell/pvcreate-metadata0.sh +++ b/test/shell/pvcreate-metadata0.sh @@ -16,7 +16,7 @@ # # 'Test pvcreate without metadata on all pvs' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -28,7 +28,7 @@ pvcreate "$dev1" pvcreate --metadatacopies 0 "$dev2" # "check lv snapshot" -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" lvcreate -aey -n $lv -l 60%FREE $vg lvcreate -s -n $lv2 -l 10%FREE $vg/$lv vgremove -f $vg diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh index af1c5a237..c449438e6 100644 --- a/test/shell/pvcreate-operation.sh +++ b/test/shell/pvcreate-operation.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -46,7 +46,7 @@ do # pvcreate (lvm$mdatype) fails when PV belongs to VG # pvcreate -M$mdatype "$dev1" - vgcreate -M$mdatype $vg1 "$dev1" + vgcreate $SHARED -M$mdatype $vg1 "$dev1" not pvcreate -M$mdatype "$dev1" vgremove -f $vg1 @@ -55,7 +55,7 @@ do # pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG pvcreate -M$mdatype "$dev1" pvcreate -M$mdatype "$dev2" - vgcreate -M$mdatype $vg1 "$dev1" + vgcreate $SHARED -M$mdatype $vg1 "$dev1" # pvcreate a second time on $dev2 and $dev1 not pvcreate -M$mdatype "$dev2" "$dev1" @@ -77,7 +77,7 @@ done # pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG pvcreate --metadatacopies 0 "$dev1" pvcreate --metadatacopies 1 "$dev2" -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" not pvcreate "$dev1" vgremove -f $vg1 pvremove -f "$dev2" "$dev1" @@ -85,7 +85,7 @@ pvremove -f "$dev2" "$dev1" # pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG pvcreate --metadatacopies 0 "$dev1" pvcreate --metadatacopies 1 "$dev2" -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" pvcreate -ff -y "$dev1" vgreduce --removemissing $vg1 vgremove -ff $vg1 @@ -129,7 +129,7 @@ not pvcreate --uuid $uuid2 --restorefile "$backupfile" "$dev2" # (use case: one PV in a VG used solely to keep metadata) size_mb=$(($(blockdev --getsz "$dev1") / 2048)) pvcreate --metadatasize $size_mb "$dev1" -vgcreate $vg1 "$dev1" +vgcreate $SHARED $vg1 "$dev1" vgcfgbackup -f "$backupfile" vgcfgrestore -f "$backupfile" "$vg1" vgremove -f $vg1 @@ -139,7 +139,7 @@ pvremove -f "$dev1" # and check it's compatible with pe_start value being restored # X * dataalignment + dataalignmentoffset == pe_start pvcreate --norestorefile --uuid "$uuid1" --dataalignment 600k --dataalignmentoffset 32k "$dev1" -vgcreate $vg1 "$dev1" +vgcreate $SHARED $vg1 "$dev1" vgcfgbackup -f "$backupfile" "$vg1" vgremove -ff $vg1 pvremove -ff "$dev1" @@ -169,7 +169,7 @@ grep -- "Command does not accept option combination: --bootloaderareasize with rm -f "$backupfile" pvcreate --norestorefile --uuid $uuid1 "$dev1" -vgcreate --physicalextentsize 1m $vg1 "$dev1" +vgcreate $SHARED --physicalextentsize 1m $vg1 "$dev1" vgcfgbackup -f "$backupfile" "$vg1" vgremove -ff "$vg1" pvremove -ff "$dev1" diff --git a/test/shell/pvcreate-usage.sh b/test/shell/pvcreate-usage.sh index f0e6ee640..4ece05f78 100644 --- a/test/shell/pvcreate-usage.sh +++ b/test/shell/pvcreate-usage.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Test pvcreate option values' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 PAGESIZE=$(getconf PAGESIZE) # MDA_SIZE_MIN defined in lib/format_text/layout.h @@ -45,7 +45,7 @@ pvremove "$dev1" #Verify vg_mda_size is smaller pv_mda_size pvcreate --metadatasize 512k "$dev1" pvcreate --metadatasize 96k "$dev2" -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" pvs -o +pv_mda_size check compare_fields vgs $vg vg_mda_size pvs "$dev2" pv_mda_size vgremove $vg @@ -108,8 +108,8 @@ fi pvcreate --dataalignment 512k "$dev1" check pv_field "$dev1" pe_start "512.00k" -#COMM 'vgcreate/vgremove do not modify data offset of existing PV' -vgcreate $vg "$dev1" --config 'devices { data_alignment = 1024 }' +#COMM 'vgcreate $SHARED/vgremove do not modify data offset of existing PV' +vgcreate $SHARED $vg "$dev1" --config 'devices { data_alignment = 1024 }' check pv_field "$dev1" pe_start "512.00k" vgremove $vg --config 'devices { data_alignment = 1024 }' check pv_field "$dev1" pe_start "512.00k" @@ -147,7 +147,7 @@ check pv_field "$dev1" pv_mda_count 2 #compatible == LVM1_PE_ALIGN == 64k if test -n "$LVM_TEST_LVM1" ; then pvcreate --dataalignment 256k "$dev1" -vgcreate -s 1m $vg "$dev1" +vgcreate $SHARED -s 1m $vg "$dev1" vgconvert -M1 $vg vgconvert -M2 $vg check pv_field "$dev1" pe_start 256.00k @@ -157,7 +157,7 @@ fi #COMM 'pv with LVM1 incompatible data alignment cannot be convereted' if test -n "$LVM_TEST_LVM1" ; then pvcreate --dataalignment 10k "$dev1" -vgcreate -s 1m $vg "$dev1" +vgcreate $SHARED -s 1m $vg "$dev1" not vgconvert -M1 $vg vgremove $vg fi @@ -167,7 +167,7 @@ fi #not that final cfg is usable... pvcreate --metadatacopies 0 "$dev1" pvcreate "$dev2" -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" vgcfgbackup -f backup.$$ $vg sed 's/pe_start = [0-9]*/pe_start = 0/' backup.$$ > backup.$$1 vgcfgrestore -f backup.$$1 $vg @@ -190,9 +190,9 @@ for ignore in y n; do check pv_field "$dev1" pv_mda_used_count "$mdacp" check pv_field "$dev2" pv_mda_used_count "$mdacp" fi - echo "vgcreate has proper vg_mda_count and vg_mda_used_count" + echo "vgcreate $SHARED has proper vg_mda_count and vg_mda_used_count" if [ $pv_in_vg = 1 ]; then - vgcreate $vg "$dev1" "$dev2" + vgcreate $SHARED $vg "$dev1" "$dev2" check vg_field $vg vg_mda_count $(( mdacp * 2 )) if [ $ignore = y ]; then check vg_field $vg vg_mda_used_count "1" diff --git a/test/shell/pvremove-thin.sh b/test/shell/pvremove-thin.sh index 9bb9d448b..9859b6cad 100644 --- a/test/shell/pvremove-thin.sh +++ b/test/shell/pvremove-thin.sh @@ -13,7 +13,7 @@ # Checks we are not reading our own devices # https://bugzilla.redhat.com/show_bug.cgi?id=1064374 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/pvremove-usage.sh b/test/shell/pvremove-usage.sh index be51ce16f..17d90e62e 100644 --- a/test/shell/pvremove-usage.sh +++ b/test/shell/pvremove-usage.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -34,7 +34,7 @@ pvs -a -o+devices pvcreate --metadatacopies 0 "$dev2" # check pvremove refuses to remove pv in a vg -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" not pvremove "$dev2" "$dev3" for mdacp in 0 1 2; do @@ -53,7 +53,7 @@ for mdacp in 0 1 2; do vgremove -ff $vg pvcreate --metadatacopies $mdacp "$dev1" pvcreate "$dev2" - vgcreate $vg "$dev1" "$dev2" + vgcreate $SHARED $vg "$dev1" "$dev2" # pvremove -f fails when pv in a vg (---metadatacopies $mdacp) not pvremove -f "$dev1" 2>&1 | tee out diff --git a/test/shell/pvremove-warnings.sh b/test/shell/pvremove-warnings.sh index 57a376c23..dc3178daa 100644 --- a/test/shell/pvremove-warnings.sh +++ b/test/shell/pvremove-warnings.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -21,6 +21,6 @@ pvremove "$dev1" "$dev2" 2>&1 | tee pvremove.txt not grep "No physical" pvremove.txt pvcreate "$dev1" "$dev2" -vgcreate bla "$dev1" "$dev2" +vgcreate $SHARED bla "$dev1" "$dev2" pvremove -ff -y "$dev1" "$dev2" 2>&1 | tee pvremove.txt not grep "device missing" pvremove.txt diff --git a/test/shell/pvresize-mdas.sh b/test/shell/pvresize-mdas.sh index 3bed8bc03..da4119c9e 100644 --- a/test/shell/pvresize-mdas.sh +++ b/test/shell/pvresize-mdas.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/read-ahead.sh b/test/shell/read-ahead.sh index 9045de82d..60e5912f2 100644 --- a/test/shell/read-ahead.sh +++ b/test/shell/read-ahead.sh @@ -15,7 +15,7 @@ # test_description='Test read-ahead functionality' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/relative-sign-options.sh b/test/shell/relative-sign-options.sh index 2a36f1f8e..82a5ed2d0 100644 --- a/test/shell/relative-sign-options.sh +++ b/test/shell/relative-sign-options.sh @@ -12,7 +12,7 @@ test_description='Exercise toollib process_each_lv' SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + # disable lvmetad logging as it bogs down test systems export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} diff --git a/test/shell/report-fields.sh b/test/shell/report-fields.sh index 0473a33f5..82606107c 100644 --- a/test/shell/report-fields.sh +++ b/test/shell/report-fields.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMETAD=1 SKIP_WITH_LVMPOLLD=1 SKIP_WITH_CLVMD=1 diff --git a/test/shell/report-hidden.sh b/test/shell/report-hidden.sh index fb70e607e..24a11c8f1 100644 --- a/test/shell/report-hidden.sh +++ b/test/shell/report-hidden.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMETAD=1 SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/select-report.sh b/test/shell/select-report.sh index b879bf5cd..f404be58b 100644 --- a/test/shell/select-report.sh +++ b/test/shell/select-report.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -23,9 +23,9 @@ aux prepare_pvs 6 16 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # create $VGS with assorted tags -vgcreate $vg1 --vgmetadatacopies 2 --addtag "vg_tag3" --addtag "vg_tag2" -s 4m "$dev1" "$dev2" "$dev3" -vgcreate $vg2 --addtag "vg_tag2" -s 4m "$dev4" "$dev5" -vgcreate $vg3 --addtag "vg_tag1" -s 4m "$dev6" +vgcreate $SHARED $vg1 --vgmetadatacopies 2 --addtag "vg_tag3" --addtag "vg_tag2" -s 4m "$dev1" "$dev2" "$dev3" +vgcreate $SHARED $vg2 --addtag "vg_tag2" -s 4m "$dev4" "$dev5" +vgcreate $SHARED $vg3 --addtag "vg_tag1" -s 4m "$dev6" # add PV assorted tags pvchange --addtag "pv_tag3" --addtag "pv_tag1" --addtag "pv_tag2" "$dev1" diff --git a/test/shell/select-tools-thin.sh b/test/shell/select-tools-thin.sh index aa43ef3b7..8fbe1b322 100644 --- a/test/shell/select-tools-thin.sh +++ b/test/shell/select-tools-thin.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -30,7 +30,7 @@ aux prepare_pvs 1 16 # selecting on initial state (here, thin origin LV thin_orig is removed # first, but thin snap should be still selectable based on origin=thin_orig # condition even though thin_orig has just been removed) -vgcreate -s 4m $vg1 "$dev1" +vgcreate $SHARED -s 4m $vg1 "$dev1" lvcreate -l100%FREE -T $vg1/pool lvcreate -V4m -T $vg1/pool -n thin_orig lvcreate -s $vg1/thin_orig -n thin_snap diff --git a/test/shell/select-tools.sh b/test/shell/select-tools.sh index e0ceccca1..0ca633c93 100644 --- a/test/shell/select-tools.sh +++ b/test/shell/select-tools.sh @@ -10,15 +10,15 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest aux prepare_pvs 4 12 -vgcreate -s 4m $vg1 "$dev1" "$dev2" -vgcreate -s 4m $vg2 "$dev3" "$dev4" +vgcreate $SHARED -s 4m $vg1 "$dev1" "$dev2" +vgcreate $SHARED -s 4m $vg2 "$dev3" "$dev4" # vg1/lv1 mapped onto dev1 lvcreate -l1 -n "lv1" $vg1 "$dev1" diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh index e2702bb41..7967e865d 100644 --- a/test/shell/snapshot-autoumount-dmeventd.sh +++ b/test/shell/snapshot-autoumount-dmeventd.sh @@ -12,7 +12,7 @@ # no automatic extensions please -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/snapshot-cluster.sh b/test/shell/snapshot-cluster.sh index d6459d85f..e6c9ab359 100644 --- a/test/shell/snapshot-cluster.sh +++ b/test/shell/snapshot-cluster.sh @@ -13,7 +13,7 @@ # Testing renaming snapshots in cluster # https://bugzilla.redhat.com/show_bug.cgi?id=1136925 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/snapshot-maxsize.sh b/test/shell/snapshot-maxsize.sh index 9a1f4d74b..9427566d5 100644 --- a/test/shell/snapshot-maxsize.sh +++ b/test/shell/snapshot-maxsize.sh @@ -13,7 +13,7 @@ # Testing calculation of snapshot space # https://bugzilla.redhat.com/show_bug.cgi?id=1035871 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -21,7 +21,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_pvs 1 get_devs -vgcreate -s 4K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 4K "$vg" "${DEVICES[@]}" lvcreate -aey -L1 -n $lv1 $vg # Snapshot should be large enough to handle any writes diff --git a/test/shell/snapshot-merge-stack.sh b/test/shell/snapshot-merge-stack.sh index fe208655e..b6763caec 100644 --- a/test/shell/snapshot-merge-stack.sh +++ b/test/shell/snapshot-merge-stack.sh @@ -12,7 +12,7 @@ # Exercise snapshot merge also when stacked -SKIP_WITH_LVMLOCKD=1 + export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} . lib/inittest diff --git a/test/shell/snapshot-merge.sh b/test/shell/snapshot-merge.sh index 41e7b00a2..a50ffdcd8 100644 --- a/test/shell/snapshot-merge.sh +++ b/test/shell/snapshot-merge.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/snapshot-reactivate.sh b/test/shell/snapshot-reactivate.sh index fb6973a88..4138e6e24 100644 --- a/test/shell/snapshot-reactivate.sh +++ b/test/shell/snapshot-reactivate.sh @@ -17,7 +17,7 @@ # http://www.redhat.com/archives/dm-devel/2014-March/msg00005.html # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/snapshot-rename.sh b/test/shell/snapshot-rename.sh index a7eb54cc9..e8d77a3ac 100644 --- a/test/shell/snapshot-rename.sh +++ b/test/shell/snapshot-rename.sh @@ -13,7 +13,7 @@ # Testing renaming snapshots (had problem in cluster) # https://bugzilla.redhat.com/show_bug.cgi?id=1136925 -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/snapshots-of-mirrors.sh b/test/shell/snapshots-of-mirrors.sh index 7e3f736cb..48cadc5fc 100644 --- a/test/shell/snapshots-of-mirrors.sh +++ b/test/shell/snapshots-of-mirrors.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/stray-device-node.sh b/test/shell/stray-device-node.sh index 2467a4781..7ed229388 100644 --- a/test/shell/stray-device-node.sh +++ b/test/shell/stray-device-node.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -20,7 +20,7 @@ get_devs cp -r "$dev1" "$DM_DEV_DIR/stray" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -an -Zn --type mirror -m 1 -l 1 -n mirror $vg aux disable_dev "$dev1" # FIXME: diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh index b7e61a955..21c5bd0b6 100644 --- a/test/shell/system_id.sh +++ b/test/shell/system_id.sh @@ -11,6 +11,8 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Test system_id' + +# test does not apply to lvmlockd SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/tags.sh b/test/shell/tags.sh index 2d8731eee..fd1b33229 100644 --- a/test/shell/tags.sh +++ b/test/shell/tags.sh @@ -10,23 +10,23 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest aux prepare_pvs 4 -# vgcreate with --addtag -vgcreate --addtag firstvg $vg1 "$dev1" "$dev2" -vgcreate --addtag secondvg $vg2 "$dev3" "$dev4" +# vgcreate $SHARED with --addtag +vgcreate $SHARED --addtag firstvg $vg1 "$dev1" "$dev2" +vgcreate $SHARED --addtag secondvg $vg2 "$dev3" "$dev4" check vg_field $vg1 tags "firstvg" check vg_field $vg2 tags "secondvg" vgremove -f $vg1 $vg2 # vgchange with --addtag and --deltag -vgcreate $vg1 "$dev1" "$dev2" -vgcreate $vg2 "$dev3" "$dev4" +vgcreate $SHARED $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg2 "$dev3" "$dev4" vgchange --addtag firstvgtag1 $vg1 # adding a tag multiple times is not an error vgchange --addtag firstvgtag2 $vg1 @@ -45,7 +45,7 @@ vgchange --deltag firstvgtag1 $vg2 vgremove -f $vg1 $vg2 # lvcreate with --addtag -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" lvcreate --addtag firstlvtag1 -l 4 -n $lv1 $vg1 lvcreate --addtag secondlvtag1 -l 4 -n $lv2 $vg1 check lv_field @firstlvtag1 tags "firstlvtag1" @@ -55,7 +55,7 @@ not check lv_field $vg1/$lv1 tags "secondlvtag1" vgremove -f $vg1 # lvchange with --addtag and --deltag -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" lvcreate -l 4 -n $lv1 $vg1 lvcreate -l 4 -n $lv2 $vg1 lvchange --addtag firstlvtag1 $vg1/$lv1 diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh index bcbf9f10a..083cd9877 100644 --- a/test/shell/test-partition.sh +++ b/test/shell/test-partition.sh @@ -16,7 +16,7 @@ # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]" diff --git a/test/shell/thin-autoumount-dmeventd.sh b/test/shell/thin-autoumount-dmeventd.sh index cee2f4cb9..724433362 100644 --- a/test/shell/thin-autoumount-dmeventd.sh +++ b/test/shell/thin-autoumount-dmeventd.sh @@ -12,7 +12,7 @@ # no automatic extensions, just umount -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-defaults.sh b/test/shell/thin-defaults.sh index 89c0fa459..3f2db2031 100644 --- a/test/shell/thin-defaults.sh +++ b/test/shell/thin-defaults.sh @@ -12,7 +12,7 @@ # test defaults entered through lvm.conf -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-dmeventd-warns.sh b/test/shell/thin-dmeventd-warns.sh index d87410262..a8002ae99 100644 --- a/test/shell/thin-dmeventd-warns.sh +++ b/test/shell/thin-dmeventd-warns.sh @@ -12,7 +12,7 @@ # test if dmeventd produces multiple warnings when pools runs above 80% -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 SKIP_WITH_CLVMD=1 SKIP_WITH_LVMETAD=1 diff --git a/test/shell/thin-foreign-dmeventd.sh b/test/shell/thin-foreign-dmeventd.sh index 4e373ad06..561cea885 100644 --- a/test/shell/thin-foreign-dmeventd.sh +++ b/test/shell/thin-foreign-dmeventd.sh @@ -12,7 +12,7 @@ # test foreing user of thin-pool -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/thin-merge.sh b/test/shell/thin-merge.sh index 457bd47a3..c0a022c57 100644 --- a/test/shell/thin-merge.sh +++ b/test/shell/thin-merge.sh @@ -12,7 +12,7 @@ # test merge of thin snapshot -SKIP_WITH_LVMLOCKD=1 + export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-overprovisioning.sh b/test/shell/thin-overprovisioning.sh index 85d8577a1..d4ab63de6 100644 --- a/test/shell/thin-overprovisioning.sh +++ b/test/shell/thin-overprovisioning.sh @@ -12,7 +12,7 @@ # Test warns when thin pool is overprovisiong -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-resize-match.sh b/test/shell/thin-resize-match.sh index 3bbf33479..dda557381 100644 --- a/test/shell/thin-resize-match.sh +++ b/test/shell/thin-resize-match.sh @@ -12,7 +12,7 @@ # ensure there is no data loss during thin-pool resize -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-restore.sh b/test/shell/thin-restore.sh index afcbd7f91..3682a8ca7 100644 --- a/test/shell/thin-restore.sh +++ b/test/shell/thin-restore.sh @@ -12,7 +12,7 @@ # test restore operation of thin pool metadata -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-vglock.sh b/test/shell/thin-vglock.sh index 9664e30bc..b48ef253e 100644 --- a/test/shell/thin-vglock.sh +++ b/test/shell/thin-vglock.sh @@ -13,7 +13,7 @@ # Test locking works and doesn't update metadata # RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1063542 -SKIP_WITH_LVMLOCKD=1 + export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/thin-volume-list.sh b/test/shell/thin-volume-list.sh index f4fb0a3fa..6caa7200c 100644 --- a/test/shell/thin-volume-list.sh +++ b/test/shell/thin-volume-list.sh @@ -12,7 +12,7 @@ # test pool behaviour when volume_list masks activation -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/topology-support.sh b/test/shell/topology-support.sh index 482205af8..f8526addf 100644 --- a/test/shell/topology-support.sh +++ b/test/shell/topology-support.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -62,7 +62,7 @@ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$LOGICAL_BLOCK_SIZE" aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE get_devs -vgcreate $vg "${DEVICES[@]}" +vgcreate $SHARED $vg "${DEVICES[@]}" test_snapshot_mount vgremove $vg @@ -77,7 +77,7 @@ aux prepare_scsi_debug_dev $DEV_SIZE \ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE -vgcreate $vg "${DEVICES[@]}" +vgcreate $SHARED $vg "${DEVICES[@]}" test_snapshot_mount vgremove $vg @@ -92,7 +92,7 @@ aux prepare_scsi_debug_dev $DEV_SIZE \ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE -vgcreate $vg "${DEVICES[@]}" +vgcreate $SHARED $vg "${DEVICES[@]}" test_snapshot_mount vgremove $vg diff --git a/test/shell/unknown-segment.sh b/test/shell/unknown-segment.sh index 42f1fd346..ef66447a5 100644 --- a/test/shell/unknown-segment.sh +++ b/test/shell/unknown-segment.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vg-check-devs-used.sh b/test/shell/vg-check-devs-used.sh index 9b99ef70a..f62799e20 100644 --- a/test/shell/vg-check-devs-used.sh +++ b/test/shell/vg-check-devs-used.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA SKIP_WITH_LVMPOLLD=1 -SKIP_WITH_LVMLOCKD=1 + . lib/inittest @@ -20,7 +20,7 @@ aux driver_at_least 4 15 || skip aux prepare_devs 3 8 -vgcreate "$vg" "$dev1" "$dev2" +vgcreate $SHARED "$vg" "$dev1" "$dev2" lvcreate -l100%FREE -n $lv $vg dd if="$dev1" of="$dev3" bs=1M pvs --config "devices/global_filter = [ \"a|$dev2|\", \"a|$dev3|\", \"r|.*|\" ]" 2>err diff --git a/test/shell/vg-name-from-env.sh b/test/shell/vg-name-from-env.sh index 9ba6b4592..48e471c13 100644 --- a/test/shell/vg-name-from-env.sh +++ b/test/shell/vg-name-from-env.sh @@ -7,7 +7,7 @@ # of the GNU General Public License v.2. test_description='Test the vg name for an lv from env var' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -17,8 +17,8 @@ aux prepare_devs 2 pvcreate "$dev1" pvcreate "$dev2" -vgcreate $vg1 "$dev1" -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg1 "$dev1" +vgcreate $SHARED $vg2 "$dev2" export LVM_VG_NAME=$vg1 diff --git a/test/shell/vgcfgbackup-lvm1.sh b/test/shell/vgcfgbackup-lvm1.sh index e9738e8d7..a148ec1de 100644 --- a/test/shell/vgcfgbackup-lvm1.sh +++ b/test/shell/vgcfgbackup-lvm1.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -28,7 +28,7 @@ aux lvmconf "backup/backup = 0" # vgcfgbackup correctly stores metadata LVM1 with missing PVs pvcreate -M1 "${DEVICES[@]}" -vgcreate -M1 -c n "$vg" "${DEVICES[@]}" +vgcreate $SHARED -M1 -c n "$vg" "${DEVICES[@]}" lvcreate -l1 -n $lv1 $vg "$dev1" pvremove -ff -y "$dev2" not lvcreate -l1 -n $lv1 $vg "$dev3" diff --git a/test/shell/vgcfgbackup-usage.sh b/test/shell/vgcfgbackup-usage.sh index c506a14f7..801f9cea1 100644 --- a/test/shell/vgcfgbackup-usage.sh +++ b/test/shell/vgcfgbackup-usage.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -26,8 +26,8 @@ aux lvmconf "backup/backup = 0" # vgcfgbackup handles similar VG names (bz458941) vg1=${PREFIX}vg00 vg2=${PREFIX}vg01 -vgcreate $vg1 "$dev1" -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg1 "$dev1" +vgcreate $SHARED $vg2 "$dev2" # Enforces system backup test ! -e etc/backup/$vg1 @@ -58,7 +58,7 @@ vgremove -ff $vg1 $vg2 # and vgcfgrestore able to restore them when device reappears pv1_uuid=$(get pv_field "$dev1" pv_uuid) pv2_uuid=$(get pv_field "$dev2" pv_uuid) -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" lvcreate -l1 -n $lv1 $vg "$dev1" lvcreate -l1 -n $lv2 $vg "$dev2" lvcreate -l1 -n $lv3 $vg "$dev3" diff --git a/test/shell/vgchange-many.sh b/test/shell/vgchange-many.sh index 95bc868bb..debfdc4c3 100644 --- a/test/shell/vgchange-many.sh +++ b/test/shell/vgchange-many.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Check perfomance of activation and deactivation -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -26,7 +26,7 @@ test "$(aux total_mem)" -gt 524288 || TEST_DEVS=256 aux prepare_pvs 1 400 get_devs -vgcreate -s 128K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 128K "$vg" "${DEVICES[@]}" vgcfgbackup -f data $vg diff --git a/test/shell/vgchange-maxlv.sh b/test/shell/vgchange-maxlv.sh index 987fa9e23..626128e9e 100644 --- a/test/shell/vgchange-maxlv.sh +++ b/test/shell/vgchange-maxlv.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -19,13 +19,13 @@ aux prepare_dmeventd aux prepare_pvs 3 get_devs -vgcreate -l 2 "$vg" "${DEVICES[@]}" +vgcreate $SHARED -l 2 "$vg" "${DEVICES[@]}" lvcreate -aey -n one -l 1 $vg lvcreate -n two -l 1 $vg not lvcreate -n three -l 1 $vg vgremove -ff $vg -vgcreate -l 3 "$vg" "${DEVICES[@]}" +vgcreate $SHARED -l 3 "$vg" "${DEVICES[@]}" lvcreate -aey -n one -l 1 $vg lvcreate -n snap -s -l 1 $vg/one lvcreate -n two -l 1 $vg diff --git a/test/shell/vgchange-partial.sh b/test/shell/vgchange-partial.sh index b77ad1ae6..5f5920f8e 100644 --- a/test/shell/vgchange-partial.sh +++ b/test/shell/vgchange-partial.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vgchange-sysinit.sh b/test/shell/vgchange-sysinit.sh index ec0a6cdb4..cea72f4d0 100644 --- a/test/shell/vgchange-sysinit.sh +++ b/test/shell/vgchange-sysinit.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 @@ -30,8 +29,8 @@ cleanup_mounted_and_teardown() aux teardown } -vgcreate $vg1 "$dev1" -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg1 "$dev1" +vgcreate $SHARED $vg2 "$dev2" lvcreate -l 1 -n $lv2 $vg2 vgchange -an $vg2 @@ -54,7 +53,12 @@ test ! -b "$DM_DEV_DIR/$vg2/$lv2" vgchange --ignorelockingfailure -ay $vg2 +if test -n "$LVM_TEST_LVMLOCKD"; then +vgremove --config 'global{locking_type=0}' -ff $vg2 +else # TODO maybe also support --ignorelockingfailure ?? vgremove --config 'global{locking_type=0}' -ff $vg2 +fi + umount "$mount_dir" || true vgremove -ff $vg1 diff --git a/test/shell/vgck.sh b/test/shell/vgck.sh index 186704c70..c9d29bb3b 100644 --- a/test/shell/vgck.sh +++ b/test/shell/vgck.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vgcreate-many-pvs.sh b/test/shell/vgcreate-many-pvs.sh index a75b3f3e6..9598f915e 100644 --- a/test/shell/vgcreate-many-pvs.sh +++ b/test/shell/vgcreate-many-pvs.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -40,7 +40,7 @@ SKIP_WITH_LVMPOLLD=1 LVM_TEST_PVS=${LVM_TEST_PVS:-100} #aux prepare_devs $LVM_TEST_PVS 8 -#vgcreate $vg $(< DEVICES) +#vgcreate $SHARED $vg $(< DEVICES) # prepare_vg is now directly using steps above aux prepare_vg $LVM_TEST_PVS @@ -62,5 +62,5 @@ vgremove -ff $vg # TODO Turn this into another test case: # #for i in $(seq 1 $LVM_TEST_PVS); do -# vgcreate ${vg}$i "$DM_DEV_DIR/mapper/${PREFIX}pv$i" +# vgcreate $SHARED ${vg}$i "$DM_DEV_DIR/mapper/${PREFIX}pv$i" #done diff --git a/test/shell/vgextend-usage.sh b/test/shell/vgextend-usage.sh index 178df4db3..3d5adfd80 100644 --- a/test/shell/vgextend-usage.sh +++ b/test/shell/vgextend-usage.sh @@ -14,7 +14,7 @@ # Exercise various vgextend commands # -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -32,30 +32,30 @@ do # Explicit pvcreate pvcreate -M$mdatype "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" -vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" vgextend $vg1 "$dev3" "$dev4" "$dev5" vgremove -ff $vg1 # Implicit pvcreate pvremove "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" -vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" vgextend -M$mdatype $vg1 "$dev3" "$dev4" "$dev5" vgremove -ff $vg1 pvremove "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" done -# Implicit pvcreate tests, test pvcreate options on vgcreate +# Implicit pvcreate tests, test pvcreate options on vgcreate $SHARED # --force, --yes, --metadata{size|copies|type}, --zero # --dataalignment[offset] -vgcreate $vg "$dev2" +vgcreate $SHARED $vg "$dev2" vgextend --force --yes --zero y $vg "$dev1" vgreduce $vg "$dev1" pvremove -f "$dev1" for i in 0 1 2 3 do -# vgcreate (lvm2) succeeds writing LVM label at sector $i +# vgcreate $SHARED (lvm2) succeeds writing LVM label at sector $i vgextend --labelsector $i $vg "$dev1" dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null vgreduce $vg "$dev1" @@ -87,15 +87,15 @@ vgremove -f $vg pvremove -f "$dev1" # vgextend fails if pv belongs to existing vg -vgcreate $vg1 "$dev1" "$dev3" -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev3" +vgcreate $SHARED $vg2 "$dev2" not vgextend $vg2 "$dev3" vgremove -f $vg1 vgremove -f $vg2 pvremove -f "$dev1" "$dev2" "$dev3" #vgextend fails if vg is not resizeable -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" vgchange --resizeable n $vg1 not vgextend $vg1 "$dev3" vgremove -f $vg1 @@ -103,7 +103,7 @@ pvremove -f "$dev1" "$dev2" # all PVs exist in the VG after extended pvcreate "$dev1" -vgcreate $vg1 "$dev2" +vgcreate $SHARED $vg1 "$dev2" vgextend $vg1 "$dev1" "$dev3" check pv_field "$dev1" vg_name $vg1 check pv_field "$dev2" vg_name $vg1 @@ -115,7 +115,7 @@ echo test vgextend --metadataignore for mdacp in 1 2; do for ignore in y n; do echo vgextend --metadataignore has proper mda_count and mda_used_count - vgcreate $vg "$dev3" + vgcreate $SHARED $vg "$dev3" vgextend --metadataignore $ignore --pvmetadatacopies $mdacp $vg "$dev1" "$dev2" check pv_field "$dev1" pv_mda_count $mdacp check pv_field "$dev2" pv_mda_count $mdacp diff --git a/test/shell/vgremove-corrupt-vg.sh b/test/shell/vgremove-corrupt-vg.sh index edc911b0d..1de77e4db 100644 --- a/test/shell/vgremove-corrupt-vg.sh +++ b/test/shell/vgremove-corrupt-vg.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vgsplit-stacked.sh b/test/shell/vgsplit-stacked.sh index 1388e9144..331ee8e86 100644 --- a/test/shell/vgsplit-stacked.sh +++ b/test/shell/vgsplit-stacked.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -18,12 +18,12 @@ SKIP_WITH_LVMPOLLD=1 aux extend_filter_LVMTEST aux prepare_pvs 3 -vgcreate $vg1 "$dev1" "$dev2" +vgcreate $SHARED $vg1 "$dev1" "$dev2" lvcreate -n $lv1 -l 100%FREE $vg1 #top VG pvcreate "$DM_DEV_DIR/$vg1/$lv1" -vgcreate $vg "$DM_DEV_DIR/$vg1/$lv1" "$dev3" +vgcreate $SHARED $vg "$DM_DEV_DIR/$vg1/$lv1" "$dev3" vgchange -a n $vg $vg1 diff --git a/test/shell/zero-usage.sh b/test/shell/zero-usage.sh index 68afaaf6b..53ffbe499 100644 --- a/test/shell/zero-usage.sh +++ b/test/shell/zero-usage.sh @@ -11,7 +11,7 @@ # Basic usage of zero target -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest From 95cf127134c93882f78d13d26a87e28f2c256d34 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 14:28:53 -0500 Subject: [PATCH 60/81] tests: vgcreate-usage update for lvmlockd --- test/shell/vgcreate-usage.sh | 89 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/test/shell/vgcreate-usage.sh b/test/shell/vgcreate-usage.sh index 40eb99be8..19593130d 100644 --- a/test/shell/vgcreate-usage.sh +++ b/test/shell/vgcreate-usage.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise some vgcreate diagnostics' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -22,87 +22,90 @@ pvcreate --metadatacopies 0 "$dev3" vg=${PREFIX}vg -#COMM 'vgcreate accepts 8.00m physicalextentsize for VG' -vgcreate $vg --physicalextentsize 8.00m "$dev1" "$dev2" +#COMM 'vgcreate $SHARED accepts 8.00m physicalextentsize for VG' +vgcreate $SHARED $vg --physicalextentsize 8.00m "$dev1" "$dev2" check vg_field $vg vg_extent_size 8.00m vgremove $vg # try vgck and to remove it again - should fail (but not segfault) not vgremove $vg not vgck $vg -#COMM 'vgcreate accepts smaller (128) maxlogicalvolumes for VG' -vgcreate $vg --maxlogicalvolumes 128 "$dev1" "$dev2" +#COMM 'vgcreate $SHARED accepts smaller (128) maxlogicalvolumes for VG' +vgcreate $SHARED $vg --maxlogicalvolumes 128 "$dev1" "$dev2" check vg_field $vg max_lv 128 vgremove $vg -#COMM 'vgcreate accepts smaller (128) maxphysicalvolumes for VG' -vgcreate $vg --maxphysicalvolumes 128 "$dev1" "$dev2" +#COMM 'vgcreate $SHARED accepts smaller (128) maxphysicalvolumes for VG' +vgcreate $SHARED $vg --maxphysicalvolumes 128 "$dev1" "$dev2" check vg_field $vg max_pv 128 vgremove $vg -#COMM 'vgcreate rejects a zero physical extent size' -not vgcreate --physicalextentsize 0 $vg "$dev1" "$dev2" 2>err +#COMM 'vgcreate $SHARED rejects a zero physical extent size' +not vgcreate $SHARED --physicalextentsize 0 $vg "$dev1" "$dev2" 2>err grep "Physical extent size may not be zero" err -#COMM 'vgcreate rejects "inherit" allocation policy' -not vgcreate --alloc inherit $vg "$dev1" "$dev2" 2>err +#COMM 'vgcreate $SHARED rejects "inherit" allocation policy' +not vgcreate $SHARED --alloc inherit $vg "$dev1" "$dev2" 2>err grep "Volume Group allocation policy cannot inherit from anything" err -#COMM 'vgcreate rejects vgname "."' +#COMM 'vgcreate $SHARED rejects vgname "."' vginvalid=.; -not vgcreate $vginvalid "$dev1" "$dev2" 2>err +not vgcreate $SHARED $vginvalid "$dev1" "$dev2" 2>err grep "New volume group name \"$vginvalid\" is invalid" err -#COMM 'vgcreate rejects vgname greater than 128 characters' +#COMM 'vgcreate $SHARED rejects vgname greater than 128 characters' vginvalid=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome -not vgcreate $vginvalid "$dev1" "$dev2" 2>err +not vgcreate $SHARED $vginvalid "$dev1" "$dev2" 2>err grep "New volume group name \"$vginvalid\" is invalid" err -#COMM 'vgcreate rejects already existing vgname "/tmp/$vg"' +#COMM 'vgcreate $SHARED rejects already existing vgname "/tmp/$vg"' #touch /tmp/$vg -#not vgcreate $vg "$dev1" "$dev2" 2>err +#not vgcreate $SHARED $vg "$dev1" "$dev2" 2>err #grep "New volume group name \"$vg\" is invalid\$" err -#COMM "vgcreate rejects repeated invocation (run 2 times) (bz178216)" -vgcreate $vg "$dev1" "$dev2" -not vgcreate $vg "$dev1" "$dev2" +#COMM "vgcreate $SHARED rejects repeated invocation (run 2 times) (bz178216)" +vgcreate $SHARED $vg "$dev1" "$dev2" +not vgcreate $SHARED $vg "$dev1" "$dev2" vgremove -ff $vg -#COMM "vgcreate fails when the only pv has --metadatacopies 0" -not vgcreate $vg "$dev3" +#COMM "vgcreate $SHARED fails when the only pv has --metadatacopies 0" +not vgcreate $SHARED $vg "$dev3" # Test default (4MB) vg_extent_size as well as limits of extent_size -not vgcreate --physicalextentsize 0k $vg "$dev1" "$dev2" -vgcreate --physicalextentsize 4k $vg "$dev1" "$dev2" +not vgcreate $SHARED --physicalextentsize 0k $vg "$dev1" "$dev2" +vgcreate $SHARED --physicalextentsize 4k $vg "$dev1" "$dev2" check vg_field $vg vg_extent_size 4.00k vgremove -ff $vg -not vgcreate --physicalextentsize 7K $vg "$dev1" "$dev2" -not vgcreate --physicalextentsize 1024t $vg "$dev1" "$dev2" -#not vgcreate --physicalextentsize 1T $vg "$dev1" "$dev2" -# FIXME: vgcreate allows physicalextentsize larger than pv size! +not vgcreate $SHARED --physicalextentsize 7K $vg "$dev1" "$dev2" +not vgcreate $SHARED --physicalextentsize 1024t $vg "$dev1" "$dev2" +#not vgcreate $SHARED --physicalextentsize 1T $vg "$dev1" "$dev2" +# FIXME: vgcreate $SHARED allows physicalextentsize larger than pv size! # Test default max_lv, max_pv, extent_size, alloc_policy, clustered -vgcreate $vg "$dev1" "$dev2" +vgcreate $SHARED $vg "$dev1" "$dev2" check vg_field $vg vg_extent_size 4.00m check vg_field $vg max_lv 0 check vg_field $vg max_pv 0 ATTRS="wz--n-" test -e LOCAL_CLVMD && ATTRS="wz--nc" +if test -n "$LVM_TEST_LVMLOCKD"; then +ATTRS="wz--ns" +fi check vg_field $vg vg_attr $ATTRS vgremove -ff $vg -# Implicit pvcreate tests, test pvcreate options on vgcreate +# Implicit pvcreate tests, test pvcreate options on vgcreate $SHARED # --force, --yes, --metadata{size|copies|type}, --zero # --dataalignment[offset] pvremove "$dev1" "$dev2" -vgcreate --force --yes --zero y $vg "$dev1" "$dev2" +vgcreate $SHARED --force --yes --zero y $vg "$dev1" "$dev2" vgremove -f $vg pvremove -f "$dev1" for i in 0 1 2 3 do -# vgcreate (lvm2) succeeds writing LVM label at sector $i - vgcreate --labelsector $i $vg "$dev1" +# vgcreate $SHARED (lvm2) succeeds writing LVM label at sector $i + vgcreate $SHARED --labelsector $i $vg "$dev1" dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null vgremove -f $vg pvremove -f "$dev1" @@ -111,14 +114,14 @@ done # pvmetadatacopies for i in 1 2 do - vgcreate --pvmetadatacopies $i $vg "$dev1" + vgcreate $SHARED --pvmetadatacopies $i $vg "$dev1" check pv_field "$dev1" pv_mda_count $i vgremove -f $vg pvremove -f "$dev1" done -not vgcreate --pvmetadatacopies 0 $vg "$dev1" +not vgcreate $SHARED --pvmetadatacopies 0 $vg "$dev1" pvcreate --metadatacopies 1 "$dev2" -vgcreate --pvmetadatacopies 0 $vg "$dev1" "$dev2" +vgcreate $SHARED --pvmetadatacopies 0 $vg "$dev1" "$dev2" check pv_field "$dev1" pv_mda_count 0 check pv_field "$dev2" pv_mda_count 1 vgremove -f $vg @@ -126,7 +129,7 @@ pvremove -f "$dev1" # metadatasize, dataalignment, dataalignmentoffset #COMM 'pvcreate sets data offset next to mda area' -vgcreate --metadatasize 100k --dataalignment 100k $vg "$dev1" +vgcreate $SHARED --metadatasize 100k --dataalignment 100k $vg "$dev1" check pv_field "$dev1" pe_start 200.00k vgremove -f $vg pvremove -f "$dev1" @@ -134,7 +137,7 @@ pvremove -f "$dev1" # data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset pv_align=1052160 # 1048576 + (7*512) -vgcreate --metadatasize 128k --dataalignmentoffset 7s $vg "$dev1" +vgcreate $SHARED --metadatasize 128k --dataalignmentoffset 7s $vg "$dev1" check pv_field "$dev1" pe_start ${pv_align}B --units b vgremove -f $vg pvremove -f "$dev1" @@ -148,21 +151,21 @@ fi # metadatatype for i in $mdatypes do - vgcreate -M $i $vg "$dev1" + vgcreate $SHARED -M $i $vg "$dev1" check vg_field $vg vg_fmt lvm$i vgremove -f $vg pvremove -f "$dev1" done -# vgcreate fails if pv belongs to existing vg -vgcreate $vg1 "$dev1" "$dev2" -not vgcreate $vg2 "$dev2" +# vgcreate $SHARED fails if pv belongs to existing vg +vgcreate $SHARED $vg1 "$dev1" "$dev2" +not vgcreate $SHARED $vg2 "$dev2" vgremove -f $vg1 pvremove -f "$dev1" "$dev2" # all PVs exist in the VG after created pvcreate "$dev1" -vgcreate $vg1 "$dev1" "$dev2" "$dev3" +vgcreate $SHARED $vg1 "$dev1" "$dev2" "$dev3" check pv_field "$dev1" vg_name $vg1 check pv_field "$dev2" vg_name $vg1 check pv_field "$dev3" vg_name $vg1 From a40d447a02521820c23422fdd43f795c32d402a7 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 14:34:38 -0500 Subject: [PATCH 61/81] tests: vgchange-usage update for lvmlockd --- test/shell/vgchange-usage.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/shell/vgchange-usage.sh b/test/shell/vgchange-usage.sh index 152014205..1885a6458 100644 --- a/test/shell/vgchange-usage.sh +++ b/test/shell/vgchange-usage.sh @@ -11,7 +11,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA test_description='Exercise some vgchange diagnostics' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -19,7 +19,7 @@ SKIP_WITH_LVMPOLLD=1 aux prepare_pvs 4 pvcreate --metadatacopies 0 "$dev1" -vgcreate -s 4M $vg "$dev1" "$dev2" "$dev3" +vgcreate $SHARED -s 4M $vg "$dev1" "$dev2" "$dev3" # cannot change anything in exported vg vgexport $vg @@ -97,6 +97,9 @@ fail vgchange -x n $vg fail vgextend $vg "$dev4" vgremove -ff $vg +# skip cluster tests with lvmlockd +test -n "$LVM_TEST_LVMLOCKD" && exit 0 + # set cluster bit vgcreate -cn $vg "$dev1" "$dev2" "$dev3" # check prompt to change cluster bit without giving explicit vg name From 5c5e449dc5f955481f9409ff0e7ed39cf7b2e87d Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 15:26:30 -0500 Subject: [PATCH 62/81] lvmlockd: fix vgimportclone of a shared VG The new VG from the duplicate PV is imported as a local VG. --- test/shell/vgimportclone.sh | 5 ++--- tools/vgimportclone.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test/shell/vgimportclone.sh b/test/shell/vgimportclone.sh index f97c6df8c..48a666e4a 100644 --- a/test/shell/vgimportclone.sh +++ b/test/shell/vgimportclone.sh @@ -10,14 +10,13 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest aux prepare_devs 2 -vgcreate --metadatasize 128k $vg1 "$dev1" +vgcreate $SHARED --metadatasize 128k $vg1 "$dev1" lvcreate -l100%FREE -n $lv1 $vg1 # Test plain vgexport vgimport tools @@ -76,7 +75,7 @@ vgremove -ff $vg1 $vg2 # Verify that if we provide the -n|--basevgname, # the number suffix is not added unnecessarily. -vgcreate --metadatasize 128k A${vg1}B "$dev1" +vgcreate $SHARED --metadatasize 128k A${vg1}B "$dev1" # vg1B is not the same as Avg1B - we don't need number suffix dd if="$dev1" of="$dev2" bs=256K count=1 diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c index 224d0b546..c4c5d4cd0 100644 --- a/tools/vgimportclone.c +++ b/tools/vgimportclone.c @@ -153,6 +153,11 @@ static int _vgimportclone_vg_single(struct cmd_context *cmd, const char *vg_name if (!(vg->name = dm_pool_strdup(vg->vgmem, vp->new_vgname))) goto_bad; + /* A duplicate of a shared VG is imported as a new local VG. */ + vg->lock_type = NULL; + vg->lock_args = NULL; + vg->system_id = cmd->system_id ? dm_pool_strdup(vg->vgmem, cmd->system_id) : NULL; + dm_list_iterate_items(pvl, &vg->pvs) { if (!(new_pvl = dm_pool_zalloc(vg->vgmem, sizeof(*new_pvl)))) goto_bad; @@ -174,8 +179,10 @@ static int _vgimportclone_vg_single(struct cmd_context *cmd, const char *vg_name dm_list_add(&vg->pv_write_list, &new_pvl->list); } - dm_list_iterate_items(lvl, &vg->lvs) + dm_list_iterate_items(lvl, &vg->lvs) { memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id)); + lvl->lv->lock_args = NULL; + } if (!vg_write(vg) || !vg_commit(vg)) goto_bad; @@ -343,6 +350,12 @@ retry_name: goto out; } + /* + * Trying to lock the duplicated VG would conflict with the original, + * and it's not needed because the new VG will be imported as a local VG. + */ + cmd->lockd_vg_disable = 1; + ret = process_each_vg(cmd, 0, NULL, vp.old_vgname, NULL, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, 0, handle, _vgimportclone_vg_single); unlock_vg(cmd, NULL, vp.new_vgname); From 3759a1f62bf314fbe2f25b2365c1aebca8071e31 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 15:57:17 -0500 Subject: [PATCH 63/81] pvremove: skip lvmlockd locks for forced clearing pvremove -ff to force clear a PV shouldn't care if lvmlockd locks fail. --- tools/pvremove.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/pvremove.c b/tools/pvremove.c index 28c7b83a1..06a7e7307 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -39,10 +39,19 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv) * (disable afterward to prevent process_each_pv from doing * a shared global lock since it's already acquired it ex.) */ - if (!lockd_gl(cmd, "ex", 0)) - return_ECMD_FAILED; + if (!lockd_gl(cmd, "ex", 0)) { + /* Let pvremove -ff skip locks */ + if (pp.force == DONT_PROMPT_OVERRIDE) + log_warn("WARNING: skipping global lock in lvmlockd for force."); + else + return_ECMD_FAILED; + } cmd->lockd_gl_disable = 1; + /* When forcibly clearing a PV we don't care about a VG lock. */ + if (pp.force == DONT_PROMPT_OVERRIDE) + cmd->lockd_vg_disable = 1; + if (!(handle = init_processing_handle(cmd, NULL))) { log_error("Failed to initialize processing handle."); return ECMD_FAILED; From abba06fb3b3b813e55ab7f27c6ac8274115083e4 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 15:59:17 -0500 Subject: [PATCH 64/81] tests: process-each-duplicate-pvs update for lvmlockd --- test/shell/process-each-duplicate-pvs.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/shell/process-each-duplicate-pvs.sh b/test/shell/process-each-duplicate-pvs.sh index 9ce4e142b..b8a87746e 100644 --- a/test/shell/process-each-duplicate-pvs.sh +++ b/test/shell/process-each-duplicate-pvs.sh @@ -8,7 +8,6 @@ test_description='Test duplicate PVs' -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 SKIP_WITH_CLVMD=1 @@ -25,8 +24,8 @@ aux lvmconf 'devices/allow_changes_with_duplicate_pvs = 0' pvcreate "$dev1" pvcreate "$dev2" -vgcreate $vg1 "$dev1" -vgcreate $vg2 "$dev2" +vgcreate $SHARED $vg1 "$dev1" +vgcreate $SHARED $vg2 "$dev2" pvresize --setphysicalvolumesize 8m -y "$dev2" lvcreate -an -l1 -n $lv1 $vg1 @@ -378,7 +377,16 @@ dd if=/dev/zero of="$dev3" bs=1M oflag=direct,sync || true dd if=/dev/zero of="$dev4" bs=1M oflag=direct,sync || true pvscan --cache -vgcreate "$vg2" "$dev3" "$dev4" +# The previous steps prevent us from nicely cleaning up +# the vg lockspace in lvmlockd, so just restart it; +# what follows could also just be split into a separate test. +if test -n "$LVM_TEST_LVMLOCKD_TEST" ; then + killall -9 lvmlockd + sleep 2 + aux prepare_lvmlockd +fi + +vgcreate $SHARED "$vg2" "$dev3" "$dev4" lvcreate -l1 -n $lv1 $vg2 "$dev3" lvcreate -l1 -n $lv2 $vg2 "$dev4" @@ -457,7 +465,7 @@ pvscan --cache # Reverse devs in the previous in case dev3/dev4 would be # preferred even without an active LV using them. -vgcreate $vg2 "$dev5" "$dev6" +vgcreate $SHARED $vg2 "$dev5" "$dev6" lvcreate -l1 -n $lv1 $vg2 "$dev5" lvcreate -l1 -n $lv2 $vg2 "$dev6" From 063d065388b6437b77815cb1d13a72395a46fd45 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 25 May 2018 17:02:25 -0500 Subject: [PATCH 65/81] tests: add missing file --- test/lib/flavour-udev-lvmlockd-test-lvmetad.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/lib/flavour-udev-lvmlockd-test-lvmetad.sh diff --git a/test/lib/flavour-udev-lvmlockd-test-lvmetad.sh b/test/lib/flavour-udev-lvmlockd-test-lvmetad.sh new file mode 100644 index 000000000..d2a7b4af1 --- /dev/null +++ b/test/lib/flavour-udev-lvmlockd-test-lvmetad.sh @@ -0,0 +1,9 @@ +export LVM_TEST_LOCKING=1 +export LVM_TEST_LVMETAD=1 +export LVM_TEST_LVMPOLLD=1 +export LVM_TEST_LVMLOCKD=1 +export LVM_TEST_LVMLOCKD_TEST=1 +export LVM_TEST_DEVDIR=/dev + +# FIXME:dct: add option to allow --test with sanlock +export LVM_TEST_LVMLOCKD_TEST_DLM=1 From 6cd052333719e4ae23bfaaa03011ed1a2f384f69 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 12:48:18 -0500 Subject: [PATCH 66/81] lvmlockd: enable repairing shared VG while reading it When the lvmlockd lock is shared, upgrade it to ex when repair (writing) is needed during vg_read. Pass the lockd state through additional read-related functions so the instances of repair scattered through vg_read can be handled. (Temporary solution until the ad hoc repairs can be pulled out of vg_read into a top level, centralized repair function.) --- daemons/clvmd/lvm-functions.c | 2 +- lib/metadata/metadata-exported.h | 2 +- lib/metadata/metadata.c | 75 ++++++++++++++++++-------------- tools/toollib.c | 2 +- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 34da66df9..24ed7a031 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -832,7 +832,7 @@ void lvm_do_backup(const char *vgname) pthread_mutex_lock(&lvm_lock); - vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, WARN_PV_READ, &consistent); + vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, 0, WARN_PV_READ, &consistent); if (vg && consistent) check_current_backup(vg); diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 97184ed18..ccf6004e2 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -652,7 +652,7 @@ int vg_write(struct volume_group *vg); int vg_commit(struct volume_group *vg); void vg_revert(struct volume_group *vg); struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name, - const char *vgid, uint32_t warn_flags, int *consistent); + const char *vgid, uint32_t lockd_state, uint32_t warn_flags, int *consistent); #define get_pvs( cmd ) get_pvs_internal((cmd), NULL, NULL) #define get_pvs_perserve_vg( cmd, pv_list, vg_list ) get_pvs_internal((cmd), (pv_list), (vg_list)) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 3f6c2e47a..da66e156c 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -3541,7 +3541,7 @@ static int _is_foreign_vg(struct volume_group *vg) return vg->cmd->system_id && strcmp(vg->system_id, vg->cmd->system_id); } -static int _repair_inconsistent_vg(struct volume_group *vg) +static int _repair_inconsistent_vg(struct volume_group *vg, uint32_t lockd_state) { unsigned saved_handles_missing_pvs = vg->cmd->handles_missing_pvs; @@ -3556,9 +3556,8 @@ static int _repair_inconsistent_vg(struct volume_group *vg) return 0; } - /* FIXME: do this at higher level where lvmlockd lock can be changed. */ - if (is_lockd_type(vg->lock_type)) { - log_verbose("Skip metadata repair for shared VG."); + if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) { + log_verbose("Skip metadata repair for shared VG without exclusive lock."); return 0; } @@ -3581,7 +3580,7 @@ static int _repair_inconsistent_vg(struct volume_group *vg) return 1; } -static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg, struct dm_list *to_check) +static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg, struct dm_list *to_check, uint32_t lockd_state) { struct pv_list *pvl, *pvl2; char uuid[64] __attribute__((aligned(8))); @@ -3603,14 +3602,8 @@ static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg, return 0; } - /* - * FIXME: do this at higher level where lvmlockd lock can be changed. - * Also if we're reading the VG with the --shared option (not using - * lvmlockd), we can see a VG while it's being written by another - * host, same as the foreign VG case. - */ - if (is_lockd_type(vg->lock_type)) { - log_debug_metadata("Skip wiping outdated PVs for shared VG."); + if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) { + log_verbose("Skip wiping outdated PVs for shared VG without exclusive lock."); return 0; } @@ -3619,6 +3612,8 @@ static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg, if (pvl->pv->dev == pvl2->pv->dev) goto next_pv; } + + if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) return_0; log_warn("WARNING: Removing PV %s (%s) that no longer belongs to VG %s", @@ -3639,6 +3634,7 @@ next_pv: static int _check_or_repair_pv_ext(struct cmd_context *cmd, struct volume_group *vg, + uint32_t lockd_state, int repair, int *inconsistent_pvs) { char uuid[64] __attribute__((aligned(8))); @@ -3688,10 +3684,7 @@ static int _check_or_repair_pv_ext(struct cmd_context *cmd, "VG %s but not marked as used.", pv_dev_name(pvl->pv), vg->name); *inconsistent_pvs = 1; - } else if (is_lockd_type(vg->lock_type)) { - /* - * FIXME: decide how to handle repair for shared VGs. - */ + } else if (is_lockd_type(vg->lock_type) && !(lockd_state & LDST_EX)) { log_warn("Skip repair of PV %s that is in shared " "VG %s but not marked as used.", pv_dev_name(pvl->pv), vg->name); @@ -3715,7 +3708,7 @@ static int _check_or_repair_pv_ext(struct cmd_context *cmd, r = 1; out: - if ((pvs_fixed > 0) && !_repair_inconsistent_vg(vg)) + if ((pvs_fixed > 0) && !_repair_inconsistent_vg(vg, lockd_state)) return_0; return r; @@ -3738,6 +3731,7 @@ out: static struct volume_group *_vg_read(struct cmd_context *cmd, const char *vgname, const char *vgid, + uint32_t lockd_state, uint32_t warn_flags, int *consistent, unsigned precommitted) { @@ -3787,10 +3781,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, dm_list_iterate_items(pvl, &correct_vg->pvs) reappeared += _check_reappeared_pv(correct_vg, pvl->pv, *consistent); if (reappeared && *consistent) - *consistent = _repair_inconsistent_vg(correct_vg); + *consistent = _repair_inconsistent_vg(correct_vg, lockd_state); else *consistent = !reappeared; - if (_wipe_outdated_pvs(cmd, correct_vg, &correct_vg->pvs_outdated)) { + if (_wipe_outdated_pvs(cmd, correct_vg, &correct_vg->pvs_outdated, lockd_state)) { /* clear the list */ dm_list_init(&correct_vg->pvs_outdated); lvmetad_vg_clear_outdated_pvs(correct_vg); @@ -4310,13 +4304,13 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, dm_list_iterate_items(pvl, &all_pvs) _check_reappeared_pv(correct_vg, pvl->pv, 1); - if (!_repair_inconsistent_vg(correct_vg)) { + if (!_repair_inconsistent_vg(correct_vg, lockd_state)) { _free_pv_list(&all_pvs); release_vg(correct_vg); return NULL; } - if (!_wipe_outdated_pvs(cmd, correct_vg, &all_pvs)) { + if (!_wipe_outdated_pvs(cmd, correct_vg, &all_pvs, lockd_state)) { _free_pv_list(&all_pvs); release_vg(correct_vg); return_NULL; @@ -4340,7 +4334,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, } /* We have the VG now finally, check if PV ext info is in sync with VG metadata. */ - if (!cmd->is_clvmd && !_check_or_repair_pv_ext(cmd, correct_vg, + if (!cmd->is_clvmd && !_check_or_repair_pv_ext(cmd, correct_vg, lockd_state, skipped_rescan ? 0 : *consistent, &inconsistent_pvs)) { release_vg(correct_vg); @@ -4502,13 +4496,15 @@ static int _check_devs_used_correspond_with_vg(struct volume_group *vg) return 1; } -struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname, - const char *vgid, uint32_t warn_flags, int *consistent) +struct volume_group *vg_read_internal(struct cmd_context *cmd, + const char *vgname, const char *vgid, + uint32_t lockd_state, uint32_t warn_flags, + int *consistent) { struct volume_group *vg; struct lv_list *lvl; - if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, consistent, 0))) + if (!(vg = _vg_read(cmd, vgname, vgid, lockd_state, warn_flags, consistent, 0))) goto_out; if (!check_pv_dev_sizes(vg)) @@ -4616,7 +4612,7 @@ struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, label_scan_setup_bcache(); - if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, &consistent, precommitted))) { + if (!(vg = _vg_read(cmd, vgname, vgid, 0, warn_flags, &consistent, precommitted))) { log_error("Rescan devices to look for missing VG."); goto scan; } @@ -4637,7 +4633,7 @@ struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, lvmcache_label_scan(cmd); warn_flags |= SKIP_RESCAN; - if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, &consistent, precommitted))) + if (!(vg = _vg_read(cmd, vgname, vgid, 0, warn_flags, &consistent, precommitted))) goto fail; label_scan_destroy(cmd); /* drop bcache to close devs, keep lvmcache */ @@ -4876,7 +4872,7 @@ static int _get_pvs(struct cmd_context *cmd, uint32_t warn_flags, warn_flags |= WARN_INCONSISTENT; - if (!(vg = vg_read_internal(cmd, vgname, (!vgslist) ? vgid : NULL, warn_flags, &consistent))) { + if (!(vg = vg_read_internal(cmd, vgname, (!vgslist) ? vgid : NULL, 0, warn_flags, &consistent))) { stack; continue; } @@ -5189,17 +5185,30 @@ int vg_check_status(const struct volume_group *vg, uint64_t status) * VG is left unlocked on failure */ static struct volume_group *_recover_vg(struct cmd_context *cmd, - const char *vg_name, const char *vgid) + const char *vg_name, const char *vgid, uint32_t lockd_state) { int consistent = 1; struct volume_group *vg; + uint32_t state = 0; unlock_vg(cmd, NULL, vg_name); if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) return_NULL; - if (!(vg = vg_read_internal(cmd, vg_name, vgid, WARN_PV_READ, &consistent))) { + /* + * Convert vg lock in lvmlockd from sh to ex. + */ + if (!(lockd_state & LDST_FAIL) && !(lockd_state & LDST_EX)) { + log_debug("Upgrade lvmlockd lock to repair vg %s.", vg_name); + if (!lockd_vg(cmd, vg_name, "ex", 0, &state)) { + log_warn("Skip repair for shared VG without exclusive lock."); + return NULL; + } + lockd_state |= LDST_EX; + } + + if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, WARN_PV_READ, &consistent))) { unlock_vg(cmd, NULL, vg_name); return_NULL; } @@ -5473,7 +5482,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha warn_flags |= WARN_INCONSISTENT; /* If consistent == 1, we get NULL here if correction fails. */ - if (!(vg = vg_read_internal(cmd, vg_name, vgid, warn_flags, &consistent))) { + if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, warn_flags, &consistent))) { if (consistent_in && !consistent) { failure |= FAILED_INCONSISTENT; goto bad; @@ -5490,7 +5499,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha /* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */ if (!consistent && !failure) { release_vg(vg); - if (!(vg = _recover_vg(cmd, vg_name, vgid))) { + if (!(vg = _recover_vg(cmd, vg_name, vgid, lockd_state))) { if (is_orphan_vg(vg_name)) log_error("Recovery of standalone physical volumes failed."); else diff --git a/tools/toollib.c b/tools/toollib.c index 0fc86cff5..19f4c331a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -5730,7 +5730,7 @@ do_command: if (pp->preserve_existing && pp->orphan_vg_name) { log_debug("Using existing orphan PVs in %s.", pp->orphan_vg_name); - if (!(orphan_vg = vg_read_internal(cmd, pp->orphan_vg_name, NULL, 0, &consistent))) { + if (!(orphan_vg = vg_read_internal(cmd, pp->orphan_vg_name, NULL, 0, 0, &consistent))) { log_error("Cannot read orphans VG %s.", pp->orphan_vg_name); goto bad; } From 05ee83579be1f7aa1107de438762d039e0424edf Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 12:55:49 -0500 Subject: [PATCH 67/81] tests: enable vg repair tests with lvmlockd --- test/shell/inconsistent-metadata.sh | 4 ++-- test/shell/lvchange-partial.sh | 2 +- test/shell/lvconvert-repair-dmeventd.sh | 2 +- test/shell/lvconvert-repair-mirror.sh | 2 +- test/shell/lvconvert-repair-policy.sh | 2 +- test/shell/lvconvert-repair-raid-dmeventd.sh | 2 +- test/shell/lvconvert-repair-replace.sh | 12 ++++++------ test/shell/lvconvert-repair-snapshot.sh | 2 +- test/shell/lvconvert-repair-transient-dmeventd.sh | 2 +- test/shell/lvconvert-repair-transient.sh | 2 +- test/shell/mda-rollback.sh | 4 ++-- test/shell/unlost-pv.sh | 2 +- test/shell/vgextend-restoremissing.sh | 2 +- test/shell/vgreduce-removemissing-snapshot.sh | 2 +- test/shell/vgreduce-usage.sh | 14 +++++++------- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/shell/inconsistent-metadata.sh b/test/shell/inconsistent-metadata.sh index 358ffcb1b..f5ccd137d 100644 --- a/test/shell/inconsistent-metadata.sh +++ b/test/shell/inconsistent-metadata.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -74,7 +74,7 @@ vgremove -f $vg pvremove -ff "${DEVICES[@]}" pvcreate "${DEVICES[@]}" aux backup_dev "$dev2" -vgcreate $vg "$dev1" +vgcreate $SHARED $vg "$dev1" vgextend $vg "$dev2" aux restore_dev "$dev2" vgscan $cache diff --git a/test/shell/lvchange-partial.sh b/test/shell/lvchange-partial.sh index 60b2b50bf..7913811ae 100644 --- a/test/shell/lvchange-partial.sh +++ b/test/shell/lvchange-partial.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-dmeventd.sh b/test/shell/lvconvert-repair-dmeventd.sh index b7efda25d..9e0dd8c74 100644 --- a/test/shell/lvconvert-repair-dmeventd.sh +++ b/test/shell/lvconvert-repair-dmeventd.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-mirror.sh b/test/shell/lvconvert-repair-mirror.sh index b0c199df0..a37dec9ba 100644 --- a/test/shell/lvconvert-repair-mirror.sh +++ b/test/shell/lvconvert-repair-mirror.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-policy.sh b/test/shell/lvconvert-repair-policy.sh index 15d4e7ca0..f9fca0028 100644 --- a/test/shell/lvconvert-repair-policy.sh +++ b/test/shell/lvconvert-repair-policy.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/lvconvert-repair-raid-dmeventd.sh b/test/shell/lvconvert-repair-raid-dmeventd.sh index f08b3da96..5519c4e52 100644 --- a/test/shell/lvconvert-repair-raid-dmeventd.sh +++ b/test/shell/lvconvert-repair-raid-dmeventd.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-replace.sh b/test/shell/lvconvert-repair-replace.sh index 4a55969c1..1fe796579 100644 --- a/test/shell/lvconvert-repair-replace.sh +++ b/test/shell/lvconvert-repair-replace.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + . lib/inittest @@ -32,7 +32,7 @@ vgremove -ff $vg # 3-way, disk log # multiple failures, partial replace -vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" lvcreate -aey --mirrorlog disk --type mirror -m 2 --ignoremonitoring --nosync -L 1 -n 3way $vg "$dev1" "$dev2" "$dev3" "$dev4" aux disable_dev "$dev1" "$dev2" lvconvert -y --repair $vg/3way 2>&1 | tee 3way.out @@ -43,7 +43,7 @@ check mirror $vg 3way aux enable_dev "$dev1" "$dev2" vgremove -ff $vg -vgcreate $vg "$dev1" "$dev2" "$dev3" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" lvcreate -aey --mirrorlog disk --type mirror -m 1 --ignoremonitoring --nosync -l 1 -n 2way $vg "$dev1" "$dev2" "$dev3" aux disable_dev "$dev1" lvconvert -y --repair $vg/2way 2>&1 | tee 2way.out @@ -61,7 +61,7 @@ test -e LOCAL_CLVMD && exit 0 # Test repair of inactive mirror with log failure # Replacement should fail, but convert should succeed (switch to corelog) -vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" lvcreate -aey --type mirror -m 2 --ignoremonitoring -l 2 -n mirror2 $vg "$dev1" "$dev2" "$dev3" "$dev4":0 vgchange -a n $vg pvremove -ff -y "$dev4" @@ -73,7 +73,7 @@ vgremove -ff $vg if aux kernel_at_least 3 0 0; then # 2-way, mirrored log # Double log failure, full replace - vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" + vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" lvcreate -aey --mirrorlog mirrored --type mirror -m 1 --ignoremonitoring --nosync -L 1 -n 2way $vg \ "$dev1" "$dev2" "$dev3":0 "$dev4":0 aux disable_dev "$dev3" "$dev4" @@ -88,7 +88,7 @@ fi # 3-way, mirrored log # Single log failure, replace -vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" lvcreate -aey --mirrorlog mirrored --type mirror -m 2 --ignoremonitoring --nosync -L 1 -n 3way $vg \ "$dev1" "$dev2" "$dev3" "$dev4":0 "$dev5":0 aux disable_dev "$dev4" diff --git a/test/shell/lvconvert-repair-snapshot.sh b/test/shell/lvconvert-repair-snapshot.sh index 8e66664be..0e9b2a362 100644 --- a/test/shell/lvconvert-repair-snapshot.sh +++ b/test/shell/lvconvert-repair-snapshot.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-transient-dmeventd.sh b/test/shell/lvconvert-repair-transient-dmeventd.sh index 7b2dd3fa3..6679dd625 100644 --- a/test/shell/lvconvert-repair-transient-dmeventd.sh +++ b/test/shell/lvconvert-repair-transient-dmeventd.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair-transient.sh b/test/shell/lvconvert-repair-transient.sh index 082f7f2d9..aa697f9a6 100644 --- a/test/shell/lvconvert-repair-transient.sh +++ b/test/shell/lvconvert-repair-transient.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/mda-rollback.sh b/test/shell/mda-rollback.sh index 34080faaf..adfc110c6 100644 --- a/test/shell/mda-rollback.sh +++ b/test/shell/mda-rollback.sh @@ -10,14 +10,14 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest aux prepare_devs 3 -vgcreate --metadatasize 128k $vg1 "$dev1" "$dev2" "$dev3" +vgcreate $SHARED --metadatasize 128k $vg1 "$dev1" "$dev2" "$dev3" vgreduce $vg1 "$dev1" dd if="$dev1" of=badmda bs=256K count=1 diff --git a/test/shell/unlost-pv.sh b/test/shell/unlost-pv.sh index ffc22b834..edf7f31e2 100644 --- a/test/shell/unlost-pv.sh +++ b/test/shell/unlost-pv.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vgextend-restoremissing.sh b/test/shell/vgextend-restoremissing.sh index 969140ac2..afbe5ba7b 100644 --- a/test/shell/vgextend-restoremissing.sh +++ b/test/shell/vgextend-restoremissing.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/vgreduce-removemissing-snapshot.sh b/test/shell/vgreduce-removemissing-snapshot.sh index 8ddb3d945..a74ff3400 100644 --- a/test/shell/vgreduce-removemissing-snapshot.sh +++ b/test/shell/vgreduce-removemissing-snapshot.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_CLVMD=1 SKIP_WITH_LVMPOLLD=1 diff --git a/test/shell/vgreduce-usage.sh b/test/shell/vgreduce-usage.sh index e24be368d..e6f10f0c3 100644 --- a/test/shell/vgreduce-usage.sh +++ b/test/shell/vgreduce-usage.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -30,18 +30,18 @@ do pvcreate -M$mdatype "$dev1" "$dev2" # (lvm$mdatype) vgreduce removes only the specified pv from vg (bz427382)" ' - vgcreate -M$mdatype $vg1 "$dev1" "$dev2" + vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" vgreduce $vg1 "$dev1" check pv_field "$dev2" vg_name $vg1 vgremove -f $vg1 # (lvm$mdatype) vgreduce rejects removing the last pv (--all) - vgcreate -M$mdatype $vg1 "$dev1" "$dev2" + vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" not vgreduce --all $vg1 vgremove -f $vg1 # (lvm$mdatype) vgreduce rejects removing the last pv - vgcreate -M$mdatype $vg1 "$dev1" "$dev2" + vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" not vgreduce $vg1 "$dev1" "$dev2" vgremove -f $vg1 @@ -55,13 +55,13 @@ pvcreate -M$mdatype "$dev1" "$dev2" pvcreate --metadatacopies 0 -M$mdatype "$dev3" "$dev4" # (lvm$mdatype) vgreduce rejects removing pv with the last mda copy (bz247448) -vgcreate -M$mdatype $vg1 "$dev1" "$dev3" +vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev3" not vgreduce $vg1 "$dev1" vgremove -f $vg1 #COMM "(lvm$mdatype) vgreduce --removemissing --force repares to linear (bz221921)" # (lvm$mdatype) setup: create mirror & damage one pv -vgcreate -M$mdatype $vg1 "$dev1" "$dev2" "$dev3" +vgcreate $SHARED -M$mdatype $vg1 "$dev1" "$dev2" "$dev3" lvcreate -aey -n $lv1 --type mirror -m1 -l 4 $vg1 lvcreate -n $lv2 -l 4 $vg1 "$dev2" lvcreate -n $lv3 -l 4 $vg1 "$dev3" @@ -79,7 +79,7 @@ not vgs $vg1 # just double-check it's really gone #COMM "vgreduce rejects --removemissing --mirrorsonly --force when nonmirror lv lost too" # (lvm$mdatype) setup: create mirror + linear lvs -vgcreate -M$mdatype "$vg1" "${DEVICES[@]}" +vgcreate $SHARED -M$mdatype "$vg1" "${DEVICES[@]}" lvcreate -n $lv2 -l 4 $vg1 lvcreate -aey --type mirror -m1 -n $lv1 -l 4 $vg1 "$dev1" "$dev2" "$dev3" lvcreate -n $lv3 -l 4 $vg1 "$dev3" From 27495a355536360404c8b8ee254ccaebb054debc Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 13:56:06 -0500 Subject: [PATCH 68/81] tests: enable pvmove-restart with lvmlockd --- test/shell/pvmove-restart.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh index abdcd86dd..dcf4c3792 100644 --- a/test/shell/pvmove-restart.sh +++ b/test/shell/pvmove-restart.sh @@ -12,13 +12,11 @@ # Check pvmove behavior when it's progress and machine is rebooted -SKIP_WITH_LVMLOCKD=1 - . lib/inittest aux prepare_pvs 3 60 -vgcreate -s 128k $vg "$dev1" "$dev2" +vgcreate $SHARED -s 128k $vg "$dev1" "$dev2" pvcreate --metadatacopies 0 "$dev3" vgextend $vg "$dev3" @@ -94,7 +92,7 @@ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10 aux wait_pvmove_lv_ready "$vg-pvmove0" dmsetup table -pvmove --abort +pvmove --abort "$dev1" lvs -a -o+devices $vg From c516321325f41f6b1f9d9342e2b0d0507b5a30fd Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 15:24:24 -0500 Subject: [PATCH 69/81] lvmlockd: enable lvcreate of new LV plus existing cache pool In this command, lvcreate creates a new LV and then combines it with an existing cache pool, producing a cache LV. This command was previously not allowed in in a shared VG. --- lib/locking/lvmlockd.c | 8 -------- lib/metadata/lv_manip.c | 14 ++++++++++++-- tools/lvcreate.c | 3 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index be37dc287..0af2b3872 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -2454,14 +2454,6 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic lv->lock_args = NULL; return 1; - } else if (seg_is_cache(lp)) { - /* - * This should not happen because the command defs are - * checked and excluded for shared VGs early in lvcreate. - */ - log_error("Use lvconvert for cache with lock type %s", vg->lock_type); - return 0; - } else if (!seg_is_thin_volume(lp) && lp->snapshot) { struct logical_volume *origin_lv; diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 4aefea06f..c1bba03db 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -7801,10 +7801,20 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, lv->status |= LV_TEMPORARY; if (seg_is_cache(lp)) { + if (is_lockd_type(lv->vg->lock_type)) { + if (is_change_activating(lp->activate)) { + if (!lv_active_change(cmd, lv, CHANGE_AEY, 0)) { + log_error("Aborting. Failed to activate LV %s.", + display_lvname(lv)); + goto revert_new_lv; + } + } + } + /* FIXME Support remote exclusive activation? */ /* Not yet 'cache' LV, it is stripe volume for wiping */ - if (is_change_activating(lp->activate) && - !activate_lv_excl_local(cmd, lv)) { + + else if (is_change_activating(lp->activate) && !activate_lv_excl_local(cmd, lv)) { log_error("Aborting. Failed to activate LV %s locally exclusively.", display_lvname(lv)); goto revert_new_lv; diff --git a/tools/lvcreate.c b/tools/lvcreate.c index ee6df02ab..7f97ebd1c 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -1638,8 +1638,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name, lp->snapshot ? lp->origin_name : "", lp->segtype->name); if (is_lockd_type(vg->lock_type)) { - if (cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD || - cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD || + if (cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD || cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) { log_error("Use lvconvert to create thin pools and cache pools in a shared VG."); goto out; From 214235367b3500a586fc42232af34bd04ad14078 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 15:56:08 -0500 Subject: [PATCH 70/81] tests: enable lvcreate cache tests with lvmlockd Tests that want to use lvcreate to create a new origin LV and then combine it with an existing cache pool to create a cache LV. --- test/shell/cache-metadata2.sh | 2 +- test/shell/component-cache.sh | 2 +- test/shell/lvchange-cache-mode.sh | 2 +- test/shell/lvchange-cache.sh | 2 +- test/shell/lvconvert-cache-abort.sh | 2 +- test/shell/lvconvert-cache-smq.sh | 2 +- test/shell/profiles-cache.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/shell/cache-metadata2.sh b/test/shell/cache-metadata2.sh index a7586f7b6..684ae670a 100644 --- a/test/shell/cache-metadata2.sh +++ b/test/shell/cache-metadata2.sh @@ -12,7 +12,7 @@ # Exercise usage of metadata2 cache metadata format -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 # Until new version of cache_check tools - no integrity validation diff --git a/test/shell/component-cache.sh b/test/shell/component-cache.sh index 2060b3132..87ca9583d 100644 --- a/test/shell/component-cache.sh +++ b/test/shell/component-cache.sh @@ -12,7 +12,7 @@ # Exercise activation of cache component devices -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-cache-mode.sh b/test/shell/lvchange-cache-mode.sh index 2bb8641d4..a34e51750 100644 --- a/test/shell/lvchange-cache-mode.sh +++ b/test/shell/lvchange-cache-mode.sh @@ -12,7 +12,7 @@ # Exercise changing of caching mode on both cache pool and cached LV. -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh index 73ad6c0a0..7e95f6157 100644 --- a/test/shell/lvchange-cache.sh +++ b/test/shell/lvchange-cache.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-cache-abort.sh b/test/shell/lvconvert-cache-abort.sh index e771947c2..404f44269 100644 --- a/test/shell/lvconvert-cache-abort.sh +++ b/test/shell/lvconvert-cache-abort.sh @@ -12,7 +12,7 @@ # Exercise cache flushing is abortable -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-cache-smq.sh b/test/shell/lvconvert-cache-smq.sh index e329aee98..67710fa63 100644 --- a/test/shell/lvconvert-cache-smq.sh +++ b/test/shell/lvconvert-cache-smq.sh @@ -12,7 +12,7 @@ # Exercise conversion of cache and cache pool -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/profiles-cache.sh b/test/shell/profiles-cache.sh index dd4affb07..9e17ebf60 100644 --- a/test/shell/profiles-cache.sh +++ b/test/shell/profiles-cache.sh @@ -13,7 +13,7 @@ # Exercise obtaining cache parameter from various sources # Either commmand line or metadata profile or implicit default... -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest From 2beb3009bd7e34604dbd4f03c95fb7cd85eb98a6 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 30 May 2018 16:40:03 -0500 Subject: [PATCH 71/81] tests: change lvcreate syntax to allow lvmlockd Using the less ambiguous lvcreate syntax for creating a cache LV allows more tests to run with lvmlockd. --- test/shell/lvchange-cache-old.sh | 4 ++-- test/shell/lvconvert-cache-raid.sh | 3 +-- test/shell/lvcreate-cache-snapshot.sh | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/shell/lvchange-cache-old.sh b/test/shell/lvchange-cache-old.sh index cb7915d93..992249cd7 100644 --- a/test/shell/lvchange-cache-old.sh +++ b/test/shell/lvchange-cache-old.sh @@ -12,7 +12,7 @@ # Exercise usage of older metadata which are missing some new settings -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -24,7 +24,7 @@ aux prepare_vg 5 80 lvcreate -l 10 --type cache-pool $vg/cpool -lvcreate -l 20 -H -n $lv1 $vg/cpool +lvcreate -l 20 -H -n $lv1 --cachepool $vg/cpool $vg vgcfgbackup -f backup $vg diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh index ec9b1e462..fa4916398 100644 --- a/test/shell/lvconvert-cache-raid.sh +++ b/test/shell/lvconvert-cache-raid.sh @@ -12,7 +12,6 @@ # Exercise usage of stacked cache volume using raid volume -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -86,7 +85,7 @@ lvremove -f $vg # Test up/down raid conversion of cache pool data and metadata lvcreate --type cache-pool $vg/cpool -l 10 -lvcreate -n corigin -H $vg/cpool -l 20 +lvcreate -H -n corigin --cachepool $vg/cpool -l 20 $vg lvconvert -y -m +1 --type raid1 $vg/cpool_cmeta check lv_field $vg/cpool_cmeta layout "raid,raid1" diff --git a/test/shell/lvcreate-cache-snapshot.sh b/test/shell/lvcreate-cache-snapshot.sh index c1be6a2da..5d1c5a753 100644 --- a/test/shell/lvcreate-cache-snapshot.sh +++ b/test/shell/lvcreate-cache-snapshot.sh @@ -12,7 +12,6 @@ # Exercise creation of snapshot of cached LV -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -25,7 +24,7 @@ aux have_cache 1 5 0 || skip aux prepare_vg 2 lvcreate --type cache-pool -L1 $vg/cpool -lvcreate -H -L4 -n $lv1 $vg/cpool +lvcreate -H -L4 -n $lv1 --cachepool $vg/cpool $vg lvcreate -s -L2 -n $lv2 $vg/$lv1 check lv_field $vg/$lv1 segtype cache From fdaa7e2e87d4a59b39e701961da6961f371ca980 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 10:23:03 -0500 Subject: [PATCH 72/81] vgs: add report field for shared equivalent to a non-empty -o locktype. --- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 5 +++++ lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 8 ++++++++ lib/report/values.h | 1 + 6 files changed, 18 insertions(+) diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index ccf6004e2..916d029e2 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -1310,6 +1310,7 @@ int validate_vg_rename_params(struct cmd_context *cmd, const char *vg_name_new); int is_lockd_type(const char *lock_type); +int vg_is_shared(const struct volume_group *vg); int is_system_id_allowed(struct cmd_context *cmd, const char *system_id); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index da66e156c..ab53bfa45 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -6052,6 +6052,11 @@ int is_lockd_type(const char *lock_type) return 0; } +int vg_is_shared(const struct volume_group *vg) +{ + return (vg->lock_type && is_lockd_type(vg->lock_type)); +} + int vg_strip_outdated_historical_lvs(struct volume_group *vg) { struct glv_list *glvl, *tglvl; time_t current_time = time(NULL); diff --git a/lib/report/columns.h b/lib/report/columns.h index be39ed992..827a15720 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -211,6 +211,7 @@ FIELD(VGS, vg, BIN, "Exported", cmd, 10, vgexported, vg_exported, "Set if VG is FIELD(VGS, vg, BIN, "Partial", cmd, 10, vgpartial, vg_partial, "Set if VG is partial.", 0) FIELD(VGS, vg, STR, "AllocPol", cmd, 10, vgallocationpolicy, vg_allocation_policy, "VG allocation policy.", 0) FIELD(VGS, vg, BIN, "Clustered", cmd, 10, vgclustered, vg_clustered, "Set if VG is clustered.", 0) +FIELD(VGS, vg, BIN, "Shared", cmd, 7, vgshared, vg_shared, "Set if VG is shared.", 0) FIELD(VGS, vg, SIZ, "VSize", cmd, 0, vgsize, vg_size, "Total size of VG in current units.", 0) FIELD(VGS, vg, SIZ, "VFree", cmd, 0, vgfree, vg_free, "Total amount of free space in current units.", 0) FIELD(VGS, vg, STR, "SYS ID", cmd, 0, vgsystemid, vg_sysid, "System ID of the VG indicating which host owns it.", 0) diff --git a/lib/report/properties.c b/lib/report/properties.c index 8e86b7a67..72c8f3236 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -213,6 +213,8 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size) #define _vg_allocation_policy_get prop_not_implemented_get #define _vg_clustered_set prop_not_implemented_set #define _vg_clustered_get prop_not_implemented_get +#define _vg_shared_set prop_not_implemented_set +#define _vg_shared_get prop_not_implemented_get #define _lv_layout_set prop_not_implemented_set #define _lv_layout_get prop_not_implemented_get diff --git a/lib/report/report.c b/lib/report/report.c index 01ab62722..19f0f5c6c 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -3385,6 +3385,14 @@ static int _vgclustered_disp(struct dm_report *rh, struct dm_pool *mem, return _binary_disp(rh, mem, field, clustered, GET_FIRST_RESERVED_NAME(vg_clustered_y), private); } +static int _vgshared_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) +{ + int shared = (vg_is_shared((const struct volume_group *) data)) != 0; + return _binary_disp(rh, mem, field, shared, GET_FIRST_RESERVED_NAME(vg_shared_y), private); +} + static int _lvlayout_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) diff --git a/lib/report/values.h b/lib/report/values.h index 7c53651d4..96729efdf 100644 --- a/lib/report/values.h +++ b/lib/report/values.h @@ -60,6 +60,7 @@ FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "", "extendable") FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "", "exported") FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "", "partial") FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "", "clustered") +FIELD_RESERVED_BINARY_VALUE(vg_shared, vg_shared, "", "shared") FIELD_RESERVED_VALUE(NAMED, vg_permissions, vg_permissions_rw, "", "writeable", "writeable", "rw", "read-write") FIELD_RESERVED_VALUE(NAMED, vg_permissions, vg_permissions_r, "", "read-only", "read-only", "r", "ro") FIELD_RESERVED_VALUE(NOFLAG, vg_mda_copies, vg_mda_copies_unmanaged, "", &GET_TYPE_RESERVED_VALUE(num_undef_64), "unmanaged") From 8d9d32b315afd0fb2b674ca3bb857cb4ce2cbf2e Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 14:20:11 -0500 Subject: [PATCH 73/81] lvmlockd: enable lvcreate -H -L LV Allow this command in a shared VG which had previously been disallowed. --- tools/lvcreate.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 7f97ebd1c..867cde163 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -1230,6 +1230,14 @@ static int _determine_cache_argument(struct volume_group *vg, log_verbose("Skipping activation of cache origin %s.", display_lvname(lv)); return 1; + + } else if (is_lockd_type(vg->lock_type)) { + if (!lv_active_change(cmd, lv, CHANGE_AEY, 0)) { + log_error("Cannot activate cache origin %s.", + display_lvname(lv)); + return 0; + } + } else if (!activate_lv_excl_local(cmd, lv)) { log_error("Cannot activate cache origin %s.", display_lvname(lv)); @@ -1638,8 +1646,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name, lp->snapshot ? lp->origin_name : "", lp->segtype->name); if (is_lockd_type(vg->lock_type)) { - if (cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD || - cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) { + if (cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD) { log_error("Use lvconvert to create thin pools and cache pools in a shared VG."); goto out; } From 08771bbbbf20298df0440dd8ca75ca10af60eb2f Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 14:49:16 -0500 Subject: [PATCH 74/81] tests: enable lvmlockd with tests using lvcreate -H -L LV --- test/shell/lvcreate-cache-no-tools.sh | 2 +- test/shell/lvcreate-cache-raid.sh | 2 +- test/shell/lvcreate-cache.sh | 2 +- test/shell/lvcreate-thin-cache.sh | 4 ++-- test/shell/lvextend-thin-cache.sh | 2 +- test/shell/lvs-cache.sh | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/shell/lvcreate-cache-no-tools.sh b/test/shell/lvcreate-cache-no-tools.sh index c38ecfd3b..23528e493 100644 --- a/test/shell/lvcreate-cache-no-tools.sh +++ b/test/shell/lvcreate-cache-no-tools.sh @@ -12,7 +12,7 @@ # Exercise creation of cache without cache_check -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-cache-raid.sh b/test/shell/lvcreate-cache-raid.sh index d540d4e4e..d1d1c1900 100644 --- a/test/shell/lvcreate-cache-raid.sh +++ b/test/shell/lvcreate-cache-raid.sh @@ -12,7 +12,7 @@ # Exercise creation of cache and raids -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh index 8edbeb2e0..010c06f4a 100644 --- a/test/shell/lvcreate-cache.sh +++ b/test/shell/lvcreate-cache.sh @@ -15,7 +15,7 @@ # Full CLI uses --type # Shorthand CLI uses -H | --cache -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-thin-cache.sh b/test/shell/lvcreate-thin-cache.sh index 0b9f3c868..f87526ad4 100644 --- a/test/shell/lvcreate-thin-cache.sh +++ b/test/shell/lvcreate-thin-cache.sh @@ -12,7 +12,7 @@ # Exercise caching thin-pool's data LV -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} @@ -30,7 +30,7 @@ which mkfs.ext4 || skip aux prepare_pvs 2 64 get_devs -vgcreate -s 64K "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 64K "$vg" "${DEVICES[@]}" lvcreate -L10M -V10M -T $vg/pool --name $lv1 diff --git a/test/shell/lvextend-thin-cache.sh b/test/shell/lvextend-thin-cache.sh index 8983b7d8b..f7bbfd992 100644 --- a/test/shell/lvextend-thin-cache.sh +++ b/test/shell/lvextend-thin-cache.sh @@ -12,7 +12,7 @@ # Exercise resize of cached thin pool data volumes -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false} diff --git a/test/shell/lvs-cache.sh b/test/shell/lvs-cache.sh index 84ac02628..62d45ac02 100644 --- a/test/shell/lvs-cache.sh +++ b/test/shell/lvs-cache.sh @@ -15,7 +15,7 @@ # Full CLI uses --type # Shorthand CLI uses -H | --cache -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest From 4a01e4f3895a947c0c693d0336643a1287de6df5 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 15:12:34 -0500 Subject: [PATCH 75/81] tests: enable metadata-balance with lvmlockd --- test/shell/metadata-balance.sh | 49 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/test/shell/metadata-balance.sh b/test/shell/metadata-balance.sh index fe94aed57..5f856a1ba 100644 --- a/test/shell/metadata-balance.sh +++ b/test/shell/metadata-balance.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -23,7 +22,7 @@ for mdacp in 1 2; do pvcreate --metadatacopies $mdacp "$dev1" "$dev2" pvcreate --metadatacopies 0 "$dev3" if [ $pv_in_vg = 1 ]; then - vgcreate $vg "$dev1" "$dev2" "$dev3" + vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" fi pvchange --metadataignore y "$dev1" check pv_field "$dev1" pv_mda_count $mdacp @@ -64,7 +63,7 @@ pvunignore_ () { fi } -echo Test of vgmetadatacopies with vgcreate and vgchange +echo Test of vgmetadatacopies with vgcreate $SHARED and vgchange for mdacp in 1 2; do pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev4" "$dev5" check pv_field "$dev1" pv_mda_used_count $mdacp @@ -72,7 +71,7 @@ for mdacp in 1 2; do check pv_field "$dev4" pv_mda_used_count $mdacp check pv_field "$dev5" pv_mda_used_count $mdacp pvcreate --metadatacopies 0 "$dev3" - vgcreate $vg "$dev1" "$dev2" "$dev3" + vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" check vg_field $vg vg_mda_copies unmanaged echo ensure both --vgmetadatacopies and --metadatacopies accepted vgchange --metadatacopies $(( mdacp * 1 )) $vg @@ -91,34 +90,34 @@ for mdacp in 1 2; do vgchange --vgmetadatacopies unmanaged $vg check vg_field $vg vg_mda_copies unmanaged vgremove -f $vg - echo vgcreate succeeds even when creating a VG w/all ignored mdas + echo vgcreate $SHARED succeeds even when creating a VG w/all ignored mdas pvchange --metadataignore y "$dev1" "$dev2" check pv_field "$dev1" pv_mda_count $mdacp check pv_field "$dev2" pv_mda_used_count 0 - vgcreate $vg "$dev1" "$dev2" + vgcreate $SHARED $vg "$dev1" "$dev2" check vg_field $vg vg_mda_copies unmanaged vgremove -f $vg - echo vgcreate succeeds with a specific number of metadata copies - vgcreate --vgmetadatacopies $(( mdacp * 2 )) $vg "$dev1" "$dev2" + echo vgcreate $SHARED succeeds with a specific number of metadata copies + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 2 )) $vg "$dev1" "$dev2" check vg_field $vg vg_mda_copies $(( mdacp * 2 )) vgremove -f $vg - vgcreate --vgmetadatacopies $(( mdacp * 1 )) $vg "$dev1" "$dev2" + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg "$dev1" "$dev2" check vg_field $vg vg_mda_copies $(( mdacp * 1 )) vgremove -f $vg - echo vgcreate succeeds with a larger value than total metadatacopies - vgcreate --vgmetadatacopies $(( mdacp * 5 )) $vg "$dev1" "$dev2" + echo vgcreate $SHARED succeeds with a larger value than total metadatacopies + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 5 )) $vg "$dev1" "$dev2" check vg_field $vg vg_mda_copies $(( mdacp * 5 )) vgremove -f $vg - echo vgcreate succeeds with --vgmetadatacopies unmanaged - vgcreate --vgmetadatacopies unmanaged $vg "$dev1" "$dev2" + echo vgcreate $SHARED succeeds with --vgmetadatacopies unmanaged + vgcreate $SHARED --vgmetadatacopies unmanaged $vg "$dev1" "$dev2" check vg_field $vg vg_mda_copies unmanaged vgremove -f $vg pvunignore_ "$dev1" pvunignore_ "$dev2" pvunignore_ "$dev4" pvunignore_ "$dev5" - echo vgcreate succeds with small value of --metadatacopies, ignores mdas - vgcreate --vgmetadatacopies 1 $vg "$dev1" "$dev2" "$dev4" "$dev5" + echo vgcreate $SHARED succeds with small value of --metadatacopies, ignores mdas + vgcreate $SHARED --vgmetadatacopies 1 $vg "$dev1" "$dev2" "$dev4" "$dev5" check vg_field $vg vg_mda_copies 1 check vg_field $vg vg_mda_count $(( mdacp * 4 )) check vg_field $vg vg_mda_used_count 1 @@ -131,11 +130,11 @@ for mdacp in 1 2; do check vg_field $vg vg_mda_count $(( mdacp * 4 )) check vg_field $vg vg_mda_copies unmanaged check vg_field $vg vg_mda_used_count $(( mdacp * 4 )) - echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate + echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate $SHARED vgchange --vgmetadatacopies 0 $vg check vg_field $vg vg_mda_copies unmanaged vgremove -f $vg - vgcreate --vgmetadatacopies 0 $vg "$dev1" "$dev2" "$dev4" "$dev5" + vgcreate $SHARED --vgmetadatacopies 0 $vg "$dev1" "$dev2" "$dev4" "$dev5" check vg_field $vg vg_mda_copies unmanaged vgremove -f $vg done @@ -145,7 +144,7 @@ for mdacp in 1 2; do pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev4" "$dev5" pvcreate --metadatacopies 0 "$dev3" echo Set a large value of vgmetadatacopies - vgcreate --vgmetadatacopies $(( mdacp * 5 )) $vg "$dev1" "$dev2" "$dev3" + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 5 )) $vg "$dev1" "$dev2" "$dev3" check vg_field $vg vg_mda_copies $(( mdacp * 5 )) echo Ignore mdas on devices to be used for vgextend echo Large value of vgetadatacopies should automatically un-ignore mdas @@ -156,7 +155,7 @@ for mdacp in 1 2; do check pv_field "$dev5" pv_mda_used_count $mdacp vgremove -f $vg echo Set a small value of vgmetadatacopies - vgcreate --vgmetadatacopies $(( mdacp * 1 )) $vg "$dev1" "$dev2" "$dev3" + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg "$dev1" "$dev2" "$dev3" check vg_field $vg vg_mda_copies $(( mdacp * 1 )) echo Ignore mdas on devices to be used for vgextend echo Small value of vgetadatacopies should leave mdas as ignored @@ -186,11 +185,15 @@ for mdacp in 1 2; do vgremove -f $vg done +if test -n "$LVM_TEST_LVMLOCKD"; then +echo skip vgsplit and vgmerge with lvmlockd +else + echo Test special situations, vgsplit, vgmerge, etc for mdacp in 1 2; do pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" - vgcreate --vgmetadatacopies 2 $vg1 "$dev1" "$dev2" "$dev3" - vgcreate --vgmetadatacopies $(( mdacp * 1 )) $vg2 "$dev4" "$dev5" + vgcreate $SHARED --vgmetadatacopies 2 $vg1 "$dev1" "$dev2" "$dev3" + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg2 "$dev4" "$dev5" echo vgsplit/vgmerge preserves value of metadata copies check vg_field $vg1 vg_mda_copies 2 check vg_field $vg2 vg_mda_copies $(( mdacp * 1 )) @@ -207,10 +210,12 @@ for mdacp in 1 2; do vgremove -f $vg1 $vg2 done +fi + echo Test combination of --vgmetadatacopies and pvchange --metadataignore for mdacp in 1 2; do pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" - vgcreate --vgmetadatacopies $(( mdacp * 1 )) $vg1 "$dev1" "$dev2" + vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg1 "$dev1" "$dev2" check vg_field $vg1 vg_mda_copies $(( mdacp * 1 )) check vg_field $vg1 vg_mda_used_count $(( mdacp * 1 )) pvignore_ "$dev3" From b9c1cef8176ad127e682e40b1508816b23c9a989 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 15:35:48 -0500 Subject: [PATCH 76/81] lvmlockd: fix reverting new lv in error path The wrong name was being used to free the LV lock in lvmlockd in the error exit path. --- lib/metadata/lv_manip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index c1bba03db..c5e63a923 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -8010,7 +8010,7 @@ deactivate_and_revert_new_lv: revert_new_lv: lockd_lv(cmd, lv, "un", LDLV_PERSISTENT); - lockd_free_lv(vg->cmd, vg, lp->lv_name, &lv->lvid.id[1], lv->lock_args); + lockd_free_lv(vg->cmd, vg, lv->name, &lv->lvid.id[1], lv->lock_args); /* FIXME Better to revert to backup of metadata? */ if (!lv_remove(lv) || !vg_write(vg) || !vg_commit(vg)) From caa600a409fe811a25f2d784daeb6780ea977614 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 15:37:25 -0500 Subject: [PATCH 77/81] tests: enable lvcreate-pvtags with lvmlockd --- test/shell/lvcreate-pvtags.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/shell/lvcreate-pvtags.sh b/test/shell/lvcreate-pvtags.sh index 893b3ef48..b794c450a 100644 --- a/test/shell/lvcreate-pvtags.sh +++ b/test/shell/lvcreate-pvtags.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -24,7 +23,7 @@ aux lvmconf 'allocation/maximise_cling = 0' \ # not required, just testing aux pvcreate --metadatacopies 0 "$dev1" -vgcreate "$vg" "${DEVICES[@]}" +vgcreate $SHARED "$vg" "${DEVICES[@]}" pvchange --addtag fast "${DEVICES[@]}" # 3 stripes with 3 PVs (selected by tag, @fast) is fine From 06b2e5c176b7a371efa62b27af2acb1e6f7984be Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 15:52:23 -0500 Subject: [PATCH 78/81] lvmlockd: improve error message for existing lockspace When a VG/lockspace already exists with the same name don't just print the error number. --- lib/locking/lvmlockd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index 0af2b3872..24a46e792 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -548,6 +548,9 @@ static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg) case -EPROTONOSUPPORT: log_error("VG %s init failed: lock manager dlm is not supported by lvmlockd", vg->name); break; + case -EEXIST: + log_error("VG %s init failed: a lockspace with the same name exists", vg->name); + break; default: log_error("VG %s init failed: %d", vg->name, result); } @@ -671,6 +674,9 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in case -EMSGSIZE: log_error("VG %s init failed: no disk space for leases", vg->name); break; + case -EEXIST: + log_error("VG %s init failed: a lockspace with the same name exists", vg->name); + break; default: log_error("VG %s init failed: %d", vg->name, result); } From 00f6a8466edfc386067efb1e000a808080966076 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 15:55:18 -0500 Subject: [PATCH 79/81] tests: enable more working tests with lvmlockd --- test/shell/lvconvert-repair-cache.sh | 1 - test/shell/lvconvert-repair.sh | 8 +++++--- test/shell/lvcreate-repair.sh | 5 ++--- test/shell/lvextend-snapshot-dmeventd.sh | 1 - test/shell/mdata-strings.sh | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/shell/lvconvert-repair-cache.sh b/test/shell/lvconvert-repair-cache.sh index 6afb7ea3b..348dbaf31 100644 --- a/test/shell/lvconvert-repair-cache.sh +++ b/test/shell/lvconvert-repair-cache.sh @@ -12,7 +12,6 @@ # Test repairing of broken cached LV -SKIP_WITH_LVMPOLLD=1 SKIP_WITH_LVMLOCKD=1 . lib/inittest diff --git a/test/shell/lvconvert-repair.sh b/test/shell/lvconvert-repair.sh index b5ae20623..9ee7980a5 100644 --- a/test/shell/lvconvert-repair.sh +++ b/test/shell/lvconvert-repair.sh @@ -10,14 +10,12 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 - . lib/inittest recreate_vg_() { vgremove -ff $vg - vgcreate "$vg" "$@" "${DEVICES[@]}" + vgcreate $SHARED "$vg" "$@" "${DEVICES[@]}" } _check_mlog() @@ -70,7 +68,11 @@ vgreduce --removemissing $vg aux enable_dev "$dev4" # 3-way, mirrored log => 3-way, core log +if test -n "$LVM_TEST_LVMLOCKD"; then +recreate_vg_ +else recreate_vg_ -c n +fi lvcreate -aey --type mirror -m 2 --mirrorlog mirrored --ignoremonitoring -L 1 -n 3way $vg \ "$dev1" "$dev2" "$dev3" "$dev4":0 "$dev5":0 aux disable_dev "$dev4" "$dev5" diff --git a/test/shell/lvcreate-repair.sh b/test/shell/lvcreate-repair.sh index 5e02e7ff5..cff001827 100644 --- a/test/shell/lvcreate-repair.sh +++ b/test/shell/lvcreate-repair.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -23,7 +22,7 @@ for i in "$dev1" "$dev2" "$dev3" ; do if test "$i" = "$j" ; then continue ; fi vgremove -ff $vg - vgcreate $vg "$dev1" "$dev2" "$dev3" + vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" # exit 1 lvcreate -l1 -n $lv1 $vg "$dev1" @@ -49,7 +48,7 @@ for i in "$dev1" "$dev2" "$dev3" ; do done vgremove -ff $vg -vgcreate $vg "$dev1" "$dev2" "$dev3" +vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" # use tricky 'dd' for i in "$dev1" "$dev2" "$dev3" ; do diff --git a/test/shell/lvextend-snapshot-dmeventd.sh b/test/shell/lvextend-snapshot-dmeventd.sh index 0f9b0a902..01fc843ed 100644 --- a/test/shell/lvextend-snapshot-dmeventd.sh +++ b/test/shell/lvextend-snapshot-dmeventd.sh @@ -10,7 +10,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/mdata-strings.sh b/test/shell/mdata-strings.sh index 4fcb89cea..c87cd75ae 100644 --- a/test/shell/mdata-strings.sh +++ b/test/shell/mdata-strings.sh @@ -12,7 +12,6 @@ # 'Test for proper escaping of strings in metadata (bz431474)' -SKIP_WITH_LVMLOCKD=1 SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -42,7 +41,7 @@ pvcreate "$dev1" || created="$dev2" pvdisplay 2>&1 | tee err should grep -F "$pv_ugly" err should check pv_field "$dev1" pv_name "$dev1" -vgcreate $vg "$created" +vgcreate $SHARED $vg "$created" # 'no parse errors and VG really exists' vgs $vg 2>err not grep "Parse error" err From 885eb2024ffff6757bba39666a1d334d6d72a066 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 16:18:53 -0500 Subject: [PATCH 80/81] tests: enable non-working tests with lvmlockd Those that are failing for reasons other than lvmlockd restrictions. --- test/shell/component-thin.sh | 2 +- test/shell/lvconvert-raid-allocation.sh | 4 ++-- test/shell/lvconvert-raid-reshape-load.sh | 4 ++-- test/shell/lvconvert-raid-reshape-stripes-load-fail.sh | 4 ++-- test/shell/lvconvert-raid-reshape-stripes-load-reload.sh | 4 ++-- test/shell/lvconvert-raid-reshape-stripes-load.sh | 4 ++-- test/shell/lvconvert-raid-reshape.sh | 4 ++-- test/shell/lvconvert-raid-status-validation.sh | 4 ++-- test/shell/lvconvert-raid5_to_raid10.sh | 2 +- test/shell/lvcreate-large-raid.sh | 4 ++-- test/shell/mirror-names.sh | 2 +- test/shell/pvcreate-md-fake-hdr.sh | 4 ++-- test/shell/pvcreate-operation-md.sh | 2 +- test/shell/thin-large.sh | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/shell/component-thin.sh b/test/shell/component-thin.sh index 4b1a35bfc..3cf02f37d 100644 --- a/test/shell/component-thin.sh +++ b/test/shell/component-thin.sh @@ -12,7 +12,7 @@ # Exercise activation of thin component devices -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvconvert-raid-allocation.sh b/test/shell/lvconvert-raid-allocation.sh index 75298009c..acdae0caa 100644 --- a/test/shell/lvconvert-raid-allocation.sh +++ b/test/shell/lvconvert-raid-allocation.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -20,7 +20,7 @@ aux have_raid 1 3 0 || skip aux prepare_pvs 5 get_devs -vgcreate -s 256k "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 256k "$vg" "${DEVICES[@]}" # Start with linear on 2 PV and ensure that converting to # RAID is not allowed to reuse PVs for different images. (Bug 1113180) diff --git a/test/shell/lvconvert-raid-reshape-load.sh b/test/shell/lvconvert-raid-reshape-load.sh index cd72d09ee..11af24def 100644 --- a/test/shell/lvconvert-raid-reshape-load.sh +++ b/test/shell/lvconvert-raid-reshape-load.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -35,7 +35,7 @@ aux prepare_pvs 16 32 get_devs -vgcreate -s 1M "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}" trap 'cleanup_mounted_and_teardown' EXIT diff --git a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh index 88722b01e..feaf1e2b4 100644 --- a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh +++ b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -35,7 +35,7 @@ aux prepare_pvs 16 32 get_devs -vgcreate -s 1M "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}" trap 'cleanup_mounted_and_teardown' EXIT diff --git a/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh b/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh index fc463bf84..839e7048f 100644 --- a/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh +++ b/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -35,7 +35,7 @@ aux prepare_pvs 16 32 get_devs -vgcreate -s 1M "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}" trap 'cleanup_mounted_and_teardown' EXIT diff --git a/test/shell/lvconvert-raid-reshape-stripes-load.sh b/test/shell/lvconvert-raid-reshape-stripes-load.sh index 1be8d613f..29790aace 100644 --- a/test/shell/lvconvert-raid-reshape-stripes-load.sh +++ b/test/shell/lvconvert-raid-reshape-stripes-load.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -35,7 +35,7 @@ aux prepare_pvs 16 32 get_devs -vgcreate -s 1M "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}" trap 'cleanup_mounted_and_teardown' EXIT diff --git a/test/shell/lvconvert-raid-reshape.sh b/test/shell/lvconvert-raid-reshape.sh index e62131891..ab3ea4e72 100644 --- a/test/shell/lvconvert-raid-reshape.sh +++ b/test/shell/lvconvert-raid-reshape.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 LVM_SKIP_LARGE_TESTS=0 @@ -34,7 +34,7 @@ fi get_devs -vgcreate -s 1M "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}" function _lvcreate { diff --git a/test/shell/lvconvert-raid-status-validation.sh b/test/shell/lvconvert-raid-status-validation.sh index 3e91d23be..c5396d7ee 100644 --- a/test/shell/lvconvert-raid-status-validation.sh +++ b/test/shell/lvconvert-raid-status-validation.sh @@ -15,7 +15,7 @@ # 'dmsetup status' for RAID LVs - especially during various sync action # transitions, like: recover, resync, check, repair, idle, reshape, etc ####################################################################### -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 export LVM_TEST_LVMETAD_DEBUG_OPTS=${LVM_TEST_LVMETAD_DEBUG_OPTS-} @@ -33,7 +33,7 @@ aux have_raid 1 13 0 || skip aux prepare_pvs 9 get_devs -vgcreate -s 2m "$vg" "${DEVICES[@]}" +vgcreate $SHARED -s 2m "$vg" "${DEVICES[@]}" ########################################### # Upconverted RAID1 should never have all 'a's in status output diff --git a/test/shell/lvconvert-raid5_to_raid10.sh b/test/shell/lvconvert-raid5_to_raid10.sh index cc0e4684a..e38e4d3f7 100644 --- a/test/shell/lvconvert-raid5_to_raid10.sh +++ b/test/shell/lvconvert-raid5_to_raid10.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/lvcreate-large-raid.sh b/test/shell/lvcreate-large-raid.sh index 3488db40b..b66cfd26e 100644 --- a/test/shell/lvcreate-large-raid.sh +++ b/test/shell/lvcreate-large-raid.sh @@ -12,7 +12,7 @@ # 'Exercise some lvcreate diagnostics' -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -31,7 +31,7 @@ aux have_raid4 && segtypes="raid4 raid5" aux prepare_pvs 5 1000000000 get_devs -vgcreate "$vg1" "${DEVICES[@]}" +vgcreate $SHARED "$vg1" "${DEVICES[@]}" aux lvmconf 'devices/issue_discards = 1' diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh index a3bc80fc9..54d42e188 100644 --- a/test/shell/mirror-names.sh +++ b/test/shell/mirror-names.sh @@ -13,7 +13,7 @@ test_description="check namings of mirrored LV" -SKIP_WITH_LVMLOCKD=1 + . lib/inittest diff --git a/test/shell/pvcreate-md-fake-hdr.sh b/test/shell/pvcreate-md-fake-hdr.sh index 50a5b1495..b89fe4377 100644 --- a/test/shell/pvcreate-md-fake-hdr.sh +++ b/test/shell/pvcreate-md-fake-hdr.sh @@ -12,7 +12,7 @@ # TODO: once code get fixed, add matching 'check' calls -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest @@ -25,7 +25,7 @@ aux extend_filter_LVMTEST "a|/dev/md|" aux prepare_devs 4 -vgcreate $vg "$dev3" "$dev4" +vgcreate $SHARED $vg "$dev3" "$dev4" # create 2 disk MD raid1 array # by default using metadata format 1.0 with data at the end of device diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh index f5347850e..11f08877f 100644 --- a/test/shell/pvcreate-operation-md.sh +++ b/test/shell/pvcreate-operation-md.sh @@ -10,7 +10,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest diff --git a/test/shell/thin-large.sh b/test/shell/thin-large.sh index b1cf29a15..714f91e03 100644 --- a/test/shell/thin-large.sh +++ b/test/shell/thin-large.sh @@ -12,7 +12,7 @@ # 'Exercise logic around boundary sizes of thin-pool data and chunksize -SKIP_WITH_LVMLOCKD=1 + SKIP_WITH_LVMPOLLD=1 . lib/inittest From 81f07c3cca417bbf8d290073a20586b47a6d127e Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 31 May 2018 16:38:39 -0500 Subject: [PATCH 81/81] man lvmlockd: update list of limitations --- man/lvmlockd.8_main | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main index 90a07c70b..9fe569d6a 100644 --- a/man/lvmlockd.8_main +++ b/man/lvmlockd.8_main @@ -843,12 +843,6 @@ to a lockd VG". Things that do not yet work in lockd VGs: .br \[bu] -creating a new thin pool and a new thin LV in a single command -.br -\[bu] -using lvcreate to create cache pools or cache LVs (use lvconvert) -.br -\[bu] using external origins for thin LVs .br \[bu] @@ -861,10 +855,7 @@ splitting mirrors in sanlock VGs pvmove of entire PVs, or under LVs activated with shared locks .br \[bu] -vgsplit -.br -\[bu] -vgmerge +vgsplit and vgmerge (convert to a local VG to do this) .SS lvmlockd changes from clvmd