@@ -3118,7 +3118,7 @@ static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
31183118 * we release the path used to search the chunk/dev tree and before
31193119 * the current task acquires this mutex and calls us.
31203120 */
3121- lockdep_assert_held (& fs_info -> delete_unused_bgs_mutex );
3121+ lockdep_assert_held (& fs_info -> reclaim_bgs_lock );
31223122
31233123 /* step one, relocate all the extents inside this chunk */
31243124 btrfs_scrub_pause (fs_info );
@@ -3188,18 +3188,18 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
31883188 key .type = BTRFS_CHUNK_ITEM_KEY ;
31893189
31903190 while (1 ) {
3191- mutex_lock (& fs_info -> delete_unused_bgs_mutex );
3191+ mutex_lock (& fs_info -> reclaim_bgs_lock );
31923192 ret = btrfs_search_slot (NULL , chunk_root , & key , path , 0 , 0 );
31933193 if (ret < 0 ) {
3194- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3194+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
31953195 goto error ;
31963196 }
31973197 BUG_ON (ret == 0 ); /* Corruption */
31983198
31993199 ret = btrfs_previous_item (chunk_root , path , key .objectid ,
32003200 key .type );
32013201 if (ret )
3202- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3202+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
32033203 if (ret < 0 )
32043204 goto error ;
32053205 if (ret > 0 )
@@ -3220,7 +3220,7 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
32203220 else
32213221 BUG_ON (ret );
32223222 }
3223- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3223+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
32243224
32253225 if (found_key .offset == 0 )
32263226 break ;
@@ -3760,10 +3760,10 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
37603760 goto error ;
37613761 }
37623762
3763- mutex_lock (& fs_info -> delete_unused_bgs_mutex );
3763+ mutex_lock (& fs_info -> reclaim_bgs_lock );
37643764 ret = btrfs_search_slot (NULL , chunk_root , & key , path , 0 , 0 );
37653765 if (ret < 0 ) {
3766- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3766+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
37673767 goto error ;
37683768 }
37693769
@@ -3777,7 +3777,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
37773777 ret = btrfs_previous_item (chunk_root , path , 0 ,
37783778 BTRFS_CHUNK_ITEM_KEY );
37793779 if (ret ) {
3780- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3780+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
37813781 ret = 0 ;
37823782 break ;
37833783 }
@@ -3787,7 +3787,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
37873787 btrfs_item_key_to_cpu (leaf , & found_key , slot );
37883788
37893789 if (found_key .objectid != key .objectid ) {
3790- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3790+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
37913791 break ;
37923792 }
37933793
@@ -3804,12 +3804,12 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
38043804
38053805 btrfs_release_path (path );
38063806 if (!ret ) {
3807- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3807+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
38083808 goto loop ;
38093809 }
38103810
38113811 if (counting ) {
3812- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3812+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
38133813 spin_lock (& fs_info -> balance_lock );
38143814 bctl -> stat .expected ++ ;
38153815 spin_unlock (& fs_info -> balance_lock );
@@ -3834,7 +3834,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
38343834 count_meta < bctl -> meta .limit_min )
38353835 || ((chunk_type & BTRFS_BLOCK_GROUP_SYSTEM ) &&
38363836 count_sys < bctl -> sys .limit_min )) {
3837- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3837+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
38383838 goto loop ;
38393839 }
38403840
@@ -3848,15 +3848,15 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
38483848 ret = btrfs_may_alloc_data_chunk (fs_info ,
38493849 found_key .offset );
38503850 if (ret < 0 ) {
3851- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3851+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
38523852 goto error ;
38533853 } else if (ret == 1 ) {
38543854 chunk_reserved = 1 ;
38553855 }
38563856 }
38573857
38583858 ret = btrfs_relocate_chunk (fs_info , found_key .offset );
3859- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
3859+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
38603860 if (ret == - ENOSPC ) {
38613861 enospc_errors ++ ;
38623862 } else if (ret == - ETXTBSY ) {
@@ -4741,16 +4741,16 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
47414741 key .type = BTRFS_DEV_EXTENT_KEY ;
47424742
47434743 do {
4744- mutex_lock (& fs_info -> delete_unused_bgs_mutex );
4744+ mutex_lock (& fs_info -> reclaim_bgs_lock );
47454745 ret = btrfs_search_slot (NULL , root , & key , path , 0 , 0 );
47464746 if (ret < 0 ) {
4747- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4747+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47484748 goto done ;
47494749 }
47504750
47514751 ret = btrfs_previous_item (root , path , 0 , key .type );
47524752 if (ret ) {
4753- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4753+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47544754 if (ret < 0 )
47554755 goto done ;
47564756 ret = 0 ;
@@ -4763,7 +4763,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
47634763 btrfs_item_key_to_cpu (l , & key , path -> slots [0 ]);
47644764
47654765 if (key .objectid != device -> devid ) {
4766- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4766+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47674767 btrfs_release_path (path );
47684768 break ;
47694769 }
@@ -4772,7 +4772,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
47724772 length = btrfs_dev_extent_length (l , dev_extent );
47734773
47744774 if (key .offset + length <= new_size ) {
4775- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4775+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47764776 btrfs_release_path (path );
47774777 break ;
47784778 }
@@ -4788,12 +4788,12 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
47884788 */
47894789 ret = btrfs_may_alloc_data_chunk (fs_info , chunk_offset );
47904790 if (ret < 0 ) {
4791- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4791+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47924792 goto done ;
47934793 }
47944794
47954795 ret = btrfs_relocate_chunk (fs_info , chunk_offset );
4796- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
4796+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
47974797 if (ret == - ENOSPC ) {
47984798 failed ++ ;
47994799 } else if (ret ) {
@@ -8068,7 +8068,7 @@ static int relocating_repair_kthread(void *data)
80688068 return - EBUSY ;
80698069 }
80708070
8071- mutex_lock (& fs_info -> delete_unused_bgs_mutex );
8071+ mutex_lock (& fs_info -> reclaim_bgs_lock );
80728072
80738073 /* Ensure block group still exists */
80748074 cache = btrfs_lookup_block_group (fs_info , target );
@@ -8090,7 +8090,7 @@ static int relocating_repair_kthread(void *data)
80908090out :
80918091 if (cache )
80928092 btrfs_put_block_group (cache );
8093- mutex_unlock (& fs_info -> delete_unused_bgs_mutex );
8093+ mutex_unlock (& fs_info -> reclaim_bgs_lock );
80948094 btrfs_exclop_finish (fs_info );
80958095
80968096 return ret ;
0 commit comments