Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3c978f7bcc8c7d7cb473b…
Commit: 3c978f7bcc8c7d7cb473ba718a8e44523a09d02e
Parent: 222e1e3acee399b0acf31565f784716d67c465a8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Aug 15 13:23:51 2017 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Aug 15 13:40:25 2017 +0200
pvcreate: fix check for 2nd mda at end of disk fits if using pvcreate --restorefile
Fix code checking that the 2nd mda which is at the end of disk really
fits the available free space and avoid any DA and MDA interleaving when
we already have DA preallocated. This mainly applies when we're restoring
a PV from VG backup using pvcreate --restorefile where we may already have
some DA preallocated - this means the PV was in a VG before with already
allocated space from it (the LVs were created). Hence we need to avoid
stepping into DA - the MDA can never ever be inside in such case!
The code responsible for this calculation was already in
_text_pv_add_metadata_area fn, but it had a bug in the calculation where
we subtracted one more sector by mistake and then the code could still
incorrectly allocate the MDA inside existing DA. The patch also renames
the variable in the code so it doesn't confuse us in future.
Also, if the 2nd mda doesn't fit, don't silently continue with just 1
MDA (at the start of the disk). If 2nd mda was requested and we can't
create that due to unavailable space, error out correctly (the patch
also adds a test to shell/pvcreate-operation.sh for this case).
---
WHATS_NEW | 1 +
lib/format_text/format-text.c | 34 +++++++++++++++++-----------------
test/shell/pvcreate-operation.sh | 28 ++++++++++++++++++++++++----
3 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2e1294e..c8f072f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.174 -
=================================
+ Fix check for 2nd mda at end of disk fits if using pvcreate --restorefile.
Use maximum metadataarea size that fits with pvcreate --restorefile.
Always clear cached bootloaderarea when wiping label e.g. in pvcreate.
Disallow --bootloaderareasize with pvcreate --restorefile.
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 7db4637..e974f05 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2078,7 +2078,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
{
struct format_instance *fid = pv->fid;
const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
- uint64_t ba_size, pe_start, pe_end;
+ uint64_t ba_size, pe_start, first_unallocated;
uint64_t alignment, alignment_offset;
uint64_t disk_size;
uint64_t mda_start;
@@ -2213,14 +2213,24 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
* if defined or locked. If pe_start is not defined yet, count
* with any existing MDA0. If MDA0 does not exist, just use
* LABEL_SCAN_SIZE.
+ *
+ * The first_unallocated here is the first unallocated byte
+ * beyond existing pe_end if there is any preallocated data area
+ * reserved already so we can take that as lower limit for our MDA1
+ * start calculation. If data area is not reserved yet, we set
+ * first_unallocated to 0, meaning this is not our limiting factor
+ * and we will look at other limiting factors if they exist.
+ * Of course, if we have preallocated data area, we also must
+ * have pe_start assigned too (simply, data area needs its start
+ * and end specification).
*/
- pe_end = pv->pe_count ? (pv->pe_start +
- pv->pe_count * (uint64_t)pv->pe_size - 1) << SECTOR_SHIFT
- : 0;
+ first_unallocated = pv->pe_count ? (pv->pe_start + pv->pe_count *
+ (uint64_t)pv->pe_size) << SECTOR_SHIFT
+ : 0;
if (pe_start || pe_start_locked) {
- limit = pe_end ? pe_end : pe_start;
- limit_name = pe_end ? "pe_end" : "pe_start";
+ limit = first_unallocated ? first_unallocated : pe_start;
+ limit_name = first_unallocated ? "pe_end" : "pe_start";
} else {
if ((mda = fid_get_mda_indexed(fid, pvid, ID_LEN, 0)) &&
(mdac = mda->metadata_locn)) {
@@ -2239,7 +2249,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
}
}
- if (limit > disk_size)
+ if (limit >= disk_size)
goto bad;
if (mda_size > disk_size) {
@@ -2265,16 +2275,6 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
mda_start = disk_size - mda_size;
}
}
-
- /*
- * If PV's pe_end not set yet, set it to the end of the
- * area that precedes the MDA1 we've just calculated.
- * FIXME: do we need to set this? Isn't it always set before?
- */
- /*if (!pe_end) {
- pe_end = mda_start;
- pv->pe_end = pe_end >> SECTOR_SHIFT;
- }*/
}
if (limit_applied)
diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh
index ad80375..af1c5a2 100644
--- a/test/shell/pvcreate-operation.sh
+++ b/test/shell/pvcreate-operation.sh
@@ -149,16 +149,36 @@ grep "incompatible with restored pe_start value" err
# 300k is multiple of 600k so this should pass
pvcreate --restorefile "$backupfile" --uui "$uuid1" --dataalignment 300k --dataalignmentoffset 32k "$dev1" 2> err
not grep "incompatible with restored pe_start value" err
-rm -f "$backupfile"
# pvcreate rejects non-existent uuid given with restorefile
-not pvcreate --uuid "$uuid1" --restorefile "$backupfile" "$dev1"
+not pvcreate --uuid "$uuid2" --restorefile "$backupfile" "$dev1" 2> err
+grep "Can't find uuid $uuid2 in backup file $backupfile" err
# pvcreate rejects restorefile without uuid
-not pvcreate --restorefile "$backupfile" "$dev1"
+not pvcreate --restorefile "$backupfile" "$dev1" 2>err
+grep -- "--uuid is required with --restorefile" err
# pvcreate rejects uuid restore with multiple volumes specified
-not pvcreate --uuid "$uuid1" --restorefile "$backupfile" "$dev1" "$dev2"
+not pvcreate --uuid "$uuid1" --restorefile "$backupfile" "$dev1" "$dev2" 2>err
+grep "Can only set uuid on one volume at once" err
+
+# --bootloaderareasize not allowed with pvcreate --restorefile
+not pvcreate --uuid "$uuid1" --restorefile "$backupfile" --bootloaderareasize 1m "$dev1" "$dev2" 2>err
+grep -- "Command does not accept option combination: --bootloaderareasize with --restorefile" err
+
+rm -f "$backupfile"
+
+pvcreate --norestorefile --uuid $uuid1 "$dev1"
+vgcreate --physicalextentsize 1m $vg1 "$dev1"
+vgcfgbackup -f "$backupfile" "$vg1"
+vgremove -ff "$vg1"
+pvremove -ff "$dev1"
+
+# when 2nd mda requested on pvcreate --restorefile and not enough space for it, pvcreate fails
+not pvcreate --restorefile "$backupfile" --uuid $uuid1 --metadatacopies 2 "$dev1" 2>err
+grep "Not enough space available for metadata area with index 1 on PV $dev1" err
+
+rm -f "$backupfile"
# pvcreate wipes swap signature when forced
dd if=/dev/zero of="$dev1" bs=1024 count=64
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=42fa20d0d0136c1aeb3cc…
Commit: 42fa20d0d0136c1aeb3ccdf0654c64beeee05821
Parent: 4fa5add6b1bd4d7f7313f2950021a09e4130ad08
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Aug 11 20:41:37 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Aug 11 20:41:37 2017 +0100
pvcreate: Use maximum metadata area size with --restorefile
If the PV was originally created with a larger-than-default
metadata area the restored one wasn't and might not even be
large enough to hold the metadata!
---
WHATS_NEW | 1 +
tools/pvcreate.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e05fae2..2e1294e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.174 -
=================================
+ Use maximum metadataarea size that fits with pvcreate --restorefile.
Always clear cached bootloaderarea when wiping label e.g. in pvcreate.
Disallow --bootloaderareasize with pvcreate --restorefile.
Fix lvmlockd check for running lock managers during lock adoption.
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 0fe5ad5..9dc50e4 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -135,6 +135,15 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!pvcreate_params_from_args(cmd, &pp))
return EINVALID_CMD_LINE;
+ /*
+ * If --metadatasize was not given with --restorefile, set it to pe_start.
+ * Later code treats this as a maximum size and reduces it to fit.
+ */
+ if (!arg_is_set(cmd, metadatasize_ARG) && arg_is_set(cmd, restorefile_ARG))
+ pp.pva.pvmetadatasize = pp.pva.pe_start;
+
+ /* FIXME Also needs to check any 2nd metadata area isn't inside the data area! */
+
pp.pv_count = argc;
pp.pv_names = argv;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8ecb5817c7e08a9a95a01…
Commit: 8ecb5817c7e08a9a95a0172386af61ba3715948d
Parent: 568c7ed6f1a1df23b9843a54b0bc53816ac5f621
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Aug 7 10:43:28 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Aug 7 10:46:03 2017 -0500
lvmlockd: global name doesn't apply to sanlock
When adopting locks, we shouldn't skip the special
dlm global lockspace name when using sanlock.
---
daemons/lvmlockd/lvmlockd-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 5f08bbf..01259c0 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -5263,7 +5263,7 @@ static void adopt_locks(void)
list_for_each_entry_safe(ls1, l1safe, &ls_found, list) {
/* The dlm global lockspace is special and doesn't match a VG. */
- if (!strcmp(ls1->name, gl_lsname_dlm)) {
+ if ((ls1->lm_type == LD_LM_DLM) && !strcmp(ls1->name, gl_lsname_dlm)) {
list_del(&ls1->list);
free(ls1);
continue;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=568c7ed6f1a1df23b9843…
Commit: 568c7ed6f1a1df23b9843a54b0bc53816ac5f621
Parent: fe423ef583a48ca0f780156ec5f1fe33716318ad
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Aug 7 10:37:22 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Aug 7 10:45:59 2017 -0500
lvmlockd: fix lm running check during adoption
When trying to adopt locks in startup, we want to ignore
a lock manager that isn't running, not fail.
---
WHATS_NEW | 1 +
daemons/lvmlockd/lvmlockd-core.c | 11 ++++-------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ebbc7d1..c484529 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.174 -
=================================
+ Fix lvmlockd check for running lock managers during lock adoption.
Add --withgeneralpreamble and --withlocalpreamble to lvmconfig.
Improve makefiles' linking.
Fix some paths in generated makefiles to respected configured settings.
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 867e3ca..5f08bbf 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -5176,20 +5176,17 @@ static void adopt_locks(void)
* Get list of lockspaces from lock managers.
* Get list of VGs from lvmetad with a lockd type.
* Get list of active lockd type LVs from /dev.
- *
- * ECONNREFUSED means the lock manager is not running.
- * This is expected for at least one of them.
*/
- if (lm_support_dlm()) {
+ if (lm_support_dlm() && lm_is_running_dlm()) {
rv = lm_get_lockspaces_dlm(&ls_found);
- if ((rv < 0) && (rv != -ECONNREFUSED))
+ if (rv < 0)
goto fail;
}
- if (lm_support_sanlock()) {
+ if (lm_support_sanlock() && lm_is_running_sanlock()) {
rv = lm_get_lockspaces_sanlock(&ls_found);
- if ((rv < 0) && (rv != -ECONNREFUSED))
+ if (rv < 0)
goto fail;
}