master - lv_update_and_reload: replace code sequence
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a3b75d7a8a3caa832af3b7d1f7d3fa488901ae06 Commit: a3b75d7a8a3caa832af3b7d1f7d3fa488901ae06 Parent: ca2ea5f984207ca9ff8a48bcbb84ca0fc3ee6e72 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Sep 9 14:40:32 2014 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Sep 10 21:57:38 2014 +0200
lv_update_and_reload: replace code sequence
Use lv_update_and_reload() and lv_update_and_reload_origin() to handle write/suspend/commit/resume sequence.
In few places this properly handle vg_revert() after suspend failure, and also ensures there is metadata backup after successful vg_commit().
--- lib/metadata/cache_manip.c | 27 ++------ lib/metadata/lv_manip.c | 35 ++------- lib/metadata/raid_manip.c | 173 ++++---------------------------------------- tools/lvchange.c | 120 ++---------------------------- 4 files changed, 34 insertions(+), 321 deletions(-)
lib/metadata/cache_manip.c +6 -21
@@ -175,7 +175,6 @@ static int _cleanup_orphan_lv(struct logical_volume *lv)*/ int lv_cache_remove (struct logical_volume *cache_lv) { -struct cmd_context *cmd = cache_lv->vg->cmd;const char *policy_name;uint64_t dirty_blocks;struct lv_segment *cache_seg =first_seg (cache_lv);
@@ -225,14 +224,8 @@ int lv_cache_remove(struct logical_volume *cache_lv) cache_seg->policy_argv =NULL ;/* update the kernel to put the cleaner policy in place */ -if (!vg_write (cache_lv->vg)) - return_0; -if (!suspend_lv (cmd, cache_lv)) - return_0; -if (!vg_commit (cache_lv->vg)) - return_0; -if (!resume_lv (cmd, cache_lv)) - return_0; +if (lv_update_and_reload (cache_lv)) + return_0; }//FIXME: use polling to do this...
@@ -256,7 +249,7 @@ int lv_cache_remove(struct logical_volume *cache_lv)if (!remove_layer_from_lv (cache_lv, corigin_lv)) return_0; -if (!vg_write (cache_lv->vg)) +if (!lv_update_and_reload (cache_lv)) return_0;/*
@@ -264,20 +257,12 @@ int lv_cache_remove(struct logical_volume *cache_lv)* - the top-level cache LV * - the origin * - the cache_pool _cdata and _cmeta -*/ -if (!suspend_lv (cmd, cache_lv)) - return_0; - -if (!vg_commit (cache_lv->vg)) - return_0; - -/* resume_lv on this (former) cache LV will resume all */ -/* +* +* resume_lv on this (former) cache LV will resume all +* * FIXME: currently we can't easily avoid execution of * blkid on resumed error device */ -if (!resume_lv (cmd, cache_lv)) - return_0;/* * cleanup orphan devices
lib/metadata/lv_manip.c +7 -28
@@ -5043,26 +5043,8 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv, }/* store vg on disk(s) */ -if (!vg_write (vg)) - goto_out; - -if (!suspend_lv (cmd, lock_lv)) { -log_error ("Failed to suspend %s" , lock_lv->name); -vg_revert (vg); - goto bad; - } - -if (!vg_commit (vg)) { - stack; -if (!resume_lv (cmd, lock_lv)) - stack; - goto bad; - } - -if (!resume_lv (cmd, lock_lv)) { -log_error ("Problem reactivating %s" , lock_lv->name); - goto bad; - } +if (!lv_update_and_reload (lock_lv)) + goto_bad;if (lv_is_cow_covering_origin (lv))if (!monitor_dev_for_events (cmd, lv,0 ,0 ))
@@ -5073,15 +5055,14 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,if (!update_pool_lv (lock_lv,0 )) goto_bad; +backup (vg); +if (inactive && !deactivate_lv (cmd, lock_lv)) {log_error ("Problem deactivating %s." , lock_lv->name); -backup (vg);return 0 ; } } -backup (vg); -log_print_unless_silent ("Logical volume %s successfully resized" , lp->lv_name); if (lp->resizefs && (lp->resize == LV_EXTEND) &&
@@ -5089,10 +5070,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv, return_0;return 1 ; - bad: -backup (vg); -out:if (inactive && !deactivate_lv (cmd, lock_lv))log_error ("Problem deactivating %s." , lock_lv->name);
@@ -6955,9 +6933,10 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,* I say that would be cleaner, but I'm not sure * about the effects on thinpool yet... */ -if (!vg_write (vg) || !suspend_lv (cmd, lv) || - !vg_commit (vg) || !resume_lv (cmd, lv)) +if (!lv_update_and_reload (lv)) { + stack; goto deactivate_and_revert_new_lv; + }if (!(lvl =find_lv_in_vg (vg, lp->origin))) goto deactivate_and_revert_new_lv;
lib/metadata/raid_manip.c +13 -160
231 lines not on this page · raw message
tools/lvchange.c +8 -112
175 lines not on this page · raw message