From 381f32b1c5943afb35940b88c45c3fa4bf5fc1de Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Fri, 18 Aug 2023 12:49:16 +0200 Subject: [PATCH] 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 --- collector/btrfs_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/btrfs_linux.go b/collector/btrfs_linux.go index b5642b33..f1490541 100644 --- a/collector/btrfs_linux.go +++ b/collector/btrfs_linux.go @@ -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 {