master - cleanup: skip double assign
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=760714829bfd6f...
Commit: 760714829bfd6f3cc6e0f23f029baf4cc9ed441d
Parent: 904a02335ffe831dfedc32d074f5b659189aaa76
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 17 13:57:13 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 17 14:08:54 2013 +0100
cleanup: skip double assign
Assing NULL to type only in defaut: switch.
Debug print '--' for unlocked and unused resource (-1)
---
daemons/clvmd/lvm-functions.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index b15732f..fb3a95c 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -483,18 +483,19 @@ static int do_deactivate_lv(char *resource, unsigned char command, unsigned char
const char *do_lock_query(char *resource)
{
int mode;
- const char *type = NULL;
+ const char *type;
mode = get_current_lock(resource);
switch (mode) {
- case LCK_NULL: type = "NL"; break;
- case LCK_READ: type = "CR"; break;
- case LCK_PREAD:type = "PR"; break;
- case LCK_WRITE:type = "PW"; break;
- case LCK_EXCL: type = "EX"; break;
+ case LCK_NULL: type = "NL"; break;
+ case LCK_READ: type = "CR"; break;
+ case LCK_PREAD:type = "PR"; break;
+ case LCK_WRITE:type = "PW"; break;
+ case LCK_EXCL: type = "EX"; break;
+ default: type = NULL;
}
- DEBUGLOG("do_lock_query: resource '%s', mode %i (%s)\n", resource, mode, type ?: "?");
+ DEBUGLOG("do_lock_query: resource '%s', mode %i (%s)\n", resource, mode, type ?: "--");
return type;
}
10 years, 3 months
master - tests: hide expected error message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=904a02335ffe83...
Commit: 904a02335ffe831dfedc32d074f5b659189aaa76
Parent: fd73b2b7b92a2bb1d3ae3d6c4d2eb5eef78594c0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 17 13:55:19 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 17 14:08:54 2013 +0100
tests: hide expected error message
Test typically enables disabled device - so it mostly expects
error target will be reloaded here - thus hide confusing message.
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 2256fce..92385c8 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -392,7 +392,7 @@ enable_dev() {
init_udev_transaction
for dev in "$@"; do
local name=$(echo "$dev" | sed -e 's,.*/,,')
- dmsetup create -u "TEST-$name" "$name" "$name.table" || \
+ dmsetup create -u "TEST-$name" "$name" "$name.table" 2>/dev/null || \
dmsetup load "$name" "$name.table"
# using device name (since device path does not exists yes with udev)
dmsetup resume "$name"
10 years, 3 months
master - tests: skip pool-label test for lvmetad
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fd73b2b7b92a2b...
Commit: fd73b2b7b92a2bb1d3ae3d6c4d2eb5eef78594c0
Parent: a8b5dce997b26ff10892aab83646b65c1146f576
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 16 13:29:46 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 17 14:08:54 2013 +0100
tests: skip pool-label test for lvmetad
Unsupported by lvmetad.
---
test/shell/pool-labels.sh | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/shell/pool-labels.sh b/test/shell/pool-labels.sh
index 9d3fa03..b5cbbdc 100644
--- a/test/shell/pool-labels.sh
+++ b/test/shell/pool-labels.sh
@@ -11,6 +11,9 @@
. lib/test
+# lvmetad does not handle pool labels so skip test.
+test ! -e LOCAL_LVMETAD || skip
+
env printf "" || skip # skip if printf is not available
# create the old GFS pool labeled linear devices
10 years, 3 months
master - systemd: make sure lvm2-lvmetad.socket is available for lvm2-pvscan@.service
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8b5dce997b26f...
Commit: a8b5dce997b26ff10892aab83646b65c1146f576
Parent: 56af6cae087259f620a356a6706ea10249015069
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Dec 17 10:40:32 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Dec 17 10:40:32 2013 +0100
systemd: make sure lvm2-lvmetad.socket is available for lvm2-pvscan@.service
---
scripts/lvm2_pvscan_systemd_red_hat@.service.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/scripts/lvm2_pvscan_systemd_red_hat@.service.in b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
index 4225982..6b21c75 100644
--- a/scripts/lvm2_pvscan_systemd_red_hat@.service.in
+++ b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
@@ -3,6 +3,7 @@ Description=LVM2 PV scan on device %i
Documentation=man:pvscan(8)
DefaultDependencies=no
BindsTo=dev-block-%i.device
+Requires=lvm2-lvmetad.socket
After=lvm2-lvmetad.socket
Before=shutdown.target
Conflicts=shutdown.target
10 years, 3 months
master - test: Turn check_full into check_system complementary with normal check.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56af6cae087259...
Commit: 56af6cae087259f620a356a6706ea10249015069
Parent: 18afca5ddded15c528a88a11fe1ea29c8a29cbcd
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Dec 15 17:26:28 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Dec 15 17:26:28 2013 +0100
test: Turn check_full into check_system complementary with normal check.
---
Makefile.in | 2 +-
test/Makefile.in | 9 ++-------
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index e1178ee..ce61957 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -91,7 +91,7 @@ all: cscope.out
endif
DISTCLEAN_TARGETS += cscope.out
-check check_full check_cluster check_local check_lvmetad unit: all
+check check_system check_cluster check_local check_lvmetad unit: all
$(MAKE) -C test $(@)
install_system_dirs:
diff --git a/test/Makefile.in b/test/Makefile.in
index 96c4fdb..5c9f5d5 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -90,19 +90,14 @@ check: .tests-stamp
$(patsubst %,cluster:%,$(RUN_BASE)) \
$(patsubst %,lvmetad:%,$(LVMETAD_RUN_BASE))
-check_full: .tests-stamp
+check_system: .tests-stamp
VERBOSE=$(VERBOSE) \
- cluster_LVM_TEST_LOCKING=3 \
scluster_LVM_TEST_LOCKING=3 \
- lvmetad_LVM_TEST_LVMETAD=1 \
slvmetad_LVM_TEST_LVMETAD=1 \
snormal_LVM_TEST_DEVDIR=/dev \
scluster_LVM_TEST_DEVDIR=/dev \
slvmetad_LVM_TEST_DEVDIR=/dev \
- ./lib/harness $(patsubst %,normal:%,$(RUN_BASE)) \
- $(patsubst %,cluster:%,$(RUN_BASE)) \
- $(patsubst %,lvmetad:%,$(LVMETAD_RUN_BASE)) \
- $(patsubst %,snormal:%,$(RUN_BASE)) \
+ ./lib/harness $(patsubst %,snormal:%,$(RUN_BASE)) \
$(patsubst %,scluster:%,$(RUN_BASE)) \
$(patsubst %,slvmetad:%,$(LVMETAD_RUN_BASE))
10 years, 3 months
master - pvscan --cache: Use FMT_LVM1_NAME instead of hardcoded "lvm1".
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=18afca5ddded15...
Commit: 18afca5ddded15c528a88a11fe1ea29c8a29cbcd
Parent: bd3edb2566189e1e3e016933e397a58a90bc81ea
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Dec 15 16:37:03 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Dec 15 16:44:47 2013 +0100
pvscan --cache: Use FMT_LVM1_NAME instead of hardcoded "lvm1".
---
lib/cache/lvmetad.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a2ebefb..65ed520 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -914,7 +914,7 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
}
/* LVM1 VGs have no MDAs. */
- if (!baton.vg && lvmcache_fmt(info) == get_format_by_name(cmd, "lvm1"))
+ if (!baton.vg && lvmcache_fmt(info) == get_format_by_name(cmd, FMT_LVM1_NAME))
baton.vg = ((struct metadata_area *) dm_list_first(&baton.fid->metadata_areas_in_use))->
ops->vg_read(baton.fid, lvmcache_vgname_from_info(info), NULL, 0);
10 years, 3 months
master - pvscan --cache: Error out on pool-format VGs for now.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd3edb2566189e...
Commit: bd3edb2566189e1e3e016933e397a58a90bc81ea
Parent: 97fbbbc150cdaea359370912a7b5a9a546490e98
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Dec 15 16:31:35 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Dec 15 16:44:47 2013 +0100
pvscan --cache: Error out on pool-format VGs for now.
---
lib/cache/lvmetad.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 1ead9f8..a2ebefb 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -20,6 +20,8 @@
#include "lvmcache.h"
#include "lvmetad-client.h"
#include "format-text.h" // TODO for disk_locn, used as a DA representation
+#include "format_pool.h" // for FMT_POOL_NAME
+#include "format1.h" // for FMT_LVM1_NAME
#include "crc.h"
static daemon_handle _lvmetad;
@@ -904,6 +906,13 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
lvmcache_foreach_mda(info, _lvmetad_pvscan_single, &baton);
+ if (lvmcache_fmt(info) == get_format_by_name(cmd, FMT_POOL_NAME)) {
+ log_error("WARNING: Ignoring old GFS pool metadata on device %s "
+ "when using lvmetad", dev_name(dev));
+ lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
+ return 0;
+ }
+
/* LVM1 VGs have no MDAs. */
if (!baton.vg && lvmcache_fmt(info) == get_format_by_name(cmd, "lvm1"))
baton.vg = ((struct metadata_area *) dm_list_first(&baton.fid->metadata_areas_in_use))->
10 years, 3 months
master - test: Make the harness optionally less verbose (QUIET=1).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=97fbbbc150cdae...
Commit: 97fbbbc150cdaea359370912a7b5a9a546490e98
Parent: d443bfac216a3eedcd752d532f6f90a339681b44
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Dec 15 16:36:24 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Sun Dec 15 16:44:47 2013 +0100
test: Make the harness optionally less verbose (QUIET=1).
---
test/lib/harness.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index fa174bb..f27fbeb 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -53,6 +53,7 @@ static size_t readbuf_sz = 0, readbuf_used = 0;
static int die = 0;
static int verbose = 0; /* >1 with timestamps */
static int interactive = 0; /* disable all redirections */
+static int quiet = 0;
static const char *results;
static unsigned fullbuffer = 0;
static int unlimited = 0;
@@ -298,7 +299,7 @@ static void interrupted(int i, char *f) {
++ s.ninterrupted;
s.status[i] = INTERRUPTED;
printf("\ninterrupted.\n");
- if (!verbose && fullbuffer) {
+ if (!quiet && !verbose && fullbuffer) {
printf("-- Interrupted %s ------------------------------------\n", f);
dump();
printf("\n-- Interrupted %s (end) ------------------------------\n", f);
@@ -309,7 +310,7 @@ static void timeout(int i, char *f) {
++ s.ninterrupted;
s.status[i] = TIMEOUT;
printf("timeout.\n");
- if (!verbose && readbuf) {
+ if (!quiet && !verbose && readbuf) {
printf("-- Timed out %s ------------------------------------\n", f);
dump();
printf("\n-- Timed out %s (end) ------------------------------\n", f);
@@ -333,7 +334,7 @@ static void failed(int i, char *f, int st) {
++ s.nfailed;
s.status[i] = FAILED;
printf("FAILED (status %d).\n", WEXITSTATUS(st));
- if (!verbose && readbuf) {
+ if (!quiet && !verbose && readbuf) {
printf("-- FAILED %s ------------------------------------\n", f);
dump();
printf("-- FAILED %s (end) ------------------------------\n", f);
@@ -491,7 +492,8 @@ int main(int argc, char **argv) {
char results_list[PATH_MAX];
const char *result;
const char *be_verbose = getenv("VERBOSE"),
- *be_interactive = getenv("INTERACTIVE");
+ *be_interactive = getenv("INTERACTIVE"),
+ *be_quiet = getenv("QUIET");;
time_t start = time(NULL);
int i;
FILE *list;
@@ -507,6 +509,9 @@ int main(int argc, char **argv) {
if (be_interactive)
interactive = atoi(be_interactive);
+ if (be_quiet)
+ quiet = atoi(be_quiet);
+
results = getenv("LVM_TEST_RESULTS") ? : "results";
unlimited = getenv("LVM_TEST_UNLIMITED") ? 1 : 0;
(void) snprintf(results_list, sizeof(results_list), "%s/list", results);
10 years, 3 months
master - config: fix metadata/disk_areas config setting registration
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d443bfac216a3e...
Commit: d443bfac216a3eedcd752d532f6f90a339681b44
Parent: 32080c4ff748e4afbeacf9dbc4a98bfea658a392
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Dec 13 16:43:01 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Dec 13 16:52:51 2013 +0100
config: fix metadata/disk_areas config setting registration
The metadata/disk_areas setting was incorrectly registered as
"string" configuration option but it's a section where each area
is defined in its own subsection with "start_sector", "size" and "id"
setting.
This setting is not officialy supported, it's undocumented and it's
used solely for debugging.
Note: At this moment, it does not seem to be working with lvmetad!
---
lib/config/config_settings.h | 7 ++++++-
lib/format_text/format-text.c | 3 ++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 0e0e469..1546b3f 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -205,7 +205,12 @@ cfg(metadata_pvmetadatasize_CFG, "pvmetadatasize", metadata_CFG_SECTION, CFG_ADV
cfg(metadata_pvmetadataignore_CFG, "pvmetadataignore", metadata_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_BOOL, DEFAULT_PVMETADATAIGNORE, vsn(2, 2, 69), NULL)
cfg(metadata_stripesize_CFG, "stripesize", metadata_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_INT, DEFAULT_STRIPESIZE, vsn(1, 0, 0), NULL)
cfg_array(metadata_dirs_CFG, "dirs", metadata_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL)
-cfg(metadata_disk_areas_CFG, "disk_areas", metadata_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_ADVANCED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL)
+
+cfg_section(metadata_disk_areas_CFG_SUBSECTION, "disk_areas", metadata_CFG_SECTION, CFG_ADVANCED | CFG_UNSUPPORTED, vsn(1, 0, 0), NULL)
+cfg_section(disk_area_CFG_SUBSECTION, "disk_area", metadata_disk_areas_CFG_SUBSECTION, CFG_NAME_VARIABLE | CFG_ADVANCED | CFG_UNSUPPORTED, vsn(1, 0, 0), NULL)
+cfg(disk_area_start_sector_CFG, "start_sector", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL)
+cfg(disk_area_size_CFG, "size", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL)
+cfg(disk_area_id_CFG, "id", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL)
cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REP_ALIGNED, vsn(1, 0, 0), NULL)
cfg(report_buffered_CFG, "buffered", report_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REP_BUFFERED, vsn(1, 0, 0), NULL)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index eb5c9e9..22d772f 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2458,7 +2458,8 @@ struct format_type *create_text_format(struct cmd_context *cmd)
}
}
- if ((cn = find_config_tree_node(cmd, metadata_disk_areas_CFG, NULL))) {
+ if ((cn = find_config_tree_node(cmd, metadata_disk_areas_CFG_SUBSECTION, NULL))) {
+ /* FIXME: disk_areas do not work with lvmetad - the "id" can't be found. */
for (cn = cn->child; cn; cn = cn->sib) {
if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
goto_bad;
10 years, 3 months
master - device: add physical block size info and make sure VG extent size >= PV's phys. block size
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=32080c4ff748e4...
Commit: 32080c4ff748e4afbeacf9dbc4a98bfea658a392
Parent: 3eed0aa7dca9c1895bbf80e1585debf9bddac5a8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 12 11:26:35 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 12 15:02:36 2013 +0100
device: add physical block size info and make sure VG extent size >= PV's phys. block size
---
WHATS_NEW | 1 +
lib/device/dev-cache.c | 1 +
lib/device/dev-io.c | 65 +++++++++++++++++---------------------
lib/device/device.h | 3 +-
lib/metadata/metadata-exported.h | 1 +
lib/metadata/metadata.c | 56 +++++++++++++++++++++++++++++---
lib/metadata/metadata.h | 3 ++
man/vgchange.8.in | 6 ++-
man/vgcreate.8.in | 6 ++-
tools/vgchange.c | 6 +++
10 files changed, 101 insertions(+), 47 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 78657dd..1679131 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Make sure VG extent size is always greater or equal to PV phys. block size.
Optimize double call of stat() for cached devices.
Enable support for thin provisioning for default configuration.
Improve process_each_lv_in_vg() tag processing.
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 5d26d41..87d2f58 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -56,6 +56,7 @@ static int _insert(const char *path, const struct stat *info,
/* Setup non-zero members of passed zeroed 'struct device' */
static void _dev_init(struct device *dev, int max_error_count)
{
+ dev->phys_block_size = -1;
dev->block_size = -1;
dev->fd = -1;
dev->read_ahead = -1;
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 1d35a8f..45700e5 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -123,23 +123,44 @@ static int _io(struct device_area *where, char *buffer, int should_write)
*---------------------------------------------------------------*/
/*
- * Get the sector size from an _open_ device.
+ * Get the physical and logical block size for a device.
*/
-static int _get_block_size(struct device *dev, unsigned int *size)
+int dev_get_block_size(struct device *dev, unsigned int *physical_block_size, unsigned int *block_size)
{
const char *name = dev_name(dev);
+ int needs_open;
+ int r = 1;
+
+ needs_open = (!dev->open_count && (dev->phys_block_size == -1 || dev->block_size == -1));
+
+ if (needs_open && !dev_open_readonly(dev))
+ return_0;
+
+ if (dev->phys_block_size == -1) {
+ if (ioctl(dev_fd(dev), BLKPBSZGET, &dev->phys_block_size) < 0) {
+ log_sys_error("ioctl BLKPBSZGET", name);
+ r = 0;
+ goto out;
+ }
+ log_debug_devs("%s: physical block size is %u bytes", name, dev->phys_block_size);
+ }
if (dev->block_size == -1) {
if (ioctl(dev_fd(dev), BLKBSZGET, &dev->block_size) < 0) {
log_sys_error("ioctl BLKBSZGET", name);
- return 0;
+ r = 0;
+ goto out;
}
log_debug_devs("%s: block size is %u bytes", name, dev->block_size);
}
- *size = (unsigned int) dev->block_size;
+ *physical_block_size = (unsigned int) dev->phys_block_size;
+ *block_size = (unsigned int) dev->block_size;
+out:
+ if (needs_open)
+ dev_close(dev);
- return 1;
+ return r;
}
/*
@@ -168,13 +189,14 @@ static int _aligned_io(struct device_area *where, char *buffer,
int should_write)
{
char *bounce, *bounce_buf;
+ unsigned int physical_block_size = 0;
unsigned int block_size = 0;
uintptr_t mask;
struct device_area widened;
int r = 0;
if (!(where->dev->flags & DEV_REGULAR) &&
- !_get_block_size(where->dev, &block_size))
+ !dev_get_block_size(where->dev, &physical_block_size, &block_size))
return_0;
if (!block_size)
@@ -370,36 +392,6 @@ int dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64_t size_
return _dev_discard_blocks(dev, offset_bytes, size_bytes);
}
-/* FIXME Unused
-int dev_get_sectsize(struct device *dev, uint32_t *size)
-{
- int fd;
- int s;
- const char *name = dev_name(dev);
-
- if ((fd = open(name, O_RDONLY)) < 0) {
- log_sys_error("open", name);
- return 0;
- }
-
- if (ioctl(fd, BLKSSZGET, &s) < 0) {
- log_sys_error("ioctl BLKSSZGET", name);
- if (close(fd))
- log_sys_error("close", name);
- return 0;
- }
-
- if (close(fd))
- log_sys_error("close", name);
-
- *size = (uint32_t) s;
-
- log_very_verbose("%s: sector size is %" PRIu32 " bytes", name, *size);
-
- return 1;
-}
-*/
-
void dev_flush(struct device *dev)
{
if (!(dev->flags & DEV_REGULAR) && ioctl(dev->fd, BLKFLSBUF, 0) >= 0)
@@ -571,6 +563,7 @@ static void _close(struct device *dev)
if (close(dev->fd))
log_sys_error("close", dev_name(dev));
dev->fd = -1;
+ dev->phys_block_size = -1;
dev->block_size = -1;
dm_list_del(&dev->open_list);
diff --git a/lib/device/device.h b/lib/device/device.h
index e42f664..35d7505 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -42,6 +42,7 @@ struct device {
int open_count;
int error_count;
int max_error_count;
+ int phys_block_size;
int block_size;
int read_ahead;
uint32_t flags;
@@ -66,8 +67,8 @@ struct device_area {
/*
* All io should use these routines.
*/
+int dev_get_block_size(struct device *dev, unsigned int *phys_block_size, unsigned int *block_size);
int dev_get_size(const struct device *dev, uint64_t *size);
-int dev_get_sectsize(struct device *dev, uint32_t *size);
int dev_get_read_ahead(struct device *dev, uint32_t *read_ahead);
int dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64_t size_bytes);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 9d547bb..1cce72c 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -903,6 +903,7 @@ int vg_remove_snapshot(struct logical_volume *cow);
int vg_check_status(const struct volume_group *vg, uint64_t status);
+int vg_check_pv_dev_block_sizes(const struct volume_group *vg);
/*
* Check if the VG reached maximal LVs count (if set)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5f2addd..84d3200 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -619,6 +619,40 @@ int vg_remove(struct volume_group *vg)
return ret;
}
+int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *vg,
+ unsigned int *max_phys_block_size_found)
+{
+ unsigned int phys_block_size, block_size;
+
+ if (!(dev_get_block_size(dev, &phys_block_size, &block_size)))
+ return_0;
+
+ if (phys_block_size > *max_phys_block_size_found)
+ *max_phys_block_size_found = phys_block_size;
+
+ if (phys_block_size >> SECTOR_SHIFT > vg->extent_size) {
+ log_error("Physical extent size used for volume group %s "
+ "is less than physical block size that %s uses.",
+ vg->name, dev_name(dev));
+ return 0;
+ }
+
+ return 1;
+}
+
+int vg_check_pv_dev_block_sizes(const struct volume_group *vg)
+{
+ struct pv_list *pvl;
+ unsigned int max_phys_block_size_found = 0;
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (!check_dev_block_size_for_vg(pvl->pv->dev, vg, &max_phys_block_size_found))
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* Extend a VG by a single PV / device path
*
@@ -626,10 +660,12 @@ int vg_remove(struct volume_group *vg)
* - vg: handle of volume group to extend by 'pv_name'
* - pv_name: device path of PV to add to VG
* - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
+ * - max_phys_block_size: largest physical block size found amongst PVs in a VG
*
*/
static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
- struct pvcreate_params *pp)
+ struct pvcreate_params *pp,
+ unsigned int *max_phys_block_size)
{
struct physical_volume *pv;
@@ -643,11 +679,18 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
return_0;
}
- if (!add_pv_to_vg(vg, pv_name, pv, pp)) {
- free_pv_fid(pv);
- return_0;
- }
+
+ if (!(check_dev_block_size_for_vg(pv->dev, (const struct volume_group *) vg,
+ max_phys_block_size)))
+ goto_bad;
+
+ if (!add_pv_to_vg(vg, pv_name, pv, pp))
+ goto_bad;
+
return 1;
+bad:
+ free_pv_fid(pv);
+ return 0;
}
/*
@@ -665,6 +708,7 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names
{
int i;
char *pv_name;
+ unsigned int max_phys_block_size = 0;
if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
return_0;
@@ -676,7 +720,7 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names
return 0;
}
dm_unescape_colons_and_at_signs(pv_name, NULL, NULL);
- if (!vg_extend_single_pv(vg, pv_name, pp)) {
+ if (!vg_extend_single_pv(vg, pv_name, pp, &max_phys_block_size)) {
log_error("Unable to add physical volume '%s' to "
"volume group '%s'.", pv_name, vg->name);
dm_free(pv_name);
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 0ab63f2..fef4b3f 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -347,6 +347,9 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name,
struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
struct pvcreate_params *pp, int write_now);
+int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *vg,
+ unsigned int *max_phys_block_size_found);
+
/* Manipulate PV structures */
int pv_add(struct volume_group *vg, struct physical_volume *pv);
int pv_remove(struct volume_group *vg, struct physical_volume *pv);
diff --git a/man/vgchange.8.in b/man/vgchange.8.in
index e687587..823d134 100644
--- a/man/vgchange.8.in
+++ b/man/vgchange.8.in
@@ -183,8 +183,10 @@ minimize metadata read and write overhead.
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIBbBsSkKmMgGtTpPeE ]
Changes the physical extent size on physical volumes of this volume group.
A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes
-is the default if no suffix is present.
-The default is 4 MiB and it must be at least 1 KiB and a power of 2.
+is the default if no suffix is present. The value must be at least 1 sector
+for LVM2 format (where the sector size is the largest sector size of the
+PVs currently used in the VG) or 8KiB for LVM1 format and it must be a
+power of 2. The default is 4 MiB.
Before increasing the physical extent size, you might need to use lvresize,
pvresize and/or pvmove so that everything fits. For example, every
diff --git a/man/vgcreate.8.in b/man/vgcreate.8.in
index 577fee2..e62df9e 100644
--- a/man/vgcreate.8.in
+++ b/man/vgcreate.8.in
@@ -94,8 +94,10 @@ The default value is \fIunmanaged\fP.
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIbBsSkKmMgGtTpPeE ]
Sets the physical extent size on physical volumes of this volume group.
A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes
-is the default if no suffix is present.
-The default is 4 MiB and it must be at least 1 KiB and a power of 2.
+is the default if no suffix is present. The value must be at least 1 sector
+for LVM2 format (where the sector size is the largest sector size of the
+PVs currently used in the VG) or 8KiB for LVM1 format and it must be a
+power of 2. The default is 4 MiB.
Once this value has been set, it is difficult to change it without recreating
the volume group which would involve backing up and restoring data on any
diff --git a/tools/vgchange.c b/tools/vgchange.c
index f9811d2..af4b002 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -368,6 +368,12 @@ static int _vgchange_pesize(struct cmd_context *cmd, struct volume_group *vg)
if (!vg_set_extent_size(vg, extent_size))
return_0;
+ if (!vg_check_pv_dev_block_sizes(vg)) {
+ log_error("Failed to change physical extent size for VG %s.",
+ vg->name);
+ return 0;
+ }
+
return 1;
}
10 years, 3 months