diff mbox series

[2/3] btrfs: move comments to btrfs_loop_type definition

Message ID 6abfcd8c6763baf92199be9532db3bd9e9e0e418.1689883754.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: fix generic/475 hang | expand

Commit Message

Josef Bacik July 20, 2023, 8:12 p.m. UTC
Some of these loop types aren't described, and they should be with the
definitions to make it easier to tell what each of them do.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent-tree.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)

Comments

Boris Burkov July 20, 2023, 10:28 p.m. UTC | #1
On Thu, Jul 20, 2023 at 04:12:15PM -0400, Josef Bacik wrote:
> Some of these loop types aren't described, and they should be with the
> definitions to make it easier to tell what each of them do.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Boris Burkov <boris@bur.io>
David Sterba July 27, 2023, 4:32 p.m. UTC | #2
On Thu, Jul 20, 2023 at 04:12:15PM -0400, Josef Bacik wrote:
> Some of these loop types aren't described, and they should be with the
> definitions to make it easier to tell what each of them do.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

This is still relevant, without LOOP_CACHING_DONE, so added to
misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2850bd411a0e..8db2673948c9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3329,12 +3329,44 @@  int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
 }
 
 enum btrfs_loop_type {
+	/*
+	 * Start caching block groups but do not wait for progress or for them
+	 * to be done.
+	 */
 	LOOP_CACHING_NOWAIT,
+
+	/*
+	 * Wait for the block group free_space >= the space we're waiting for if
+	 * the block group isn't cached.
+	 */
 	LOOP_CACHING_WAIT,
+
+	/*
+	 * Wait for the block group to be completely cached before attempting to
+	 * make an allocation.
+	 */
 	LOOP_CACHING_DONE,
+
+	/*
+	 * Allow allocations to happen from block groups that do not yet have a
+	 * size classification.
+	 */
 	LOOP_UNSET_SIZE_CLASS,
+
+	/*
+	 * Allocate a chunk and then retry the allocation.
+	 */
 	LOOP_ALLOC_CHUNK,
+
+	/*
+	 * Ignore the size class restrictions for this allocation.
+	 */
 	LOOP_WRONG_SIZE_CLASS,
+
+	/*
+	 * Ignore the empty size, only try to allocate the number of bytes
+	 * needed for this allocation.
+	 */
 	LOOP_NO_EMPTY_SIZE,
 };
 
@@ -3926,15 +3958,7 @@  static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
 		return 1;
 
 	/*
-	 * LOOP_CACHING_NOWAIT, search partially cached block groups, kicking
-	 *			caching kthreads as we move along
-	 * LOOP_CACHING_WAIT, search everything, and wait if our bg is caching
-	 * LOOP_CACHING_DONE, search everything, wait for the caching to
-	 *			completely finish
-	 * LOOP_UNSET_SIZE_CLASS, allow unset size class
-	 * LOOP_ALLOC_CHUNK, force a chunk allocation and try again
-	 * LOOP_NO_EMPTY_SIZE, set empty_size and empty_cluster to 0 and try
-	 *		       again
+	 * See the comment for btrfs_loop_type for an explanation of the phases.
 	 */
 	if (ffe_ctl->loop < LOOP_NO_EMPTY_SIZE) {
 		ffe_ctl->index = 0;