master - autoactivation: issue a VG refresh before autoactivation only if 'change' lvmetad flag is set
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ca880a4f130a0d6111613e23f926c344217581a2 Commit: ca880a4f130a0d6111613e23f926c344217581a2 Parent: 900cb6717b9d06e2b40049e4da2b25e8b98375a7 Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Mar 14 10:44:14 2014 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Mar 14 10:48:56 2014 +0100
autoactivation: issue a VG refresh before autoactivation only if 'change' lvmetad flag is set
This prevents numerous VG refreshes on each "pvscan --cache -aay" call if the VG is found complete. We need to issue the refresh only if the PV:
- is new
- was gone before and now it reappears (device "unplug/plug back" scenario)
- the metadata has changed
--- WHATS_NEW | 2 ++ lib/cache/lvmetad.c | 6 ++++-- lib/cache/lvmetad.h | 3 ++- tools/pvscan.c | 21 ++++++++++++--------- 4 files changed, 20 insertions(+), 12 deletions(-)
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@ Version 2.02.106 - ==================================== + Issue a VG refresh before autoactivation only if the PV has changed/is new. + Add flag to lvmetad protocol to indicate the PV scanned has changed/is new. Add man page for lvm2-activation-generator. Don't print an error and accept empty value for global/thin_disabled_features. Update API for internal function build_dm_uuid().
lib/cache/lvmetad.c +4 -2
@@ -750,6 +750,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct forstruct lvmcache_info *info;struct dm_config_tree *pvmeta, *vgmeta;const char *status, *vgid; +int64_t changed;int result;if (!lvmetad_active () ||test_mode ())
@@ -819,10 +820,11 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct forif (result && handler) { status =daemon_reply_str (reply,"status" ,"<missing>" ); vgid =daemon_reply_str (reply,"vgid" ,"<missing>" ); + changed =daemon_reply_int (reply,"changed" ,0 );if (!strcmp (status,"partial" )) -handler (_lvmetad_cmd, vgid,1 ,CHANGE_AAY ); +handler (_lvmetad_cmd, vgid,1 , changed,CHANGE_AAY );else if (!strcmp (status,"complete" )) -handler (_lvmetad_cmd, vgid,0 ,CHANGE_AAY ); +handler (_lvmetad_cmd, vgid,0 , changed,CHANGE_AAY );else if (!strcmp (status,"orphan" )) ;else
lib/cache/lvmetad.h +2 -1
@@ -23,7 +23,8 @@ struct dm_config_tree;enum activation_change ;typedef int (*activation_handler ) (struct cmd_context *cmd, -const char *vgid,int partial, +const char *vgid, +int partial,int changed,enum activation_change activate);#ifdef LVMETAD_SUPPORT
tools/pvscan.c +12 -9
@@ -95,7 +95,8 @@ static void _pvscan_display_single(struct cmd_context *cmd,#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000static int _auto_activation_handler (struct cmd_context *cmd, -const char *vgid,int partial, +const char *vgid, +int partial,int changed,activation_change_t activate) {unsigned int refresh_retries =REFRESH_BEFORE_AUTOACTIVATION_RETRIES ;
@@ -139,16 +140,18 @@ static int _auto_activation_handler(struct cmd_context *cmd,* * Remove this workaround with "refresh_retries" once we have proper locking in! */ -while (refresh_retries--) { -if (vg_refresh_visible (vg->cmd, vg)) { - refresh_done =1 ; -break ; +if (changed) { +while (refresh_retries--) { +if (vg_refresh_visible (vg->cmd, vg)) { + refresh_done =1 ; +break ; + } +usleep (REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY ); } -usleep (REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY ); - } -if (!refresh_done) -log_warn ("%s: refresh before autoactivation failed." , vg->name); +if (!refresh_done) +log_warn ("%s: refresh before autoactivation failed." , vg->name); + }if (!vgchange_activate (vg->cmd, vg, activate)) {log_error ("%s: autoactivation failed." , vg->name);