summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2019-02-05 14:02:24 -0600
committerDavid Teigland <teigland@redhat.com>2019-04-11 12:03:04 -0500
commit21f7dfe5105a8377ec6a8ff1a9535802f127ec85 (patch)
treea2e2437028c81683d49a1d1fd7dd06b1bab66161
parentda39cf4a9e5661d7dcec3c7fa9d1bd88ce08608c (diff)
downloadlvm2-21f7dfe5105a8377ec6a8ff1a9535802f127ec85.tar.gz
fix vg_commit return value
The existing comment was desribing the correct behavior, but the code didn't match. The commit is successful if one mda was committed. Making it depend on the result of the internal lvmcache update was wrong.
-rw-r--r--lib/metadata/metadata.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 865f0d1c2..f1e0e8072 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3072,6 +3072,7 @@ static int _vg_commit_mdas(struct volume_group *vg)
struct metadata_area *mda, *tmda;
struct dm_list ignored;
int failed = 0;
+ int good = 0;
int cache_updated = 0;
/* Rearrange the metadata_areas_in_use so ignored mdas come first. */
@@ -3092,27 +3093,31 @@ static int _vg_commit_mdas(struct volume_group *vg)
!mda->ops->vg_commit(vg->fid, vg, mda)) {
stack;
failed = 1;
- }
+ } else
+ good++;
+
/* Update cache first time we succeed */
if (!failed && !cache_updated) {
lvmcache_update_vg(vg, 0);
cache_updated = 1;
}
}
- return cache_updated;
+ if (good)
+ return 1;
+ return 0;
}
/* Commit pending changes */
int vg_commit(struct volume_group *vg)
{
- int cache_updated = 0;
struct pv_list *pvl;
+ int ret;
- cache_updated = _vg_commit_mdas(vg);
+ ret = _vg_commit_mdas(vg);
set_vg_notify(vg->cmd);
- if (cache_updated) {
+ if (ret) {
/*
* We need to clear old_name after a successful commit.
* The volume_group structure could be reused later.
@@ -3126,7 +3131,7 @@ int vg_commit(struct volume_group *vg)
}
/* If at least one mda commit succeeded, it was committed */
- return cache_updated;
+ return ret;
}
/* Don't commit any pending changes */