diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 53f1c959f..017a86b07 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -141,6 +141,8 @@ void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd) /* Volume Group metadata cache functions */ static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo) { + struct lvmcache_info *info; + if (!vginfo || !vginfo->vgmetadata) return; @@ -154,6 +156,10 @@ static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo) vginfo->cft = NULL; } + /* Invalidate any cached device buffers */ + dm_list_iterate_items(info, &vginfo->infos) + devbufs_release(info->dev); + log_debug_cache("lvmcache: VG %s wiped.", vginfo->vgname); release_vg(vginfo->cached_vg); diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c index 47d3ad945..18a09d15b 100644 --- a/lib/device/dev-io.c +++ b/lib/device/dev-io.c @@ -85,6 +85,9 @@ static void _release_devbuf(struct device_buffer *devbuf) void devbufs_release(struct device *dev) { + if ((dev->flags & DEV_REGULAR)) + return; + _release_devbuf(&dev->last_devbuf); _release_devbuf(&dev->last_extra_devbuf); } @@ -706,6 +709,7 @@ static void _close(struct device *dev) dev->phys_block_size = -1; dev->block_size = -1; dm_list_del(&dev->open_list); + devbufs_release(dev); log_debug_devs("Closed %s", dev_name(dev));