Commit a5dee37d authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: deal with io_tree->mapping being NULL

I need to add infrastructure to allocate dummy extent buffers for running sanity
tests, and to do this I need to not have to worry about having an
address_mapping for an io_tree, so just fix up the places where we assume that
all io_tree's have a non-NULL ->mapping.  Thanks,
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 2ef1fed2
...@@ -77,13 +77,19 @@ void btrfs_leak_debug_check(void) ...@@ -77,13 +77,19 @@ void btrfs_leak_debug_check(void)
} }
} }
#define btrfs_debug_check_extent_io_range(inode, start, end) \ #define btrfs_debug_check_extent_io_range(tree, start, end) \
__btrfs_debug_check_extent_io_range(__func__, (inode), (start), (end)) __btrfs_debug_check_extent_io_range(__func__, (tree), (start), (end))
static inline void __btrfs_debug_check_extent_io_range(const char *caller, static inline void __btrfs_debug_check_extent_io_range(const char *caller,
struct inode *inode, u64 start, u64 end) struct extent_io_tree *tree, u64 start, u64 end)
{ {
u64 isize = i_size_read(inode); struct inode *inode;
u64 isize;
if (!tree->mapping)
return;
inode = tree->mapping->host;
isize = i_size_read(inode);
if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) { if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
printk_ratelimited(KERN_DEBUG printk_ratelimited(KERN_DEBUG
"btrfs: %s: ino %llu isize %llu odd range [%llu,%llu]\n", "btrfs: %s: ino %llu isize %llu odd range [%llu,%llu]\n",
...@@ -124,6 +130,8 @@ static noinline void flush_write_bio(void *data); ...@@ -124,6 +130,8 @@ static noinline void flush_write_bio(void *data);
static inline struct btrfs_fs_info * static inline struct btrfs_fs_info *
tree_fs_info(struct extent_io_tree *tree) tree_fs_info(struct extent_io_tree *tree)
{ {
if (!tree->mapping)
return NULL;
return btrfs_sb(tree->mapping->host->i_sb); return btrfs_sb(tree->mapping->host->i_sb);
} }
...@@ -570,7 +578,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -570,7 +578,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
int err; int err;
int clear = 0; int clear = 0;
btrfs_debug_check_extent_io_range(tree->mapping->host, start, end); btrfs_debug_check_extent_io_range(tree, start, end);
if (bits & EXTENT_DELALLOC) if (bits & EXTENT_DELALLOC)
bits |= EXTENT_NORESERVE; bits |= EXTENT_NORESERVE;
...@@ -730,7 +738,7 @@ static void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -730,7 +738,7 @@ static void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
struct extent_state *state; struct extent_state *state;
struct rb_node *node; struct rb_node *node;
btrfs_debug_check_extent_io_range(tree->mapping->host, start, end); btrfs_debug_check_extent_io_range(tree, start, end);
spin_lock(&tree->lock); spin_lock(&tree->lock);
again: again:
...@@ -817,7 +825,7 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -817,7 +825,7 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u64 last_start; u64 last_start;
u64 last_end; u64 last_end;
btrfs_debug_check_extent_io_range(tree->mapping->host, start, end); btrfs_debug_check_extent_io_range(tree, start, end);
bits |= EXTENT_FIRST_DELALLOC; bits |= EXTENT_FIRST_DELALLOC;
again: again:
...@@ -1043,7 +1051,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -1043,7 +1051,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u64 last_start; u64 last_start;
u64 last_end; u64 last_end;
btrfs_debug_check_extent_io_range(tree->mapping->host, start, end); btrfs_debug_check_extent_io_range(tree, start, end);
again: again:
if (!prealloc && (mask & __GFP_WAIT)) { if (!prealloc && (mask & __GFP_WAIT)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment