main - lvpoll: improve merge polling
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=eadd58a97dd9a199b74260e8a2bdb5657bf7a88d Commit: eadd58a97dd9a199b74260e8a2bdb5657bf7a88d Parent: 1a451207b8ddbd15519ff9556c59287023ab50fa Author: Zdenek Kabelac <[email protected]> AuthorDate: Sun Mar 14 22:03:41 2021 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Mar 15 11:13:24 2021 +0100
lvpoll: improve merge polling
When multiple polling tasks are watching for same LV, clearly when some of them wins the game - other polling tasks will fail. Improve the logic and report success if the merged LV is actually not a merging origin anymore (since likely someone else has already finished merging).
--- tools/lvconvert_poll.c | 11 +++++++---- tools/polldaemon.c | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-)
tools/lvconvert_poll.c +7 -4
@@ -111,9 +111,9 @@ int lvconvert_merge_finish(struct cmd_context *cmd,struct lv_segment *snap_seg =find_snapshot (lv);if (!lv_is_merging_origin (lv)) { -log_error ("Logical volume %s has no merging snapshot." , +log_print ("Logical volume %s is no longer merging origin, polling has finished." ,display_lvname (lv)); -return 0 ; +return 1 ; } log_print_unless_silent("Merge of snapshot into logical volume %s has finished.",
@@ -141,8 +141,11 @@ progress_t poll_merge_progress(struct cmd_context *cmd, {dm_percent_t percent =DM_PERCENT_0 ; -if (!lv_is_merging_origin (lv) || - !lv_snapshot_percent (lv, &percent)) { +if (!lv_is_merging_origin (lv)) +/* Nothing to monitor here */ +return PROGRESS_FINISHED_ALL ; + +if (!lv_snapshot_percent (lv, &percent)) {log_error ("%s: Failed query for merging percentage. Aborting merge." ,display_lvname (lv));return PROGRESS_CHECK_FAILED ;
tools/polldaemon.c +7 -2
@@ -172,8 +172,13 @@ int wait_for_single_lv(struct cmd_context *cmd, struct poll_operation_id *id, vg =vg_read (cmd, id->vg_name,NULL ,READ_FOR_UPDATE , lockd_state, &error_flags,NULL );if (!vg) {/* What more could we do here? */ -log_error ("ABORTING: Can't reread VG for %s error flags %x." , id->display_name, error_flags); - ret =0 ; +if (error_flags &FAILED_NOTFOUND ) { +log_print_unless_silent ("Can't find VG %s. No longer active." , id->display_name); + ret =1 ; + }else { +log_error ("ABORTING: Can't reread VG for %s error flags %x." , id->display_name, error_flags); + ret =0 ; + } goto out; }