main - unit-test: modify for systems with PGSIZE of 64K
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=262008f1ceb050a9eed...
Commit: 262008f1ceb050a9eed64f2fa50b1bc9366b9e75
Parent: 236a45dfc5e0292c99240aaeef42591c77a28549
Author: Wu Guanghao <wuguanghao3(a)huawei.com>
AuthorDate: Tue Feb 23 17:39:29 2021 +0800
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:56:43 2021 +0100
unit-test: modify for systems with PGSIZE of 64K
This modification supports dynamically obtaining the value of PAGE_SIZE,
which is compatible with systems with PAGE_SIZE of (4K/64K)
Signed-off-by: wuguanghao <wuguanghao3(a)huawei.com>
---
test/unit/bcache_t.c | 7 ++++---
test/unit/bcache_utils_t.c | 2 +-
test/unit/io_engine_t.c | 11 +++++++----
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index 9c4d102de..399468ad4 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -360,6 +360,7 @@ static void _large_fixture_exit(void *context)
*--------------------------------------------------------------*/
#define MEG 2048
#define SECTOR_SHIFT 9
+#define PAGE_SIZE_SECTORS (sysconf(_SC_PAGE_SIZE) >> SECTOR_SHIFT)
static void good_create(sector_t block_size, unsigned nr_cache_blocks)
{
@@ -389,12 +390,12 @@ static void bad_create(sector_t block_size, unsigned nr_cache_blocks)
static void test_create(void *fixture)
{
- good_create(8, 16);
+ good_create(PAGE_SIZE_SECTORS, 16);
}
static void test_nr_cache_blocks_must_be_positive(void *fixture)
{
- bad_create(8, 0);
+ bad_create(PAGE_SIZE_SECTORS, 0);
}
static void test_block_size_must_be_positive(void *fixture)
@@ -412,7 +413,7 @@ static void test_block_size_must_be_multiple_of_page_size(void *fixture)
bad_create(_bad_examples[i], 16);
for (i = 1; i < 100; i++)
- good_create(i * 8, 16);
+ good_create(i * PAGE_SIZE_SECTORS, 16);
}
static void test_get_triggers_read(void *context)
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 69c510109..ecc3ebb32 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -26,7 +26,7 @@
//----------------------------------------------------------------
-#define T_BLOCK_SIZE 4096
+#define T_BLOCK_SIZE sysconf(_SC_PAGESIZE)
#define NR_BLOCKS 64
#define INIT_PATTERN 123
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index 349df2586..431cca6d3 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -25,8 +25,11 @@
//----------------------------------------------------------------
+#define SECTOR_SHIFT 9
#define SECTOR_SIZE 512
#define BLOCK_SIZE_SECTORS 8
+#define PAGE_SIZE sysconf(_SC_PAGESIZE)
+#define PAGE_SIZE_SECTORS (PAGE_SIZE >> SECTOR_SHIFT)
#define NR_BLOCKS 64
struct fixture {
@@ -83,7 +86,7 @@ static void *_fix_init(void)
T_ASSERT(f);
f->e = create_async_io_engine();
T_ASSERT(f->e);
- if (posix_memalign((void **) &f->data, 4096, SECTOR_SIZE * BLOCK_SIZE_SECTORS))
+ if (posix_memalign((void **) &f->data, PAGE_SIZE, SECTOR_SIZE * BLOCK_SIZE_SECTORS))
test_fail("posix_memalign failed");
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
@@ -138,7 +141,7 @@ static void _test_read(void *fixture)
{
struct fixture *f = fixture;
struct io io;
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
@@ -156,7 +159,7 @@ static void _test_write(void *fixture)
{
struct fixture *f = fixture;
struct io io;
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
@@ -175,7 +178,7 @@ static void _test_write_bytes(void *fixture)
unsigned offset = 345;
char buf_out[32];
char buf_in[32];
- struct bcache *cache = bcache_create(8, BLOCK_SIZE_SECTORS, f->e);
+ struct bcache *cache = bcache_create(PAGE_SIZE_SECTORS, BLOCK_SIZE_SECTORS, f->e);
T_ASSERT(cache);
f->di = bcache_set_fd(f->fd);
3 years, 2 months
main - toollib: preserve return code 5
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=236a45dfc5e0292c992...
Commit: 236a45dfc5e0292c99240aaeef42591c77a28549
Parent: 4bbaff1fa621353d0d2adbbf86dd26284b8a11e3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 11 00:54:32 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:56:43 2021 +0100
toollib: preserve return code 5
---
tools/toollib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/toollib.c b/tools/toollib.c
index a8bda8bcd..67fbbdaa0 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4463,6 +4463,7 @@ int process_each_pv(struct cmd_context *cmd,
ret_max = ret;
if (ret_max == ECMD_FAILED)
goto_out;
+ ret_max = ECMD_FAILED; /* but ATM we've returned FAILED for all cases */
}
ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids, &all_devices,
3 years, 2 months
main - tests: settle after wiping
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4bbaff1fa621353d0d2...
Commit: 4bbaff1fa621353d0d2adbbf86dd26284b8a11e3
Parent: 2cbe88d6a1e9e6f637ee1b5ccdc7b78712d46998
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 23:36:03 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
tests: settle after wiping
Add call to settle after wiping device so there is reduced
change to meet watch rule race during tests.
---
test/lib/aux.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 0e10a06dd..2e6191d70 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -837,6 +837,7 @@ wipefs_a() {
lvmdevices --adddev $dev || true
fi
+ udev_wait
}
prepare_backing_dev() {
3 years, 2 months
main - debug: display_lvname
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2cbe88d6a1e9e6f637e...
Commit: 2cbe88d6a1e9e6f637ee1b5ccdc7b78712d46998
Parent: a654148b76c71022997c3ea509b52354985b8d7f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 22:05:10 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
debug: display_lvname
---
tools/toollib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index f60847b48..a8bda8bcd 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3074,7 +3074,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!process_lv)
continue;
- log_very_verbose("Adding %s/%s to the list of LVs to be processed.", vg->name, lvl->lv->name);
+ log_very_verbose("Adding %s to the list of LVs to be processed.", display_lvname(lvl->lv));
if (!(final_lvl = dm_pool_zalloc(cmd->mem, sizeof(struct lv_list)))) {
log_error("Failed to allocate final LV list item.");
3 years, 2 months
main - gcc: adding const
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a654148b76c71022997...
Commit: a654148b76c71022997c3ea509b52354985b8d7f
Parent: d7bb23dd156cd059500e32a4f3966d3d1be52225
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 21:58:57 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
gcc: adding const
---
lib/metadata/metadata.c | 2 +-
lib/metadata/metadata.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 71e59207d..ed1c05f75 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1659,7 +1659,7 @@ struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
return NULL;
}
-struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg,
+struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
const union lvid *lvid)
{
struct lv_list *lvl;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index c6500d488..3ea77ce2e 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -393,7 +393,7 @@ uint32_t vg_bad_status_bits(const struct volume_group *vg, uint64_t status);
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
struct physical_volume *pv, int new_pv);
-struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg,
+struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
const union lvid *lvid);
struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
3 years, 2 months
main - cov: initialize value
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d7bb23dd156cd059500...
Commit: d7bb23dd156cd059500e32a4f3966d3d1be52225
Parent: 23afad824715f941ebeccc2c12aec75fc241b984
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 15:53:58 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
cov: initialize value
Coverity can't understand conditions together, so just keep it quiet.
---
lib/mm/memlock.c | 2 +-
tools/command.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 0c05038fe..1e6cedc5f 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -551,7 +551,7 @@ static void _lock_mem(struct cmd_context *cmd)
static void _unlock_mem(struct cmd_context *cmd)
{
- size_t unlock_mstats;
+ size_t unlock_mstats = 0;
log_very_verbose("Unlocking memory");
diff --git a/tools/command.c b/tools/command.c
index 81720acf1..bb707d66f 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -3595,7 +3595,7 @@ static void _print_man_secondary(char *name)
int main(int argc, char *argv[])
{
- struct cmd_context cmdtool;
+ struct cmd_context cmdtool = { 0 };
char *cmdname = NULL;
char *desfile = NULL;
char *stdout_buf;
3 years, 2 months
main - cleanup: use already set vg_complete
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=23afad824715f941ebe...
Commit: 23afad824715f941ebeccc2c12aec75fc241b984
Parent: c4f5d9312283b5a096c99d4ccd28b89cbf89b1e7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 14:16:42 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
cleanup: use already set vg_complete
Already set to 0.
---
tools/pvscan.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 8bcfe311c..22cb7bc18 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1351,14 +1351,11 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
}
if (pvs_unknown) {
- log_print("pvscan[%d] PV %s online, VG unknown.", getpid(), dev_name(dev));
- vg_complete = 0;
-
+ log_print("pvscan[%d] PV %s online, VG unknown.",
+ getpid(), dev_name(dev));
} else if (pvs_offline) {
log_print("pvscan[%d] PV %s online, VG %s incomplete (need %d).",
getpid(), dev_name(dev), vgname, pvs_offline);
- vg_complete = 0;
-
} else {
log_print("pvscan[%d] PV %s online, VG %s is complete.", getpid(), dev_name(dev), vgname);
if (!str_list_add(cmd->mem, complete_vgnames, dm_pool_strdup(cmd->mem, vgname)))
3 years, 2 months
main - cleanup: eliminate unused assign
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c4f5d9312283b5a096c...
Commit: c4f5d9312283b5a096c99d4ccd28b89cbf89b1e7
Parent: d86e943b80a94427bc2cd9deed151dd84c74ffbe
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 14:12:17 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
cleanup: eliminate unused assign
---
lib/datastruct/str_list.c | 2 +-
lib/metadata/raid_manip.c | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index efbdeda64..b8b340307 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -218,7 +218,7 @@ struct dm_list *str_to_str_list(struct dm_pool *mem, const char *str,
return NULL;
}
- p1 = p2 = str;
+ p1 = str;
while (*p1) {
if (!(p2 = strstr(p1, delim)))
next = p2 = str + strlen(str);
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 9c57e8b88..a43e36141 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -584,18 +584,18 @@ static int _lv_update_reload_fns_reset_eliminate_lvs(struct logical_volume *lv,
* Returning 2 from pre function -> lv is suspended and
* metadata got updated, don't need to do it again
*/
- if (!(r = (origin_only ? resume_lv_origin(lv->vg->cmd, lock_lv) :
- resume_lv(lv->vg->cmd, lock_lv)))) {
+ if (!(origin_only ? resume_lv_origin(lv->vg->cmd, lock_lv) :
+ resume_lv(lv->vg->cmd, lock_lv))) {
log_error("Failed to resume %s.", display_lvname(lv));
return 0;
}
/* Update metadata and reload mappings including flags (e.g. LV_REBUILD, LV_RESHAPE_DELTA_DISKS_PLUS) */
- } else if (!(r = (origin_only ? lv_update_and_reload_origin(lv) : lv_update_and_reload(lv))))
+ } else if (!(origin_only ? lv_update_and_reload_origin(lv) : lv_update_and_reload(lv)))
return_0;
/* Eliminate any residual LV and don't commit the metadata */
- if (!(r = _eliminate_extracted_lvs_optional_write_vg(lv->vg, removal_lvs, 0)))
+ if (!_eliminate_extracted_lvs_optional_write_vg(lv->vg, removal_lvs, 0))
return_0;
/*
@@ -620,7 +620,7 @@ static int _lv_update_reload_fns_reset_eliminate_lvs(struct logical_volume *lv,
/* Update and reload to clear out reset flags in the metadata and in the kernel */
log_debug_metadata("Updating metadata mappings for %s.", display_lvname(lv));
if ((r != 2 || flags_reset) &&
- !(r = (origin_only ? lv_update_and_reload_origin(lv) : lv_update_and_reload(lv))))
+ !(origin_only ? lv_update_and_reload_origin(lv) : lv_update_and_reload(lv)))
return_0;
return 1;
3 years, 2 months
main - toollib: use EINIT_FAILED for missing devs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d86e943b80a94427bc2...
Commit: d86e943b80a94427bc2cd9deed151dd84c74ffbe
Parent: f4543aca15743eafdc03b4ad92084ef7343f904d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 14:37:19 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
toollib: use EINIT_FAILED for missing devs
There is really no practical reason to continue running
when we fail on allocation.
It seems we may need further fine frained errors, as for
some error type we simply need to exit ASAP, while
others may still produce usable results.
---
tools/toollib.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index de51632a6..f60847b48 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3853,7 +3853,7 @@ static int _get_arg_devices(struct cmd_context *cmd,
if (!(dil->dev = dev_cache_get(cmd, sl->str, cmd->filter))) {
log_error("Cannot use %s: %s", sl->str, devname_error_reason(sl->str));
- ret_max = ECMD_FAILED;
+ ret_max = EINIT_FAILED;
} else {
strncpy(dil->pvid, dil->dev->pvid, ID_LEN);
dm_list_add(arg_devices, &dil->list);
@@ -4458,9 +4458,12 @@ int process_each_pv(struct cmd_context *cmd,
goto_out;
}
- if ((ret = _get_arg_devices(cmd, &arg_pvnames, &arg_devices)) != ECMD_PROCESSED)
- /* get_arg_devices reports the error for any PV names not found. */
- ret_max = ECMD_FAILED;
+ if ((ret = _get_arg_devices(cmd, &arg_pvnames, &arg_devices)) != ECMD_PROCESSED) {
+ /* get_arg_devices reports EINIT_FAILED for any PV names not found. */
+ ret_max = ret;
+ if (ret_max == ECMD_FAILED)
+ goto_out;
+ }
ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids, &all_devices,
&arg_devices, &arg_tags,
3 years, 2 months
main - lvremove: support faster removal of thin-pools
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f4543aca15743eafdc0...
Commit: f4543aca15743eafdc03b4ad92084ef7343f904d
Parent: dac827470195f46393522b20ef5678136f72126b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 23:19:25 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
lvremove: support faster removal of thin-pools
When lvremove/vgremove removes thin volumes with its thin-pool as well,
try to skip any updates of such thin-pool, so when everything properly
deactivates, there is no message send to this thin-pool and whole
thin-pool is removed with a single commit.
---
lib/metadata/lv.h | 1 +
lib/metadata/lv_manip.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 28bd4b869..304ee2f7d 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -57,6 +57,7 @@ struct logical_volume {
uint64_t timestamp;
unsigned new_lock_args:1;
+ unsigned to_remove:1; /* set when LV is known to be removed */
const char *hostname;
const char *lock_args;
};
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 74a34c9cd..4114e7d5c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6589,6 +6589,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
lock_lv = pool_lv;
+ if (pool_lv->to_remove)
+ /* Thin pool is to be removed so skip updating it when possible */
+ pool_lv = NULL;
}
if (lv_is_locked(lv)) {
@@ -6823,6 +6826,11 @@ static int _lv_remove_segs_using_this_lv(struct cmd_context *cmd, struct logical
log_error("Logical volume \"%s\" not removed.", lv->name);
return 0;
}
+
+ /* Make aware users of this LV, it's going to be removed, so they
+ * can skip any updates of itself */
+ lv->to_remove = 1;
+
/*
* Not using _safe iterator here - since we may delete whole subtree
* (similar as process_each_lv_in_vg())
3 years, 2 months