btrfs: rename workspaces_list to workspace_manager
authorDennis Zhou <dennis@kernel.org>
Mon, 4 Feb 2019 20:19:58 +0000 (15:19 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:13:30 +0000 (14:13 +0100)
This is in preparation for zstd compression levels. As each level will
require different size of workspace, workspaces_list is no longer a
really fitting name.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c

index 94a0b0a3a301e880f768576f3b9599be2dddc7c6..d098df768b67720d95e0bf9500da0bfdf0827255 100644 (file)
@@ -769,7 +769,7 @@ fail:
        return ERR_PTR(-ENOMEM);
 }
 
        return ERR_PTR(-ENOMEM);
 }
 
-struct workspaces_list {
+struct workspace_manager {
        struct list_head idle_ws;
        spinlock_t ws_lock;
        /* Number of free workspaces */
        struct list_head idle_ws;
        spinlock_t ws_lock;
        /* Number of free workspaces */
@@ -780,9 +780,9 @@ struct workspaces_list {
        wait_queue_head_t ws_wait;
 };
 
        wait_queue_head_t ws_wait;
 };
 
-static struct workspaces_list btrfs_comp_ws[BTRFS_COMPRESS_TYPES];
+static struct workspace_manager wsm[BTRFS_COMPRESS_TYPES];
 
 
-static struct workspaces_list btrfs_heuristic_ws;
+static struct workspace_manager btrfs_heuristic_ws;
 
 static const struct btrfs_compress_op * const btrfs_compress_op[] = {
        &btrfs_zlib_compress,
 
 static const struct btrfs_compress_op * const btrfs_compress_op[] = {
        &btrfs_zlib_compress,
@@ -811,10 +811,10 @@ void __init btrfs_init_compress(void)
        }
 
        for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
        }
 
        for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
-               INIT_LIST_HEAD(&btrfs_comp_ws[i].idle_ws);
-               spin_lock_init(&btrfs_comp_ws[i].ws_lock);
-               atomic_set(&btrfs_comp_ws[i].total_ws, 0);
-               init_waitqueue_head(&btrfs_comp_ws[i].ws_wait);
+               INIT_LIST_HEAD(&wsm[i].idle_ws);
+               spin_lock_init(&wsm[i].ws_lock);
+               atomic_set(&wsm[i].total_ws, 0);
+               init_waitqueue_head(&wsm[i].ws_wait);
 
                /*
                 * Preallocate one workspace for each compression type so
 
                /*
                 * Preallocate one workspace for each compression type so
@@ -824,9 +824,9 @@ void __init btrfs_init_compress(void)
                if (IS_ERR(workspace)) {
                        pr_warn("BTRFS: cannot preallocate compression workspace, will try later\n");
                } else {
                if (IS_ERR(workspace)) {
                        pr_warn("BTRFS: cannot preallocate compression workspace, will try later\n");
                } else {
-                       atomic_set(&btrfs_comp_ws[i].total_ws, 1);
-                       btrfs_comp_ws[i].free_ws = 1;
-                       list_add(workspace, &btrfs_comp_ws[i].idle_ws);
+                       atomic_set(&wsm[i].total_ws, 1);
+                       wsm[i].free_ws = 1;
+                       list_add(workspace, &wsm[i].idle_ws);
                }
        }
 }
                }
        }
 }
@@ -856,11 +856,11 @@ static struct list_head *__find_workspace(int type, bool heuristic)
                ws_wait  = &btrfs_heuristic_ws.ws_wait;
                free_ws  = &btrfs_heuristic_ws.free_ws;
        } else {
                ws_wait  = &btrfs_heuristic_ws.ws_wait;
                free_ws  = &btrfs_heuristic_ws.free_ws;
        } else {
-               idle_ws  = &btrfs_comp_ws[idx].idle_ws;
-               ws_lock  = &btrfs_comp_ws[idx].ws_lock;
-               total_ws = &btrfs_comp_ws[idx].total_ws;
-               ws_wait  = &btrfs_comp_ws[idx].ws_wait;
-               free_ws  = &btrfs_comp_ws[idx].free_ws;
+               idle_ws  = &wsm[idx].idle_ws;
+               ws_lock  = &wsm[idx].ws_lock;
+               total_ws = &wsm[idx].total_ws;
+               ws_wait  = &wsm[idx].ws_wait;
+               free_ws  = &wsm[idx].free_ws;
        }
 
 again:
        }
 
 again:
@@ -952,11 +952,11 @@ static void __free_workspace(int type, struct list_head *workspace,
                ws_wait  = &btrfs_heuristic_ws.ws_wait;
                free_ws  = &btrfs_heuristic_ws.free_ws;
        } else {
                ws_wait  = &btrfs_heuristic_ws.ws_wait;
                free_ws  = &btrfs_heuristic_ws.free_ws;
        } else {
-               idle_ws  = &btrfs_comp_ws[idx].idle_ws;
-               ws_lock  = &btrfs_comp_ws[idx].ws_lock;
-               total_ws = &btrfs_comp_ws[idx].total_ws;
-               ws_wait  = &btrfs_comp_ws[idx].ws_wait;
-               free_ws  = &btrfs_comp_ws[idx].free_ws;
+               idle_ws  = &wsm[idx].idle_ws;
+               ws_lock  = &wsm[idx].ws_lock;
+               total_ws = &wsm[idx].total_ws;
+               ws_wait  = &wsm[idx].ws_wait;
+               free_ws  = &wsm[idx].free_ws;
        }
 
        spin_lock(ws_lock);
        }
 
        spin_lock(ws_lock);
@@ -998,11 +998,11 @@ static void free_workspaces(void)
        }
 
        for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
        }
 
        for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
-               while (!list_empty(&btrfs_comp_ws[i].idle_ws)) {
-                       workspace = btrfs_comp_ws[i].idle_ws.next;
+               while (!list_empty(&wsm[i].idle_ws)) {
+                       workspace = wsm[i].idle_ws.next;
                        list_del(workspace);
                        btrfs_compress_op[i]->free_workspace(workspace);
                        list_del(workspace);
                        btrfs_compress_op[i]->free_workspace(workspace);
-                       atomic_dec(&btrfs_comp_ws[i].total_ws);
+                       atomic_dec(&wsm[i].total_ws);
                }
        }
 }
                }
        }
 }