master - cachevol: wipe 'normal' device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f6d171ffe33455ab48e...
Commit: f6d171ffe33455ab48e142820aa74be901e8aee9
Parent: 615e18f5b2356bd1fd134bc24ea790fa6ec0653f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 15:27:41 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:46 2019 +0200
cachevol: wipe 'normal' device
For wiping we activate and clear 'regular' devices,
since in case of whole process interuption (i.e. kill -9)
we leave metadata & DM table and workable state all the time.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 8 +++-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bb806ac..6405686 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.06 -
================================
+ Use normal LVs for wiping of cachevols.
Reload cleanered cache DM only with cleaner policy.
Fix cmd return when zering of cachevol fails.
Extend lvs to show all VDO properties.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8ecbf34..885380c 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4224,8 +4224,6 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
if (!lockd_lv(cmd, cachevol_lv, "ex", LDLV_PERSISTENT))
goto_out;
- cachevol_lv->status |= LV_CACHE_VOL;
-
if (!wipe_cache_pool(cachevol_lv))
goto_out;
@@ -4240,7 +4238,7 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
goto_out;
/* Attach the cache to the main LV. */
-
+ cachevol_lv->status |= LV_CACHE_VOL;
if (!_cache_vol_attach(cmd, lv, cachevol_lv))
goto_out;
@@ -5551,8 +5549,6 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
if (!archive(vg))
goto_bad;
- lv_fast->status |= LV_CACHE_VOL;
-
/*
* TODO: use libblkid to get the sector size of lv. If it doesn't
* match the block_size we are using for the writecache, then warn that
@@ -5567,6 +5563,8 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
return ECMD_FAILED;
}
+ lv_fast->status |= LV_CACHE_VOL;
+
/*
* Changes the vg struct to match the desired state.
*
4 years, 7 months
master - cachevol: rename converted LV to _cvol
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8a8e6ebba2521da596e...
Commit: 8a8e6ebba2521da596e9e85fe2799e336640ace3
Parent: f6d171ffe33455ab48e142820aa74be901e8aee9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 12 23:37:17 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:15:12 2019 +0200
cachevol: rename converted LV to _cvol
When converting existing public LV to internally used
'CacheVol' LV - rename LV to LV_cvol.
When splitting CacheVol, remove _cvol suffix.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6405686..6d1700a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.06 -
================================
+ Rename LV converted to cachevol to use _cvol suffix.
Use normal LVs for wiping of cachevols.
Reload cleanered cache DM only with cleaner policy.
Fix cmd return when zering of cachevol fails.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 885380c..14663e8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1840,6 +1840,8 @@ static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *lv_fast)
{
+ char cvol_name[NAME_LEN];
+ char *c;
struct lv_segment *cache_seg = first_seg(lv);
int cache_mode = cache_seg->cache_mode;
int noflush = 0;
@@ -1879,6 +1881,25 @@ static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
if (!lv_detach_cache_vol(lv, noflush))
return_0;
+ /* Cut off suffix _cvol */
+ if (!dm_strncpy(cvol_name, lv_fast->name, sizeof(cvol_name)) ||
+ !(c = strstr(cvol_name, "_cvol"))) {
+ /* likely older instance of metadata */
+ log_debug("LV %s has no suffix for cachevol (skipping rename).",
+ display_lvname(lv_fast));
+ } else {
+ *c = 0;
+ /* If the name is in use, generate new lvol%d */
+ if (lv_name_is_used_in_vg(lv->vg, cvol_name, NULL) &&
+ !generate_lv_name(lv->vg, "lvol%d", cvol_name, sizeof(cvol_name))) {
+ log_error("Failed to generate unique name for unused logical volume.");
+ return 0;
+ }
+
+ if (!lv_rename_update(cmd, lv_fast, cvol_name, 0))
+ return_0;
+ }
+
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
@@ -4193,6 +4214,7 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
struct volume_group *vg = lv->vg;
struct logical_volume *cachevol_lv;
const char *cachevol_name;
+ char cvol_name[NAME_LEN];
if (!(cachevol_name = arg_str_value(cmd, cachevol_ARG, NULL)))
goto_out;
@@ -4238,6 +4260,13 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
goto_out;
/* Attach the cache to the main LV. */
+ if (dm_snprintf(cvol_name, sizeof(cvol_name), "%s_cvol", cachevol_lv->name) < 0) {
+ log_error("Can't prepare new metadata name for %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
+ if (!lv_rename_update(cmd, cachevol_lv, cvol_name, 0))
+ return_0;
+
cachevol_lv->status |= LV_CACHE_VOL;
if (!_cache_vol_attach(cmd, lv, cachevol_lv))
goto_out;
4 years, 7 months
master - cache: enhance removal function to work with cvol
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=615e18f5b2356bd1fd1...
Commit: 615e18f5b2356bd1fd134bc24ea790fa6ec0653f
Parent: 6ee83f699b5f3e5ffc09a7264de44425e8634970
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 14 10:43:04 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:25 2019 +0200
cache: enhance removal function to work with cvol
To keep things simple, use same code for all cache removal functions,
not just for cachepools but also cachevols.
---
lib/metadata/cache_manip.c | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 1a5482b..9ace494 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -747,7 +747,7 @@ int lv_detach_cache_vol(struct logical_volume *cache_lv, int noflush)
* @cache_lv
*
* Given a cache LV, remove the cache layer. This will unlink
- * the origin and cache_pool, remove the cache LV layer, and promote
+ * the origin and cache_pool/cachevol, remove the cache LV layer, and promote
* the origin to a usable non-cached LV of the same name as the
* given cache_lv.
*
@@ -758,6 +758,8 @@ int lv_cache_remove(struct logical_volume *cache_lv)
struct lv_segment *cache_seg = first_seg(cache_lv);
struct logical_volume *corigin_lv;
struct logical_volume *cache_pool_lv;
+ const struct id *data_id, *metadata_id;
+ uint64_t data_len, metadata_len;
cache_mode_t cache_mode;
int is_clear;
@@ -767,11 +769,6 @@ int lv_cache_remove(struct logical_volume *cache_lv)
return 0;
}
- if (lv_is_cache_vol(cache_seg->pool_lv)) {
- log_error(INTERNAL_ERROR "Incorrect remove for cache single");
- return 0;
- }
-
if (lv_is_pending_delete(cache_lv)) {
log_debug(INTERNAL_ERROR "LV %s is already dropped cache volume.",
display_lvname(cache_lv));
@@ -849,6 +846,13 @@ int lv_cache_remove(struct logical_volume *cache_lv)
if (!remove_layer_from_lv(cache_lv, corigin_lv))
return_0;
+ /* Preserve currently imortant data from original cache segment.
+ * TODO: can it be done without this ? */
+ data_id = &cache_seg->data_id;
+ data_len = cache_seg->data_len;
+ metadata_id = &cache_seg->metadata_id;
+ metadata_len = cache_seg->metadata_len;
+
/* Replace 'error' with 'cache' segtype */
cache_seg = first_seg(corigin_lv);
if (!(cache_seg->segtype = get_segtype_from_string(corigin_lv->vg->cmd, SEG_TYPE_NAME_CACHE)))
@@ -864,6 +868,18 @@ int lv_cache_remove(struct logical_volume *cache_lv)
corigin_lv->size = cache_lv->size;
corigin_lv->status |= LV_PENDING_DELETE;
+ /* Restore preserved data into a new cache segment that is going to be removed. */
+ if ((cache_seg->data_len = data_len)) {
+ cache_seg->metadata_len = metadata_len;
+ memcpy(&cache_seg->data_id, data_id, sizeof(struct id));
+ memcpy(&cache_seg->metadata_id, metadata_id, sizeof(struct id));
+ cache_pool_lv->status |= LV_CACHE_VOL;
+ /* Unused settings set only for passing metadata validation. */
+ cache_seg->cache_mode = CACHE_MODE_WRITETHROUGH;
+ cache_seg->chunk_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
+ cache_seg->cache_metadata_format = CACHE_METADATA_FORMAT_2;
+ }
+
/* Reattach cache pool */
if (!attach_pool_lv(cache_seg, cache_pool_lv, NULL, NULL, NULL))
return_0;
@@ -879,6 +895,8 @@ remove:
if (!lv_remove(cache_lv)) /* Will use LV_PENDING_DELETE */
return_0;
+ /* CachePool or CacheVol is left inactivate for further manipulation */
+
return 1;
}
4 years, 7 months
master - cache: correct condition
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6ee83f699b5f3e5ffc0...
Commit: 6ee83f699b5f3e5ffc09a7264de44425e8634970
Parent: bc35ccd1740a588293b5a2eb5bbe936f837f6c21
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 12 23:40:58 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:25 2019 +0200
cache: correct condition
---
lib/metadata/cache_manip.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index e444e37..1a5482b 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -1434,8 +1434,7 @@ int wipe_cache_pool(struct logical_volume *cache_pool_lv)
int r;
/* Only unused cache-pool could be activated and wiped */
- if ((!lv_is_cache_pool(cache_pool_lv) && !lv_is_cache_vol(cache_pool_lv)) ||
- !dm_list_empty(&cache_pool_lv->segs_using_this_lv)) {
+ if (lv_is_used_cache_pool(cache_pool_lv) || lv_is_cache_vol(cache_pool_lv)) {
log_error(INTERNAL_ERROR "Failed to wipe cache pool for volume %s.",
display_lvname(cache_pool_lv));
return 0;
4 years, 7 months
master - cache: recognize cachevol with lv_cache_remove
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bc35ccd1740a588293b...
Commit: bc35ccd1740a588293b5a2eb5bbe936f837f6c21
Parent: 36944e1009e932902269d3eab547e0b19da13468
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 12 23:40:15 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:25 2019 +0200
cache: recognize cachevol with lv_cache_remove
---
lib/metadata/cache_manip.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index e4cd345..e444e37 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -758,6 +758,7 @@ int lv_cache_remove(struct logical_volume *cache_lv)
struct lv_segment *cache_seg = first_seg(cache_lv);
struct logical_volume *corigin_lv;
struct logical_volume *cache_pool_lv;
+ cache_mode_t cache_mode;
int is_clear;
if (!lv_is_cache(cache_lv)) {
@@ -783,7 +784,9 @@ int lv_cache_remove(struct logical_volume *cache_lv)
if (!deactivate_lv_with_sub_lv(cache_lv))
return_0;
- switch (first_seg(cache_seg->pool_lv)->cache_mode) {
+ cache_mode = (lv_is_cache_pool(cache_seg->pool_lv)) ?
+ first_seg(cache_seg->pool_lv)->cache_mode : cache_seg->cache_mode;
+ switch (cache_mode) {
case CACHE_MODE_WRITETHROUGH:
case CACHE_MODE_PASSTHROUGH:
/* For inactive pass/writethrough just drop cache layer */
4 years, 7 months
master - cache: reload only when switched to cleaner policy
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=36944e1009e93290226...
Commit: 36944e1009e932902269d3eab547e0b19da13468
Parent: ddaf2002c94a33863ef7adf69ad4cdffcfbd73c5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 12 11:12:11 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:22 2019 +0200
cache: reload only when switched to cleaner policy
Reload cache target only when lvm2 reload table with
cache with clearer policy.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d530d9f..bb806ac 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.06 -
================================
+ Reload cleanered cache DM only with cleaner policy.
Fix cmd return when zering of cachevol fails.
Extend lvs to show all VDO properties.
Preserve VDO write policy with vdopool.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 65589f7..e4cd345 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -545,7 +545,7 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
* TODO: add check if extra suspend resume is necessary
* ATM this is workaround for missing cache sync when cache gets clean
*/
- if (1) {
+ if (cleaner_policy) {
if (!lv_refresh_suspend_resume(lock_lv))
return_0;
4 years, 7 months
master - lvconvert: use struct initializer
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ddaf2002c94a33863ef...
Commit: ddaf2002c94a33863ef7adf69ad4cdffcfbd73c5
Parent: e6691aa04be8bbe8768c6a7a520b36498066b9e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 14 11:53:59 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:13:47 2019 +0200
lvconvert: use struct initializer
Always good to keep rest of structure initilized with zeros.
---
tools/lvconvert.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index caef5d5..8ecbf34 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5290,7 +5290,11 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
{
- struct wipe_params wp;
+ struct wipe_params wp = {
+ .do_wipe_signatures = 1, /* optional, to print warning if clobbering something */
+ .do_zero = 1, /* required for dm-writecache to work */
+ .zero_sectors = 1
+ };
int ret;
if (!activate_lv(cmd, lv)) {
@@ -5298,11 +5302,6 @@ static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
return 0;
}
- wp.do_wipe_signatures = 1; /* optional, to print warning if clobbering something */
- wp.do_zero = 1; /* required for dm-writecache to work */
- wp.zero_sectors = 1;
- wp.zero_value = 0;
-
ret = wipe_lv(lv, wp);
if (!deactivate_lv(cmd, lv)) {
4 years, 7 months
master - tests: disable caching of VDO
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e6691aa04be8bbe8768...
Commit: e6691aa04be8bbe8768c6a7a520b36498066b9e8
Parent: 76a9a86fd359681a598a6509eb90940c3a10f1f3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 9 15:27:44 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:13:47 2019 +0200
tests: disable caching of VDO
Disable until vdo gets fixed, then require fixed version.
Otherwise test kills kernel
---
test/shell/lvcreate-vdo-cache.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvcreate-vdo-cache.sh b/test/shell/lvcreate-vdo-cache.sh
index c3d3ed0..a104a16 100644
--- a/test/shell/lvcreate-vdo-cache.sh
+++ b/test/shell/lvcreate-vdo-cache.sh
@@ -20,7 +20,11 @@ SKIP_WITH_LVMPOLLD=1
#
# Main
#
-aux have_vdo 6 2 0 || skip
+
+#
+# FIXME: tempororarily disable this test until fixed VDO driver is relase
+#
+aux have_vdo 96 2 0 || skip
aux have_cache 1 3 0 || skip
which mkfs.ext4 || skip
4 years, 7 months
master - lvconvert: fix return value when zeroing fails
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=76a9a86fd359681a598...
Commit: 76a9a86fd359681a598a6509eb90940c3a10f1f3
Parent: bd21736e8b082319e1a9a29e75badd906ee277f6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 14 11:54:49 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 15:13:33 2019 +0200
lvconvert: fix return value when zeroing fails
Use correct error return code for fail path.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 767973c..d530d9f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.06 -
================================
+ Fix cmd return when zering of cachevol fails.
Extend lvs to show all VDO properties.
Preserve VDO write policy with vdopool.
Increase default vdo bio threads to 4.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 60ab956..caef5d5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5565,7 +5565,7 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
if (!_writecache_zero(cmd, lv_fast)) {
log_error("LV %s could not be zeroed.", display_lvname(lv_fast));
- return 0;
+ return ECMD_FAILED;
}
/*
4 years, 7 months
master - vgck: fix updatemetadata writing different descriptions
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d6ffc990523468e46ae...
Commit: d6ffc990523468e46ae03a462ef1ec73067f9934
Parent: fe16d296b058333fddd5102afbebf95a18f85468
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 8 14:36:55 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 11 12:57:32 2019 -0500
vgck: fix updatemetadata writing different descriptions
vgck --updatemetadata would write the same correct
metadata to good mdas, and then to bad mdas, but the
sequence of vg_write/vg_commit calls betwen good and
bad mdas could cause a different description field to
be generated for good/bad mdas. (The description field
describing the command was recently included in the
ondisk copy of the metadata text.)
---
lib/format_text/format-text.c | 29 ++++++++++++++++++++++++++++-
lib/format_text/format-text.h | 3 +++
tools/vgck.c | 15 +++++++++++++++
3 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index be4730b..6ec47bf 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -41,8 +41,35 @@ struct text_fid_context {
char *write_buf; /* buffer containing metadata text to write to disk */
uint32_t write_buf_size; /* mem size of write_buf, increases in 64K multiples */
uint32_t new_metadata_size; /* size of text metadata in buf */
+ unsigned preserve:1;
};
+void preserve_text_fidtc(struct volume_group *vg)
+{
+ struct format_instance *fid = vg->fid;
+ struct text_fid_context *fidtc = (struct text_fid_context *)fid->private;
+
+ if (fidtc)
+ fidtc->preserve = 1;
+}
+
+void free_text_fidtc(struct volume_group *vg)
+{
+ struct format_instance *fid = vg->fid;
+ struct text_fid_context *fidtc = (struct text_fid_context *)fid->private;
+
+ if (!fidtc)
+ return;
+
+ fidtc->preserve = 0;
+
+ if (fidtc->write_buf)
+ free(fidtc->write_buf);
+ fidtc->write_buf = NULL;
+ fidtc->write_buf_size = 0;
+ fidtc->new_metadata_size = 0;
+}
+
int rlocn_is_ignored(const struct raw_locn *rlocn)
{
return (rlocn->flags & RAW_LOCN_IGNORED ? 1 : 0);
@@ -1183,7 +1210,7 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
r = 1;
out:
- if (!precommit) {
+ if (!precommit && !fidtc->preserve) {
free(fidtc->write_buf);
fidtc->write_buf = NULL;
fidtc->write_buf_size = 0;
diff --git a/lib/format_text/format-text.h b/lib/format_text/format-text.h
index 2345d52..552bfb7 100644
--- a/lib/format_text/format-text.h
+++ b/lib/format_text/format-text.h
@@ -80,4 +80,7 @@ struct data_area_list {
int text_wipe_outdated_pv_mda(struct cmd_context *cmd, struct device *dev,
struct metadata_area *mda);
+void preserve_text_fidtc(struct volume_group *vg);
+void free_text_fidtc(struct volume_group *vg);
+
#endif
diff --git a/tools/vgck.c b/tools/vgck.c
index 46ad594..4e797e7 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -14,6 +14,7 @@
*/
#include "tools.h"
+#include "lib/format_text/format-text.h"
/*
* TODO: we cannot yet repair corruption in label_header, pv_header/locations,
@@ -39,6 +40,14 @@ static int _update_metadata_single(struct cmd_context *cmd __attribute__((unused
return 0;
}
+ /*
+ * Prevent vg_commit from freeing the metadata
+ * buffer that vg_write wrote to disk so that
+ * vg_write_commit_bad_mdas() can use the same
+ * metadata buffer to write to the bad mdas.
+ */
+ preserve_text_fidtc(vg);
+
if (!vg_commit(vg)) {
log_error("Failed to commit VG.");
return 0;
@@ -53,6 +62,12 @@ static int _update_metadata_single(struct cmd_context *cmd __attribute__((unused
*/
vg_write_commit_bad_mdas(cmd, vg);
+ /*
+ * Now free the metadata buffer that was
+ * preserved above.
+ */
+ free_text_fidtc(vg);
+
return 1;
}
4 years, 7 months