stable-2.02 - pvscan: fix activation of incomplete VGs
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6b12930860a993624d6325aec2e9c561f4412aa9 Commit: 6b12930860a993624d6325aec2e9c561f4412aa9 Parent: 402b41f58dc14160ec21937d6308b0d9a1abba7d Author: David Teigland <[email protected]> AuthorDate: Tue Sep 3 15:14:08 2019 -0500 Committer: David Teigland <[email protected]> CommitterDate: Tue Sep 3 15:53:07 2019 -0500
pvscan: fix activation of incomplete VGs
For a long time there has been a bug in the activation done by the initial pvscan (which scans all devs to initialize the lvmetad cache.) It was attempting to activate all VGs, even those that were not complete.
lvmetad tells pvscan when a VG is complete, and pvscan needs to use this information to decide which VGs to activate.
When there are problems that prevent lvmetad from being used (e.g. lvmetad is disabled or not running), pvscan activation cannot use lvmetad to determine when a VG is complete, so it now checks if devices are present for all PVs in the VG before activating.
(The recent commit "pvscan: avoid redundant activation" could make this bug more apparent because redundant activations can cover up the effect of activating an incomplete VG and missing some LV activations.)
--- lib/cache/lvmetad.c | 15 ++++++++--- lib/cache/lvmetad.h | 2 +- tools/lvmcmdline.c | 2 +- tools/lvscan.c | 2 +- tools/pvscan.c | 65 ++++++++++++++++++++++++++++++++++++++++++++---- tools/vgcfgrestore.c | 2 +- tools/vgimport.c | 2 +- tools/vgimportclone.c | 2 +- tools/vgscan.c | 2 +- 9 files changed, 77 insertions(+), 17 deletions(-)
lib/cache/lvmetad.c +11 -4
@@ -1702,6 +1702,13 @@ int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct devi changed =daemon_reply_int (reply,"changed" ,0 ); } +if (vg && vg->system_id && vg->system_id[0 ] && + cmd->system_id && cmd->system_id[0 ] && +strcmp (vg->system_id, cmd->system_id)) { +log_debug_lvmetad ("Ignore foreign VG %s on %s" , vg->name ,dev_name (dev)); + goto out; + } +/* * If lvmetad now sees all PVs in the VG, it returned the * "complete" status string. Add this VG name to the list
@@ -1732,7 +1739,7 @@ int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct devilog_error ("str_list_add failed" ); } } - +out:daemon_reply_destroy (reply);return result;
@@ -2333,7 +2340,7 @@ bad:* generally revert disk scanning and not use lvmetad. */ -int lvmetad_pvscan_all_devs (struct cmd_context *cmd,int do_wait) +int lvmetad_pvscan_all_devs (struct cmd_context *cmd,int do_wait,struct dm_list *found_vgnames) {struct device_list *devl, *devl2;struct dm_list scan_devs;
@@ -2415,7 +2422,7 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)dm_list_del (&devl->list); - ret =lvmetad_pvscan_single (cmd, devl->dev,NULL ,NULL ); + ret =lvmetad_pvscan_single (cmd, devl->dev, found_vgnames,NULL );label_scan_invalidate (devl->dev);
@@ -2758,7 +2765,7 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)* we rescanned for the token, and the time we acquired the global * lock.) */ -if (!lvmetad_pvscan_all_devs (cmd,1 )) { +if (!lvmetad_pvscan_all_devs (cmd,1 ,NULL )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_make_unused (cmd);return ;
lib/cache/lvmetad.h +1 -1
@@ -151,7 +151,7 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,struct dm_list *found_vgnames, struct dm_list *changed_vgnames); -int lvmetad_pvscan_all_devs (struct cmd_context *cmd,int do_wait); +int lvmetad_pvscan_all_devs (struct cmd_context *cmd,int do_wait,struct dm_list *found_vgnames);int lvmetad_vg_clear_outdated_pvs (struct volume_group *vg);void lvmetad_validate_global_cache (struct cmd_context *cmd,int force);
tools/lvmcmdline.c +1 -1
@@ -2980,7 +2980,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)*/ if (lvmetad_used () && !_cmd_no_lvmetad_autoscan (cmd)) {if (cmd->include_foreign_vgs || !lvmetad_token_matches (cmd)) { -if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd, cmd->include_foreign_vgs ?1 :0 )) { +if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd, cmd->include_foreign_vgs ?1 :0 ,NULL )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_make_unused (cmd); }
tools/lvscan.c +1 -1
@@ -103,7 +103,7 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)/* Needed because this command has NO_LVMETAD_AUTOSCAN. */ if (lvmetad_used () && (!lvmetad_token_matches (cmd) ||lvmetad_is_disabled (cmd, &reason))) { -if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd,0 )) { +if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd,0 ,NULL )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_make_unused (cmd); }
tools/pvscan.c +59 -6
129 lines not on this page · raw message
tools/vgcfgrestore.c +1 -1
@@ -177,7 +177,7 @@ rescan: }if (!refresh_filters (cmd)) stack; -if (!lvmetad_pvscan_all_devs (cmd,1 )) { +if (!lvmetad_pvscan_all_devs (cmd,1 ,NULL )) {log_warn ("WARNING: Failed to scan devices." );log_warn ("WARNING: Update lvmetad with pvscan --cache." ); goto out;
tools/vgimport.c +1 -1
@@ -96,7 +96,7 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)* import it. */ if (lvmetad_used ()) { -if (!lvmetad_pvscan_all_devs (cmd,1 )) { +if (!lvmetad_pvscan_all_devs (cmd,1 ,NULL )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_make_unused (cmd); }
tools/vgimportclone.c +1 -1
@@ -377,7 +377,7 @@ out:if (!refresh_filters (cmd)) stack; -if (!lvmetad_pvscan_all_devs (cmd,1 )) { +if (!lvmetad_pvscan_all_devs (cmd,1 ,NULL )) {log_warn ("WARNING: Failed to scan devices." );log_warn ("WARNING: Update lvmetad with pvscan --cache." ); }
tools/vgscan.c +1 -1
@@ -101,7 +101,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)log_verbose ("Ignoring vgscan --cache command because lvmetad is not in use." );if (lvmetad_used () && (arg_is_set (cmd, cache_long_ARG) || !lvmetad_token_matches (cmd) ||lvmetad_is_disabled (cmd, &reason))) { -if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd,arg_is_set (cmd, cache_long_ARG))) { +if (lvmetad_used () && !lvmetad_pvscan_all_devs (cmd,arg_is_set (cmd, cache_long_ARG),NULL )) {log_warn ("WARNING: Not using lvmetad because cache update failed." );lvmetad_make_unused (cmd); }