Skip to contentSkip to conversation

btrfs: opencode chunk locking, remove helpers

PATCH New David Sterba 1 participant 1 message Dec 6, 2016 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH v2 1/1 btrfs: opencode chunk locking, remove helpers

The helpers are trivial and we don't use them consistently.

---

Refreshed on top of Jeff's cleanup regarding passing fs_info and root to various functions.

 fs/btrfs/disk-io.c          |  4 +--
 fs/btrfs/extent-tree.c      |  8 +++---
 fs/btrfs/free-space-cache.c |  4 +--
 fs/btrfs/volumes.c          | 70 ++++++++++++++++++++++-----------------------
 fs/btrfs/volumes.h          | 10 -------
 5 files changed, 43 insertions(+), 53 deletions(-)
fs/btrfs/disk-io.c +2 -2
index 196f1aafcea9..848d5e1c0585 100644
@@ -4003,7 +4003,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)
 	__btrfs_free_block_rsv(root->orphan_block_rsv);
 	root->orphan_block_rsv = NULL;
 
-	lock_chunks(fs_info);
+	mutex_lock(&fs_info->chunk_mutex);
 	while (!list_empty(&fs_info->pinned_chunks)) {
 		struct extent_map *em;
 
@@ -4012,7 +4012,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)
 		list_del_init(&em->list);
 		free_extent_map(em);
 	}
-	unlock_chunks(fs_info);
+	mutex_unlock(&fs_info->chunk_mutex);
 }
 
 int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
fs/btrfs/extent-tree.c +4 -4
index 2825019cd18f..e97302f437a1 100644
@@ -9419,9 +9419,9 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,
 out:
 	if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
 		alloc_flags = update_block_group_flags(fs_info, cache->flags);
-		lock_chunks(fs_info);
+		mutex_lock(&fs_info->chunk_mutex);
 		check_system_chunk(trans, fs_info, alloc_flags);
-		unlock_chunks(fs_info);
+		mutex_unlock(&fs_info->chunk_mutex);
 	}
 	mutex_unlock(&fs_info->ro_block_group_mutex);
 
@@ -10458,7 +10458,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
 
 	memcpy(&key, &block_group->key, sizeof(key));
 
-	lock_chunks(fs_info);
+	mutex_lock(&fs_info->chunk_mutex);
 	if (!list_empty(&em->list)) {
 		/* We're in the transaction->pending_chunks list. */
 		free_extent_map(em);
@@ -10526,7 +10526,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
 		free_extent_map(em);
 	}
 
-	unlock_chunks(fs_info);
+	mutex_unlock(&fs_info->chunk_mutex);
 
 	ret = remove_block_group_free_space(trans, fs_info, block_group);
 	if (ret)
fs/btrfs/free-space-cache.c +2 -2
index 2e8445e4ffa3..7015892c9ee8 100644
@@ -3352,7 +3352,7 @@ void btrfs_put_block_group_trimming(struct btrfs_block_group_cache *block_group)
 	spin_unlock(&block_group->lock);
 
 	if (cleanup) {
-		lock_chunks(fs_info);
+		mutex_lock(&fs_info->chunk_mutex);
 		em_tree = &fs_info->mapping_tree.map_tree;
 		write_lock(&em_tree->lock);
 		em = lookup_extent_mapping(em_tree, block_group->key.objectid,
@@ -3364,7 +3364,7 @@ void btrfs_put_block_group_trimming(struct btrfs_block_group_cache *block_group)
 		 */
 		remove_extent_mapping(em_tree, em);
 		write_unlock(&em_tree->lock);
-		unlock_chunks(fs_info);
+		mutex_unlock(&fs_info->chunk_mutex);
 
 		/* once for us and once for the tree */
 		free_extent_map(em);
fs/btrfs/volumes.c +35 -35

250 lines not on this page · raw message

fs/btrfs/volumes.h +0 -10
index 18b4449fa5a5..811328984702 100644
@@ -534,16 +534,6 @@ void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);
 void btrfs_update_commit_device_bytes_used(struct btrfs_fs_info *fs_info,
 					struct btrfs_transaction *transaction);
 
-static inline void lock_chunks(struct btrfs_fs_info *fs_info)
-{
-	mutex_lock(&fs_info->chunk_mutex);
-}
-
-static inline void unlock_chunks(struct btrfs_fs_info *fs_info)
-{
-	mutex_unlock(&fs_info->chunk_mutex);
-}
-
 struct list_head *btrfs_get_fs_uuids(void);
 void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
 void btrfs_reset_fs_info_ptr(struct btrfs_fs_info *fs_info);
Signature · 1 line
2.10.1