main - config: correct option name
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ff712987a5792cfc3fb...
Commit: ff712987a5792cfc3fba03889ec4485294386a03
Parent: b4dfe026dd38a3d84de48664f357828f05b36da2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 13 20:35:16 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:59:24 2021 +0100
config: correct option name
---
conf/example.conf.in | 2 +-
lib/config/config_settings.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 204ec82d1..215a30f86 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1335,7 +1335,7 @@ activation {
# Configuration option activation/udev_sync.
# Use udev notifications to synchronize udev and LVM.
- # The --nodevsync option overrides this setting.
+ # The --noudevsync option overrides this setting.
# When disabled, LVM commands will not wait for notifications from
# udev, but continue irrespective of any possible udev processing in
# the background. Only use this if udev is not running or has rules
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index fac5d6317..3000a4be1 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1323,7 +1323,7 @@ cfg(global_io_memory_size_CFG, "io_memory_size", global_CFG_SECTION, CFG_DEFAULT
cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL, 0, NULL,
"Use udev notifications to synchronize udev and LVM.\n"
- "The --nodevsync option overrides this setting.\n"
+ "The --noudevsync option overrides this setting.\n"
"When disabled, LVM commands will not wait for notifications from\n"
"udev, but continue irrespective of any possible udev processing in\n"
"the background. Only use this if udev is not running or has rules\n"
3 years, 2 months
main - config: keep issue_discards in config struct
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b4dfe026dd38a3d84de...
Commit: b4dfe026dd38a3d84de48664f357828f05b36da2
Parent: fab9987ad73d1de55f21f71fed065525aa4cf4d5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 13 18:33:55 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:59:24 2021 +0100
config: keep issue_discards in config struct
Avoid quering for this config option and keep it for removing in struct.
Also drop unused cache_vgmetadata variable.
---
lib/commands/toolcontext.c | 2 ++
lib/commands/toolcontext.h | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c3de18d7f..92008a641 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -661,6 +661,8 @@ static int _process_config(struct cmd_context *cmd)
*/
cmd->default_settings.udev_fallback = udev_disabled ? 1 : -1;
+ cmd->default_settings.issue_discards = find_config_tree_bool(cmd, devices_issue_discards_CFG, NULL);
+
init_retry_deactivation(find_config_tree_bool(cmd, activation_retry_deactivation_CFG, NULL));
init_activation_checks(find_config_tree_bool(cmd, activation_checks_CFG, NULL));
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 977b31412..a47b7d760 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -39,7 +39,7 @@ struct config_info {
int udev_rules;
int udev_sync;
int udev_fallback;
- int cache_vgmetadata;
+ int issue_discards;
const char *msg_prefix;
const char *fmt_name;
const char *dmeventd_executable;
3 years, 2 months
main - cleanup: move common condition
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fab9987ad73d1de55f2...
Commit: fab9987ad73d1de55f21f71fed065525aa4cf4d5
Parent: b563c926ba348be14988889a581c81ca09ca66e0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 14 13:15:24 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
cleanup: move common condition
---
lib/metadata/lv_manip.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9b1eefe60..ec8704ce7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6834,12 +6834,12 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
struct lv_list *lvl;
struct logical_volume *origin;
- if (lv_is_cow(lv)) {
+ if (!level && lv_is_cow(lv)) {
/*
* A merging snapshot cannot be removed directly unless
* it has been invalidated or failed merge removal is requested.
*/
- if (lv_is_merging_cow(lv) && !level) {
+ if (lv_is_merging_cow(lv)) {
if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
info.exists && info.live_table) {
if (!lv_snapshot_percent(lv, &snap_percent)) {
@@ -6864,7 +6864,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
display_lvname(origin_from_cow(lv))) == 'n')
goto no_remove;
}
- } else if (!level && lv_is_virtual_origin(origin = origin_from_cow(lv)))
+ } else if (lv_is_virtual_origin(origin = origin_from_cow(lv)))
/* If this is a sparse device, remove its origin too. */
/* Stacking is not supported */
lv = origin;
3 years, 2 months
main - cleanup: simplify
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b563c926ba348be1498...
Commit: b563c926ba348be14988889a581c81ca09ca66e0
Parent: 664d3b0f226ffbbf064157885d7d4f8c0aed49cf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 12 13:25:42 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
cleanup: simplify
---
tools/lvconvert.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4c159b01e..b50074294 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4958,7 +4958,7 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
struct logical_volume *lv_main = NULL;
struct logical_volume *lv_fast = NULL;
struct lv_segment *seg;
- int ret;
+ int ret = 0;
if (lv_is_writecache(lv)) {
lv_main = lv;
@@ -5031,10 +5031,8 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
display_lvname(lv), display_lvname(lv_fast));
- } else {
+ } else
log_error(INTERNAL_ERROR "Unknown cache split command.");
- ret = 0;
- }
} else if (lv_is_cache(lv_main) && lv_is_cache_pool(lv_fast)) {
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
@@ -5043,14 +5041,10 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
ret = _lvconvert_split_and_keep_cachepool(cmd, lv_main, lv_fast);
- else {
+ else
log_error(INTERNAL_ERROR "Unknown cache split command.");
- ret = 0;
- }
- } else {
+ } else
log_error(INTERNAL_ERROR "Unknown cache split command.");
- ret = 0;
- }
if (!ret)
return ECMD_FAILED;
3 years, 2 months
main - lvremove: drop flushing dm cache before remove
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=664d3b0f226ffbbf064...
Commit: 664d3b0f226ffbbf064157885d7d4f8c0aed49cf
Parent: 5141a510bdfbf1ac8a64cc7ffd8c292c0c4b7a60
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 11 13:29:37 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
lvremove: drop flushing dm cache before remove
Since cached LV is going to be removed together with its cache,
there is not much to gain if we try to flush cache first.
User may use 'vgcfgrestore' to get back origin + cache.
Assuming user is not using issue_discards.
When data are discarded after remove there is nothing to restore!
This change allows to futher reduce number of commits
during lvremove/vgremove.
---
lib/metadata/lv_manip.c | 25 -------------------------
1 file changed, 25 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2c77bacc2..9b1eefe60 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6663,31 +6663,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (lv_is_cache(lv) && !lv_is_pending_delete(lv)) {
- /* Handles both cachepool & cachevol based cached LVs.
- * It's placed before deactivation, so it can try to uncache
- * 'active' LV if possible
- */
- struct logical_volume *cachevol_lv = first_seg(lv)->pool_lv;
-
- if (!archive(vg))
- return_0;
-
- if (!lv_cache_remove(lv))
- return_0;
-
- if (!lv_remove_single(cmd, cachevol_lv, force,
- suppress_remove_message)) {
- if (force < DONT_PROMPT_OVERRIDE) {
- log_error("Failed to uncache %s.", display_lvname(lv));
- return 0;
- }
- /* Proceed with -ff */
- log_print_unless_silent("Ignoring uncache failure of %s.",
- display_lvname(lv));
- }
- }
-
/* Used cache pool, COW or historical LV cannot be activated */
if (!lv_is_used_cache_pool(lv) &&
!lv_is_cache_vol(lv) &&
3 years, 2 months
main - lv_info: missing check for info.exists
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5141a510bdfbf1ac8a6...
Commit: 5141a510bdfbf1ac8a64cc7ffd8c292c0c4b7a60
Parent: 3608e8aee74a5c771b96d768e6c32edc728dbca0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 11 20:38:51 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
lv_info: missing check for info.exists
When &info is passed in, user needs to check for exists.
When there is NULL, return value includes check for exists.
---
lib/mirror/mirrored.c | 4 ++--
lib/raid/raid.c | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 64b470a98..83f1bffcb 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -212,7 +212,7 @@ static int _mirrored_transient_status(struct dm_pool *mem, struct lv_segment *se
if (!strcmp(sm->log_type, "disk")) {
log = first_seg(lv)->log_lv;
- if (!lv_info(lv->vg->cmd, log, 0, &info, 0, 0)) {
+ if (!lv_info(lv->vg->cmd, log, 0, &info, 0, 0) || !info.exists) {
log_error("Check for existence of mirror log %s failed.",
display_lvname(log));
goto out;
@@ -235,7 +235,7 @@ static int _mirrored_transient_status(struct dm_pool *mem, struct lv_segment *se
}
for (i = 0; i < seg->area_count; ++i) {
- if (!lv_info(lv->vg->cmd, seg_lv(seg, i), 0, &info, 0, 0)) {
+ if (!lv_info(lv->vg->cmd, seg_lv(seg, i), 0, &info, 0, 0) || !info.exists) {
log_error("Check for existence of mirror image %s failed.",
seg_lv(seg, i)->name);
goto out;
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index a0f00637a..4bb21d758 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -402,7 +402,6 @@ static int _raid_transient_status(struct dm_pool *mem,
{
int failed = 0, r = 0;
unsigned i;
- struct lvinfo info;
struct logical_volume *lv;
struct dm_status_raid *sr;
@@ -421,7 +420,7 @@ static int _raid_transient_status(struct dm_pool *mem,
if (seg->meta_areas)
for (i = 0; i < seg->area_count; ++i) {
lv = seg_metalv(seg, i);
- if (!lv_info(lv->vg->cmd, lv, 0, &info, 0, 0)) {
+ if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0)) {
log_error("Check for existence of raid meta %s failed.",
display_lvname(lv));
goto out;
@@ -430,7 +429,7 @@ static int _raid_transient_status(struct dm_pool *mem,
for (i = 0; i < seg->area_count; ++i) {
lv = seg_lv(seg, i);
- if (!lv_info(lv->vg->cmd, lv, 0, &info, 0, 0)) {
+ if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0)) {
log_error("Check for existence of raid image %s failed.",
display_lvname(lv));
goto out;
3 years, 2 months
main - cache: use interruptible_usleep
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3608e8aee74a5c771b9...
Commit: 3608e8aee74a5c771b96d768e6c32edc728dbca0
Parent: a3bb8f2ec195fcfbea599d6efa784cb5cbd39741
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 12 13:07:05 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
cache: use interruptible_usleep
Reuse code for interruptible sleeping.
---
lib/metadata/cache_manip.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 3eac736dd..98821430f 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -470,13 +470,7 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
//FIXME: use polling to do this...
for (;;) {
- sigint_allow();
- if (cleaner_policy)
- /* TODO: Use centralized place */
- usleep(500000);
- sigint_restore();
- if (sigint_caught()) {
- sigint_clear();
+ if (cleaner_policy && interruptible_usleep(500000)) {
log_error("Flushing of %s aborted.", display_lvname(cache_lv));
if (cache_seg->cleaner_policy) {
cache_seg->cleaner_policy = 0;
3 years, 2 months
main - activation: use interruptible_usleep
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a3bb8f2ec195fcfbea5...
Commit: a3bb8f2ec195fcfbea599d6efa784cb5cbd39741
Parent: 941f67ed09155011f13bb75db6aed621f94e2374
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 11 20:50:39 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
activation: use interruptible_usleep
Support interruption while waiting on device close.
---
lib/activate/activate.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 4452d4d40..93ab30424 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -29,6 +29,7 @@
#include "lib/metadata/segtype.h"
#include "lib/misc/sharedlib.h"
#include "lib/metadata/metadata.h"
+#include "lib/misc/lvm-signal.h"
#include <limits.h>
#include <fcntl.h>
@@ -863,25 +864,24 @@ int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used)
}
open_count_check_retries = retry_deactivation() ? OPEN_COUNT_CHECK_RETRIES : 1;
- while (info.open_count > 0 && open_count_check_retries--) {
- if (!open_count_check_retries) {
- if (error_if_used)
- log_error("Logical volume %s in use.", display_lvname(lv));
- else
- log_debug_activation("Logical volume %s in use.", display_lvname(lv));
- return 0;
- }
+ while (open_count_check_retries--) {
+ if (interruptible_usleep(OPEN_COUNT_CHECK_USLEEP_DELAY))
+ break; /* interrupted */
- usleep(OPEN_COUNT_CHECK_USLEEP_DELAY);
log_debug_activation("Retrying open_count check for %s.",
display_lvname(lv));
- if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0)) {
+ if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists) {
stack; /* device dissappeared? */
- break;
- }
+ return 1;
+ } else if (!info.open_count)
+ return 1;
}
- return 1;
+ if (error_if_used)
+ log_error("Logical volume %s in use.", display_lvname(lv));
+ else
+ log_debug_activation("Logical volume %s in use.", display_lvname(lv));
+ return 0;
}
/*
3 years, 2 months
main - signals: add interruptible usleep
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=941f67ed09155011f13...
Commit: 941f67ed09155011f13bb75db6aed621f94e2374
Parent: bbac843268ab353bb80a7f09841ff467bdcdeb04
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 12 11:18:53 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 14 16:34:38 2021 +0100
signals: add interruptible usleep
Add small wrapper that temporarily enables signal handling during
usleep() and return '0' when interrupted.
---
lib/misc/lvm-signal.c | 13 +++++++++++++
lib/misc/lvm-signal.h | 3 +++
2 files changed, 16 insertions(+)
diff --git a/lib/misc/lvm-signal.c b/lib/misc/lvm-signal.c
index b90a2db81..b1653a85c 100644
--- a/lib/misc/lvm-signal.c
+++ b/lib/misc/lvm-signal.c
@@ -153,3 +153,16 @@ void unblock_signals(void)
_signals_blocked = 0;
}
+
+/* usleep with enabled signal handler.
+ * Returns 1 when there was interruption */
+int interruptible_usleep(useconds_t usec)
+{
+ int r;
+
+ sigint_allow();
+ r = usleep(usec);
+ sigint_restore();
+
+ return (sigint_caught() || r) ? 1 : 0;
+}
diff --git a/lib/misc/lvm-signal.h b/lib/misc/lvm-signal.h
index 2f7309f5d..a39f77eb2 100644
--- a/lib/misc/lvm-signal.h
+++ b/lib/misc/lvm-signal.h
@@ -16,6 +16,8 @@
#ifndef _LVM_SIGNAL_H
#define _LVM_SIGNAL_H
+#include <unistd.h>
+
void remove_ctrl_c_handler(void);
void install_ctrl_c_handler(void);
int init_signals(int suppress_messages);
@@ -28,4 +30,5 @@ void sigint_clear(void);
void block_signals(uint32_t flags);
void unblock_signals(void);
+int interruptible_usleep(useconds_t usec);
#endif
3 years, 2 months
main - thinpool: correct condition
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bbac843268ab353bb80...
Commit: bbac843268ab353bb80a7f09841ff467bdcdeb04
Parent: 262008f1ceb050a9eed64f2fa50b1bc9366b9e75
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 11 13:33:24 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 12 12:59:55 2021 +0100
thinpool: correct condition
Actually we do want to flush thin-pool message for particular LV first.
Existing condition evaluated to noop.
---
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 4114e7d5c..2c77bacc2 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6707,7 +6707,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* Clear thin pool stacked messages */
- if (pool_lv && !pool_has_message(first_seg(pool_lv), lv, 0) &&
+ if (pool_lv && pool_has_message(first_seg(pool_lv), lv, 0) &&
!update_pool_lv(pool_lv, 1)) {
if (force < DONT_PROMPT_OVERRIDE) {
log_error("Failed to update pool %s.", display_lvname(pool_lv));
3 years, 2 months