1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

filters: update composable filter

Last commit made dump filter only partially composable.
Add remaining functionality and also support composable wipe,
which is needed, when i.e. vgscan needs to remove cache.

(in release fix)
This commit is contained in:
Zdenek Kabelac 2013-06-02 21:59:57 +02:00
parent 20868482dd
commit 5467a3b2b7
7 changed files with 20 additions and 15 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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);

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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