|
|
b83e05 |
lib/commands/toolcontext.h | 1 +
|
|
|
b83e05 |
lib/config/config_settings.h | 5 +++++
|
|
|
b83e05 |
lib/metadata/metadata-exported.h | 1 +
|
|
|
b83e05 |
lib/metadata/metadata.c | 44 +++++++++++++++++++++++++++++++++++++
|
|
|
b83e05 |
tools/lvmcmdline.c | 2 ++
|
|
|
b83e05 |
tools/toollib.c | 47 ++++++++++++++++++++++++++++++++++++++++
|
|
|
b83e05 |
tools/vgcreate.c | 2 ++
|
|
|
b83e05 |
7 files changed, 102 insertions(+)
|
|
|
b83e05 |
|
|
|
b83e05 |
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
|
|
|
b83e05 |
index 4b2a079..497f4bd 100644
|
|
|
b83e05 |
--- a/lib/commands/toolcontext.h
|
|
|
b83e05 |
+++ b/lib/commands/toolcontext.h
|
|
|
b83e05 |
@@ -155,6 +155,7 @@ struct cmd_context {
|
|
|
b83e05 |
unsigned include_shared_vgs:1; /* report/display cmds can reveal lockd VGs */
|
|
|
b83e05 |
unsigned include_active_foreign_vgs:1; /* cmd should process foreign VGs with active LVs */
|
|
|
b83e05 |
unsigned vg_read_print_access_error:1; /* print access errors from vg_read */
|
|
|
b83e05 |
+ unsigned allow_mixed_block_sizes:1;
|
|
|
b83e05 |
unsigned force_access_clustered:1;
|
|
|
b83e05 |
unsigned lockd_gl_disable:1;
|
|
|
b83e05 |
unsigned lockd_vg_disable:1;
|
|
|
b83e05 |
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
|
|
|
b83e05 |
index 9904a62..622e982 100644
|
|
|
b83e05 |
--- a/lib/config/config_settings.h
|
|
|
b83e05 |
+++ b/lib/config/config_settings.h
|
|
|
b83e05 |
@@ -470,6 +470,11 @@ cfg(devices_allow_changes_with_duplicate_pvs_CFG, "allow_changes_with_duplicate_
|
|
|
b83e05 |
"Enabling this setting allows the VG to be used as usual even with\n"
|
|
|
b83e05 |
"uncertain devices.\n")
|
|
|
b83e05 |
|
|
|
b83e05 |
+cfg(devices_allow_mixed_block_sizes_CFG, "allow_mixed_block_sizes", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 3, 6), NULL, 0, NULL,
|
|
|
b83e05 |
+ "Allow PVs in the same VG with different logical block sizes.\n"
|
|
|
b83e05 |
+ "When allowed, the user is responsible to ensure that an LV is\n"
|
|
|
b83e05 |
+ "using PVs with matching block sizes when necessary.\n")
|
|
|
b83e05 |
+
|
|
|
b83e05 |
cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 77), NULL, 0, NULL,
|
|
|
b83e05 |
"Advise LVM which PVs to use when searching for new space.\n"
|
|
|
b83e05 |
"When searching for free space to extend an LV, the 'cling' allocation\n"
|
|
|
b83e05 |
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
|
|
|
b83e05 |
index 2245c29..5674545 100644
|
|
|
b83e05 |
--- a/lib/metadata/metadata-exported.h
|
|
|
b83e05 |
+++ b/lib/metadata/metadata-exported.h
|
|
|
b83e05 |
@@ -593,6 +593,7 @@ struct pvcreate_params {
|
|
|
b83e05 |
unsigned is_remove : 1; /* is removing PVs, not creating */
|
|
|
b83e05 |
unsigned preserve_existing : 1;
|
|
|
b83e05 |
unsigned check_failed : 1;
|
|
|
b83e05 |
+ unsigned check_consistent_block_size : 1;
|
|
|
b83e05 |
};
|
|
|
b83e05 |
|
|
|
b83e05 |
struct lvresize_params {
|
|
|
b83e05 |
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
|
|
|
b83e05 |
index 3620240..123f7f5 100644
|
|
|
b83e05 |
--- a/lib/metadata/metadata.c
|
|
|
b83e05 |
+++ b/lib/metadata/metadata.c
|
|
|
b83e05 |
@@ -699,12 +699,40 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
|
|
|
b83e05 |
{
|
|
|
b83e05 |
struct pv_list *pvl;
|
|
|
b83e05 |
unsigned int max_phys_block_size = 0;
|
|
|
b83e05 |
+ unsigned int physical_block_size, logical_block_size;
|
|
|
b83e05 |
+ unsigned int prev_lbs = 0;
|
|
|
b83e05 |
+ int inconsistent_existing_lbs = 0;
|
|
|
b83e05 |
|
|
|
b83e05 |
log_debug_metadata("Adding PVs to VG %s.", vg->name);
|
|
|
b83e05 |
|
|
|
b83e05 |
if (vg_bad_status_bits(vg, RESIZEABLE_VG))
|
|
|
b83e05 |
return_0;
|
|
|
b83e05 |
|
|
|
b83e05 |
+ /*
|
|
|
b83e05 |
+ * Check if existing PVs have inconsistent block sizes.
|
|
|
b83e05 |
+ * If so, do not enforce new devices to be consistent.
|
|
|
b83e05 |
+ */
|
|
|
b83e05 |
+ dm_list_iterate_items(pvl, &vg->pvs) {
|
|
|
b83e05 |
+ logical_block_size = 0;
|
|
|
b83e05 |
+ physical_block_size = 0;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!dev_get_direct_block_sizes(pvl->pv->dev, &physical_block_size, &logical_block_size))
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!logical_block_size)
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!prev_lbs) {
|
|
|
b83e05 |
+ prev_lbs = logical_block_size;
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (prev_lbs != logical_block_size) {
|
|
|
b83e05 |
+ inconsistent_existing_lbs = 1;
|
|
|
b83e05 |
+ break;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
dm_list_iterate_items(pvl, &pp->pvs) {
|
|
|
b83e05 |
log_debug_metadata("Adding PV %s to VG %s.", pv_dev_name(pvl->pv), vg->name);
|
|
|
b83e05 |
|
|
|
b83e05 |
@@ -715,6 +743,22 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
|
|
|
b83e05 |
return 0;
|
|
|
b83e05 |
}
|
|
|
b83e05 |
|
|
|
b83e05 |
+ logical_block_size = 0;
|
|
|
b83e05 |
+ physical_block_size = 0;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!dev_get_direct_block_sizes(pvl->pv->dev, &physical_block_size, &logical_block_size))
|
|
|
b83e05 |
+ log_warn("WARNING: PV %s has unknown block size.", pv_dev_name(pvl->pv));
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ else if (prev_lbs && logical_block_size && (logical_block_size != prev_lbs)) {
|
|
|
b83e05 |
+ if (vg->cmd->allow_mixed_block_sizes || inconsistent_existing_lbs)
|
|
|
b83e05 |
+ log_debug("Devices have inconsistent block sizes (%u and %u)", prev_lbs, logical_block_size);
|
|
|
b83e05 |
+ else {
|
|
|
b83e05 |
+ log_error("Devices have inconsistent logical block sizes (%u and %u).",
|
|
|
b83e05 |
+ prev_lbs, logical_block_size);
|
|
|
b83e05 |
+ return 0;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
if (!add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, 0)) {
|
|
|
b83e05 |
log_error("PV %s cannot be added to VG %s.",
|
|
|
b83e05 |
pv_dev_name(pvl->pv), vg->name);
|
|
|
b83e05 |
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
|
|
|
b83e05 |
index f238b64..f82827d 100644
|
|
|
b83e05 |
--- a/tools/lvmcmdline.c
|
|
|
b83e05 |
+++ b/tools/lvmcmdline.c
|
|
|
b83e05 |
@@ -2308,6 +2308,8 @@ static int _get_current_settings(struct cmd_context *cmd)
|
|
|
b83e05 |
if (cmd->cname->flags & CAN_USE_ONE_SCAN)
|
|
|
b83e05 |
cmd->can_use_one_scan = 1;
|
|
|
b83e05 |
|
|
|
b83e05 |
+ cmd->allow_mixed_block_sizes = find_config_tree_bool(cmd, devices_allow_mixed_block_sizes_CFG, NULL);
|
|
|
b83e05 |
+
|
|
|
b83e05 |
cmd->partial_activation = 0;
|
|
|
b83e05 |
cmd->degraded_activation = 0;
|
|
|
b83e05 |
activation_mode = find_config_tree_str(cmd, activation_mode_CFG, NULL);
|
|
|
b83e05 |
diff --git a/tools/toollib.c b/tools/toollib.c
|
|
|
b83e05 |
index 81953ee..0b957cc 100644
|
|
|
b83e05 |
--- a/tools/toollib.c
|
|
|
b83e05 |
+++ b/tools/toollib.c
|
|
|
b83e05 |
@@ -5506,6 +5506,8 @@ int pvcreate_each_device(struct cmd_context *cmd,
|
|
|
b83e05 |
struct device_list *devl;
|
|
|
b83e05 |
const char *pv_name;
|
|
|
b83e05 |
int consistent = 0;
|
|
|
b83e05 |
+ unsigned int physical_block_size, logical_block_size;
|
|
|
b83e05 |
+ unsigned int prev_pbs = 0, prev_lbs = 0;
|
|
|
b83e05 |
int must_use_all = (cmd->cname->flags & MUST_USE_ALL_ARGS);
|
|
|
b83e05 |
int found;
|
|
|
b83e05 |
unsigned i;
|
|
|
b83e05 |
@@ -5584,6 +5586,51 @@ int pvcreate_each_device(struct cmd_context *cmd,
|
|
|
b83e05 |
pd->dev = dev_cache_get(pd->name, cmd->full_filter);
|
|
|
b83e05 |
|
|
|
b83e05 |
/*
|
|
|
b83e05 |
+ * Check for consistent block sizes.
|
|
|
b83e05 |
+ */
|
|
|
b83e05 |
+ if (pp->check_consistent_block_size) {
|
|
|
b83e05 |
+ dm_list_iterate_items(pd, &pp->arg_devices) {
|
|
|
b83e05 |
+ if (!pd->dev)
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ logical_block_size = 0;
|
|
|
b83e05 |
+ physical_block_size = 0;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!dev_get_direct_block_sizes(pd->dev, &physical_block_size, &logical_block_size)) {
|
|
|
b83e05 |
+ log_warn("WARNING: Unknown block size for device %s.", dev_name(pd->dev));
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!logical_block_size) {
|
|
|
b83e05 |
+ log_warn("WARNING: Unknown logical_block_size for device %s.", dev_name(pd->dev));
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!prev_lbs) {
|
|
|
b83e05 |
+ prev_lbs = logical_block_size;
|
|
|
b83e05 |
+ prev_pbs = physical_block_size;
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (prev_lbs == logical_block_size) {
|
|
|
b83e05 |
+ /* Require lbs to match, just warn about unmatching pbs. */
|
|
|
b83e05 |
+ if (!cmd->allow_mixed_block_sizes && prev_pbs && physical_block_size &&
|
|
|
b83e05 |
+ (prev_pbs != physical_block_size))
|
|
|
b83e05 |
+ log_warn("WARNING: Devices have inconsistent physical block sizes (%u and %u).",
|
|
|
b83e05 |
+ prev_pbs, physical_block_size);
|
|
|
b83e05 |
+ continue;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ if (!cmd->allow_mixed_block_sizes) {
|
|
|
b83e05 |
+ log_error("Devices have inconsistent logical block sizes (%u and %u).",
|
|
|
b83e05 |
+ prev_lbs, logical_block_size);
|
|
|
b83e05 |
+ log_print("See lvm.conf allow_mixed_block_sizes.");
|
|
|
b83e05 |
+ return 0;
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+ }
|
|
|
b83e05 |
+
|
|
|
b83e05 |
+ /*
|
|
|
b83e05 |
* Use process_each_pv to search all existing PVs and devices.
|
|
|
b83e05 |
*
|
|
|
b83e05 |
* This is a slightly different way to use process_each_pv, because the
|
|
|
b83e05 |
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
|
|
|
b83e05 |
index 4356d99..7add53b 100644
|
|
|
b83e05 |
--- a/tools/vgcreate.c
|
|
|
b83e05 |
+++ b/tools/vgcreate.c
|
|
|
b83e05 |
@@ -48,6 +48,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|
|
b83e05 |
/* Don't create a new PV on top of an existing PV like pvcreate does. */
|
|
|
b83e05 |
pp.preserve_existing = 1;
|
|
|
b83e05 |
|
|
|
b83e05 |
+ pp.check_consistent_block_size = 1;
|
|
|
b83e05 |
+
|
|
|
b83e05 |
if (!vgcreate_params_set_defaults(cmd, &vp_def, NULL))
|
|
|
b83e05 |
return EINVALID_CMD_LINE;
|
|
|
b83e05 |
vp_def.vg_name = vg_name;
|