master - thin: max thin
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1cc690e911f3caa1252...
Commit: 1cc690e911f3caa1252cac6e19488345a0a1a4bc
Parent: 74b5f228383d29ff84293a3691ecc02f023512ad
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 29 18:45:52 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:37:44 2019 +0100
thin: max thin
---
lib/config/defaults.h | 2 ++
lib/metadata/thin_manip.c | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 3b8d341..fac5b75 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -124,6 +124,8 @@
#define DEFAULT_THIN_POOL_CHUNK_SIZE_POLICY "generic"
#define DEFAULT_THIN_POOL_CHUNK_SIZE 64 /* KB */
#define DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE 512 /* KB */
+/* Chunk size big enough it no longer needs jump by power-of-2 */
+#define DEFAULT_THIN_POOL_CHUNK_SIZE_ALIGNED 1024 /* KB */
#define DEFAULT_THIN_POOL_DISCARDS "passdown"
#define DEFAULT_THIN_POOL_ZERO 1
#define DEFAULT_POOL_METADATA_SPARE 1 /* thin + cache */
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 5e52889..79fadc2 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -577,10 +577,15 @@ static uint32_t _estimate_chunk_size(uint32_t data_extents, uint32_t extent_size
uint64_t metadata_size, int attr)
{
uint32_t chunk_size = _estimate_size(data_extents, extent_size, metadata_size);
+ const uint32_t BIG_CHUNK = 2 * DEFAULT_THIN_POOL_CHUNK_SIZE_ALIGNED - 1;
- /* Always round up to nearest power of 2 of 32-bit,
- * even when pool supports multiple of 64KiB */
- chunk_size = 1 << (32 - clz(chunk_size - 1));
+ if ((attr & THIN_FEATURE_BLOCK_SIZE) &&
+ (chunk_size > BIG_CHUNK) &&
+ (chunk_size < (UINT32_MAX - BIG_CHUNK)))
+ chunk_size = (chunk_size + BIG_CHUNK) & ~BIG_CHUNK;
+ else
+ /* Round up to nearest power of 2 of 32-bit */
+ chunk_size = 1 << (32 - clz(chunk_size - 1));
if (chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
5 years, 1 month
master - debug: use log_warn
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=74b5f228383d29ff842...
Commit: 74b5f228383d29ff84293a3691ecc02f023512ad
Parent: dc6dea40331687b8740cc48833f4c7c42a2db1a1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 13 12:58:13 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:37:44 2019 +0100
debug: use log_warn
This reports are not causing command failure, so report them as
warning.
---
lib/filters/filter-mpath.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index 25a507c..466d9c9 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -211,12 +211,12 @@ static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
return_0;
break;
default: /* 0, error. */
- log_error("Failed to get primary device for %d:%d.", major, minor);
+ log_warn("Failed to get primary device for %d:%d.", major, minor);
return 0;
}
if (dm_snprintf(path, sizeof(path), "%s/block/%s/holders", sysfs_dir, name) < 0) {
- log_error("Sysfs path to check mpath is too long.");
+ log_warn("Sysfs path to check mpath is too long.");
return 0;
}
@@ -225,7 +225,7 @@ static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
return 0;
if (!S_ISDIR(info.st_mode)) {
- log_error("Path %s is not a directory.", path);
+ log_warn("Path %s is not a directory.", path);
return 0;
}
5 years, 1 month
master - filter: enhance mpath detection
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dc6dea40331687b8740...
Commit: dc6dea40331687b8740cc48833f4c7c42a2db1a1
Parent: 1eeb2fa3f687e71a541299383fe15bdb9e5a8088
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 13 13:02:09 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:37:42 2019 +0100
filter: enhance mpath detection
Internal detection of SCSI device being in-use by DM mpath has been
performed several times for each component device - this could be
eventually racy - so instead when we do remember 1st. checked result
for device being mpath and use it consistenly over the filter runtime.
---
WHATS_NEW | 1 +
lib/filters/filter-mpath.c | 78 +++++++++++++++++++++++++++++++++++++-------
2 files changed, 67 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 168b267..ad92827 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Query mpath device only once per command for its state.
Use device INFO instead of STATUS when checking for mpath device uuid.
Change default io_memory_size from 4 to 8 MiB.
Add config setting io_memory_size to set bcache size.
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index f0374b4..25a507c 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -27,6 +27,14 @@
#define MPATH_PREFIX "mpath-"
+
+struct mpath_priv {
+ struct dm_pool *mem;
+ struct dev_filter f;
+ struct dev_types *dt;
+ struct dm_hash_table *hash;
+};
+
static const char *_get_sysfs_name(struct device *dev)
{
const char *name;
@@ -174,7 +182,8 @@ static int _udev_dev_is_mpath(struct device *dev)
static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
{
- struct dev_types *dt = (struct dev_types *) f->private;
+ struct mpath_priv *mp = (struct mpath_priv *) f->private;
+ struct dev_types *dt = mp->dt;
const char *part_name, *name;
struct stat info;
char path[PATH_MAX], parent_name[PATH_MAX];
@@ -182,6 +191,7 @@ static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
int major = MAJOR(dev->dev);
int minor = MINOR(dev->dev);
dev_t primary_dev;
+ long look;
/* Limit this filter only to SCSI devices */
if (!major_is_scsi_device(dt, MAJOR(dev->dev)))
@@ -228,7 +238,22 @@ static int _native_dev_is_mpath(struct dev_filter *f, struct device *dev)
if (major != dt->device_mapper_major)
return 0;
- return lvm_dm_prefix_check(major, minor, MPATH_PREFIX);
+ /* Avoid repeated detection of multipath device and use first checked result */
+ look = (long) dm_hash_lookup_binary(mp->hash, &minor, sizeof(minor));
+ if (look > 0) {
+ log_debug_devs("%s(%u:%u): already checked as %sbeing mpath.",
+ parent_name, major, minor, (look > 1) ? "" : "not ");
+ return (look > 1) ? 0 : 1;
+ }
+
+ if (lvm_dm_prefix_check(major, minor, MPATH_PREFIX)) {
+ (void) dm_hash_insert_binary(mp->hash, &minor, sizeof(minor), (void*)2);
+ return 1;
+ }
+
+ (void) dm_hash_insert_binary(mp->hash, &minor, sizeof(minor), (void*)1);
+
+ return 0;
}
static int _dev_is_mpath(struct dev_filter *f, struct device *dev)
@@ -263,36 +288,65 @@ static int _ignore_mpath(struct cmd_context *cmd, struct dev_filter *f, struct d
static void _destroy(struct dev_filter *f)
{
+ struct mpath_priv *mp = (struct mpath_priv*) f->private;
+
if (f->use_count)
log_error(INTERNAL_ERROR "Destroying mpath filter while in use %u times.", f->use_count);
- free(f);
+ dm_hash_destroy(mp->hash);
+ dm_pool_destroy(mp->mem);
}
struct dev_filter *mpath_filter_create(struct dev_types *dt)
{
const char *sysfs_dir = dm_sysfs_dir();
- struct dev_filter *f;
+ struct dm_pool *mem;
+ struct mpath_priv *mp;
+ struct dm_hash_table *hash;
if (!*sysfs_dir) {
log_verbose("No proc filesystem found: skipping multipath filter");
return NULL;
}
- if (!(f = zalloc(sizeof(*f)))) {
- log_error("mpath filter allocation failed");
+ if (!(hash = dm_hash_create(128))) {
+ log_error("mpath hash table creation failed.");
return NULL;
}
- f->passes_filter = _ignore_mpath;
- f->destroy = _destroy;
- f->use_count = 0;
- f->private = dt;
- f->name = "mpath";
+ if (!(mem = dm_pool_create("mpath", 256))) {
+ log_error("mpath pool creation failed.");
+ dm_hash_destroy(hash);
+ return NULL;
+ }
+
+ if (!(mp = dm_pool_zalloc(mem, sizeof(*mp)))) {
+ log_error("mpath filter allocation failed.");
+ goto bad;
+ }
+
+ if (!(mp = dm_pool_zalloc(mem, sizeof(*mp)))) {
+ log_error("mpath filter allocation failed.");
+ goto bad;
+ }
+
+ mp->f.passes_filter = _ignore_mpath;
+ mp->f.destroy = _destroy;
+ mp->f.use_count = 0;
+ mp->f.private = mp;
+ mp->f.name = "mpath";
+
+ mp->mem = mem;
+ mp->dt = dt;
+ mp->hash = hash;
log_debug_devs("mpath filter initialised.");
- return f;
+ return &mp->f;
+bad:
+ dm_pool_destroy(mem);
+ dm_hash_destroy(hash);
+ return NULL;
}
#else
5 years, 1 month
master - dev_manager: add dev_manager_remove_dm_major_minor
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1eeb2fa3f687e71a541...
Commit: 1eeb2fa3f687e71a541299383fe15bdb9e5a8088
Parent: da31541bd8c6945158266f32a31842884e45a09b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 13 12:59:59 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:37:10 2019 +0100
dev_manager: add dev_manager_remove_dm_major_minor
Move DM usage into dev_manager.c source file.
Also convert STATUS to INFO ioctl - as that's enough
to obtain UUID - this also avoid issuing unwanted flush on checked DM
device for being mpath.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 20 +-------------------
lib/activate/dev_manager.c | 17 +++++++++++++++++
lib/activate/dev_manager.h | 2 ++
4 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 61d347a..168b267 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Use device INFO instead of STATUS when checking for mpath device uuid.
Change default io_memory_size from 4 to 8 MiB.
Add config setting io_memory_size to set bcache size.
Fix pvscan autoactivation for concurrent pvscans.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ddc175c..38e21be 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -539,25 +539,7 @@ int target_version(const char *target_name, uint32_t *maj,
int lvm_dm_prefix_check(int major, int minor, const char *prefix)
{
- struct dm_task *dmt;
- const char *uuid;
- int r;
-
- if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
- return_0;
-
- if (!dm_task_set_minor(dmt, minor) ||
- !dm_task_set_major(dmt, major) ||
- !dm_task_run(dmt) ||
- !(uuid = dm_task_get_uuid(dmt))) {
- dm_task_destroy(dmt);
- return 0;
- }
-
- r = strncasecmp(uuid, prefix, strlen(prefix));
- dm_task_destroy(dmt);
-
- return r ? 0 : 1;
+ return dev_manager_check_prefix_dm_major_minor(major, minor, prefix);
}
int module_present(struct cmd_context *cmd, const char *target_name)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 37ce2bf..09fca63 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -943,6 +943,23 @@ static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
return _info_run(NULL, info, NULL, 0, 0, 0, major, minor);
}
+int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix)
+{
+ struct dm_task *dmt;
+ const char *uuid;
+ int r = 1;
+
+ if (!(dmt = _setup_task_run(DM_DEVICE_INFO, NULL, NULL, NULL, 0, major, minor, 0, 0, 0)))
+ return_0;
+
+ if (!(uuid = dm_task_get_uuid(dmt)) || strncasecmp(uuid, prefix, strlen(prefix)))
+ r = 0;
+
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
int dev_manager_info(struct cmd_context *cmd,
const struct logical_volume *lv, const char *layer,
int with_open_count, int with_read_ahead,
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index e8e8ae3..d159364 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -107,6 +107,8 @@ int dev_manager_device_uses_vg(struct device *dev,
int dev_manager_remove_dm_major_minor(uint32_t major, uint32_t minor);
+int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix);
+
int get_cache_vol_meta_data(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *pool_lv,
5 years, 1 month
master - gitignore: update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=da31541bd8c69451582...
Commit: da31541bd8c6945158266f32a31842884e45a09b
Parent: d84134c75bf2f5e9d289da73f68a57d43f5976c3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 6 14:39:17 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:35:09 2019 +0100
gitignore: update
---
.gitignore | 9 +++++++++
scripts/.gitignore | 3 +++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index f51bb67..7ebb8bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,17 +25,25 @@ make.tmpl
/autom4te.cache/
/autoscan.log
+/build/
+/config.cache
/config.log
/config.status
/configure.scan
/cscope.out
+/html/
+/reports/
/tags
/tmp/
+coverity/coverity_model.xml
tools/man-generator
tools/man-generator.c
+test/.lib-dir-stamp
+test/.tests-stamp
+test/lib/dmsecuretest
test/lib/lvchange
test/lib/lvconvert
test/lib/lvcreate
@@ -60,6 +68,7 @@ test/lib/pvremove
test/lib/pvresize
test/lib/pvs
test/lib/pvscan
+test/lib/securetest
test/lib/vgcfgbackup
test/lib/vgcfgrestore
test/lib/vgchange
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 314bdb5..eb97db0 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -24,3 +24,6 @@ lvm2_monitoring_systemd_red_hat.service
lvm2_pvscan_systemd_red_hat@.service
lvm2_tmpfiles_red_hat.conf
lvmdump.sh
+lvm2-pvscan.service
+lvmlockd.service
+lvmlocks.service
5 years, 1 month
master - pvscan: fix ignoring foreign PVs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d84134c75bf2f5e9d28...
Commit: d84134c75bf2f5e9d289da73f68a57d43f5976c3
Parent: 9b2b0fef9c6c475a2023b9e5ca9525d850aed1cc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 13 16:03:02 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 13 16:03:02 2019 -0500
pvscan: fix ignoring foreign PVs
Fix to previous commit
"pvscan: ignore online for shared and foreign PVs"
which was incorrectly considering a PV foreign if its
VG had no system ID when the host did have a system ID.
---
test/shell/pvscan-autoactivate.sh | 27 ++++++++++++++++++++++++---
tools/pvscan.c | 7 ++++++-
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/test/shell/pvscan-autoactivate.sh b/test/shell/pvscan-autoactivate.sh
index 20a0eeb..e48aeac 100644
--- a/test/shell/pvscan-autoactivate.sh
+++ b/test/shell/pvscan-autoactivate.sh
@@ -154,6 +154,7 @@ pvscan --cache -aay "$dev2"
check lv_field $vg1/$lv1 lv_active "active"
lvchange -an $vg1
+vgremove -f $vg1
# pvscan cache ignores pv that's not used
@@ -174,17 +175,37 @@ not ls "$RUNDIR/lvm/pvs_online/$PVID3"
aux lvmconf "global/system_id_source = uname"
+_clear_online_files
+
vgcreate $vg2 "$dev3"
-lvcreate -an -n $lv1 -l1 $vg2
+lvcreate -an -n $lv2 -l1 $vg2
pvscan --cache -aay "$dev3"
ls "$RUNDIR/lvm/pvs_online/$PVID3"
-check lv_field $vg2/$lv1 lv_active "active"
+check lv_field $vg2/$lv2 lv_active "active"
lvchange -an $vg2
rm "$RUNDIR/lvm/pvs_online/$PVID3"
+# a vg without a system id is not foreign, not ignored
+vgchange -y --systemid "" "$vg2"
+
+_clear_online_files
+pvscan --cache -aay "$dev3"
+ls "$RUNDIR/lvm/pvs_online/$PVID3"
+check lv_field $vg2/$lv2 lv_active "active"
+lvchange -an $vg2
+rm "$RUNDIR/lvm/pvs_online/$PVID3"
+
+# make the vg foreign by assigning a system id different from ours
vgchange -y --systemid "asdf" "$vg2"
+_clear_online_files
+
pvscan --cache -aay "$dev3"
not ls "$RUNDIR/lvm/pvs_online/$PVID3"
-check lv_field $vg2/$lv1 lv_active "" --foreign
+lvs --foreign $vg2 > tmp
+cat tmp
+grep $lv2 tmp
+check lv_field $vg2/$lv2 lv_active "" --foreign
+
+
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 30f6fe8..d69d919 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -702,7 +702,12 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
return 1;
}
- if (baton.vg && vg_is_foreign(baton.vg)) {
+ if (baton.vg &&
+ baton.vg->system_id && baton.vg->system_id[0] &&
+ cmd->system_id && cmd->system_id[0] &&
+ vg_is_foreign(baton.vg)) {
+ log_verbose("Ignore PV %s with VG system id %s with our system id %s",
+ dev_name(dev), baton.vg->system_id, cmd->system_id);
log_print("pvscan[%d] PV %s ignore foreign VG.", getpid(), dev_name(dev));
release_vg(baton.vg);
return 1;
5 years, 1 month
stable-2.02 - config: improve scan_lvs description
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ece0b131e51154253e1...
Commit: ece0b131e51154253e14a938e6c24f4983e77bec
Parent: 519f4453a51508e43d36607cc7d1693c79275151
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 6 13:33:07 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 6 13:38:33 2019 -0600
config: improve scan_lvs description
---
lib/config/config_settings.h | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 75321da..0e81252 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -346,7 +346,17 @@ cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, 0, CFG_TYPE_BOOL,
"present on the system. sysfs must be part of the kernel and mounted.)\n")
cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
- "Scan LVM LVs for layered PVs.\n")
+ "Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.\n"
+ "When 1, LVM will detect PVs layered on LVs, and caution must be\n"
+ "taken to avoid a host accessing a layered VG that may not belong\n"
+ "to it, e.g. from a guest image. This generally requires excluding\n"
+ "the LVs with device filters. Also, when this setting is enabled,\n"
+ "every LVM command will scan every active LV on the system (unless\n"
+ "filtered), which can cause performance problems on systems with\n"
+ "many active LVs. When this setting is 0, LVM will not detect or\n"
+ "use PVs that exist on LVs, and will not allow a PV to be created on\n"
+ "an LV. The LVs are ignored using a built in device filter that\n"
+ "identifies and excludes LVs.\n")
cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
"Ignore devices that are components of DM multipath devices.\n")
5 years, 2 months
master - config: improve scan_lvs description
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9b2b0fef9c6c475a202...
Commit: 9b2b0fef9c6c475a2023b9e5ca9525d850aed1cc
Parent: 98b7a3a42dd3adc13b87233846ae2e8e1f6b4bb0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 6 13:33:07 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 6 13:33:07 2019 -0600
config: improve scan_lvs description
---
lib/config/config_settings.h | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index a2df3ce..efa86e7 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -352,7 +352,17 @@ cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, 0, CFG_TYPE_BOOL,
"present on the system. sysfs must be part of the kernel and mounted.)\n")
cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
- "Scan LVM LVs for layered PVs.\n")
+ "Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.\n"
+ "When 1, LVM will detect PVs layered on LVs, and caution must be\n"
+ "taken to avoid a host accessing a layered VG that may not belong\n"
+ "to it, e.g. from a guest image. This generally requires excluding\n"
+ "the LVs with device filters. Also, when this setting is enabled,\n"
+ "every LVM command will scan every active LV on the system (unless\n"
+ "filtered), which can cause performance problems on systems with\n"
+ "many active LVs. When this setting is 0, LVM will not detect or\n"
+ "use PVs that exist on LVs, and will not allow a PV to be created on\n"
+ "an LV. The LVs are ignored using a built in device filter that\n"
+ "identifies and excludes LVs.\n")
cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
"Ignore devices that are components of DM multipath devices.\n")
5 years, 2 months
master - tests: check that pvscan --cache ignores certain PVs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=98b7a3a42dd3adc13b8...
Commit: 98b7a3a42dd3adc13b87233846ae2e8e1f6b4bb0
Parent: 4e20ebd6a1b993b1f04aa13f55b9c5d8ca2ff287
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 6 12:17:47 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 6 12:17:47 2019 -0600
tests: check that pvscan --cache ignores certain PVs
---
test/shell/lvmlockd-lv-types.sh | 14 ++++++++++++++
test/shell/pvscan-autoactivate.sh | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvmlockd-lv-types.sh b/test/shell/lvmlockd-lv-types.sh
index b82f21b..44ff532 100644
--- a/test/shell/lvmlockd-lv-types.sh
+++ b/test/shell/lvmlockd-lv-types.sh
@@ -39,6 +39,20 @@ aux prepare_devs 5
vgcreate --shared $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
#
+# pvscan autoactivation ignore shared PVs
+#
+RUNDIR="/run"
+test -d "$RUNDIR" || RUNDIR="/var/run"
+
+PVID1=`pvs $dev1 --noheading -o uuid | tr -d - | awk '{print $1}'`
+pvscan --cache -aay "$dev1"
+not ls "$RUNDIR/lvm/pvs_online/$PVID1"
+pvscan --cache -aay
+not ls "$RUNDIR/lvm/pvs_online/$PVID1"
+not ls "$RUNDIR/lvm/vgs_online/$vg"
+
+
+#
# thin pool, thin lv, thin snap
#
diff --git a/test/shell/pvscan-autoactivate.sh b/test/shell/pvscan-autoactivate.sh
index 419fb9b..20a0eeb 100644
--- a/test/shell/pvscan-autoactivate.sh
+++ b/test/shell/pvscan-autoactivate.sh
@@ -27,7 +27,7 @@ _clear_online_files() {
. lib/inittest
-aux prepare_pvs 2
+aux prepare_pvs 3
vgcreate $vg1 "$dev1" "$dev2"
lvcreate -n $lv1 -l 4 -a n $vg1
@@ -153,3 +153,38 @@ check lv_field $vg1/$lv1 lv_active ""
pvscan --cache -aay "$dev2"
check lv_field $vg1/$lv1 lv_active "active"
lvchange -an $vg1
+
+
+# pvscan cache ignores pv that's not used
+
+pvcreate "$dev3"
+
+PVID3=`pvs $dev3 --noheading -o uuid | tr -d - | awk '{print $1}'`
+echo $PVID3
+
+not ls "$RUNDIR/lvm/pvs_online/$PVID3"
+
+pvscan --cache -aay "$dev3"
+
+ls "$RUNDIR/lvm/pvs_online"
+not ls "$RUNDIR/lvm/pvs_online/$PVID3"
+
+
+# pvscan cache ignores pv in a foreign vg
+
+aux lvmconf "global/system_id_source = uname"
+
+vgcreate $vg2 "$dev3"
+lvcreate -an -n $lv1 -l1 $vg2
+pvscan --cache -aay "$dev3"
+ls "$RUNDIR/lvm/pvs_online/$PVID3"
+check lv_field $vg2/$lv1 lv_active "active"
+lvchange -an $vg2
+rm "$RUNDIR/lvm/pvs_online/$PVID3"
+
+vgchange -y --systemid "asdf" "$vg2"
+
+pvscan --cache -aay "$dev3"
+not ls "$RUNDIR/lvm/pvs_online/$PVID3"
+check lv_field $vg2/$lv1 lv_active "" --foreign
+
5 years, 2 months
master - pvscan: ignore online for shared and foreign PVs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4e20ebd6a1b993b1f04...
Commit: 4e20ebd6a1b993b1f04aa13f55b9c5d8ca2ff287
Parent: a0c848d4e4a9b53fa1f9cc7a8330fea6b23c07a8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 5 15:19:05 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 5 15:19:05 2019 -0600
pvscan: ignore online for shared and foreign PVs
Activation would not be allowed anyway, but we can
check for these cases early and avoid wasted time in
pvscan managing online files an attempting activation.
---
lib/metadata/metadata-exported.h | 2 ++
lib/metadata/metadata.c | 5 +++++
tools/pvscan.c | 12 ++++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f451140..df217db 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1377,4 +1377,6 @@ int vg_strip_outdated_historical_lvs(struct volume_group *vg);
int lv_on_pmem(struct logical_volume *lv);
+int vg_is_foreign(struct volume_group *vg);
+
#endif
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 9efc355..c50e633 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5668,3 +5668,8 @@ int lv_on_pmem(struct logical_volume *lv)
return 0;
}
+int vg_is_foreign(struct volume_group *vg)
+{
+ return _is_foreign_vg(vg);
+}
+
diff --git a/tools/pvscan.c b/tools/pvscan.c
index c484531..30f6fe8 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -696,6 +696,18 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
fmt->ops->destroy_instance(baton.fid);
}
+ if (baton.vg && vg_is_shared(baton.vg)) {
+ log_print("pvscan[%d] PV %s ignore shared VG.", getpid(), dev_name(dev));
+ release_vg(baton.vg);
+ return 1;
+ }
+
+ if (baton.vg && vg_is_foreign(baton.vg)) {
+ log_print("pvscan[%d] PV %s ignore foreign VG.", getpid(), dev_name(dev));
+ release_vg(baton.vg);
+ return 1;
+ }
+
ret = _online_pv_found(cmd, dev, dev_args, baton.vg, found_vgnames);
release_vg(baton.vg);
5 years, 2 months