@@ -688,8 +688,6 @@ struct heuristic_ws {
688688 struct list_head list ;
689689};
690690
691- static struct workspace_manager heuristic_wsm ;
692-
693691static void free_heuristic_ws (struct list_head * ws )
694692{
695693 struct heuristic_ws * workspace ;
@@ -729,9 +727,7 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
729727 return ERR_PTR (- ENOMEM );
730728}
731729
732- const struct btrfs_compress_op btrfs_heuristic_compress = {
733- .workspace_manager = & heuristic_wsm ,
734- };
730+ const struct btrfs_compress_op btrfs_heuristic_compress = { 0 };
735731
736732static const struct btrfs_compress_op * const btrfs_compress_op [] = {
737733 /* The heuristic is represented as compression type 0 */
@@ -807,32 +803,6 @@ static int alloc_workspace_manager(struct btrfs_fs_info *fs_info,
807803 return 0 ;
808804}
809805
810- static void btrfs_init_workspace_manager (struct btrfs_fs_info * fs_info , int type )
811- {
812- struct workspace_manager * wsm ;
813- struct list_head * workspace ;
814-
815- wsm = btrfs_compress_op [type ]-> workspace_manager ;
816- INIT_LIST_HEAD (& wsm -> idle_ws );
817- spin_lock_init (& wsm -> ws_lock );
818- atomic_set (& wsm -> total_ws , 0 );
819- init_waitqueue_head (& wsm -> ws_wait );
820-
821- /*
822- * Preallocate one workspace for each compression type so we can
823- * guarantee forward progress in the worst case
824- */
825- workspace = alloc_workspace (fs_info , type , 0 );
826- if (IS_ERR (workspace )) {
827- btrfs_warn (fs_info ,
828- "cannot preallocate compression workspace, will try later" );
829- } else {
830- atomic_set (& wsm -> total_ws , 1 );
831- wsm -> free_ws = 1 ;
832- list_add (workspace , & wsm -> idle_ws );
833- }
834- }
835-
836806static void free_workspace_manager (struct btrfs_fs_info * fs_info ,
837807 enum btrfs_compression_type type )
838808{
@@ -853,20 +823,6 @@ static void free_workspace_manager(struct btrfs_fs_info *fs_info,
853823 kfree (gwsm );
854824}
855825
856- static void btrfs_cleanup_workspace_manager (int type )
857- {
858- struct workspace_manager * wsman ;
859- struct list_head * ws ;
860-
861- wsman = btrfs_compress_op [type ]-> workspace_manager ;
862- while (!list_empty (& wsman -> idle_ws )) {
863- ws = wsman -> idle_ws .next ;
864- list_del (ws );
865- free_workspace (type , ws );
866- atomic_dec (& wsman -> total_ws );
867- }
868- }
869-
870826/*
871827 * This finds an available workspace or allocates a new one.
872828 * If it's not possible to allocate a new one, waits until there's one.
@@ -1192,11 +1148,6 @@ int __init btrfs_init_compress(void)
11921148 if (!compr_pool .shrinker )
11931149 return - ENOMEM ;
11941150
1195- btrfs_init_workspace_manager (NULL , BTRFS_COMPRESS_NONE );
1196- btrfs_init_workspace_manager (NULL , BTRFS_COMPRESS_ZLIB );
1197- btrfs_init_workspace_manager (NULL , BTRFS_COMPRESS_LZO );
1198- zstd_init_workspace_manager (NULL );
1199-
12001151 spin_lock_init (& compr_pool .lock );
12011152 INIT_LIST_HEAD (& compr_pool .list );
12021153 compr_pool .count = 0 ;
@@ -1217,10 +1168,6 @@ void __cold btrfs_exit_compress(void)
12171168 btrfs_compr_pool_scan (NULL , NULL );
12181169 shrinker_free (compr_pool .shrinker );
12191170
1220- btrfs_cleanup_workspace_manager (BTRFS_COMPRESS_NONE );
1221- btrfs_cleanup_workspace_manager (BTRFS_COMPRESS_ZLIB );
1222- btrfs_cleanup_workspace_manager (BTRFS_COMPRESS_LZO );
1223- zstd_cleanup_workspace_manager ();
12241171 bioset_exit (& btrfs_compressed_bioset );
12251172}
12261173
0 commit comments