aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dressler <danieru.dressler@gmail.com>2014-11-11 23:43:09 -0500
committerDavid Sterba <dsterba@suse.cz>2015-02-16 12:48:43 -0500
commitb7a0365ec7a0fb1d39113846fd34038af68ebd01 (patch)
tree20bc3d4adf09e22f0a7b7c2fb6b081dd60cd6d52
parenta742994aa2e271eb8cd8e043d276515ec858ed73 (diff)
Btrfs: ctree: reduce args where only fs_info used
This patch is part of a larger project to cleanup btrfs's internal usage of struct btrfs_root. Many functions take btrfs_root only to grab a pointer to fs_info. This causes programmers to ponder which root can be passed. Since only the fs_info is read affected functions can accept any root, except this is only obvious upon inspection. This patch reduces the specificty of such functions to accept the fs_info directly. This patch does not address the two functions in ctree.c (insert_ptr, and split_item) which only use root for BUG_ONs in ctree.c This patch affects the following functions: 1) fixup_low_keys 2) btrfs_set_item_key_safe Signed-off-by: Daniel Dressler <danieru.dressler@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--fs/btrfs/ctree.c27
-rw-r--r--fs/btrfs/ctree.h3
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/file.c8
4 files changed, 22 insertions, 18 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 993642199326..8c03c9222154 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3126,7 +3126,8 @@ again:
3126 * higher levels 3126 * higher levels
3127 * 3127 *
3128 */ 3128 */
3129static void fixup_low_keys(struct btrfs_root *root, struct btrfs_path *path, 3129static void fixup_low_keys(struct btrfs_fs_info *fs_info,
3130 struct btrfs_path *path,
3130 struct btrfs_disk_key *key, int level) 3131 struct btrfs_disk_key *key, int level)
3131{ 3132{
3132 int i; 3133 int i;
@@ -3137,7 +3138,7 @@ static void fixup_low_keys(struct btrfs_root *root, struct btrfs_path *path,
3137 if (!path->nodes[i]) 3138 if (!path->nodes[i])
3138 break; 3139 break;
3139 t = path->nodes[i]; 3140 t = path->nodes[i];
3140 tree_mod_log_set_node_key(root->fs_info, t, tslot, 1); 3141 tree_mod_log_set_node_key(fs_info, t, tslot, 1);
3141 btrfs_set_node_key(t, key, tslot); 3142 btrfs_set_node_key(t, key, tslot);
3142 btrfs_mark_buffer_dirty(path->nodes[i]); 3143 btrfs_mark_buffer_dirty(path->nodes[i]);
3143 if (tslot != 0) 3144 if (tslot != 0)
@@ -3151,7 +3152,8 @@ static void fixup_low_keys(struct btrfs_root *root, struct btrfs_path *path,
3151 * This function isn't completely safe. It's the caller's responsibility 3152 * This function isn't completely safe. It's the caller's responsibility
3152 * that the new key won't break the order 3153 * that the new key won't break the order
3153 */ 3154 */
3154void btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path, 3155void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
3156 struct btrfs_path *path,
3155 struct btrfs_key *new_key) 3157 struct btrfs_key *new_key)
3156{ 3158{
3157 struct btrfs_disk_key disk_key; 3159 struct btrfs_disk_key disk_key;
@@ -3173,7 +3175,7 @@ void btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path,
3173 btrfs_set_item_key(eb, &disk_key, slot); 3175 btrfs_set_item_key(eb, &disk_key, slot);
3174 btrfs_mark_buffer_dirty(eb); 3176 btrfs_mark_buffer_dirty(eb);
3175 if (slot == 0) 3177 if (slot == 0)
3176 fixup_low_keys(root, path, &disk_key, 1); 3178 fixup_low_keys(fs_info, path, &disk_key, 1);
3177} 3179}
3178 3180
3179/* 3181/*
@@ -3931,7 +3933,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
3931 clean_tree_block(trans, root, right); 3933 clean_tree_block(trans, root, right);
3932 3934
3933 btrfs_item_key(right, &disk_key, 0); 3935 btrfs_item_key(right, &disk_key, 0);
3934 fixup_low_keys(root, path, &disk_key, 1); 3936 fixup_low_keys(root->fs_info, path, &disk_key, 1);
3935 3937
3936 /* then fixup the leaf pointer in the path */ 3938 /* then fixup the leaf pointer in the path */
3937 if (path->slots[0] < push_items) { 3939 if (path->slots[0] < push_items) {
@@ -4168,6 +4170,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
4168 int mid; 4170 int mid;
4169 int slot; 4171 int slot;
4170 struct extent_buffer *right; 4172 struct extent_buffer *right;
4173 struct btrfs_fs_info *fs_info = root->fs_info;
4171 int ret = 0; 4174 int ret = 0;
4172 int wret; 4175 int wret;
4173 int split; 4176 int split;
@@ -4271,10 +4274,10 @@ again:
4271 btrfs_set_header_backref_rev(right, BTRFS_MIXED_BACKREF_REV); 4274 btrfs_set_header_backref_rev(right, BTRFS_MIXED_BACKREF_REV);
4272 btrfs_set_header_owner(right, root->root_key.objectid); 4275 btrfs_set_header_owner(right, root->root_key.objectid);
4273 btrfs_set_header_level(right, 0); 4276 btrfs_set_header_level(right, 0);
4274 write_extent_buffer(right, root->fs_info->fsid, 4277 write_extent_buffer(right, fs_info->fsid,
4275 btrfs_header_fsid(), BTRFS_FSID_SIZE); 4278 btrfs_header_fsid(), BTRFS_FSID_SIZE);
4276 4279
4277 write_extent_buffer(right, root->fs_info->chunk_tree_uuid, 4280 write_extent_buffer(right, fs_info->chunk_tree_uuid,
4278 btrfs_header_chunk_tree_uuid(right), 4281 btrfs_header_chunk_tree_uuid(right),
4279 BTRFS_UUID_SIZE); 4282 BTRFS_UUID_SIZE);
4280 4283
@@ -4297,7 +4300,7 @@ again:
4297 path->nodes[0] = right; 4300 path->nodes[0] = right;
4298 path->slots[0] = 0; 4301 path->slots[0] = 0;
4299 if (path->slots[1] == 0) 4302 if (path->slots[1] == 0)
4300 fixup_low_keys(root, path, &disk_key, 1); 4303 fixup_low_keys(fs_info, path, &disk_key, 1);
4301 } 4304 }
4302 btrfs_mark_buffer_dirty(right); 4305 btrfs_mark_buffer_dirty(right);
4303 return ret; 4306 return ret;
@@ -4615,7 +4618,7 @@ void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path,
4615 btrfs_set_disk_key_offset(&disk_key, offset + size_diff); 4618 btrfs_set_disk_key_offset(&disk_key, offset + size_diff);
4616 btrfs_set_item_key(leaf, &disk_key, slot); 4619 btrfs_set_item_key(leaf, &disk_key, slot);
4617 if (slot == 0) 4620 if (slot == 0)
4618 fixup_low_keys(root, path, &disk_key, 1); 4621 fixup_low_keys(root->fs_info, path, &disk_key, 1);
4619 } 4622 }
4620 4623
4621 item = btrfs_item_nr(slot); 4624 item = btrfs_item_nr(slot);
@@ -4716,7 +4719,7 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
4716 4719
4717 if (path->slots[0] == 0) { 4720 if (path->slots[0] == 0) {
4718 btrfs_cpu_key_to_disk(&disk_key, cpu_key); 4721 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
4719 fixup_low_keys(root, path, &disk_key, 1); 4722 fixup_low_keys(root->fs_info, path, &disk_key, 1);
4720 } 4723 }
4721 btrfs_unlock_up_safe(path, 1); 4724 btrfs_unlock_up_safe(path, 1);
4722 4725
@@ -4888,7 +4891,7 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path,
4888 struct btrfs_disk_key disk_key; 4891 struct btrfs_disk_key disk_key;
4889 4892
4890 btrfs_node_key(parent, &disk_key, 0); 4893 btrfs_node_key(parent, &disk_key, 0);
4891 fixup_low_keys(root, path, &disk_key, level + 1); 4894 fixup_low_keys(root->fs_info, path, &disk_key, level + 1);
4892 } 4895 }
4893 btrfs_mark_buffer_dirty(parent); 4896 btrfs_mark_buffer_dirty(parent);
4894} 4897}
@@ -4990,7 +4993,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
4990 struct btrfs_disk_key disk_key; 4993 struct btrfs_disk_key disk_key;
4991 4994
4992 btrfs_item_key(leaf, &disk_key, 0); 4995 btrfs_item_key(leaf, &disk_key, 0);
4993 fixup_low_keys(root, path, &disk_key, 1); 4996 fixup_low_keys(root->fs_info, path, &disk_key, 1);
4994 } 4997 }
4995 4998
4996 /* delete the leaf if it is mostly empty */ 4999 /* delete the leaf if it is mostly empty */
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b3dd55f52f71..216056c37940 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3483,7 +3483,8 @@ int btrfs_previous_item(struct btrfs_root *root,
3483 int type); 3483 int type);
3484int btrfs_previous_extent_item(struct btrfs_root *root, 3484int btrfs_previous_extent_item(struct btrfs_root *root,
3485 struct btrfs_path *path, u64 min_objectid); 3485 struct btrfs_path *path, u64 min_objectid);
3486void btrfs_set_item_key_safe(struct btrfs_root *root, struct btrfs_path *path, 3486void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
3487 struct btrfs_path *path,
3487 struct btrfs_key *new_key); 3488 struct btrfs_key *new_key);
3488struct extent_buffer *btrfs_root_node(struct btrfs_root *root); 3489struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
3489struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); 3490struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 84a2d1868271..fc003321bdd4 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -553,7 +553,7 @@ static noinline void truncate_one_csum(struct btrfs_root *root,
553 btrfs_truncate_item(root, path, new_size, 0); 553 btrfs_truncate_item(root, path, new_size, 0);
554 554
555 key->offset = end_byte; 555 key->offset = end_byte;
556 btrfs_set_item_key_safe(root, path, key); 556 btrfs_set_item_key_safe(root->fs_info, path, key);
557 } else { 557 } else {
558 BUG(); 558 BUG();
559 } 559 }
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e4090259569b..6b796f03de10 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -868,7 +868,7 @@ next_slot:
868 868
869 memcpy(&new_key, &key, sizeof(new_key)); 869 memcpy(&new_key, &key, sizeof(new_key));
870 new_key.offset = end; 870 new_key.offset = end;
871 btrfs_set_item_key_safe(root, path, &new_key); 871 btrfs_set_item_key_safe(root->fs_info, path, &new_key);
872 872
873 extent_offset += end - key.offset; 873 extent_offset += end - key.offset;
874 btrfs_set_file_extent_offset(leaf, fi, extent_offset); 874 btrfs_set_file_extent_offset(leaf, fi, extent_offset);
@@ -1126,7 +1126,7 @@ again:
1126 ino, bytenr, orig_offset, 1126 ino, bytenr, orig_offset,
1127 &other_start, &other_end)) { 1127 &other_start, &other_end)) {
1128 new_key.offset = end; 1128 new_key.offset = end;
1129 btrfs_set_item_key_safe(root, path, &new_key); 1129 btrfs_set_item_key_safe(root->fs_info, path, &new_key);
1130 fi = btrfs_item_ptr(leaf, path->slots[0], 1130 fi = btrfs_item_ptr(leaf, path->slots[0],
1131 struct btrfs_file_extent_item); 1131 struct btrfs_file_extent_item);
1132 btrfs_set_file_extent_generation(leaf, fi, 1132 btrfs_set_file_extent_generation(leaf, fi,
@@ -1160,7 +1160,7 @@ again:
1160 trans->transid); 1160 trans->transid);
1161 path->slots[0]++; 1161 path->slots[0]++;
1162 new_key.offset = start; 1162 new_key.offset = start;
1163 btrfs_set_item_key_safe(root, path, &new_key); 1163 btrfs_set_item_key_safe(root->fs_info, path, &new_key);
1164 1164
1165 fi = btrfs_item_ptr(leaf, path->slots[0], 1165 fi = btrfs_item_ptr(leaf, path->slots[0],
1166 struct btrfs_file_extent_item); 1166 struct btrfs_file_extent_item);
@@ -2169,7 +2169,7 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
2169 u64 num_bytes; 2169 u64 num_bytes;
2170 2170
2171 key.offset = offset; 2171 key.offset = offset;
2172 btrfs_set_item_key_safe(root, path, &key); 2172 btrfs_set_item_key_safe(root->fs_info, path, &key);
2173 fi = btrfs_item_ptr(leaf, path->slots[0], 2173 fi = btrfs_item_ptr(leaf, path->slots[0],
2174 struct btrfs_file_extent_item); 2174 struct btrfs_file_extent_item);
2175 num_bytes = btrfs_file_extent_num_bytes(leaf, fi) + end - 2175 num_bytes = btrfs_file_extent_num_bytes(leaf, fi) + end -