1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-08 09:57:55 +03:00

Fix refresh_toolcontext() always to wipe persistent device filter cache.

Add is_long_lived to toolcontext.
This commit is contained in:
Alasdair Kergon 2007-01-23 15:58:06 +00:00
parent 13635d281a
commit 9d944d6cf9
5 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,7 @@
Version 2.02.20 - Version 2.02.20 -
=================================== ===================================
Fix refresh_toolcontext() always to wipe persistent device filter cache.
Add is_long_lived to toolcontext.
Add --clustered to man pages. Add --clustered to man pages.
Streamline dm_report_field_* interface. Streamline dm_report_field_* interface.
Change remaining dmeventd terminology 'register' to 'monitor'. Change remaining dmeventd terminology 'register' to 'monitor'.

View File

@ -575,7 +575,7 @@ void init_lvhash()
/* Called to initialise the LVM context of the daemon */ /* Called to initialise the LVM context of the daemon */
int init_lvm(int using_gulm) int init_lvm(int using_gulm)
{ {
if (!(cmd = create_toolcontext(NULL, 0))) { if (!(cmd = create_toolcontext(NULL, 0, 1))) {
log_error("Failed to allocate command context"); log_error("Failed to allocate command context");
return 0; return 0;
} }

View File

@ -575,7 +575,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
filters[0] : composite_filter_create(nr_filt, filters); filters[0] : composite_filter_create(nr_filt, filters);
} }
static int _init_filters(struct cmd_context *cmd) static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
{ {
const char *dev_cache; const char *dev_cache;
struct dev_filter *f3, *f4; struct dev_filter *f3, *f4;
@ -608,8 +608,13 @@ static int _init_filters(struct cmd_context *cmd)
if (!*cmd->sys_dir) if (!*cmd->sys_dir)
cmd->dump_filter = 0; cmd->dump_filter = 0;
if (!stat(dev_cache, &st) && /*
(st.st_ctime != config_file_timestamp(cmd->cft)) && * Only load persistent filter device cache on startup if it is newer
* than the config file and this is not a long-lived process.
*/
if (load_persistent_cache && !cmd->is_long_lived &&
!stat(dev_cache, &st) &&
(st.st_ctime > config_file_timestamp(cmd->cft)) &&
!persistent_filter_load(f4, NULL)) !persistent_filter_load(f4, NULL))
log_verbose("Failed to load existing device cache from %s", log_verbose("Failed to load existing device cache from %s",
dev_cache); dev_cache);
@ -881,7 +886,8 @@ static int _init_backup(struct cmd_context *cmd)
} }
/* Entry point */ /* Entry point */
struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static) struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static,
unsigned is_long_lived)
{ {
struct cmd_context *cmd; struct cmd_context *cmd;
@ -905,6 +911,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static)
memset(cmd, 0, sizeof(*cmd)); memset(cmd, 0, sizeof(*cmd));
cmd->args = the_args; cmd->args = the_args;
cmd->is_static = is_static; cmd->is_static = is_static;
cmd->is_long_lived = is_long_lived;
cmd->hosttags = 0; cmd->hosttags = 0;
list_init(&cmd->formats); list_init(&cmd->formats);
list_init(&cmd->segtypes); list_init(&cmd->segtypes);
@ -953,7 +960,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static)
if (!_init_dev_cache(cmd)) if (!_init_dev_cache(cmd))
goto error; goto error;
if (!_init_filters(cmd)) if (!_init_filters(cmd, 1))
goto error; goto error;
if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) { if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) {
@ -1022,10 +1029,10 @@ int refresh_toolcontext(struct cmd_context *cmd)
{ {
log_verbose("Reloading config files"); log_verbose("Reloading config files");
if (cmd->config_valid) { /*
if (cmd->dump_filter) * Don't update the persistent filter cache as we will
persistent_filter_dump(cmd->filter); * perform a full rescan.
} */
activation_release(); activation_release();
lvmcache_destroy(); lvmcache_destroy();
@ -1064,7 +1071,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
if (!_init_dev_cache(cmd)) if (!_init_dev_cache(cmd))
return 0; return 0;
if (!_init_filters(cmd)) if (!_init_filters(cmd, 0))
return 0; return 0;
if (!_init_formats(cmd)) if (!_init_formats(cmd))

View File

@ -65,6 +65,7 @@ struct cmd_context {
struct arg *args; struct arg *args;
char **argv; char **argv;
unsigned is_static; /* Static binary? */ unsigned is_static; /* Static binary? */
unsigned is_long_lived; /* Optimises persistent_filter handling */
struct dev_filter *filter; struct dev_filter *filter;
int dump_filter; /* Dump filter when exiting? */ int dump_filter; /* Dump filter when exiting? */
@ -88,7 +89,7 @@ struct cmd_context {
char proc_dir[PATH_MAX]; char proc_dir[PATH_MAX];
}; };
struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static); struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived);
void destroy_toolcontext(struct cmd_context *cmd); void destroy_toolcontext(struct cmd_context *cmd);
int refresh_toolcontext(struct cmd_context *cmd); int refresh_toolcontext(struct cmd_context *cmd);
int config_files_changed(struct cmd_context *cmd); int config_files_changed(struct cmd_context *cmd);

View File

@ -1030,7 +1030,7 @@ struct cmd_context *init_lvm(unsigned is_static)
{ {
struct cmd_context *cmd; struct cmd_context *cmd;
if (!(cmd = create_toolcontext(&the_args[0], is_static))) { if (!(cmd = create_toolcontext(&the_args[0], is_static, 0))) {
stack; stack;
return NULL; return NULL;
} }