From a171bb6e85509e6da3008039c34a36d5ea9930a3 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 22 Sep 2010 01:36:13 +0000 Subject: [PATCH] Track recursive filter iteration to avoid refreshing while in use. (2.02.56) --- VERSION | 2 +- VERSION_DM | 2 +- WHATS_NEW | 13 +++++++------ WHATS_NEW_DM | 3 ++- lib/cache/lvmcache.c | 2 +- lib/device/dev-cache.c | 2 ++ lib/device/dev-cache.h | 1 + lib/filters/filter-composite.c | 4 ++++ lib/filters/filter-md.c | 4 ++++ lib/filters/filter-persistent.c | 8 ++++++-- lib/filters/filter-regex.c | 5 +++++ lib/filters/filter-sysfs.c | 5 +++++ lib/filters/filter.c | 4 ++++ 13 files changed, 43 insertions(+), 12 deletions(-) diff --git a/VERSION b/VERSION index ece396e43..19fb16642 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.02.74(2)-cvs (2010-08-19) +2.02.74(2)-cvs (2010-09-22) diff --git a/VERSION_DM b/VERSION_DM index 36e481905..633df7f36 100644 --- a/VERSION_DM +++ b/VERSION_DM @@ -1 +1 @@ -1.02.55-cvs (2010-08-19) +1.02.55-cvs (2010-09-22) diff --git a/WHATS_NEW b/WHATS_NEW index 20f4e4837..3444069cf 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,7 +1,8 @@ Version 2.02.74 - -================================== - Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function. - Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit). +===================================== + Track recursive filter iteration to avoid refreshing while in use. (2.02.56) + Revert to old glibc vsnprintf behaviour in emit_to_buffer() to catch overflow. + Allocate buffer for metadata tags dynamically to remove 4k limit. Add random suffix to archive file names to prevent races when being created. Reinitialize archive and backup handling on toolcontext refresh. Fix opprobriously slow I/O to cluster mirrors created with --nosync. @@ -16,16 +17,16 @@ Version 2.02.74 - Add "devices/default_data_alignment" to lvm.conf. Add implmentation for simple numeric 'get' property functions. Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' function - Add properties.[ch] to lib/report, defined based on columns.h. + Add properties.[ch] to lib/report using columns.h. Add macro definitions to report infrastructure for character array length. Remove explicit double quotes from columns.h 'id' entries. Add 'flags' field to columns.h and define FIELD_MODIFIABLE. Add vg_mda_size and vg_mda_free functions. Simplify MD/swap signature detection in pvcreate and allow aborting. - Remove assumption that --yes must be used only in --force mode. + Allow --yes to be used without --force mode. Fix file descriptor leak in swap signature detection error path. Detect and allow abort in pvcreate if LUKS signature is detected. - Use proper locks mask when checking for LCK_WRITE. + Always mask lock flags correctly when checking for LCK_WRITE. Version 2.02.73 - 18th August 2010 ================================== diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 272416014..13b791a82 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.55 - -================================== +===================================== + Add DM_REPORT_FIELD_TYPE_ID_LEN to libdevmapper.h. Version 1.02.54 - 18th August 2010 ================================== diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 5a9c3f297..2af4e4a65 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -570,7 +570,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan) goto out; } - if (full_scan == 2 && !refresh_filters(cmd)) { + if (full_scan == 2 && !cmd->filter->use_count && !refresh_filters(cmd)) { log_error("refresh filters failed"); goto out; } diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index f28968fa9..d43fcc02c 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -815,12 +815,14 @@ struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan) di->current = btree_first(_cache.devices); di->filter = f; + di->filter->use_count++; return di; } void dev_iter_destroy(struct dev_iter *iter) { + iter->filter->use_count--; dm_free(iter); } diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 96bf0133c..0ade053c5 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -24,6 +24,7 @@ struct dev_filter { int (*passes_filter) (struct dev_filter * f, struct device * dev); void (*destroy) (struct dev_filter * f); + unsigned use_count; void *private; }; diff --git a/lib/filters/filter-composite.c b/lib/filters/filter-composite.c index d1606d32d..130490af3 100644 --- a/lib/filters/filter-composite.c +++ b/lib/filters/filter-composite.c @@ -37,6 +37,9 @@ static void _composite_destroy(struct dev_filter *f) { struct dev_filter **filters = (struct dev_filter **) f->private; + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying composite filter while in use %u times.", f->use_count); + while (*filters) { (*filters)->destroy(*filters); filters++; @@ -69,6 +72,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters) cft->passes_filter = _and_p; cft->destroy = _composite_destroy; + cft->use_count = 0; cft->private = filters_copy; return cft; diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c index 5dc71a9a3..baf54ec3e 100644 --- a/lib/filters/filter-md.c +++ b/lib/filters/filter-md.c @@ -45,6 +45,9 @@ static int _ignore_md(struct dev_filter *f __attribute__((unused)), static void _destroy(struct dev_filter *f) { + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying sysfs filter while in use %u times.", f->use_count); + dm_free(f); } @@ -59,6 +62,7 @@ struct dev_filter *md_filter_create(void) f->passes_filter = _ignore_md; f->destroy = _destroy; + f->use_count = 0; f->private = NULL; return f; diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c index 5e05d2ba3..7f48a4791 100644 --- a/lib/filters/filter-persistent.c +++ b/lib/filters/filter-persistent.c @@ -274,13 +274,13 @@ static int _lookup_p(struct dev_filter *f, struct device *dev) return 0; } - /* Test dm devices every time, so cache them as GOOD. */ + /* Test dm devices every time, so cache them as GOOD. */ if (MAJOR(dev->dev) == dm_major()) { if (!l) dm_list_iterate_items(sl, &dev->aliases) dm_hash_insert(pf->devices, sl->str, PF_GOOD_DEVICE); if (!device_is_usable(dev)) { - log_debug("%s: Skipping unusable device", dev_name(dev)); + log_debug("%s: Skipping unusable device", dev_name(dev)); return 0; } return pf->real->passes_filter(pf->real, dev); @@ -301,6 +301,9 @@ static void _persistent_destroy(struct dev_filter *f) { struct pfilter *pf = (struct pfilter *) f->private; + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying persistent filter while in use %u times.", f->use_count); + dm_hash_destroy(pf->devices); dm_free(pf->file); pf->real->destroy(pf->real); @@ -339,6 +342,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real, f->passes_filter = _lookup_p; f->destroy = _persistent_destroy; + f->use_count = 0; f->private = pf; return f; diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c index c06240215..7bc0a7349 100644 --- a/lib/filters/filter-regex.c +++ b/lib/filters/filter-regex.c @@ -181,6 +181,10 @@ static int _accept_p(struct dev_filter *f, struct device *dev) static void _regex_destroy(struct dev_filter *f) { struct rfilter *rf = (struct rfilter *) f->private; + + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying regex filter while in use %u times.", f->use_count); + dm_pool_destroy(rf->mem); } @@ -206,6 +210,7 @@ struct dev_filter *regex_filter_create(struct config_value *patterns) f->passes_filter = _accept_p; f->destroy = _regex_destroy; + f->use_count = 0; f->private = rf; return f; diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c index 781e43365..be8fbde5f 100644 --- a/lib/filters/filter-sysfs.c +++ b/lib/filters/filter-sysfs.c @@ -282,6 +282,10 @@ static int _accept_p(struct dev_filter *f, struct device *dev) static void _destroy(struct dev_filter *f) { struct dev_set *ds = (struct dev_set *) f->private; + + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying sysfs filter while in use %u times.", f->use_count); + dm_pool_destroy(ds->mem); } @@ -316,6 +320,7 @@ struct dev_filter *sysfs_filter_create(const char *sysfs_dir) f->passes_filter = _accept_p; f->destroy = _destroy; + f->use_count = 0; f->private = ds; return f; diff --git a/lib/filters/filter.c b/lib/filters/filter.c index 6b54ed829..d570f795e 100644 --- a/lib/filters/filter.c +++ b/lib/filters/filter.c @@ -326,6 +326,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc, f->passes_filter = _passes_lvm_type_device_filter; f->destroy = lvm_type_filter_destroy; + f->use_count = 0; f->private = NULL; if (!_scan_proc_dev(proc, cn)) { @@ -338,5 +339,8 @@ struct dev_filter *lvm_type_filter_create(const char *proc, void lvm_type_filter_destroy(struct dev_filter *f) { + if (f->use_count) + log_error(INTERNAL_ERROR "Destroying lvm_type filter while in use %u times.", f->use_count); + dm_free(f); } -- 2.43.5