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
1 changed files with 1 additions and 0 deletions

View File

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