Commit cfbc0ffe authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull btrfs fix from David Sterba:
 "A fixup for a recent fix that prevents an infinite loop during block
  group reclaim.

  Unfortunately it introduced an unsafe way of updating block group list
  and could race with relocation. This could be hit on fast devices when
  relocation/balance does not have enough space"

* tag 'for-6.10-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix adding block group to a reclaim list and the unused list during reclaim
parents 9903efbd 48f091fd
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1924,9 +1924,18 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
next:
		if (ret) {
			/* Refcount held by the reclaim_bgs list after splice. */
			spin_lock(&fs_info->unused_bgs_lock);
			/*
			 * This block group might be added to the unused list
			 * during the above process. Move it back to the
			 * reclaim list otherwise.
			 */
			if (list_empty(&bg->bg_list)) {
				btrfs_get_block_group(bg);
				list_add_tail(&bg->bg_list, &retry_list);
			}
			spin_unlock(&fs_info->unused_bgs_lock);
		}
		btrfs_put_block_group(bg);

		mutex_unlock(&fs_info->reclaim_bgs_lock);