mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-15 16:24:21 +08:00
btrfs-progs: kill BUG_ON in readahead_tree_block()
David sent a quick patch that removed a BUG_ON(). I took a peek and found that the function was already leaking an eb ref and only returned 0. So this fixes the leak and makes the function void and fixes up the callers. Accidentally-motivated-by: David Sterba <dsterba@suse.cz> Signed-off-by: Zach Brown <zab@zabbo.net> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
cf8599c338
commit
977f2baf36
@ -1287,7 +1287,6 @@ static void reada_walk_down(struct btrfs_root *root,
|
||||
u32 nritems;
|
||||
u32 blocksize;
|
||||
int i;
|
||||
int ret;
|
||||
int level;
|
||||
|
||||
level = btrfs_header_level(node);
|
||||
@ -1299,9 +1298,7 @@ static void reada_walk_down(struct btrfs_root *root,
|
||||
for (i = slot; i < nritems; i++) {
|
||||
bytenr = btrfs_node_blockptr(node, i);
|
||||
ptr_gen = btrfs_node_ptr_generation(node, i);
|
||||
ret = readahead_tree_block(root, bytenr, blocksize, ptr_gen);
|
||||
if (ret)
|
||||
break;
|
||||
readahead_tree_block(root, bytenr, blocksize, ptr_gen);
|
||||
}
|
||||
}
|
||||
|
||||
|
25
disk-io.c
25
disk-io.c
@ -134,31 +134,26 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
|
||||
blocksize);
|
||||
}
|
||||
|
||||
int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||
u64 parent_transid)
|
||||
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||
u64 parent_transid)
|
||||
{
|
||||
int ret;
|
||||
struct extent_buffer *eb;
|
||||
u64 length;
|
||||
struct btrfs_multi_bio *multi = NULL;
|
||||
struct btrfs_device *device;
|
||||
|
||||
eb = btrfs_find_tree_block(root, bytenr, blocksize);
|
||||
if (eb && btrfs_buffer_uptodate(eb, parent_transid)) {
|
||||
free_extent_buffer(eb);
|
||||
return 0;
|
||||
if (!(eb && btrfs_buffer_uptodate(eb, parent_transid)) &&
|
||||
!btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
||||
bytenr, &length, &multi, 0, NULL)) {
|
||||
device = multi->stripes[0].dev;
|
||||
device->total_ios++;
|
||||
blocksize = min(blocksize, (u32)(64 * 1024));
|
||||
readahead(device->fd, multi->stripes[0].physical, blocksize);
|
||||
}
|
||||
|
||||
length = blocksize;
|
||||
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
||||
bytenr, &length, &multi, 0, NULL);
|
||||
BUG_ON(ret);
|
||||
device = multi->stripes[0].dev;
|
||||
device->total_ios++;
|
||||
blocksize = min(blocksize, (u32)(64 * 1024));
|
||||
readahead(device->fd, multi->stripes[0].physical, blocksize);
|
||||
free_extent_buffer(eb);
|
||||
kfree(multi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verify_parent_transid(struct extent_io_tree *io_tree,
|
||||
|
@ -48,8 +48,8 @@ struct btrfs_device;
|
||||
int read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, int mirror);
|
||||
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
|
||||
u32 blocksize, u64 parent_transid);
|
||||
int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||
u64 parent_transid);
|
||||
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||
u64 parent_transid);
|
||||
struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
|
||||
u64 bytenr, u32 blocksize);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user