1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

filters: toplevel filter not persistent

Add a generic dump operation to filters and make the composite filter call
through to its components. Previously, when global filter was set, the code
would treat the toplevel composite filter's private area as if it belonged a
persistent filter, trying to write nonsense into a non-sensical file.
Also deal with NULL cmd->filter gracefully.
This commit is contained in:
Petr Rockai 2013-05-27 00:49:40 +02:00 committed by Zdenek Kabelac
parent 05bf4b8cc3
commit e7878da921
5 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Update persistent filter functinality 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.

View File

@ -1650,8 +1650,8 @@ void destroy_toolcontext(struct cmd_context *cmd)
struct dm_config_tree *cft_cmdline;
FILE *new_stream;
if (cmd->dump_filter)
persistent_filter_dump(cmd->filter, 1);
if (cmd->dump_filter && cmd->filter && cmd->filter->dump)
cmd->filter->dump(cmd->filter);
archive_exit(cmd);
backup_exit(cmd);

View File

@ -26,6 +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 *private;
unsigned use_count;
};

View File

@ -49,6 +49,17 @@ static void _composite_destroy(struct dev_filter *f)
dm_free(f);
}
static void _dump(struct dev_filter *f)
{
struct dev_filter **filters = (struct dev_filter **) f->private;
while (*filters) {
if ((*filters)->dump)
(*filters)->dump(*filters);
filters++;
}
}
struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
{
struct dev_filter **filters_copy, *cft;
@ -72,6 +83,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->use_count = 0;
cft->private = filters_copy;

View File

@ -274,6 +274,11 @@ 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;
@ -367,6 +372,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;
return f;