extent_io.c (171170c1c5625cab9687ecf6714e09e0c8a6ed3c) extent_io.c (c1c9ff7c94e83fae89a742df74db51156869bad5)
1#include <linux/bitops.h>
2#include <linux/slab.h>
3#include <linux/bio.h>
4#include <linux/mm.h>
5#include <linux/pagemap.h>
6#include <linux/page-flags.h>
7#include <linux/spinlock.h>
8#include <linux/blkdev.h>

--- 47 unchanged lines hidden (view full) ---

56{
57 struct extent_state *state;
58 struct extent_buffer *eb;
59
60 while (!list_empty(&states)) {
61 state = list_entry(states.next, struct extent_state, leak_list);
62 printk(KERN_ERR "btrfs state leak: start %llu end %llu "
63 "state %lu in tree %p refs %d\n",
1#include <linux/bitops.h>
2#include <linux/slab.h>
3#include <linux/bio.h>
4#include <linux/mm.h>
5#include <linux/pagemap.h>
6#include <linux/page-flags.h>
7#include <linux/spinlock.h>
8#include <linux/blkdev.h>

--- 47 unchanged lines hidden (view full) ---

56{
57 struct extent_state *state;
58 struct extent_buffer *eb;
59
60 while (!list_empty(&states)) {
61 state = list_entry(states.next, struct extent_state, leak_list);
62 printk(KERN_ERR "btrfs state leak: start %llu end %llu "
63 "state %lu in tree %p refs %d\n",
64 (unsigned long long)state->start,
65 (unsigned long long)state->end,
66 state->state, state->tree, atomic_read(&state->refs));
64 state->start, state->end, state->state, state->tree,
65 atomic_read(&state->refs));
67 list_del(&state->leak_list);
68 kmem_cache_free(extent_state_cache, state);
69 }
70
71 while (!list_empty(&buffers)) {
72 eb = list_entry(buffers.next, struct extent_buffer, leak_list);
73 printk(KERN_ERR "btrfs buffer leak start %llu len %lu "
66 list_del(&state->leak_list);
67 kmem_cache_free(extent_state_cache, state);
68 }
69
70 while (!list_empty(&buffers)) {
71 eb = list_entry(buffers.next, struct extent_buffer, leak_list);
72 printk(KERN_ERR "btrfs buffer leak start %llu len %lu "
74 "refs %d\n", (unsigned long long)eb->start,
75 eb->len, atomic_read(&eb->refs));
73 "refs %d\n",
74 eb->start, eb->len, atomic_read(&eb->refs));
76 list_del(&eb->leak_list);
77 kmem_cache_free(extent_buffer_cache, eb);
78 }
79}
80
81#define btrfs_debug_check_extent_io_range(inode, start, end) \
82 __btrfs_debug_check_extent_io_range(__func__, (inode), (start), (end))
83static inline void __btrfs_debug_check_extent_io_range(const char *caller,
84 struct inode *inode, u64 start, u64 end)
85{
86 u64 isize = i_size_read(inode);
87
88 if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
89 printk_ratelimited(KERN_DEBUG
90 "btrfs: %s: ino %llu isize %llu odd range [%llu,%llu]\n",
75 list_del(&eb->leak_list);
76 kmem_cache_free(extent_buffer_cache, eb);
77 }
78}
79
80#define btrfs_debug_check_extent_io_range(inode, start, end) \
81 __btrfs_debug_check_extent_io_range(__func__, (inode), (start), (end))
82static inline void __btrfs_debug_check_extent_io_range(const char *caller,
83 struct inode *inode, u64 start, u64 end)
84{
85 u64 isize = i_size_read(inode);
86
87 if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
88 printk_ratelimited(KERN_DEBUG
89 "btrfs: %s: ino %llu isize %llu odd range [%llu,%llu]\n",
91 caller,
92 (unsigned long long)btrfs_ino(inode),
93 (unsigned long long)isize,
94 (unsigned long long)start,
95 (unsigned long long)end);
90 caller, btrfs_ino(inode), isize, start, end);
96 }
97}
98#else
99#define btrfs_leak_debug_add(new, head) do {} while (0)
100#define btrfs_leak_debug_del(entry) do {} while (0)
101#define btrfs_leak_debug_check() do {} while (0)
102#define btrfs_debug_check_extent_io_range(c, s, e) do {} while (0)
103#endif

--- 279 unchanged lines hidden (view full) ---

383static int insert_state(struct extent_io_tree *tree,
384 struct extent_state *state, u64 start, u64 end,
385 unsigned long *bits)
386{
387 struct rb_node *node;
388
389 if (end < start)
390 WARN(1, KERN_ERR "btrfs end < start %llu %llu\n",
91 }
92}
93#else
94#define btrfs_leak_debug_add(new, head) do {} while (0)
95#define btrfs_leak_debug_del(entry) do {} while (0)
96#define btrfs_leak_debug_check() do {} while (0)
97#define btrfs_debug_check_extent_io_range(c, s, e) do {} while (0)
98#endif

--- 279 unchanged lines hidden (view full) ---

378static int insert_state(struct extent_io_tree *tree,
379 struct extent_state *state, u64 start, u64 end,
380 unsigned long *bits)
381{
382 struct rb_node *node;
383
384 if (end < start)
385 WARN(1, KERN_ERR "btrfs end < start %llu %llu\n",
391 (unsigned long long)end,
392 (unsigned long long)start);
386 end, start);
393 state->start = start;
394 state->end = end;
395
396 set_state_bits(tree, state, bits);
397
398 node = tree_insert(&tree->state, end, &state->rb_node);
399 if (node) {
400 struct extent_state *found;
401 found = rb_entry(node, struct extent_state, rb_node);
402 printk(KERN_ERR "btrfs found node %llu %llu on insert of "
387 state->start = start;
388 state->end = end;
389
390 set_state_bits(tree, state, bits);
391
392 node = tree_insert(&tree->state, end, &state->rb_node);
393 if (node) {
394 struct extent_state *found;
395 found = rb_entry(node, struct extent_state, rb_node);
396 printk(KERN_ERR "btrfs found node %llu %llu on insert of "
403 "%llu %llu\n", (unsigned long long)found->start,
404 (unsigned long long)found->end,
405 (unsigned long long)start, (unsigned long long)end);
397 "%llu %llu\n",
398 found->start, found->end, start, end);
406 return -EEXIST;
407 }
408 state->tree = tree;
409 merge_state(tree, state);
410 return 0;
411}
412
413static void split_cb(struct extent_io_tree *tree, struct extent_state *orig,

--- 2879 unchanged lines hidden (view full) ---

3293 SetPageError(page);
3294 } else {
3295 unsigned long max_nr = end_index + 1;
3296
3297 set_range_writeback(tree, cur, cur + iosize - 1);
3298 if (!PageWriteback(page)) {
3299 printk(KERN_ERR "btrfs warning page %lu not "
3300 "writeback, cur %llu end %llu\n",
399 return -EEXIST;
400 }
401 state->tree = tree;
402 merge_state(tree, state);
403 return 0;
404}
405
406static void split_cb(struct extent_io_tree *tree, struct extent_state *orig,

--- 2879 unchanged lines hidden (view full) ---

3286 SetPageError(page);
3287 } else {
3288 unsigned long max_nr = end_index + 1;
3289
3290 set_range_writeback(tree, cur, cur + iosize - 1);
3291 if (!PageWriteback(page)) {
3292 printk(KERN_ERR "btrfs warning page %lu not "
3293 "writeback, cur %llu end %llu\n",
3301 page->index, (unsigned long long)cur,
3302 (unsigned long long)end);
3294 page->index, cur, end);
3303 }
3304
3305 ret = submit_extent_page(write_flags, tree, page,
3306 sector, iosize, pg_offset,
3307 bdev, &epd->bio, max_nr,
3308 end_bio_extent_writepage,
3309 0, 0, 0);
3310 if (ret)

--- 1607 unchanged lines hidden (view full) ---

4918 *map_start = 0;
4919 } else {
4920 offset = 0;
4921 *map_start = ((u64)i << PAGE_CACHE_SHIFT) - start_offset;
4922 }
4923
4924 if (start + min_len > eb->len) {
4925 WARN(1, KERN_ERR "btrfs bad mapping eb start %llu len %lu, "
3295 }
3296
3297 ret = submit_extent_page(write_flags, tree, page,
3298 sector, iosize, pg_offset,
3299 bdev, &epd->bio, max_nr,
3300 end_bio_extent_writepage,
3301 0, 0, 0);
3302 if (ret)

--- 1607 unchanged lines hidden (view full) ---

4910 *map_start = 0;
4911 } else {
4912 offset = 0;
4913 *map_start = ((u64)i << PAGE_CACHE_SHIFT) - start_offset;
4914 }
4915
4916 if (start + min_len > eb->len) {
4917 WARN(1, KERN_ERR "btrfs bad mapping eb start %llu len %lu, "
4926 "wanted %lu %lu\n", (unsigned long long)eb->start,
4927 eb->len, start, min_len);
4918 "wanted %lu %lu\n",
4919 eb->start, eb->len, start, min_len);
4928 return -EINVAL;
4929 }
4930
4931 p = extent_buffer_page(eb, i);
4932 kaddr = page_address(p);
4933 *map = kaddr + offset;
4934 *map_len = PAGE_CACHE_SIZE - offset;
4935 return 0;

--- 310 unchanged lines hidden ---
4920 return -EINVAL;
4921 }
4922
4923 p = extent_buffer_page(eb, i);
4924 kaddr = page_address(p);
4925 *map = kaddr + offset;
4926 *map_len = PAGE_CACHE_SIZE - offset;
4927 return 0;

--- 310 unchanged lines hidden ---