Skip to contentSkip to conversation

btrfs: remove call to btrfs_delete_unused_bgs() in close_ctree()

PATCH In review Mark Harmstone 4 participants 4 messages Mar 18, 2025 – Mar 27, 2025 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: remove call to btrfs_delete_unused_bgs() in close_ctree()

btrfs_delete_unused_bgs() returns early if the filesystem is closing, so the call in close_ctree() will always do nothing.

---
 fs/btrfs/disk-io.c | 6 ------
 1 file changed, 6 deletions(-)
fs/btrfs/disk-io.c +0 -6
index 1a916716cefe..7c114d5d0f77 100644
@@ -4412,12 +4412,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
 	btrfs_discard_cleanup(fs_info);
 
 	if (!sb_rdonly(fs_info->sb)) {
-		/*
-		 * The cleaner kthread is stopped, so do one final pass over
-		 * unused block groups.
-		 */
-		btrfs_delete_unused_bgs(fs_info);
-
 		/*
 		 * There might be existing delayed inode workers still running
 		 * and holding an empty delayed inode item. We must wait for
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Mark Harmstone

btrfs_delete_unused_bgs() returns early if the filesystem is closing, so the call in close_ctree() will always do nothing.

Thanks,
Qu

Quoted 21 lines
---
  fs/btrfs/disk-io.c | 6 ------
  1 file changed, 6 deletions(-)
fs/btrfs/disk-io.c +0 -6
index 1a916716cefe..7c114d5d0f77 100644
@@ -4412,12 +4412,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
  	btrfs_discard_cleanup(fs_info);
 
  	if (!sb_rdonly(fs_info->sb)) {
-		/*
-		 * The cleaner kthread is stopped, so do one final pass over
-		 * unused block groups.
-		 */
-		btrfs_delete_unused_bgs(fs_info);
-
  		/*
  		 * There might be existing delayed inode workers still running
  		 * and holding an empty delayed inode item. We must wait for
#3 lore raw
In reply to Mark Harmstone
Quoted 13 lines · Mark Harmstone

btrfs_delete_unused_bgs() returns early if the filesystem is closing, so the call in close_ctree() will always do nothing.

---
 fs/btrfs/disk-io.c | 6 ------
 1 file changed, 6 deletions(-)
fs/btrfs/disk-io.c +0 -0
index 1a916716cefe..7c114d5d0f77 100644

fs/btrfs/disk-io.c void __cold close_ctree(struct btrfs_fs_info *fs_info) · line 4419

Quoted 8 lines
fs/btrfs/disk-io.c +0 -5
@@ -4412,12 +4412,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
 	btrfs_discard_cleanup(fs_info);
 
 	if (!sb_rdonly(fs_info->sb)) {
-		/*
-		 * The cleaner kthread is stopped, so do one final pass over
-		 * unused block groups.
-		 */
-		btrfs_delete_unused_bgs(fs_info);

I've checked the original commit that added it, e44163e17796 ("btrfs:
explictly delete unused block groups in close_ctree and ro-remount") and this at that time it was cleaning the unused block groups.

This changed in 2f12741f81af ("btrfs: use btrfs_fs_closing for background bg work") supposedly moving the work to a workque, so this should be reviewed again if it works as expected.