btrfs: close btrfs.FS handle after use

Despite being quite hard to provoke (< 10% in my testing), the btrfs
collector would occasionally leave stale FDs relating to btrfs
mountpoints, making the filesystems unable to be unmounted.

Fixes: #2772.

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
This commit is contained in:
Daniel Swarbrick 2023-08-18 12:49:16 +02:00 committed by Johannes 'fish' Ziemke
parent f2b274350a
commit 381f32b1c5

View File

@ -135,6 +135,7 @@ func (c *btrfsCollector) getIoctlStats() (map[string]*btrfsIoctlFsStats, error)
"err", err)
continue
}
defer fs.Close()
fsInfo, err := fs.Info()
if err != nil {