Accepting request 958732 from home:hmzhao:branches:openSUSE:Factory

Update lvm2 from LVM2.2.03.12 to LVM2.2.03.15 (latest version)

OBS-URL: https://build.opensuse.org/request/show/958732
OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=305
This commit is contained in:
heming zhao 2022-03-03 10:29:46 +00:00 committed by Git OBS Bridge
parent f8b3f79d97
commit 43699ef0cc
74 changed files with 2806 additions and 8078 deletions

File diff suppressed because it is too large Load Diff

51
0001-post-release.patch Normal file
View File

@ -0,0 +1,51 @@
From 8dccc2314e2482370bc6e5cf007eb210994abdef Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Mon, 7 Feb 2022 18:02:07 +0100
Subject: 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 0e6ab70a9c50..fba090956ba1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.03.15(2) (2022-02-07)
+2.03.16(2)-git (2022-02-07)
diff --git a/VERSION_DM b/VERSION_DM
index d6704212f283..d122183b2c63 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.183 (2022-02-07)
+1.02.185-git (2022-02-07)
diff --git a/WHATS_NEW b/WHATS_NEW
index dda9954fe52f..006d0acb141c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.03.16 -
+====================================
+
Version 2.03.15 - 07th February 2022
====================================
Remove service based autoactivation. global/event_activation = 0 is NOOP.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 77843726211c..c634362217a5 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.185 -
+=====================================
+
Version 1.02.183 - 07th February 2022
=====================================
Unmangle UUIDs for DM_DEVICE_LIST ioctl.
--
2.34.1

View File

