diff --git a/WHATS_NEW b/WHATS_NEW index d0bc3863b..16ad1d97b 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.178 - ===================================== + Automatically avoid reading invalid snapshots during device scan. Ensure COW device is writable even for read-only thick snapshots. Support activation of component LVs in read-only mode. Extend internal library to recognize and work with component LV. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index b8b937d9c..dab16038f 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -518,6 +518,24 @@ out: return r; } +static int _ignore_invalid_snapshot(const char *params) +{ + struct dm_status_snapshot *s; + struct dm_pool *mem; + int r; + + if (!(mem = dm_pool_create("invalid snapshots", 128))) + return_0; + + if (!dm_get_status_snapshot(mem, params, &s)) + return_0; + + r = s->invalid; + dm_pool_destroy(mem); + + return r; +} + /* * device_is_usable * @dev @@ -633,6 +651,12 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check) goto out; } + if (target_type && !strcmp(target_type, TARGET_NAME_SNAPSHOT) && + _ignore_invalid_snapshot(params)) { + log_debug_activation("%s: Invalid %s device %s not usable.", dev_name(dev), target_type, name); + goto out; + } + /* TODO: extend check struct ? */ if (target_type && !strcmp(target_type, TARGET_NAME_THIN) && !_ignore_unusable_thins(dev)) {