Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6c8c8b1b244fc6a6a27c4…
Commit: 6c8c8b1b244fc6a6a27c4b3888844ad8a4750394
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2017-12-18 20:36 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2017-12-18 20:36 +0000
annotated tag: v2_02_177 has been created
at 6c8c8b1b244fc6a6a27c4b3888844ad8a4750394 (tag)
tagging a1f7a483253b11e52ad5460b28cf0c75dba26659 (commit)
replaces v2_02_176
Release 2.02.177.
A wide-ranging bug fix and tidy-up release, covering in particular raid,
pvmove, activation and also switching to aligned 4k blocks when writing
out on-disk volume group metadata.
124 files changed, 3119 insertions(+), 2485 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlo4KDgACgkQIoGRwVZ+LBfTKwCgsJYQcXtiuHP5MWpJcCiZSDvZ
rVkAnRcOvGOnfkpwX7aFrKecuoxjqTyv
=KKDA
-----END PGP SIGNATURE-----
Alasdair G Kergon (31):
post-release
persistent filter: Skip import before rescan
log: Improve various device-related messages
metadata: Remove unused vg.cft_precommitted
metadata: Eliminate redundant nested VG metadata
log: Add io debug class
regenerate man and conf
lvmdiskscan: Remove unnecessary read.
device: log debug when I/O bounce buffer used
label: Remove unused verify functions.
device: categorise block i/o
device: Skip read-modify-write if replacing whole block.
device: Tag I/O for each mda on a device separately in log messages.
lvmetad: drop stray underscore
format_text: Use explicit alignment in wrapping calc.
format_text: Replace PRI with FMT.
format_text: Log additional circular buffer information.
format_text: Move metadata size checking into separate fn.
format_text: Use absolute alignment to calculate metadata usage
format_text: Adjust metadata alignment calculation.
device: Internal error if writing 0 bytes to dev.
metadata: Consistently skip metadata areas that failed.
device: Fix an unpaired device close.
format_text: Refactor and document metadata offset calculation.
format_text: More refactoring of metadata offset calcs
format_text: Change metadata alignment from 512 to 4096.
format_text: Round size written up to multiple of 4096.
format_text: Supply mempool directly to raw_read_mda_header.
format_text: Separate out code paths for buffer wraparound
format_text: Transfer circular buf alloc to device layer.
pre-release
David Teigland (11):
lvmlockd: retry on other sanlock errors
lvmlockd: override unknown lock manager error numbers
man: lvmlockd steps for changing lock type
lvconvert: prevent combining split snapshots in shared vg
lvmlockd: avoid blocking in sanlock_convert
lvmlockd: recognize normal errors from sanlock_convert
lvmlockd: improve error message for VG lock conflict
lvmlockd: fix log print
lvmlockd: use pool lock for tmeta access
lvmlock: return an error if lvb cannot be written
lvmlockd: clear coverity complaint
Eric Ren (1):
clvmd: supress ENOENT error on testing connection
Heinz Mauelshagen (17):
raid: reject conversion request to striped/raid0 on 2-legged raid4/5
raid: reject message for 2-legged raid4/5 -> striped
raid: correct raid6_n_6 -> raid5 convenience type
test: avoid have_raid overhead
test: additional avoid have_raid overhead
raid: add validation checks for reshape flags
raid: ignore --stripesize on raid4/5 conversion to 1 stripe
test: new reshape test under io load
test: disable new reshape test until target version 1.13.1
lv_manip: allow extension on --nosync raid lv
test: cleanup command
test: reduce pv sizes, fix comment and stripe size
test: add large tests skip option
test: allow to succeed in the cluster
deactivate_lvs: deactivate any missing RaidLV legs
test: new raid tests
test: fix trap adding proper teardown to previous, new raid tests
Marian Csontos (15):
test: Rename test nothing methods
test: D-Bus test_nesting requires filter
Update WHATS_NEW
tests: Fix common_dev_ argument handling
Update WHATS_NEW
Update WHATS_NEW
configure: applib is not required by dbusd
lvmdbusd: Fix path to python3
configure: Fix deprecation warning for lvmapp
test: lvmdbusd is used for process name
lvmdbusd: All tools use detected python3
test: Fix condition when detecting lvmdbusd
docs: Add TESTING file
lvmdbusd: Make lvmdbusd executable
lvm2app: Suppress deprecation warnings for our builds
Ondrej Kozina (2):
dmsetup: hide integrity encryption keys on table output
test: check dmsetup hides integrity encryption keys
Zdenek Kabelac (91):
snapshot: prevent repeated merging
coverity: avoid memleak
coverity: avoid overflow_before_widen
blkdeactive: use /sbin for mdamd
shellcheck: fsadm cleanup
cleanup: gcc const warning
cleanup: update messages in lvconvert
cleanup: drop unneeded headerfiles
coverity: add some initilizers
tests: snasphot merging
lvconvert: update delaying message
tests: have some space for 2nd mda
tests: detect racy systemd version
tests: allow to proceed futher with test
raid: protect raid4 activation
cleanup: constify lv parameter
cleanup: remove stack tracing for ok path
reload: do not take backup with suspended devices
lvremove: for unused cache deactive sublv
lv_lock_holder: unused cache-pool is not lock holder
tests: use nonflusing status
pvmove: snapshots need to go with origin device
pvmove: return pvmove itself
layers: collect only lock holding LVs
activate_lvs: deactivate on uniterate
activation: check subLV before skipping resume
activation: suspend pvmove using lv.
pvmove: always flush when working with pvmove tree
activate_lvs: use exclusive activation
cleanup: update log messages
pvmove: change locking on finish
pvmove: activation changes
pvmove: remove unusued code
tests: pvmove supports more cases
suspend: handle start of pvmove
resume: secure critical section
locking: pvmove is locking holding LV
libdm: preload propagates delayed resume
mirror: use lv_update_and_reload_origin
activation: automaticaly discover pvmove holders
pvmove: finish no longer needs explicit resumed
toollib: avoid printing default stripe size
cache: use conditional in warning message
cleanup: reduce couple debug lines
cleanup: using max args consistently
cleanup: update error messages
tests: typo
tests: more places where missing should not appear
activation: enhance holders detection
pvmove: enhance delayed_resume logic
toollib: improve stripes args reading
cmdline: avoid overrun on very large numbers.
cleanup: reuse existing macro
pvmove: move code from tools to lib
pvmove: add missing segment merging
activation: split priority from memory locking
activation: extend resume validation
activation: avoid rechecking pvmove node
suspend: optimize generated list
cleanup: simplify _deps code
cleanup: remove debug code
libdm: watch for failing _info_by_dev
libdm: support for replicator target is dropped
cleanup: drop unused header
cleanup: futher code reduction
cleanup: simplier error message
cleanup: drop impossible test case
cleanup: mark success at the end
cleanup: stack tracing
cleanup: use _node_name
clenaup: use log_warn
cleanup: use log_warn
cleanup: use existing define with prefix
cleanup: drop unused define
cleanup: messsage cleanup
cleanup: drop unneeded check
activation: also lock memory for clustered locking
thin: always clear memory before parsing status
thin: missing type is error
libdm: add help func _get_last_load_segment
libdm: avoid checking status on activation
libdm: use delay_resume_if_extended
libdm: drop extra structure copy
cleanup: reorder calling of pool checking tools
cleanup: use log_warn
debug: update debug msg
vgchange: drop extra counting
activation: keep priority till memlock_unlock
thin: regression fix for metadata checking
cleanup: switch to standard query
cleanup: debug message
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=761691e233fabddfbf678…
Commit: 761691e233fabddfbf678b3a988fce99d39591f4
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2017-09-13 19:38 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2017-09-13 19:38 +0000
annotated tag: v2.02.174 has been created
at 761691e233fabddfbf678b3a988fce99d39591f4 (tag)
tagging 918f0a92daef84867e0df4b422c3de2a36997f17 (commit)
replaces v2_02_173
Release 2.02.174
Assorted fixes and small improvements, including an extension to
dmsetup for activating more than one device with a single command.
As of this release, we're also pushing the code to github:
https://github.com/lvmteam/lvm2
and will handle any issues reported at
https://github.com/lvmteam/lvm2/issues
81 files changed, 1782 insertions(+), 857 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlm5iu8ACgkQIoGRwVZ+LBdCwgCfWI67MvWO3jaZ0/xvgwl5qjU1
KBwAoM8aCqMfl6N6X8jDEhR8FGDoKJ62
=oAdS
-----END PGP SIGNATURE-----
Alasdair G Kergon (14):
post-release
dmsetup: Add concise table output format.
make generate
dmsetup: Add minor number to concise table output format.
tools: Introduce exit code EINIT_FAILED.
toolcontext: Improve invalid units error message.
ioctl: Allow minor without major.
dmsetup: Add --concise to dmsetup create.
lvmconfig: Add options to produce file preamble
pvcreate: Disallow --bootloaderareasize with --restorefile.
pvcreate: Wipe cached bootloaderarea when wiping label.
pvcreate: Use maximum metadata area size with --restorefile
README: Include new github links
pre-release
David Teigland (16):
vgchange: separate change locktype and allow recovery
vgchange: split out code for lockstart and lockstop
vgchange: split out code for systemid
man: remove hyphen escapes from source
commands: expand comment on configuring option vals
lvmlockd: fix lm running check during adoption
lvmlockd: global name doesn't apply to sanlock
commands: recognize -? for help
commands: recognize lvm command -?
lvmlockd: zero extended lvmlock LV
lvmlockd: add comment about temp ls name
lvmlockd: fix mutex unlock
man lvmthin: change fsck references
lvmlockd: print error about starting lock manager
lvmlockd: fix check for no running lock manager
lvmlockd: always disallow mirror splitting
Heinz Mauelshagen (1):
raid: more validation checks for segment data_offset member
Peter Rajnoha (2):
pvcreate: fix check for 2nd mda at end of disk fits if using pvcreate --restorefile
test: pvcreate-bootloaderarea: pvcreate --restorefile --bootloaderarea not supported anymore
Zdenek Kabelac (31):
raid: reshape synchronization point
tidy: declaration names match implementation
thin: warn about too big chunks size
man: fix generated paths
libdm: log_warn
makefiles: RT_LIB
makefiles: use gcc warns with gcc only
makefiles: fixing linking
makefiles: cleanups
tests: update makefile
configure: improve test for realtime clock
configure: tune BUILD_DMEVENTD
makefiles: fix tested vars
makefiles: script executable missed dynamic
makefiles: add DEFS_$@ for cxx
tests: update makefiles
tests: update checked message
libdm: fix errpath for control node creation
lvmlockd: shorter code
lvmcache: check for lvmcache_foreach_mda return code
debug: add stack trace point
locking: avoid descriptor leak for nonblocking mode
daemonize: more unified code
lvmlockd: avoid double unlock of client_mutex
lvmlockctl: fix check for failing close
lvmlockd: log pthread_join errno code
reporting: validate time parsing with strtol
dmsetup: add missing -- for option
dmsetup: validate strtol reading
cleanup: easier to read code
deamonize: restore detection of errors
Zhang Huan (1):
lvmlockd: reduce io impact for finding sanlock lv free lock offset
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c48d22bd3cddfe540413e…
Commit: c48d22bd3cddfe540413ed591ea18399c571a852
Parent: 584ff361dff9dc27a05839ac179899a80007b56e
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Thu Dec 14 15:42:34 2017 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu Dec 14 16:45:47 2017 +0100
docs: Add TESTING file
---
TESTING | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/TESTING b/TESTING
new file mode 100644
index 0000000..57932f5
--- /dev/null
+++ b/TESTING
@@ -0,0 +1,62 @@
+LVM2 Test Suite
+===============
+
+The codebase contains many tests in the test subdirectory.
+
+Before running tests
+--------------------
+
+Keep in mind the testsuite MUST run under root user.
+
+It is recommended not to use LVM on the test machine, especially when running
+tests with udev (`make check_system`.)
+
+You MUST disable (or mask) any LVM daemons:
+
+- lvmetad
+- dmeventd
+- lvmpolld
+- lvmdbusd
+- lvmlockd
+- clvmd
+- cmirrord
+
+For running cluster tests, we are using singlenode locking. Pass
+`--with-clvmd=singlenode` to configure.
+
+NOTE: This is useful only for testing, and should not be used in produciton
+code.
+
+To run D-Bus daemon tests, existing D-Bus session is required.
+
+Running tests
+-------------
+
+As root run:
+
+ make check
+
+To run only tests matching a string:
+
+ make check T=test
+
+To skip tests matching a string:
+
+ make check S=test
+
+There are other targets and many environment variables can be used to tweak the
+testsuite - for full list and description run `make -C test help`.
+
+Installing testsuite
+--------------------
+
+It is possible to install and run a testsuite against installed LVM. Run the
+following:
+
+ make -C test install
+
+Then lvm2-testsuite binary can be executed to test installed binaries.
+
+See `lvm2-testsuite --help` for options. The same environment variables can be
+used as with `make check`.
+
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=78ffa44fc58fba6f4e8d2…
Commit: 78ffa44fc58fba6f4e8d2046798783d7f4f11b41
Parent: 643df602c7d199c15ba27958e51e61b822a14755
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Dec 12 20:57:36 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Dec 12 20:57:36 2017 +0000
format_text: Change metadata alignment from 512 to 4096.
If there is sufficient space in the metadata area, align the next
metadata to a disk offset that is a multiple of 4096 bytes and
don't write it circularly. If it doesn't all fit at the end
of the metadata area, go back to the start and write it all there
contiguously.
If there is insufficient space to use the new stricter rules, revert to
the original behaviour, aligning on 512-byte boundaries wrapping around
the circular buffer as required.
---
WHATS_NEW | 1 +
lib/format_text/format-text.c | 70 ++++++++++++++++++++++++++++++++---------
lib/format_text/layout.h | 1 +
3 files changed, 57 insertions(+), 15 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f6ead67..f871377 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ Change text format metadata alignment from 512 to 4096 bytes.
When writing metadata, consistently skip mdas marked as failed.
Refactor and adjust text format metadata alignment calculation.
Fix python3 path in lvmdbusd to use value detected by configure.
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 0c5dd1b..ea31a2f 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -488,7 +488,7 @@ static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *md
if (!rlocn)
/* Find an empty slot */
/* FIXME Assumes only one VG per mdah for now */
- return alignment;
+ return ALIGN_ABSOLUTE(MDA_HEADER_SIZE, mdac_area_start, alignment);
/* First find the end of the old metadata */
old_end = rlocn->offset + rlocn->size;
@@ -501,10 +501,21 @@ static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *md
/* Calculate new start position relative to start of buffer rounded up to absolute alignment */
new_start_offset = ALIGN_ABSOLUTE(old_end, mdac_area_start, alignment);
- /* If new location is beyond the end of the buffer, wrap around back to start of circular buffer */
- if (new_start_offset >= mdah->size)
- new_start_offset -= (mdah->size - MDA_HEADER_SIZE);
+ /* If new location is beyond the end of the buffer, return to start of circular buffer and realign */
+ if (new_start_offset >= mdah->size) {
+ /* If the start of the buffer is occupied, move past it */
+ if (old_wrapped || rlocn->offset == MDA_HEADER_SIZE)
+ new_start_offset = old_end;
+ else
+ new_start_offset = MDA_HEADER_SIZE;
+
+ new_start_offset = ALIGN_ABSOLUTE(new_start_offset, mdac_area_start, alignment);
+ }
+ /*
+ * Note that we don't check here that this location isn't inside the existing metadata.
+ * If it is, then it means this value of alignment cannot be used.
+ */
return new_start_offset;
}
@@ -640,6 +651,15 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
uint64_t old_start = 0; /* The start of the existing metadata */
uint64_t new_start = mdac->rlocn.offset; /* The proposed start of the new metadata */
+ /*
+ * If the (aligned) start of the new metadata is already beyond the end
+ * of the buffer this means it didn't fit with the given alignment.
+ * (The caller has already tried to wrap it back to the start
+ * of the buffer but the alignment pushed it back outside.)
+ */
+ if (new_start >= mdah->size)
+ return_0;
+
/* Does the total amount of metadata, old and new, fit inside the buffer? */
if (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)
return_0;
@@ -654,7 +674,7 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
old_wrap = old_end - mdah->size;
}
- new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE : (mdac->rlocn.offset + mdac->rlocn.size);
+ new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE : new_start + mdac->rlocn.size;
/* If both wrap around, there's necessarily overlap */
if (new_wrap && old_wrap)
@@ -668,6 +688,10 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
if ((new_wrap || old_wrap) && (new_end > old_start))
return_0;
+ /* If there's no wrap, check there's no overlap */
+ if (!new_wrap && !old_wrap && (old_end > new_start) && (old_start < new_end))
+ return_0;
+
return 1;
}
@@ -681,7 +705,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
struct pv_list *pvl;
int r = 0;
uint64_t new_wrap; /* Number of bytes of new metadata that wrap around to start of buffer */
- uint64_t alignment = MDA_ORIGINAL_ALIGNMENT;
+ uint64_t alignment = MDA_ALIGNMENT;
int found = 0;
int noprecommit = 0;
const char *old_vg_name = NULL;
@@ -725,16 +749,32 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
/* Find where the new metadata would be written with our preferred alignment */
mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, alignment);
- /* Does the new metadata wrap around? */
+ /* If metadata extends beyond the buffer, return to the start instead of wrapping it */
if (mdac->rlocn.offset + mdac->rlocn.size > mdah->size)
- new_wrap = (mdac->rlocn.offset + mdac->rlocn.size) - mdah->size;
- else
- new_wrap = 0;
+ mdac->rlocn.offset = ALIGN_ABSOLUTE(MDA_HEADER_SIZE, mdac->area.start, alignment);
- if (!_metadata_fits_into_buffer(mdac, mdah, rlocn, new_wrap)) {
- log_error("VG %s metadata on %s (" FMTu64 " bytes) too large for circular buffer (" FMTu64 " bytes with " FMTu64 " used)",
- vg->name, dev_name(mdac->area.dev), mdac->rlocn.size, mdah->size - MDA_HEADER_SIZE, rlocn ? rlocn->size : 0);
- goto out;
+ /*
+ * If the metadata doesn't fit into the buffer correctly with these
+ * settings, fall back to the 512-byte alignment used by the original
+ * LVM2 code and allow the metadata to be split into two parts,
+ * wrapping around from the end of the circular buffer back to the
+ * beginning.
+ */
+ if (!_metadata_fits_into_buffer(mdac, mdah, rlocn, 0)) {
+ alignment = MDA_ORIGINAL_ALIGNMENT;
+ mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, alignment);
+
+ /* Does the new metadata wrap around? */
+ if (mdac->rlocn.offset + mdac->rlocn.size > mdah->size)
+ new_wrap = (mdac->rlocn.offset + mdac->rlocn.size) - mdah->size;
+ else
+ new_wrap = 0;
+
+ if (!_metadata_fits_into_buffer(mdac, mdah, rlocn, new_wrap)) {
+ log_error("VG %s metadata on %s (" FMTu64 " bytes) too large for circular buffer (" FMTu64 " bytes with " FMTu64 " used)",
+ vg->name, dev_name(mdac->area.dev), mdac->rlocn.size, mdah->size - MDA_HEADER_SIZE, rlocn ? rlocn->size : 0);
+ goto out;
+ }
}
log_debug_metadata("Writing %s metadata to %s at " FMTu64 " len " FMTu64 " of " FMTu64 " aligned to " FMTu64,
@@ -1323,7 +1363,7 @@ int vgname_from_mda(const struct format_type *fmt,
(char *)&vgsummary->vgid);
if (mda_free_sectors) {
- current_usage = ALIGN_ABSOLUTE(rlocn->size, dev_area->start + rlocn->offset, MDA_ORIGINAL_ALIGNMENT);
+ current_usage = ALIGN_ABSOLUTE(rlocn->size, dev_area->start + rlocn->offset, MDA_ALIGNMENT);
buffer_size = mdah->size - MDA_HEADER_SIZE;
diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h
index 1746b9c..1eed664 100644
--- a/lib/format_text/layout.h
+++ b/lib/format_text/layout.h
@@ -103,6 +103,7 @@ struct mda_context {
#define LVM2_LABEL "LVM2 001"
#define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
#define MDA_ORIGINAL_ALIGNMENT 512 /* Original alignment used for start of VG metadata content */
+#define MDA_ALIGNMENT 4096 /* Default alignment in bytes since 2.02.177 for start of VG metadata content. */
int vgname_from_mda(const struct format_type *fmt, struct mda_header *mdah, int primary_mda,
struct device_area *dev_area, struct lvmcache_vgsummary *vgsummary,
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=643df602c7d199c15ba27…
Commit: 643df602c7d199c15ba27958e51e61b822a14755
Parent: 4002f5e206ae89db28eb60bdfb3685bd926fed57
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Dec 12 18:46:25 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Dec 12 18:51:32 2017 +0000
format_text: More refactoring of metadata offset calcs
---
lib/format_text/format-text.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 174a579..0c5dd1b 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -482,15 +482,24 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
*/
static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *mdah, uint64_t mdac_area_start, uint64_t alignment)
{
- uint64_t new_start_offset;
+ uint64_t old_end, new_start_offset;
+ int old_wrapped = 0; /* Does the old metadata wrap around? */
if (!rlocn)
/* Find an empty slot */
/* FIXME Assumes only one VG per mdah for now */
return alignment;
+ /* First find the end of the old metadata */
+ old_end = rlocn->offset + rlocn->size;
+
+ if (old_end > mdah->size) {
+ old_wrapped = 1;
+ old_end -= (mdah->size - MDA_HEADER_SIZE);
+ }
+
/* Calculate new start position relative to start of buffer rounded up to absolute alignment */
- new_start_offset = ALIGN_ABSOLUTE(rlocn->offset + rlocn->size, mdac_area_start, alignment);
+ new_start_offset = ALIGN_ABSOLUTE(old_end, mdac_area_start, alignment);
/* If new location is beyond the end of the buffer, wrap around back to start of circular buffer */
if (new_start_offset >= mdah->size)
@@ -626,16 +635,23 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
struct raw_locn *rlocn, uint64_t new_wrap)
{
uint64_t old_wrap = 0; /* Amount of wrap around in existing metadata */
- uint64_t new_end; /* The end location of the new metadata */
+ uint64_t old_end = 0; /* The (byte after the) end of the existing metadata */
+ uint64_t new_end; /* The (byte after the) end of the new metadata */
+ uint64_t old_start = 0; /* The start of the existing metadata */
+ uint64_t new_start = mdac->rlocn.offset; /* The proposed start of the new metadata */
/* Does the total amount of metadata, old and new, fit inside the buffer? */
if (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)
return_0;
- /* Does the existing metadata wrap around the end of the buffer? */
+ /* If there's existing metadata, set old_start, old_end and old_wrap. */
if (rlocn) {
- if (rlocn->offset + rlocn->size > mdah->size)
- old_wrap = (rlocn->offset + rlocn->size) - mdah->size;
+ old_start = rlocn->offset;
+ old_end = old_start + rlocn->size;
+
+ /* Does the existing metadata wrap around the end of the buffer? */
+ if (old_end > mdah->size)
+ old_wrap = old_end - mdah->size;
}
new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE : (mdac->rlocn.offset + mdac->rlocn.size);
@@ -649,7 +665,7 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
return 1;
/* If either wraps around, there's overlap if the new end falls beyond the old start */
- if ((new_wrap || old_wrap) && (new_end > rlocn->offset))
+ if ((new_wrap || old_wrap) && (new_end > old_start))
return_0;
return 1;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4002f5e206ae89db28eb6…
Commit: 4002f5e206ae89db28eb60bdfb3685bd926fed57
Parent: e932c5da50a22e585a3cd08edb3d849e7715e244
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Dec 12 18:36:54 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Dec 12 18:36:54 2017 +0000
format_text: Refactor and document metadata offset calculation.
---
lib/format_text/format-text.c | 47 +++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 154d748..174a579 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -476,7 +476,9 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
}
/*
- * Determine offset for uncommitted metadata
+ * Find first aligned offset after end of existing metadata.
+ * Based on the alignment provided, this is the exact offset to use for the new metadata.
+ * The caller is responsible for validating the result.
*/
static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *mdah, uint64_t mdac_area_start, uint64_t alignment)
{
@@ -484,7 +486,7 @@ static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *md
if (!rlocn)
/* Find an empty slot */
- /* FIXME Assume only one VG per mdah for now */
+ /* FIXME Assumes only one VG per mdah for now */
return alignment;
/* Calculate new start position relative to start of buffer rounded up to absolute alignment */
@@ -626,23 +628,28 @@ static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_heade
uint64_t old_wrap = 0; /* Amount of wrap around in existing metadata */
uint64_t new_end; /* The end location of the new metadata */
- /* Do we have existing metadata that ends beyond the end of the buffer? */
- if (rlocn && (rlocn->offset + rlocn->size > mdah->size))
- old_wrap = (rlocn->offset + rlocn->size) - mdah->size;
+ /* Does the total amount of metadata, old and new, fit inside the buffer? */
+ if (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)
+ return_0;
- new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE :
- mdac->rlocn.offset + mdac->rlocn.size;
+ /* Does the existing metadata wrap around the end of the buffer? */
+ if (rlocn) {
+ if (rlocn->offset + rlocn->size > mdah->size)
+ old_wrap = (rlocn->offset + rlocn->size) - mdah->size;
+ }
+
+ new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE : (mdac->rlocn.offset + mdac->rlocn.size);
/* If both wrap around, there's necessarily overlap */
if (new_wrap && old_wrap)
return_0;
- /* If either wraps around, does the new end fall beyond the old start? */
- if (rlocn && (new_wrap || old_wrap) && (new_end > rlocn->offset))
- return_0;
+ /* If there's no existing metadata, we're OK */
+ if (!rlocn)
+ return 1;
- /* Does the total amount of metadata, old and new, fit inside the buffer? */
- if (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)
+ /* If either wraps around, there's overlap if the new end falls beyond the old start */
+ if ((new_wrap || old_wrap) && (new_end > rlocn->offset))
return_0;
return 1;
@@ -658,6 +665,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
struct pv_list *pvl;
int r = 0;
uint64_t new_wrap; /* Number of bytes of new metadata that wrap around to start of buffer */
+ uint64_t alignment = MDA_ORIGINAL_ALIGNMENT;
int found = 0;
int noprecommit = 0;
const char *old_vg_name = NULL;
@@ -675,6 +683,12 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!found)
return 1;
+ /*
+ * This is paired with the following closes:
+ * - at the end of this fn if returning 0
+ * - in _vg_commit_raw_rlocn regardless of return code
+ * which handles commit (but not pre-commit) and revert.
+ */
if (!dev_open(mdac->area.dev))
return_0;
@@ -692,8 +706,10 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
mdac->rlocn.size = fidtc->raw_metadata_buf_size;
- mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, MDA_ORIGINAL_ALIGNMENT);
+ /* Find where the new metadata would be written with our preferred alignment */
+ mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, alignment);
+ /* Does the new metadata wrap around? */
if (mdac->rlocn.offset + mdac->rlocn.size > mdah->size)
new_wrap = (mdac->rlocn.offset + mdac->rlocn.size) - mdah->size;
else
@@ -705,9 +721,9 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
goto out;
}
- log_debug_metadata("Writing %s metadata to %s at " FMTu64 " len " FMTu64 " of " FMTu64,
+ log_debug_metadata("Writing %s metadata to %s at " FMTu64 " len " FMTu64 " of " FMTu64 " aligned to " FMTu64,
vg->name, dev_name(mdac->area.dev), mdac->area.start +
- mdac->rlocn.offset, mdac->rlocn.size - new_wrap, mdac->rlocn.size);
+ mdac->rlocn.offset, mdac->rlocn.size - new_wrap, mdac->rlocn.size, alignment);
/* Write text out, circularly */
if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
@@ -837,6 +853,7 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
out:
if (!precommit) {
+ /* This is an paired with the open at the start of _vg_write_raw */
if (!dev_close(mdac->area.dev))
stack;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b96862ee11e0291cc1101…
Commit: b96862ee11e0291cc1101ff4e17e54f9fe8da666
Parent: 15ccea71116f4c0a587aaa0ed25dc1d8d98c0c7f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Dec 12 17:49:35 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Dec 12 17:52:45 2017 +0000
metadata: Consistently skip metadata areas that failed.
Even after writing some metadata encountered problems, some commands
continue (rightly or wrongly) and attempt to make further changes.
Once an mda is marked MDA_FAILED, don't try to use it again.
This also applies when reverting, where one loop already skips
failed mdas but the other doesn't.
This fixes some device open_count warnings on relevant failure paths.
---
WHATS_NEW | 1 +
lib/metadata/metadata.c | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9ff8b51..f6ead67 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.177 -
====================================
+ When writing metadata, consistently skip mdas marked as failed.
Refactor and adjust text format metadata alignment calculation.
Fix python3 path in lvmdbusd to use value detected by configure.
Reduce checks for active LVs in vgchange before background polling.
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 56b5b13..6c55d89 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3039,6 +3039,8 @@ int vg_write(struct volume_group *vg)
/* Write to each copy of the metadata area */
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
+ if (mda->status & MDA_FAILED)
+ continue;
if (!mda->ops->vg_write) {
log_error("Format does not support writing volume"
"group metadata areas");
@@ -3063,6 +3065,9 @@ int vg_write(struct volume_group *vg)
dm_list_uniterate(mdah, &vg->fid->metadata_areas_in_use, &mda->list) {
mda = dm_list_item(mdah, struct metadata_area);
+ if (mda->status & MDA_FAILED)
+ continue;
+
if (mda->ops->vg_revert &&
!mda->ops->vg_revert(vg->fid, vg, mda)) {
stack;