@ -0,0 +1,144 @@
From f83b3962c10bf4e196fec0e3e735820ba908661f Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Mon, 7 Feb 2022 19:58:04 +0100
Subject: asan: fix some reports from libasan
When compiled and used with:
CFLAGS="-fsanitize=address -g -O0"
ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
we have few reported issue - they where not normally spotted, since
we were still accessing our own memory - but ouf of buffer-range.
TODO: there is still something to enhance with handling of #orphan vgids
---
lib/config/config.c | 4 +++-
lib/format_text/format-text.c | 2 +-
lib/format_text/text_label.c | 6 ++++--
lib/metadata/metadata-exported.h | 2 +-
lib/uuid/uuid.c | 5 +++++
tools/Makefile.in | 4 ++--
tools/command.c | 2 +-
7 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index c8dab5683a20..f9614779a743 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -522,7 +522,9 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
if (!(dev->flags & DEV_REGULAR) || size2)
use_plain_read = 0;
- if (!(buf = zalloc(size + size2))) {
+ /* Ensure there is extra '\0' after end of buffer since we pass
+ * buffer to funtions like strtoll() */
+ if (!(buf = zalloc(size + size2 + 1))) {
log_error("Failed to allocate circular buffer.");
return 0;
}
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 00443faa12f7..07aaa0b28880 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2601,7 +2601,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
fmt->ops = &_text_handler;
fmt->name = FMT_TEXT_NAME;
fmt->alias = FMT_TEXT_ALIAS;
- fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_TEXT_NAME);
+ strncpy(fmt->orphan_vg_name, ORPHAN_VG_NAME(FMT_TEXT_NAME), sizeof(fmt->orphan_vg_name));
fmt->features = FMT_SEGMENTS | FMT_TAGS | FMT_PRECOMMIT |
FMT_UNLIMITED_VOLS | FMT_RESIZE_PV |
FMT_UNLIMITED_STRIPESIZE | FMT_CONFIG_PROFILE |
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 29b470271170..324c86e44978 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -410,6 +410,7 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
{
struct lvmcache_vgsummary vgsummary;
char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
struct lvmcache_info *info;
const struct format_type *fmt = labeller->fmt;
struct label_header *lh = (struct label_header *) label_buf;
@@ -433,6 +434,7 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
pvhdr = (struct pv_header *) ((char *) label_buf + xlate32(lh->offset_xl));
memcpy(pvid, &pvhdr->pv_uuid, ID_LEN);
+ strncpy(vgid, FMT_TEXT_ORPHAN_VG_NAME, ID_LEN);
/*
* FIXME: stop adding the device to lvmcache initially as an orphan
@@ -449,8 +451,8 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
* Other reasons for lvmcache_add to return NULL are internal errors.
*/
if (!(info = lvmcache_add(cmd, labeller, pvid, dev, label_sector,
- FMT_TEXT_ORPHAN_VG_NAME,
- FMT_TEXT_ORPHAN_VG_NAME, 0, is_duplicate)))
+ vgid,
+ vgid, 0, is_duplicate)))
return_0;
lvmcache_set_device_size(info, xlate64(pvhdr->device_size_xl));
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7bac5b900343..fd370d4b261a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -371,7 +371,7 @@ struct format_type {
struct labeller *labeller;
const char *name;
const char *alias;
- const char *orphan_vg_name;
+ char orphan_vg_name[ID_LEN];
struct volume_group *orphan_vg; /* Only one ever exists. */
uint32_t features;
void *library;
diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c
index be4cbc3ec194..d8b72422bc0f 100644
--- a/lib/uuid/uuid.c
+++ b/lib/uuid/uuid.c
@@ -168,6 +168,11 @@ int id_write_format(const struct id *id, char *buffer, size_t size)
assert(ID_LEN == 32);
+ if (id->uuid[0] == '#') {
+ (void) dm_strncpy(buffer, (char*)id->uuid, size);
+ return 1;
+ }
+
/* split into groups separated by dashes */
if (size < (32 + 6 + 1)) {
if (size > 0)
diff --git a/tools/Makefile.in b/tools/Makefile.in
index e0e180474789..25fe3b6b36d8 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -190,9 +190,9 @@ command-lines-input.h: $(srcdir)/command-lines.in Makefile
$(Q) set -o pipefail && \
( cat $(srcdir)/license.inc && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
- echo -en "const char _command_input[] =\n\n\"" && \
+ echo -en "static const char _command_input[] =\n\n\"" && \
$(EGREP) -v '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
- echo "\\n\";" \
+ echo "\\n\\n\";" \
) > $@
$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
diff --git a/tools/command.c b/tools/command.c
index 18ffd64ed986..8de8825e4cbd 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2549,7 +2549,7 @@ static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
}
if (strchr(long_opt, '[')) {
- for (i = 0; i < sizeof(long_opt_name) - 1; ++long_opt, ++i) {
+ for (i = 0; *long_opt && i < sizeof(long_opt_name) - 1; ++long_opt, ++i) {
if (i < (sizeof(long_opt_name) - 8))
switch(*long_opt) {
case '[':
--
2.34.1

View File

@ -1,708 +0,0 @@
From d02f5392a0ed8a5f6b7aa14642db1f46ac0682d8 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 7 May 2021 10:25:13 +0800
Subject: [PATCH 02/33] lvmlockd: idm: Hook Seagate IDM wrapper APIs
To allow the IDM locking scheme be used by users, this patch hooks the
IDM wrapper; it also introducs a new locking type "idm" and we can use
it for global lock with option '-g idm'.
To support IDM locking type, the main change in the data structure is to
add pvs path arrary. The pvs list is transferred from the lvm commands,
when lvmlockd core layer receives message, it extracts the message with
the keyword "path[idx]". Finally, the pv list will pass to IDM lock
manager as the target drives for sending IDM SCSI commands.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
daemons/lvmlockd/lvmlockd-core.c | 281 +++++++++++++++++++++++++++++++----
daemons/lvmlockd/lvmlockd-internal.h | 4 +-
2 files changed, 257 insertions(+), 28 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 238ec718b45a..ea76f2214b3e 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -421,6 +421,63 @@ struct lockspace *alloc_lockspace(void)
return ls;
}
+static char **alloc_pvs_path(struct pvs *pvs, int num)
+{
+ if (!num)
+ return NULL;
+
+ pvs->path = malloc(sizeof(char *) * num);
+ if (!pvs->path)
+ return NULL;
+
+ memset(pvs->path, 0x0, sizeof(char *) * num);
+ return pvs->path;
+}
+
+static void free_pvs_path(struct pvs *pvs)
+{
+ int i;
+
+ for (i = 0; i < pvs->num; i++) {
+ if (!pvs->path[i])
+ continue;
+
+ free((char *)pvs->path[i]);
+ pvs->path[i] = NULL;
+ }
+
+ if (!pvs->path) {
+ free(pvs->path);
+ pvs->path = NULL;
+ }
+}
+
+static char **alloc_and_copy_pvs_path(struct pvs *dst, struct pvs *src)
+{
+ int i;
+
+ if (!alloc_pvs_path(dst, src->num))
+ return NULL;
+
+ dst->num = 0;
+ for (i = 0; i < src->num; i++) {
+ if (!src->path[i] || !strcmp(src->path[i], "none"))
+ continue;
+
+ dst->path[dst->num] = strdup(src->path[i]);
+ if (!dst->path[dst->num]) {
+ log_error("out of memory for copying pvs path");
+ goto failed;
+ }
+ dst->num++;
+ }
+ return dst->path;
+
+failed:
+ free_pvs_path(dst);
+ return NULL;
+}
+
static struct action *alloc_action(void)
{
struct action *act;
@@ -510,6 +567,9 @@ static void free_action(struct action *act)
free(act->path);
act->path = NULL;
}
+
+ free_pvs_path(&act->pvs);
+
pthread_mutex_lock(&unused_struct_mutex);
if (unused_action_count >= MAX_UNUSED_ACTION) {
free(act);
@@ -564,9 +624,12 @@ static int setup_structs(void)
struct lock *lk;
int data_san = lm_data_size_sanlock();
int data_dlm = lm_data_size_dlm();
+ int data_idm = lm_data_size_idm();
int i;
resource_lm_data_size = data_san > data_dlm ? data_san : data_dlm;
+ resource_lm_data_size = resource_lm_data_size > data_idm ?
+ resource_lm_data_size : data_idm;
pthread_mutex_init(&unused_struct_mutex, NULL);
INIT_LIST_HEAD(&unused_action);
@@ -683,6 +746,8 @@ static const char *lm_str(int x)
return "dlm";
case LD_LM_SANLOCK:
return "sanlock";
+ case LD_LM_IDM:
+ return "idm";
default:
return "lm_unknown";
}
@@ -968,6 +1033,8 @@ static int lm_prepare_lockspace(struct lockspace *ls, struct action *act)
rv = lm_prepare_lockspace_dlm(ls);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_prepare_lockspace_sanlock(ls);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_prepare_lockspace_idm(ls);
else
return -1;
@@ -984,6 +1051,8 @@ static int lm_add_lockspace(struct lockspace *ls, struct action *act, int adopt)
rv = lm_add_lockspace_dlm(ls, adopt);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_add_lockspace_sanlock(ls, adopt);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_add_lockspace_idm(ls, adopt);
else
return -1;
@@ -1000,6 +1069,8 @@ static int lm_rem_lockspace(struct lockspace *ls, struct action *act, int free_v
rv = lm_rem_lockspace_dlm(ls, free_vg);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_rem_lockspace_sanlock(ls, free_vg);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_rem_lockspace_idm(ls, free_vg);
else
return -1;
@@ -1017,6 +1088,9 @@ static int lm_lock(struct lockspace *ls, struct resource *r, int mode, struct ac
rv = lm_lock_dlm(ls, r, mode, vb_out, adopt);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_lock_sanlock(ls, r, mode, vb_out, retry, adopt);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_lock_idm(ls, r, mode, vb_out, act->lv_uuid,
+ &act->pvs, adopt);
else
return -1;
@@ -1034,6 +1108,8 @@ static int lm_convert(struct lockspace *ls, struct resource *r,
rv = lm_convert_dlm(ls, r, mode, r_version);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_convert_sanlock(ls, r, mode, r_version);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_convert_idm(ls, r, mode, r_version);
else
return -1;
@@ -1051,6 +1127,8 @@ static int lm_unlock(struct lockspace *ls, struct resource *r, struct action *ac
rv = lm_unlock_dlm(ls, r, r_version, lmu_flags);
else if (ls->lm_type == LD_LM_SANLOCK)
rv = lm_unlock_sanlock(ls, r, r_version, lmu_flags);
+ else if (ls->lm_type == LD_LM_IDM)
+ rv = lm_unlock_idm(ls, r, r_version, lmu_flags);
else
return -1;
@@ -1065,6 +1143,8 @@ static int lm_hosts(struct lockspace *ls, int notify)
return lm_hosts_dlm(ls, notify);
else if (ls->lm_type == LD_LM_SANLOCK)
return lm_hosts_sanlock(ls, notify);
+ else if (ls->lm_type == LD_LM_IDM)
+ return lm_hosts_idm(ls, notify);
return -1;
}
@@ -1074,6 +1154,8 @@ static void lm_rem_resource(struct lockspace *ls, struct resource *r)
lm_rem_resource_dlm(ls, r);
else if (ls->lm_type == LD_LM_SANLOCK)
lm_rem_resource_sanlock(ls, r);
+ else if (ls->lm_type == LD_LM_IDM)
+ lm_rem_resource_idm(ls, r);
}
static int lm_find_free_lock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size)
@@ -1082,6 +1164,8 @@ static int lm_find_free_lock(struct lockspace *ls, uint64_t *free_offset, int *s
return 0;
else if (ls->lm_type == LD_LM_SANLOCK)
return lm_find_free_lock_sanlock(ls, free_offset, sector_size, align_size);
+ else if (ls->lm_type == LD_LM_IDM)
+ return 0;
return -1;
}
@@ -1690,8 +1774,8 @@ static int res_update(struct lockspace *ls, struct resource *r,
}
/*
- * There is nothing to deallocate when freeing a dlm LV, the LV
- * will simply be unlocked by rem_resource.
+ * For DLM and IDM locking scheme, there is nothing to deallocate when freeing a
+ * LV, the LV will simply be unlocked by rem_resource.
*/
static int free_lv(struct lockspace *ls, struct resource *r)
@@ -1700,6 +1784,8 @@ static int free_lv(struct lockspace *ls, struct resource *r)
return lm_free_lv_sanlock(ls, r);
else if (ls->lm_type == LD_LM_DLM)
return 0;
+ else if (ls->lm_type == LD_LM_IDM)
+ return 0;
else
return -EINVAL;
}
@@ -2758,6 +2844,8 @@ out_act:
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
+ if (ls->lm_type == LD_LM_IDM && !strcmp(ls->name, gl_lsname_idm))
+ global_idm_lockspace_exists = 0;
/*
* Avoid a name collision of the same lockspace is added again before
@@ -2849,6 +2937,8 @@ static void gl_ls_name(char *ls_name)
memcpy(ls_name, gl_lsname_dlm, MAX_NAME);
else if (gl_use_sanlock)
memcpy(ls_name, gl_lsname_sanlock, MAX_NAME);
+ else if (gl_use_idm)
+ memcpy(ls_name, gl_lsname_idm, MAX_NAME);
else
memset(ls_name, 0, MAX_NAME);
}
@@ -2877,9 +2967,20 @@ static int add_lockspace_thread(const char *ls_name,
strncpy(ls->name, ls_name, MAX_NAME);
ls->lm_type = lm_type;
- if (act)
+ if (act) {
ls->start_client_id = act->client_id;
+ /*
+ * Copy PV list to lockspact structure, so this is
+ * used for VG locking for idm scheme.
+ */
+ if (lm_type == LD_LM_IDM &&
+ !alloc_and_copy_pvs_path(&ls->pvs, &act->pvs)) {
+ free(ls);
+ return -ENOMEM;
+ }
+ }
+
if (vg_uuid)
strncpy(ls->vg_uuid, vg_uuid, 64);
@@ -2906,6 +3007,18 @@ static int add_lockspace_thread(const char *ls_name,
pthread_mutex_lock(&lockspaces_mutex);
ls2 = find_lockspace_name(ls->name);
if (ls2) {
+ /*
+ * If find an existed lockspace, we need to update the PV list
+ * based on the latest information, and release for the old
+ * PV list in case it keeps stale information.
+ */
+ free_pvs_path(&ls2->pvs);
+ if (lm_type == LD_LM_IDM &&
+ !alloc_and_copy_pvs_path(&ls2->pvs, &ls->pvs)) {
+ log_debug("add_lockspace_thread %s fails to allocate pvs", ls->name);
+ rv = -ENOMEM;
+ }
+
if (ls2->thread_stop) {
log_debug("add_lockspace_thread %s exists and stopping", ls->name);
rv = -EAGAIN;
@@ -2918,6 +3031,7 @@ static int add_lockspace_thread(const char *ls_name,
}
pthread_mutex_unlock(&lockspaces_mutex);
free_resource(r);
+ free_pvs_path(&ls->pvs);
free(ls);
return rv;
}
@@ -2931,6 +3045,8 @@ static int add_lockspace_thread(const char *ls_name,
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 1;
+ if (ls->lm_type == LD_LM_IDM && !strcmp(ls->name, gl_lsname_idm))
+ global_idm_lockspace_exists = 1;
list_add_tail(&ls->list, &lockspaces);
pthread_mutex_unlock(&lockspaces_mutex);
@@ -2941,6 +3057,7 @@ static int add_lockspace_thread(const char *ls_name,
list_del(&ls->list);
pthread_mutex_unlock(&lockspaces_mutex);
free_resource(r);
+ free_pvs_path(&ls->pvs);
free(ls);
return rv;
}
@@ -2949,16 +3066,15 @@ static int add_lockspace_thread(const char *ls_name,
}
/*
- * There is no add_sanlock_global_lockspace or
- * rem_sanlock_global_lockspace because with sanlock,
- * the global lockspace is one of the vg lockspaces.
+ * There is no variant for sanlock because, with sanlock, the global
+ * lockspace is one of the vg lockspaces.
*/
-
-static int add_dlm_global_lockspace(struct action *act)
+static int add_global_lockspace(char *ls_name, int lm_type,
+ struct action *act)
{
int rv;
- if (global_dlm_lockspace_exists)
+ if (global_dlm_lockspace_exists || global_idm_lockspace_exists)
return 0;
/*
@@ -2966,9 +3082,9 @@ static int add_dlm_global_lockspace(struct action *act)
* lock request, insert an internal gl sh lock request?
*/
- rv = add_lockspace_thread(gl_lsname_dlm, NULL, NULL, LD_LM_DLM, NULL, act);
+ rv = add_lockspace_thread(ls_name, NULL, NULL, lm_type, NULL, act);
if (rv < 0)
- log_debug("add_dlm_global_lockspace add_lockspace_thread %d", rv);
+ log_debug("add_global_lockspace add_lockspace_thread %d", rv);
/*
* EAGAIN may be returned for a short period because
@@ -2981,12 +3097,12 @@ static int add_dlm_global_lockspace(struct action *act)
}
/*
- * If dlm gl lockspace is the only one left, then stop it.
- * This is not used for an explicit rem_lockspace action from
- * the client, only for auto remove.
+ * When DLM or IDM locking scheme is used for global lock, if the global
+ * lockspace is the only one left, then stop it. This is not used for
+ * an explicit rem_lockspace action from the client, only for auto
+ * remove.
*/
-
-static int rem_dlm_global_lockspace(void)
+static int rem_global_lockspace(char *ls_name)
{
struct lockspace *ls, *ls_gl = NULL;
int others = 0;
@@ -2994,7 +3110,7 @@ static int rem_dlm_global_lockspace(void)
pthread_mutex_lock(&lockspaces_mutex);
list_for_each_entry(ls, &lockspaces, list) {
- if (!strcmp(ls->name, gl_lsname_dlm)) {
+ if (!strcmp(ls->name, ls_name)) {
ls_gl = ls;
continue;
}
@@ -3026,6 +3142,26 @@ out:
return rv;
}
+static int add_dlm_global_lockspace(struct action *act)
+{
+ return add_global_lockspace(gl_lsname_dlm, LD_LM_DLM, act);
+}
+
+static int rem_dlm_global_lockspace(void)
+{
+ return rem_global_lockspace(gl_lsname_dlm);
+}
+
+static int add_idm_global_lockspace(struct action *act)
+{
+ return add_global_lockspace(gl_lsname_idm, LD_LM_IDM, act);
+}
+
+static int rem_idm_global_lockspace(void)
+{
+ return rem_global_lockspace(gl_lsname_idm);
+}
+
/*
* When the first dlm lockspace is added for a vg, automatically add a separate
* dlm lockspace for the global lock.
@@ -3051,6 +3187,9 @@ static int add_lockspace(struct action *act)
if (gl_use_dlm) {
rv = add_dlm_global_lockspace(act);
return rv;
+ } else if (gl_use_idm) {
+ rv = add_idm_global_lockspace(act);
+ return rv;
} else {
return -EINVAL;
}
@@ -3059,6 +3198,8 @@ static int add_lockspace(struct action *act)
if (act->rt == LD_RT_VG) {
if (gl_use_dlm)
add_dlm_global_lockspace(NULL);
+ else if (gl_use_idm)
+ add_idm_global_lockspace(NULL);
vg_ls_name(act->vg_name, ls_name);
@@ -3126,14 +3267,15 @@ static int rem_lockspace(struct action *act)
pthread_mutex_unlock(&lockspaces_mutex);
/*
- * The dlm global lockspace was automatically added when
- * the first dlm vg lockspace was added, now reverse that
- * by automatically removing the dlm global lockspace when
- * the last dlm vg lockspace is removed.
+ * For DLM and IDM locking scheme, the global lockspace was
+ * automatically added when the first vg lockspace was added,
+ * now reverse that by automatically removing the dlm global
+ * lockspace when the last vg lockspace is removed.
*/
-
if (rt == LD_RT_VG && gl_use_dlm)
rem_dlm_global_lockspace();
+ else if (rt == LD_RT_VG && gl_use_idm)
+ rem_idm_global_lockspace();
return 0;
}
@@ -3257,6 +3399,7 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
if (ls->free_vg) {
/* In future we may need to free ls->actions here */
free_ls_resources(ls);
+ free_pvs_path(&ls->pvs);
free(ls);
free_count++;
}
@@ -3270,6 +3413,7 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
if (!gl_type_static) {
gl_use_dlm = 0;
gl_use_sanlock = 0;
+ gl_use_idm = 0;
}
}
pthread_mutex_unlock(&lockspaces_mutex);
@@ -3345,6 +3489,9 @@ static int work_init_vg(struct action *act)
rv = lm_init_vg_sanlock(ls_name, act->vg_name, act->flags, act->vg_args);
else if (act->lm_type == LD_LM_DLM)
rv = lm_init_vg_dlm(ls_name, act->vg_name, act->flags, act->vg_args);
+ else if (act->lm_type == LD_LM_IDM)
+ /* Non't do anything for IDM when initialize VG */
+ rv = 0;
else
rv = -EINVAL;
@@ -3448,6 +3595,8 @@ static int work_init_lv(struct action *act)
} else if (act->lm_type == LD_LM_DLM) {
return 0;
+ } else if (act->lm_type == LD_LM_IDM) {
+ return 0;
} else {
log_error("init_lv ls_name %s bad lm_type %d", ls_name, act->lm_type);
return -EINVAL;
@@ -3511,20 +3660,29 @@ static void *worker_thread_main(void *arg_in)
if (act->op == LD_OP_RUNNING_LM) {
int run_sanlock = lm_is_running_sanlock();
int run_dlm = lm_is_running_dlm();
+ int run_idm = lm_is_running_idm();
if (daemon_test) {
run_sanlock = gl_use_sanlock;
run_dlm = gl_use_dlm;
+ run_idm = gl_use_idm;
}
- if (run_sanlock && run_dlm)
+ /*
+ * It's not possible to enable multiple locking schemes
+ * for global lock, otherwise, it must be conflict and
+ * reports it!
+ */
+ if ((run_sanlock + run_dlm + run_idm) >= 2)
act->result = -EXFULL;
- else if (!run_sanlock && !run_dlm)
+ else if (!run_sanlock && !run_dlm && !run_idm)
act->result = -ENOLCK;
else if (run_sanlock)
act->result = LD_LM_SANLOCK;
else if (run_dlm)
act->result = LD_LM_DLM;
+ else if (run_idm)
+ act->result = LD_LM_IDM;
add_client_result(act);
} else if ((act->op == LD_OP_LOCK) && (act->flags & LD_AF_SEARCH_LS)) {
@@ -3812,6 +3970,9 @@ static int client_send_result(struct client *cl, struct action *act)
} else if (gl_use_dlm) {
if (!gl_lsname_dlm[0])
strcat(result_flags, "NO_GL_LS,");
+ } else if (gl_use_idm) {
+ if (!gl_lsname_idm[0])
+ strcat(result_flags, "NO_GL_LS,");
} else {
int found_lm = 0;
@@ -3819,6 +3980,8 @@ static int client_send_result(struct client *cl, struct action *act)
found_lm++;
if (lm_support_sanlock() && lm_is_running_sanlock())
found_lm++;
+ if (lm_support_idm() && lm_is_running_idm())
+ found_lm++;
if (!found_lm)
strcat(result_flags, "NO_GL_LS,NO_LM");
@@ -3994,11 +4157,13 @@ static int add_lock_action(struct action *act)
if (gl_use_sanlock && (act->op == LD_OP_ENABLE || act->op == LD_OP_DISABLE)) {
vg_ls_name(act->vg_name, ls_name);
} else {
- if (!gl_use_dlm && !gl_use_sanlock) {
+ if (!gl_use_dlm && !gl_use_sanlock && !gl_use_idm) {
if (lm_is_running_dlm())
gl_use_dlm = 1;
else if (lm_is_running_sanlock())
gl_use_sanlock = 1;
+ else if (lm_is_running_idm())
+ gl_use_idm = 1;
}
gl_ls_name(ls_name);
}
@@ -4046,6 +4211,17 @@ static int add_lock_action(struct action *act)
add_dlm_global_lockspace(NULL);
goto retry;
+ } else if (act->op == LD_OP_LOCK && act->rt == LD_RT_GL && act->mode != LD_LK_UN && gl_use_idm) {
+ /*
+ * Automatically start the idm global lockspace when
+ * a command tries to acquire the global lock.
+ */
+ log_debug("lockspace \"%s\" not found for idm gl, adding...", ls_name);
+ act->flags |= LD_AF_SEARCH_LS;
+ act->flags |= LD_AF_WAIT_STARTING;
+ add_idm_global_lockspace(NULL);
+ goto retry;
+
} else if (act->op == LD_OP_LOCK && act->mode == LD_LK_UN) {
log_debug("lockspace \"%s\" not found for unlock ignored", ls_name);
return -ENOLS;
@@ -4266,6 +4442,8 @@ static int str_to_lm(const char *str)
return LD_LM_SANLOCK;
if (!strcmp(str, "dlm"))
return LD_LM_DLM;
+ if (!strcmp(str, "idm"))
+ return LD_LM_IDM;
return -2;
}
@@ -4601,12 +4779,14 @@ static void client_recv_action(struct client *cl)
const char *vg_sysid;
const char *path;
const char *str;
+ struct pvs pvs;
+ char buf[11]; /* p a t h [ x x x x ] \0 */
int64_t val;
uint32_t opts = 0;
int result = 0;
int cl_pid;
int op, rt, lm, mode;
- int rv;
+ int rv, i;
buffer_init(&req.buffer);
@@ -4695,11 +4875,13 @@ static void client_recv_action(struct client *cl)
if (!cl->name[0] && cl_name)
strncpy(cl->name, cl_name, MAX_NAME);
- if (!gl_use_dlm && !gl_use_sanlock && (lm > 0)) {
+ if (!gl_use_dlm && !gl_use_sanlock && !gl_use_idm && (lm > 0)) {
if (lm == LD_LM_DLM && lm_support_dlm())
gl_use_dlm = 1;
else if (lm == LD_LM_SANLOCK && lm_support_sanlock())
gl_use_sanlock = 1;
+ else if (lm == LD_LM_IDM && lm_support_idm())
+ gl_use_idm = 1;
log_debug("set gl_use_%s", lm_str(lm));
}
@@ -4756,6 +4938,40 @@ static void client_recv_action(struct client *cl)
if (val)
act->host_id = val;
+ /* Create PV list for idm */
+ if (lm == LD_LM_IDM) {
+ memset(&pvs, 0x0, sizeof(pvs));
+
+ pvs.num = daemon_request_int(req, "path_num", 0);
+ log_error("pvs_num = %d", pvs.num);
+
+ if (!pvs.num)
+ goto skip_pvs_path;
+
+ /* Receive the pv list which is transferred from LVM command */
+ if (!alloc_pvs_path(&pvs, pvs.num)) {
+ log_error("fail to allocate pvs path");
+ rv = -ENOMEM;
+ goto out;
+ }
+
+ for (i = 0; i < pvs.num; i++) {
+ snprintf(buf, sizeof(buf), "path[%d]", i);
+ pvs.path[i] = (char *)daemon_request_str(req, buf, NULL);
+ }
+
+ if (!alloc_and_copy_pvs_path(&act->pvs, &pvs)) {
+ log_error("fail to allocate pvs path");
+ rv = -ENOMEM;
+ goto out;
+ }
+
+ if (pvs.path)
+ free(pvs.path);
+ pvs.path = NULL;
+ }
+
+skip_pvs_path:
act->max_retries = daemon_request_int(req, "max_retries", DEFAULT_MAX_RETRIES);
dm_config_destroy(req.cft);
@@ -4777,6 +4993,12 @@ static void client_recv_action(struct client *cl)
goto out;
}
+ if (lm == LD_LM_IDM && !lm_support_idm()) {
+ log_debug("idm not supported");
+ rv = -EPROTONOSUPPORT;
+ goto out;
+ }
+
if (act->op == LD_OP_LOCK && act->mode != LD_LK_UN)
cl->lock_ops = 1;
@@ -5375,6 +5597,7 @@ static void adopt_locks(void)
}
list_del(&ls->list);
+ free_pvs_path(&ls->pvs);
free(ls);
}
@@ -5415,6 +5638,7 @@ static void adopt_locks(void)
if (rv < 0) {
log_error("Failed to create lockspace thread for VG %s", ls->vg_name);
list_del(&ls->list);
+ free_pvs_path(&ls->pvs);
free(ls);
free_action(act);
count_start_fail++;
@@ -5857,6 +6081,7 @@ static int main_loop(daemon_state *ds_arg)
}
strcpy(gl_lsname_dlm, S_NAME_GL_DLM);
+ strcpy(gl_lsname_idm, S_NAME_GL_IDM);
INIT_LIST_HEAD(&lockspaces);
pthread_mutex_init(&lockspaces_mutex, NULL);
@@ -6110,6 +6335,8 @@ int main(int argc, char *argv[])
gl_use_dlm = 1;
else if (lm == LD_LM_SANLOCK && lm_support_sanlock())
gl_use_sanlock = 1;
+ else if (lm == LD_LM_IDM && lm_support_idm())
+ gl_use_idm = 1;
else {
fprintf(stderr, "invalid gl-type option\n");
exit(EXIT_FAILURE);
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index 06bf07eb59cf..ad32eb3a40e2 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -121,7 +121,7 @@ struct client {
#define DEFAULT_MAX_RETRIES 4
struct pvs {
- const char **path;
+ char **path;
int num;
};
@@ -338,7 +338,9 @@ EXTERN int gl_use_idm;
EXTERN int gl_vg_removed;
EXTERN char gl_lsname_dlm[MAX_NAME+1];
EXTERN char gl_lsname_sanlock[MAX_NAME+1];
+EXTERN char gl_lsname_idm[MAX_NAME+1];
EXTERN int global_dlm_lockspace_exists;
+EXTERN int global_idm_lockspace_exists;
EXTERN int daemon_test; /* run as much as possible without a live lock manager */
EXTERN int daemon_debug;
--
1.8.3.1

View File

@ -1,301 +0,0 @@
From ef1c57e68fa67dc0bc144b3a745bc456c3232d3e Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 7 May 2021 10:25:14 +0800
Subject: [PATCH 03/33] lib: locking: Add new type "idm"
We can consider the drive firmware a server to handle the locking
request from nodes, this essentially is a client-server model.
DLM uses the kernel as a central place to manage locks, so it also
complies with client-server model for locking operations. This is
why IDM and DLM are similar with each other for their wrappers.
This patch largely works by generalizing the DLM code paths and then
providing degeneralized functions as wrappers for both IDM and DLM.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/display/display.c | 4 +++
lib/locking/lvmlockd.c | 72 ++++++++++++++++++++++++++++++++++------
lib/metadata/metadata-exported.h | 1 +
lib/metadata/metadata.c | 12 ++++++-
4 files changed, 78 insertions(+), 11 deletions(-)
diff --git a/lib/display/display.c b/lib/display/display.c
index f0f03c0a5411..f9c9ef83667d 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -95,6 +95,8 @@ const char *get_lock_type_string(lock_type_t lock_type)
return "dlm";
case LOCK_TYPE_SANLOCK:
return "sanlock";
+ case LOCK_TYPE_IDM:
+ return "idm";
}
return "invalid";
}
@@ -111,6 +113,8 @@ lock_type_t get_lock_type_from_string(const char *str)
return LOCK_TYPE_DLM;
if (!strcmp(str, "sanlock"))
return LOCK_TYPE_SANLOCK;
+ if (!strcmp(str, "idm"))
+ return LOCK_TYPE_IDM;
return LOCK_TYPE_INVALID;
}
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 9a1b4f476f01..040c4246d718 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -553,7 +553,8 @@ static int _deactivate_sanlock_lv(struct cmd_context *cmd, struct volume_group *
return 1;
}
-static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+static int _init_vg(struct cmd_context *cmd, struct volume_group *vg,
+ const char *lock_type)
{
daemon_reply reply;
const char *reply_str;
@@ -569,7 +570,7 @@ static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
reply = _lockd_send("init_vg",
"pid = " FMTd64, (int64_t) getpid(),
"vg_name = %s", vg->name,
- "vg_lock_type = %s", "dlm",
+ "vg_lock_type = %s", lock_type,
NULL);
if (!_lockd_result(reply, &result, NULL)) {
@@ -589,10 +590,12 @@ static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
log_error("VG %s init failed: invalid parameters for dlm", vg->name);
break;
case -EMANAGER:
- log_error("VG %s init failed: lock manager dlm is not running", vg->name);
+ log_error("VG %s init failed: lock manager %s is not running",
+ vg->name, lock_type);
break;
case -EPROTONOSUPPORT:
- log_error("VG %s init failed: lock manager dlm is not supported by lvmlockd", vg->name);
+ log_error("VG %s init failed: lock manager %s is not supported by lvmlockd",
+ vg->name, lock_type);
break;
case -EEXIST:
log_error("VG %s init failed: a lockspace with the same name exists", vg->name);
@@ -616,7 +619,7 @@ static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
goto out;
}
- vg->lock_type = "dlm";
+ vg->lock_type = lock_type;
vg->lock_args = vg_lock_args;
if (!vg_write(vg) || !vg_commit(vg)) {
@@ -631,6 +634,16 @@ out:
return ret;
}
+static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _init_vg(cmd, vg, "dlm");
+}
+
+static int _init_vg_idm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _init_vg(cmd, vg, "idm");
+}
+
static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, int lv_lock_count)
{
daemon_reply reply;
@@ -794,7 +807,7 @@ out:
/* called after vg_remove on disk */
-static int _free_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+static int _free_vg(struct cmd_context *cmd, struct volume_group *vg)
{
daemon_reply reply;
uint32_t lockd_flags = 0;
@@ -820,16 +833,27 @@ static int _free_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
}
if (!ret)
- log_error("_free_vg_dlm lvmlockd result %d", result);
+ log_error("%s: lock type %s lvmlockd result %d",
+ __func__, vg->lock_type, result);
daemon_reply_destroy(reply);
return 1;
}
+static int _free_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _free_vg(cmd, vg);
+}
+
+static int _free_vg_idm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _free_vg(cmd, vg);
+}
+
/* called before vg_remove on disk */
-static int _busy_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+static int _busy_vg(struct cmd_context *cmd, struct volume_group *vg)
{
daemon_reply reply;
uint32_t lockd_flags = 0;
@@ -864,13 +888,24 @@ static int _busy_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
}
if (!ret)
- log_error("_busy_vg_dlm lvmlockd result %d", result);
+ log_error("%s: lock type %s lvmlockd result %d", __func__,
+ vg->lock_type, result);
out:
daemon_reply_destroy(reply);
return ret;
}
+static int _busy_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _busy_vg(cmd, vg);
+}
+
+static int _busy_vg_idm(struct cmd_context *cmd, struct volume_group *vg)
+{
+ return _busy_vg(cmd, vg);
+}
+
/* called before vg_remove on disk */
static int _free_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg)
@@ -976,6 +1011,8 @@ int lockd_init_vg(struct cmd_context *cmd, struct volume_group *vg,
return _init_vg_dlm(cmd, vg);
case LOCK_TYPE_SANLOCK:
return _init_vg_sanlock(cmd, vg, lv_lock_count);
+ case LOCK_TYPE_IDM:
+ return _init_vg_idm(cmd, vg);
default:
log_error("Unknown lock_type.");
return 0;
@@ -1017,7 +1054,8 @@ int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg,
* When removing (not changing), each LV is locked
* when it is removed, they do not need checking here.
*/
- if (lock_type_num == LOCK_TYPE_DLM || lock_type_num == LOCK_TYPE_SANLOCK) {
+ if (lock_type_num == LOCK_TYPE_DLM || lock_type_num == LOCK_TYPE_SANLOCK ||
+ lock_type_num == LOCK_TYPE_IDM) {
if (changing && !_lockd_all_lvs(cmd, vg)) {
log_error("Cannot change VG %s with active LVs", vg->name);
return 0;
@@ -1041,6 +1079,9 @@ int lockd_free_vg_before(struct cmd_context *cmd, struct volume_group *vg,
case LOCK_TYPE_SANLOCK:
/* returning an error will prevent vg_remove() */
return _free_vg_sanlock(cmd, vg);
+ case LOCK_TYPE_IDM:
+ /* returning an error will prevent vg_remove() */
+ return _busy_vg_idm(cmd, vg);
default:
log_error("Unknown lock_type.");
return 0;
@@ -1059,6 +1100,9 @@ void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg)
case LOCK_TYPE_DLM:
_free_vg_dlm(cmd, vg);
break;
+ case LOCK_TYPE_IDM:
+ _free_vg_idm(cmd, vg);
+ break;
default:
log_error("Unknown lock_type.");
}
@@ -2679,6 +2723,7 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
return 1;
case LOCK_TYPE_SANLOCK:
case LOCK_TYPE_DLM:
+ case LOCK_TYPE_IDM:
break;
default:
log_error("lockd_init_lv: unknown lock_type.");
@@ -2821,6 +2866,8 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
lv->lock_args = "pending";
else if (!strcmp(vg->lock_type, "dlm"))
lv->lock_args = "dlm";
+ else if (!strcmp(vg->lock_type, "idm"))
+ lv->lock_args = "idm";
return 1;
}
@@ -2836,6 +2883,7 @@ int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
return 1;
case LOCK_TYPE_DLM:
case LOCK_TYPE_SANLOCK:
+ case LOCK_TYPE_IDM:
if (!lock_args)
return 1;
return _free_lv(cmd, vg, lv_name, lv_id, lock_args);
@@ -3007,6 +3055,10 @@ const char *lockd_running_lock_type(struct cmd_context *cmd, int *found_multiple
log_debug("lvmlockd found dlm");
lock_type = "dlm";
break;
+ case LOCK_TYPE_IDM:
+ log_debug("lvmlockd found idm");
+ lock_type = "idm";
+ break;
default:
log_error("Failed to find a running lock manager.");
break;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c6116350f643..52062a1002da 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -356,6 +356,7 @@ typedef enum {
LOCK_TYPE_CLVM = 1,
LOCK_TYPE_DLM = 2,
LOCK_TYPE_SANLOCK = 3,
+ LOCK_TYPE_IDM = 4,
} lock_type_t;
struct cmd_context;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 002d80c010cb..110cbaed4e62 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2235,6 +2235,13 @@ static int _validate_lv_lock_args(struct logical_volume *lv)
lv->vg->name, display_lvname(lv), lv->lock_args);
r = 0;
}
+
+ } else if (!strcmp(lv->vg->lock_type, "idm")) {
+ if (strcmp(lv->lock_args, "idm")) {
+ log_error(INTERNAL_ERROR "LV %s/%s has invalid lock_args \"%s\"",
+ lv->vg->name, display_lvname(lv), lv->lock_args);
+ r = 0;
+ }
}
return r;
@@ -2569,7 +2576,8 @@ int vg_validate(struct volume_group *vg)
r = 0;
}
- if (strcmp(vg->lock_type, "sanlock") && strcmp(vg->lock_type, "dlm")) {
+ if (strcmp(vg->lock_type, "sanlock") && strcmp(vg->lock_type, "dlm") &&
+ strcmp(vg->lock_type, "idm")) {
log_error(INTERNAL_ERROR "VG %s has unknown lock_type %s",
vg->name, vg->lock_type);
r = 0;
@@ -4355,6 +4363,8 @@ int is_lockd_type(const char *lock_type)
return 1;
if (!strcmp(lock_type, "sanlock"))
return 1;
+ if (!strcmp(lock_type, "idm"))
+ return 1;
return 0;
}
--
1.8.3.1

318
0003-make-generate.patch Normal file
View File

@ -0,0 +1,318 @@
From 13122bcc3329f3c1aee0a1cc478eda8906cd96df Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Sun, 6 Feb 2022 20:05:54 +0100
Subject: make: generate
---
conf/example.conf.in | 15 +++-----
man/lvdisplay.8_pregen | 12 -------
man/lvmdevices.8_pregen | 3 +-
man/pvdisplay.8_pregen | 12 -------
man/pvscan.8_pregen | 77 ++++++++++++++++++++++-------------------
man/vgchange.8_pregen | 12 +++++++
man/vgdisplay.8_pregen | 12 -------
7 files changed, 60 insertions(+), 83 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index a78ed7333310..94f7a23fdb11 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1151,16 +1151,11 @@ global {
# lvdisplay_shows_full_device_path = 0
# Configuration option global/event_activation.
- # Activate LVs based on system-generated device events.
- # When a PV appears on the system, a system-generated uevent triggers
- # the lvm2-pvscan service which runs the pvscan --cache -aay command.
- # If the new PV completes a VG, pvscan autoactivates LVs in the VG.
- # When event_activation is disabled, the lvm2-activation services are
- # generated and run at fixed points during system startup. These
- # services run vgchange -aay to autoactivate LVs in VGs that happen
- # to be present at that point in time.
- # See the --setautoactivation option or the auto_activation_volume_list
- # setting to configure autoactivation for specific VGs or LVs.
+ # Disable event based autoactivation commands.
+ # WARNING: setting this to zero may cause machine startup to fail.
+ # Previously, setting this to zero would enable static autoactivation
+ # services (via the lvm2-activation-generator), but the autoactivation
+ # services and generator have been removed.
# This configuration option has an automatic default value.
# event_activation = 1
diff --git a/man/lvdisplay.8_pregen b/man/lvdisplay.8_pregen
index a1740ebed152..04aab4c0970c 100644
--- a/man/lvdisplay.8_pregen
+++ b/man/lvdisplay.8_pregen
@@ -61,8 +61,6 @@ and more, using a more compact and configurable output format.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
-.br
[ \fB--segments\fP ]
.br
[ \fB--separator\fP \fIString\fP ]
@@ -332,16 +330,6 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
-.br
-Overrides current output format for reports which is defined globally by
-the report/output_format setting in \fBlvm.conf\fP(5).
-\fBbasic\fP is the original format with columns and rows.
-If there is more than one report per command, each report is prefixed
-with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
-.
-.HP
\fB--segments\fP
.br
.
diff --git a/man/lvmdevices.8_pregen b/man/lvmdevices.8_pregen
index d64c3a31abe7..a2391a62bb3e 100644
--- a/man/lvmdevices.8_pregen
+++ b/man/lvmdevices.8_pregen
@@ -322,7 +322,8 @@ Find a device with the PVID and add the device to the devices file.
.HP
\fB--check\fP
.br
-Check the content of the devices file.
+Checks the content of the devices file.
+Reports incorrect device names or PVIDs for entries.
.
.HP
\fB--commandprofile\fP \fIString\fP
diff --git a/man/pvdisplay.8_pregen b/man/pvdisplay.8_pregen
index 22a0992b52bb..2f26a8727d43 100644
--- a/man/pvdisplay.8_pregen
+++ b/man/pvdisplay.8_pregen
@@ -61,8 +61,6 @@ and more, using a more compact and configurable output format.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
-.br
[ \fB--separator\fP \fIString\fP ]
.br
[ \fB--shared\fP ]
@@ -320,16 +318,6 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
-.br
-Overrides current output format for reports which is defined globally by
-the report/output_format setting in \fBlvm.conf\fP(5).
-\fBbasic\fP is the original format with columns and rows.
-If there is more than one report per command, each report is prefixed
-with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
-.
-.HP
\fB-S\fP|\fB--select\fP \fIString\fP
.br
Select objects for processing and reporting based on specified criteria.
diff --git a/man/pvscan.8_pregen b/man/pvscan.8_pregen
index 9eb6b5bf96be..4622e145e564 100644
--- a/man/pvscan.8_pregen
+++ b/man/pvscan.8_pregen
@@ -15,6 +15,8 @@ pvscan \(em List all physical volumes
.P
.ad l
\fB-a\fP|\fB--activate\fP \fBy\fP|\fBn\fP|\fBay\fP
+.br
+ \fB--autoactivation\fP \fIString\fP
.br
\fB--cache\fP
.br
@@ -91,59 +93,50 @@ like
or
.BR pvdisplay (8).
.P
-When the --cache and -aay options are used, pvscan records which PVs are
-available on the system, and activates LVs in completed VGs. A VG is
-complete when pvscan sees that the final PV in the VG has appeared. This
-is used by event-based system startup (systemd, udev) to activate LVs.
-.P
-The four main variations of this are:
+When --cache is used, pvscan updates runtime lvm state on the system, or
+with -aay performs autoactivation.
.P
.B pvscan --cache
.I device
.P
-If device is present, lvm adds a record that the PV on device is online.
+If device is present, lvm records that the PV on device is online.
If device is not present, lvm removes the online record for the PV.
-In most cases, the pvscan will only read the named devices.
+pvscan only reads the named device.
.P
-.B pvscan --cache -aay
-.IR device ...
+.B pvscan --cache
.P
-This begins by performing the same steps as above. Afterward, if the VG
-for the specified PV is complete, then pvscan will activate LVs in the VG
-(the same as vgchange -aay vgname would do.)
+Updates the runtime state for all lvm devices.
.P
-.B pvscan --cache
+.B pvscan --cache -aay
+.I device
.P
-This first clears all existing PV online records, then scans all devices
-on the system, adding PV online records for any PVs that are found.
+Performs the --cache steps for the device, then checks if the VG using the
+device is complete. If so, LVs in the VG are autoactivated, the same as
+vgchange -aay vgname would do. (A device name may be replaced with major
+and minor numbers.)
.P
.B pvscan --cache -aay
.P
-This begins by performing the same steps as pvscan --cache. Afterward, it
-activates LVs in any complete VGs.
+Performs the --cache steps for all devices, then autoactivates any complete VGs.
.P
-To prevent devices from being scanned by pvscan --cache, add them
-to
-.BR lvm.conf (5)
-.B devices/global_filter.
-For more information, see:
-.br
-.B lvmconfig --withcomments devices/global_filter
+.B pvscan --cache --listvg|--listlvs
+.I device
.P
-Auto-activation of VGs or LVs can be enabled/disabled using:
-.br
+Performs the --cache steps for the device, then prints the name of the VG
+using the device, or the names of LVs using the device. --checkcomplete
+is usually included to check if all PVs for the VG or LVs are online.
+When this command is called by a udev rule, the output must conform to
+udev rule specifications (see --udevoutput.) The udev rule will use the
+results to perform autoactivation.
+.P
+Autoactivation of VGs or LVs can be enabled/disabled using vgchange or
+lvchange with --setautoactivation y|n, or by adding names to
.BR lvm.conf (5)
.B activation/auto_activation_volume_list
.P
-For more information, see:
-.br
-.B lvmconfig --withcomments activation/auto_activation_volume_list
-.P
-To disable auto-activation, explicitly set this list to an empty list,
-i.e. auto_activation_volume_list = [ ].
-.P
-When this setting is undefined (e.g. commented), then all LVs are
-auto-activated.
+See
+.BR lvmautoactivation (7)
+for more information about how pvscan is used for autoactivation.
.
.SH USAGE
.
@@ -215,6 +208,8 @@ Record that a PV is online and autoactivate the VG if complete.
.br
[ \fB--noudevsync\fP ]
.br
+[ \fB--autoactivation\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -239,6 +234,8 @@ Record that a PV is online and list the VG using the PV.
.br
[ \fB--udevoutput\fP ]
.br
+[ \fB--autoactivation\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -342,6 +339,14 @@ Auto-activate LVs in a VG when the PVs scanned have completed the VG.
(Only \fBay\fP is applicable.)
.
.HP
+\fB--autoactivation\fP \fIString\fP
+.br
+Specify if autoactivation is being used from an event.
+This allows the command to apply settings that are specific
+to event activation, such as device scanning optimizations
+using pvs_online files created by event-based pvscans.
+.
+.HP
\fB--cache\fP
.br
Scan one or more devices and record that they are online.
diff --git a/man/vgchange.8_pregen b/man/vgchange.8_pregen
index 05c67aeada56..9dbad3faad87 100644
--- a/man/vgchange.8_pregen
+++ b/man/vgchange.8_pregen
@@ -24,6 +24,8 @@ vgchange \(em Change volume group attributes
.nh
\%\fBcontiguous\fP|\:\fBcling\fP|\:\fBcling_by_tags\fP|\:\fBnormal\fP|\:\fBanywhere\fP|\:\fBinherit\fP
.hy
+.br
+ \fB--autoactivation\fP \fIString\fP
.br
\fB-A\fP|\fB--autobackup\fP \fBy\fP|\fBn\fP
.br
@@ -286,6 +288,8 @@ Activate or deactivate LVs.
.br
[ \fB--poll\fP \fBy\fP|\fBn\fP ]
.br
+[ \fB--autoactivation\fP \fIString\fP ]
+.br
[ \fB--ignoremonitoring\fP ]
.br
[ \fB--noudevsync\fP ]
@@ -516,6 +520,14 @@ which PVs the command will use for allocation.
See \fBlvm\fP(8) for more information about allocation.
.
.HP
+\fB--autoactivation\fP \fIString\fP
+.br
+Specify if autoactivation is being used from an event.
+This allows the command to apply settings that are specific
+to event activation, such as device scanning optimizations
+using pvs_online files created by event-based pvscans.
+.
+.HP
\fB-A\fP|\fB--autobackup\fP \fBy\fP|\fBn\fP
.br
Specifies if metadata should be backed up automatically after a change.
diff --git a/man/vgdisplay.8_pregen b/man/vgdisplay.8_pregen
index 9c694921dee8..0a12b3c395bb 100644
--- a/man/vgdisplay.8_pregen
+++ b/man/vgdisplay.8_pregen
@@ -58,8 +58,6 @@ and more, using a more compact and configurable output format.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
-.br
[ \fB--shared\fP ]
.br
[ \fB--separator\fP \fIString\fP ]
@@ -312,16 +310,6 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
-.br
-Overrides current output format for reports which is defined globally by
-the report/output_format setting in \fBlvm.conf\fP(5).
-\fBbasic\fP is the original format with columns and rows.
-If there is more than one report per command, each report is prefixed
-with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
-.
-.HP
\fB-S\fP|\fB--select\fP \fIString\fP
.br
Select objects for processing and reporting based on specified criteria.
--
2.34.1

View File

@ -1,412 +0,0 @@
From affe1af148d5d939ffad7bde2ad51b0f386a44b7 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 7 May 2021 10:25:15 +0800
Subject: [PATCH 04/33] lib: locking: Parse PV list for IDM locking
For shared VG or LV locking, IDM locking scheme needs to use the PV
list assocated with VG or LV for sending SCSI commands, thus it requires
to use some places to generate PV list.
In reviewing the flow for LVM commands, the best place to generate PV
list is in the locking lib. So this is why this patch parses PV list as
shown. It iterates over all the PV nodes one by one, and compare with
the VG name or LV prefix string. If any PV matches, then the PV is
added into the PV list. Finally the PV list is sent to lvmlockd daemon.
Here as mentioned, it compares LV prefix string with the format
"lv_name_", the reason is it needs to find out all relevant PVs, e.g.
for the thin pool, it has LVs for metadata, pool, error, and raw LV, so
we can use the prefix string to find out all PVs belonging to the thin
pool.
For the global lock, it's not covered in this patch. To avoid the egg
and chicken issue, we need to prepare the global lock ahead before any
locking can be used. So the global lock's PV list is established in
lvmlockd daemon by iterating all drives with partition labeled with
"propeller".
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/locking/lvmlockd.c | 258 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 241 insertions(+), 17 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 040c4246d718..766be71badf3 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -25,6 +25,11 @@ static int _use_lvmlockd = 0; /* is 1 if command is configured to use lv
static int _lvmlockd_connected = 0; /* is 1 if command is connected to lvmlockd */
static int _lvmlockd_init_failed = 0; /* used to suppress further warnings */
+struct lvmlockd_pvs {
+ char **path;
+ int num;
+};
+
void lvmlockd_set_socket(const char *sock)
{
_lvmlockd_socket = sock;
@@ -178,18 +183,34 @@ static int _lockd_result(daemon_reply reply, int *result, uint32_t *lockd_flags)
return 1;
}
-static daemon_reply _lockd_send(const char *req_name, ...)
+static daemon_reply _lockd_send_with_pvs(const char *req_name,
+ const struct lvmlockd_pvs *lock_pvs, ...)
{
- va_list ap;
daemon_reply repl;
daemon_request req;
+ int i;
+ char key[32];
+ const char *val;
+ va_list ap;
req = daemon_request_make(req_name);
- va_start(ap, req_name);
+ va_start(ap, lock_pvs);
daemon_request_extend_v(req, ap);
va_end(ap);
+ /* Pass PV list */
+ if (lock_pvs && lock_pvs->num) {
+ daemon_request_extend(req, "path_num = " FMTd64,
+ (int64_t)(lock_pvs)->num, NULL);
+
+ for (i = 0; i < lock_pvs->num; i++) {
+ snprintf(key, sizeof(key), "path[%d] = %%s", i);
+ val = lock_pvs->path[i] ? lock_pvs->path[i] : "none";
+ daemon_request_extend(req, key, val, NULL);
+ }
+ }
+
repl = daemon_send(_lvmlockd, req);
daemon_request_destroy(req);
@@ -197,6 +218,166 @@ static daemon_reply _lockd_send(const char *req_name, ...)
return repl;
}
+#define _lockd_send(req_name, args...) \
+ _lockd_send_with_pvs(req_name, NULL, ##args)
+
+static int _lockd_retrive_vg_pv_num(struct volume_group *vg)
+{
+ struct pv_list *pvl;
+ int num = 0;
+
+ dm_list_iterate_items(pvl, &vg->pvs)
+ num++;
+
+ return num;
+}
+
+static void _lockd_retrive_vg_pv_list(struct volume_group *vg,
+ struct lvmlockd_pvs *lock_pvs)
+{
+ struct pv_list *pvl;
+ int pv_num, i;
+
+ memset(lock_pvs, 0x0, sizeof(*lock_pvs));
+
+ pv_num = _lockd_retrive_vg_pv_num(vg);
+ if (!pv_num) {
+ log_error("Fail to any PVs for VG %s", vg->name);
+ return;
+ }
+
+ /* Allocate buffer for PV list */
+ lock_pvs->path = zalloc(sizeof(*lock_pvs->path) * pv_num);
+ if (!lock_pvs->path) {
+ log_error("Fail to allocate PV list for VG %s", vg->name);
+ return;
+ }
+
+ i = 0;
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
+ if (!lock_pvs->path[i]) {
+ log_error("Fail to allocate PV path for VG %s", vg->name);
+ goto fail;
+ }
+
+ log_debug("VG %s find PV device %s", vg->name, lock_pvs->path[i]);
+ i++;
+ }
+
+ lock_pvs->num = pv_num;
+ return;
+
+fail:
+ for (i = 0; i < pv_num; i++) {
+ if (!lock_pvs->path[i])
+ continue;
+ free(lock_pvs->path[i]);
+ }
+ free(lock_pvs->path);
+ return;
+}
+
+static int _lockd_retrive_lv_pv_num(struct volume_group *vg,
+ const char *lv_name)
+{
+ struct logical_volume *lv = find_lv(vg, lv_name);
+ struct pv_list *pvl;
+ int num;
+
+ if (!lv)
+ return 0;
+
+ num = 0;
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (lv_is_on_pv(lv, pvl->pv))
+ num++;
+ }
+
+ return num;
+}
+
+static void _lockd_retrive_lv_pv_list(struct volume_group *vg,
+ const char *lv_name,
+ struct lvmlockd_pvs *lock_pvs)
+{
+ struct logical_volume *lv = find_lv(vg, lv_name);
+ struct pv_list *pvl;
+ int pv_num, i = 0;
+
+ memset(lock_pvs, 0x0, sizeof(*lock_pvs));
+
+ /* Cannot find any existed LV? */
+ if (!lv)
+ return;
+
+ pv_num = _lockd_retrive_lv_pv_num(vg, lv_name);
+ if (!pv_num) {
+ /*
+ * Fixup for 'lvcreate --type error -L1 -n $lv1 $vg', in this
+ * case, the drive path list is empty since it doesn't establish
+ * the structure 'pvseg->lvseg->lv->name'.
+ *
+ * So create drive path list with all drives in the VG.
+ */
+ log_error("Fail to find any PVs for %s/%s, try to find PVs from VG instead",
+ vg->name, lv_name);
+ _lockd_retrive_vg_pv_list(vg, lock_pvs);
+ return;
+ }
+
+ /* Allocate buffer for PV list */
+ lock_pvs->path = malloc(sizeof(*lock_pvs->path) * pv_num);
+ if (!lock_pvs->path) {
+ log_error("Fail to allocate PV list for %s/%s", vg->name, lv_name);
+ return;
+ }
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (lv_is_on_pv(lv, pvl->pv)) {
+ lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
+ if (!lock_pvs->path[i]) {
+ log_error("Fail to allocate PV path for LV %s/%s",
+ vg->name, lv_name);
+ goto fail;
+ }
+
+ log_debug("Find PV device %s for LV %s/%s",
+ lock_pvs->path[i], vg->name, lv_name);
+ i++;
+ }
+ }
+
+ lock_pvs->num = pv_num;
+ return;
+
+fail:
+ for (i = 0; i < pv_num; i++) {
+ if (!lock_pvs->path[i])
+ continue;
+ free(lock_pvs->path[i]);
+ lock_pvs->path[i] = NULL;
+ }
+ free(lock_pvs->path);
+ lock_pvs->path = NULL;
+ lock_pvs->num = 0;
+ return;
+}
+
+static void _lockd_free_pv_list(struct lvmlockd_pvs *lock_pvs)
+{
+ int i;
+
+ for (i = 0; i < lock_pvs->num; i++) {
+ free(lock_pvs->path[i]);
+ lock_pvs->path[i] = NULL;
+ }
+
+ free(lock_pvs->path);
+ lock_pvs->path = NULL;
+ lock_pvs->num = 0;
+}
+
/*
* result/lockd_flags are values returned from lvmlockd.
*
@@ -227,6 +408,7 @@ static int _lockd_request(struct cmd_context *cmd,
const char *lv_lock_args,
const char *mode,
const char *opts,
+ const struct lvmlockd_pvs *lock_pvs,
int *result,
uint32_t *lockd_flags)
{
@@ -251,7 +433,8 @@ static int _lockd_request(struct cmd_context *cmd,
cmd_name = "none";
if (vg_name && lv_name) {
- reply = _lockd_send(req_name,
+ reply = _lockd_send_with_pvs(req_name,
+ lock_pvs,
"cmd = %s", cmd_name,
"pid = " FMTd64, (int64_t) pid,
"mode = %s", mode,
@@ -271,7 +454,8 @@ static int _lockd_request(struct cmd_context *cmd,
req_name, mode, vg_name, lv_name, *result, *lockd_flags);
} else if (vg_name) {
- reply = _lockd_send(req_name,
+ reply = _lockd_send_with_pvs(req_name,
+ lock_pvs,
"cmd = %s", cmd_name,
"pid = " FMTd64, (int64_t) pid,
"mode = %s", mode,
@@ -288,7 +472,8 @@ static int _lockd_request(struct cmd_context *cmd,
req_name, mode, vg_name, *result, *lockd_flags);
} else {
- reply = _lockd_send(req_name,
+ reply = _lockd_send_with_pvs(req_name,
+ lock_pvs,
"cmd = %s", cmd_name,
"pid = " FMTd64, (int64_t) pid,
"mode = %s", mode,
@@ -1134,6 +1319,7 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_i
int host_id = 0;
int result;
int ret;
+ struct lvmlockd_pvs lock_pvs;
memset(uuid, 0, sizeof(uuid));
@@ -1169,7 +1355,28 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_i
host_id = find_config_tree_int(cmd, local_host_id_CFG, NULL);
}
- reply = _lockd_send("start_vg",
+ /*
+ * Create the VG's PV list when start the VG, the PV list
+ * is passed to lvmlockd, and the the PVs path will be used
+ * to send SCSI commands for idm locking scheme.
+ */
+ if (!strcmp(vg->lock_type, "idm")) {
+ _lockd_retrive_vg_pv_list(vg, &lock_pvs);
+ reply = _lockd_send_with_pvs("start_vg",
+ &lock_pvs,
+ "pid = " FMTd64, (int64_t) getpid(),
+ "vg_name = %s", vg->name,
+ "vg_lock_type = %s", vg->lock_type,
+ "vg_lock_args = %s", vg->lock_args ?: "none",
+ "vg_uuid = %s", uuid[0] ? uuid : "none",
+ "version = " FMTd64, (int64_t) vg->seqno,
+ "host_id = " FMTd64, (int64_t) host_id,
+ "opts = %s", start_init ? "start_init" : "none",
+ NULL);
+ _lockd_free_pv_list(&lock_pvs);
+ } else {
+ reply = _lockd_send_with_pvs("start_vg",
+ NULL,
"pid = " FMTd64, (int64_t) getpid(),
"vg_name = %s", vg->name,
"vg_lock_type = %s", vg->lock_type,
@@ -1179,6 +1386,7 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_i
"host_id = " FMTd64, (int64_t) host_id,
"opts = %s", start_init ? "start_init" : "none",
NULL);
+ }
if (!_lockd_result(reply, &result, &lockd_flags)) {
ret = 0;
@@ -1406,7 +1614,7 @@ int lockd_global_create(struct cmd_context *cmd, const char *def_mode, const cha
req:
if (!_lockd_request(cmd, "lock_gl",
NULL, vg_lock_type, NULL, NULL, NULL, NULL, mode, NULL,
- &result, &lockd_flags)) {
+ NULL, &result, &lockd_flags)) {
/* No result from lvmlockd, it is probably not running. */
log_error("Global lock failed: check that lvmlockd is running.");
return 0;
@@ -1642,7 +1850,7 @@ int lockd_global(struct cmd_context *cmd, const char *def_mode)
if (!_lockd_request(cmd, "lock_gl",
NULL, NULL, NULL, NULL, NULL, NULL, mode, opts,
- &result, &lockd_flags)) {
+ NULL, &result, &lockd_flags)) {
/* No result from lvmlockd, it is probably not running. */
/* We don't care if an unlock fails. */
@@ -1910,7 +2118,7 @@ int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
if (!_lockd_request(cmd, "lock_vg",
vg_name, NULL, NULL, NULL, NULL, NULL, mode, NULL,
- &result, &lockd_flags)) {
+ NULL, &result, &lockd_flags)) {
/*
* No result from lvmlockd, it is probably not running.
* Decide if it is ok to continue without a lock in
@@ -2170,6 +2378,7 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
uint32_t lockd_flags;
int refreshed = 0;
int result;
+ struct lvmlockd_pvs lock_pvs;
/*
* Verify that when --readonly is used, no LVs should be activated or used.
@@ -2235,13 +2444,28 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
retry:
log_debug("lockd LV %s/%s mode %s uuid %s", vg->name, lv_name, mode, lv_uuid);
- if (!_lockd_request(cmd, "lock_lv",
- vg->name, vg->lock_type, vg->lock_args,
- lv_name, lv_uuid, lock_args, mode, opts,
- &result, &lockd_flags)) {
- /* No result from lvmlockd, it is probably not running. */
- log_error("Locking failed for LV %s/%s", vg->name, lv_name);
- return 0;
+ /* Pass PV list for IDM lock type */
+ if (!strcmp(vg->lock_type, "idm")) {
+ _lockd_retrive_lv_pv_list(vg, lv_name, &lock_pvs);
+ if (!_lockd_request(cmd, "lock_lv",
+ vg->name, vg->lock_type, vg->lock_args,
+ lv_name, lv_uuid, lock_args, mode, opts,
+ &lock_pvs, &result, &lockd_flags)) {
+ _lockd_free_pv_list(&lock_pvs);
+ /* No result from lvmlockd, it is probably not running. */
+ log_error("Locking failed for LV %s/%s", vg->name, lv_name);
+ return 0;
+ }
+ _lockd_free_pv_list(&lock_pvs);
+ } else {
+ if (!_lockd_request(cmd, "lock_lv",
+ vg->name, vg->lock_type, vg->lock_args,
+ lv_name, lv_uuid, lock_args, mode, opts,
+ NULL, &result, &lockd_flags)) {
+ /* No result from lvmlockd, it is probably not running. */
+ log_error("Locking failed for LV %s/%s", vg->name, lv_name);
+ return 0;
+ }
}
/* The lv was not active/locked. */
--
1.8.3.1

View File

@ -0,0 +1,63 @@
From 61f23fe15e0c6e5b7882263e0d527f363535da4d Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 7 Feb 2022 16:44:57 -0600
Subject: tests: udev-pvscan-vgchange fix service wait
As a result of removing -r from systemd-run in
commit fbd8b0cf43dc67f51f86f060dce748f446985855
this test needs to change how it handles the
transient services.
---
test/shell/udev-pvscan-vgchange.sh | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/test/shell/udev-pvscan-vgchange.sh b/test/shell/udev-pvscan-vgchange.sh
index a209dc048cce..eb698407881f 100644
--- a/test/shell/udev-pvscan-vgchange.sh
+++ b/test/shell/udev-pvscan-vgchange.sh
@@ -75,7 +75,7 @@ wait_lvm_activate() {
local vgw=$1
local wait=0
- while systemctl status lvm-activate-$vgw | grep "active (running)" && test "$wait" -le 30; do
+ while systemctl status lvm-activate-$vgw > /dev/null && test "$wait" -le 30; do
sleep .2
wait=$(( wait + 1 ))
done
@@ -382,7 +382,6 @@ lvcreate -l1 -an -n $lv1 $vg9
lvcreate -l1 -an -n $lv2 $vg9
mdadm --stop "$mddev"
-systemctl stop lvm-activate-$vg9 || true
_clear_online_files
mdadm --assemble "$mddev" "$dev1" "$dev2"
@@ -405,17 +404,6 @@ mdadm --stop "$mddev"
aux udev_wait
wipe_all
-systemctl stop lvm-activate-$vg1
-systemctl stop lvm-activate-$vg2
-systemctl stop lvm-activate-$vg3
-systemctl stop lvm-activate-$vg4
-systemctl stop lvm-activate-$vg5
-systemctl stop lvm-activate-$vg6
-systemctl stop lvm-activate-$vg7
-systemctl stop lvm-activate-$vg8
-systemctl stop lvm-activate-$vg9
-
-
# no devices file, filter with symlink of PV
# the pvscan needs to look at all dev names to
# match the symlink in the filter with the
@@ -439,7 +427,6 @@ udevadm trigger --settle -c add /sys/block/$BDEV1
ls /dev/disk/by-id/lvm-pv-uuid-$OPVID1
vgchange -an $vg10
-systemctl stop lvm-activate-$vg10
_clear_online_files
aux lvmconf "devices/filter = [ \"a|/dev/disk/by-id/lvm-pv-uuid-$OPVID1|\", \"r|.*|\" ]"
--
2.34.1

View File

@ -0,0 +1,144 @@
From d59382c772483d3c09b4fcff90c01d81742feac6 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 10 Feb 2022 14:00:25 -0600
Subject: devices file: do not clear PVID of unread devices
In a certain disconnected state, a block device is present on
the system, can be opened, reports a valid size, reports the
correct device id (wwid), and matches a devices file entry.
But, reading the device can still fail. In this case,
device_ids_validate() was misinterpreting the read error as
the device having no data/label on it (and no PVID).
The validate function would then clear the PVID from the
devices file entry for the device, thinking that it was
fixing the devices file (making it consistent with the on disk
state.) Fix this by not attempting to check and correct a
devices file entry that cannot be read. Also make this case
explicit in the hints validation code (which was doing the
right thing but indirectly.)
---
lib/device/device.h | 1 +
lib/device/device_id.c | 14 ++++++++++++++
lib/label/hints.c | 14 ++++++++++++++
lib/label/label.c | 8 ++++++++
4 files changed, 37 insertions(+)
diff --git a/lib/device/device.h b/lib/device/device.h
index 9e471a9b514a..8c3a8c30e086 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -40,6 +40,7 @@
#define DEV_IS_NVME 0x00040000 /* set if dev is nvme */
#define DEV_MATCHED_USE_ID 0x00080000 /* matched an entry from cmd->use_devices */
#define DEV_SCAN_FOUND_NOLABEL 0x00100000 /* label_scan read, passed filters, but no lvm label */
+#define DEV_SCAN_NOT_READ 0x00200000 /* label_scan not able to read dev */
/*
* Support for external device info.
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 4618247ba1f2..003f10a96641 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1746,6 +1746,13 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
if (scanned_devs && !dev_in_device_list(dev, scanned_devs))
continue;
+ /*
+ * The matched device could not be read so we do not have
+ * the PVID from disk and cannot verify the devices file entry.
+ */
+ if (dev->flags & DEV_SCAN_NOT_READ)
+ continue;
+
/*
* du and dev may have been matched, but the dev could still
* have been excluded by other filters during label scan.
@@ -1828,6 +1835,13 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
if (scanned_devs && !dev_in_device_list(dev, scanned_devs))
continue;
+ /*
+ * The matched device could not be read so we do not have
+ * the PVID from disk and cannot verify the devices file entry.
+ */
+ if (dev->flags & DEV_SCAN_NOT_READ)
+ continue;
+
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent")) {
log_warn("Devices file %s is excluded by filter: %s.",
dev_name(dev), dev_filtered_reason(dev));
diff --git a/lib/label/hints.c b/lib/label/hints.c
index 93dfdd5c1d9a..35ae7f5cc8df 100644
--- a/lib/label/hints.c
+++ b/lib/label/hints.c
@@ -236,6 +236,7 @@ static int _touch_newhints(void)
return_0;
if (fclose(fp))
stack;
+ log_debug("newhints created");
return 1;
}
@@ -506,6 +507,19 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
if (!hint->chosen)
continue;
+ /*
+ * label_scan was unable to read the dev so we don't know its pvid.
+ * Since we are unable to verify the hint is correct, it's possible
+ * that the PVID is actually found on a different device, so don't
+ * depend on hints. (This would also fail the following pvid check.)
+ */
+ if (dev->flags & DEV_SCAN_NOT_READ) {
+ log_debug("Uncertain hint for unread device %d:%d %s",
+ major(hint->devt), minor(hint->devt), dev_name(dev));
+ ret = 0;
+ continue;
+ }
+
if (strcmp(dev->pvid, hint->pvid)) {
log_debug("Invalid hint device %d:%d %s pvid %s had hint pvid %s",
major(hint->devt), minor(hint->devt), dev_name(dev),
diff --git a/lib/label/label.c b/lib/label/label.c
index 8676b9e4a642..fe2bc8fec743 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -687,6 +687,8 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
dm_list_iterate_items_safe(devl, devl2, devs) {
+ devl->dev->flags &= ~DEV_SCAN_NOT_READ;
+
/*
* If we prefetch more devs than blocks in the cache, then the
* cache will wait for earlier reads to complete, toss the
@@ -702,6 +704,7 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
log_debug_devs("Scan failed to open %s.", dev_name(devl->dev));
dm_list_del(&devl->list);
dm_list_add(&reopen_devs, &devl->list);
+ devl->dev->flags |= DEV_SCAN_NOT_READ;
continue;
}
}
@@ -725,6 +728,7 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
log_debug_devs("Scan failed to read %s.", dev_name(devl->dev));
scan_read_errors++;
scan_failed_count++;
+ devl->dev->flags |= DEV_SCAN_NOT_READ;
lvmcache_del_dev(devl->dev);
if (bb)
bcache_put(bb);
@@ -1389,6 +1393,10 @@ int label_scan(struct cmd_context *cmd)
* filter", and this result needs to be cleared (wiped) so that the
* complete set of filters (including those that require data) can be
* checked in _process_block, where headers have been read.
+ *
+ * FIXME: devs that are filtered with data in _process_block
+ * are not moved to the filtered_devs list like devs filtered
+ * here without data. Does that have any effect?
*/
log_debug_devs("Filtering devices to scan (nodata)");
--
2.34.1

View File

@ -1,80 +0,0 @@
From 8b904dc71143f4dc7553026f783aa1c0b1d4b954 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 7 May 2021 10:25:16 +0800
Subject: [PATCH 05/33] tools: Add support for "idm" lock type
This patch is to update the comment and code to support "idm" lock type
which is used for LVM toolkit.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/lvconvert.c | 2 ++
tools/toollib.c | 11 ++++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8dd8a15c4054..71f7a7627fa1 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3416,6 +3416,8 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
pool_lv->lock_args = "pending";
else if (!strcmp(vg->lock_type, "dlm"))
pool_lv->lock_args = "dlm";
+ else if (!strcmp(vg->lock_type, "idm"))
+ pool_lv->lock_args = "idm";
/* The lock_args will be set in vg_write(). */
}
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 07f065322d94..f337f9fcf9d5 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -591,15 +591,15 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
* new VG, and is it compatible with current lvm.conf settings.
*
* The end result is to set vp_new->lock_type to:
- * none | clvm | dlm | sanlock.
+ * none | clvm | dlm | sanlock | idm.
*
* If 'vgcreate --lock-type <arg>' is set, the answer is given
- * directly by <arg> which is one of none|clvm|dlm|sanlock.
+ * directly by <arg> which is one of none|clvm|dlm|sanlock|idm.
*
* 'vgcreate --clustered y' is the way to create clvm VGs.
*
* 'vgcreate --shared' is the way to create lockd VGs.
- * lock_type of sanlock or dlm is selected based on
+ * lock_type of sanlock, dlm or idm is selected based on
* which lock manager is running.
*
*
@@ -646,7 +646,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
* - lvmlockd is used
* - VGs with CLUSTERED set are ignored (requires clvmd)
* - VGs with lockd type can be used
- * - vgcreate can create new VGs with lock_type sanlock or dlm
+ * - vgcreate can create new VGs with lock_type sanlock, dlm or idm
* - 'vgcreate --clustered y' fails
* - 'vgcreate --shared' works
* - 'vgcreate' (neither option) creates a local VG
@@ -658,7 +658,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
lock_type = arg_str_value(cmd, locktype_ARG, "");
if (arg_is_set(cmd, shared_ARG) && !is_lockd_type(lock_type)) {
- log_error("The --shared option requires lock type sanlock or dlm.");
+ log_error("The --shared option requires lock type sanlock, dlm or idm.");
return 0;
}
@@ -697,6 +697,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
case LOCK_TYPE_SANLOCK:
case LOCK_TYPE_DLM:
+ case LOCK_TYPE_IDM:
if (!use_lvmlockd) {
log_error("Using a shared lock type requires lvmlockd.");
return 0;
--
1.8.3.1

View File

@ -1,34 +0,0 @@
From 102294f9788f243509f1001a60924d6920fd9092 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Fri, 21 May 2021 10:56:37 +0800
Subject: [PATCH 06/33] configure: Add macro LOCKDIDM_SUPPORT
The macro LOCKDIDM_SUPPORT is missed in configure.h.in file, thus when
execute "configure" command, it has no chance to add this macro in the
automatic generated header include/configure.h.
This patch adds macro LOCKDIDM_SUPPORT into configure.h.in.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
include/configure.h.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/configure.h.in b/include/configure.h.in
index 671d201b2a7e..bcb282660694 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -561,6 +561,9 @@
/* Define to 1 to include code that uses lvmlockd sanlock option. */
#undef LOCKDSANLOCK_SUPPORT
+/* Define to 1 to include code that uses lvmlockd IDM option. */
+#undef LOCKDIDM_SUPPORT
+
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
--
1.8.3.1

View File

@ -0,0 +1,27 @@
From 6626adb46789e329a53242822dc6e9d233320adb Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 15 Feb 2022 15:56:01 -0600
Subject: tests: skip vgchange-pvs-online.sh on rhel5
the /dev/mapper/ paths to test devices don't seem to work there
---
test/shell/vgchange-pvs-online.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/shell/vgchange-pvs-online.sh b/test/shell/vgchange-pvs-online.sh
index ced03f4daef7..9bcf70e4b245 100644
--- a/test/shell/vgchange-pvs-online.sh
+++ b/test/shell/vgchange-pvs-online.sh
@@ -19,6 +19,9 @@ _clear_online_files() {
aux prepare_devs 4
+# skip rhel5 which doesn't seem to have /dev/mapper/LVMTESTpv1
+aux driver_at_least 4 15 || skip
+
DFDIR="$LVM_SYSTEM_DIR/devices"
mkdir -p "$DFDIR" || true
DF="$DFDIR/system.devices"
--
2.34.1

View File

@ -0,0 +1,44 @@
From 6ffb150f3075da69597e6f3e84d7533f2d8a36fa Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 16 Feb 2022 00:33:25 +0100
Subject: dev_manager: fix dm_task_get_device_list
With very old version of DM target driver we have to avoid
trying to use newuuid setting - otherwise we get error
during ioctl preparation phase.
Patch is fixing regression from commit:
988ea0e94c79a496f2619eab878fd9db6168711d
---
lib/activate/dev_manager.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 6cf4c718c389..3fd6aaff76a9 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -107,6 +107,8 @@ static struct dm_task *_setup_task_run(int task, struct dm_info *info,
int with_flush,
int query_inactive)
{
+ char vsn[80];
+ unsigned maj, min;
struct dm_task *dmt;
if (!(dmt = dm_task_create(task)))
@@ -142,7 +144,11 @@ static struct dm_task *_setup_task_run(int task, struct dm_info *info,
case DM_DEVICE_TARGET_MSG:
return dmt; /* TARGET_MSG needs more local tweaking before task_run() */
case DM_DEVICE_LIST:
- if (!dm_task_set_newuuid(dmt, " ")) // new uuid has no meaning here
+ /* Use 'newuuid' only with DM version that supports it */
+ if (driver_version(vsn, sizeof(vsn)) &&
+ (sscanf(vsn, "%u.%u", &maj, &min) == 2) &&
+ (maj == 4 ? min >= 19 : maj > 4) &&
+ !dm_task_set_newuuid(dmt, " ")) // new uuid has no meaning here
log_warn("WARNING: Failed to query uuid with LIST.");
break;
default:
--
2.34.1

View File

@ -1,38 +0,0 @@
From a65f8e0a62b9ab3c2fc909a63abfa0e933619a8c Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 19 May 2021 14:36:40 -0500
Subject: [PATCH 07/33] enable command syntax for thin and writecache
converting an LV with a writecache to thin pool data in
addition to previous attaching writecache to thin pool data
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/command-lines.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 1107c1e026e1..67c37ffd033b 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -534,7 +534,7 @@ RULE: all and lv_is_visible
---
-lvconvert --type thin-pool LV_linear_striped_raid_cache_error_zero
+lvconvert --type thin-pool LV_linear_striped_raid_cache_writecache_error_zero
OO: --stripes_long Number, --stripesize SizeKB,
OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...
@@ -566,7 +566,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long
# This command syntax is deprecated, and the primary forms
# of creating a pool or swapping metadata should be used.
-lvconvert --thinpool LV_linear_striped_raid_cache_thinpool
+lvconvert --thinpool LV_linear_striped_raid_cache_writecache_thinpool
OO: --stripes_long Number, --stripesize SizeKB,
OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...
--
1.8.3.1

View File

@ -0,0 +1,29 @@
From c2679f76e5c1733451361b593fa45ba9545250b1 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 15 Feb 2022 21:16:10 +0100
Subject: dev_manager: failing status is not internal error
Different target type for LV it's not an internal error.
i.e. when target type is replaced with 'error' type - it should be
reported as regular warning and not cause interruption of command with
internall error.
---
lib/activate/dev_manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 3fd6aaff76a9..4d18d9838736 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -204,7 +204,7 @@ static int _get_segment_status_from_target_params(const char *target_name,
/* If kernel's type isn't an exact match is it compatible? */
(!segtype->ops->target_status_compatible ||
!segtype->ops->target_status_compatible(target_name))) {
- log_warn(INTERNAL_ERROR "WARNING: Segment type %s found does not match expected type %s for %s.",
+ log_warn("WARNING: Detected %s segment type does not match expected type %s for %s.",
target_name, segtype->name, display_lvname(seg_status->seg->lv));
return 0;
}
--
2.34.1

View File

@ -1,161 +0,0 @@
From 4a746f7ffcc8e61c9cb5ce9f9e8a061d1ef6b28e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 24 May 2021 16:08:27 -0500
Subject: [PATCH 08/33] lvremove: fix removing thin pool with writecache on
data
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/metadata/lv_manip.c | 19 +++++++++
lib/metadata/metadata-exported.h | 2 +
lib/metadata/thin_manip.c | 12 ++++++
test/shell/lvremove-thindata-caches.sh | 71 ++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+)
create mode 100644 test/shell/lvremove-thindata-caches.sh
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 508f78c132d0..37dd3611dde7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6692,6 +6692,25 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
}
+ /* if thin pool data lv is writecache, then detach and remove the writecache */
+ if (lv_is_thin_pool(lv)) {
+ struct logical_volume *data_lv = data_lv_from_thin_pool(lv);
+
+ if (data_lv && lv_is_writecache(data_lv)) {
+ struct logical_volume *cachevol_lv = first_seg(data_lv)->writecache;
+
+ if (!lv_detach_writecache_cachevol(data_lv, 1)) {
+ log_error("Failed to detach writecache from %s", display_lvname(data_lv));
+ return 0;
+ }
+
+ if (!lv_remove_single(cmd, cachevol_lv, force, 1)) {
+ log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
+ }
+ }
+
if (lv_is_writecache(lv)) {
struct logical_volume *cachevol_lv = first_seg(lv)->writecache;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 52062a1002da..9ac3c677ed82 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -928,6 +928,8 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
int vg_set_pool_metadata_spare(struct logical_volume *lv);
int vg_remove_pool_metadata_spare(struct volume_group *vg);
+struct logical_volume *data_lv_from_thin_pool(struct logical_volume *pool_lv);
+
int attach_thin_external_origin(struct lv_segment *seg,
struct logical_volume *external_lv);
int detach_thin_external_origin(struct lv_segment *seg);
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 451c382600f7..6ce88bd3d6ee 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -21,6 +21,18 @@
#include "lib/config/defaults.h"
#include "lib/display/display.h"
+struct logical_volume *data_lv_from_thin_pool(struct logical_volume *pool_lv)
+{
+ struct lv_segment *seg_thinpool = first_seg(pool_lv);
+
+ if (!seg_thinpool || !seg_is_thin_pool(seg_thinpool)) {
+ log_error(INTERNAL_ERROR "data_lv_from_thin_pool arg not thin pool %s", pool_lv->name);
+ return NULL;
+ }
+
+ return seg_thinpool->areas[0].u.lv.lv;
+}
+
/* TODO: drop unused no_update */
int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
struct logical_volume *lv, uint32_t delete_id,
diff --git a/test/shell/lvremove-thindata-caches.sh b/test/shell/lvremove-thindata-caches.sh
new file mode 100644
index 000000000000..ba099c373b32
--- /dev/null
+++ b/test/shell/lvremove-thindata-caches.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017-2020 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 10 0 || skip
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+aux prepare_devs 6 70 # want 64M of usable space from each dev
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6"
+
+# lv1 is thinpool LV: 128M
+# lv2 is fast LV: 64M
+# lv3 is thin LV: 1G
+
+#
+# Test lvremove of a thinpool that uses cache|writecache on data
+#
+
+# attach writecache to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type writecache --cachevol $lv2 $vg/$lv1
+lvchange -ay $vg/$lv1
+lvs -a $vg
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache/writeback (cachevol) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache/writethrough (cachevol) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache (cachepool) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -y --type cache-pool -n $lv2 -L64M --poolmetadataspare n $vg "$dev3" "$dev6"
+lvconvert -y --type cache --cachepool $lv2 --poolmetadataspare n $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+vgremove -f $vg
+
--
1.8.3.1

View File

@ -0,0 +1,26 @@
From d2e7a05573f54750d13c1154036ae2c67478539b Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 8 Feb 2022 19:17:30 +0100
Subject: clang: add extra check
Make clang happier.
---
lib/metadata/metadata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index db0e511ec8ea..1cda1888f356 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2197,7 +2197,7 @@ static int _validate_lock_args_chars(const char *lock_args)
static int _validate_vg_lock_args(struct volume_group *vg)
{
- if (!_validate_lock_args_chars(vg->lock_args)) {
+ if (!vg->lock_args || !_validate_lock_args_chars(vg->lock_args)) {
log_error(INTERNAL_ERROR "VG %s has invalid lock_args chars", vg->name);
return 0;
}
--
2.34.1

View File

@ -1,37 +0,0 @@
From b725b5ea6ecfeef428fd7ffcd6855a38378d761b Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 26 May 2021 00:19:28 +0200
Subject: [PATCH 09/33] vdo: fix preload of kvdo
Commit 5bf1dba9eb8a8b77410e386e59dadeb27801b14e broke load of kvdo
kernel module - correct it by loading kvdo instead of trying dm-vdo.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/activate/activate.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 71db98191506..6bda7385ba5c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -574,13 +574,9 @@ int module_present(struct cmd_context *cmd, const char *target_name)
}
#ifdef MODPROBE_CMD
- if (strcmp(target_name, MODULE_NAME_VDO) == 0) {
- argv[1] = target_name; /* ATM kvdo is without dm- prefix */
- if ((ret = exec_cmd(cmd, argv, NULL, 0)))
- return ret;
- }
-
- if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
+ if (strcmp(target_name, TARGET_NAME_VDO) == 0)
+ argv[1] = MODULE_NAME_VDO; /* ATM kvdo is without dm- prefix */
+ else if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
log_error("module_present module name too long: %s",
target_name);
return 0;
--
1.8.3.1

View File

@ -0,0 +1,27 @@
From 4fd76de4b69f8e5e6d5afa03d54cb4b8986c4bcc Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 16 Feb 2022 00:48:49 +0100
Subject: clang: possible better compilation with musl c
Try to help resolving reported compilation problem with
clang & musl C.
https://github.com/lvmteam/lvm2/issues/61
---
libdaemon/server/daemon-server.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 88905a7ddd5a..96cfc392e22b 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -18,6 +18,7 @@
#include <dlfcn.h>
#include <errno.h>
+#include <fcntl.h> /* help musl C */
#include <pthread.h>
#include <sys/file.h>
#include <sys/stat.h>
--
2.34.1

View File

@ -1,29 +0,0 @@
From 247f69f9aafe731ef85268da1e6ce817295b265d Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 2 Jun 2021 10:51:12 -0500
Subject: [PATCH 10/33] writecache: fix lv_on_pmem
dev_is_pmem on pv->dev requires a pv segment or it could segfault.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/metadata/metadata.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 110cbaed4e62..0b284435b41b 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4412,6 +4412,9 @@ int lv_on_pmem(struct logical_volume *lv)
dm_list_iterate_items(seg, &lv->segments) {
for (s = 0; s < seg->area_count; s++) {
+ if (seg_type(seg, s) != AREA_PV)
+ continue;
+
pv = seg_pv(seg, s);
if (dev_is_pmem(lv->vg->cmd->dev_types, pv->dev)) {
--
1.8.3.1

View File

@ -0,0 +1,26 @@
From fa7b67eeebfc28bce355991eebe1b5f21f075e9a Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 11 Feb 2022 23:55:08 +0100
Subject: dev_manager: do not query for open_count
Oepn count is not used along this code path.
---
lib/activate/dev_manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 4d18d9838736..feea06a47e53 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2268,7 +2268,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return 1;
}
- if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
+ if (!_info(dm->cmd, name, dlid, 0, 0, 0, &info, NULL, NULL))
return_0;
/*
--
2.34.1

View File

@ -1,36 +0,0 @@
From e7f107c24666c8577f30e530b74f1ce0347e459b Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 2 Jun 2021 11:12:20 -0500
Subject: [PATCH 11/33] writecache: don't pvmove device used by writecache
The existing check didn't cover the unusual case where the
cachevol exists on the same device as the origin LV.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/pvmove.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index da635a662d4c..bb372f7dcaeb 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -387,6 +387,15 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
return NULL;
}
+ if (lv_is_writecache(lv)) {
+ struct logical_volume *lv_cachevol = first_seg(lv)->writecache;
+ if (lv_is_on_pvs(lv_cachevol, source_pvl)) {
+ log_error("Unable to move device used for writecache cachevol %s.", display_lvname(lv_cachevol));
+ return NULL;
+ }
+
+ }
+
if (lv_is_raid(lv) && lv_raid_has_integrity(lv)) {
log_error("Unable to pvmove device used for raid with integrity.");
return NULL;
--
1.8.3.1

View File

@ -0,0 +1,55 @@
From d4a0816a5824dc375d662e76823ee8ed77bb9983 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 16 Feb 2022 00:33:32 +0100
Subject: dev_manager: use list info for preset devs
In some cases we can also use cached info obtained from DM_DEVICE_LIST
also to avoid extra ioctl check for present devices.
---
lib/activate/dev_manager.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index feea06a47e53..63bfd9b74b90 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2254,6 +2254,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
{
char *dlid, *name;
struct dm_info info, info2;
+ const struct dm_active_device *dev;
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
@@ -2262,15 +2263,20 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
if (!dm->cmd->disable_dm_devs &&
- dm->cmd->cache_dm_devs &&
- !dm_device_list_find_by_uuid(dm->cmd->cache_dm_devs, dlid, NULL)) {
- log_debug("Cached as not present %s.", name);
- return 1;
- }
-
- if (!_info(dm->cmd, name, dlid, 0, 0, 0, &info, NULL, NULL))
+ dm->cmd->cache_dm_devs) {
+ if (!dm_device_list_find_by_uuid(dm->cmd->cache_dm_devs, dlid, &dev)) {
+ log_debug("Cached as not present %s.", name);
+ return 1;
+ }
+ info = (struct dm_info) {
+ .exists = 1,
+ .major = dev->major,
+ .minor = dev->minor,
+ };
+ log_debug("Cached as present %s %s (%d:%d).",
+ name, dlid, info.major, info.minor);
+ } else if (!_info(dm->cmd, name, dlid, 0, 0, 0, &info, NULL, NULL))
return_0;
-
/*
* For top level volumes verify that existing device match
* requested major/minor and that major/minor pair is available for use
--
2.34.1

View File

@ -1,60 +0,0 @@
From 2bce6faed017df8da3e659eff3f42f39d25c7f09 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 2 Jun 2021 16:29:54 -0500
Subject: [PATCH 12/33] pvchange: fix file locking deadlock
Calling clear_hint_file() to invalidate hints would acquire
the hints flock before the global flock which could cause deadlock.
The lock order requires the global lock to be taken first.
pvchange was always invalidating hints, which was unnecessary;
only invalidate hints when changing a PV uuid. Because of the
lock ordering, take the global lock before clear_hint_file which
locks the hints file.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/pvchange.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/tools/pvchange.c b/tools/pvchange.c
index d6e35d66f9cc..04cbb428dde1 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -248,7 +248,32 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
set_pv_notify(cmd);
- clear_hint_file(cmd);
+ /*
+ * Changing a PV uuid is the only pvchange that invalidates hints.
+ * Invalidating hints (clear_hint_file) is called at the start of
+ * the command and takes the hints lock.
+ * The global lock must always be taken first, then the hints lock
+ * (the required lock ordering.)
+ *
+ * Because of these constraints, the global lock is taken ex here
+ * for any PV uuid change, even though the global lock is technically
+ * required only for changing an orphan PV (we don't know until later
+ * if the PV is an orphan). The VG lock is used when changing
+ * non-orphan PVs.
+ *
+ * For changes other than uuid on an orphan PV, the global lock is
+ * taken sh by process_each, then converted to ex in pvchange_single,
+ * which works because the hints lock is not held.
+ *
+ * (Eventually, perhaps always do lock_global(ex) here to simplify.)
+ */
+ if (arg_is_set(cmd, uuid_ARG)) {
+ if (!lock_global(cmd, "ex")) {
+ ret = ECMD_FAILED;
+ goto out;
+ }
+ clear_hint_file(cmd);
+ }
ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE, handle, _pvchange_single);
--
1.8.3.1

View File

@ -0,0 +1,95 @@
From ec2119beddde9e38681cb096b93048ee25034c1e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 16 Feb 2022 15:21:09 -0600
Subject: man lvmcache: add more writecache cachesettings info
---
man/lvmcache.7_main | 51 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 12 deletions(-)
diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main
index 8d7d3d17b766..dddd33cfa02c 100644
--- a/man/lvmcache.7_main
+++ b/man/lvmcache.7_main
@@ -243,15 +243,40 @@ can be used.
.
.SS dm-writecache settings
.
-Tunable parameters can be passed to the dm-writecache kernel module using
-the --cachesettings option when caching is started, e.g.
+To specify dm-writecache tunable settings on the command line, use:
+.br
+--cachesettings 'option=N' or
+.br
+--cachesettings 'option1=N option2=N ...'
+.P
+For example, --cachesettings 'high_watermark=90 writeback_jobs=4'.
+.P
+To include settings when caching is started, run:
.P
.nf
# lvconvert --type writecache --cachevol fast \\
- --cachesettings 'high_watermark=N writeback_jobs=N' vg/main
+ --cachesettings 'option=N' vg/main
+.fi
+.P
+To change settings for an existing writecache, run:
+.P
+.nf
+# lvchange --cachesettings 'option=N' vg/main
+.fi
+.P
+To clear all settings that have been applied, run:
+.P
+.nf
+# lvchange --cachesettings '' vg/main
+.fi
+.P
+To view the settings that are applied to a writecache LV, run:
+.P
+.nf
+# lvs -o cachesettings vg/main
.fi
.P
-Tunable options are:
+Tunable settings are:
.
.TP
high_watermark = <percent>
@@ -301,11 +326,14 @@ writecache. Adding cleaner=0 to the splitcache command will skip the
cleaner mode, and any required flushing is performed in device suspend.
.SS dm-writecache using metadata profiles
-
-Writecache allows to set a variety of options. Lots of these settings
-can be specified in lvm.conf or profile settings. You can prepare
-a number of different profiles in the \fI#DEFAULT_SYS_DIR#/profile\fP directory
-and just specify the metadata profile file name when writecaching LV.
+.
+In addition to specifying writecache settings on the command line, they
+can also be set in lvm.conf, or in a profile file, using the
+allocation/cache_settings/writecache config structure shown below.
+.P
+It's possible to prepare a number of different profile files in the
+\fI#DEFAULT_SYS_DIR#/profile\fP directory and specify the file name
+of the profile when starting writecache.
.P
.I Example
.nf
@@ -327,11 +355,10 @@ writeback_jobs=1024
EOF
.P
-# lvcreate -an -L10G --name wcache vg /dev/fast_ssd
-# lvcreate --type writecache -L10G --name main --cachevol wcache \\
+# lvcreate -an -L10G --name fast vg /dev/fast_ssd
+# lvcreate --type writecache -L10G --name main --cachevol fast \\
--metadataprofile cache_writecache vg /dev/slow_hdd
.fi
-
.
.SS dm-cache with separate data and metadata LVs
.
--
2.34.1

View File

@ -1,222 +0,0 @@
From c64dbc7ee80963a02f82f3257963f90b471fa90e Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:09 +0800
Subject: [PATCH 13/33] tests: Enable the testing for IDM locking scheme
This patch is to introduce testing option LVM_TEST_LOCK_TYPE_IDM, with
specifying this option, the Seagate IDM lock manager will be launched as
backend for testing. Also add the prepare and remove shell scripts for
IDM.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/Makefile.in | 9 +++++++++
test/lib/aux.sh | 25 +++++++++++++++++++++++++
test/lib/flavour-udev-lvmlockd-idm.sh | 5 +++++
test/lib/inittest.sh | 3 ++-
test/shell/aa-lvmlockd-idm-prepare.sh | 20 ++++++++++++++++++++
test/shell/lvmlockd-lv-types.sh | 6 ++++++
test/shell/zz-lvmlockd-idm-remove.sh | 29 +++++++++++++++++++++++++++++
7 files changed, 96 insertions(+), 1 deletion(-)
create mode 100644 test/lib/flavour-udev-lvmlockd-idm.sh
create mode 100644 test/shell/aa-lvmlockd-idm-prepare.sh
create mode 100644 test/shell/zz-lvmlockd-idm-remove.sh
diff --git a/test/Makefile.in b/test/Makefile.in
index e4cd3aac5116..662974be6ccb 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -85,6 +85,7 @@ help:
@echo " check_all_lvmpolld Run all tests with lvmpolld daemon."
@echo " check_lvmlockd_sanlock Run tests with lvmlockd and sanlock."
@echo " check_lvmlockd_dlm Run tests with lvmlockd and dlm."
+ @echo " check_lvmlockd_idm Run tests with lvmlockd and idm."
@echo " check_lvmlockd_test Run tests with lvmlockd --test."
@echo " run-unit-test Run only unit tests (root not needed)."
@echo " clean Clean dir."
@@ -169,6 +170,13 @@ check_lvmlockd_dlm: .tests-stamp
endif
ifeq ("@BUILD_LVMLOCKD@", "yes")
+check_lvmlockd_idm: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir $(LVM_TEST_RESULTS) \
+ --flavours udev-lvmlockd-idm --only shell/aa-lvmlockd-idm-prepare.sh,$(T),shell/zz-lvmlockd-idm-remove.sh --skip $(S)
+endif
+
+ifeq ("@BUILD_LVMLOCKD@", "yes")
check_lvmlockd_test: .tests-stamp
VERBOSE=$(VERBOSE) ./lib/runner \
--testdir . --outdir $(LVM_TEST_RESULTS) \
@@ -189,6 +197,7 @@ LIB_FLAVOURS = \
flavour-udev-lvmpolld\
flavour-udev-lvmlockd-sanlock\
flavour-udev-lvmlockd-dlm\
+ flavour-udev-lvmlockd-idm\
flavour-udev-lvmlockd-test\
flavour-udev-vanilla
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 1a1f11a1d48f..97c7ac68b77b 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -119,6 +119,20 @@ prepare_sanlock() {
fi
}
+prepare_idm() {
+ if pgrep seagate_ilm; then
+ echo "Cannot run while existing seagate_ilm process exists"
+ exit 1
+ fi
+
+ seagate_ilm -D 0 -l 0 -L 7 -E 7 -S 7
+
+ if ! pgrep seagate_ilm; then
+ echo "Failed to start seagate_ilm"
+ exit 1
+ fi
+}
+
prepare_lvmlockd() {
if pgrep lvmlockd ; then
echo "Cannot run while existing lvmlockd process exists"
@@ -135,6 +149,11 @@ prepare_lvmlockd() {
echo "starting lvmlockd for dlm"
lvmlockd
+ elif test -n "$LVM_TEST_LOCK_TYPE_IDM"; then
+ # make check_lvmlockd_idm
+ echo "starting lvmlockd for idm"
+ lvmlockd -g idm
+
elif test -n "$LVM_TEST_LVMLOCKD_TEST_DLM"; then
# make check_lvmlockd_test
echo "starting lvmlockd --test (dlm)"
@@ -144,6 +163,12 @@ prepare_lvmlockd() {
# FIXME: add option for this combination of --test and sanlock
echo "starting lvmlockd --test (sanlock)"
lvmlockd --test -g sanlock -o 2
+
+ elif test -n "$LVM_TEST_LVMLOCKD_TEST_IDM"; then
+ # make check_lvmlockd_test
+ echo "starting lvmlockd --test (idm)"
+ lvmlockd --test -g idm
+
else
echo "not starting lvmlockd"
exit 0
diff --git a/test/lib/flavour-udev-lvmlockd-idm.sh b/test/lib/flavour-udev-lvmlockd-idm.sh
new file mode 100644
index 000000000000..e9f8908dfb49
--- /dev/null
+++ b/test/lib/flavour-udev-lvmlockd-idm.sh
@@ -0,0 +1,5 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_LVMLOCKD=1
+export LVM_TEST_LOCK_TYPE_IDM=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 0fd6517103a5..6b4bcb348010 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -40,6 +40,7 @@ LVM_TEST_LVMPOLLD=${LVM_TEST_LVMPOLLD-}
LVM_TEST_DEVICES_FILE=${LVM_TEST_DEVICES_FILE-}
LVM_TEST_LOCK_TYPE_DLM=${LVM_TEST_LOCK_TYPE_DLM-}
LVM_TEST_LOCK_TYPE_SANLOCK=${LVM_TEST_LOCK_TYPE_SANLOCK-}
+LVM_TEST_LOCK_TYPE_IDM=${LVM_TEST_LOCK_TYPE_IDM-}
SKIP_WITHOUT_CLVMD=${SKIP_WITHOUT_CLVMD-}
SKIP_WITH_CLVMD=${SKIP_WITH_CLVMD-}
@@ -64,7 +65,7 @@ unset CDPATH
export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG
export LVM_TEST_LVMLOCKD LVM_TEST_LVMLOCKD_TEST
-export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK
+export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK LVM_TEST_LOCK_TYPE_IDM
export LVM_TEST_DEVICES_FILE
# grab some common utilities
. lib/utils
diff --git a/test/shell/aa-lvmlockd-idm-prepare.sh b/test/shell/aa-lvmlockd-idm-prepare.sh
new file mode 100644
index 000000000000..8faff3bc2c66
--- /dev/null
+++ b/test/shell/aa-lvmlockd-idm-prepare.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate. 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 v2.
+#
+# 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
+
+test_description='Set up things to run tests with idm'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+
+aux prepare_idm
+aux prepare_lvmlockd
diff --git a/test/shell/lvmlockd-lv-types.sh b/test/shell/lvmlockd-lv-types.sh
index 6138e5623d77..ee350b1c68a3 100644
--- a/test/shell/lvmlockd-lv-types.sh
+++ b/test/shell/lvmlockd-lv-types.sh
@@ -36,6 +36,12 @@ LOCKARGS2="dlm"
LOCKARGS3="dlm"
fi
+if test -n "$LVM_TEST_LOCK_TYPE_IDM" ; then
+LOCKARGS1="idm"
+LOCKARGS2="idm"
+LOCKARGS3="idm"
+fi
+
aux prepare_devs 5
vgcreate --shared $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
diff --git a/test/shell/zz-lvmlockd-idm-remove.sh b/test/shell/zz-lvmlockd-idm-remove.sh
new file mode 100644
index 000000000000..25943a579d7e
--- /dev/null
+++ b/test/shell/zz-lvmlockd-idm-remove.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate. 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 v2.
+#
+# 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
+
+test_description='Remove the idm test setup'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+
+# FIXME: collect debug logs (only if a test failed?)
+# lvmlockctl -d > lvmlockd-debug.txt
+# dlm_tool dump > dlm-debug.txt
+
+lvmlockctl --stop-lockspaces
+sleep 1
+killall lvmlockd
+sleep 1
+killall lvmlockd || true
+sleep 1
+killall seagate_ilm
--
1.8.3.1

View File

@ -0,0 +1,37 @@
From 96c99d647ef783abcd26a1f3f63f12e033195633 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 16 Feb 2022 15:36:44 -0600
Subject: man: update cachesettings option description
to be more consistent with man page description
---
tools/args.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 3f4580b8d9eb..56669645d2a1 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -862,12 +862,13 @@ arg(cachepolicy_ARG, '\0', "cachepolicy", string_VAL, 0, 0,
"See \\fBlvmcache\\fP(7) for more information.\n")
arg(cachesettings_ARG, '\0', "cachesettings", string_VAL, ARG_GROUPABLE, 0,
- "Specifies tunable values for a cache LV in \"Key = Value\" form.\n"
- "Repeat this option to specify multiple values.\n"
- "(The default values should usually be adequate.)\n"
- "The special string value \\fBdefault\\fP switches\n"
- "settings back to their default kernel values and removes\n"
- "them from the list of settings stored in LVM metadata.\n"
+ "Specifies tunable kernel options for dm-cache or dm-writecache LVs.\n"
+ "Use the form 'option=value' or 'option1=value option2=value', or\n"
+ "repeat --cachesettings for each option being set.\n"
+ "These settings override the default kernel behaviors which are\n"
+ "usually adequate. To remove cachesettings and revert to the default\n"
+ "kernel behaviors, use --cachesettings 'default' for dm-cache or\n"
+ "an empty string --cachesettings '' for dm-writecache.\n"
"See \\fBlvmcache\\fP(7) for more information.\n")
arg(unconfigured_ARG, '\0', "unconfigured", 0, 0, 0,
--
2.34.1

View File

@ -1,87 +0,0 @@
From 759b0392d5f0f15e7e503ae1b3ef82ea7b4df0c1 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:10 +0800
Subject: [PATCH 14/33] tests: Support multiple backing devices
In current implementation, the option "LVM_TEST_BACKING_DEVICE" only
supports to specify one backing device; this patch is to extend the
option to support multiple backing devices by using comma as separator,
e.g. below command specifies two backing devices:
make check_lvmlockd_idm LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3
This can allow the testing works on multiple drives and verify the
locking scheme if can work as expected for multiple drives case. For
example, for Seagate IDM locking scheme, if a VG uses two PVs, every PV
is resident on a drive, thus the locking operations will be sent to two
drives respectively; so the extension for "LVM_TEST_BACKING_DEVICE" can
help to verify different drive configurations for locking.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/lib/aux.sh | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 97c7ac68b77b..a592dad813b7 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -901,11 +901,22 @@ prepare_backing_dev() {
local size=${1=32}
shift
+ if test -n "$LVM_TEST_BACKING_DEVICE"; then
+ IFS=',' read -r -a BACKING_DEVICE_ARRAY <<< "$LVM_TEST_BACKING_DEVICE"
+
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ if test ! -b "$d"; then
+ echo "Device $d doesn't exist!"
+ return 1
+ fi
+ done
+ fi
+
if test -f BACKING_DEV; then
BACKING_DEV=$(< BACKING_DEV)
return 0
- elif test -b "$LVM_TEST_BACKING_DEVICE"; then
- BACKING_DEV=$LVM_TEST_BACKING_DEVICE
+ elif test -n "$LVM_TEST_BACKING_DEVICE"; then
+ BACKING_DEV=${BACKING_DEVICE_ARRAY[0]}
echo "$BACKING_DEV" > BACKING_DEV
return 0
elif test "${LVM_TEST_PREFER_BRD-1}" = "1" && \
@@ -953,7 +964,14 @@ prepare_devs() {
local dev="$DM_DEV_DIR/mapper/$name"
DEVICES[$count]=$dev
count=$(( count + 1 ))
- echo 0 $size linear "$BACKING_DEV" $(( ( i - 1 ) * size + ( header_shift * 2048 ) )) > "$name.table"
+ # If the backing device number can meet the requirement for PV devices,
+ # then allocate a dedicated backing device for PV; otherwise, rollback
+ # to use single backing device for device-mapper.
+ if [ -n "$LVM_TEST_BACKING_DEVICE" ] && [ $n -le ${#BACKING_DEVICE_ARRAY[@]} ]; then
+ echo 0 $size linear "${BACKING_DEVICE_ARRAY[$(( count - 1 ))]}" $(( header_shift * 2048 )) > "$name.table"
+ else
+ echo 0 $size linear "$BACKING_DEV" $(( ( i - 1 ) * size + ( header_shift * 2048 ) )) > "$name.table"
+ fi
dmsetup create -u "TEST-$name" "$name" "$name.table" || touch CREATE_FAILED &
test -f CREATE_FAILED && break;
done
@@ -971,6 +989,13 @@ prepare_devs() {
return $?
fi
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
+ cnt=$(( cnt < 1000 ? cnt : 1000 ))
+ dd if=/dev/zero of="$d" bs=1MB count=$cnt
+ wipefs -a "$d" 2>/dev/null || true
+ done
+
# non-ephemeral devices need to be cleared between tests
test -f LOOP -o -f RAMDISK || for d in "${DEVICES[@]}"; do
# ensure disk header is always zeroed
--
1.8.3.1

View File

@ -0,0 +1,35 @@
From 6144dac897728a4857294d70645df8ed7a5ff11f Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 21 Feb 2022 11:35:58 -0600
Subject: man lvmcache: mention writecache memory usage
---
man/lvmcache.7_main | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main
index dddd33cfa02c..ce440bf49983 100644
--- a/man/lvmcache.7_main
+++ b/man/lvmcache.7_main
@@ -240,6 +240,18 @@ The writecache block size should be chosen to match the xfs sectsz value.
It is also possible to specify a sector size of 4096 to mkfs.xfs when
creating the file system. In this case the writecache block size of 4096
can be used.
+.P
+.SS dm-writecache memory usage
+.P
+The amount of main system memory used by dm-writecache can be a factor
+when selecting the writecache cachevol size and the writecache block size.
+.P
+.IP \[bu] 2
+writecache block size 4096: each 100 GiB of writecache cachevol uses
+slighly over 2 GiB of system memory.
+.IP \[bu] 2
+writecache block size 512: each 100 GiB of writecache cachevol uses
+a little over 16 GiB of system memory.
.
.SS dm-writecache settings
.
--
2.34.1

View File

@ -1,65 +0,0 @@
From 2097c27c05de30003850eb667b9cf21b3181fddf Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:11 +0800
Subject: [PATCH 15/33] tests: Cleanup idm context when prepare devices
For testing idm locking scheme, it's good to cleanup the idm context
before run the test cases. This can give a clean environment for the
testing.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/lib/aux.sh | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a592dad813b7..bb189f466cef 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -897,6 +897,20 @@ wipefs_a() {
udev_wait
}
+cleanup_idm_context() {
+ local dev=$1
+
+ if [ -n "$LVM_TEST_LOCK_TYPE_IDM" ]; then
+ sg_dev=`sg_map26 ${dev}`
+ echo "Cleanup IDM context for drive ${dev} ($sg_dev)"
+ sg_raw -v -r 512 -o /tmp/idm_tmp_data.bin $sg_dev \
+ 88 00 01 00 00 00 00 20 FF 01 00 00 00 01 00 00
+ sg_raw -v -s 512 -i /tmp/idm_tmp_data.bin $sg_dev \
+ 8E 00 FF 00 00 00 00 00 00 00 00 00 00 01 00 00
+ rm /tmp/idm_tmp_data.bin
+ fi
+}
+
prepare_backing_dev() {
local size=${1=32}
shift
@@ -989,12 +1003,15 @@ prepare_devs() {
return $?
fi
- for d in "${BACKING_DEVICE_ARRAY[@]}"; do
- cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
- cnt=$(( cnt < 1000 ? cnt : 1000 ))
- dd if=/dev/zero of="$d" bs=1MB count=$cnt
- wipefs -a "$d" 2>/dev/null || true
- done
+ if [ -n "$LVM_TEST_BACKING_DEVICE" ]; then
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
+ cnt=$(( cnt < 1000 ? cnt : 1000 ))
+ dd if=/dev/zero of="$d" bs=1MB count=$cnt
+ wipefs -a "$d" 2>/dev/null || true
+ cleanup_idm_context "$d"
+ done
+ fi
# non-ephemeral devices need to be cleared between tests
test -f LOOP -o -f RAMDISK || for d in "${DEVICES[@]}"; do
--
1.8.3.1

View File

@ -1,33 +0,0 @@
From 5b361b197e1a3fbbc5419b9c46f19539c2b7305c Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:12 +0800
Subject: [PATCH 16/33] tests: Add checking for lvmlockd log
Add checking for lvmlockd log, this can be used for the test cases which
are interested in the interaction with lvmlockd.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/lib/check.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 8493bde83e1d..1f261940af3b 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -456,6 +456,11 @@ grep_dmsetup() {
grep -q "${@:3}" out || die "Expected output \"" "${@:3}" "\" from dmsetup $1 not found!"
}
+grep_lvmlockd_dump() {
+ lvmlockctl --dump | tee out
+ grep -q "${@:1}" out || die "Expected output \"" "${@:1}" "\" from lvmlockctl --dump not found!"
+}
+
#set -x
unset LVM_VALGRIND
"$@"
--
1.8.3.1

View File

@ -0,0 +1,102 @@
From ac1f4bbbfd4c5f1387c3e0607f7d556409e7a4b4 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 21 Feb 2022 16:09:57 -0600
Subject: writecache: display block size from lvs
lvs was missing the ability to display writecache block size.
now possible with lvs -o writecache_block_size
---
lib/report/columns.h | 1 +
lib/report/properties.c | 2 ++
lib/report/report.c | 20 ++++++++++++++++++++
man/lvmcache.7_main | 4 ++++
test/shell/writecache-cache-blocksize.sh | 2 ++
5 files changed, 29 insertions(+)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 12b78b766f15..7e450dacef66 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -108,6 +108,7 @@ FIELD(LVS, lv, TIM, "RTime", lvid, 26, lvtimeremoved, lv_time_removed, "Removal
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
FIELD(LVS, lv, STR_LIST, "Modules", lvid, 0, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
FIELD(LVS, lv, BIN, "Historical", lvid, 0, lvhistorical, lv_historical, "Set if the LV is historical.", 0)
+FIELD(LVS, lv, NUM, "WCacheBlkSize", lvid, 0, writecache_block_size, writecache_block_size, "The writecache block size", 0)
/*
* End of LVS type fields
*/
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 12ea890f4b09..6f302360f5d0 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -353,6 +353,8 @@ GET_PV_STR_PROPERTY_FN(pv_device_id_type, pv->device_id_type)
#define _writecache_writeback_blocks_get prop_not_implemented_get
#define _writecache_error_set prop_not_implemented_set
#define _writecache_error_get prop_not_implemented_get
+#define _writecache_block_size_set prop_not_implemented_set
+#define _writecache_block_size_get prop_not_implemented_get
#define _vdo_operating_mode_set prop_not_implemented_set
#define _vdo_operating_mode_get prop_not_implemented_get
diff --git a/lib/report/report.c b/lib/report/report.c
index 60df417a40f5..c06b22674f21 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -3346,6 +3346,26 @@ static int _integritymismatches_disp(struct dm_report *rh __attribute__((unused)
return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
+static int _writecache_block_size_disp(struct dm_report *rh __attribute__((unused)),
+ struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data,
+ void *private __attribute__((unused)))
+{
+ struct logical_volume *lv = (struct logical_volume *) data;
+ uint32_t bs = 0;
+
+ if (lv_is_writecache(lv)) {
+ struct lv_segment *seg = first_seg(lv);
+ bs = seg->writecache_block_size;
+ }
+
+ if (!bs)
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
+
+ return dm_report_field_uint32(rh, field, &bs);
+}
+
static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main
index ce440bf49983..8b8289c74ac7 100644
--- a/man/lvmcache.7_main
+++ b/man/lvmcache.7_main
@@ -241,6 +241,10 @@ It is also possible to specify a sector size of 4096 to mkfs.xfs when
creating the file system. In this case the writecache block size of 4096
can be used.
.P
+The writecache block size is displayed by the command:
+.br
+lvs -o writecacheblocksize VG/LV
+.P
.SS dm-writecache memory usage
.P
The amount of main system memory used by dm-writecache can be a factor
diff --git a/test/shell/writecache-cache-blocksize.sh b/test/shell/writecache-cache-blocksize.sh
index 2579ef7b7bac..4e17effe5f1f 100644
--- a/test/shell/writecache-cache-blocksize.sh
+++ b/test/shell/writecache-cache-blocksize.sh
@@ -222,6 +222,8 @@ vgextend $vg "$dev2"
lvcreate -n $lv1 -l 8 -an $vg "$dev1"
lvcreate -n $lv2 -l 4 -an $vg "$dev2"
lvconvert --yes --type writecache --cachevol $lv2 --cachesettings "block_size=4096" $vg/$lv1
+lvs -o writecacheblocksize $vg/$lv1 |tee out
+grep 4096 out
lvchange -ay $vg/$lv1
mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1" |tee out
grep "sectsz=4096" out
--
2.34.1

View File

@ -0,0 +1,134 @@
From 1126be8f8dbce482e82d8f98a7e7f4b7cd2cac34 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 24 Feb 2022 15:57:29 -0600
Subject: devices: simplify dev_cache_get_by_devt
remove unused args, and no callers need or want a
repeated dev_cache_scan if there is no dev from the
lookup.
---
lib/device/dev-cache.c | 60 ++++--------------------------------------
lib/device/dev-cache.h | 2 +-
lib/label/label.c | 6 ++---
3 files changed, 9 insertions(+), 59 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index d3fae494869d..1777628a81a0 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1577,63 +1577,13 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
return dev;
}
-struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct dev_filter *f, int *filtered)
+struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt)
{
- char path[PATH_MAX];
- const char *sysfs_dir;
- struct stat info;
- struct device *d = (struct device *) btree_lookup(_cache.devices, (uint32_t) dev);
- int ret;
-
- if (filtered)
- *filtered = 0;
-
- if (!d) {
- sysfs_dir = dm_sysfs_dir();
- if (sysfs_dir && *sysfs_dir) {
- /* First check if dev is sysfs to avoid useless scan */
- if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d",
- sysfs_dir, (int)MAJOR(dev), (int)MINOR(dev)) < 0) {
- log_error("dm_snprintf partition failed.");
- return NULL;
- }
-
- if (lstat(path, &info)) {
- log_debug("No sysfs entry for %d:%d errno %d at %s.",
- (int)MAJOR(dev), (int)MINOR(dev), errno, path);
- return NULL;
- }
- }
-
- log_debug_devs("Device num not found in dev_cache repeat dev_cache_scan for %d:%d",
- (int)MAJOR(dev), (int)MINOR(dev));
- dev_cache_scan(cmd);
- d = (struct device *) btree_lookup(_cache.devices, (uint32_t) dev);
-
- if (!d)
- return NULL;
- }
-
- if (d->flags & DEV_REGULAR)
- return d;
-
- if (!f)
- return d;
-
- ret = f->passes_filter(cmd, f, d, NULL);
-
- if (ret == -EAGAIN) {
- log_debug_devs("get device by number defer filter %s", dev_name(d));
- d->flags |= DEV_FILTER_AFTER_SCAN;
- ret = 1;
- }
-
- if (ret)
- return d;
-
- if (filtered)
- *filtered = 1;
+ struct device *dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devt);
+ if (dev)
+ return dev;
+ log_debug_devs("No devno %d:%d in dev cache.", (int)MAJOR(devt), (int)MINOR(devt));
return NULL;
}
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 449bfeb7511c..a88e3c282207 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -54,7 +54,7 @@ int dev_cache_has_scanned(void);
int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
-struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t device, struct dev_filter *f, int *filtered);
+struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
struct device *dev_hash_get(const char *name);
diff --git a/lib/label/label.c b/lib/label/label.c
index fe2bc8fec743..66d6e7db7a6e 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1134,7 +1134,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
dm_list_iterate_items(po, &pvs_online) {
if (po->dev)
continue;
- if (!(po->dev = dev_cache_get_by_devt(cmd, po->devno, NULL, NULL))) {
+ if (!(po->dev = dev_cache_get_by_devt(cmd, po->devno))) {
log_error("No device found for %d:%d PVID %s",
(int)MAJOR(po->devno), (int)MINOR(po->devno), po->pvid);
goto bad;
@@ -1722,7 +1722,7 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
if (lv_info(cmd, lv, 0, &lvinfo, 0, 0) && lvinfo.exists) {
/* FIXME: Still unclear what is it supposed to find */
devt = MKDEV(lvinfo.major, lvinfo.minor);
- if ((dev = dev_cache_get_by_devt(cmd, devt, NULL, NULL)))
+ if ((dev = dev_cache_get_by_devt(cmd, devt)))
label_scan_invalidate(dev);
}
}
@@ -1742,7 +1742,7 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
if (dm_dev->uuid &&
strncmp(dm_dev->uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1) == 0) {
devt = MKDEV(dm_dev->major, dm_dev->minor);
- if ((dev = dev_cache_get_by_devt(cmd, devt, NULL, NULL)))
+ if ((dev = dev_cache_get_by_devt(cmd, devt)))
label_scan_invalidate(dev);
}
/* ATM no further caching for any lvconvert command
--
2.34.1

View File

@ -1,83 +0,0 @@
From fe660467fa4c943bb0ce928e7af65572e2ddeddc Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:13 +0800
Subject: [PATCH 17/33] tests: stress: Add single thread stress testing
This patch is to add the stress testing, which loops to create LV,
activate and deactivate LV in the single thread.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/stress_single_thread.sh | 59 ++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 test/shell/stress_single_thread.sh
diff --git a/test/shell/stress_single_thread.sh b/test/shell/stress_single_thread.sh
new file mode 100644
index 000000000000..e18d4900b158
--- /dev/null
+++ b/test/shell/stress_single_thread.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_vg 3
+
+for i in {1..1000}
+do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg
+
+ # Set minor number
+ lvchange $vg/foo -My --major=255 --minor=123
+
+ # Activate logic volume
+ lvchange $vg/foo -a y
+
+ # Check device mapper
+ dmsetup info $vg-foo | tee info
+ grep -E "^Major, minor: *[0-9]+, 123" info
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg/foo
+
+ # Deactivate logic volume
+ lvchange $vg/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg -a ey
+
+ lvreduce -f -l-4 $vg/foo
+
+ lvchange -an $vg/foo
+ lvremove $vg/foo
+done
+
+vgremove -ff $vg
--
1.8.3.1

View File

@ -0,0 +1,467 @@
From 7e70041e324e1a4d49134a93323072e1b6ec661f Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 24 Feb 2022 16:03:21 -0600
Subject: devices: drop incorrect paths from aliases list
along with some basic checks for cases when a device
has no aliases.
lvm itself creates many situations where a struct device
has no valid paths, when it activates and opens an LV,
does something with it, e.g. zeroing, and then closes
and deactivates it. (dev-cache is intended for PVs, and
the use of LVs should be moved out of dev-cache in a
future patch.)
---
lib/device/dev-cache.c | 223 ++++++++++++++++++++++++++---------------
lib/device/dev-cache.h | 2 +-
lib/device/dev-io.c | 34 ++++---
lib/device/device.h | 3 -
4 files changed, 164 insertions(+), 98 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 1777628a81a0..8db28bd84a01 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -351,7 +351,7 @@ static int _add_alias(struct device *dev, const char *path, enum add_hash hash)
goto out;
}
- if (!(path = dm_pool_strdup(_cache.mem, path)) ||
+ if (!(path = _strdup(path)) ||
!(sl = _zalloc(sizeof(*sl)))) {
log_error("Failed to add allias to dev cache.");
return 0;
@@ -1162,6 +1162,17 @@ static int _insert(const char *path, const struct stat *info,
return 1;
}
+static void _drop_all_aliases(struct device *dev)
+{
+ struct dm_str_list *strl, *strl2;
+
+ dm_list_iterate_items_safe(strl, strl2, &dev->aliases) {
+ log_debug("Drop alias for %d:%d %s.", (int)MAJOR(dev->dev), (int)MINOR(dev->dev), strl->str);
+ dm_hash_remove(_cache.names, strl->str);
+ dm_list_del(&strl->list);
+ }
+}
+
void dev_cache_scan(struct cmd_context *cmd)
{
log_debug_devs("Creating list of system devices.");
@@ -1371,59 +1382,6 @@ int dev_cache_add_dir(const char *path)
return 1;
}
-/* Check cached device name is still valid before returning it */
-/* This should be a rare occurrence */
-/* set quiet if the cache is expected to be out-of-date */
-/* FIXME Make rest of code pass/cache struct device instead of dev_name */
-const char *dev_name_confirmed(struct device *dev, int quiet)
-{
- struct stat buf;
- const char *name;
- int r;
-
- if ((dev->flags & DEV_REGULAR))
- return dev_name(dev);
-
- while ((r = stat(name = dm_list_item(dev->aliases.n,
- struct dm_str_list)->str, &buf)) ||
- (buf.st_rdev != dev->dev)) {
- if (r < 0) {
- if (quiet)
- log_sys_debug("stat", name);
- else
- log_sys_error("stat", name);
- }
- if (quiet)
- log_debug_devs("Path %s no longer valid for device(%d,%d)",
- name, (int) MAJOR(dev->dev),
- (int) MINOR(dev->dev));
- else
- log_warn("Path %s no longer valid for device(%d,%d)",
- name, (int) MAJOR(dev->dev),
- (int) MINOR(dev->dev));
-
- /* Remove the incorrect hash entry */
- dm_hash_remove(_cache.names, name);
-
- /* Leave list alone if there isn't an alternative name */
- /* so dev_name will always find something to return. */
- /* Otherwise add the name to the correct device. */
- if (dm_list_size(&dev->aliases) > 1) {
- dm_list_del(dev->aliases.n);
- if (!r)
- _insert(name, &buf, 0, obtain_device_list_from_udev());
- continue;
- }
-
- /* Scanning issues this inappropriately sometimes. */
- log_debug_devs("Aborting - please provide new pathname for what "
- "used to be %s", name);
- return NULL;
- }
-
- return dev_name(dev);
-}
-
struct device *dev_hash_get(const char *name)
{
return (struct device *) dm_hash_lookup(_cache.names, name);
@@ -1452,26 +1410,23 @@ static void _remove_alias(struct device *dev, const char *name)
* deactivated LV. Those old paths are all invalid and are dropped here.
*/
-static void _verify_aliases(struct device *dev, const char *newname)
+static void _verify_aliases(struct device *dev)
{
struct dm_str_list *strl, *strl2;
struct stat st;
dm_list_iterate_items_safe(strl, strl2, &dev->aliases) {
- /* newname was just stat'd and added by caller */
- if (newname && !strcmp(strl->str, newname))
- continue;
-
if (stat(strl->str, &st) || (st.st_rdev != dev->dev)) {
- log_debug("Drop invalid path %s for %d:%d (new path %s).",
- strl->str, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), newname ?: "");
+ log_debug("Drop alias for %d:%d invalid path %s %d:%d.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), strl->str,
+ (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev));
dm_hash_remove(_cache.names, strl->str);
dm_list_del(&strl->list);
}
}
}
-struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f)
+static struct device *_dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f, int existing)
{
struct device *dev = (struct device *) dm_hash_lookup(_cache.names, name);
struct stat st;
@@ -1485,13 +1440,18 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
if (dev && (dev->flags & DEV_REGULAR))
return dev;
+ if (dev && dm_list_empty(&dev->aliases)) {
+ /* shouldn't happen */
+ log_warn("Ignoring dev with no valid paths for %s.", name);
+ return NULL;
+ }
+
/*
- * The requested path is invalid, remove any dev-cache
- * info for it.
+ * The requested path is invalid, remove any dev-cache info for it.
*/
if (stat(name, &st)) {
if (dev) {
- log_print("Device path %s is invalid for %d:%d %s.",
+ log_debug("Device path %s is invalid for %d:%d %s.",
name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev));
dm_hash_remove(_cache.names, name);
@@ -1499,11 +1459,17 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
_remove_alias(dev, name);
/* Remove any other names in dev->aliases that are incorrect. */
- _verify_aliases(dev, NULL);
+ _verify_aliases(dev);
}
return NULL;
}
+ if (dev && dm_list_empty(&dev->aliases)) {
+ /* shouldn't happen */
+ log_warn("Ignoring dev with no valid paths for %s.", name);
+ return NULL;
+ }
+
if (!S_ISBLK(st.st_mode)) {
log_debug("Not a block device %s.", name);
return NULL;
@@ -1514,26 +1480,110 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
* Remove incorrect info and then add new dev-cache entry.
*/
if (dev && (st.st_rdev != dev->dev)) {
- log_debug("Device path %s does not match %d:%d %s.",
- name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev));
+ struct device *dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) st.st_rdev);
+
+ /*
+ * lvm commands create this condition when they
+ * activate/deactivate LVs combined with creating new LVs.
+ * The command does not purge dev structs when deactivating
+ * an LV (which it probably should do), but the better
+ * approach would be not using dev-cache at all for LVs.
+ */
- dm_hash_remove(_cache.names, name);
+ log_debug("Dropping aliases for device entry %d:%d %s for new device %d:%d %s.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev_name(dev),
+ (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev), name);
- _remove_alias(dev, name);
+ _drop_all_aliases(dev);
- /* Remove any other names in dev->aliases that are incorrect. */
- _verify_aliases(dev, NULL);
+ if (dev_by_devt) {
+ log_debug("Dropping aliases for device entry %d:%d %s for new device %d:%d %s.",
+ (int)MAJOR(dev_by_devt->dev), (int)MINOR(dev_by_devt->dev), dev_name(dev_by_devt),
+ (int)MAJOR(st.st_rdev), (int)MINOR(st.st_rdev), name);
- /* Add new dev-cache entry next. */
- dev = NULL;
+ _drop_all_aliases(dev_by_devt);
+ }
+
+#if 0
+ /*
+ * I think only lvm's own dm devs should be added here, so use
+ * a warning to look for any other unknown cases.
+ */
+ if (MAJOR(st.st_rdev) != cmd->dev_types->device_mapper_major) {
+ log_warn("WARNING: new device appeared %d:%d %s",
+ (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
+ }
+#endif
+
+ if (!_insert_dev(name, st.st_rdev))
+ return_NULL;
+
+ /* Get the struct dev that was just added. */
+ dev = (struct device *) dm_hash_lookup(_cache.names, name);
+
+ if (!dev) {
+ log_error("Failed to get device %s", name);
+ return NULL;
+ }
+
+ goto out;
}
+ if (dev && dm_list_empty(&dev->aliases)) {
+ /* shouldn't happen */
+ log_warn("Ignoring dev with no valid paths for %s.", name);
+ return NULL;
+ }
+
+ if (!dev && existing)
+ return_NULL;
+
/*
- * Either add a new struct dev for st_rdev and name,
- * or add name as a new alias for an existing struct dev
- * for st_rdev.
+ * This case should never be hit for a PV. It should only
+ * happen when the command is opening a new LV it has created.
+ * Add an arg to all callers indicating when the arg should be
+ * new (for an LV) and not existing.
+ * FIXME: fix this further by not using dev-cache struct devs
+ * at all for new dm devs (LVs) that lvm uses. Make the
+ * dev-cache contain only devs for PVs.
+ * Places to fix that use a dev for LVs include:
+ * . lv_resize opening lv to discard
+ * . wipe_lv opening lv to zero it
+ * . _extend_sanlock_lv opening lv to extend it
+ * . _write_log_header opening lv to write header
+ * Also, io to LVs should not go through bcache.
+ * bcache should contain only labels and metadata
+ * scanned from PVs.
*/
if (!dev) {
+ /*
+ * This case should only be used for new devices created by this
+ * command (opening LVs it's created), so if a dev exists for the
+ * dev_t referenced by the name, then drop all aliases for before
+ * _insert_dev adds the new name. lvm commands actually hit this
+ * fairly often when it uses some LV, deactivates the LV, then
+ * creates some new LV which ends up with the same major:minor.
+ * Without dropping the aliases, it's plausible that lvm commands
+ * could end up using the wrong dm device.
+ */
+ struct device *dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) st.st_rdev);
+ if (dev_by_devt) {
+ log_debug("Dropping aliases for %d:%d before adding new path %s.",
+ (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
+ _drop_all_aliases(dev_by_devt);
+ }
+
+#if 0
+ /*
+ * I think only lvm's own dm devs should be added here, so use
+ * a warning to look for any other unknown cases.
+ */
+ if (MAJOR(st.st_rdev) != cmd->dev_types->device_mapper_major) {
+ log_warn("WARNING: new device appeared %d:%d %s",
+ (int)MAJOR(st.st_rdev), (int)(MINOR(st.st_rdev)), name);
+ }
+#endif
+
if (!_insert_dev(name, st.st_rdev))
return_NULL;
@@ -1544,10 +1594,9 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
log_error("Failed to get device %s", name);
return NULL;
}
-
- _verify_aliases(dev, name);
}
+ out:
/*
* The caller passed a filter if they only want the dev if it
* passes filters.
@@ -1577,6 +1626,16 @@ struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct d
return dev;
}
+struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f)
+{
+ return _dev_cache_get(cmd, name, f, 1);
+}
+
+struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f)
+{
+ return _dev_cache_get(cmd, name, f, 0);
+}
+
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt)
{
struct device *dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devt);
@@ -1653,8 +1712,10 @@ int dev_fd(struct device *dev)
const char *dev_name(const struct device *dev)
{
- return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct dm_str_list)->str :
- unknown_device_name();
+ if (dev && dev->aliases.n && !dm_list_empty(&dev->aliases))
+ return dm_list_item(dev->aliases.n, struct dm_str_list)->str;
+ else
+ return unknown_device_name();
}
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index a88e3c282207..622335982a10 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -53,7 +53,7 @@ int dev_cache_has_scanned(void);
int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
-
+struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
struct device *dev_hash_get(const char *name);
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index b4f1930b1605..811ad897851b 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -58,6 +58,9 @@ static int _dev_get_size_file(struct device *dev, uint64_t *size)
const char *name = dev_name(dev);
struct stat info;
+ if (dm_list_empty(&dev->aliases))
+ return_0;
+
if (dev->size_seqno == _dev_size_seqno) {
log_very_verbose("%s: using cached size %" PRIu64 " sectors",
name, dev->size);
@@ -87,7 +90,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
int do_close = 0;
if (dm_list_empty(&dev->aliases))
- return 0;
+ return_0;
if (dev->size_seqno == _dev_size_seqno) {
log_very_verbose("%s: using cached size %" PRIu64 " sectors",
@@ -305,6 +308,13 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if ((flags & O_EXCL))
need_excl = 1;
+ if (dm_list_empty(&dev->aliases)) {
+ /* shouldn't happen */
+ log_print("Cannot open device %d:%d with no valid paths.", (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
+ return 0;
+ }
+ name = dev_name(dev);
+
if (dev->fd >= 0) {
if (((dev->flags & DEV_OPENED_RW) || !need_rw) &&
((dev->flags & DEV_OPENED_EXCL) || !need_excl)) {
@@ -314,7 +324,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if (dev->open_count && !need_excl)
log_debug_devs("%s: Already opened read-only. Upgrading "
- "to read-write.", dev_name(dev));
+ "to read-write.", name);
/* dev_close_immediate will decrement this */
dev->open_count++;
@@ -327,11 +337,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if (critical_section())
/* FIXME Make this log_error */
- log_verbose("dev_open(%s) called while suspended",
- dev_name(dev));
-
- if (!(name = dev_name_confirmed(dev, quiet)))
- return_0;
+ log_verbose("dev_open(%s) called while suspended", name);
#ifdef O_DIRECT_SUPPORT
if (direct) {
@@ -372,9 +378,9 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
}
#endif
if (quiet)
- log_sys_debug("open", name);
+ log_debug("Failed to open device path %s (%d).", name, errno);
else
- log_sys_error("open", name);
+ log_error("Failed to open device path %s (%d).", name, errno);
dev->flags |= DEV_OPEN_FAILURE;
return 0;
@@ -415,10 +421,12 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if ((flags & O_CREAT) && !(flags & O_TRUNC))
dev->end = lseek(dev->fd, (off_t) 0, SEEK_END);
- log_debug_devs("Opened %s %s%s%s", dev_name(dev),
- dev->flags & DEV_OPENED_RW ? "RW" : "RO",
- dev->flags & DEV_OPENED_EXCL ? " O_EXCL" : "",
- dev->flags & DEV_O_DIRECT ? " O_DIRECT" : "");
+ if (!quiet) {
+ log_debug_devs("Opened %s %s%s%s", name,
+ dev->flags & DEV_OPENED_RW ? "RW" : "RO",
+ dev->flags & DEV_OPENED_EXCL ? " O_EXCL" : "",
+ dev->flags & DEV_O_DIRECT ? " O_DIRECT" : "");
+ }
dev->flags &= ~DEV_OPEN_FAILURE;
return 1;
diff --git a/lib/device/device.h b/lib/device/device.h
index 8c3a8c30e086..572994bb9f14 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -204,9 +204,6 @@ struct device *dev_create_file(const char *filename, struct device *dev,
struct dm_str_list *alias, int use_malloc);
void dev_destroy_file(struct device *dev);
-/* Return a valid device name from the alias list; NULL otherwise */
-const char *dev_name_confirmed(struct device *dev, int quiet);
-
int dev_mpath_init(const char *config_wwids_file);
void dev_mpath_exit(void);
--
2.34.1

View File

@ -1,137 +0,0 @@
From 692fe7bb31b6682151601f196e6274a3e8b772d5 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:14 +0800
Subject: [PATCH 18/33] tests: stress: Add multi-threads stress testing for
VG/LV
This patch is to add the stress testing, which launches two threads,
each thread creates LV, activate and deactivate LV in the loop; so this
can test for multi-threading in lvmlockd and its backend lock manager.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/stress_multi_threads_1.sh | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
create mode 100644 test/shell/stress_multi_threads_1.sh
diff --git a/test/shell/stress_multi_threads_1.sh b/test/shell/stress_multi_threads_1.sh
new file mode 100644
index 000000000000..c96fa244b1ba
--- /dev/null
+++ b/test/shell/stress_multi_threads_1.sh
@@ -0,0 +1,111 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_devs 6
+get_devs
+
+pvcreate -M2 "${DEVICES[@]}"
+
+vgcreate --shared -M2 "$vg1" "$dev1" "$dev2" "$dev3"
+vgcreate --shared -M2 "$vg2" "$dev4" "$dev5" "$dev6"
+
+test_vg_thread1()
+{
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg1
+
+ # Set minor number
+ lvchange $vg1/foo -My --major=255 --minor=123
+
+ # Activate logic volume
+ lvchange $vg1/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg1/foo
+
+ # Deactivate logic volume
+ lvchange $vg1/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg1 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg1 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg1/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg1 -a ey
+
+ lvreduce -f -l-4 $vg1/foo
+
+ lvchange -an $vg1/foo
+ lvremove $vg1/foo
+ done
+}
+
+test_vg_thread2()
+{
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg2
+
+ # Set minor number
+ lvchange $vg2/foo -My --major=255 --minor=124
+
+ # Activate logic volume
+ lvchange $vg2/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg2/foo
+
+ # Deactivate logic volume
+ lvchange $vg2/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg2 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg2 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg2/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg2 -a ey
+
+ lvreduce -f -l-4 $vg2/foo
+
+ lvchange -an $vg2/foo
+ lvremove $vg2/foo
+ done
+}
+
+test_vg_thread1 &
+WAITPID=$!
+
+test_vg_thread2 &
+WAITPID="$WAITPID "$!
+
+wait $WAITPID
+
+vgremove -ff $vg1
+vgremove -ff $vg2
--
1.8.3.1

View File

@ -0,0 +1,70 @@
From 00c3069872ab488f66f14c8c2727bd080affc05e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 24 Feb 2022 16:10:37 -0600
Subject: devices: initial use of existing option
Use dev_cache_get_existing() in a few common, high level
locations where it's obvious that only existing dev-cache
entries are wanted. This can be expanded and used in more
locations (or dev_cache_get can stop creating new entries.)
---
lib/device/device_id.c | 4 ++--
tools/toollib.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 003f10a96641..c8df47345e72 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1577,7 +1577,7 @@ void device_ids_match_device_list(struct cmd_context *cmd)
dm_list_iterate_items(du, &cmd->use_devices) {
if (du->dev)
continue;
- if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
+ if (!(du->dev = dev_cache_get_existing(cmd, du->devname, NULL))) {
log_warn("Device not found for %s.", du->devname);
} else {
/* Should we set dev->id? Which idtype? Use --deviceidtype? */
@@ -1625,7 +1625,7 @@ void device_ids_match(struct cmd_context *cmd)
* the du/dev pairs in preparation for using the filters.
*/
if (du->devname &&
- (dev = dev_cache_get(cmd, du->devname, NULL))) {
+ (dev = dev_cache_get_existing(cmd, du->devname, NULL))) {
/* On successful match, du, dev, and id are linked. */
if (_match_du_to_dev(cmd, du, dev))
continue;
diff --git a/tools/toollib.c b/tools/toollib.c
index b08c044fab7c..897adec347ae 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1488,7 +1488,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
goto out;
}
- if (!(dev = dev_cache_get(cmd, argv[opt], cmd->filter))) {
+ if (!(dev = dev_cache_get_existing(cmd, argv[opt], cmd->filter))) {
log_error("Failed to find device "
"\"%s\".", argv[opt]);
ret_max = ECMD_FAILED;
@@ -3925,7 +3925,7 @@ static int _get_arg_devices(struct cmd_context *cmd,
return ECMD_FAILED;
}
- if (!(dil->dev = dev_cache_get(cmd, sl->str, cmd->filter))) {
+ if (!(dil->dev = dev_cache_get_existing(cmd, sl->str, cmd->filter))) {
log_error("Cannot use %s: %s", sl->str, devname_error_reason(sl->str));
ret_max = EINIT_FAILED;
} else {
@@ -5261,7 +5261,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct device *dev;
/* No filter used here */
- if (!(dev = dev_cache_get(cmd, pd->name, NULL))) {
+ if (!(dev = dev_cache_get_existing(cmd, pd->name, NULL))) {
log_error("No device found for %s.", pd->name);
dm_list_del(&pd->list);
dm_list_add(&pp->arg_fail, &pd->list);
--
2.34.1

View File

@ -1,119 +0,0 @@
From f83e11ff4332ce7ca24f6bfede4fe60c48123700 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:15 +0800
Subject: [PATCH 19/33] tests: stress: Add multi-threads stress testing for
PV/VG/LV
This patch is to add the stress testing, which launches three threads,
one thread is for creating/removing PV, one thread is for
creating/removing VG, and the last one thread is for LV operations.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/stress_multi_threads_2.sh | 93 ++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
create mode 100644 test/shell/stress_multi_threads_2.sh
diff --git a/test/shell/stress_multi_threads_2.sh b/test/shell/stress_multi_threads_2.sh
new file mode 100644
index 000000000000..a035b5727c97
--- /dev/null
+++ b/test/shell/stress_multi_threads_2.sh
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_devs 8
+get_devs
+
+pvcreate -M2 "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6"
+
+test_vg_thread1()
+{
+ for i in {1..1000}
+ do
+ vgcreate --shared -M2 "$vg1" "$dev1" "$dev2" "$dev3"
+ vgremove -ff $vg1
+ done
+}
+
+test_vg_thread2()
+{
+ vgcreate --shared -M2 "$vg2" "$dev4" "$dev5" "$dev6"
+
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg2
+
+ # Set minor number
+ lvchange $vg2/foo -My --major=255 --minor=124
+
+ # Activate logic volume
+ lvchange $vg2/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg2/foo
+
+ # Deactivate logic volume
+ lvchange $vg2/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg2 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg2 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg2/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg2 -a ey
+
+ lvreduce -f -l-4 $vg2/foo
+
+ lvchange -an $vg2/foo
+ lvremove $vg2/foo
+ done
+
+ vgremove -ff $vg2
+}
+
+test_vg_thread3()
+{
+ for i in {1..1000}
+ do
+ pvcreate -M2 "$dev7" "$dev8"
+ pvremove "$dev7"
+ pvremove "$dev8"
+ done
+}
+
+test_vg_thread1 &
+WAITPID=$!
+
+test_vg_thread2 &
+WAITPID="$WAITPID "$!
+
+test_vg_thread3 &
+WAITPID="$WAITPID "$!
+
+wait $WAITPID
--
1.8.3.1

View File

@ -0,0 +1,291 @@
From 4eb04c8c05e52776891f62863375ceacf866de77 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 22 Feb 2022 15:03:11 -0600
Subject: devices: fix dev_name assumptions
dev_name(dev) returns "[unknown]" if there are no names
on dev->aliases. It's meant mainly for log messages.
Many places assume a valid path name is returned, and
use it directly. A caller that wants to use the path
from dev_name() must first check if the dev has any
paths with dm_list_empty(&dev->aliases).
---
lib/activate/dev_manager.c | 9 ++++++++-
lib/device/dev-type.c | 3 +++
lib/device/device_id.c | 13 +++++++++++--
lib/label/hints.c | 2 ++
lib/label/label.c | 23 ++++++++++++++++++++++-
lib/locking/lvmlockd.c | 4 ++++
lib/metadata/mirror.c | 17 +++++++++++++----
lib/metadata/pv_list.c | 5 +++++
lib/metadata/vg.c | 5 +++++
test/shell/losetup-partscan.sh | 2 ++
10 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 63bfd9b74b90..2cae3bed1fde 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2947,6 +2947,10 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
/* FIXME Avoid repeating identical stat in dm_tree_node_add_target_area */
for (s = start_area; s < areas; s++) {
+
+ /* FIXME: dev_name() does not return NULL! It needs to check if dm_list_empty(&dev->aliases)
+ but this knot of logic is too complex to pull apart without careful deconstruction. */
+
if ((seg_type(seg, s) == AREA_PV &&
(!seg_pvseg(seg, s) || !seg_pv(seg, s) || !seg_dev(seg, s) ||
!(name = dev_name(seg_dev(seg, s))) || !*name ||
@@ -2965,7 +2969,10 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
return_0;
num_error_areas++;
} else if (seg_type(seg, s) == AREA_PV) {
- if (!dm_tree_node_add_target_area(node, dev_name(seg_dev(seg, s)), NULL,
+ struct device *dev = seg_dev(seg, s);
+ name = dm_list_empty(&dev->aliases) ? NULL : dev_name(dev);
+
+ if (!dm_tree_node_add_target_area(node, name, NULL,
(seg_pv(seg, s)->pe_start + (extent_size * seg_pe(seg, s)))))
return_0;
num_existing_areas++;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 0e77a009d072..c67a86fa33f6 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -966,6 +966,9 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
/* TODO: Should we check for valid dev - _dev_is_valid(dev)? */
+ if (dm_list_empty(&dev->aliases))
+ goto_out;
+
if (!(probe = blkid_new_probe_from_filename(dev_name(dev)))) {
log_error("Failed to create a new blkid probe for device %s.", dev_name(dev));
goto out;
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index c8df47345e72..7ce955b11c8d 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -347,6 +347,8 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
}
else if (idtype == DEV_ID_TYPE_DEVNAME) {
+ if (dm_list_empty(&dev->aliases))
+ goto_bad;
if (!(idname = strdup(dev_name(dev))))
goto_bad;
return idname;
@@ -955,6 +957,10 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
if (!dev_get_partition_number(dev, &part))
return_0;
+ /* Ensure valid dev_name(dev) below. */
+ if (dm_list_empty(&dev->aliases))
+ return_0;
+
/*
* When enable_devices_file=0 and pending_devices_file=1 we let
* pvcreate/vgcreate add new du's to cmd->use_devices. These du's may
@@ -1842,6 +1848,9 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
if (dev->flags & DEV_SCAN_NOT_READ)
continue;
+ if (dm_list_empty(&dev->aliases))
+ continue;
+
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent")) {
log_warn("Devices file %s is excluded by filter: %s.",
dev_name(dev), dev_filtered_reason(dev));
@@ -2225,14 +2234,14 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
dm_list_iterate_items(dil, &search_pvids) {
char *dup_devname1, *dup_devname2, *dup_devname3;
- if (!dil->dev) {
+ if (!dil->dev || dm_list_empty(&dil->dev->aliases)) {
not_found++;
continue;
}
- found++;
dev = dil->dev;
devname = dev_name(dev);
+ found++;
if (!(du = get_du_for_pvid(cmd, dil->pvid))) {
/* shouldn't happen */
diff --git a/lib/label/hints.c b/lib/label/hints.c
index 35ae7f5cc8df..edce6f517133 100644
--- a/lib/label/hints.c
+++ b/lib/label/hints.c
@@ -500,6 +500,8 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
if (!(iter = dev_iter_create(NULL, 0)))
return 0;
while ((dev = dev_iter_get(cmd, iter))) {
+ if (dm_list_empty(&dev->aliases))
+ continue;
if (!(hint = _find_hint_name(hints, dev_name(dev))))
continue;
diff --git a/lib/label/label.c b/lib/label/label.c
index 66d6e7db7a6e..ffb39389188a 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1130,6 +1130,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
* sure to find the device.
*/
if (try_dev_scan) {
+ log_debug("Repeat dev cache scan to translate devnos.");
dev_cache_scan(cmd);
dm_list_iterate_items(po, &pvs_online) {
if (po->dev)
@@ -1736,6 +1737,12 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
struct lv_list *lvl;
dev_t devt;
+ /*
+ * FIXME: this is all unnecessary unless there are PVs stacked on LVs,
+ * so we can skip all of this if scan_lvs=0.
+ */
+ log_debug("invalidating devs for any pvs on lvs");
+
if (get_device_list(NULL, &devs, &devs_features)) {
if (devs_features & DM_DEVICE_LIST_HAS_UUID) {
dm_list_iterate_items(dm_dev, devs)
@@ -1879,10 +1886,24 @@ int label_scan_open_rw(struct device *dev)
int label_scan_reopen_rw(struct device *dev)
{
+ const char *name;
int flags = 0;
int prev_fd = dev->bcache_fd;
int fd;
+ if (dm_list_empty(&dev->aliases)) {
+ log_error("Cannot reopen rw device %d:%d with no valid paths di %d fd %d.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev->bcache_di, dev->bcache_fd);
+ return 0;
+ }
+
+ name = dev_name(dev);
+ if (!name || name[0] != '/') {
+ log_error("Cannot reopen rw device %d:%d with no valid name di %d fd %d.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), dev->bcache_di, dev->bcache_fd);
+ return 0;
+ }
+
if (!(dev->flags & DEV_IN_BCACHE)) {
if ((dev->bcache_fd != -1) || (dev->bcache_di != -1)) {
/* shouldn't happen */
@@ -1912,7 +1933,7 @@ int label_scan_reopen_rw(struct device *dev)
flags |= O_NOATIME;
flags |= O_RDWR;
- fd = open(dev_name(dev), flags, 0777);
+ fd = open(name, flags, 0777);
if (fd < 0) {
log_error("Failed to open rw %s errno %d di %d fd %d.",
dev_name(dev), errno, dev->bcache_di, dev->bcache_fd);
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index b598df3d6b79..60c80f1b1e5c 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -272,6 +272,8 @@ static void _lockd_retrive_vg_pv_list(struct volume_group *vg,
i = 0;
dm_list_iterate_items(pvl, &vg->pvs) {
+ if (!pvl->pv->dev || dm_list_empty(&pvl->pv->dev->aliases))
+ continue;
lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
if (!lock_pvs->path[i]) {
log_error("Fail to allocate PV path for VG %s", vg->name);
@@ -341,6 +343,8 @@ static void _lockd_retrive_lv_pv_list(struct volume_group *vg,
dm_list_iterate_items(pvl, &vg->pvs) {
if (lv_is_on_pv(lv, pvl->pv)) {
+ if (!pvl->pv->dev || dm_list_empty(&pvl->pv->dev->aliases))
+ continue;
lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
if (!lock_pvs->path[i]) {
log_error("Fail to allocate PV path for LV %s/%s",
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index e2bf191a1ef0..46da57948f00 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -1231,14 +1231,23 @@ int remove_mirrors_from_segments(struct logical_volume *lv,
const char *get_pvmove_pvname_from_lv_mirr(const struct logical_volume *lv_mirr)
{
struct lv_segment *seg;
+ struct device *dev;
dm_list_iterate_items(seg, &lv_mirr->segments) {
if (!seg_is_mirrored(seg))
continue;
- if (seg_type(seg, 0) == AREA_PV)
- return dev_name(seg_dev(seg, 0));
- if (seg_type(seg, 0) == AREA_LV)
- return dev_name(seg_dev(first_seg(seg_lv(seg, 0)), 0));
+ if (seg_type(seg, 0) == AREA_PV) {
+ dev = seg_dev(seg, 0);
+ if (!dev || dm_list_empty(&dev->aliases))
+ return NULL;
+ return dev_name(dev);
+ }
+ if (seg_type(seg, 0) == AREA_LV) {
+ dev = seg_dev(first_seg(seg_lv(seg, 0)), 0);
+ if (!dev || dm_list_empty(&dev->aliases))
+ return NULL;
+ return dev_name(dev);
+ }
}
return NULL;
diff --git a/lib/metadata/pv_list.c b/lib/metadata/pv_list.c
index 813e8e525052..fc3667db0a9a 100644
--- a/lib/metadata/pv_list.c
+++ b/lib/metadata/pv_list.c
@@ -152,6 +152,11 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
struct pv_list *new_pvl = NULL, *pvl2;
struct dm_list *pe_ranges;
+ if (!pvl->pv->dev || dm_list_empty(&pvl->pv->dev->aliases)) {
+ log_error("Failed to create PV entry for missing device.");
+ return 0;
+ }
+
pvname = pv_dev_name(pvl->pv);
if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
log_warn("WARNING: Physical volume %s not allocatable.", pvname);
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 85482552aefe..adc954babe67 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -679,6 +679,11 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return r;
}
+ if (!pv->dev || dm_list_empty(&pv->dev->aliases)) {
+ log_error("No device found for PV.");
+ return r;
+ }
+
log_debug("vgreduce_single VG %s PV %s", vg->name, pv_dev_name(pv));
if (pv_pe_alloc_count(pv)) {
diff --git a/test/shell/losetup-partscan.sh b/test/shell/losetup-partscan.sh
index 99f552ad1268..670568945953 100644
--- a/test/shell/losetup-partscan.sh
+++ b/test/shell/losetup-partscan.sh
@@ -33,6 +33,8 @@ aux udev_wait
ls -la "${LOOP}"*
test -e "${LOOP}p1"
+aux lvmconf 'devices/scan = "/dev"'
+
aux extend_filter "a|$LOOP|"
aux extend_devices "$LOOP"
--
2.34.1

View File

@ -1,111 +0,0 @@
From 8c7b2df41fdddcd1b1c504522ab79300882eb72f Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:16 +0800
Subject: [PATCH 20/33] tests: Support idm failure injection
When the drive failure occurs, the IDM lock manager and lvmlockd should
handle this case properly. E.g. when the IDM lock manager detects the
lease renewal failure caused by I/O errors, it should invoke the kill
path which is predefined by lvmlockd, so that the kill path program
(like lvmlockctl) can send requests to lvmlockd to stop and drop lock
for the relevant VG/LVs.
To verify the failure handling flow, this patch introduces an idm
failure injection program, it can input the "percentage" for drive
failures so that can emulate different failure cases.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/Makefile.in | 5 ++++
test/lib/idm_inject_failure.c | 55 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
create mode 100644 test/lib/idm_inject_failure.c
diff --git a/test/Makefile.in b/test/Makefile.in
index 662974be6ccb..573df77a7ac8 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -171,6 +171,7 @@ endif
ifeq ("@BUILD_LVMLOCKD@", "yes")
check_lvmlockd_idm: .tests-stamp
+ $(INSTALL_PROGRAM) lib/idm_inject_failure $(EXECDIR)
VERBOSE=$(VERBOSE) ./lib/runner \
--testdir . --outdir $(LVM_TEST_RESULTS) \
--flavours udev-lvmlockd-idm --only shell/aa-lvmlockd-idm-prepare.sh,$(T),shell/zz-lvmlockd-idm-remove.sh --skip $(S)
@@ -269,6 +270,10 @@ lib/securetest: lib/dmsecuretest.o .lib-dir-stamp
@echo " [CC] $@"
$(Q) $(CC) -g $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $< -L$(interfacebuilddir) -ldevmapper $(LIBS)
+lib/idm_inject_failure: lib/idm_inject_failure.o .lib-dir-stamp
+ @echo " [CC] $@"
+ $(Q) $(CC) -g $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $< $(INTERNAL_LIBS) $(LIBS) -lseagate_ilm
+
lib/runner.o: $(wildcard $(srcdir)/lib/*.h)
CFLAGS_runner.o += $(EXTRA_EXEC_CFLAGS)
diff --git a/test/lib/idm_inject_failure.c b/test/lib/idm_inject_failure.c
new file mode 100644
index 000000000000..4998b585af6e
--- /dev/null
+++ b/test/lib/idm_inject_failure.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020-2021 Seagate Ltd.
+ *
+ * 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.
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/inotify.h>
+#include <uuid/uuid.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ilm.h>
+
+int main(int argc, char *argv[])
+{
+ int pecent = atoi(argv[1]);
+ int ret, s;
+
+ ret = ilm_connect(&s);
+ if (ret == 0) {
+ printf("ilm_connect: SUCCESS\n");
+ } else {
+ printf("ilm_connect: FAIL\n");
+ exit(-1);
+ }
+
+ ret = ilm_inject_fault(s, pecent);
+ if (ret == 0) {
+ printf("ilm_inject_fault (100): SUCCESS\n");
+ } else {
+ printf("ilm_inject_fault (100): FAIL\n");
+ exit(-1);
+ }
+
+ ret = ilm_disconnect(s);
+ if (ret == 0) {
+ printf("ilm_disconnect: SUCCESS\n");
+ } else {
+ printf("ilm_disconnect: FAIL\n");
+ exit(-1);
+ }
+
+ return 0;
+}
--
1.8.3.1

View File

@ -0,0 +1,272 @@
From 7b1a857d5ac480b789af07d85e55bc87c6a76934 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 28 Feb 2022 17:37:12 -0600
Subject: [PATCH 1/3] devices: use dev-cache aliases handling from label scan
functions
The label scan functions where doing some device alias validation
which is now better handled by the dev-cache layer, so just use
that.
---
lib/device/dev-cache.c | 4 +-
lib/device/dev-cache.h | 1 +
lib/label/label.c | 143 ++++++++++-------------------------------
3 files changed, 36 insertions(+), 112 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 8db28bd84a01..5607beefc40f 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1410,7 +1410,7 @@ static void _remove_alias(struct device *dev, const char *name)
* deactivated LV. Those old paths are all invalid and are dropped here.
*/
-static void _verify_aliases(struct device *dev)
+void dev_cache_verify_aliases(struct device *dev)
{
struct dm_str_list *strl, *strl2;
struct stat st;
@@ -1459,7 +1459,7 @@ static struct device *_dev_cache_get(struct cmd_context *cmd, const char *name,
_remove_alias(dev, name);
/* Remove any other names in dev->aliases that are incorrect. */
- _verify_aliases(dev);
+ dev_cache_verify_aliases(dev);
}
return NULL;
}
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 622335982a10..46b1da72c1ad 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -55,6 +55,7 @@ int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
+void dev_cache_verify_aliases(struct device *dev);
struct device *dev_hash_get(const char *name);
diff --git a/lib/label/label.c b/lib/label/label.c
index ffb39389188a..c208638757af 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -459,7 +459,6 @@ static int _scan_dev_open(struct device *dev)
const char *name;
const char *modestr;
struct stat sbuf;
- int retried = 0;
int flags = 0;
int fd, di;
@@ -479,14 +478,23 @@ static int _scan_dev_open(struct device *dev)
return 0;
}
+ next_name:
/*
* All the names for this device (major:minor) are kept on
* dev->aliases, the first one is the primary/preferred name.
+ *
+ * The default name preferences in dev-cache mean that the first
+ * name in dev->aliases is not a symlink for scsi devices, but is
+ * the /dev/mapper/ symlink for mpath devices.
+ *
+ * If preferred names are set to symlinks, should this
+ * first attempt to open using a non-symlink?
+ *
+ * dm_list_first() returns NULL if the list is empty.
*/
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));
+ log_error("Device open %d:%d has no path names.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
return 0;
}
name_sl = dm_list_item(name_list, struct dm_str_list);
@@ -514,50 +522,34 @@ static int _scan_dev_open(struct device *dev)
modestr = "ro";
}
-retry_open:
-
fd = open(name, flags, 0777);
-
if (fd < 0) {
if ((errno == EBUSY) && (flags & O_EXCL)) {
log_error("Can't open %s exclusively. Mounted filesystem?",
dev_name(dev));
+ return 0;
} else {
- int major, minor;
-
/*
- * Shouldn't happen, if it does, print stat info to help figure
- * out what's wrong.
+ * drop name from dev->aliases and use verify_aliases to
+ * drop any other invalid aliases before retrying open with
+ * any remaining valid paths.
*/
-
- 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));
- }
-
- 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;
- }
+ log_debug("Drop alias for %d:%d failed open %s (%d)",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), name, errno);
+ dev_cache_failed_path(dev, name);
+ dev_cache_verify_aliases(dev);
+ goto next_name;
}
- return 0;
+ }
+
+ /* Verify that major:minor from the path still match dev. */
+ if ((fstat(fd, &sbuf) < 0) || (sbuf.st_rdev != dev->dev)) {
+ log_warn("Invalid path %s for device %d:%d, trying different path.",
+ name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
+ (void)close(fd);
+ dev_cache_failed_path(dev, name);
+ dev_cache_verify_aliases(dev);
+ goto next_name;
}
dev->flags |= DEV_IN_BCACHE;
@@ -605,37 +597,6 @@ 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);
- }
- }
-}
-
// Like bcache_invalidate, only it throws any dirty data away if the
// write fails.
static void _invalidate_di(struct bcache *cache, int di)
@@ -663,10 +624,8 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
char headers_buf[HEADERS_BUF_SIZE];
struct dm_list wait_devs;
struct dm_list done_devs;
- struct dm_list reopen_devs;
struct device_list *devl, *devl2;
struct block *bb;
- int retried_open = 0;
int scan_read_errors = 0;
int scan_process_errors = 0;
int scan_failed_count = 0;
@@ -677,7 +636,6 @@ 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));
@@ -701,9 +659,9 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
if (!_in_bcache(devl->dev)) {
if (!_scan_dev_open(devl->dev)) {
- log_debug_devs("Scan failed to open %s.", dev_name(devl->dev));
+ log_debug_devs("Scan failed to open %d:%d %s.",
+ (int)MAJOR(devl->dev->dev), (int)MINOR(devl->dev->dev), dev_name(devl->dev));
dm_list_del(&devl->list);
- dm_list_add(&reopen_devs, &devl->list);
devl->dev->flags |= DEV_SCAN_NOT_READ;
continue;
}
@@ -787,41 +745,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
if (!dm_list_empty(devs))
goto scan_more;
- /*
- * 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.
- */
- 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;
-
- 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++;
- }
- }
-
- /* 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);
--
2.34.1

View File

@ -1,93 +0,0 @@
From 874001ee6e0e7812e4e8d19994a1fd7de43d3249 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:17 +0800
Subject: [PATCH 21/33] tests: Add testing for lvmlockd failure
After the lvmlockd abnormally exits and relaunch the daemon, if LVM
commands continue to run, lvmlockd and the backend lock manager (e.g.
sanlock lock manager or IDM lock manager) should can continue to serve
the requests from LVM commands.
This patch adds a test to emulate lvmlockd failure, and verify the LVM
commands after lvmlockd recovers back. Below is an example for testing
the case:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdo3,/dev/sdp3,/dev/sdp4 \
LVM_TEST_FAILURE=1 T=lvmlockd_failure.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/lib/inittest.sh | 3 ++-
test/shell/lvmlockd_failure.sh | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 test/shell/lvmlockd_failure.sh
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 6b4bcb348010..98a916ca6e10 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -31,6 +31,7 @@ LVM_TEST_BACKING_DEVICE=${LVM_TEST_BACKING_DEVICE-}
LVM_TEST_DEVDIR=${LVM_TEST_DEVDIR-}
LVM_TEST_NODEBUG=${LVM_TEST_NODEBUG-}
LVM_TEST_LVM1=${LVM_TEST_LVM1-}
+LVM_TEST_FAILURE=${LVM_TEST_FAILURE-}
# TODO: LVM_TEST_SHARED
SHARED=${SHARED-}
@@ -63,7 +64,7 @@ test -n "$SKIP_WITH_LVMLOCKD" && test -n "$LVM_TEST_LVMLOCKD" && initskip
unset CDPATH
-export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG
+export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG LVM_TEST_FAILURE
export LVM_TEST_LVMLOCKD LVM_TEST_LVMLOCKD_TEST
export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK LVM_TEST_LOCK_TYPE_IDM
export LVM_TEST_DEVICES_FILE
diff --git a/test/shell/lvmlockd_failure.sh b/test/shell/lvmlockd_failure.sh
new file mode 100644
index 000000000000..e0fccfb83b53
--- /dev/null
+++ b/test/shell/lvmlockd_failure.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020~2021 Seagate, 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_vg 3
+
+# Create new logic volume
+lvcreate -a ey --zero n -l 1 -n $lv1 $vg
+
+# Emulate lvmlockd abnormally exiting
+killall -9 lvmlockd
+
+systemctl start lvm2-lvmlockd
+
+vgchange --lock-start $vg
+
+lvchange -a n $vg/$lv1
+lvchange -a sy $vg/$lv1
+
+lvcreate -a ey --zero n -l 1 -n $lv2 $vg
+lvchange -a n $vg/$lv2
+
+vgremove -ff $vg
--
1.8.3.1

View File

@ -0,0 +1,31 @@
From cc73d99886dfd6e0da3c6ca685669f77fac3c1cd Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 1 Mar 2022 12:22:46 -0600
Subject: [PATCH 2/3] devices: only close PVs on LVs when scan_lvs is enabled
This code is only needed when lvm scans PVs that are stacked on LVs.
---
lib/label/label.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index c208638757af..e6bc791a78ff 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1661,9 +1661,11 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
dev_t devt;
/*
- * FIXME: this is all unnecessary unless there are PVs stacked on LVs,
- * so we can skip all of this if scan_lvs=0.
+ * This is only needed when the command sees PVs stacked on LVs which
+ * will only happen with scan_lvs=1.
*/
+ if (!cmd->scan_lvs)
+ return;
log_debug("invalidating devs for any pvs on lvs");
if (get_device_list(NULL, &devs, &devs_features)) {
--
2.34.1

View File

@ -1,94 +0,0 @@
From fc0495ea04a96c0990726db98c80bd2732d3695a Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:18 +0800
Subject: [PATCH 22/33] tests: idm: Add testing for the fabric failure
When the fabric failure occurs, it will lose the connection with hosts
instantly, and after a while it can recovery back so that the hosts can
continue to access the drives.
For this case, the locking manager should be reliable for this case and
can dynamically handle this case and allows user to continue to use the
VG/LV with associated locking scheme.
This patch adds a testing to emulate the fabric faliure, verify LVM
commands for this case. The testing usage is:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdo3,/dev/sdp3,/dev/sdp4 \
LVM_TEST_FAILURE=1 T=idm_fabric_failure.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/idm_fabric_failure.sh | 58 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 test/shell/idm_fabric_failure.sh
diff --git a/test/shell/idm_fabric_failure.sh b/test/shell/idm_fabric_failure.sh
new file mode 100644
index 000000000000..e68d6ad07be0
--- /dev/null
+++ b/test/shell/idm_fabric_failure.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_devs 3
+aux extend_filter_LVMTEST
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3"
+
+# Create new logic volume
+lvcreate -a ey --zero n -l 50%FREE -n $lv1 $vg
+
+DRIVE1=`dmsetup deps -o devname $dev1 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+DRIVE2=`dmsetup deps -o devname $dev2 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+DRIVE3=`dmsetup deps -o devname $dev3 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+
+HOST1=`readlink /sys/block/$DRIVE1 | awk -F'/' '{print $6}'`
+HOST2=`readlink /sys/block/$DRIVE2 | awk -F'/' '{print $6}'`
+HOST3=`readlink /sys/block/$DRIVE3 | awk -F'/' '{print $6}'`
+
+# Emulate fabric failure
+echo 1 > /sys/block/$DRIVE1/device/delete
+[ -f /sys/block/$DRIVE2/device/delete ] && echo 1 > /sys/block/$DRIVE2/device/delete
+[ -f /sys/block/$DRIVE3/device/delete ] && echo 1 > /sys/block/$DRIVE3/device/delete
+
+# Wait for 10s and will not lead to timeout
+sleep 10
+
+# Rescan drives so can probe the deleted drives and join back them
+echo "- - -" > /sys/class/scsi_host/${HOST1}/scan
+echo "- - -" > /sys/class/scsi_host/${HOST2}/scan
+echo "- - -" > /sys/class/scsi_host/${HOST3}/scan
+
+not check grep_lvmlockd_dump "S lvm_$vg kill_vg"
+
+# The previous device-mapper are removed, but LVM still can directly
+# access VGs from the specified physical drives. So enable drives
+# for these drives.
+aux extend_filter_LVMTEST "a|/dev/$DRIVE1*|" "a|/dev/$DRIVE2*|" "a|/dev/$DRIVE3*|"
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+lvcreate -a n --zero n -l 10 -n $lv2 $vg
+
+vgremove -ff $vg
--
1.8.3.1

View File

@ -1,111 +0,0 @@
From 91d3b568758cbb11ffd797c864d03f7f36426efc Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:19 +0800
Subject: [PATCH 23/33] tests: idm: Add testing for the fabric failure and
timeout
If the fabric is broken instantly, the drives connected on the fabric
will disappear from the system. For worst case, the lease is timeout
and the drives cannot recovery back. So a new test is added to emulate
this scenario, it uses a drive for LVM operations and this drive is also
used for locking scheme; if the drive and all its associated paths (if
the drive supports multiple paths) are disconnected, the lock manager
should stop the lockspace for the VG/LVs.
And afterwards, if the drive recovers back, the VG/LV resident in the
drive should be operated properly. The test command is as below:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdp3 LVM_TEST_FAILURE=1 \
T=idm_fabric_failure_timeout.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/idm_fabric_failure_timeout.sh | 74 ++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 test/shell/idm_fabric_failure_timeout.sh
diff --git a/test/shell/idm_fabric_failure_timeout.sh b/test/shell/idm_fabric_failure_timeout.sh
new file mode 100644
index 000000000000..cf71f760970a
--- /dev/null
+++ b/test/shell/idm_fabric_failure_timeout.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_devs 1
+aux extend_filter_LVMTEST
+
+DRIVE1=`dmsetup deps -o devname $dev1 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+
+# The previous device-mapper are removed, but LVM still can directly
+# access VGs from the specified physical drives. So enable drives
+# for these drives.
+aux extend_filter_LVMTEST "a|/dev/$DRIVE1*|"
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgcreate $SHARED $vg "$dev1"
+
+# Create new logic volume
+lvcreate -a ey --zero n -l 1 -n $lv1 $vg
+
+drive_list=($DRIVE1)
+
+# Find all drives with the same WWN and delete them from system,
+# so that we can emulate the same drive with multiple paths are
+# disconnected with system.
+drive_wwn=`udevadm info /dev/${DRIVE1} | awk -F= '/E: ID_WWN=/ {print $2}'`
+for dev in /dev/*; do
+ if [ -b "$dev" ] && [[ ! "$dev" =~ [0-9] ]]; then
+ wwn=`udevadm info "${dev}" | awk -F= '/E: ID_WWN=/ {print $2}'`
+ if [ "$wwn" = "$drive_wwn" ]; then
+ base_name="$(basename -- ${dev})"
+ drive_list+=("$base_name")
+ host_list+=(`readlink /sys/block/$base_name | awk -F'/' '{print $6}'`)
+ fi
+ fi
+done
+
+for d in "${drive_list[@]}"; do
+ [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+done
+
+# Fail to create new logic volume
+not lvcreate -a n --zero n -l 1 -n $lv2 $vg
+
+# Wait for lock time out caused by drive failure
+sleep 70
+
+check grep_lvmlockd_dump "S lvm_$vg kill_vg"
+lvmlockctl --drop $vg
+
+# Rescan drives so can probe the deleted drives and join back them
+for h in "${host_list[@]}"; do
+ [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+done
+
+# After the drive is reconnected, $vg should be visible again.
+vgchange --lock-start
+vgremove -ff $vg
--
1.8.3.1

View File

@ -0,0 +1,101 @@
From bef1363c0064f42e8063571143a428ad163d1bd9 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 1 Mar 2022 14:31:39 -0600
Subject: [PATCH 3/3] writecache: check memory usage
warn if writecache neds > 50% of system memory, and
confirm if writecache needs > 90% of system memory.
---
tools/lvconvert.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a3eb60b20006..1c4351e9d481 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6070,6 +6070,69 @@ bad:
return 0;
}
+static int _check_writecache_memory(struct cmd_context *cmd, struct logical_volume *lv_fast,
+ uint32_t block_size_sectors)
+{
+ char line[128];
+ FILE *fp;
+ uint64_t cachevol_size_bytes = lv_fast->size * SECTOR_SIZE;
+ uint64_t need_mem_bytes = 0;
+ uint64_t proc_mem_bytes = 0;
+ uint64_t need_mem_gb;
+ uint64_t proc_mem_gb;
+ unsigned long long proc_mem_kb = 0;
+
+ if (!(fp = fopen("/proc/meminfo", "r")))
+ goto skip_proc;
+
+ while (fgets(line, sizeof(line), fp)) {
+ if (strncmp(line, "MemTotal:", 9))
+ continue;
+ if (sscanf(line, "%*s%llu%*s", &proc_mem_kb) != 1)
+ break;
+ break;
+ }
+ (void)fclose(fp);
+
+ proc_mem_bytes = proc_mem_kb * 1024;
+
+ skip_proc:
+ /* dm-writecache memory consumption per block is 88 bytes */
+ if (block_size_sectors == 8) {
+ need_mem_bytes = cachevol_size_bytes * 88 / 4096;
+ } else if (block_size_sectors == 1) {
+ need_mem_bytes = cachevol_size_bytes * 88 / 512;
+ } else {
+ /* shouldn't happen */
+ log_warn("Unknown memory usage for unknown writecache block_size_sectors %u", block_size_sectors);
+ return 1;
+ }
+
+ need_mem_gb = need_mem_bytes / 1073741824;
+ proc_mem_gb = proc_mem_bytes / 1073741824;
+
+ /*
+ * warn if writecache needs > 50% of main memory, and
+ * confirm if writecache needs > 90% of main memory.
+ */
+ if (need_mem_bytes >= (proc_mem_bytes / 2)) {
+ log_warn("WARNING: writecache size %s will use %llu GiB of system memory (%llu GiB).",
+ display_size(cmd, lv_fast->size),
+ (unsigned long long)need_mem_gb,
+ (unsigned long long)proc_mem_gb);
+
+ if (need_mem_gb >= (proc_mem_gb * 9 / 10)) {
+ if (!arg_is_set(cmd, yes_ARG) &&
+ yes_no_prompt("Continue adding writecache? [y/n]: ") == 'n') {
+ log_error("Conversion aborted.");
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
int lvconvert_writecache_attach_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
@@ -6158,6 +6221,12 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto_bad;
}
+ if (!_check_writecache_memory(cmd, lv_fast, block_size_sectors)) {
+ if (!is_active && !deactivate_lv(cmd, lv))
+ stack;
+ goto_bad;
+ }
+
if (!is_active) {
if (!deactivate_lv(cmd, lv)) {
log_error("Failed to deactivate LV after checking block size %s", display_lvname(lv));
--
2.34.1

View File

@ -1,115 +0,0 @@
From 38abd6bb2c3c35ad476f11fd3cd4ee8d119e364d Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:20 +0800
Subject: [PATCH 24/33] tests: idm: Add testing for the fabric's half brain
failure
If the fabric is broken instantly and the partial drives connected on
the fabric disappear from the system. For this case, according to the
locking algorithm in idm, the lease will not lose since the half drives
are still alive so can renew the lease for the half drives. On the
other hand, since the VG lock requires to acquire the majority of drive
number, but half drives failure cannot achieve the majority, so it
cannot acquire the lock for VG and thus cannot change metadata for VG.
This patch is to add half brain failure for idm; the test command is as
below:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdp3,/dev/sdo3 LVM_TEST_FAILURE=1 \
T=idm_fabric_failure_half_brain.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/idm_fabric_failure_half_brain.sh | 78 +++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 test/shell/idm_fabric_failure_half_brain.sh
diff --git a/test/shell/idm_fabric_failure_half_brain.sh b/test/shell/idm_fabric_failure_half_brain.sh
new file mode 100644
index 000000000000..c692a12ad9c4
--- /dev/null
+++ b/test/shell/idm_fabric_failure_half_brain.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_devs 2
+aux extend_filter_LVMTEST
+
+DRIVE1=`dmsetup deps -o devname $dev1 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+DRIVE2=`dmsetup deps -o devname $dev2 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+
+[ "$(basename -- $DRIVE1)" = "$(basename -- $DRIVE2)" ] && die "Need to pass two different drives!?"
+
+# The previous device-mapper are removed, but LVM still can directly
+# access VGs from the specified physical drives. So enable drives
+# for these drives.
+aux extend_filter_LVMTEST "a|/dev/$DRIVE1*|" "a|/dev/$DRIVE2*|"
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgcreate $SHARED $vg "$dev1" "$dev2"
+
+# Create new logic volume
+lvcreate -a ey --zero n -l 100%FREE -n $lv1 $vg
+
+drive_list=($DRIVE1)
+
+# Find all drives with the same WWN and delete them from system,
+# so that we can emulate the same drive with multiple paths are
+# disconnected with system.
+drive_wwn=`udevadm info /dev/${DRIVE1} | awk -F= '/E: ID_WWN=/ {print $2}'`
+for dev in /dev/*; do
+ if [ -b "$dev" ] && [[ ! "$dev" =~ [0-9] ]]; then
+ wwn=`udevadm info "${dev}" | awk -F= '/E: ID_WWN=/ {print $2}'`
+ if [ "$wwn" = "$drive_wwn" ]; then
+ base_name="$(basename -- ${dev})"
+ drive_list+=("$base_name")
+ host_list+=(`readlink /sys/block/$base_name | awk -F'/' '{print $6}'`)
+ fi
+ fi
+done
+
+for d in "${drive_list[@]}"; do
+ [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+done
+
+# Fail to create new logic volume
+not lvcreate -a n --zero n -l 1 -n $lv2 $vg
+
+# Wait for lock time out caused by drive failure
+sleep 70
+
+not check grep_lvmlockd_dump "S lvm_$vg kill_vg"
+
+# Rescan drives so can probe the deleted drives and join back them
+for h in "${host_list[@]}"; do
+ [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+done
+
+# After the drive is reconnected, $vg should be visible again.
+vgchange --lock-start
+lvremove -f $vg/$lv1
+lvcreate -a ey --zero n -l 1 -n $lv2 $vg
+vgremove -ff $vg
--
1.8.3.1

View File

@ -1,117 +0,0 @@
From 92b47d8eb8c4b717fd79d0b7c50ecac0dceb31a5 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:21 +0800
Subject: [PATCH 25/33] tests: idm: Add testing for IDM lock manager failure
If the IDM lock manager fails to access drives, might partially fail to
access drives (e.g. it fails to access one of three drives), or totally
fail to access drives, the lock manager should handle properly for these
cases. When the drives are partially failure, if the lock manager still
can renew the lease for the locking, then it doesn't need to take any
action for the drive failure; otherwise, if it detects it cannot renew
the locking majority, it needs ti immediately kill the VG from the
lvmlockd.
This patch adds the test for verification the IDM lock manager failure;
the command can be used as below:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdp3,/dev/sdl3,/dev/sdq3 \
LVM_TEST_FAILURE=1 T=idm_ilm_failure.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/idm_ilm_failure.sh | 80 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 test/shell/idm_ilm_failure.sh
diff --git a/test/shell/idm_ilm_failure.sh b/test/shell/idm_ilm_failure.sh
new file mode 100644
index 000000000000..58bed270eaa7
--- /dev/null
+++ b/test/shell/idm_ilm_failure.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_devs 3
+aux extend_filter_LVMTEST
+
+DRIVE1=`dmsetup deps -o devname $dev1 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+DRIVE2=`dmsetup deps -o devname $dev2 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+DRIVE3=`dmsetup deps -o devname $dev3 | awk '{gsub(/[()]/,""); print $4;}' | sed 's/[0-9]*$//'`
+
+if [ "$DRIVE1" = "$DRIVE2" ] || [ "$DRIVE1" = "$DRIVE3" ] || [ "$DRIVE2" = "$DRIVE3" ]; then
+ die "Need to pass three different drives!?"
+fi
+
+# The previous device-mapper are removed, but LVM still can directly
+# access VGs from the specified physical drives. So enable drives
+# for these drives.
+aux extend_filter_LVMTEST "a|/dev/$DRIVE1*|" "a|/dev/$DRIVE2*|" "a|/dev/$DRIVE3*|"
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3"
+
+# Create new logic volume and deactivate it
+lvcreate -a y --zero n -l 1 -n $lv1 $vg
+
+# Inject failure 40% so cannot send partially request to drives
+idm_inject_failure 40
+
+# Wait for 40s, but the lock will not be time out
+sleep 40
+
+# Inject failure with 0% so can access drives
+idm_inject_failure 0
+
+# Deactivate logic volume due to locking failure
+lvchange $vg/$lv1 -a n
+
+# Inject failure 100% so cannot send request to drives
+idm_inject_failure 100
+
+# Wait for 70s but should have no any alive locks
+sleep 70
+
+# Inject failure with 0% so can access drives
+idm_inject_failure 0
+
+# Activate logic volume
+lvchange $vg/$lv1 -a y
+
+# Inject failure so cannot send request to drives
+idm_inject_failure 100
+
+# Wait for 70s but will not time out
+sleep 70
+
+# Inject failure with 0% so can access drives
+idm_inject_failure 0
+
+check grep_lvmlockd_dump "S lvm_$vg kill_vg"
+lvmlockctl --drop $vg
+
+vgchange --lock-start
+vgremove -f $vg
--
1.8.3.1

View File

@ -1,177 +0,0 @@
From e75bd71aaea6e092b93533bdc948fd527821d297 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:22 +0800
Subject: [PATCH 26/33] tests: multi-hosts: Add VG testing
This patch is to add VG testing on multi hosts. There have two scripts,
the script multi_hosts_vg_hosta.sh is used to create VGs on one host,
and the second script multi_hosts_vg_hostb.sh afterwards will acquire
global lock and VG lock, and remove VGs. The testing flow verifies the
locking operations between two hosts with lvmlockd and the backend
locking manager.
On the host A:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hosta.sh
On the host B:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hostb.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/Makefile.in | 1 +
test/lib/inittest.sh | 2 ++
test/shell/multi_hosts_vg_hosta.sh | 45 +++++++++++++++++++++++++++++++++
test/shell/multi_hosts_vg_hostb.sh | 52 ++++++++++++++++++++++++++++++++++++++
4 files changed, 100 insertions(+)
create mode 100644 test/shell/multi_hosts_vg_hosta.sh
create mode 100644 test/shell/multi_hosts_vg_hostb.sh
diff --git a/test/Makefile.in b/test/Makefile.in
index 573df77a7ac8..cd134129be9e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -93,6 +93,7 @@ help:
@echo -e "\nSupported variables:"
@echo " LVM_TEST_AUX_TRACE Set for verbose messages for aux scripts []."
@echo " LVM_TEST_BACKING_DEVICE Set device used for testing (see also LVM_TEST_DIR)."
+ @echo " LVM_TEST_MULTI_HOST Set multiple hosts used for testing."
@echo " LVM_TEST_CAN_CLOBBER_DMESG Allow to clobber dmesg buffer without /dev/kmsg. (1)"
@echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
@echo " LVM_TEST_PREFER_BRD Prefer using brd (ramdisk) over loop for testing [1]."
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 98a916ca6e10..4ca8ac59e957 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -32,6 +32,7 @@ LVM_TEST_DEVDIR=${LVM_TEST_DEVDIR-}
LVM_TEST_NODEBUG=${LVM_TEST_NODEBUG-}
LVM_TEST_LVM1=${LVM_TEST_LVM1-}
LVM_TEST_FAILURE=${LVM_TEST_FAILURE-}
+LVM_TEST_MULTI_HOST=${LVM_TEST_MULTI_HOST-}
# TODO: LVM_TEST_SHARED
SHARED=${SHARED-}
@@ -65,6 +66,7 @@ test -n "$SKIP_WITH_LVMLOCKD" && test -n "$LVM_TEST_LVMLOCKD" && initskip
unset CDPATH
export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG LVM_TEST_FAILURE
+export LVM_TEST_MULTI_HOST
export LVM_TEST_LVMLOCKD LVM_TEST_LVMLOCKD_TEST
export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK LVM_TEST_LOCK_TYPE_IDM
export LVM_TEST_DEVICES_FILE
diff --git a/test/shell/multi_hosts_vg_hosta.sh b/test/shell/multi_hosts_vg_hosta.sh
new file mode 100644
index 000000000000..15347490c8f4
--- /dev/null
+++ b/test/shell/multi_hosts_vg_hosta.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing, the paired scripts
+# are: multi_hosts_vg_hosta.sh / multi_hosts_vg_hostb.sh
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+i=0
+for d in "${BLKDEVS[@]}"; do
+ echo $i
+ i=$((i+1))
+ vgcreate $SHARED TESTVG$i $d
+ vgchange -a n TESTVG$i
+done
diff --git a/test/shell/multi_hosts_vg_hostb.sh b/test/shell/multi_hosts_vg_hostb.sh
new file mode 100644
index 000000000000..bab65b68b35e
--- /dev/null
+++ b/test/shell/multi_hosts_vg_hostb.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing, the paired scripts
+# are: multi_hosts_vg_hosta.sh / multi_hosts_vg_hostb.sh
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgchange --lock-start
+
+i=0
+for d in "${BLKDEVS[@]}"; do
+ i=$((i+1))
+ check vg_field TESTVG$i lv_count 0
+done
+
+i=0
+for d in "${BLKDEVS[@]}"; do
+ i=$((i+1))
+ vgchange -a ey TESTVG$i
+ vgremove -ff TESTVG$i
+done
--
1.8.3.1

View File

@ -1,185 +0,0 @@
From e9950efff1d8cad43d6aec38fa30ff8b801960fb Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:23 +0800
Subject: [PATCH 27/33] tests: multi-hosts: Add LV testing
This patch is to add LV testing on multi hosts. There have two scripts,
the script multi_hosts_lv_hosta.sh is used to create LVs on one host,
and the second script multi_hosts_lv_hostb.sh will acquire
global lock and VG lock, and remove VGs. The testing flow verifies the
locking operations between two hosts with lvmlockd and the backend
locking manager.
On the host A:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hosta.sh
On the host B:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hostb.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/multi_hosts_lv_hosta.sh | 78 ++++++++++++++++++++++++++++++++++++++
test/shell/multi_hosts_lv_hostb.sh | 61 +++++++++++++++++++++++++++++
2 files changed, 139 insertions(+)
create mode 100644 test/shell/multi_hosts_lv_hosta.sh
create mode 100644 test/shell/multi_hosts_lv_hostb.sh
diff --git a/test/shell/multi_hosts_lv_hosta.sh b/test/shell/multi_hosts_lv_hosta.sh
new file mode 100644
index 000000000000..68404d251faa
--- /dev/null
+++ b/test/shell/multi_hosts_lv_hosta.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing, the paired scripts
+# are: multi_hosts_lv_hosta.sh / multi_hosts_lv_hostb.sh
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+BLKDEVS_NUM=${#BLKDEVS[@]}
+
+for d in "${BLKDEVS[@]}"; do
+ dd if=/dev/zero of="$d" bs=32k count=1
+ wipefs -a "$d" 2>/dev/null || true
+
+ sg_dev=`sg_map26 ${d}`
+ if [ -n "$LVM_TEST_LOCK_TYPE_IDM" ]; then
+ echo "Cleanup IDM context for drive ${d} ($sg_dev)"
+ sg_raw -v -r 512 -o /tmp/idm_tmp_data.bin $sg_dev \
+ 88 00 01 00 00 00 00 20 FF 01 00 00 00 01 00 00
+ sg_raw -v -s 512 -i /tmp/idm_tmp_data.bin $sg_dev \
+ 8E 00 FF 00 00 00 00 00 00 00 00 00 00 01 00 00
+ rm /tmp/idm_tmp_data.bin
+ fi
+done
+
+#aux prepare_pvs $BLKDEVS_NUM 6400
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ echo $i
+ d="dev$i"
+ vgcreate $SHARED TESTVG$i ${BLKDEVS[$(( i - 1 ))]}
+
+ for j in {1..20}; do
+ lvcreate -a n --zero n -l 1 -n foo$j TESTVG$i
+ done
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ for j in {1..20}; do
+ lvchange -a ey TESTVG$i/foo$j
+ done
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ for j in {1..20}; do
+ lvchange -a n TESTVG$i/foo$j
+ done
+done
diff --git a/test/shell/multi_hosts_lv_hostb.sh b/test/shell/multi_hosts_lv_hostb.sh
new file mode 100644
index 000000000000..13efd1a6b5b8
--- /dev/null
+++ b/test/shell/multi_hosts_lv_hostb.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing, the paired scripts
+# are: multi_hosts_lv_hosta.sh / multi_hosts_lv_hostb.sh
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgchange --lock-start
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ for j in {1..20}; do
+ lvchange -a sy TESTVG$i/foo$j
+ done
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ for j in {1..20}; do
+ lvchange -a ey TESTVG$i/foo$j
+ done
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ for j in {1..20}; do
+ lvchange -a n TESTVG$i/foo$j
+ done
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ vgremove -f TESTVG$i
+done
--
1.8.3.1

View File

@ -1,197 +0,0 @@
From 0a4d6d9d1d8ef4e3fe141c757dd5aad4b48b316c Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:24 +0800
Subject: [PATCH 28/33] tests: multi-hosts: Test lease timeout with LV
exclusive mode
This patch is to test timeout handling after activate LV with exclusive
mode. It contains two scripts for host A and host B separately.
The script on host A firstly creates VGs and LVs based on the passed
back devices, every back device is for a dedicated VG and a LV is
created as well in the VG. Afterwards, all LVs are activated by host A,
so host A acquires the lease for these LVs. Then the test is designed
to fail on host A.
After the host A fails, host B starts to run the paired testing script,
it firstly fails to activate the LVs since the locks are leased by
host A; after lease expiration (after 70s), host B can achieve the lease
for LVs and it can operate LVs and VGs.
On the host A:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hosta.sh
On the host B:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hostb.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/multi_hosts_lv_ex_timeout_hosta.sh | 87 +++++++++++++++++++++++++++
test/shell/multi_hosts_lv_ex_timeout_hostb.sh | 56 +++++++++++++++++
2 files changed, 143 insertions(+)
create mode 100644 test/shell/multi_hosts_lv_ex_timeout_hosta.sh
create mode 100644 test/shell/multi_hosts_lv_ex_timeout_hostb.sh
diff --git a/test/shell/multi_hosts_lv_ex_timeout_hosta.sh b/test/shell/multi_hosts_lv_ex_timeout_hosta.sh
new file mode 100644
index 000000000000..c8be91ee35f4
--- /dev/null
+++ b/test/shell/multi_hosts_lv_ex_timeout_hosta.sh
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing.
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+for d in "${BLKDEVS[@]}"; do
+ dd if=/dev/zero of="$d" bs=32k count=1
+ wipefs -a "$d" 2>/dev/null || true
+
+ sg_dev=`sg_map26 ${d}`
+ if [ -n "$LVM_TEST_LOCK_TYPE_IDM" ]; then
+ echo "Cleanup IDM context for drive ${d} ($sg_dev)"
+ sg_raw -v -r 512 -o /tmp/idm_tmp_data.bin $sg_dev \
+ 88 00 01 00 00 00 00 20 FF 01 00 00 00 01 00 00
+ sg_raw -v -s 512 -i /tmp/idm_tmp_data.bin $sg_dev \
+ 8E 00 FF 00 00 00 00 00 00 00 00 00 00 01 00 00
+ rm /tmp/idm_tmp_data.bin
+ fi
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ vgcreate $SHARED TESTVG$i ${BLKDEVS[$(( i - 1 ))]}
+ lvcreate -a n --zero n -l 1 -n foo TESTVG$i
+ lvchange -a ey TESTVG$i/foo
+done
+
+for d in "${BLKDEVS[@]}"; do
+ drive_wwn=`udevadm info $d | awk -F= '/E: ID_WWN=/ {print $2}'`
+ for dev in /dev/*; do
+ if [ -b "$dev" ] && [[ ! "$dev" =~ [0-9] ]]; then
+ wwn=`udevadm info "${dev}" | awk -F= '/E: ID_WWN=/ {print $2}'`
+ if [ "$wwn" = "$drive_wwn" ]; then
+ base_name="$(basename -- ${dev})"
+ drive_list+=("$base_name")
+ host_list+=(`readlink /sys/block/$base_name | awk -F'/' '{print $6}'`)
+ fi
+ fi
+ done
+done
+
+for d in "${drive_list[@]}"; do
+ [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+done
+
+sleep 100
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ check grep_lvmlockd_dump "S lvm_TESTVG$i kill_vg"
+ lvmlockctl --drop TESTVG$i
+done
+
+# Rescan drives so can probe the deleted drives and join back them
+for h in "${host_list[@]}"; do
+ [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+done
diff --git a/test/shell/multi_hosts_lv_ex_timeout_hostb.sh b/test/shell/multi_hosts_lv_ex_timeout_hostb.sh
new file mode 100644
index 000000000000..f0273fa44758
--- /dev/null
+++ b/test/shell/multi_hosts_lv_ex_timeout_hostb.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing.
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgchange --lock-start
+
+vgdisplay
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ not lvchange -a ey TESTVG$i/foo
+done
+
+# Sleep for 70 seconds so the previous lease is expired
+sleep 70
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ lvchange -a ey TESTVG$i/foo
+ lvchange -a n TESTVG$i/foo
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ vgremove -f TESTVG$i
+done
--
1.8.3.1

View File

@ -1,187 +0,0 @@
From fe05828e7e4c78a1ed4430ce4057c785d0b898a0 Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Thu, 3 Jun 2021 17:59:25 +0800
Subject: [PATCH 29/33] tests: multi-hosts: Test lease timeout with LV
shareable mode
This patch is to test timeout handling after activate LV with shareable
mode. It has the same logic with the testing for LV exclusive mode,
except it verifies the locking with shareable mode.
On the host A:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hosta.sh
On the host B:
make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hostb.sh
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/multi_hosts_lv_sh_timeout_hosta.sh | 87 +++++++++++++++++++++++++++
test/shell/multi_hosts_lv_sh_timeout_hostb.sh | 56 +++++++++++++++++
2 files changed, 143 insertions(+)
create mode 100644 test/shell/multi_hosts_lv_sh_timeout_hosta.sh
create mode 100644 test/shell/multi_hosts_lv_sh_timeout_hostb.sh
diff --git a/test/shell/multi_hosts_lv_sh_timeout_hosta.sh b/test/shell/multi_hosts_lv_sh_timeout_hosta.sh
new file mode 100644
index 000000000000..6b24f9290f1f
--- /dev/null
+++ b/test/shell/multi_hosts_lv_sh_timeout_hosta.sh
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing.
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+for d in "${BLKDEVS[@]}"; do
+ dd if=/dev/zero of="$d" bs=32k count=1
+ wipefs -a "$d" 2>/dev/null || true
+
+ sg_dev=`sg_map26 ${d}`
+ if [ -n "$LVM_TEST_LOCK_TYPE_IDM" ]; then
+ echo "Cleanup IDM context for drive ${d} ($sg_dev)"
+ sg_raw -v -r 512 -o /tmp/idm_tmp_data.bin $sg_dev \
+ 88 00 01 00 00 00 00 20 FF 01 00 00 00 01 00 00
+ sg_raw -v -s 512 -i /tmp/idm_tmp_data.bin $sg_dev \
+ 8E 00 FF 00 00 00 00 00 00 00 00 00 00 01 00 00
+ rm /tmp/idm_tmp_data.bin
+ fi
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ vgcreate $SHARED TESTVG$i ${BLKDEVS[$(( i - 1 ))]}
+ lvcreate -a n --zero n -l 1 -n foo TESTVG$i
+ lvchange -a sy TESTVG$i/foo
+done
+
+for d in "${BLKDEVS[@]}"; do
+ drive_wwn=`udevadm info $d | awk -F= '/E: ID_WWN=/ {print $2}'`
+ for dev in /dev/*; do
+ if [ -b "$dev" ] && [[ ! "$dev" =~ [0-9] ]]; then
+ wwn=`udevadm info "${dev}" | awk -F= '/E: ID_WWN=/ {print $2}'`
+ if [ "$wwn" = "$drive_wwn" ]; then
+ base_name="$(basename -- ${dev})"
+ drive_list+=("$base_name")
+ host_list+=(`readlink /sys/block/$base_name | awk -F'/' '{print $6}'`)
+ fi
+ fi
+ done
+done
+
+for d in "${drive_list[@]}"; do
+ [ -f /sys/block/$d/device/delete ] && echo 1 > /sys/block/$d/device/delete
+done
+
+sleep 100
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ check grep_lvmlockd_dump "S lvm_TESTVG$i kill_vg"
+ lvmlockctl --drop TESTVG$i
+done
+
+# Rescan drives so can probe the deleted drives and join back them
+for h in "${host_list[@]}"; do
+ [ -f /sys/class/scsi_host/${h}/scan ] && echo "- - -" > /sys/class/scsi_host/${h}/scan
+done
diff --git a/test/shell/multi_hosts_lv_sh_timeout_hostb.sh b/test/shell/multi_hosts_lv_sh_timeout_hostb.sh
new file mode 100644
index 000000000000..7aea2235dea1
--- /dev/null
+++ b/test/shell/multi_hosts_lv_sh_timeout_hostb.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+# This testing script is for multi-hosts testing.
+#
+# On the host A:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hosta.sh
+# On the host B:
+# make check_lvmlockd_idm \
+# LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
+# LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hostb.sh
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+[ -z "$LVM_TEST_MULTI_HOST" ] && skip;
+
+IFS=',' read -r -a BLKDEVS <<< "$LVM_TEST_BACKING_DEVICE"
+
+for d in "${BLKDEVS[@]}"; do
+ aux extend_filter_LVMTEST "a|$d|"
+done
+
+aux lvmconf "devices/allow_changes_with_duplicate_pvs = 1"
+
+vgchange --lock-start
+
+vgdisplay
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ lvchange -a sy TESTVG$i/foo
+done
+
+# Sleep for 70 seconds so the previous lease is expired
+sleep 70
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ lvchange -a ey TESTVG$i/foo
+ lvchange -a n TESTVG$i/foo
+done
+
+for i in $(seq 1 ${#BLKDEVS[@]}); do
+ vgremove -f TESTVG$i
+done
--
1.8.3.1

View File

@ -1,30 +0,0 @@
From c43f2f8ae08ed0555a300764c8644ea56f4f41e2 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 3 Jun 2021 14:44:55 -0500
Subject: [PATCH 30/33] fix empty mem pool leak
of "config" when LVM_SYSTEM_DIR=""
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/commands/toolcontext.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 296618686f7b..e2be89d0f480 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -966,8 +966,8 @@ static void _destroy_config(struct cmd_context *cmd)
/* CONFIG_FILE/CONFIG_MERGED_FILES */
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
config_destroy(cft);
- else
- remove_config_tree_by_source(cmd, CONFIG_FILE);
+ else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
+ config_destroy(cft);
dm_list_iterate_items(cfl, &cmd->config_files)
config_destroy(cfl->cft);
--
1.8.3.1

View File

@ -1,161 +0,0 @@
From a7f334a53269ee6967417a01d37b7f9592637cfc Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 7 Jun 2021 12:11:12 -0500
Subject: [PATCH 31/33] tests: writecache-blocksize add dm-cache tests
Add the same tests for dm-cache as exist for dm-writecache,
dm-cache uses a different blocksize in a couple cases.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/writecache-blocksize.sh | 64 +++++++++++++++++++++++++++-----------
1 file changed, 45 insertions(+), 19 deletions(-)
diff --git a/test/shell/writecache-blocksize.sh b/test/shell/writecache-blocksize.sh
index a8bb1e49d752..2579ef7b7bac 100644
--- a/test/shell/writecache-blocksize.sh
+++ b/test/shell/writecache-blocksize.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 writecache usage
+# Test dm-writecache and dm-cache with different block size combinations
SKIP_WITH_LVMPOLLD=1
@@ -94,6 +94,7 @@ _verify_data_on_lv() {
lvchange -an $vg/$lv1
}
+# Check that the LBS/PBS that were set up is accurately reported for the devs.
_check_env() {
check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$1"
@@ -105,24 +106,33 @@ _check_env() {
blockdev --getpbsz "$dev2"
}
+#
+# _run_test $BS1 $BS2 $type $optname "..."
+#
+# $BS1: the xfs sectsz is verified to match $BS1, after mkfs
+# $BS2: the lv1 LBS is verified to match $BS2, after cache is added to lv1
+# $type is cache or writecache to use in lvconvert --type $type
+# $optname is either --cachevol or --cachepool to use in lvconvert
+# "..." a sector size option to use in mkfs.xfs
+#
+
_run_test() {
vgcreate $SHARED $vg "$dev1"
vgextend $vg "$dev2"
lvcreate -n $lv1 -l 8 -an $vg "$dev1"
lvcreate -n $lv2 -l 4 -an $vg "$dev2"
lvchange -ay $vg/$lv1
- mkfs.xfs -f $2 "$DM_DEV_DIR/$vg/$lv1" |tee out
+ mkfs.xfs -f $5 "$DM_DEV_DIR/$vg/$lv1" |tee out
grep "sectsz=$1" out
_add_new_data_to_mnt
- lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
+ lvconvert --yes --type $3 $4 $lv2 $vg/$lv1
blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
- grep "$1" out
+ grep "$2" out
blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
_add_more_data_to_mnt
_verify_data_on_mnt
lvconvert --splitcache $vg/$lv1
check lv_field $vg/$lv1 segtype linear
- check lv_field $vg/$lv2 segtype linear
blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
_verify_data_on_mnt
@@ -136,7 +146,7 @@ _run_test() {
vgremove $vg
}
-# scsi_debug devices with 512 LBS 512 PBS
+# Setup: LBS 512, PBS 512
aux prepare_scsi_debug_dev 256 || skip
aux prepare_devs 2 64
@@ -150,43 +160,58 @@ vgremove -ff $vg
_check_env "512" "512"
-# lbs 512, pbs 512, xfs 512, wc 512
-_run_test 512 ""
+# lbs 512, pbs 512, xfs 512, wc bs 512
+_run_test 512 512 "writecache" "--cachevol" ""
+# lbs 512, pbs 512, xfs 512, cache bs 512
+_run_test 512 512 "cache" "--cachevol" ""
+_run_test 512 512 "cache" "--cachepool" ""
-# lbs 512, pbs 512, xfs -s 4096, wc 4096
-_run_test 4096 "-s size=4096"
+# lbs 512, pbs 512, xfs -s 4096, wc bs 4096
+_run_test 4096 4096 "writecache" "--cachevol" "-s size=4096"
+# lbs 512, pbs 512, xfs -s 4096, cache bs 512
+_run_test 4096 512 "cache" "--cachevol" "-s size=4096"
+_run_test 4096 512 "cache" "--cachepool" "-s size=4096"
aux cleanup_scsi_debug_dev
-# lbs=512, pbs=4096
+# Setup: LBS 512, PBS 4096
aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
aux prepare_devs 2 64
_check_env "512" "4096"
-# lbs 512, pbs 4k, xfs 4k, wc 4k
-_run_test 4096 ""
+# lbs 512, pbs 4k, xfs 4k, wc bs 4k
+_run_test 4096 4096 "writecache" "--cachevol" ""
+# lbs 512, pbs 4k, xfs 4k, cache bs 512
+_run_test 4096 512 "cache" "--cachevol" ""
+_run_test 4096 512 "cache" "--cachepool" ""
-# lbs 512, pbs 4k, xfs -s 512, wc 512
-_run_test 512 "-s size=512"
+# lbs 512, pbs 4k, xfs -s 512, wc bs 512
+_run_test 512 512 "writecache" "--cachevol" "-s size=512"
+# lbs 512, pbs 4k, xfs -s 512, cache bs 512
+_run_test 512 512 "cache" "--cachevol" "-s size=512"
+_run_test 512 512 "cache" "--cachepool" "-s size=512"
aux cleanup_scsi_debug_dev
-# scsi_debug devices with 4K LBS and 4K PBS
+# Setup: LBS 4096, PBS 4096
aux prepare_scsi_debug_dev 256 sector_size=4096
aux prepare_devs 2 64
_check_env "4096" "4096"
-# lbs 4k, pbs 4k, xfs 4k, wc 4k
-_run_test 4096 ""
+# lbs 4k, pbs 4k, xfs 4k, wc bs 4k
+_run_test 4096 4096 "writecache" "--cachevol" ""
+# lbs 4k, pbs 4k, xfs 4k, cache bs 4k
+_run_test 4096 4096 "cache" "--cachevol" ""
+_run_test 4096 4096 "cache" "--cachepool" ""
aux cleanup_scsi_debug_dev
-# scsi_debug devices with 512 LBS 512 PBS
+# Setup: LBS 512, PBS 512
aux prepare_scsi_debug_dev 256 || skip
aux prepare_devs 2 64
@@ -222,3 +247,4 @@ lvremove $vg/$lv2
vgremove $vg
aux cleanup_scsi_debug_dev
+
--
1.8.3.1

View File

@ -1,528 +0,0 @@
From ff677aa69f8fc31e5733b0650e2324c826ce0794 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 7 Jun 2021 12:12:33 -0500
Subject: [PATCH 32/33] tests: rename test
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/writecache-blocksize.sh | 250 -------------------------------
test/shell/writecache-cache-blocksize.sh | 250 +++++++++++++++++++++++++++++++
2 files changed, 250 insertions(+), 250 deletions(-)
delete mode 100644 test/shell/writecache-blocksize.sh
create mode 100644 test/shell/writecache-cache-blocksize.sh
diff --git a/test/shell/writecache-blocksize.sh b/test/shell/writecache-blocksize.sh
deleted file mode 100644
index 2579ef7b7bac..000000000000
--- a/test/shell/writecache-blocksize.sh
+++ /dev/null
@@ -1,250 +0,0 @@
-#!/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
-
-# Test dm-writecache and dm-cache with different block size combinations
-
-SKIP_WITH_LVMPOLLD=1
-
-. lib/inittest
-
-aux have_writecache 1 0 0 || skip
-which mkfs.xfs || skip
-
-mnt="mnt"
-mkdir -p $mnt
-
-awk 'BEGIN { while (z++ < 16384) printf "A" }' > fileA
-awk 'BEGIN { while (z++ < 16384) printf "B" }' > fileB
-awk 'BEGIN { while (z++ < 16384) printf "C" }' > fileC
-
-# generate random data
-dd if=/dev/urandom of=randA bs=512K count=2
-dd if=/dev/urandom of=randB bs=512K count=3
-dd if=/dev/urandom of=randC bs=512K count=4
-
-_add_new_data_to_mnt() {
- mount "$DM_DEV_DIR/$vg/$lv1" $mnt
-
- # add original data
- cp randA $mnt
- cp randB $mnt
- cp randC $mnt
- mkdir $mnt/1
- cp fileA $mnt/1
- cp fileB $mnt/1
- cp fileC $mnt/1
- mkdir $mnt/2
- cp fileA $mnt/2
- cp fileB $mnt/2
- cp fileC $mnt/2
- sync
-}
-
-_add_more_data_to_mnt() {
- mkdir $mnt/more
- cp fileA $mnt/more
- cp fileB $mnt/more
- cp fileC $mnt/more
- cp randA $mnt/more
- cp randB $mnt/more
- cp randC $mnt/more
- sync
-}
-
-_verify_data_on_mnt() {
- diff randA $mnt/randA
- diff randB $mnt/randB
- diff randC $mnt/randC
- diff fileA $mnt/1/fileA
- diff fileB $mnt/1/fileB
- diff fileC $mnt/1/fileC
- diff fileA $mnt/2/fileA
- diff fileB $mnt/2/fileB
- diff fileC $mnt/2/fileC
-}
-
-_verify_more_data_on_mnt() {
- diff randA $mnt/more/randA
- diff randB $mnt/more/randB
- diff randC $mnt/more/randC
- diff fileA $mnt/more/fileA
- diff fileB $mnt/more/fileB
- diff fileC $mnt/more/fileC
-}
-
-_verify_data_on_lv() {
- lvchange -ay $vg/$lv1
- mount "$DM_DEV_DIR/$vg/$lv1" $mnt
- _verify_data_on_mnt
- rm $mnt/randA
- rm $mnt/randB
- rm $mnt/randC
- rm -rf $mnt/1
- rm -rf $mnt/2
- umount $mnt
- lvchange -an $vg/$lv1
-}
-
-# Check that the LBS/PBS that were set up is accurately reported for the devs.
-_check_env() {
-
- check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$1"
- check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "$2"
-
- blockdev --getss "$dev1"
- blockdev --getpbsz "$dev1"
- blockdev --getss "$dev2"
- blockdev --getpbsz "$dev2"
-}
-
-#
-# _run_test $BS1 $BS2 $type $optname "..."
-#
-# $BS1: the xfs sectsz is verified to match $BS1, after mkfs
-# $BS2: the lv1 LBS is verified to match $BS2, after cache is added to lv1
-# $type is cache or writecache to use in lvconvert --type $type
-# $optname is either --cachevol or --cachepool to use in lvconvert
-# "..." a sector size option to use in mkfs.xfs
-#
-
-_run_test() {
- vgcreate $SHARED $vg "$dev1"
- vgextend $vg "$dev2"
- lvcreate -n $lv1 -l 8 -an $vg "$dev1"
- lvcreate -n $lv2 -l 4 -an $vg "$dev2"
- lvchange -ay $vg/$lv1
- mkfs.xfs -f $5 "$DM_DEV_DIR/$vg/$lv1" |tee out
- grep "sectsz=$1" out
- _add_new_data_to_mnt
- lvconvert --yes --type $3 $4 $lv2 $vg/$lv1
- blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
- grep "$2" out
- blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
- _add_more_data_to_mnt
- _verify_data_on_mnt
- lvconvert --splitcache $vg/$lv1
- check lv_field $vg/$lv1 segtype linear
- blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
- blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
- _verify_data_on_mnt
- _verify_more_data_on_mnt
- umount $mnt
- lvchange -an $vg/$lv1
- lvchange -an $vg/$lv2
- _verify_data_on_lv
- lvremove $vg/$lv1
- lvremove $vg/$lv2
- vgremove $vg
-}
-
-# Setup: LBS 512, PBS 512
-aux prepare_scsi_debug_dev 256 || skip
-aux prepare_devs 2 64
-
-# Tests with fs block sizes require a libblkid version that shows BLOCK_SIZE
-vgcreate $vg "$dev1"
-lvcreate -n $lv1 -L50 $vg
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
-blkid -c /dev/null "$DM_DEV_DIR/$vg/$lv1" | grep BLOCK_SIZE || skip
-lvchange -an $vg
-vgremove -ff $vg
-
-_check_env "512" "512"
-
-# lbs 512, pbs 512, xfs 512, wc bs 512
-_run_test 512 512 "writecache" "--cachevol" ""
-# lbs 512, pbs 512, xfs 512, cache bs 512
-_run_test 512 512 "cache" "--cachevol" ""
-_run_test 512 512 "cache" "--cachepool" ""
-
-# lbs 512, pbs 512, xfs -s 4096, wc bs 4096
-_run_test 4096 4096 "writecache" "--cachevol" "-s size=4096"
-# lbs 512, pbs 512, xfs -s 4096, cache bs 512
-_run_test 4096 512 "cache" "--cachevol" "-s size=4096"
-_run_test 4096 512 "cache" "--cachepool" "-s size=4096"
-
-aux cleanup_scsi_debug_dev
-
-
-# Setup: LBS 512, PBS 4096
-aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
-aux prepare_devs 2 64
-
-_check_env "512" "4096"
-
-# lbs 512, pbs 4k, xfs 4k, wc bs 4k
-_run_test 4096 4096 "writecache" "--cachevol" ""
-# lbs 512, pbs 4k, xfs 4k, cache bs 512
-_run_test 4096 512 "cache" "--cachevol" ""
-_run_test 4096 512 "cache" "--cachepool" ""
-
-# lbs 512, pbs 4k, xfs -s 512, wc bs 512
-_run_test 512 512 "writecache" "--cachevol" "-s size=512"
-# lbs 512, pbs 4k, xfs -s 512, cache bs 512
-_run_test 512 512 "cache" "--cachevol" "-s size=512"
-_run_test 512 512 "cache" "--cachepool" "-s size=512"
-
-aux cleanup_scsi_debug_dev
-
-
-# Setup: LBS 4096, PBS 4096
-aux prepare_scsi_debug_dev 256 sector_size=4096
-aux prepare_devs 2 64
-
-_check_env "4096" "4096"
-
-# lbs 4k, pbs 4k, xfs 4k, wc bs 4k
-_run_test 4096 4096 "writecache" "--cachevol" ""
-# lbs 4k, pbs 4k, xfs 4k, cache bs 4k
-_run_test 4096 4096 "cache" "--cachevol" ""
-_run_test 4096 4096 "cache" "--cachepool" ""
-
-aux cleanup_scsi_debug_dev
-
-
-# Setup: LBS 512, PBS 512
-aux prepare_scsi_debug_dev 256 || skip
-aux prepare_devs 2 64
-
-_check_env "512" "512"
-
-vgcreate $SHARED $vg "$dev1"
-vgextend $vg "$dev2"
-lvcreate -n $lv1 -l 8 -an $vg "$dev1"
-lvcreate -n $lv2 -l 4 -an $vg "$dev2"
-lvconvert --yes --type writecache --cachevol $lv2 --cachesettings "block_size=4096" $vg/$lv1
-lvchange -ay $vg/$lv1
-mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1" |tee out
-grep "sectsz=4096" out
-_add_new_data_to_mnt
-blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
-grep 4096 out
-blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
-_add_more_data_to_mnt
-_verify_data_on_mnt
-lvconvert --splitcache $vg/$lv1
-check lv_field $vg/$lv1 segtype linear
-check lv_field $vg/$lv2 segtype linear
-blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
-blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
-_verify_data_on_mnt
-_verify_more_data_on_mnt
-umount $mnt
-lvchange -an $vg/$lv1
-lvchange -an $vg/$lv2
-_verify_data_on_lv
-lvremove $vg/$lv1
-lvremove $vg/$lv2
-vgremove $vg
-
-aux cleanup_scsi_debug_dev
-
diff --git a/test/shell/writecache-cache-blocksize.sh b/test/shell/writecache-cache-blocksize.sh
new file mode 100644
index 000000000000..2579ef7b7bac
--- /dev/null
+++ b/test/shell/writecache-cache-blocksize.sh
@@ -0,0 +1,250 @@
+#!/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
+
+# Test dm-writecache and dm-cache with different block size combinations
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+mnt="mnt"
+mkdir -p $mnt
+
+awk 'BEGIN { while (z++ < 16384) printf "A" }' > fileA
+awk 'BEGIN { while (z++ < 16384) printf "B" }' > fileB
+awk 'BEGIN { while (z++ < 16384) printf "C" }' > fileC
+
+# generate random data
+dd if=/dev/urandom of=randA bs=512K count=2
+dd if=/dev/urandom of=randB bs=512K count=3
+dd if=/dev/urandom of=randC bs=512K count=4
+
+_add_new_data_to_mnt() {
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp randA $mnt
+ cp randB $mnt
+ cp randC $mnt
+ mkdir $mnt/1
+ cp fileA $mnt/1
+ cp fileB $mnt/1
+ cp fileC $mnt/1
+ mkdir $mnt/2
+ cp fileA $mnt/2
+ cp fileB $mnt/2
+ cp fileC $mnt/2
+ sync
+}
+
+_add_more_data_to_mnt() {
+ mkdir $mnt/more
+ cp fileA $mnt/more
+ cp fileB $mnt/more
+ cp fileC $mnt/more
+ cp randA $mnt/more
+ cp randB $mnt/more
+ cp randC $mnt/more
+ sync
+}
+
+_verify_data_on_mnt() {
+ diff randA $mnt/randA
+ diff randB $mnt/randB
+ diff randC $mnt/randC
+ diff fileA $mnt/1/fileA
+ diff fileB $mnt/1/fileB
+ diff fileC $mnt/1/fileC
+ diff fileA $mnt/2/fileA
+ diff fileB $mnt/2/fileB
+ diff fileC $mnt/2/fileC
+}
+
+_verify_more_data_on_mnt() {
+ diff randA $mnt/more/randA
+ diff randB $mnt/more/randB
+ diff randC $mnt/more/randC
+ diff fileA $mnt/more/fileA
+ diff fileB $mnt/more/fileB
+ diff fileC $mnt/more/fileC
+}
+
+_verify_data_on_lv() {
+ lvchange -ay $vg/$lv1
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+ _verify_data_on_mnt
+ rm $mnt/randA
+ rm $mnt/randB
+ rm $mnt/randC
+ rm -rf $mnt/1
+ rm -rf $mnt/2
+ umount $mnt
+ lvchange -an $vg/$lv1
+}
+
+# Check that the LBS/PBS that were set up is accurately reported for the devs.
+_check_env() {
+
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$1"
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "$2"
+
+ blockdev --getss "$dev1"
+ blockdev --getpbsz "$dev1"
+ blockdev --getss "$dev2"
+ blockdev --getpbsz "$dev2"
+}
+
+#
+# _run_test $BS1 $BS2 $type $optname "..."
+#
+# $BS1: the xfs sectsz is verified to match $BS1, after mkfs
+# $BS2: the lv1 LBS is verified to match $BS2, after cache is added to lv1
+# $type is cache or writecache to use in lvconvert --type $type
+# $optname is either --cachevol or --cachepool to use in lvconvert
+# "..." a sector size option to use in mkfs.xfs
+#
+
+_run_test() {
+ vgcreate $SHARED $vg "$dev1"
+ vgextend $vg "$dev2"
+ lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+ lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+ lvchange -ay $vg/$lv1
+ mkfs.xfs -f $5 "$DM_DEV_DIR/$vg/$lv1" |tee out
+ grep "sectsz=$1" out
+ _add_new_data_to_mnt
+ lvconvert --yes --type $3 $4 $lv2 $vg/$lv1
+ blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
+ grep "$2" out
+ blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+ _add_more_data_to_mnt
+ _verify_data_on_mnt
+ lvconvert --splitcache $vg/$lv1
+ check lv_field $vg/$lv1 segtype linear
+ blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+ blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+ _verify_data_on_mnt
+ _verify_more_data_on_mnt
+ umount $mnt
+ lvchange -an $vg/$lv1
+ lvchange -an $vg/$lv2
+ _verify_data_on_lv
+ lvremove $vg/$lv1
+ lvremove $vg/$lv2
+ vgremove $vg
+}
+
+# Setup: LBS 512, PBS 512
+aux prepare_scsi_debug_dev 256 || skip
+aux prepare_devs 2 64
+
+# Tests with fs block sizes require a libblkid version that shows BLOCK_SIZE
+vgcreate $vg "$dev1"
+lvcreate -n $lv1 -L50 $vg
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+blkid -c /dev/null "$DM_DEV_DIR/$vg/$lv1" | grep BLOCK_SIZE || skip
+lvchange -an $vg
+vgremove -ff $vg
+
+_check_env "512" "512"
+
+# lbs 512, pbs 512, xfs 512, wc bs 512
+_run_test 512 512 "writecache" "--cachevol" ""
+# lbs 512, pbs 512, xfs 512, cache bs 512
+_run_test 512 512 "cache" "--cachevol" ""
+_run_test 512 512 "cache" "--cachepool" ""
+
+# lbs 512, pbs 512, xfs -s 4096, wc bs 4096
+_run_test 4096 4096 "writecache" "--cachevol" "-s size=4096"
+# lbs 512, pbs 512, xfs -s 4096, cache bs 512
+_run_test 4096 512 "cache" "--cachevol" "-s size=4096"
+_run_test 4096 512 "cache" "--cachepool" "-s size=4096"
+
+aux cleanup_scsi_debug_dev
+
+
+# Setup: LBS 512, PBS 4096
+aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
+aux prepare_devs 2 64
+
+_check_env "512" "4096"
+
+# lbs 512, pbs 4k, xfs 4k, wc bs 4k
+_run_test 4096 4096 "writecache" "--cachevol" ""
+# lbs 512, pbs 4k, xfs 4k, cache bs 512
+_run_test 4096 512 "cache" "--cachevol" ""
+_run_test 4096 512 "cache" "--cachepool" ""
+
+# lbs 512, pbs 4k, xfs -s 512, wc bs 512
+_run_test 512 512 "writecache" "--cachevol" "-s size=512"
+# lbs 512, pbs 4k, xfs -s 512, cache bs 512
+_run_test 512 512 "cache" "--cachevol" "-s size=512"
+_run_test 512 512 "cache" "--cachepool" "-s size=512"
+
+aux cleanup_scsi_debug_dev
+
+
+# Setup: LBS 4096, PBS 4096
+aux prepare_scsi_debug_dev 256 sector_size=4096
+aux prepare_devs 2 64
+
+_check_env "4096" "4096"
+
+# lbs 4k, pbs 4k, xfs 4k, wc bs 4k
+_run_test 4096 4096 "writecache" "--cachevol" ""
+# lbs 4k, pbs 4k, xfs 4k, cache bs 4k
+_run_test 4096 4096 "cache" "--cachevol" ""
+_run_test 4096 4096 "cache" "--cachepool" ""
+
+aux cleanup_scsi_debug_dev
+
+
+# Setup: LBS 512, PBS 512
+aux prepare_scsi_debug_dev 256 || skip
+aux prepare_devs 2 64
+
+_check_env "512" "512"
+
+vgcreate $SHARED $vg "$dev1"
+vgextend $vg "$dev2"
+lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+lvconvert --yes --type writecache --cachevol $lv2 --cachesettings "block_size=4096" $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1" |tee out
+grep "sectsz=4096" out
+_add_new_data_to_mnt
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
+grep 4096 out
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+_add_more_data_to_mnt
+_verify_data_on_mnt
+lvconvert --splitcache $vg/$lv1
+check lv_field $vg/$lv1 segtype linear
+check lv_field $vg/$lv2 segtype linear
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+_verify_data_on_mnt
+_verify_more_data_on_mnt
+umount $mnt
+lvchange -an $vg/$lv1
+lvchange -an $vg/$lv2
+_verify_data_on_lv
+lvremove $vg/$lv1
+lvremove $vg/$lv2
+vgremove $vg
+
+aux cleanup_scsi_debug_dev
+
--
1.8.3.1

View File

@ -1,255 +0,0 @@
From 9759f915e78044667681de395bf2694bd5c7f393 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 7 Jun 2021 15:40:40 -0500
Subject: [PATCH 33/33] tests: add writecache-cache-blocksize-2
inconsistent physical block size of devs used
for main LV and cache
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
test/shell/writecache-cache-blocksize-2.sh | 232 +++++++++++++++++++++++++++++
1 file changed, 232 insertions(+)
create mode 100644 test/shell/writecache-cache-blocksize-2.sh
diff --git a/test/shell/writecache-cache-blocksize-2.sh b/test/shell/writecache-cache-blocksize-2.sh
new file mode 100644
index 000000000000..af4f60e1dcf8
--- /dev/null
+++ b/test/shell/writecache-cache-blocksize-2.sh
@@ -0,0 +1,232 @@
+#!/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
+
+# Test dm-writecache and dm-cache with different block size combinations
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+mnt="mnt"
+mkdir -p $mnt
+
+awk 'BEGIN { while (z++ < 16384) printf "A" }' > fileA
+awk 'BEGIN { while (z++ < 16384) printf "B" }' > fileB
+awk 'BEGIN { while (z++ < 16384) printf "C" }' > fileC
+
+# generate random data
+dd if=/dev/urandom of=randA bs=512K count=2
+dd if=/dev/urandom of=randB bs=512K count=3
+dd if=/dev/urandom of=randC bs=512K count=4
+
+_add_new_data_to_mnt() {
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp randA $mnt
+ cp randB $mnt
+ cp randC $mnt
+ mkdir $mnt/1
+ cp fileA $mnt/1
+ cp fileB $mnt/1
+ cp fileC $mnt/1
+ mkdir $mnt/2
+ cp fileA $mnt/2
+ cp fileB $mnt/2
+ cp fileC $mnt/2
+ sync
+}
+
+_add_more_data_to_mnt() {
+ mkdir $mnt/more
+ cp fileA $mnt/more
+ cp fileB $mnt/more
+ cp fileC $mnt/more
+ cp randA $mnt/more
+ cp randB $mnt/more
+ cp randC $mnt/more
+ sync
+}
+
+_verify_data_on_mnt() {
+ diff randA $mnt/randA
+ diff randB $mnt/randB
+ diff randC $mnt/randC
+ diff fileA $mnt/1/fileA
+ diff fileB $mnt/1/fileB
+ diff fileC $mnt/1/fileC
+ diff fileA $mnt/2/fileA
+ diff fileB $mnt/2/fileB
+ diff fileC $mnt/2/fileC
+}
+
+_verify_more_data_on_mnt() {
+ diff randA $mnt/more/randA
+ diff randB $mnt/more/randB
+ diff randC $mnt/more/randC
+ diff fileA $mnt/more/fileA
+ diff fileB $mnt/more/fileB
+ diff fileC $mnt/more/fileC
+}
+
+_verify_data_on_lv() {
+ lvchange -ay $vg/$lv1
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+ _verify_data_on_mnt
+ rm $mnt/randA
+ rm $mnt/randB
+ rm $mnt/randC
+ rm -rf $mnt/1
+ rm -rf $mnt/2
+ umount $mnt
+ lvchange -an $vg/$lv1
+}
+
+# Check that the LBS ($1) and PBS ($2) are accurately reported.
+_check_env() {
+
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$1"
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "$2"
+
+ blockdev --getss "$dev1"
+ blockdev --getpbsz "$dev1"
+ blockdev --getss "$dev2"
+ blockdev --getpbsz "$dev2"
+}
+
+#
+# _run_test $BD1 $BD2 $type $optname "..."
+#
+# $BD1: device to place the main LV on
+# $BD2: device to place the cache on
+# $type is cache or writecache to use in lvconvert --type $type
+# $optname is either --cachevol or --cachepool to use in lvconvert
+# "..." a sector size option to use in mkfs.xfs
+#
+
+_run_test() {
+ vgcreate $SHARED $vg "$1"
+ vgextend $vg "$2"
+ lvcreate -n $lv1 -l 8 -an $vg "$1"
+ lvcreate -n $lv2 -l 4 -an $vg "$2"
+ lvchange -ay $vg/$lv1
+ mkfs.xfs -f $5 "$DM_DEV_DIR/$vg/$lv1" |tee out
+ _add_new_data_to_mnt
+ lvconvert --yes --type $3 $4 $lv2 $vg/$lv1
+
+ # TODO: check expected LBS of LV1
+ # blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
+ # grep "$N" out
+ # TODO: check expected PBS of LV1
+ # blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1" |tee out
+ # grep "$N" out
+
+ _add_more_data_to_mnt
+ _verify_data_on_mnt
+ lvconvert --splitcache $vg/$lv1
+ check lv_field $vg/$lv1 segtype linear
+ blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+ blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+ _verify_data_on_mnt
+ _verify_more_data_on_mnt
+ umount $mnt
+ lvchange -an $vg/$lv1
+ lvchange -an $vg/$lv2
+ _verify_data_on_lv
+ lvremove $vg/$lv1
+ lvremove $vg/$lv2
+ vgremove $vg
+}
+
+# Setup: dev1 LBS 512, PBS 4096 (using scsi-debug)
+# dev2 LBS 512, PBS 4096 (using scsi-debug)
+# dev3 LBS 512, PBS 512 (using loop)
+# dev4 LBS 512, PBS 512 (using loop)
+#
+
+aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
+aux prepare_devs 2 64
+
+# loopa/loopb have LBS 512 PBS 512
+which fallocate || skip
+fallocate -l 64M loopa
+fallocate -l 64M loopb
+
+for i in {1..5}; do
+ LOOP1=$(losetup -f loopa --show || true)
+ test -n "$LOOP1" && break
+done
+for i in {1..5} ; do
+ LOOP2=$(losetup -f loopb --show || true)
+ test -n "$LOOP2" && break
+done
+
+# prepare devX mapping so it works for real & fake dev dir
+d=3
+for i in "$LOOP1" "$LOOP2"; do
+ echo "$i"
+ m=${i##*loop}
+ test -e "$DM_DEV_DIR/loop$m" || mknod "$DM_DEV_DIR/loop$m" b 7 "$m"
+ eval "dev$d=\"$DM_DEV_DIR/loop$m\""
+ d=$(( d + 1 ))
+done
+
+# verify dev1/dev2 have LBS 512 PBS 4096
+_check_env "512" "4096"
+
+# verify dev3/dev4 have LBS 512 PBS 512
+blockdev --getss "$LOOP1" | grep 512
+blockdev --getss "$LOOP2" | grep 512
+blockdev --getpbsz "$LOOP1" | grep 512
+blockdev --getpbsz "$LOOP2" | grep 512
+
+aux extend_filter "a|$dev3|" "a|$dev4|"
+
+# place main LV on dev1 with LBS 512, PBS 4096
+# and the cache on dev3 with LBS 512, PBS 512
+
+_run_test "$dev1" "$dev3" "writecache" "--cachevol" ""
+_run_test "$dev1" "$dev3" "cache" "--cachevol" ""
+_run_test "$dev1" "$dev3" "cache" "--cachepool" ""
+
+# place main LV on dev3 with LBS 512, PBS 512
+# and the cache on dev1 with LBS 512, PBS 4096
+
+_run_test "$dev3" "$dev1" "writecache" "--cachevol" ""
+_run_test "$dev3" "$dev1" "cache" "--cachevol" ""
+_run_test "$dev3" "$dev1" "cache" "--cachepool" ""
+
+# place main LV on dev1 with LBS 512, PBS 4096
+# and the cache on dev3 with LBS 512, PBS 512
+# and force xfs sectsz 512
+
+_run_test "$dev1" "$dev3" "writecache" "--cachevol" "-s size=512"
+_run_test "$dev1" "$dev3" "cache" "--cachevol" "-s size=512"
+_run_test "$dev1" "$dev3" "cache" "--cachepool" "-s size=512"
+
+# place main LV on dev3 with LBS 512, PBS 512
+# and the cache on dev1 with LBS 512, PBS 4096
+# and force xfs sectsz 4096
+
+_run_test "$dev3" "$dev1" "writecache" "--cachevol" "-s size=4096"
+_run_test "$dev3" "$dev1" "cache" "--cachevol" "-s size=4096"
+_run_test "$dev3" "$dev1" "cache" "--cachepool" "-s size=4096"
+
+
+losetup -d "$LOOP1" || true
+losetup -d "$LOOP2" || true
+rm loopa loopb
+
+aux cleanup_scsi_debug_dev
--
1.8.3.1

View File

@ -1,42 +0,0 @@
From 5e17203ff5dd4296760e5dad683e4cc84df2801d Mon Sep 17 00:00:00 2001
From: Leo Yan <leo.yan@linaro.org>
Date: Tue, 8 Jun 2021 14:45:09 +0800
Subject: [PATCH 1/8] lvmlockd: Fix the compilation warning
As SUSE build tool reports the warning:
lvmlockd-core.c: In function 'client_thread_main':
lvmlockd-core.c:4959:37: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "path[%d]", i);
^~
lvmlockd-core.c:4959:31: note: directive argument in the range [0, 2147483647]
snprintf(buf, sizeof(buf), "path[%d]", i);
^~~~~~~~~~
To dismiss the compilation warning, enlarge the array "buf" to 17
bytes to support the max signed integer: string format 6 bytes + signed
integer 10 bytes + terminal char "\0".
Reported-by: Heming Zhao <heming.zhao@suse.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
daemons/lvmlockd/lvmlockd-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index ea76f2214b3e..fef9589b9d98 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4780,7 +4780,7 @@ static void client_recv_action(struct client *cl)
const char *path;
const char *str;
struct pvs pvs;
- char buf[11]; /* p a t h [ x x x x ] \0 */
+ char buf[17]; /* "path[%d]\0", %d outputs signed integer so max to 10 bytes */
int64_t val;
uint32_t opts = 0;
int result = 0;
--
1.8.3.1

View File

@ -1,38 +0,0 @@
From ca930bd936de2e7d4a83fa64add800baf6cfd116 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Jun 2021 12:16:06 -0500
Subject: [PATCH 2/8] devices: don't use deleted loop backing file for device
id
check for "(deleted)" in the backing_file string and
fall back to devname for id.
$ cat /sys/block/loop0/loop/backing_file
/root/looptmp (deleted)
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/device/device_id.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 67f72e51b1ba..1b98487ab3a6 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -325,8 +325,12 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
else if (idtype == DEV_ID_TYPE_MD_UUID)
_read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
- else if (idtype == DEV_ID_TYPE_LOOP_FILE)
+ else if (idtype == DEV_ID_TYPE_LOOP_FILE) {
_read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf));
+ /* if backing file is deleted, fall back to devname */
+ if (strstr(sysbuf, "(deleted)"))
+ sysbuf[0] = '\0';
+ }
else if (idtype == DEV_ID_TYPE_DEVNAME) {
if (!(idname = strdup(dev_name(dev))))
--
1.8.3.1

View File

@ -1,80 +0,0 @@
From df27392c8c9ec5d1efd92c2214805471473f2a06 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Jun 2021 14:07:39 -0500
Subject: [PATCH 3/8] man/help: fix common option listing
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/command.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/tools/command.c b/tools/command.c
index 1de739aaa0de..7205969e1c2f 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2146,6 +2146,7 @@ void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
{
int oo, opt_enum;
+ int found_common_command = 0;
/*
* when there's more than one variant, options that
@@ -2155,6 +2156,18 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf(" Common options for command:");
/* print options with short opts */
@@ -2213,7 +2226,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
printf(" ]");
}
- printf(".P\n");
+ printf("\n\n");
}
void print_usage_notes(struct command_name *cname)
@@ -2994,6 +3007,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
{
struct command_name *cname;
int i, sep, oo, opt_enum;
+ int found_common_command = 0;
if (!(cname = _find_command_name(cmd->name)))
return;
@@ -3001,6 +3015,18 @@ static void _print_man_usage_common_cmd(struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf("Common options for command:\n");
printf(".\n");
--
1.8.3.1

View File

@ -1,417 +0,0 @@
From ba3707d9539f9cc2e72c5368388ae795776379af Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 8 Jun 2021 19:02:07 +0200
Subject: [PATCH 4/8] archiving: take archive automatically
Instead of calling explicit archive with command processing logic,
move this step towards 1st. vg_write() call, which will automatically
store archive of committed metadata.
This slightly changes some error path where the error in archiving
was detected earlier in the command, while now some on going command
'actions' might have been, but will be simply scratched in case
of error (since even new metadata would not have been even written).
So general effect should be only some command message ordering.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/metadata/lv_manip.c | 15 ---------------
lib/metadata/metadata.c | 6 +++---
lib/metadata/pv_manip.c | 3 ---
lib/metadata/vg.c | 3 ---
tools/lvconvert.c | 30 ------------------------------
tools/pvchange.c | 2 --
tools/pvmove.c | 3 ---
tools/vgchange.c | 8 --------
tools/vgcreate.c | 3 ---
tools/vgexport.c | 4 ----
tools/vgextend.c | 6 ------
tools/vgimport.c | 3 ---
tools/vgimportclone.c | 3 ---
tools/vgreduce.c | 3 ---
tools/vgrename.c | 3 ---
15 files changed, 3 insertions(+), 92 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 37dd3611dde7..899297f28498 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4834,9 +4834,6 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (update_mda && !archive(vg))
- return_0;
-
if (old_lv_is_historical) {
/*
* Historical LVs have neither sub LVs nor any
@@ -6146,9 +6143,6 @@ int lv_resize(struct logical_volume *lv,
if (!lockd_lv_resize(cmd, lock_lv, "ex", 0, lp))
return_0;
- if (!archive(vg))
- return_0;
-
/* Remove any striped raid reshape space for LV resizing */
if (aux_lv && first_seg(aux_lv)->reshape_len)
if (!lv_raid_free_reshape_space(aux_lv))
@@ -6719,9 +6713,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (!archive(vg))
- return_0;
-
if (!lv_detach_writecache_cachevol(lv, 1)) {
log_error("Failed to detach writecache from %s", display_lvname(lv));
return 0;
@@ -6742,9 +6733,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* FIXME Review and fix the snapshot error paths! */
return_0;
- if (!archive(vg))
- return_0;
-
/* Special case removing a striped raid LV with allocated reshape space */
if (seg && seg->reshape_len) {
if (!(seg->segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_STRIPED)))
@@ -8458,9 +8446,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!archive(vg))
- return_NULL;
-
if (pool_lv && segtype_is_thin_volume(create_segtype)) {
/* Ensure all stacked messages are submitted */
if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 0b284435b41b..6852d2a2a7fe 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -614,9 +614,6 @@ int vg_remove_check(struct volume_group *vg)
return 0;
}
- if (!archive(vg))
- return 0;
-
return 1;
}
@@ -2978,6 +2975,9 @@ int vg_write(struct volume_group *vg)
if (vg->cmd->wipe_outdated_pvs)
_wipe_outdated_pvs(vg->cmd, vg);
+ if (!vg_is_archived(vg) && vg->vg_committed && !archive(vg->vg_committed))
+ return_0;
+
if (critical_section())
log_error(INTERNAL_ERROR
"Writing metadata in critical section.");
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 5fd80a2ceca3..fd97bbbc2462 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -623,9 +623,6 @@ int pv_resize_single(struct cmd_context *cmd,
const char *vg_name = pv->vg_name;
int vg_needs_pv_write = 0;
- if (!archive(vg))
- goto out;
-
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
pv_name);
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 3f9ec8d350fb..428e5dca79c6 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -694,9 +694,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
pvl = find_pv_in_vg(vg, name);
- if (!archive(vg))
- goto_bad;
-
log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
if (pvl)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 71f7a7627fa1..c40031fe47a8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1861,9 +1861,6 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
}
}
- if (!archive(vg))
- return_0;
-
log_verbose("Splitting snapshot %s from its origin.", display_lvname(cow));
if (!vg_remove_snapshot(cow))
@@ -2796,9 +2793,6 @@ static int _lvconvert_to_thin_with_external(struct cmd_context *cmd,
if (!(lvc.segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_THIN)))
return_0;
- if (!archive(vg))
- return_0;
-
/*
* New thin LV needs to be created (all messages sent to pool) In this
* case thin volume is created READ-ONLY and also warn about not
@@ -2979,9 +2973,6 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
return 0;
}
- if (!archive(vg))
- return_0;
-
/* Swap names between old and new metadata LV */
if (!detach_pool_metadata_lv(seg, &prev_metadata_lv))
@@ -3286,9 +3277,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
meta_readahead = arg_uint_value(cmd, readahead_ARG, cmd->default_settings.read_ahead);
meta_alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
- if (!archive(vg))
- goto_bad;
-
if (!(metadata_lv = alloc_pool_metadata(lv,
meta_name,
meta_readahead,
@@ -3305,9 +3293,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
goto bad;
}
- if (!archive(vg))
- goto_bad;
-
if (zero_metadata) {
metadata_lv->status |= LV_ACTIVATION_SKIP;
if (!activate_lv(cmd, metadata_lv)) {
@@ -3556,9 +3541,6 @@ static int _cache_vol_attach(struct cmd_context *cmd,
if (!get_cache_params(cmd, &chunk_size, &cache_metadata_format, &cache_mode, &policy_name, &policy_settings))
goto_out;
- if (!archive(vg))
- goto_out;
-
/*
* lv/cache_lv keeps the same lockd lock it had before, the lock for
* lv_fast is kept but is not used while it's attached, and
@@ -5525,9 +5507,6 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
}
}
- if (!archive(vg))
- goto_out;
-
if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, zero_vdopool))
goto_out;
@@ -6198,9 +6177,6 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
if (fast_name && !lockd_lv(cmd, lv_fast, "ex", 0))
goto_bad;
- if (!archive(vg))
- goto_bad;
-
/*
* lv keeps the same lockd lock it had before, the lock for
* lv_fast is kept but is not used while it's attached, and
@@ -6339,9 +6315,6 @@ static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_v
if (!lockd_lv(cmd, lv, "ex", 0))
return_0;
- if (!archive(vg))
- return_0;
-
if (lv_is_raid(lv))
ret = lv_remove_integrity_from_raid(lv);
if (!ret)
@@ -6371,9 +6344,6 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
} else
use_pvh = &vg->pvs;
- if (!archive(vg))
- return_0;
-
if (lv_is_partial(lv)) {
log_error("Cannot add integrity while LV is missing PVs.");
return 0;
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 04cbb428dde1..8b4a0643d3cd 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -65,8 +65,6 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
"logical volumes", pv_name);
goto bad;
}
- if (!archive(vg))
- goto_bad;
} else {
if (tagargs) {
log_error("Can't change tag on Physical Volume %s not "
diff --git a/tools/pvmove.c b/tools/pvmove.c
index bb372f7dcaeb..ed92f3ce4a6d 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -709,9 +709,6 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
vg, pv, pp->alloc)))
goto_out;
- if (!archive(vg))
- goto_out;
-
if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, source_pvl, lv_name,
allocatable_pvs, pp->alloc,
&lvs_changed, &exclusive)))
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 032f3efcfd04..625b68d46b56 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -675,8 +675,6 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
for (i = 0; i < DM_ARRAY_SIZE(_vgchange_args); ++i) {
if (arg_is_set(cmd, _vgchange_args[i].arg)) {
- if (!archive(vg))
- return_ECMD_FAILED;
if (!_vgchange_args[i].fn(cmd, vg))
return_ECMD_FAILED;
}
@@ -1002,9 +1000,6 @@ static int _vgchange_locktype_single(struct cmd_context *cmd, const char *vg_nam
struct volume_group *vg,
struct processing_handle *handle)
{
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!_vgchange_locktype(cmd, vg))
return_ECMD_FAILED;
@@ -1201,9 +1196,6 @@ static int _vgchange_systemid_single(struct cmd_context *cmd, const char *vg_nam
struct volume_group *vg,
struct processing_handle *handle)
{
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!_vgchange_system_id(cmd, vg))
return_ECMD_FAILED;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index f9c40e86d646..d6d6bb61ddc3 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -148,9 +148,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
}
- if (!archive(vg))
- goto_bad;
-
/* Store VG on disk(s) */
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
diff --git a/tools/vgexport.c b/tools/vgexport.c
index 86dad3abb432..15cc3dd75d56 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -45,10 +45,6 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
}
}
-
- if (!archive(vg))
- goto_bad;
-
vg->status |= EXPORTED_VG;
vg->system_id = NULL;
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 04d37f886d4d..b0f49569f492 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -60,9 +60,6 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
int fixed = 0;
unsigned i;
- if (!archive(vg))
- return_0;
-
for (i = 0; i < pp->pv_count; i++)
if (_restore_pv(vg, pp->pv_names[i]))
fixed++;
@@ -99,9 +96,6 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!vg_extend_each_pv(vg, pp))
goto_out;
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 0d8b0f215704..4b25b468f017 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -33,9 +33,6 @@ static int _vgimport_single(struct cmd_context *cmd,
goto bad;
}
- if (!archive(vg))
- goto_bad;
-
vg->status &= ~EXPORTED_VG;
if (!vg_is_shared(vg))
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 1e6bb2d69d83..a4778277108e 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -110,9 +110,6 @@ static int _update_vg(struct cmd_context *cmd, struct volume_group *vg,
* Write changes.
*/
- if (!archive(vg))
- goto_bad;
-
if (vp->import_vg)
vg->status &= ~EXPORTED_VG;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 4a4202e8683f..c759c664301c 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -157,9 +157,6 @@ static int _vgreduce_repair_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_PROCESSED;
}
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (vp->force) {
if (!_make_vg_consistent(cmd, vg))
return_ECMD_FAILED;
diff --git a/tools/vgrename.c b/tools/vgrename.c
index f442f731fd4a..71b4e16774af 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -103,9 +103,6 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
dev_dir = cmd->dev_dir;
- if (!archive(vg))
- goto error;
-
if (!lockd_rename_vg_before(cmd, vg)) {
stack;
goto error;
--
1.8.3.1

View File

@ -1,565 +0,0 @@
From bb45e33518b56a06df8a52226e383ca9ce938d0d Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 8 Jun 2021 19:39:15 +0200
Subject: [PATCH 5/8] backup: automatically store data on vg_unlock
Previously there have been necessary explicit call of backup (often
either forgotten or over-used). With this patch the necessity to
store backup is remember at vg_commit and once the VG is unlocked,
the committed metadata are automatically store in backup file.
This may possibly alter some printed messages from command when the
backup is now taken later.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/format_text/archiver.c | 1 -
lib/locking/locking.h | 7 +++++--
lib/metadata/lv_manip.c | 17 +----------------
lib/metadata/metadata.c | 4 ++--
lib/metadata/pv_manip.c | 1 -
lib/metadata/raid_manip.c | 12 ------------
lib/metadata/vg.c | 11 +++++++++--
lib/metadata/vg.h | 1 +
tools/lvconvert.c | 25 -------------------------
tools/pvmove_poll.c | 3 ---
tools/toollib.c | 2 --
tools/vgchange.c | 6 ------
tools/vgcreate.c | 2 --
tools/vgexport.c | 2 --
tools/vgextend.c | 4 ----
tools/vgimport.c | 2 --
tools/vgimportdevices.c | 1 -
tools/vgreduce.c | 1 -
tools/vgrename.c | 2 --
19 files changed, 18 insertions(+), 86 deletions(-)
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 68117f7dc38d..f1590b4604e0 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -279,7 +279,6 @@ int backup_locally(struct volume_group *vg)
int backup(struct volume_group *vg)
{
- vg->needs_backup = 0;
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 3e8ae6f0c27a..a60935d528f9 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -56,8 +56,11 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
#define unlock_vg(cmd, vg, vol) \
do { \
- if (is_real_vg(vol) && !sync_local_dev_names(cmd)) \
- stack; \
+ if (is_real_vg(vol)) { \
+ if (!sync_local_dev_names(cmd)) \
+ stack; \
+ vg_backup_if_needed(vg); \
+ } \
if (!lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL)) \
stack; \
} while (0)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 899297f28498..eb92d6eca275 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6178,8 +6178,6 @@ int lv_resize(struct logical_volume *lv,
/* Update lvm pool metadata (drop messages). */
if (!update_pool_lv(lock_lv, 0))
goto_bad;
-
- backup(vg);
}
/* Check for over provisioning when extended */
@@ -7024,7 +7022,7 @@ no_remove:
static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
{
struct volume_group *vg = lv->vg;
- int do_backup = 0, r = 0;
+ int r = 0;
const struct logical_volume *lock_lv = lv_lock_holder(lv);
log_very_verbose("Updating logical volume %s on disk(s)%s.",
@@ -7048,8 +7046,6 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
return 0;
} else if (!(r = vg_commit(vg)))
stack; /* !vg_commit() has implict vg_revert() */
- else
- do_backup = 1;
log_very_verbose("Updating logical volume %s in kernel.",
display_lvname(lock_lv));
@@ -7060,9 +7056,6 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
r = 0;
}
- if (do_backup && !critical_section())
- backup(vg);
-
return r;
}
@@ -8595,8 +8588,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* Pool created metadata LV, but better avoid recover when vg_write/commit fails */
return_NULL;
- backup(vg);
-
if (test_mode()) {
log_verbose("Test mode: Skipping activation, zeroing and signature wiping.");
goto out;
@@ -8607,8 +8598,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!lv_add_integrity_to_raid(lv, &lp->integrity_settings, lp->pvh, NULL))
goto revert_new_lv;
-
- backup(vg);
}
/* Do not scan this LV until properly zeroed/wiped. */
@@ -8708,7 +8697,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto revert_new_lv;
}
}
- backup(vg);
if (!lv_active_change(cmd, lv, lp->activate)) {
log_error("Failed to activate thin %s.", lv->name);
@@ -8829,7 +8817,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!vg_write(vg) || !vg_commit(vg))
return_NULL; /* Metadata update fails, deep troubles */
- backup(vg);
/*
* FIXME We do not actually need snapshot-origin as an active device,
* as virtual origin is already 'hidden' private device without
@@ -8873,8 +8860,6 @@ revert_new_lv:
!lv_remove(lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
return NULL;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 6852d2a2a7fe..d5b28a58f200 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -991,6 +991,7 @@ static void _vg_move_cached_precommitted_to_committed(struct volume_group *vg)
release_vg(vg->vg_committed);
vg->vg_committed = vg->vg_precommitted;
vg->vg_precommitted = NULL;
+ vg->needs_backup = 1;
}
int lv_has_unknown_segments(const struct logical_volume *lv)
@@ -3165,8 +3166,7 @@ int vg_commit(struct volume_group *vg)
dm_list_init(&vg->msg_list);
vg->needs_write_and_commit = 0;
}
- vg->needs_backup = 0;
- }
+ }
/* If at least one mda commit succeeded, it was committed */
return ret;
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index fd97bbbc2462..cfc983174623 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -687,7 +687,6 @@ int pv_resize_single(struct cmd_context *cmd,
"volume group \"%s\"", pv_name, vg_name);
goto out;
}
- backup(vg);
}
log_print_unless_silent("Physical volume \"%s\" changed", pv_name);
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 74adf02315b0..f0d401cdedc3 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -2210,9 +2210,6 @@ static int _vg_write_lv_suspend_commit_backup(struct volume_group *vg,
} else if (!(r = vg_commit(vg)))
stack; /* !vg_commit() has implicit vg_revert() */
- if (r && do_backup)
- backup(vg);
-
return r;
}
@@ -2221,8 +2218,6 @@ static int _vg_write_commit_backup(struct volume_group *vg)
if (!vg_write(vg) || !vg_commit(vg))
return_0;
- backup(vg);
-
return 1;
}
@@ -2847,7 +2842,6 @@ static int _raid_add_images(struct logical_volume *lv,
display_lvname(lv));
return 0;
}
- backup(lv->vg);
}
return 1;
@@ -3172,8 +3166,6 @@ static int _raid_remove_images(struct logical_volume *lv, int yes,
if (!lv_update_and_reload_origin(lv))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -3431,8 +3423,6 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -3915,8 +3905,6 @@ static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg,
if (vg_write_requested) {
if (!vg_write(vg) || !vg_commit(vg))
return_0;
-
- backup(vg);
}
/* Wait for events following any deactivation. */
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 428e5dca79c6..85482552aefe 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -739,8 +739,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
goto bad;
}
- backup(vg);
-
log_print_unless_silent("Removed \"%s\" from volume group \"%s\"",
name, vg->name);
}
@@ -752,3 +750,12 @@ bad:
release_vg(orphan_vg);
return r;
}
+
+void vg_backup_if_needed(struct volume_group *vg)
+{
+ if (!vg || !vg->needs_backup)
+ return;
+
+ vg->needs_backup = 0;
+ backup(vg->vg_committed);
+}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 36d1ed1556c9..8ce57acdce01 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -170,6 +170,7 @@ uint32_t vg_mda_used_count(const struct volume_group *vg);
uint32_t vg_mda_copies(const struct volume_group *vg);
int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies);
char *vg_profile_dup(const struct volume_group *vg);
+void vg_backup_if_needed(struct volume_group *vg);
/*
* Returns visible LV count - number of LVs from user perspective
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c40031fe47a8..e19c445b17ee 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1263,8 +1263,6 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
new_mimage_count, new_log_count, lp->pvh))
return_0;
- backup(lv->vg);
-
if (!lp->need_polling)
log_print_unless_silent("Logical volume %s converted.",
display_lvname(lv));
@@ -1866,8 +1864,6 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
if (!vg_remove_snapshot(cow))
return_0;
- backup(vg);
-
log_print_unless_silent("Logical Volume %s split from its origin.", display_lvname(cow));
return 1;
@@ -1941,8 +1937,6 @@ static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -1989,8 +1983,6 @@ static int _lvconvert_split_and_keep_cachepool(struct cmd_context *cmd,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
display_lvname(lv), display_lvname(lv_fast));
@@ -2224,7 +2216,6 @@ static int _lvconvert_merge_old_snapshot(struct cmd_context *cmd,
/* Store and commit vg but skip starting the merge */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
} else {
/* Perform merge */
if (!lv_update_and_reload(origin))
@@ -2335,8 +2326,6 @@ static int _lvconvert_merge_thin_snapshot(struct cmd_context *cmd,
log_print_unless_silent("Merging of thin snapshot %s will occur on "
"next activation of %s.",
display_lvname(lv), display_lvname(origin));
- backup(lv->vg);
-
return 1;
}
@@ -2860,8 +2849,6 @@ revert_new_lv:
if (!lv_remove(thin_lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
return 0;
}
@@ -2999,7 +2986,6 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
if (!vg_write(vg) || !vg_commit(vg))
return_0;
- backup(vg);
return 1;
}
@@ -3472,8 +3458,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
r = 1;
out:
- backup(vg);
-
if (r)
log_print_unless_silent("Converted %s to %s pool.",
converted_names, to_cachepool ? "cache" : "thin");
@@ -3509,8 +3493,6 @@ revert_new_lv:
if (!lv_remove(metadata_lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
}
return 0;
@@ -5701,8 +5683,6 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
if (!lv_detach_writecache_cachevol(lv, noflush))
return_0;
- backup(lv->vg);
-
log_print_unless_silent("Logical volume %s writecache has been detached.",
display_lvname(lv));
return 1;
@@ -5827,7 +5807,6 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
}
ret = 1;
- backup(vg);
out_release:
if (ret)
@@ -6320,8 +6299,6 @@ static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_v
if (!ret)
return_0;
- backup(vg);
-
log_print_unless_silent("Logical volume %s has removed integrity.", display_lvname(lv));
return 1;
}
@@ -6354,8 +6331,6 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
if (!ret)
return_0;
- backup(vg);
-
log_print_unless_silent("Logical volume %s has added integrity.", display_lvname(lv));
return 1;
}
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index d379596f2f73..751313cd7e7a 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -120,8 +120,5 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
- /* FIXME backup positioning */
- backup(vg);
-
return 1;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index f337f9fcf9d5..338551015e7c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3224,8 +3224,6 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (vg->needs_write_and_commit && (ret_max == ECMD_PROCESSED) &&
(!vg_write(vg) || !vg_commit(vg)))
ret_max = ECMD_FAILED;
- else if (vg->needs_backup)
- backup(vg);
if (lvargs_supplied) {
/*
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 625b68d46b56..9f972acdb4da 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -684,8 +684,6 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
}
@@ -1006,8 +1004,6 @@ static int _vgchange_locktype_single(struct cmd_context *cmd, const char *vg_nam
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
/*
* When init_vg_sanlock is called for vgcreate, the lockspace remains
* started and lvmlock remains active, but when called for
@@ -1202,8 +1198,6 @@ static int _vgchange_systemid_single(struct cmd_context *cmd, const char *vg_nam
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index d6d6bb61ddc3..dde3f1eac279 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -167,8 +167,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
unlock_vg(cmd, vg, vp_new.vg_name);
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully created%s%s",
vg->name,
vg->system_id ? " with system ID " : "", vg->system_id ? : "");
diff --git a/tools/vgexport.c b/tools/vgexport.c
index 15cc3dd75d56..526ffed7db59 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -54,8 +54,6 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully exported", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgextend.c b/tools/vgextend.c
index b0f49569f492..0856b4c78d25 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -72,8 +72,6 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully extended", vg_name);
return ECMD_PROCESSED;
@@ -116,8 +114,6 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
if (!vg_write(vg) || !vg_commit(vg))
goto_out;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully extended", vg_name);
ret = ECMD_PROCESSED;
out:
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 4b25b468f017..84b76bd8d244 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -46,8 +46,6 @@ static int _vgimport_single(struct cmd_context *cmd,
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully imported", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index af0e618aa932..1cf7ad31a827 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -72,7 +72,6 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
if (updated_pvs) {
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
}
return ECMD_PROCESSED;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index c759c664301c..f500b553add1 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -169,7 +169,6 @@ static int _vgreduce_repair_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- backup(vg);
return ECMD_PROCESSED;
}
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 71b4e16774af..d627bd056d8e 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -141,8 +141,6 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
lockd_rename_vg_final(cmd, vg, 1);
- if (!backup(vg))
- stack;
if (!backup_remove(cmd, vg_name))
stack;
--
1.8.3.1

View File

@ -1,41 +0,0 @@
From 17b27464868ac7049624d9b90f68c59200866997 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 9 Jun 2021 16:16:26 +0200
Subject: [PATCH 6/8] archive: avoid abuse of internal flag
Since archive is now postponned we use internal variable 'changed'
to mark we need to commit new metadata.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/vgchange.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9f972acdb4da..22038ba9b7da 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -640,6 +640,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
int ret = ECMD_PROCESSED;
unsigned i;
activation_change_t activate;
+ int changed = 0;
static const struct {
int arg;
@@ -677,10 +678,11 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (arg_is_set(cmd, _vgchange_args[i].arg)) {
if (!_vgchange_args[i].fn(cmd, vg))
return_ECMD_FAILED;
+ changed = 1;
}
}
- if (vg_is_archived(vg)) {
+ if (changed) {
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
--
1.8.3.1

View File

@ -1,28 +0,0 @@
From 8331321070899507b904d8a0ec78b413c826ae32 Mon Sep 17 00:00:00 2001
From: Wu Guanghao <wuguanghao3@huawei.com>
Date: Fri, 11 Jun 2021 10:18:56 -0500
Subject: [PATCH 7/8] pvck: add lock_global() before clean_hint_file()
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
tools/pvck.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/pvck.c b/tools/pvck.c
index 74663ec43f65..aba6a9cc8787 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -3037,6 +3037,9 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, repairtype_ARG) || arg_is_set(cmd, repair_ARG)) {
pv_name = argv[0];
+ if (!lock_global(cmd, "ex"))
+ return ECMD_FAILED;
+
clear_hint_file(cmd);
if (!setup_device(cmd, pv_name)) {
--
1.8.3.1

View File

@ -1,230 +0,0 @@
From 440d6ae79fb4df92c7992d3c1689ba4f2d242d6a Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Jun 2021 14:49:34 -0500
Subject: [PATCH 8/8] lvmdevices: add deviceidtype option
When adding a device to the devices file with --adddev, lvm
by default chooses the best device ID type for the new device.
The new --deviceidtype option allows the user to override the
built in preference. This is useful if there's a problem with
the default type, or if a secondary type is preferrable.
If the specified deviceidtype does not produce a device ID,
then lvm falls back to the preference it would otherwise use.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/device/device_id.c | 32 ++++++++++++++----------
man/lvmdevices.8_des | 68 +++++++++++++++++++++++++++++++++++++++-----------
tools/args.h | 5 ++++
tools/command-lines.in | 1 +
tools/lvmdevices.c | 7 ++++--
5 files changed, 84 insertions(+), 29 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 1b98487ab3a6..f158e4f06dee 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -931,6 +931,7 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
/*
* Choose the device_id type for the device being added.
*
+ * 0. use an idtype specified by the user
* 1. use an idtype specific to a special/virtual device type
* e.g. loop, mpath, crypt, lvmlv, md, etc.
* 2. use an idtype specified by user option.
@@ -939,6 +940,24 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
* 5. use devname as the last resort.
*/
+ if (idtype_arg) {
+ if (!(idtype = idtype_from_str(idtype_arg)))
+ log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
+ else {
+ if (id_arg) {
+ if ((idname = strdup(id_arg)))
+ goto id_done;
+ log_warn("WARNING: ignoring device_id name %s.", id_arg);
+ }
+
+ if ((idname = device_id_system_read(cmd, dev, idtype)))
+ goto id_done;
+
+ log_warn("WARNING: ignoring deviceidtype %s which is not available for device.", idtype_arg);
+ idtype = 0;
+ }
+ }
+
if (MAJOR(dev->dev) == cmd->dev_types->device_mapper_major) {
if (_dev_has_mpath_uuid(cmd, dev, &idname)) {
idtype = DEV_ID_TYPE_MPATH_UUID;
@@ -972,19 +991,6 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
log_warn("Missing support for DRBD idtype");
}
- if (idtype_arg) {
- if (!(idtype = idtype_from_str(idtype_arg)))
- log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
- else {
- if (id_arg) {
- if (!(idname = strdup(id_arg)))
- stack;
- goto id_done;
- }
- goto id_name;
- }
- }
-
/*
* No device-specific, existing, or user-specified idtypes,
* so use first available of sys_wwid / sys_serial / devname.
diff --git a/man/lvmdevices.8_des b/man/lvmdevices.8_des
index 015aa1122731..2335456adbfd 100644
--- a/man/lvmdevices.8_des
+++ b/man/lvmdevices.8_des
@@ -9,18 +9,18 @@ remove it from the devices file with lvmdevices --deldev. The
vgimportdevices(8) command adds all PVs from a VG to the devices file,
and updates the VG metadata to include device IDs of the PVs.
.P
-Commands adding new devices to the devices file necessarily look outside
-the existing devices file to find the devices to add. pvcreate, vgcreate,
-and vgextend also look outside the devices file to create new PVs and add
-them to the devices file.
+Commands that add new devices to the devices file necessarily look outside
+the existing devices file to find the devices being added. pvcreate,
+vgcreate, and vgextend also look outside the devices file to create new
+PVs and add those PVs to the devices file.
.P
LVM records devices in the devices file using hardware-specific IDs, such
as the WWID, and attempts to use subsystem-specific IDs for virtual device
-types (which also aim to be as unique and stable as possible.)
-These device IDs are also written in the VG metadata. When no hardware or
+types (which also aim to be as unique and stable as possible.) These
+device IDs are also written in the VG metadata. When no hardware or
virtual ID is available, lvm falls back using the unstable device name as
-the device ID. When devnames are used, lvm performs extra scanning to
-find devices if their devname changes, e.g. after reboot.
+the device ID. When devnames are used as IDs, lvm performs extra scanning
+to find devices if their devname changes, e.g. after reboot.
.P
When proper device IDs are used, an lvm command will not look at devices
outside the devices file, but when devnames are used as a fallback, lvm
@@ -34,12 +34,13 @@ overriding the devices file. The listed devices act as a sort of devices
file in terms of limiting which devices lvm will see and use. Devices
that are not listed will appear to be missing to the lvm command.
.P
-Multiple devices files can be kept in \fI#DEFAULT_SYS_DIR#/devices\fP, which allows lvm
-to be used with different sets of devices, e.g. system devices do not need
-to be exposed to a specific application, and the application can use lvm on
-its own devices that are not exposed to the system. The option
---devicesfile <filename> is used to select the devices file to use with the
-command. Without the option set, the default system devices file is used.
+Multiple devices files can be kept \fI#DEFAULT_SYS_DIR#/devices\fP, which
+allows lvm to be used with different sets of devices. For example, system
+devices do not need to be exposed to a specific application, and the
+application can use lvm on its own devices that are not exposed to the
+system. The option --devicesfile <filename> is used to select the devices
+file to use with the command. Without the option set, the default system
+devices file is used.
.P
Setting --devicesfile "" causes lvm to not use a devices file.
.P
@@ -59,3 +60,42 @@ if it does not yet exist.
.P
It is recommended to use lvm commands to make changes to the devices file to
ensure proper updates.
+.P
+The device ID and device ID type are included in the VG metadata and can
+be reported with pvs -o deviceid,deviceidtype. (Note that the lvmdevices
+command does not update VG metadata, but subsequent lvm commands modifying
+the metadata will include the device ID.)
+.P
+Possible device ID types are:
+.br
+.IP \[bu] 2
+.B sys_wwid
+uses the wwid reported by sysfs. This is the first choice for non-virtual
+devices.
+.IP \[bu] 2
+.B sys_serial
+uses the serial number reported by sysfs. This is the second choice for
+non-virtual devices.
+.IP \[bu] 2
+.B mpath_uuid
+is used for dm multipath devices, reported by sysfs.
+.IP \[bu] 2
+.B crypt_uuid
+is used for dm crypt devices, reported by sysfs.
+.IP \[bu] 2
+.B md_uuid
+is used for md devices, reported by sysfs.
+.B lvmlv_uuid
+is used if a PV is placed on top of an lvm LV, reported by sysfs.
+.IP \[bu] 2
+.B loop_file
+is used for loop devices, the backing file name repored by sysfs.
+.IP \[bu] 2
+.B devname
+the device name is used if no other type applies.
+.P
+
+The default choice for device ID type can be overriden using lvmdevices
+--addev --deviceidtype <type>. If the specified type is available for the
+device it will be used, otherwise the device will be added using the type
+that would otherwise be chosen.
diff --git a/tools/args.h b/tools/args.h
index 741c82b9f644..d4f23f849278 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -228,6 +228,11 @@ arg(detachprofile_ARG, '\0', "detachprofile", 0, 0, 0,
"Detaches a metadata profile from a VG or LV.\n"
"See \\fBlvm.conf\\fP(5) for more information about profiles.\n")
+arg(deviceidtype_ARG, '\0', "deviceidtype", string_VAL, 0, 0,
+ "The type of device ID to use for the device.\n"
+ "If the specified type is available for the device,\n"
+ "then it will override the default type that lvm would use.\n")
+
arg(devices_ARG, '\0', "devices", pv_VAL, ARG_GROUPABLE, 0,
"Devices that the command can use. This option can be repeated\n"
"or accepts a comma separated list of devices. This overrides\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 67c37ffd033b..8607305cbb84 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1430,6 +1430,7 @@ ID: lvmdevices_update
DESC: Update the devices file to fix incorrect values.
lvmdevices --adddev PV
+OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Add a device to the devices file.
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index 6b3e05683991..3448bdd14722 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -265,6 +265,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, adddev_ARG)) {
const char *devname;
+ const char *deviceidtype;
if (!(devname = arg_str_value(cmd, adddev_ARG, NULL)))
goto_bad;
@@ -311,8 +312,10 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
dev_name(dev), dev_filtered_reason(dev));
}
- /* allow deviceidtype_ARG/deviceid_ARG ? */
- if (!device_id_add(cmd, dev, dev->pvid, NULL, NULL))
+ /* also allow deviceid_ARG ? */
+ deviceidtype = arg_str_value(cmd, deviceidtype_ARG, NULL);
+
+ if (!device_id_add(cmd, dev, dev->pvid, deviceidtype, NULL))
goto_bad;
if (!device_ids_write(cmd))
goto_bad;
--
1.8.3.1

View File

@ -1,43 +0,0 @@
From e10f67e91728f1e576803df884049ecbd92874d0 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Fri, 28 Jan 2022 14:42:29 +0100
Subject: [PATCH] udev: create symlinks and watch even in suspended state
If a dm device is suspended, we can't run blkid on it. But earlier
rules (e.g. 11-dm-parts.rules) might have imported previously scanned
properties from the udev db, in particular if the device had been correctly
set up beforehand (DM_UDEV_PRIMARY_SOURCE_FLAG==1). Symlinks for existing
ID_FS_xyz properties must be preserved in this case. Otherwise lower-priority
devices (such as multipath components) might take over the symlink
temporarily.
Likewise, we should't stop watching a temporarily suspended, but previously
correctly configured dm device.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
udev/13-dm-disk.rules.in | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index 535581070..5cc08121e 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -17,10 +17,14 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
+ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
+ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link"
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE)
+
+LABEL="dm_link"
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
--
2.34.1

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:76075cf2a2dd12ef526a583f0b3c72a6deaa10691fab28216b0821d01cff0cea
size 2594040

View File

@ -1,17 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAABAgAGBQJgla2zAAoJELkRJDHlCQOfqvYP/j1wFtzE+dX8NmNpMRsS53qh
7AwkYZH0h6VJfzXc2o7jt7Xfytj2zNzq9ZD+HPLPiQg5M2Aa2NlHwk3tIzCAVk5t
LA3GKM4GT8PL/gS2uYaYAzkKW5NWd9cAItkWGRaydgqonwq5ZVekKeSurpfzwp2F
lE+iVclkmerZqGwQriV3Z1alLdm6h0UbkfRemaD8mKA+1IHFeG6Tq/lZEGvjkXL3
IlTZfGF5Ddp2ZJmiIyQiYymiFWhS/XUNrXyVJlAysjtBuWEiywGSoDpf+GkMNTVg
jYmW0wvW5TxGi8yjD2wHK4turEhDyWdHftIaa21v7PD+DAHc5Vhr6QlcCCVb/s00
qSrZaMZJ4RGCnEWf2mZe4m2Ckg7o4owP5CtCHuA4yZ5/SGZ2OhIRGIM/RAcUgC/u
wrzVZOCB4iFnDp7tEFWRq3uwfrHzl5l886nFYt62DZyoG3HlZOpPt0c7Xk5vyNgC
uoIgHHcasTJw6+2prxJ+u6I7+FP0yygKOdY0g3u+WOwYAlXgr2N1M+xFC8Q0tA/I
OQDCc8cHAFdl7K+lGITWGICPIkArW2HJVex2vtHFD23waCoxnsGXLE4mi6IJ7NPl
uSSsnw2cWcBGlVvJdwDCem7Bb50g2VPocOEW4SVgGQdrl76r/Y0epqYNREMGA82i
r30zWBTHczgZfDEIPqqV
=OKc0
-----END PGP SIGNATURE-----

3
LVM2.2.03.15.tgz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:935283a51ee17abd752a545a0ed1cf4edc993359265bc9e562edf81500edc99e
size 2651598

16
LVM2.2.03.15.tgz.asc Normal file
View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEE1QGkeEQK4v0TChvouREkMeUJA58FAmIBUeQACgkQuREkMeUJ
A58DthAA16VW+k8lVVAkX+PfcpqVgvO9M4Rhj4qPAcmwKX2z8wMo5hYnrsG3cQDg
NIbtlD05FZuFFMA7GFBdV+LtHCRF6lCe2LbuSsRWmbxz8Z8yn/h801d4Fp/SaZpm
2Itq0Ve6HLysNqA9P6Yl6YE7U6hWnR6PxoS4jl1C5ttpOlmgDHcIM5xl8Dn3PQbZ
S6ujlWl4OX+E0bG5Qg5iwpUcfZMboJ7VGGCKmXzO0Z/7ABw4Os9dgApHGFlHEsKm
XBmeKT77AQxgozPefiqve1CHFNZG8HmSyMhhstUFNl1qMvxGD3CAObdHIiGT1uQL
z6HrxANZ+5EU+sGgCtJtSBfxzPP3s8RPhUiN0WD3rgkJdshc2qBXsOfkNEUKycnq
wCZtJdh6CPsSEfRv83TrGKTKiNT4DyIzPLBh+goV5SpMc/e1kijv6uUMRwEFGb5Y
LZsMRrO8GmwhkkdIDWhdvhGtzJVhd6n80fNPuQTDm7Rp+1+fhgnV6teRNXxO9aWC
eKeZkpaj0/fjpbDc9o+y5DGpvXdbY4KfNx6nGUGEPsqnTYBnq3Ud/V1fZuaOC2AV
iZK4bXXVQoFVkLGnl3sHx2SQInuui0nDo4i2nIwI2rqIMNClb59hAotDEYdlCQc7
GlAnvWBqrJFjPhVYj8x933lbOyie5GO4qSTI7n0O72c80f8dcbY=
=EPS0
-----END PGP SIGNATURE-----

View File

@ -1,66 +0,0 @@
From: Martin Wilck <mwilck@suse.com>
Subject: [PATCH] config: set external_device_info_source=none if udev isn't running
Date: Wed, 27 Jan 2021 18:28:59 +0100
Message-Id: <20210127172859.956-1-mwilck@suse.com>
LVM2 has several configuration options related to device detection
and udev. In particular, we have obtain_device_list_from_udev=(0|1)
and external_device_info_source=("none"|"udev"). The two options are
obviously semantically related, but it's rather unclear if and how
they interact.
If udev is unavailable, e.g. in containers, obtain_device_list_from_udev
(which defaults to 1) will be automatically reset to 0. However,
if external_device_info_source="udev" is set, this setting is not
reset to "none", leading to error messages like
Udev database has incomplete information about device /dev/vda.
/dev/vda: Failed to get external handle [udev].
This patch changes that, treating external_device_info_source the
same way as obtain_device_list_from_udev, thereby making LVM2's
device detection more consistent.
The default for external_device_info_source is "none", but I believe
there are very good reasons to change this setting to "udev", because
LVM will get detection of multipath and md devices wrong most of the
time otherwise. LVM should follow the same logic as systemd and other
system components with respect to device detection.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>,
---
lib/commands/toolcontext.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 63b6811..55f6806 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -598,9 +598,20 @@ static int _process_config(struct cmd_context *cmd)
dev_ext_info_src = find_config_tree_str(cmd, devices_external_device_info_source_CFG, NULL);
if (dev_ext_info_src && !strcmp(dev_ext_info_src, "none"))
init_external_device_info_source(DEV_EXT_NONE);
- else if (dev_ext_info_src && !strcmp(dev_ext_info_src, "udev"))
- init_external_device_info_source(DEV_EXT_UDEV);
- else {
+ else if (dev_ext_info_src && !strcmp(dev_ext_info_src, "udev")) {
+ /*
+ * Override existing config and hardcode external_device_info_source==none if:
+ * - udev is not running
+ * - udev is disabled using DM_DISABLE_UDEV environment variable
+ * See also treatment of obtain_device_list_from_udev in _init_dev_cache()
+ */
+ if (udev_is_running())
+ init_external_device_info_source(DEV_EXT_UDEV);
+ else {
+ log_notice("udev is not running. Using external_device_info_source==none");
+ init_external_device_info_source(DEV_EXT_NONE);
+ }
+ } else {
log_error("Invalid external device info source specification.");
return 0;
}
--
2.29.2

View File

@ -1,62 +0,0 @@
From db22a389cfb12eef77dfc2e1ce124ac83ed6c5a2 Mon Sep 17 00:00:00 2001
From: Heming Zhao <heming.zhao@suse.com>
Date: Tue, 13 Jul 2021 03:01:00 +0800
Subject: [PATCH] toolcontext: fix double free (core dumped) issue
How to trigger:
```
~ # export LVM_SYSTEM_DIR=_
~ # pvscan
No matching physical volumes found
double free or corruption (!prev)
Aborted (core dumped)
```
when LVM_SYSTEM_DIR is empty, _load_config_file() won't be called.
when LVM_SYSTEM_DIR is not empty, cfl->cft links into cmd->config_files
by _load_config_file()@lib/commands/toolcontext.c
core dumped code: _destroy_config()@lib/commands/toolcontext.c
```
/* CONFIG_FILE/CONFIG_MERGED_FILES */
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
config_destroy(cft);
else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
config_destroy(cft); <=== first free the cft
dm_list_iterate_items(cfl, &cmd->config_files)
config_destroy(cfl->cft); <=== double free the cft
```
Fixes: c43f2f8ae08ed0555a300764c8644ea56f4f41e2
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
lib/commands/toolcontext.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index b295a20efe52..742bdd9c2311 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -966,8 +966,13 @@ static void _destroy_config(struct cmd_context *cmd)
/* CONFIG_FILE/CONFIG_MERGED_FILES */
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
config_destroy(cft);
- else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
+ else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE))) {
+ dm_list_iterate_items(cfl, &cmd->config_files) {
+ if (cfl->cft == cft)
+ dm_list_del(&cfl->list);
+ }
config_destroy(cft);
+ }
dm_list_iterate_items(cfl, &cmd->config_files)
config_destroy(cfl->cft);
--
1.8.3.1

View File

@ -15,7 +15,7 @@ Index: LVM2.2.02.170/lib/config/config_settings.h
+cfg(global_display_dm_name_for_lv_name_CFG, "display_dm_name_for_lv_name", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_DISPLAY_DM_NAME_FOR_LV_NAME, vsn(2, 2, 98), NULL, 0, NULL,
+ "Display dm name for lv name.\n")
+
cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL, 0, NULL,
cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL, 0, NULL,
"The method LVM uses to set the local system ID.\n"
"Volume Groups can also be given a system ID (by vgcreate, vgchange,\n"
Index: LVM2.2.02.170/lib/config/defaults.h
@ -23,7 +23,7 @@ Index: LVM2.2.02.170/lib/config/defaults.h
--- LVM2.2.02.170.orig/lib/config/defaults.h
+++ LVM2.2.02.170/lib/config/defaults.h
@@ -33,6 +33,7 @@
#define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 1
#define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 0
#define DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE "none"
#define DEFAULT_SYSFS_SCAN 1
+#define DEFAULT_DISPLAY_DM_NAME_FOR_LV_NAME 0

View File

@ -1,3 +1,155 @@
-------------------------------------------------------------------
Tue Mar 1 15:45:00 UTC 2022 - heming.zhao@suse.com
- Update lvm2 from LVM2.2.03.12 to LVM2.2.03.15
*** WHATS_NEW from 2.03.13 to 2.03.15 ***
Version 2.03.15 - 07th February 2022
====================================
Remove service based autoactivation. global/event_activation = 0 is NOOP.
Improve support for metadata profiles for --type writecache.
Use cache or active DM device when available with new kernels.
Introduce function to utilize UUIDs from DM_DEVICE_LIST.
Increase some hash table size to better support large device sets.
Version 2.03.14 - 20th October 2021
===================================
Device scanning is skipping directories on different filesystems.
Print info message with too many or too large archived files.
Reduce metadata readings during scanning phase.
Optimize computation of crc32 check sum with multiple PVs.
Enhance recover path on cache creation failure.
Filter out unsupported MQ/SMQ cache policy setting.
Fix memleak in mpath filter.
Support newer location for VDO statistics.
Add support for VDO async-unsafe write policy.
Improve lvm_import_vdo script.
Support VDO LV with lvcreate -ky.
Fix lvconvert for VDO LV bigger then 2T.
Create VDO LVs automatically without zeroing.
Rename vdoimport to lvm_import_vdo.
Version 2.03.13 - 11th August 2021
==================================
Changes in udev support:
- obtain_device_list_from_udev defaults to 0.
- see devices/external_device_info_source,
devices/obtain_device_list_from_udev, and devices/multipath_wwids_file help
in lvm.conf
Fix devices file handling of loop with deleted backing file.
Fix devices file handling of scsi_debug WWIDs.
Fix many static analysis issues.
Support --poolmetadataspare with vgsplit and vgmerge.
Fix detection of active components of external origin volume.
Add vdoimport tool to support conversion of VDO volumes.
Support configurable allocation/vdo_pool_header_size.
Fix handling of lvconvert --type vdo-pool --virtualsize.
Simplified handling of archive() and backup() internal calls.
Add 'idm' locking type for IDM lock manager.
Fix load of kvdo target when it is not present in memory (2.03.12).
*** WHATS_NEW_DM from 1.02.179 to 1.02.183 ***
Version 1.02.183 - 07th February 2022
=====================================
Unmangle UUIDs for DM_DEVICE_LIST ioctl.
Version 1.02.181 - 20th October 2021
====================================
Add IMA support with 'dmsetup measure' command.
Add defines DM_NAME_LIST_FLAG_HAS_UUID, DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID.
Enhance tracking of activated devices when preloading dm tree.
Fix bug in construction of cache table line (regression from 1.02.159).
Version 1.02.179 - 11th August 2021
===================================
(empty)
- Drop patches that have been merged into upstream
- 0001-lvmlockd-idm-Introduce-new-locking-scheme.patch
- 0002-lvmlockd-idm-Hook-Seagate-IDM-wrapper-APIs.patch
- 0003-lib-locking-Add-new-type-idm.patch
- 0004-lib-locking-Parse-PV-list-for-IDM-locking.patch
- 0005-tools-Add-support-for-idm-lock-type.patch
- 0006-configure-Add-macro-LOCKDIDM_SUPPORT.patch
- 0007-enable-command-syntax-for-thin-and-writecache.patch
- 0008-lvremove-fix-removing-thin-pool-with-writecache-on-d.patch
- 0009-vdo-fix-preload-of-kvdo.patch
- 0010-writecache-fix-lv_on_pmem.patch
- 0011-writecache-don-t-pvmove-device-used-by-writecache.patch
- 0012-pvchange-fix-file-locking-deadlock.patch
- 0013-tests-Enable-the-testing-for-IDM-locking-scheme.patch
- 0014-tests-Support-multiple-backing-devices.patch
- 0015-tests-Cleanup-idm-context-when-prepare-devices.patch
- 0016-tests-Add-checking-for-lvmlockd-log.patch
- 0017-tests-stress-Add-single-thread-stress-testing.patch
- 0018-tests-stress-Add-multi-threads-stress-testing-for-VG.patch
- 0019-tests-stress-Add-multi-threads-stress-testing-for-PV.patch
- 0020-tests-Support-idm-failure-injection.patch
- 0021-tests-Add-testing-for-lvmlockd-failure.patch
- 0022-tests-idm-Add-testing-for-the-fabric-failure.patch
- 0023-tests-idm-Add-testing-for-the-fabric-failure-and-tim.patch
- 0024-tests-idm-Add-testing-for-the-fabric-s-half-brain-fa.patch
- 0025-tests-idm-Add-testing-for-IDM-lock-manager-failure.patch
- 0026-tests-multi-hosts-Add-VG-testing.patch
- 0027-tests-multi-hosts-Add-LV-testing.patch
- 0028-tests-multi-hosts-Test-lease-timeout-with-LV-exclusi.patch
- 0029-tests-multi-hosts-Test-lease-timeout-with-LV-shareab.patch
- 0030-fix-empty-mem-pool-leak.patch
- 0031-tests-writecache-blocksize-add-dm-cache-tests.patch
- 0032-tests-rename-test.patch
- 0033-tests-add-writecache-cache-blocksize-2.patch
- 0034-lvmlockd-Fix-the-compilation-warning.patch
- 0035-devices-don-t-use-deleted-loop-backing-file-for-devi.patch
- 0036-man-help-fix-common-option-listing.patch
- 0037-archiving-take-archive-automatically.patch
- 0038-backup-automatically-store-data-on-vg_unlock.patch
- 0039-archive-avoid-abuse-of-internal-flag.patch
- 0040-pvck-add-lock_global-before-clean_hint_file.patch
- 0041-lvmdevices-add-deviceidtype-option.patch
- bug-1188141_toolcontext-fix-double-free-core-dumped-issue.patch
- 0043-udev-create-symlinks-and-watch-even-in-suspended-sta.patch
- bug-1179691_config-set-external_device_info_source-none.patch
- Add upstream patch
- 0001-post-release.patch
- 0002-asan-fix-some-reports-from-libasan.patch
- 0003-make-generate.patch
- 0004-tests-udev-pvscan-vgchange-fix-service-wait.patch
- 0005-devices-file-do-not-clear-PVID-of-unread-devices.patch
- 0006-tests-skip-vgchange-pvs-online.sh-on-rhel5.patch
- 0007-dev_manager-fix-dm_task_get_device_list.patch
- 0008-dev_manager-failing-status-is-not-internal-error.patch
- 0009-clang-add-extra-check.patch
- 0010-clang-possible-better-compilation-with-musl-c.patch
- 0011-dev_manager-do-not-query-for-open_count.patch
- 0012-dev_manager-use-list-info-for-preset-devs.patch
- 0013-man-lvmcache-add-more-writecache-cachesettings-info.patch
- 0014-man-update-cachesettings-option-description.patch
- 0015-man-lvmcache-mention-writecache-memory-usage.patch
- 0016-writecache-display-block-size-from-lvs.patch
- 0017-devices-simplify-dev_cache_get_by_devt.patch
- 0018-devices-drop-incorrect-paths-from-aliases-list.patch
- 0019-devices-initial-use-of-existing-option.patch
- 0020-devices-fix-dev_name-assumptions.patch
- 0021-devices-use-dev-cache-aliases-handling-from-label-sc.patch
- 0022-devices-only-close-PVs-on-LVs-when-scan_lvs-is-enabl.patch
- 0023-writecache-check-memory-usage.patch
- Update patch
- fate-309425_display-dm-name-for-lv-name.patch
- lvm2.spec
- add new binraries: lvmdevices vgimportdevices
- add config item "--with-cluster=internal" for cluster test
- add config item "--with-integrity=internal"
- add new man lvmautoactivation.7
- remove lvm2-activation-generator & man page
- remove lvm2-pvscan@.service
- replace 69-dm-lvm-metad.rules with 69-dm-lvm.rules
-------------------------------------------------------------------
Tue Feb 1 13:10:31 UTC 2022 - Martin Wilck <mwilck@suse.com>

128
lvm2.spec
View File

@ -1,5 +1,5 @@
#
# spec file
# spec file for package lvm2
#
# Copyright (c) 2022 SUSE LLC
#
@ -21,8 +21,8 @@
%define libname_event libdevmapper-event1_03
%define _udevdir %(pkg-config --variable=udevdir udev)
%define cmdlib liblvm2cmd2_03
%define lvm2_version 2.03.12
%define device_mapper_version 1.02.177
%define lvm2_version 2.03.15
%define device_mapper_version 1.02.185
%define thin_provisioning_version 0.7.0
%define _supportsanlock 0
%define dlm_version 4.0.9
@ -63,61 +63,39 @@ Source42: ftp://sourceware.org/pub/lvm2/LVM2.%{version}.tgz.asc
Source99: baselibs.conf
# Upstream patches
Patch0001: 0001-lvmlockd-idm-Introduce-new-locking-scheme.patch
Patch0002: 0002-lvmlockd-idm-Hook-Seagate-IDM-wrapper-APIs.patch
Patch0003: 0003-lib-locking-Add-new-type-idm.patch
Patch0004: 0004-lib-locking-Parse-PV-list-for-IDM-locking.patch
Patch0005: 0005-tools-Add-support-for-idm-lock-type.patch
Patch0006: 0006-configure-Add-macro-LOCKDIDM_SUPPORT.patch
Patch0007: 0007-enable-command-syntax-for-thin-and-writecache.patch
Patch0008: 0008-lvremove-fix-removing-thin-pool-with-writecache-on-d.patch
Patch0009: 0009-vdo-fix-preload-of-kvdo.patch
Patch0010: 0010-writecache-fix-lv_on_pmem.patch
Patch0011: 0011-writecache-don-t-pvmove-device-used-by-writecache.patch
Patch0012: 0012-pvchange-fix-file-locking-deadlock.patch
Patch0013: 0013-tests-Enable-the-testing-for-IDM-locking-scheme.patch
Patch0014: 0014-tests-Support-multiple-backing-devices.patch
Patch0015: 0015-tests-Cleanup-idm-context-when-prepare-devices.patch
Patch0016: 0016-tests-Add-checking-for-lvmlockd-log.patch
Patch0017: 0017-tests-stress-Add-single-thread-stress-testing.patch
Patch0018: 0018-tests-stress-Add-multi-threads-stress-testing-for-VG.patch
Patch0019: 0019-tests-stress-Add-multi-threads-stress-testing-for-PV.patch
Patch0020: 0020-tests-Support-idm-failure-injection.patch
Patch0021: 0021-tests-Add-testing-for-lvmlockd-failure.patch
Patch0022: 0022-tests-idm-Add-testing-for-the-fabric-failure.patch
Patch0023: 0023-tests-idm-Add-testing-for-the-fabric-failure-and-tim.patch
Patch0024: 0024-tests-idm-Add-testing-for-the-fabric-s-half-brain-fa.patch
Patch0025: 0025-tests-idm-Add-testing-for-IDM-lock-manager-failure.patch
Patch0026: 0026-tests-multi-hosts-Add-VG-testing.patch
Patch0027: 0027-tests-multi-hosts-Add-LV-testing.patch
Patch0028: 0028-tests-multi-hosts-Test-lease-timeout-with-LV-exclusi.patch
Patch0029: 0029-tests-multi-hosts-Test-lease-timeout-with-LV-shareab.patch
Patch0030: 0030-fix-empty-mem-pool-leak.patch
Patch0031: 0031-tests-writecache-blocksize-add-dm-cache-tests.patch
Patch0032: 0032-tests-rename-test.patch
Patch0033: 0033-tests-add-writecache-cache-blocksize-2.patch
Patch0034: 0034-lvmlockd-Fix-the-compilation-warning.patch
Patch0035: 0035-devices-don-t-use-deleted-loop-backing-file-for-devi.patch
Patch0036: 0036-man-help-fix-common-option-listing.patch
Patch0037: 0037-archiving-take-archive-automatically.patch
Patch0038: 0038-backup-automatically-store-data-on-vg_unlock.patch
Patch0039: 0039-archive-avoid-abuse-of-internal-flag.patch
Patch0040: 0040-pvck-add-lock_global-before-clean_hint_file.patch
Patch0041: 0041-lvmdevices-add-deviceidtype-option.patch
Patch0042: bug-1188141_toolcontext-fix-double-free-core-dumped-issue.patch
Patch0043: 0043-udev-create-symlinks-and-watch-even-in-suspended-sta.patch
Patch0001: 0001-post-release.patch
Patch0002: 0002-asan-fix-some-reports-from-libasan.patch
Patch0003: 0003-make-generate.patch
Patch0004: 0004-tests-udev-pvscan-vgchange-fix-service-wait.patch
Patch0005: 0005-devices-file-do-not-clear-PVID-of-unread-devices.patch
Patch0006: 0006-tests-skip-vgchange-pvs-online.sh-on-rhel5.patch
Patch0007: 0007-dev_manager-fix-dm_task_get_device_list.patch
Patch0008: 0008-dev_manager-failing-status-is-not-internal-error.patch
Patch0009: 0009-clang-add-extra-check.patch
Patch0010: 0010-clang-possible-better-compilation-with-musl-c.patch
Patch0011: 0011-dev_manager-do-not-query-for-open_count.patch
Patch0012: 0012-dev_manager-use-list-info-for-preset-devs.patch
Patch0013: 0013-man-lvmcache-add-more-writecache-cachesettings-info.patch
Patch0014: 0014-man-update-cachesettings-option-description.patch
Patch0015: 0015-man-lvmcache-mention-writecache-memory-usage.patch
Patch0016: 0016-writecache-display-block-size-from-lvs.patch
Patch0017: 0017-devices-simplify-dev_cache_get_by_devt.patch
Patch0018: 0018-devices-drop-incorrect-paths-from-aliases-list.patch
Patch0019: 0019-devices-initial-use-of-existing-option.patch
Patch0020: 0020-devices-fix-dev_name-assumptions.patch
Patch0021: 0021-devices-use-dev-cache-aliases-handling-from-label-sc.patch
Patch0022: 0022-devices-only-close-PVs-on-LVs-when-scan_lvs-is-enabl.patch
Patch0023: 0023-writecache-check-memory-usage.patch
# SUSE patches: 1000+ for LVM
# Never upstream
Patch1001: cmirrord_remove_date_time_from_compilation.patch
Patch1002: fate-309425_display-dm-name-for-lv-name.patch
Patch1003: bug-935623_dmeventd-fix-dso-name-wrong-compare.patch
Patch1004: bug-998893_make_pvscan_service_after_multipathd.patch
Patch1005: bug-1179691_config-set-external_device_info_source-none.patch
Patch1006: bug-1184687_Add-nolvm-for-kernel-cmdline.patch
Patch1007: fate-31841-01_fsadm-add-support-to-resize-check-btrfs-filesystem.patch
Patch1008: fate-31841-02_man-add-support-for-btrfs.patch
Patch1009: fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
Patch1005: bug-1184687_Add-nolvm-for-kernel-cmdline.patch
Patch1006: fate-31841-01_fsadm-add-support-to-resize-check-btrfs-filesystem.patch
Patch1007: fate-31841-02_man-add-support-for-btrfs.patch
Patch1008: fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
# SUSE patches 2000+ for device mapper, udev rules
Patch2001: bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch
# SUSE patches 3000+ for test code
@ -190,26 +168,6 @@ Volume Manager.
%patch0021 -p1
%patch0022 -p1
%patch0023 -p1
%patch0024 -p1
%patch0025 -p1
%patch0026 -p1
%patch0027 -p1
%patch0028 -p1
%patch0029 -p1
%patch0030 -p1
%patch0031 -p1
%patch0032 -p1
%patch0033 -p1
%patch0034 -p1
%patch0035 -p1
%patch0036 -p1
%patch0037 -p1
%patch0038 -p1
%patch0039 -p1
%patch0040 -p1
%patch0041 -p1
%patch0042 -p1
%patch0043 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
@ -218,7 +176,6 @@ Volume Manager.
%patch1006 -p1
%patch1007 -p1
%patch1008 -p1
%patch1009 -p1
%patch2001 -p1
%patch3001 -p1
@ -230,7 +187,6 @@ Volume Manager.
%if !%{with devicemapper} && !%{with lockd}
extra_opts="
--enable-blkid_wiping
--enable-lvmpolld
--enable-realtime
--with-cache=internal
--with-writecache=internal
@ -239,7 +195,6 @@ extra_opts="
--with-default-run-dir=/run/lvm
--enable-cmirrord
--enable-fsadm
--disable-silent-rules
--enable-write_install
--with-vdo=internal
--with-vdo-format=%{_bindir}/vdoformat
@ -248,17 +203,16 @@ extra_opts="
%if %{with lockd}
extra_opts="
--enable-blkid_wiping
--enable-lvmpolld
--enable-realtime
--with-default-locking-dir=/run/lock/lvm
--with-default-pid-dir=/run
--with-default-run-dir=/run/lvm
--with-cluster=internal
--enable-lvmlockd-dlm
--enable-lvmlockd-dlmcontrol
%if 0%{_supportsanlock} == 1
--enable-lvmlockd-sanlock
%endif
--disable-silent-rules
"
%endif
@ -268,6 +222,7 @@ export PATH=$PATH:/sbin:%{_sbindir}
sed -ie "s/%{device_mapper_version}/1.03.01/g" VERSION_DM
%configure \
--enable-dmeventd \
--enable-lvmpolld \
--enable-cmdlib \
--enable-udev_rules \
--enable-udev_sync \
@ -286,6 +241,8 @@ sed -ie "s/%{device_mapper_version}/1.03.01/g" VERSION_DM
--with-thin-check=%{_sbindir}/thin_check \
--with-thin-dump=%{_sbindir}/thin_dump \
--with-thin-repair=%{_sbindir}/thin_repair \
--with-integrity=internal \
--disable-silent-rules \
$extra_opts
### COMMON-CONFIG-END ###
@ -339,11 +296,8 @@ rm %{buildroot}%{_unitdir}/blk-availability.service
rm %{buildroot}%{_unitdir}/dm-event.service
rm %{buildroot}%{_unitdir}/dm-event.socket
rm %{buildroot}%{_unitdir}/lvm2-monitor.service
rm %{buildroot}%{_mandir}/man8/lvm2-activation-generator.8
rm %{buildroot}%{_systemdgeneratordir}/lvm2-activation-generator
rm %{buildroot}%{_unitdir}/lvm2-lvmpolld.service
rm %{buildroot}%{_unitdir}/lvm2-lvmpolld.socket
rm %{buildroot}%{_unitdir}/lvm2-pvscan@.service
%else
%make_install
make install_system_dirs DESTDIR=%{buildroot}
@ -595,8 +549,10 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_sbindir}/fsadm
%{_sbindir}/lvm
%{_sbindir}/lvmconfig
%{_sbindir}/lvmdevices
%{_sbindir}/lvmdump
%{_sbindir}/lvmpolld
%{_sbindir}/lvm_import_vdo
# Other files
%{_sbindir}/lvchange
%{_sbindir}/lvconvert
@ -632,6 +588,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_sbindir}/vgextend
%{_sbindir}/vgimport
%{_sbindir}/vgimportclone
%{_sbindir}/vgimportdevices
%{_sbindir}/vgmerge
%{_sbindir}/vgmknodes
%{_sbindir}/vgreduce
@ -646,7 +603,9 @@ LVM commands use lvmlockd to coordinate access to shared storage.
# compat symlinks in /sbin
%if !0%{?usrmerged}
/sbin/lvm
/sbin/lvm_import_vdo
/sbin/lvmconfig
/sbin/lvmdevices
/sbin/lvmdump
/sbin/lvmpolld
/sbin/lvchange
@ -683,6 +642,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
/sbin/vgextend
/sbin/vgimport
/sbin/vgimportclone
/sbin/vgimportdevices
/sbin/vgmerge
/sbin/vgmknodes
/sbin/vgreduce
@ -693,6 +653,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
/sbin/vgsplit
%endif
%{_mandir}/man5/lvm.conf.5%{?ext_man}
%{_mandir}/man7/lvmautoactivation.7%{?ext_man}
%{_mandir}/man7/lvmcache.7%{?ext_man}
%{_mandir}/man7/lvmraid.7%{?ext_man}
%{_mandir}/man7/lvmreport.7%{?ext_man}
@ -706,9 +667,9 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_mandir}/man8/lvdisplay.8%{?ext_man}
%{_mandir}/man8/lvextend.8%{?ext_man}
%{_mandir}/man8/lvm.8%{?ext_man}
%{_mandir}/man8/lvm2-activation-generator.8%{?ext_man}
%{_mandir}/man8/lvm-config.8%{?ext_man}
%{_mandir}/man8/lvmconfig.8%{?ext_man}
%{_mandir}/man8/lvmdevices.8%{?ext_man}
%{_mandir}/man8/lvm-dumpconfig.8%{?ext_man}
%{_mandir}/man8/lvmdiskscan.8%{?ext_man}
%{_mandir}/man8/lvmdump.8%{?ext_man}
@ -741,6 +702,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_mandir}/man8/vgextend.8%{?ext_man}
%{_mandir}/man8/vgimport.8%{?ext_man}
%{_mandir}/man8/vgimportclone.8%{?ext_man}
%{_mandir}/man8/vgimportdevices.8%{?ext_man}
%{_mandir}/man8/vgmerge.8%{?ext_man}
%{_mandir}/man8/vgmknodes.8%{?ext_man}
%{_mandir}/man8/vgreduce.8%{?ext_man}
@ -753,7 +715,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_mandir}/man8/lvmpolld.8%{?ext_man}
%{_mandir}/man8/lvm-lvpoll.8%{?ext_man}
%{_udevdir}/rules.d/11-dm-lvm.rules
%{_udevdir}/rules.d/69-dm-lvm-metad.rules
%{_udevdir}/rules.d/69-dm-lvm.rules
%dir %{_sysconfdir}/lvm
%config(noreplace) %{_sysconfdir}/lvm/lvm.conf
%config(noreplace) %{_sysconfdir}/lvm/lvmlocal.conf
@ -773,10 +735,8 @@ LVM commands use lvmlockd to coordinate access to shared storage.
%{_tmpfilesdir}/%{name}.conf
%{_unitdir}/blk-availability.service
%{_unitdir}/lvm2-monitor.service
%{_unitdir}/lvm2-pvscan@.service
%{_unitdir}/lvm2-lvmpolld.socket
%{_unitdir}/lvm2-lvmpolld.service
%{_systemdgeneratordir}/lvm2-activation-generator
%dir %{_libdir}/device-mapper
%{_libdir}/device-mapper/libdevmapper-event-lvm2*.so
%{_libdir}/libdevmapper-event-lvm2*.so