master - cleanup: remove {}
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1dcba13dfcccfb...
Commit: 1dcba13dfcccfb043f49708ca8f44c4d9fa9a260
Parent: d0def236d636d2f4d9d0a08878d19a59891fa963
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 11 13:45:36 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 11 13:55:26 2013 +0200
cleanup: remove {}
---
lib/metadata/lv.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index b47b096..182eb57 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -556,9 +556,9 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[0] = (_lv_raid_image_in_sync(lv)) ? 'i' : 'I';
else if (lv->status & MIRROR_LOG)
repstr[0] = 'l';
- else if (lv_is_cow(lv)) {
+ else if (lv_is_cow(lv))
repstr[0] = (lv_is_merging_cow(lv)) ? 'S' : 's';
- } else
+ else
repstr[0] = '-';
if (lv->status & PVMOVE)
9 years, 9 months
master - cleanup: move lv assignment
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0def236d636d2...
Commit: d0def236d636d2f4d9d0a08878d19a59891fa963
Parent: f5a3bef276fe610b34b7ea6c53d332c429c31f01
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 5 13:28:26 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 11 13:55:26 2013 +0200
cleanup: move lv assignment
Use shorter lv->.
---
tools/lvresize.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/lvresize.c b/tools/lvresize.c
index ae42ce8..7b1bd50 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -386,25 +386,27 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED;
}
- if (lv_is_external_origin(lvl->lv)) {
+ lv = lvl->lv;
+
+ if (lv_is_external_origin(lv)) {
/*
* Since external-origin can be activated read-only,
* there is no way to use extended areas.
*/
- log_error("Cannot resize external origin \"%s\".", lvl->lv->name);
+ log_error("Cannot resize external origin \"%s\".", lv->name);
return EINVALID_CMD_LINE;
}
- if (lvl->lv->status & (RAID_IMAGE | RAID_META)) {
+ if (lv->status & (RAID_IMAGE | RAID_META)) {
log_error("Cannot resize a RAID %s directly",
- (lvl->lv->status & RAID_IMAGE) ? "image" :
+ (lv->status & RAID_IMAGE) ? "image" :
"metadata area");
return ECMD_FAILED;
}
- if (lv_is_raid_with_tracking(lvl->lv)) {
+ if (lv_is_raid_with_tracking(lv)) {
log_error("Cannot resize %s while it is tracking a split image",
- lvl->lv->name);
+ lv->name);
return ECMD_FAILED;
}
@@ -430,8 +432,6 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
!_validate_stripesize(cmd, vg, lp))
return EINVALID_CMD_LINE;
- lv = lvl->lv;
-
if (use_policy) {
if (!lv_is_cow(lv) &&
!lv_is_thin_pool(lv)) {
@@ -817,7 +817,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
log_print_unless_silent("%sing logical volume %s to %s",
(lp->resize == LV_REDUCE) ? "Reduc" : "Extend",
- lp->lv_name,
+ lv->name,
display_size(cmd, (uint64_t) lp->extents * vg->extent_size));
if (lp->resize == LV_REDUCE) {
@@ -848,7 +848,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
lock_lv = lv;
if (!suspend_lv(cmd, lock_lv)) {
- log_error("Failed to suspend %s", lp->lv_name);
+ log_error("Failed to suspend %s", lock_lv->name);
vg_revert(vg);
backup(vg);
return ECMD_FAILED;
@@ -863,7 +863,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
}
if (!resume_lv(cmd, lock_lv)) {
- log_error("Problem reactivating %s", lp->lv_name);
+ log_error("Problem reactivating %s", lock_lv->name);
backup(vg);
return ECMD_FAILED;
}
9 years, 9 months
master - format1: Fix snapshot reload in lv_remove.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f5a3bef276fe61...
Commit: f5a3bef276fe610b34b7ea6c53d332c429c31f01
Parent: 7d644443e0f496f1cc34a5b2a9c66e96b3160b97
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jun 10 17:31:13 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 21:01:57 2013 +0200
format1: Fix snapshot reload in lv_remove.
The special suspend/resume code in lv_remove for LVM1 snapshots was interpsersed
with a vg_commit call. However, while with LVM1 metadata, vg_commit is
technically a no-op, the activation code relied on the ondisk and incore
metadata being the same, since on LVM1, a "commit" happens in vg_write
already. Since the "ondisk" metadata was previously not available with format1
(and incore was silently used instead, via lvmcache), the problem was masked.
---
lib/metadata/lv_manip.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8f2f2ca..966b8fa 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3557,20 +3557,18 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* store it on disks */
- if (!vg_write(vg))
+ if (!vg_write(vg) || !vg_commit(vg))
return_0;
/* format1 */
- if (format1_reload_required && !suspend_lv(cmd, format1_origin))
- log_error("Failed to refresh %s without snapshot.", format1_origin->name);
+ if (format1_reload_required) {
+ if (!suspend_lv(cmd, format1_origin))
+ log_error("Failed to refresh %s without snapshot.", format1_origin->name);
- if (!vg_commit(vg))
- return_0;
-
- /* format1 */
- if (format1_reload_required && !resume_lv(cmd, format1_origin)) {
- log_error("Failed to resume %s.", format1_origin->name);
- return 0;
+ if (!resume_lv(cmd, format1_origin)) {
+ log_error("Failed to resume %s.", format1_origin->name);
+ return 0;
+ }
}
/* Release unneeded blocks in thin pool */
9 years, 9 months
master - activation: Pass both ondisk and incore LV to suspend.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7d644443e0f496...
Commit: 7d644443e0f496f1cc34a5b2a9c66e96b3160b97
Parent: 2cce2f67abf488eaed94902d415dd6f106c84229
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Mar 20 00:00:11 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 17:26:38 2013 +0200
activation: Pass both ondisk and incore LV to suspend.
---
daemons/clvmd/lvm-functions.c | 2 +-
lib/activate/activate.c | 71 +++++++++++++++++++++--------------------
lib/activate/activate.h | 2 +-
lib/locking/file_locking.c | 2 +-
lib/locking/no_locking.c | 4 +-
5 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index 99d2eb3..c7f3488 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -450,7 +450,7 @@ static int do_suspend_lv(char *resource, unsigned char command, unsigned char lo
exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
/* Always call lv_suspend to read commited and precommited data */
- if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive, NULL))
+ if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive, NULL, NULL))
return EIO;
return 0;
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 15e684a..a69b725 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1616,9 +1616,9 @@ static int _preload_detached_lv(struct cmd_context *cmd, struct logical_volume *
static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
struct lv_activate_opts *laopts, int error_if_not_suspended,
- struct logical_volume *lv)
+ struct logical_volume *ondisk_lv, struct logical_volume *incore_lv)
{
- struct logical_volume *lv_pre = NULL, *pvmove_lv = NULL, *lv_to_free = NULL;
+ struct logical_volume *pvmove_lv = NULL, *ondisk_lv_to_free = NULL, *incore_lv_to_free = NULL;
struct lv_list *lvl_pre;
struct seg_list *sl;
struct lv_segment *snap_seg;
@@ -1629,24 +1629,25 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
if (!activation())
return 1;
- if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!ondisk_lv && !(ondisk_lv_to_free = ondisk_lv = lv_from_lvid(cmd, lvid_s, 0)))
goto_out;
/* Use precommitted metadata if present */
- if (!(lv_pre = lv_from_lvid(cmd, lvid_s, 1)))
+ if (!incore_lv && !(incore_lv_to_free = incore_lv = lv_from_lvid(cmd, lvid_s, 1)))
goto_out;
/* Ignore origin_only unless LV is origin in both old and new metadata */
- if (!lv_is_thin_volume(lv) && !(lv_is_origin(lv) && lv_is_origin(lv_pre)))
+ if (!lv_is_thin_volume(ondisk_lv) && !(lv_is_origin(ondisk_lv) && lv_is_origin(incore_lv)))
laopts->origin_only = 0;
if (test_mode()) {
- _skip("Suspending %s%s.", lv->name, laopts->origin_only ? " origin without snapshots" : "");
+ _skip("Suspending %s%s.", ondisk_lv->name,
+ laopts->origin_only ? " origin without snapshots" : "");
r = 1;
goto out;
}
- if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0))
+ if (!lv_info(cmd, ondisk_lv, laopts->origin_only, &info, 0, 0))
goto_out;
if (!info.exists || info.suspended) {
@@ -1658,10 +1659,10 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
goto out;
}
- if (!lv_read_replicator_vgs(lv))
+ if (!lv_read_replicator_vgs(ondisk_lv))
goto_out;
- lv_calculate_readahead(lv, NULL);
+ lv_calculate_readahead(ondisk_lv, NULL);
/*
* Preload devices for the LV.
@@ -1670,12 +1671,12 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
* tables for all the changed LVs here, as the relationships
* are not found by walking the new metadata.
*/
- if (!(lv_pre->status & LOCKED) &&
- (lv->status & LOCKED) &&
- (pvmove_lv = find_pvmove_lv_in_lv(lv))) {
+ if (!(incore_lv->status & LOCKED) &&
+ (ondisk_lv->status & LOCKED) &&
+ (pvmove_lv = find_pvmove_lv_in_lv(ondisk_lv))) {
/* Preload all the LVs above the PVMOVE LV */
dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) {
- if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, sl->seg->lv->name))) {
+ if (!(lvl_pre = find_lv_in_vg(incore_lv->vg, sl->seg->lv->name))) {
log_error(INTERNAL_ERROR "LV %s missing from preload metadata", sl->seg->lv->name);
goto out;
}
@@ -1683,33 +1684,33 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
goto_out;
}
/* Now preload the PVMOVE LV itself */
- if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, pvmove_lv->name))) {
+ if (!(lvl_pre = find_lv_in_vg(incore_lv->vg, pvmove_lv->name))) {
log_error(INTERNAL_ERROR "LV %s missing from preload metadata", pvmove_lv->name);
goto out;
}
if (!_lv_preload(lvl_pre->lv, laopts, &flush_required))
goto_out;
} else {
- if (!_lv_preload(lv_pre, laopts, &flush_required))
+ if (!_lv_preload(incore_lv, laopts, &flush_required))
/* FIXME Revert preloading */
goto_out;
/*
* Search for existing LVs that have become detached and preload them.
*/
- detached.lv_pre = lv_pre;
+ detached.lv_pre = incore_lv;
detached.laopts = laopts;
detached.flush_required = &flush_required;
- if (!for_each_sub_lv(cmd, lv, &_preload_detached_lv, &detached))
+ if (!for_each_sub_lv(cmd, ondisk_lv, &_preload_detached_lv, &detached))
goto_out;
/*
* Preload any snapshots that are being removed.
*/
- if (!laopts->origin_only && lv_is_origin(lv)) {
- dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) {
- if (!(lvl_pre = find_lv_in_vg_by_lvid(lv_pre->vg, &snap_seg->cow->lvid))) {
+ if (!laopts->origin_only && lv_is_origin(ondisk_lv)) {
+ dm_list_iterate_items_gen(snap_seg, &ondisk_lv->snapshot_segs, origin_list) {
+ if (!(lvl_pre = find_lv_in_vg_by_lvid(incore_lv->vg, &snap_seg->cow->lvid))) {
log_error(INTERNAL_ERROR "LV %s (%s) missing from preload metadata",
snap_seg->cow->name, snap_seg->cow->lvid.id[1].uuid);
goto out;
@@ -1721,7 +1722,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
}
}
- if (!monitor_dev_for_events(cmd, lv, laopts, 0))
+ if (!monitor_dev_for_events(cmd, ondisk_lv, laopts, 0))
/* FIXME Consider aborting here */
stack;
@@ -1730,14 +1731,14 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
critical_section_inc(cmd, "suspending pvmove LV");
if (!laopts->origin_only &&
- (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
+ (lv_is_origin(incore_lv) || lv_is_cow(incore_lv)))
lockfs = 1;
/* Converting non-thin LV to thin external origin ? */
- if (!lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
+ if (!lv_is_thin_volume(ondisk_lv) && lv_is_thin_volume(incore_lv))
lockfs = 1; /* Sync before conversion */
- if (laopts->origin_only && lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
+ if (laopts->origin_only && lv_is_thin_volume(ondisk_lv) && lv_is_thin_volume(incore_lv))
lockfs = 1;
/*
@@ -1748,9 +1749,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
* inactive table to load or not instead so lv_suspend
* can be called separately for each LV safely.
*/
- if ((lv_pre->vg->status & PRECOMMITTED) &&
- (lv_pre->status & LOCKED) && find_pvmove_lv_in_lv(lv_pre)) {
- if (!_lv_suspend_lv(lv_pre, laopts, lockfs, flush_required)) {
+ if ((incore_lv->vg->status & PRECOMMITTED) &&
+ (incore_lv->status & LOCKED) && find_pvmove_lv_in_lv(incore_lv)) {
+ if (!_lv_suspend_lv(incore_lv, laopts, lockfs, flush_required)) {
critical_section_dec(cmd, "failed precommitted suspend");
if (pvmove_lv)
critical_section_dec(cmd, "failed precommitted suspend (pvmove)");
@@ -1758,7 +1759,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
}
} else {
/* Normal suspend */
- if (!_lv_suspend_lv(lv, laopts, lockfs, flush_required)) {
+ if (!_lv_suspend_lv(ondisk_lv, laopts, lockfs, flush_required)) {
critical_section_dec(cmd, "failed suspend");
if (pvmove_lv)
critical_section_dec(cmd, "failed suspend (pvmove)");
@@ -1768,11 +1769,11 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
r = 1;
out:
- if (lv_pre)
- release_vg(lv_pre->vg);
- if (lv_to_free) {
- lv_release_replicator_vgs(lv_to_free);
- release_vg(lv_to_free->vg);
+ if (incore_lv_to_free)
+ release_vg(incore_lv_to_free->vg);
+ if (ondisk_lv_to_free) {
+ lv_release_replicator_vgs(ondisk_lv_to_free);
+ release_vg(ondisk_lv_to_free->vg);
}
return r;
@@ -1784,14 +1785,14 @@ out:
*
* Returns success if the device is not active
*/
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv)
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *ondisk_lv, struct logical_volume *incore_lv)
{
struct lv_activate_opts laopts = {
.origin_only = origin_only,
.exclusive = exclusive
};
- return _lv_suspend(cmd, lvid_s, &laopts, 0, lv);
+ return _lv_suspend(cmd, lvid_s, &laopts, 0, ondisk_lv, incore_lv);
}
/* No longer used */
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 7446bec..1cbb67f 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -75,7 +75,7 @@ void activation_release(void);
void activation_exit(void);
/* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv);
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv_ondisk, struct logical_volume *lv_incore);
int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct logical_volume *lv);
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
unsigned origin_only, unsigned exclusive, unsigned revert, struct logical_volume *lv);
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 2854015..934bfe2 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -313,7 +313,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
break;
case LCK_WRITE:
log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
- if (!lv_suspend_if_active(cmd, resource, origin_only, 0, lv_ondisk(lv)))
+ if (!lv_suspend_if_active(cmd, resource, origin_only, 0, lv_ondisk(lv), lv))
return 0;
break;
case LCK_EXCL:
diff --git a/lib/locking/no_locking.c b/lib/locking/no_locking.c
index f6f76cf..b1b235c 100644
--- a/lib/locking/no_locking.c
+++ b/lib/locking/no_locking.c
@@ -46,11 +46,11 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
case LCK_NULL:
return lv_deactivate(cmd, resource, lv_ondisk(lv));
case LCK_UNLOCK:
- return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0, NULL);
+ return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0, lv_ondisk(lv));
case LCK_READ:
return lv_activate_with_filter(cmd, resource, 0, lv_ondisk(lv));
case LCK_WRITE:
- return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0, lv);
+ return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0, lv_ondisk(lv), lv);
case LCK_EXCL:
return lv_activate_with_filter(cmd, resource, 1, lv_ondisk(lv));
default:
9 years, 9 months
master - metadata: Fix a pool CRC failure due to "late" ondisk copy creation.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2cce2f67abf488...
Commit: 2cce2f67abf488eaed94902d415dd6f106c84229
Parent: df4c0bedfbe59d780b14346ce190673148c0cd98
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Mon Mar 18 15:46:00 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 17:26:38 2013 +0200
metadata: Fix a pool CRC failure due to "late" ondisk copy creation.
---
lib/metadata/metadata.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 922e82e..d25fe01 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -837,12 +837,21 @@ static int _vg_update_vg_ondisk(struct volume_group *vg)
if (vg->vg_ondisk) /* we already have it */
return 1;
+ int pool_locked = dm_pool_locked(vg->vgmem);
+ if (pool_locked && !dm_pool_unlock(vg->vgmem, 0))
+ return_0;
+
cft = export_vg_to_config_tree(vg);
if (!cft)
return 0;
vg->vg_ondisk = import_vg_from_config_tree(cft, vg->fid);
dm_config_destroy(cft);
+
+ /* recompute the pool crc */
+ if (pool_locked && !dm_pool_lock(vg->vgmem, detect_internal_vg_cache_corruption()))
+ return_0;
+
return 1;
}
9 years, 9 months
master - Actually pass LV metadata to activation code, when available.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=df4c0bedfbe59d...
Commit: df4c0bedfbe59d780b14346ce190673148c0cd98
Parent: f65dd341a5617aeffe18127ba5bd7ca5ca4d8477
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 17 21:49:00 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 17:26:38 2013 +0200
Actually pass LV metadata to activation code, when available.
This ties the two preceding changes together, actually using the "ondisk"
version of VG metadata instead of calling into lvmcache when activating
volumes. The cache hooks are still used as a fallback, because we don't have an
uncached scanning API yet.
---
lib/locking/file_locking.c | 10 +++++-----
lib/locking/no_locking.c | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 1f2468d..2854015 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -295,17 +295,17 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
switch (flags & LCK_TYPE_MASK) {
case LCK_UNLOCK:
log_very_verbose("Unlocking LV %s%s%s", resource, origin_only ? " without snapshots" : "", revert ? " (reverting)" : "");
- if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert, NULL))
+ if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert, lv_ondisk(lv)))
return 0;
break;
case LCK_NULL:
log_very_verbose("Locking LV %s (NL)", resource);
- if (!lv_deactivate(cmd, resource, NULL))
+ if (!lv_deactivate(cmd, resource, lv_ondisk(lv)))
return 0;
break;
case LCK_READ:
log_very_verbose("Locking LV %s (R)", resource);
- if (!lv_activate_with_filter(cmd, resource, 0, NULL))
+ if (!lv_activate_with_filter(cmd, resource, 0, lv_ondisk(lv)))
return 0;
break;
case LCK_PREAD:
@@ -313,12 +313,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
break;
case LCK_WRITE:
log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
- if (!lv_suspend_if_active(cmd, resource, origin_only, 0, NULL))
+ if (!lv_suspend_if_active(cmd, resource, origin_only, 0, lv_ondisk(lv)))
return 0;
break;
case LCK_EXCL:
log_very_verbose("Locking LV %s (EX)", resource);
- if (!lv_activate_with_filter(cmd, resource, 1, NULL))
+ if (!lv_activate_with_filter(cmd, resource, 1, lv_ondisk(lv)))
return 0;
break;
default:
diff --git a/lib/locking/no_locking.c b/lib/locking/no_locking.c
index 715cc10..f6f76cf 100644
--- a/lib/locking/no_locking.c
+++ b/lib/locking/no_locking.c
@@ -44,15 +44,15 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
case LCK_LV:
switch (flags & LCK_TYPE_MASK) {
case LCK_NULL:
- return lv_deactivate(cmd, resource, lv);
+ return lv_deactivate(cmd, resource, lv_ondisk(lv));
case LCK_UNLOCK:
return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0, NULL);
case LCK_READ:
- return lv_activate_with_filter(cmd, resource, 0, NULL);
+ return lv_activate_with_filter(cmd, resource, 0, lv_ondisk(lv));
case LCK_WRITE:
return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0, lv);
case LCK_EXCL:
- return lv_activate_with_filter(cmd, resource, 1, NULL);
+ return lv_activate_with_filter(cmd, resource, 1, lv_ondisk(lv));
default:
break;
}
9 years, 9 months
master - locking: Make it possible to pass down an LV to activation code.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f65dd341a5617a...
Commit: f65dd341a5617aeffe18127ba5bd7ca5ca4d8477
Parent: 5d5f2306bd4635cdc7e97a6a875384a00c9be460
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 17 21:29:58 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 17:26:38 2013 +0200
locking: Make it possible to pass down an LV to activation code.
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.
---
daemons/clvmd/lvm-functions.c | 12 +++---
lib/activate/activate.c | 79 +++++++++++++++++++++-------------------
lib/activate/activate.h | 14 ++++----
lib/locking/cluster_locking.c | 4 +-
lib/locking/external_locking.c | 2 +-
lib/locking/file_locking.c | 12 +++---
lib/locking/locking.c | 14 ++++----
lib/locking/locking.h | 16 +++++----
lib/locking/locking_types.h | 2 +-
lib/locking/no_locking.c | 16 ++++----
lib/metadata/metadata.c | 8 ++--
liblvm/lvm_vg.c | 4 +-
tools/lvconvert.c | 2 +-
tools/pvchange.c | 2 +-
tools/pvcreate.c | 2 +-
tools/pvremove.c | 2 +-
tools/pvresize.c | 2 +-
tools/pvscan.c | 4 +-
tools/toollib.c | 2 +-
tools/vgcfgrestore.c | 4 +-
tools/vgcreate.c | 2 +-
tools/vgextend.c | 2 +-
tools/vgreduce.c | 2 +-
tools/vgscan.c | 2 +-
24 files changed, 108 insertions(+), 103 deletions(-)
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index 5e83454..99d2eb3 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -356,7 +356,7 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
}
/* Does the config file want us to activate this LV ? */
- if (!lv_activation_filter(cmd, resource, &activate_lv))
+ if (!lv_activation_filter(cmd, resource, &activate_lv, NULL))
return EIO;
if (!activate_lv)
@@ -394,14 +394,14 @@ static int do_activate_lv(char *resource, unsigned char command, unsigned char l
if (lvi.suspended) {
critical_section_inc(cmd, "resuming");
- if (!lv_resume(cmd, resource, 0)) {
+ if (!lv_resume(cmd, resource, 0, NULL)) {
critical_section_dec(cmd, "resumed");
goto error;
}
}
/* Now activate it */
- if (!lv_activate(cmd, resource, exclusive))
+ if (!lv_activate(cmd, resource, exclusive, NULL))
goto error;
return 0;
@@ -427,7 +427,7 @@ static int do_resume_lv(char *resource, unsigned char command, unsigned char loc
exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
revert = (lock_flags & LCK_REVERT_MODE) ? 1 : 0;
- if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert))
+ if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert, NULL))
return EIO;
return 0;
@@ -450,7 +450,7 @@ static int do_suspend_lv(char *resource, unsigned char command, unsigned char lo
exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
/* Always call lv_suspend to read commited and precommited data */
- if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive))
+ if (!lv_suspend_if_active(cmd, resource, origin_only, exclusive, NULL))
return EIO;
return 0;
@@ -468,7 +468,7 @@ static int do_deactivate_lv(char *resource, unsigned char command, unsigned char
return 0; /* We don't need to do anything */
}
- if (!lv_deactivate(cmd, resource))
+ if (!lv_deactivate(cmd, resource, NULL))
return EIO;
if (command & LCK_CLUSTER_VG) {
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7f3d7c6..15e684a 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1615,9 +1615,10 @@ static int _preload_detached_lv(struct cmd_context *cmd, struct logical_volume *
}
static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
- struct lv_activate_opts *laopts, int error_if_not_suspended)
+ struct lv_activate_opts *laopts, int error_if_not_suspended,
+ struct logical_volume *lv)
{
- struct logical_volume *lv = NULL, *lv_pre = NULL, *pvmove_lv = NULL;
+ struct logical_volume *lv_pre = NULL, *pvmove_lv = NULL, *lv_to_free = NULL;
struct lv_list *lvl_pre;
struct seg_list *sl;
struct lv_segment *snap_seg;
@@ -1628,7 +1629,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
if (!activation())
return 1;
- if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
goto_out;
/* Use precommitted metadata if present */
@@ -1769,9 +1770,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
out:
if (lv_pre)
release_vg(lv_pre->vg);
- if (lv) {
- lv_release_replicator_vgs(lv);
- release_vg(lv->vg);
+ if (lv_to_free) {
+ lv_release_replicator_vgs(lv_to_free);
+ release_vg(lv_to_free->vg);
}
return r;
@@ -1783,14 +1784,14 @@ out:
*
* Returns success if the device is not active
*/
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive)
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv)
{
struct lv_activate_opts laopts = {
.origin_only = origin_only,
.exclusive = exclusive
};
- return _lv_suspend(cmd, lvid_s, &laopts, 0);
+ return _lv_suspend(cmd, lvid_s, &laopts, 0, lv);
}
/* No longer used */
@@ -1802,9 +1803,10 @@ int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
***********/
static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
- struct lv_activate_opts *laopts, int error_if_not_active)
+ struct lv_activate_opts *laopts, int error_if_not_active,
+ struct logical_volume *lv)
{
- struct logical_volume *lv;
+ struct logical_volume *lv_to_free = NULL;
struct lvinfo info;
int r = 0;
int messages_only = 0;
@@ -1812,7 +1814,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
if (!activation())
return 1;
- if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
goto_out;
if (lv_is_thin_pool(lv) && laopts->origin_only)
@@ -1857,8 +1859,8 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
r = 1;
out:
- if (lv)
- release_vg(lv->vg);
+ if (lv_to_free)
+ release_vg(lv_to_free->vg);
return r;
}
@@ -1875,7 +1877,7 @@ out:
*/
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
unsigned origin_only, unsigned exclusive,
- unsigned revert)
+ unsigned revert, struct logical_volume *lv)
{
struct lv_activate_opts laopts = {
.origin_only = origin_only,
@@ -1883,14 +1885,14 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
.revert = revert
};
- return _lv_resume(cmd, lvid_s, &laopts, 0);
+ return _lv_resume(cmd, lvid_s, &laopts, 0, lv);
}
-int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
+int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct logical_volume *lv)
{
struct lv_activate_opts laopts = { .origin_only = origin_only, };
- return _lv_resume(cmd, lvid_s, &laopts, 1);
+ return _lv_resume(cmd, lvid_s, &laopts, 1, lv);
}
static int _lv_has_open_snapshots(struct logical_volume *lv)
@@ -1916,16 +1918,16 @@ static int _lv_has_open_snapshots(struct logical_volume *lv)
return r;
}
-int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
+int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_volume *lv)
{
- struct logical_volume *lv;
+ struct logical_volume *lv_to_free = NULL;
struct lvinfo info;
int r = 0;
if (!activation())
return 1;
- if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
goto out;
if (test_mode()) {
@@ -1967,9 +1969,9 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists)
r = 0;
out:
- if (lv) {
- lv_release_replicator_vgs(lv);
- release_vg(lv->vg);
+ if (lv_to_free) {
+ lv_release_replicator_vgs(lv_to_free);
+ release_vg(lv_to_free->vg);
}
return r;
@@ -1977,9 +1979,9 @@ out:
/* Test if LV passes filter */
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
- int *activate_lv)
+ int *activate_lv, struct logical_volume *lv)
{
- struct logical_volume *lv;
+ struct logical_volume *lv_to_free = NULL;
int r = 0;
if (!activation()) {
@@ -1987,7 +1989,7 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
return 1;
}
- if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
goto out;
if (!_passes_activation_filter(cmd, lv)) {
@@ -1998,23 +2000,24 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
*activate_lv = 1;
r = 1;
out:
- if (lv)
- release_vg(lv->vg);
+ if (lv_to_free)
+ release_vg(lv_to_free->vg);
return r;
}
static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
- struct lv_activate_opts *laopts, int filter)
+ struct lv_activate_opts *laopts, int filter,
+ struct logical_volume *lv)
{
- struct logical_volume *lv;
+ struct logical_volume *lv_to_free = NULL;
struct lvinfo info;
int r = 0;
if (!activation())
return 1;
- if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
+ if (!lv && !(lv_to_free = lv = lv_from_lvid(cmd, lvid_s, 0)))
goto out;
if (filter && !_passes_activation_filter(cmd, lv)) {
@@ -2074,31 +2077,31 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
stack;
out:
- if (lv) {
- lv_release_replicator_vgs(lv);
- release_vg(lv->vg);
+ if (lv_to_free) {
+ lv_release_replicator_vgs(lv_to_free);
+ release_vg(lv_to_free->vg);
}
return r;
}
/* Activate LV */
-int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive)
+int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv)
{
struct lv_activate_opts laopts = { .exclusive = exclusive };
- if (!_lv_activate(cmd, lvid_s, &laopts, 0))
+ if (!_lv_activate(cmd, lvid_s, &laopts, 0, lv))
return_0;
return 1;
}
/* Activate LV only if it passes filter */
-int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive)
+int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv)
{
struct lv_activate_opts laopts = { .exclusive = exclusive };
- if (!_lv_activate(cmd, lvid_s, &laopts, 1))
+ if (!_lv_activate(cmd, lvid_s, &laopts, 1, lv))
return_0;
return 1;
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index e80115a..7446bec 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -75,14 +75,14 @@ void activation_release(void);
void activation_exit(void);
/* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive);
-int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive, struct logical_volume *lv);
+int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct logical_volume *lv);
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
- unsigned origin_only, unsigned exclusive, unsigned revert);
-int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive);
+ unsigned origin_only, unsigned exclusive, unsigned revert, struct logical_volume *lv);
+int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive, struct logical_volume *lv);
int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s,
- int exclusive);
-int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
+ int exclusive, struct logical_volume *lv);
+int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_volume *lv);
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
@@ -101,7 +101,7 @@ int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
* Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
*/
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
- int *activate_lv);
+ int *activate_lv, struct logical_volume *lv);
/*
* Checks against the auto_activation_volume_list and
* returns 1 if the LV should be activated, 0 otherwise.
diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c
index 3169f0d..1350d18 100644
--- a/lib/locking/cluster_locking.c
+++ b/lib/locking/cluster_locking.c
@@ -403,9 +403,9 @@ static int _lock_for_cluster(struct cmd_context *cmd, unsigned char clvmd_cmd,
/* API entry point for LVM */
#ifdef CLUSTER_LOCKING_INTERNAL
static int _lock_resource(struct cmd_context *cmd, const char *resource,
- uint32_t flags)
+ uint32_t flags, struct logical_volume *lv __attribute__((unused)))
#else
-int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
+ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags, struct logical_volume *lv __attribute__((unused)))
#endif
{
char lockname[PATH_MAX];
diff --git a/lib/locking/external_locking.c b/lib/locking/external_locking.c
index 1076174..d5c39d7 100644
--- a/lib/locking/external_locking.c
+++ b/lib/locking/external_locking.c
@@ -31,7 +31,7 @@ static int (*_init_fn) (int type, struct dm_config_tree * cft,
static int (*_lock_query_fn) (const char *resource, int *mode) = NULL;
static int _lock_resource(struct cmd_context *cmd, const char *resource,
- uint32_t flags)
+ uint32_t flags, struct logical_volume *lv __attribute__((unused)))
{
if (!_lock_fn)
return 0;
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 4711fa2..1f2468d 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -254,7 +254,7 @@ static int _lock_file(const char *file, uint32_t flags)
}
static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
- uint32_t flags)
+ uint32_t flags, struct logical_volume *lv)
{
char lockfile[PATH_MAX];
unsigned origin_only = (flags & LCK_ORIGIN_ONLY) ? 1 : 0;
@@ -295,17 +295,17 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
switch (flags & LCK_TYPE_MASK) {
case LCK_UNLOCK:
log_very_verbose("Unlocking LV %s%s%s", resource, origin_only ? " without snapshots" : "", revert ? " (reverting)" : "");
- if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert))
+ if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert, NULL))
return 0;
break;
case LCK_NULL:
log_very_verbose("Locking LV %s (NL)", resource);
- if (!lv_deactivate(cmd, resource))
+ if (!lv_deactivate(cmd, resource, NULL))
return 0;
break;
case LCK_READ:
log_very_verbose("Locking LV %s (R)", resource);
- if (!lv_activate_with_filter(cmd, resource, 0))
+ if (!lv_activate_with_filter(cmd, resource, 0, NULL))
return 0;
break;
case LCK_PREAD:
@@ -313,12 +313,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
break;
case LCK_WRITE:
log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
- if (!lv_suspend_if_active(cmd, resource, origin_only, 0))
+ if (!lv_suspend_if_active(cmd, resource, origin_only, 0, NULL))
return 0;
break;
case LCK_EXCL:
log_very_verbose("Locking LV %s (EX)", resource);
- if (!lv_activate_with_filter(cmd, resource, 1))
+ if (!lv_activate_with_filter(cmd, resource, 1, NULL))
return 0;
break;
default:
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 63f946f..044570f 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -352,7 +352,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
* FIXME This should become VG uuid.
*/
static int _lock_vol(struct cmd_context *cmd, const char *resource,
- uint32_t flags, lv_operation_t lv_op)
+ uint32_t flags, lv_operation_t lv_op, struct logical_volume *lv)
{
uint32_t lck_type = flags & LCK_TYPE_MASK;
uint32_t lck_scope = flags & LCK_SCOPE_MASK;
@@ -379,7 +379,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
return 0;
}
- if ((ret = _locking.lock_resource(cmd, resource, flags))) {
+ if ((ret = _locking.lock_resource(cmd, resource, flags, lv))) {
if (lck_scope == LCK_VG && !(flags & LCK_CACHE)) {
if (lck_type != LCK_UNLOCK)
lvmcache_lock_vgname(resource, lck_type == LCK_READ);
@@ -403,7 +403,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
return ret;
}
-int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
+int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, struct logical_volume *lv)
{
char resource[258] __attribute__((aligned(8)));
lv_operation_t lv_op;
@@ -457,7 +457,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
strncpy(resource, vol, sizeof(resource) - 1);
resource[sizeof(resource) - 1] = '\0';
- if (!_lock_vol(cmd, resource, flags, lv_op))
+ if (!_lock_vol(cmd, resource, flags, lv_op, lv))
return_0;
/*
@@ -468,7 +468,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
(flags & (LCK_CACHE | LCK_HOLD)))
return 1;
- if (!_lock_vol(cmd, resource, (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op))
+ if (!_lock_vol(cmd, resource, (flags & ~LCK_TYPE_MASK) | LCK_UNLOCK, lv_op, lv))
return_0;
return 1;
@@ -626,12 +626,12 @@ int sync_local_dev_names(struct cmd_context* cmd)
{
memlock_unlock(cmd);
- return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC_LOCAL);
+ return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC_LOCAL, NULL);
}
int sync_dev_names(struct cmd_context* cmd)
{
memlock_unlock(cmd);
- return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC);
+ return lock_vol(cmd, VG_SYNC_NAMES, LCK_VG_SYNC, NULL);
}
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 23c312d..aa42138 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -19,6 +19,8 @@
#include "uuid.h"
#include "config.h"
+struct logical_volume;
+
int init_locking(int type, struct cmd_context *cmd, int suppress_messages);
void fin_locking(void);
void reset_locking(void);
@@ -46,7 +48,7 @@ int remote_lock_held(const char *vol, int *exclusive);
* Lock/unlock an individual logical volume
* char *vol holds lvid
*/
-int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags);
+int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, struct logical_volume *lv);
/*
* Internal locking representation.
@@ -156,14 +158,14 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define lock_lv_vol(cmd, lv, flags) \
(find_replicator_vgs((lv)) ? \
- lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv)) : \
+ lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv), lv) : \
0)
#define unlock_vg(cmd, vol) \
do { \
if (is_real_vg(vol)) \
sync_dev_names(cmd); \
- (void) lock_vol(cmd, vol, LCK_VG_UNLOCK); \
+ (void) lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL); \
} while (0)
#define unlock_and_release_vg(cmd, vg, vol) \
do { \
@@ -192,13 +194,13 @@ int activate_lv_excl(struct cmd_context *cmd, struct logical_volume *lv);
#define deactivate_lv_local(cmd, lv) \
lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE | LCK_LOCAL)
#define drop_cached_metadata(vg) \
- lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE)
+ lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE, NULL)
#define remote_commit_cached_metadata(vg) \
- lock_vol((vg)->cmd, (vg)->name, LCK_VG_COMMIT)
+ lock_vol((vg)->cmd, (vg)->name, LCK_VG_COMMIT, NULL)
#define remote_revert_cached_metadata(vg) \
- lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT)
+ lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT, NULL)
#define remote_backup_metadata(vg) \
- lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP)
+ lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP, NULL)
int sync_local_dev_names(struct cmd_context* cmd);
int sync_dev_names(struct cmd_context* cmd);
diff --git a/lib/locking/locking_types.h b/lib/locking/locking_types.h
index 53c7016..3009490 100644
--- a/lib/locking/locking_types.h
+++ b/lib/locking/locking_types.h
@@ -17,7 +17,7 @@
#include "config.h"
typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
- uint32_t flags);
+ uint32_t flags, struct logical_volume *lv);
typedef int (*query_resource_fn) (const char *resource, int *mode);
typedef void (*fin_lock_fn) (void);
diff --git a/lib/locking/no_locking.c b/lib/locking/no_locking.c
index 53a5948..715cc10 100644
--- a/lib/locking/no_locking.c
+++ b/lib/locking/no_locking.c
@@ -34,7 +34,7 @@ static void _no_reset_locking(void)
}
static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
- uint32_t flags)
+ uint32_t flags, struct logical_volume *lv)
{
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
@@ -44,15 +44,15 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
case LCK_LV:
switch (flags & LCK_TYPE_MASK) {
case LCK_NULL:
- return lv_deactivate(cmd, resource);
+ return lv_deactivate(cmd, resource, lv);
case LCK_UNLOCK:
- return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0);
+ return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0, NULL);
case LCK_READ:
- return lv_activate_with_filter(cmd, resource, 0);
+ return lv_activate_with_filter(cmd, resource, 0, NULL);
case LCK_WRITE:
- return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0);
+ return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0, lv);
case LCK_EXCL:
- return lv_activate_with_filter(cmd, resource, 1);
+ return lv_activate_with_filter(cmd, resource, 1, NULL);
default:
break;
}
@@ -68,7 +68,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
static int _readonly_lock_resource(struct cmd_context *cmd,
const char *resource,
- uint32_t flags)
+ uint32_t flags, struct logical_volume *lv)
{
if ((flags & LCK_TYPE_MASK) == LCK_WRITE &&
(flags & LCK_SCOPE_MASK) == LCK_VG &&
@@ -79,7 +79,7 @@ static int _readonly_lock_resource(struct cmd_context *cmd,
return 0;
}
- return _no_lock_resource(cmd, resource, flags);
+ return _no_lock_resource(cmd, resource, flags, lv);
}
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute__((unused)),
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 6cee8d5..922e82e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -562,7 +562,7 @@ int vg_remove(struct volume_group *vg)
struct pv_list *pvl;
int ret = 1;
- if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return 0;
}
@@ -3971,7 +3971,7 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd,
dev_close_all();
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE))
+ if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL))
return_NULL;
if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent)))
@@ -4018,7 +4018,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
already_locked = lvmcache_vgname_is_locked(vg_name);
if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
- !lock_vol(cmd, vg_name, lock_flags)) {
+ !lock_vol(cmd, vg_name, lock_flags, NULL)) {
log_error("Can't get lock for %s", vg_name);
return _vg_make_handle(cmd, vg, FAILED_LOCKING);
}
@@ -4173,7 +4173,7 @@ uint32_t vg_read_error(struct volume_group *vg_handle)
*/
uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
{
- if (!lock_vol(cmd, vgname, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, vgname, LCK_VG_WRITE, NULL)) {
return FAILED_LOCKING;
}
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index 405a91a..b090b84 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -73,7 +73,7 @@ int lvm_vg_extend(vg_t vg, const char *device)
if (!vg_check_write_mode(vg))
return -1;
- if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return -1;
}
@@ -131,7 +131,7 @@ int lvm_vg_write(vg_t vg)
}
if (! dm_list_empty(&vg->removed_pvs)) {
- if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return 0;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 718f49c..46f996a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2503,7 +2503,7 @@ static int lvconvert_merge_single(struct cmd_context *cmd, struct logical_volume
lp->wait_completion);
/* use LCK_VG_WRITE to match lvconvert()'s READ_FOR_UPDATE */
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
log_error("ABORTING: Can't relock VG for %s "
"after polling finished", vg_name);
ret = ECMD_FAILED;
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 1458e92..d2a3d9b 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -219,7 +219,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
* take the lock here, pvs with 0 mdas in a non-orphan VG will
* be processed twice.
*/
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 91562d2..d3703b4 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -108,7 +108,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
}
for (i = 0; i < argc; i++) {
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return ECMD_FAILED;
}
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 823c069..cbbf6e2 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -101,7 +101,7 @@ static int pvremove_single(struct cmd_context *cmd, const char *pv_name,
struct device *dev;
int ret = ECMD_FAILED;
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return ECMD_FAILED;
}
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 2f0693a..26959e8 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -38,7 +38,7 @@ static int _pv_resize_single(struct cmd_context *cmd,
int vg_needs_pv_write = 0;
if (is_orphan_vg(vg_name)) {
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphans");
return 0;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 7c55faa..12b9a2d 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -170,7 +170,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
@@ -288,7 +288,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 6e004f3..b238a61 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -712,7 +712,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
dm_list_init(&tags);
- if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
+ if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index 20ca16b..618fa7e 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -47,12 +47,12 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
lvmcache_seed_infos_from_lvmetad(cmd);
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
log_error("Unable to lock volume group %s", vg_name);
return ECMD_FAILED;
}
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Unable to lock orphans");
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 8ce7803..9be9416 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -70,7 +70,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
!vg_set_mda_copies(vg, vp_new.vgmetadatacopies))
goto bad_orphan;
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
goto bad_orphan;
}
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 93d55a0..1f482b4 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -95,7 +95,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
goto bad;
}
} else { /* no --restore, normal vgextend */
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
unlock_and_release_vg(cmd, vg, vg_name);
return ECMD_FAILED;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index c068b26..8803899 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -146,7 +146,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED;
}
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return ECMD_FAILED;
}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index 99124ef..baf25b0 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -37,7 +37,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
9 years, 9 months
master - Add and track an "ondisk" pointer to struct volume_group.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5d5f2306bd4635...
Commit: 5d5f2306bd4635cdc7e97a6a875384a00c9be460
Parent: c1e851e2084cbb09ed28199bc332aa3b1e99bbae
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 17 16:27:44 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 17:26:29 2013 +0200
Add and track an "ondisk" pointer to struct volume_group.
This allows us to get the current on-disk version of the metadata whenever we
have the current in-flight version, without a recourse to scanning or lvmcache.
---
lib/metadata/lv.h | 1 +
lib/metadata/metadata.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
lib/metadata/vg.c | 1 +
lib/metadata/vg.h | 9 +++++++++
4 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 8e771a1..b1cce51 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -90,4 +90,5 @@ int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
enum activation_change activate);
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv);
const struct logical_volume *lv_lock_holder(const struct logical_volume *lv);
+struct logical_volume *lv_ondisk(struct logical_volume *lv);
#endif /* _LVM_LV_H */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 62b5c3f..6cee8d5 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -831,6 +831,21 @@ int vgcreate_params_validate(struct cmd_context *cmd,
return 1;
}
+static int _vg_update_vg_ondisk(struct volume_group *vg)
+{
+ struct dm_config_tree *cft;
+ if (vg->vg_ondisk) /* we already have it */
+ return 1;
+
+ cft = export_vg_to_config_tree(vg);
+ if (!cft)
+ return 0;
+
+ vg->vg_ondisk = import_vg_from_config_tree(cft, vg->fid);
+ dm_config_destroy(cft);
+ return 1;
+}
+
/*
* Create a (struct volume_group) volume group handle from a struct volume_group pointer and a
* possible failure code or zero for success.
@@ -839,6 +854,7 @@ static struct volume_group *_vg_make_handle(struct cmd_context *cmd,
struct volume_group *vg,
uint32_t failure)
{
+
/* Never return a cached VG structure for a failure */
if (vg && vg->vginfo && failure != SUCCESS) {
release_vg(vg);
@@ -848,6 +864,9 @@ static struct volume_group *_vg_make_handle(struct cmd_context *cmd,
if (!vg && !(vg = alloc_vg("vg_make_handle", cmd, NULL)))
return_NULL;
+ if (vg->fid && !_vg_update_vg_ondisk(vg))
+ vg->read_status |= FAILED_ALLOCATION;
+
if (vg->read_status != failure)
vg->read_status = failure;
@@ -2690,6 +2709,12 @@ int vg_commit(struct volume_group *vg)
* The volume_group structure could be reused later.
*/
vg->old_name = NULL;
+
+ /* This *is* the original now that it's commited. */
+ release_vg(vg->vg_ondisk);
+ vg->vg_ondisk = NULL;
+ if (!_vg_update_vg_ondisk(vg)) /* make a new one for future edits */
+ return_0;
}
/* If update failed, remove any cached precommitted metadata. */
@@ -4523,3 +4548,25 @@ char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tags)
}
return dm_pool_end_object(mem);
}
+
+struct logical_volume *lv_ondisk(struct logical_volume *lv)
+{
+ struct volume_group *vg;
+ struct lv_list *lvl;
+
+ if (!lv)
+ return NULL;
+
+ vg = lv->vg;
+
+ if (vg->vg_ondisk)
+ vg = vg->vg_ondisk;
+
+ dm_list_iterate_items(lvl, &vg->lvs)
+ if (!strncmp(lvl->lv->lvid.s, lv->lvid.s, sizeof(lv->lvid)))
+ return lvl->lv;
+
+ log_error(INTERNAL_ERROR "LV %s/%s (UUID %s) not found in ondisk metadata.",
+ lv->vg->name, lv->name, lv->lvid.s);
+ return NULL;
+}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index a868df7..50e8328 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -87,6 +87,7 @@ void release_vg(struct volume_group *vg)
!lvmcache_vginfo_holders_dec_and_test_for_zero(vg->vginfo))
return;
+ release_vg(vg->vg_ondisk);
_free_vg(vg);
}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index f876968..0dc3ba7 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -48,6 +48,15 @@ struct volume_group {
uint32_t cmd_missing_vgs;/* Flag marks missing VG */
uint32_t seqno; /* Metadata sequence number */
+ /*
+ * The parsed on-disk copy of this VG; is NULL if this is the on-disk
+ * version (i.e. vg_ondisk == NULL *implies* this is the on-disk copy,
+ * there is no guarantee that if this VG is the same as the on-disk one
+ * this will be NULL). The pointer is maintained by calls to
+ * _vg_update_vg_ondisk.
+ */
+ struct volume_group *vg_ondisk;
+
alloc_policy_t alloc;
uint64_t status;
9 years, 9 months
master - Move export_vg_to_config_tree alongside export_vg_to_buffer.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1e851e2084cbb...
Commit: c1e851e2084cbb09ed28199bc332aa3b1e99bbae
Parent: c3b06ff55de5288a2ac4e351176c00404bc5a0fc
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 17 16:25:12 2013 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jun 10 15:55:55 2013 +0200
Move export_vg_to_config_tree alongside export_vg_to_buffer.
---
lib/cache/lvmetad.c | 24 ++----------------------
lib/format_text/export.c | 20 ++++++++++++++++++++
lib/metadata/metadata.h | 2 +-
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 7aa8641..6c8b10b 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -425,26 +425,6 @@ static int _fixup_ignored(struct metadata_area *mda, void *baton) {
return 1;
}
-static struct dm_config_tree *_export_vg_to_config_tree(struct volume_group *vg)
-{
- char *buf = NULL;
- struct dm_config_tree *vgmeta;
-
- if (!export_vg_to_buffer(vg, &buf)) {
- log_error("Could not format VG metadata.");
- return 0;
- }
-
- if (!(vgmeta = dm_config_from_string(buf))) {
- log_error("Error parsing VG metadata.");
- dm_free(buf);
- return 0;
- }
-
- dm_free(buf);
- return vgmeta;
-}
-
int lvmetad_vg_update(struct volume_group *vg)
{
daemon_reply reply;
@@ -462,7 +442,7 @@ int lvmetad_vg_update(struct volume_group *vg)
if (!lvmetad_active() || test_mode())
return 1; /* fake it */
- if (!(vgmeta = _export_vg_to_config_tree(vg)))
+ if (!(vgmeta = export_vg_to_config_tree(vg)))
return_0;
log_debug_lvmetad("Sending lvmetad updated metadata for VG %s (seqno %" PRIu32 ")", vg->name, vg->seqno);
@@ -772,7 +752,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
_extract_mdas(info, pvmeta, pvmeta->root);
if (vg) {
- if (!(vgmeta = _export_vg_to_config_tree(vg))) {
+ if (!(vgmeta = export_vg_to_config_tree(vg))) {
dm_config_destroy(pvmeta);
return_0;
}
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 73b5a3a..b6aac45 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -841,5 +841,25 @@ size_t export_vg_to_buffer(struct volume_group *vg, char **buf)
return text_vg_export_raw(vg, "", buf);
}
+struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg)
+{
+ char *buf = NULL;
+ struct dm_config_tree *vg_cft;
+
+ if (!export_vg_to_buffer(vg, &buf)) {
+ log_error("Could not format metadata for VG %s.", vg->name);
+ return_NULL;
+ }
+
+ if (!(vg_cft = dm_config_from_string(buf))) {
+ log_error("Error parsing metadata for VG %s.", vg->name);
+ dm_free(buf);
+ return_NULL;
+ }
+
+ dm_free(buf);
+ return vg_cft;
+}
+
#undef outf
#undef outnl
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 4f504ed..bf9bd55 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -437,7 +437,7 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea
* For internal metadata caching.
*/
size_t export_vg_to_buffer(struct volume_group *vg, char **buf);
-int export_vg_to_config_tree(struct volume_group *vg, struct dm_config_tree **cft);
+struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
struct volume_group *import_vg_from_buffer(const char *buf,
struct format_instance *fid);
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
9 years, 9 months