diff --git a/WHATS_NEW b/WHATS_NEW index ba88915b1..cd2d8edb8 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,7 +1,7 @@ Version 2.02.99 - =================================== Do not use persistent filter with lvmetad. - Update persistent filter functinality for global filter. + Composable persistent filter functionality for global filter. Override system's global_filter settings for vgimportclone. Detect maximum usable size for snapshot for lvresize. Creation of snapshot takes at most 100% origin coverage. diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 174c133dc..81b8de145 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -707,8 +707,9 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan) * If we are a long-lived process, write out the updated persistent * device cache for the benefit of short-lived processes. */ - if (full_scan == 2 && cmd->is_long_lived && cmd->dump_filter) - persistent_filter_dump(cmd->filter, 0); + if (full_scan == 2 && cmd->is_long_lived && + cmd->dump_filter && cmd->filter && cmd->filter->dump) + cmd->filter->dump(cmd->filter, 0); r = 1; diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index af1aa6344..00887ab27 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1653,7 +1653,7 @@ void destroy_toolcontext(struct cmd_context *cmd) FILE *new_stream; if (cmd->dump_filter && cmd->filter && cmd->filter->dump) - cmd->filter->dump(cmd->filter); + cmd->filter->dump(cmd->filter, 1); archive_exit(cmd); backup_exit(cmd); diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 4119d9005..b886098a5 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -26,7 +26,7 @@ struct dev_filter { int (*passes_filter) (struct dev_filter * f, struct device * dev); void (*destroy) (struct dev_filter * f); void (*wipe) (struct dev_filter * f); - void (*dump) (struct dev_filter * f); + void (*dump) (struct dev_filter * f, int merge_existing); void *private; unsigned use_count; }; diff --git a/lib/filters/filter-composite.c b/lib/filters/filter-composite.c index 0d09c0477..e183c00a3 100644 --- a/lib/filters/filter-composite.c +++ b/lib/filters/filter-composite.c @@ -49,17 +49,26 @@ static void _composite_destroy(struct dev_filter *f) dm_free(f); } -static void _dump(struct dev_filter *f) +static void _dump(struct dev_filter *f, int merge_existing) { struct dev_filter **filters = (struct dev_filter **) f->private; while (*filters) { if ((*filters)->dump) - (*filters)->dump(*filters); + (*filters)->dump(*filters, merge_existing); filters++; } } +static void _wipe(struct dev_filter *f) +{ + struct dev_filter **filters; + + for (filters = f->private; *filters; filters++) + if ((*filters)->wipe) + (*filters)->wipe(*filters); +} + struct dev_filter *composite_filter_create(int n, struct dev_filter **filters) { struct dev_filter **filters_copy, *cft; @@ -84,6 +93,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters) cft->passes_filter = _and_p; cft->destroy = _composite_destroy; cft->dump = _dump; + cft->wipe = _wipe; cft->use_count = 0; cft->private = filters_copy; diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c index 7288d9dfa..799e7d8b1 100644 --- a/lib/filters/filter-persistent.c +++ b/lib/filters/filter-persistent.c @@ -179,7 +179,7 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path, fprintf(fp, "\n\t]\n"); } -int persistent_filter_dump(struct dev_filter *f, int merge_existing) +static int _persistent_filter_dump(struct dev_filter *f, int merge_existing) { struct pfilter *pf; char *tmp_file; @@ -274,11 +274,6 @@ out: return r; } -static void _dump(struct dev_filter *f) -{ - persistent_filter_dump(f, 1); -} - static int _lookup_p(struct dev_filter *f, struct device *dev) { struct pfilter *pf = (struct pfilter *) f->private; @@ -372,7 +367,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real, f->use_count = 0; f->private = pf; f->wipe = _persistent_filter_wipe; - f->dump = _dump; + f->dump = _persistent_filter_dump; return f; diff --git a/lib/filters/filter-persistent.h b/lib/filters/filter-persistent.h index c2eee3092..58fbc1007 100644 --- a/lib/filters/filter-persistent.h +++ b/lib/filters/filter-persistent.h @@ -22,6 +22,5 @@ struct dev_filter *persistent_filter_create(struct dev_filter *f, const char *file); int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out); -int persistent_filter_dump(struct dev_filter *f, int merge_existing); #endif