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

device: Free cached device bufs when metadata invalid or dev closed.

This commit is contained in:
Alasdair G Kergon 2018-01-10 12:03:31 +00:00
parent bd0967a4b1
commit 4d568b709c
2 changed files with 10 additions and 0 deletions

View File

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

View File

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