aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2012-03-01 08:56:26 -0500
committerDavid Sterba <dsterba@suse.cz>2012-03-21 20:45:34 -0400
commit143bede527b054a271053f41bfaca2b57baa9408 (patch)
tree95c71d3705c73bf98e7a1547da35e70a44703c1e /fs/btrfs
parentffd7b33944f4573a063af7a55f8a5199c8185665 (diff)
btrfs: return void in functions without error conditions
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/async-thread.c15
-rw-r--r--fs/btrfs/async-thread.h4
-rw-r--r--fs/btrfs/compression.c8
-rw-r--r--fs/btrfs/compression.h2
-rw-r--r--fs/btrfs/ctree.c200
-rw-r--r--fs/btrfs/ctree.h45
-rw-r--r--fs/btrfs/delayed-inode.c6
-rw-r--r--fs/btrfs/delayed-ref.c27
-rw-r--r--fs/btrfs/dir-item.c9
-rw-r--r--fs/btrfs/disk-io.c39
-rw-r--r--fs/btrfs/disk-io.h2
-rw-r--r--fs/btrfs/extent-tree.c60
-rw-r--r--fs/btrfs/extent_io.c35
-rw-r--r--fs/btrfs/extent_io.h4
-rw-r--r--fs/btrfs/file-item.c25
-rw-r--r--fs/btrfs/inode-item.c4
-rw-r--r--fs/btrfs/inode.c7
-rw-r--r--fs/btrfs/locking.c6
-rw-r--r--fs/btrfs/locking.h4
-rw-r--r--fs/btrfs/ordered-data.c48
-rw-r--r--fs/btrfs/ordered-data.h24
-rw-r--r--fs/btrfs/scrub.c36
-rw-r--r--fs/btrfs/super.c5
-rw-r--r--fs/btrfs/transaction.c3
-rw-r--r--fs/btrfs/tree-log.c17
-rw-r--r--fs/btrfs/tree-log.h2
-rw-r--r--fs/btrfs/volumes.c18
-rw-r--r--fs/btrfs/volumes.h4
28 files changed, 249 insertions, 410 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 0cc20b35c1c4..42704149b723 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -171,11 +171,11 @@ out:
171 spin_unlock_irqrestore(&workers->lock, flags); 171 spin_unlock_irqrestore(&workers->lock, flags);
172} 172}
173 173
174static noinline int run_ordered_completions(struct btrfs_workers *workers, 174static noinline void run_ordered_completions(struct btrfs_workers *workers,
175 struct btrfs_work *work) 175 struct btrfs_work *work)
176{ 176{
177 if (!workers->ordered) 177 if (!workers->ordered)
178 return 0; 178 return;
179 179
180 set_bit(WORK_DONE_BIT, &work->flags); 180 set_bit(WORK_DONE_BIT, &work->flags);
181 181
@@ -213,7 +213,6 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers,
213 } 213 }
214 214
215 spin_unlock(&workers->order_lock); 215 spin_unlock(&workers->order_lock);
216 return 0;
217} 216}
218 217
219static void put_worker(struct btrfs_worker_thread *worker) 218static void put_worker(struct btrfs_worker_thread *worker)
@@ -399,7 +398,7 @@ again:
399/* 398/*
400 * this will wait for all the worker threads to shutdown 399 * this will wait for all the worker threads to shutdown
401 */ 400 */
402int btrfs_stop_workers(struct btrfs_workers *workers) 401void btrfs_stop_workers(struct btrfs_workers *workers)
403{ 402{
404 struct list_head *cur; 403 struct list_head *cur;
405 struct btrfs_worker_thread *worker; 404 struct btrfs_worker_thread *worker;
@@ -427,7 +426,6 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
427 put_worker(worker); 426 put_worker(worker);
428 } 427 }
429 spin_unlock_irq(&workers->lock); 428 spin_unlock_irq(&workers->lock);
430 return 0;
431} 429}
432 430
433/* 431/*
@@ -615,14 +613,14 @@ found:
615 * it was taken from. It is intended for use with long running work functions 613 * it was taken from. It is intended for use with long running work functions
616 * that make some progress and want to give the cpu up for others. 614 * that make some progress and want to give the cpu up for others.
617 */ 615 */
618int btrfs_requeue_work(struct btrfs_work *work) 616void btrfs_requeue_work(struct btrfs_work *work)
619{ 617{
620 struct btrfs_worker_thread *worker = work->worker; 618 struct btrfs_worker_thread *worker = work->worker;
621 unsigned long flags; 619 unsigned long flags;
622 int wake = 0; 620 int wake = 0;
623 621
624 if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags)) 622 if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags))
625 goto out; 623 return;
626 624
627 spin_lock_irqsave(&worker->lock, flags); 625 spin_lock_irqsave(&worker->lock, flags);
628 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags)) 626 if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags))
@@ -649,9 +647,6 @@ int btrfs_requeue_work(struct btrfs_work *work)
649 if (wake) 647 if (wake)
650 wake_up_process(worker->task); 648 wake_up_process(worker->task);
651 spin_unlock_irqrestore(&worker->lock, flags); 649 spin_unlock_irqrestore(&worker->lock, flags);
652out:
653
654 return 0;
655} 650}
656 651
657void btrfs_set_work_high_prio(struct btrfs_work *work) 652void btrfs_set_work_high_prio(struct btrfs_work *work)
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index f34cc31fa3c9..063698b90ce2 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -111,9 +111,9 @@ struct btrfs_workers {
111 111
112void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); 112void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work);
113int btrfs_start_workers(struct btrfs_workers *workers); 113int btrfs_start_workers(struct btrfs_workers *workers);
114int btrfs_stop_workers(struct btrfs_workers *workers); 114void btrfs_stop_workers(struct btrfs_workers *workers);
115void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max, 115void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max,
116 struct btrfs_workers *async_starter); 116 struct btrfs_workers *async_starter);
117int btrfs_requeue_work(struct btrfs_work *work); 117void btrfs_requeue_work(struct btrfs_work *work);
118void btrfs_set_work_high_prio(struct btrfs_work *work); 118void btrfs_set_work_high_prio(struct btrfs_work *work);
119#endif 119#endif
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index d02c27cd14c7..0ed1ed22775f 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -226,8 +226,8 @@ out:
226 * Clear the writeback bits on all of the file 226 * Clear the writeback bits on all of the file
227 * pages for a compressed write 227 * pages for a compressed write
228 */ 228 */
229static noinline int end_compressed_writeback(struct inode *inode, u64 start, 229static noinline void end_compressed_writeback(struct inode *inode, u64 start,
230 unsigned long ram_size) 230 unsigned long ram_size)
231{ 231{
232 unsigned long index = start >> PAGE_CACHE_SHIFT; 232 unsigned long index = start >> PAGE_CACHE_SHIFT;
233 unsigned long end_index = (start + ram_size - 1) >> PAGE_CACHE_SHIFT; 233 unsigned long end_index = (start + ram_size - 1) >> PAGE_CACHE_SHIFT;
@@ -253,7 +253,6 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start,
253 index += ret; 253 index += ret;
254 } 254 }
255 /* the inode may be gone now */ 255 /* the inode may be gone now */
256 return 0;
257} 256}
258 257
259/* 258/*
@@ -734,7 +733,7 @@ struct btrfs_compress_op *btrfs_compress_op[] = {
734 &btrfs_lzo_compress, 733 &btrfs_lzo_compress,
735}; 734};
736 735
737int __init btrfs_init_compress(void) 736void __init btrfs_init_compress(void)
738{ 737{
739 int i; 738 int i;
740 739
@@ -744,7 +743,6 @@ int __init btrfs_init_compress(void)
744 atomic_set(&comp_alloc_workspace[i], 0); 743 atomic_set(&comp_alloc_workspace[i], 0);
745 init_waitqueue_head(&comp_workspace_wait[i]); 744 init_waitqueue_head(&comp_workspace_wait[i]);
746 } 745 }
747 return 0;
748} 746}
749 747
750/* 748/*
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index a12059f4f0fd..9afb0a62ae82 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -19,7 +19,7 @@
19#ifndef __BTRFS_COMPRESSION_ 19#ifndef __BTRFS_COMPRESSION_
20#define __BTRFS_COMPRESSION_ 20#define __BTRFS_COMPRESSION_
21 21
22int btrfs_init_compress(void); 22void btrfs_init_compress(void);
23void btrfs_exit_compress(void); 23void btrfs_exit_compress(void);
24 24
25int btrfs_compress_pages(int type, struct address_space *mapping, 25int btrfs_compress_pages(int type, struct address_space *mapping,
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 0639a555e16e..9d472c2a8de8 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -36,7 +36,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
36 struct btrfs_root *root, 36 struct btrfs_root *root,
37 struct extent_buffer *dst_buf, 37 struct extent_buffer *dst_buf,
38 struct extent_buffer *src_buf); 38 struct extent_buffer *src_buf);
39static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, 39static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
40 struct btrfs_path *path, int level, int slot); 40 struct btrfs_path *path, int level, int slot);
41 41
42struct btrfs_path *btrfs_alloc_path(void) 42struct btrfs_path *btrfs_alloc_path(void)
@@ -1010,10 +1010,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1010 if (btrfs_header_nritems(right) == 0) { 1010 if (btrfs_header_nritems(right) == 0) {
1011 clean_tree_block(trans, root, right); 1011 clean_tree_block(trans, root, right);
1012 btrfs_tree_unlock(right); 1012 btrfs_tree_unlock(right);
1013 wret = del_ptr(trans, root, path, level + 1, pslot + 1013 del_ptr(trans, root, path, level + 1, pslot + 1);
1014 1);
1015 if (wret)
1016 ret = wret;
1017 root_sub_used(root, right->len); 1014 root_sub_used(root, right->len);
1018 btrfs_free_tree_block(trans, root, right, 0, 1, 0); 1015 btrfs_free_tree_block(trans, root, right, 0, 1, 0);
1019 free_extent_buffer(right); 1016 free_extent_buffer(right);
@@ -1051,9 +1048,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1051 if (btrfs_header_nritems(mid) == 0) { 1048 if (btrfs_header_nritems(mid) == 0) {
1052 clean_tree_block(trans, root, mid); 1049 clean_tree_block(trans, root, mid);
1053 btrfs_tree_unlock(mid); 1050 btrfs_tree_unlock(mid);
1054 wret = del_ptr(trans, root, path, level + 1, pslot); 1051 del_ptr(trans, root, path, level + 1, pslot);
1055 if (wret)
1056 ret = wret;
1057 root_sub_used(root, mid->len); 1052 root_sub_used(root, mid->len);
1058 btrfs_free_tree_block(trans, root, mid, 0, 1, 0); 1053 btrfs_free_tree_block(trans, root, mid, 0, 1, 0);
1059 free_extent_buffer(mid); 1054 free_extent_buffer(mid);
@@ -1881,15 +1876,12 @@ done:
1881 * fixing up pointers when a given leaf/node is not in slot 0 of the 1876 * fixing up pointers when a given leaf/node is not in slot 0 of the
1882 * higher levels 1877 * higher levels
1883 * 1878 *
1884 * If this fails to write a tree block, it returns -1, but continues
1885 * fixing up the blocks in ram so the tree is consistent.
1886 */ 1879 */
1887static int fixup_low_keys(struct btrfs_trans_handle *trans, 1880static void fixup_low_keys(struct btrfs_trans_handle *trans,
1888 struct btrfs_root *root, struct btrfs_path *path, 1881 struct btrfs_root *root, struct btrfs_path *path,
1889 struct btrfs_disk_key *key, int level) 1882 struct btrfs_disk_key *key, int level)
1890{ 1883{
1891 int i; 1884 int i;
1892 int ret = 0;
1893 struct extent_buffer *t; 1885 struct extent_buffer *t;
1894 1886
1895 for (i = level; i < BTRFS_MAX_LEVEL; i++) { 1887 for (i = level; i < BTRFS_MAX_LEVEL; i++) {
@@ -1902,7 +1894,6 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans,
1902 if (tslot != 0) 1894 if (tslot != 0)
1903 break; 1895 break;
1904 } 1896 }
1905 return ret;
1906} 1897}
1907 1898
1908/* 1899/*
@@ -1911,9 +1902,9 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans,
1911 * This function isn't completely safe. It's the caller's responsibility 1902 * This function isn't completely safe. It's the caller's responsibility
1912 * that the new key won't break the order 1903 * that the new key won't break the order
1913 */ 1904 */
1914int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, 1905void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
1915 struct btrfs_root *root, struct btrfs_path *path, 1906 struct btrfs_root *root, struct btrfs_path *path,
1916 struct btrfs_key *new_key) 1907 struct btrfs_key *new_key)
1917{ 1908{
1918 struct btrfs_disk_key disk_key; 1909 struct btrfs_disk_key disk_key;
1919 struct extent_buffer *eb; 1910 struct extent_buffer *eb;
@@ -1923,13 +1914,11 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
1923 slot = path->slots[0]; 1914 slot = path->slots[0];
1924 if (slot > 0) { 1915 if (slot > 0) {
1925 btrfs_item_key(eb, &disk_key, slot - 1); 1916 btrfs_item_key(eb, &disk_key, slot - 1);
1926 if (comp_keys(&disk_key, new_key) >= 0) 1917 BUG_ON(comp_keys(&disk_key, new_key) >= 0);
1927 return -1;
1928 } 1918 }
1929 if (slot < btrfs_header_nritems(eb) - 1) { 1919 if (slot < btrfs_header_nritems(eb) - 1) {
1930 btrfs_item_key(eb, &disk_key, slot + 1); 1920 btrfs_item_key(eb, &disk_key, slot + 1);
1931 if (comp_keys(&disk_key, new_key) <= 0) 1921 BUG_ON(comp_keys(&disk_key, new_key) <= 0);
1932 return -1;
1933 } 1922 }
1934 1923
1935 btrfs_cpu_key_to_disk(&disk_key, new_key); 1924 btrfs_cpu_key_to_disk(&disk_key, new_key);
@@ -1937,7 +1926,6 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
1937 btrfs_mark_buffer_dirty(eb); 1926 btrfs_mark_buffer_dirty(eb);
1938 if (slot == 0) 1927 if (slot == 0)
1939 fixup_low_keys(trans, root, path, &disk_key, 1); 1928 fixup_low_keys(trans, root, path, &disk_key, 1);
1940 return 0;
1941} 1929}
1942 1930
1943/* 1931/*
@@ -2140,12 +2128,11 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,
2140 * 2128 *
2141 * slot and level indicate where you want the key to go, and 2129 * slot and level indicate where you want the key to go, and
2142 * blocknr is the block the key points to. 2130 * blocknr is the block the key points to.
2143 *
2144 * returns zero on success and < 0 on any error
2145 */ 2131 */
2146static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root 2132static void insert_ptr(struct btrfs_trans_handle *trans,
2147 *root, struct btrfs_path *path, struct btrfs_disk_key 2133 struct btrfs_root *root, struct btrfs_path *path,
2148 *key, u64 bytenr, int slot, int level) 2134 struct btrfs_disk_key *key, u64 bytenr,
2135 int slot, int level)
2149{ 2136{
2150 struct extent_buffer *lower; 2137 struct extent_buffer *lower;
2151 int nritems; 2138 int nritems;
@@ -2155,8 +2142,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root
2155 lower = path->nodes[level]; 2142 lower = path->nodes[level];
2156 nritems = btrfs_header_nritems(lower); 2143 nritems = btrfs_header_nritems(lower);
2157 BUG_ON(slot > nritems); 2144 BUG_ON(slot > nritems);
2158 if (nritems == BTRFS_NODEPTRS_PER_BLOCK(root)) 2145 BUG_ON(nritems == BTRFS_NODEPTRS_PER_BLOCK(root));
2159 BUG();
2160 if (slot != nritems) { 2146 if (slot != nritems) {
2161 memmove_extent_buffer(lower, 2147 memmove_extent_buffer(lower,
2162 btrfs_node_key_ptr_offset(slot + 1), 2148 btrfs_node_key_ptr_offset(slot + 1),
@@ -2169,7 +2155,6 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root
2169 btrfs_set_node_ptr_generation(lower, slot, trans->transid); 2155 btrfs_set_node_ptr_generation(lower, slot, trans->transid);
2170 btrfs_set_header_nritems(lower, nritems + 1); 2156 btrfs_set_header_nritems(lower, nritems + 1);
2171 btrfs_mark_buffer_dirty(lower); 2157 btrfs_mark_buffer_dirty(lower);
2172 return 0;
2173} 2158}
2174 2159
2175/* 2160/*
@@ -2190,7 +2175,6 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
2190 struct btrfs_disk_key disk_key; 2175 struct btrfs_disk_key disk_key;
2191 int mid; 2176 int mid;
2192 int ret; 2177 int ret;
2193 int wret;
2194 u32 c_nritems; 2178 u32 c_nritems;
2195 2179
2196 c = path->nodes[level]; 2180 c = path->nodes[level];
@@ -2247,11 +2231,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
2247 btrfs_mark_buffer_dirty(c); 2231 btrfs_mark_buffer_dirty(c);
2248 btrfs_mark_buffer_dirty(split); 2232 btrfs_mark_buffer_dirty(split);
2249 2233
2250 wret = insert_ptr(trans, root, path, &disk_key, split->start, 2234 insert_ptr(trans, root, path, &disk_key, split->start,
2251 path->slots[level + 1] + 1, 2235 path->slots[level + 1] + 1, level + 1);
2252 level + 1);
2253 if (wret)
2254 ret = wret;
2255 2236
2256 if (path->slots[level] >= mid) { 2237 if (path->slots[level] >= mid) {
2257 path->slots[level] -= mid; 2238 path->slots[level] -= mid;
@@ -2537,7 +2518,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
2537 u32 old_left_nritems; 2518 u32 old_left_nritems;
2538 u32 nr; 2519 u32 nr;
2539 int ret = 0; 2520 int ret = 0;
2540 int wret;
2541 u32 this_item_size; 2521 u32 this_item_size;
2542 u32 old_left_item_size; 2522 u32 old_left_item_size;
2543 2523
@@ -2643,9 +2623,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
2643 clean_tree_block(trans, root, right); 2623 clean_tree_block(trans, root, right);
2644 2624
2645 btrfs_item_key(right, &disk_key, 0); 2625 btrfs_item_key(right, &disk_key, 0);
2646 wret = fixup_low_keys(trans, root, path, &disk_key, 1); 2626 fixup_low_keys(trans, root, path, &disk_key, 1);
2647 if (wret)
2648 ret = wret;
2649 2627
2650 /* then fixup the leaf pointer in the path */ 2628 /* then fixup the leaf pointer in the path */
2651 if (path->slots[0] < push_items) { 2629 if (path->slots[0] < push_items) {
@@ -2738,21 +2716,17 @@ out:
2738/* 2716/*
2739 * split the path's leaf in two, making sure there is at least data_size 2717 * split the path's leaf in two, making sure there is at least data_size
2740 * available for the resulting leaf level of the path. 2718 * available for the resulting leaf level of the path.
2741 *
2742 * returns 0 if all went well and < 0 on failure.
2743 */ 2719 */
2744static noinline int copy_for_split(struct btrfs_trans_handle *trans, 2720static noinline void copy_for_split(struct btrfs_trans_handle *trans,
2745 struct btrfs_root *root, 2721 struct btrfs_root *root,
2746 struct btrfs_path *path, 2722 struct btrfs_path *path,
2747 struct extent_buffer *l, 2723 struct extent_buffer *l,
2748 struct extent_buffer *right, 2724 struct extent_buffer *right,
2749 int slot, int mid, int nritems) 2725 int slot, int mid, int nritems)
2750{ 2726{
2751 int data_copy_size; 2727 int data_copy_size;
2752 int rt_data_off; 2728 int rt_data_off;
2753 int i; 2729 int i;
2754 int ret = 0;
2755 int wret;
2756 struct btrfs_disk_key disk_key; 2730 struct btrfs_disk_key disk_key;
2757 2731
2758 nritems = nritems - mid; 2732 nritems = nritems - mid;
@@ -2780,12 +2754,9 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans,
2780 } 2754 }
2781 2755
2782 btrfs_set_header_nritems(l, mid); 2756 btrfs_set_header_nritems(l, mid);
2783 ret = 0;
2784 btrfs_item_key(right, &disk_key, 0); 2757 btrfs_item_key(right, &disk_key, 0);
2785 wret = insert_ptr(trans, root, path, &disk_key, right->start, 2758 insert_ptr(trans, root, path, &disk_key, right->start,
2786 path->slots[1] + 1, 1); 2759 path->slots[1] + 1, 1);
2787 if (wret)
2788 ret = wret;
2789 2760
2790 btrfs_mark_buffer_dirty(right); 2761 btrfs_mark_buffer_dirty(right);
2791 btrfs_mark_buffer_dirty(l); 2762 btrfs_mark_buffer_dirty(l);
@@ -2803,8 +2774,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans,
2803 } 2774 }
2804 2775
2805 BUG_ON(path->slots[0] < 0); 2776 BUG_ON(path->slots[0] < 0);
2806
2807 return ret;
2808} 2777}
2809 2778
2810/* 2779/*
@@ -2993,12 +2962,8 @@ again:
2993 if (split == 0) { 2962 if (split == 0) {
2994 if (mid <= slot) { 2963 if (mid <= slot) {
2995 btrfs_set_header_nritems(right, 0); 2964 btrfs_set_header_nritems(right, 0);
2996 wret = insert_ptr(trans, root, path, 2965 insert_ptr(trans, root, path, &disk_key, right->start,
2997 &disk_key, right->start, 2966 path->slots[1] + 1, 1);
2998 path->slots[1] + 1, 1);
2999 if (wret)
3000 ret = wret;
3001
3002 btrfs_tree_unlock(path->nodes[0]); 2967 btrfs_tree_unlock(path->nodes[0]);
3003 free_extent_buffer(path->nodes[0]); 2968 free_extent_buffer(path->nodes[0]);
3004 path->nodes[0] = right; 2969 path->nodes[0] = right;
@@ -3006,29 +2971,21 @@ again:
3006 path->slots[1] += 1; 2971 path->slots[1] += 1;
3007 } else { 2972 } else {
3008 btrfs_set_header_nritems(right, 0); 2973 btrfs_set_header_nritems(right, 0);
3009 wret = insert_ptr(trans, root, path, 2974 insert_ptr(trans, root, path, &disk_key, right->start,
3010 &disk_key,
3011 right->start,
3012 path->slots[1], 1); 2975 path->slots[1], 1);
3013 if (wret)
3014 ret = wret;
3015 btrfs_tree_unlock(path->nodes[0]); 2976 btrfs_tree_unlock(path->nodes[0]);
3016 free_extent_buffer(path->nodes[0]); 2977 free_extent_buffer(path->nodes[0]);
3017 path->nodes[0] = right; 2978 path->nodes[0] = right;
3018 path->slots[0] = 0; 2979 path->slots[0] = 0;
3019 if (path->slots[1] == 0) { 2980 if (path->slots[1] == 0)
3020 wret = fixup_low_keys(trans, root, 2981 fixup_low_keys(trans, root, path,
3021 path, &disk_key, 1); 2982 &disk_key, 1);
3022 if (wret)
3023 ret = wret;
3024 }
3025 } 2983 }
3026 btrfs_mark_buffer_dirty(right); 2984 btrfs_mark_buffer_dirty(right);
3027 return ret; 2985 return ret;
3028 } 2986 }
3029 2987
3030 ret = copy_for_split(trans, root, path, l, right, slot, mid, nritems); 2988 copy_for_split(trans, root, path, l, right, slot, mid, nritems);
3031 BUG_ON(ret);
3032 2989
3033 if (split == 2) { 2990 if (split == 2) {
3034 BUG_ON(num_doubles != 0); 2991 BUG_ON(num_doubles != 0);
@@ -3036,7 +2993,7 @@ again:
3036 goto again; 2993 goto again;
3037 } 2994 }
3038 2995
3039 return ret; 2996 return 0;
3040 2997
3041push_for_double: 2998push_for_double:
3042 push_for_double_split(trans, root, path, data_size); 2999 push_for_double_split(trans, root, path, data_size);
@@ -3238,11 +3195,9 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
3238 return ret; 3195 return ret;
3239 3196
3240 path->slots[0]++; 3197 path->slots[0]++;
3241 ret = setup_items_for_insert(trans, root, path, new_key, &item_size, 3198 setup_items_for_insert(trans, root, path, new_key, &item_size,
3242 item_size, item_size + 3199 item_size, item_size +
3243 sizeof(struct btrfs_item), 1); 3200 sizeof(struct btrfs_item), 1);
3244 BUG_ON(ret);
3245
3246 leaf = path->nodes[0]; 3201 leaf = path->nodes[0];
3247 memcpy_extent_buffer(leaf, 3202 memcpy_extent_buffer(leaf,
3248 btrfs_item_ptr_offset(leaf, path->slots[0]), 3203 btrfs_item_ptr_offset(leaf, path->slots[0]),
@@ -3257,10 +3212,10 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
3257 * off the end of the item or if we shift the item to chop bytes off 3212 * off the end of the item or if we shift the item to chop bytes off
3258 * the front. 3213 * the front.
3259 */ 3214 */
3260int btrfs_truncate_item(struct btrfs_trans_handle *trans, 3215void btrfs_truncate_item(struct btrfs_trans_handle *trans,
3261 struct btrfs_root *root, 3216 struct btrfs_root *root,
3262 struct btrfs_path *path, 3217 struct btrfs_path *path,
3263 u32 new_size, int from_end) 3218 u32 new_size, int from_end)
3264{ 3219{
3265 int slot; 3220 int slot;
3266 struct extent_buffer *leaf; 3221 struct extent_buffer *leaf;
@@ -3277,7 +3232,7 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
3277 3232
3278 old_size = btrfs_item_size_nr(leaf, slot); 3233 old_size = btrfs_item_size_nr(leaf, slot);
3279 if (old_size == new_size) 3234 if (old_size == new_size)
3280 return 0; 3235 return;
3281 3236
3282 nritems = btrfs_header_nritems(leaf); 3237 nritems = btrfs_header_nritems(leaf);
3283 data_end = leaf_data_end(root, leaf); 3238 data_end = leaf_data_end(root, leaf);
@@ -3350,15 +3305,14 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
3350 btrfs_print_leaf(root, leaf); 3305 btrfs_print_leaf(root, leaf);
3351 BUG(); 3306 BUG();
3352 } 3307 }
3353 return 0;
3354} 3308}
3355 3309
3356/* 3310/*
3357 * make the item pointed to by the path bigger, data_size is the new size. 3311 * make the item pointed to by the path bigger, data_size is the new size.
3358 */ 3312 */
3359int btrfs_extend_item(struct btrfs_trans_handle *trans, 3313void btrfs_extend_item(struct btrfs_trans_handle *trans,
3360 struct btrfs_root *root, struct btrfs_path *path, 3314 struct btrfs_root *root, struct btrfs_path *path,
3361 u32 data_size) 3315 u32 data_size)
3362{ 3316{
3363 int slot; 3317 int slot;
3364 struct extent_buffer *leaf; 3318 struct extent_buffer *leaf;
@@ -3416,7 +3370,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
3416 btrfs_print_leaf(root, leaf); 3370 btrfs_print_leaf(root, leaf);
3417 BUG(); 3371 BUG();
3418 } 3372 }
3419 return 0;
3420} 3373}
3421 3374
3422/* 3375/*
@@ -3544,7 +3497,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans,
3544 ret = 0; 3497 ret = 0;
3545 if (slot == 0) { 3498 if (slot == 0) {
3546 btrfs_cpu_key_to_disk(&disk_key, cpu_key); 3499 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
3547 ret = fixup_low_keys(trans, root, path, &disk_key, 1); 3500 fixup_low_keys(trans, root, path, &disk_key, 1);
3548 } 3501 }
3549 3502
3550 if (btrfs_leaf_free_space(root, leaf) < 0) { 3503 if (btrfs_leaf_free_space(root, leaf) < 0) {
@@ -3562,17 +3515,16 @@ out:
3562 * to save stack depth by doing the bulk of the work in a function 3515 * to save stack depth by doing the bulk of the work in a function
3563 * that doesn't call btrfs_search_slot 3516 * that doesn't call btrfs_search_slot
3564 */ 3517 */
3565int setup_items_for_insert(struct btrfs_trans_handle *trans, 3518void setup_items_for_insert(struct btrfs_trans_handle *trans,
3566 struct btrfs_root *root, struct btrfs_path *path, 3519 struct btrfs_root *root, struct btrfs_path *path,
3567 struct btrfs_key *cpu_key, u32 *data_size, 3520 struct btrfs_key *cpu_key, u32 *data_size,
3568 u32 total_data, u32 total_size, int nr) 3521 u32 total_data, u32 total_size, int nr)
3569{ 3522{
3570 struct btrfs_item *item; 3523 struct btrfs_item *item;
3571 int i; 3524 int i;
3572 u32 nritems; 3525 u32 nritems;
3573 unsigned int data_end; 3526 unsigned int data_end;
3574 struct btrfs_disk_key disk_key; 3527 struct btrfs_disk_key disk_key;
3575 int ret;
3576 struct extent_buffer *leaf; 3528 struct extent_buffer *leaf;
3577 int slot; 3529 int slot;
3578 3530
@@ -3633,10 +3585,9 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans,
3633 3585
3634 btrfs_set_header_nritems(leaf, nritems + nr); 3586 btrfs_set_header_nritems(leaf, nritems + nr);
3635 3587
3636 ret = 0;
3637 if (slot == 0) { 3588 if (slot == 0) {
3638 btrfs_cpu_key_to_disk(&disk_key, cpu_key); 3589 btrfs_cpu_key_to_disk(&disk_key, cpu_key);
3639 ret = fixup_low_keys(trans, root, path, &disk_key, 1); 3590 fixup_low_keys(trans, root, path, &disk_key, 1);
3640 } 3591 }
3641 btrfs_unlock_up_safe(path, 1); 3592 btrfs_unlock_up_safe(path, 1);
3642 btrfs_mark_buffer_dirty(leaf); 3593 btrfs_mark_buffer_dirty(leaf);
@@ -3645,7 +3596,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans,
3645 btrfs_print_leaf(root, leaf); 3596 btrfs_print_leaf(root, leaf);
3646 BUG(); 3597 BUG();
3647 } 3598 }
3648 return ret;
3649} 3599}
3650 3600
3651/* 3601/*
@@ -3672,16 +3622,14 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
3672 if (ret == 0) 3622 if (ret == 0)
3673 return -EEXIST; 3623 return -EEXIST;
3674 if (ret < 0) 3624 if (ret < 0)
3675 goto out; 3625 return ret;
3676 3626
3677 slot = path->slots[0]; 3627 slot = path->slots[0];
3678 BUG_ON(slot < 0); 3628 BUG_ON(slot < 0);
3679 3629
3680 ret = setup_items_for_insert(trans, root, path, cpu_key, data_size, 3630 setup_items_for_insert(trans, root, path, cpu_key, data_size,
3681 total_data, total_size, nr); 3631 total_data, total_size, nr);
3682 3632 return 0;
3683out:
3684 return ret;
3685} 3633}
3686 3634
3687/* 3635/*
@@ -3717,13 +3665,11 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
3717 * the tree should have been previously balanced so the deletion does not 3665 * the tree should have been previously balanced so the deletion does not
3718 * empty a node. 3666 * empty a node.
3719 */ 3667 */
3720static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, 3668static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3721 struct btrfs_path *path, int level, int slot) 3669 struct btrfs_path *path, int level, int slot)
3722{ 3670{
3723 struct extent_buffer *parent = path->nodes[level]; 3671 struct extent_buffer *parent = path->nodes[level];
3724 u32 nritems; 3672 u32 nritems;
3725 int ret = 0;
3726 int wret;
3727 3673
3728 nritems = btrfs_header_nritems(parent); 3674 nritems = btrfs_header_nritems(parent);
3729 if (slot != nritems - 1) { 3675 if (slot != nritems - 1) {
@@ -3743,12 +3689,9 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3743 struct btrfs_disk_key disk_key; 3689 struct btrfs_disk_key disk_key;
3744 3690
3745 btrfs_node_key(parent, &disk_key, 0); 3691 btrfs_node_key(parent, &disk_key, 0);
3746 wret = fixup_low_keys(trans, root, path, &disk_key, level + 1); 3692 fixup_low_keys(trans, root, path, &disk_key, level + 1);
3747 if (wret)
3748 ret = wret;
3749 } 3693 }
3750 btrfs_mark_buffer_dirty(parent); 3694 btrfs_mark_buffer_dirty(parent);
3751 return ret;
3752} 3695}
3753 3696
3754/* 3697/*
@@ -3761,17 +3704,13 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3761 * The path must have already been setup for deleting the leaf, including 3704 * The path must have already been setup for deleting the leaf, including
3762 * all the proper balancing. path->nodes[1] must be locked. 3705 * all the proper balancing. path->nodes[1] must be locked.
3763 */ 3706 */
3764static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, 3707static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans,
3765 struct btrfs_root *root, 3708 struct btrfs_root *root,
3766 struct btrfs_path *path, 3709 struct btrfs_path *path,
3767 struct extent_buffer *leaf) 3710 struct extent_buffer *leaf)
3768{ 3711{
3769 int ret;
3770
3771 WARN_ON(btrfs_header_generation(leaf) != trans->transid); 3712 WARN_ON(btrfs_header_generation(leaf) != trans->transid);
3772 ret = del_ptr(trans, root, path, 1, path->slots[1]); 3713 del_ptr(trans, root, path, 1, path->slots[1]);
3773 if (ret)
3774 return ret;
3775 3714
3776 /* 3715 /*
3777 * btrfs_free_extent is expensive, we want to make sure we 3716 * btrfs_free_extent is expensive, we want to make sure we
@@ -3782,7 +3721,6 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans,
3782 root_sub_used(root, leaf->len); 3721 root_sub_used(root, leaf->len);
3783 3722
3784 btrfs_free_tree_block(trans, root, leaf, 0, 1, 0); 3723 btrfs_free_tree_block(trans, root, leaf, 0, 1, 0);
3785 return 0;
3786} 3724}
3787/* 3725/*
3788 * delete the item at the leaf level in path. If that empties 3726 * delete the item at the leaf level in path. If that empties
@@ -3839,8 +3777,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3839 } else { 3777 } else {
3840 btrfs_set_path_blocking(path); 3778 btrfs_set_path_blocking(path);
3841 clean_tree_block(trans, root, leaf); 3779 clean_tree_block(trans, root, leaf);
3842 ret = btrfs_del_leaf(trans, root, path, leaf); 3780 btrfs_del_leaf(trans, root, path, leaf);
3843 BUG_ON(ret);
3844 } 3781 }
3845 } else { 3782 } else {
3846 int used = leaf_space_used(leaf, 0, nritems); 3783 int used = leaf_space_used(leaf, 0, nritems);
@@ -3848,10 +3785,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3848 struct btrfs_disk_key disk_key; 3785 struct btrfs_disk_key disk_key;
3849 3786
3850 btrfs_item_key(leaf, &disk_key, 0); 3787 btrfs_item_key(leaf, &disk_key, 0);
3851 wret = fixup_low_keys(trans, root, path, 3788 fixup_low_keys(trans, root, path, &disk_key, 1);
3852 &disk_key, 1);
3853 if (wret)
3854 ret = wret;
3855 } 3789 }
3856 3790
3857 /* delete the leaf if it is mostly empty */ 3791 /* delete the leaf if it is mostly empty */
@@ -3879,9 +3813,9 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3879 3813
3880 if (btrfs_header_nritems(leaf) == 0) { 3814 if (btrfs_header_nritems(leaf) == 0) {
3881 path->slots[1] = slot; 3815 path->slots[1] = slot;
3882 ret = btrfs_del_leaf(trans, root, path, leaf); 3816 btrfs_del_leaf(trans, root, path, leaf);
3883 BUG_ON(ret);
3884 free_extent_buffer(leaf); 3817 free_extent_buffer(leaf);
3818 ret = 0;
3885 } else { 3819 } else {
3886 /* if we're still in the path, make sure 3820 /* if we're still in the path, make sure
3887 * we're dirty. Otherwise, one of the 3821 * we're dirty. Otherwise, one of the
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 339e637ab272..30c5a247ab2b 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2485,8 +2485,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
2485int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); 2485int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len);
2486int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, 2486int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root,
2487 u64 start, u64 len); 2487 u64 start, u64 len);
2488int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, 2488void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
2489 struct btrfs_root *root); 2489 struct btrfs_root *root);
2490int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, 2490int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
2491 struct btrfs_root *root); 2491 struct btrfs_root *root);
2492int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, 2492int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
@@ -2549,8 +2549,8 @@ void btrfs_block_rsv_release(struct btrfs_root *root,
2549 u64 num_bytes); 2549 u64 num_bytes);
2550int btrfs_set_block_group_ro(struct btrfs_root *root, 2550int btrfs_set_block_group_ro(struct btrfs_root *root,
2551 struct btrfs_block_group_cache *cache); 2551 struct btrfs_block_group_cache *cache);
2552int btrfs_set_block_group_rw(struct btrfs_root *root, 2552void btrfs_set_block_group_rw(struct btrfs_root *root,
2553 struct btrfs_block_group_cache *cache); 2553 struct btrfs_block_group_cache *cache);
2554void btrfs_put_block_group_cache(struct btrfs_fs_info *info); 2554void btrfs_put_block_group_cache(struct btrfs_fs_info *info);
2555u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo); 2555u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo);
2556int btrfs_error_unpin_extent_range(struct btrfs_root *root, 2556int btrfs_error_unpin_extent_range(struct btrfs_root *root,
@@ -2569,9 +2569,9 @@ int btrfs_comp_cpu_keys(struct btrfs_key *k1, struct btrfs_key *k2);
2569int btrfs_previous_item(struct btrfs_root *root, 2569int btrfs_previous_item(struct btrfs_root *root,
2570 struct btrfs_path *path, u64 min_objectid, 2570 struct btrfs_path *path, u64 min_objectid,
2571 int type); 2571 int type);
2572int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, 2572void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
2573 struct btrfs_root *root, struct btrfs_path *path, 2573 struct btrfs_root *root, struct btrfs_path *path,
2574 struct btrfs_key *new_key); 2574 struct btrfs_key *new_key);
2575struct extent_buffer *btrfs_root_node(struct btrfs_root *root); 2575struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
2576struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); 2576struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
2577int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, 2577int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
@@ -2591,12 +2591,13 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
2591 struct extent_buffer **cow_ret, u64 new_root_objectid); 2591 struct extent_buffer **cow_ret, u64 new_root_objectid);
2592int btrfs_block_can_be_shared(struct btrfs_root *root, 2592int btrfs_block_can_be_shared(struct btrfs_root *root,
2593 struct extent_buffer *buf); 2593 struct extent_buffer *buf);
2594int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root 2594void btrfs_extend_item(struct btrfs_trans_handle *trans,
2595 *root, struct btrfs_path *path, u32 data_size); 2595 struct btrfs_root *root, struct btrfs_path *path,
2596int btrfs_truncate_item(struct btrfs_trans_handle *trans, 2596 u32 data_size);
2597 struct btrfs_root *root, 2597void btrfs_truncate_item(struct btrfs_trans_handle *trans,
2598 struct btrfs_path *path, 2598 struct btrfs_root *root,
2599 u32 new_size, int from_end); 2599 struct btrfs_path *path,
2600 u32 new_size, int from_end);
2600int btrfs_split_item(struct btrfs_trans_handle *trans, 2601int btrfs_split_item(struct btrfs_trans_handle *trans,
2601 struct btrfs_root *root, 2602 struct btrfs_root *root,
2602 struct btrfs_path *path, 2603 struct btrfs_path *path,
@@ -2630,10 +2631,10 @@ static inline int btrfs_del_item(struct btrfs_trans_handle *trans,
2630 return btrfs_del_items(trans, root, path, path->slots[0], 1); 2631 return btrfs_del_items(trans, root, path, path->slots[0], 1);
2631} 2632}
2632 2633
2633int setup_items_for_insert(struct btrfs_trans_handle *trans, 2634void setup_items_for_insert(struct btrfs_trans_handle *trans,
2634 struct btrfs_root *root, struct btrfs_path *path, 2635 struct btrfs_root *root, struct btrfs_path *path,
2635 struct btrfs_key *cpu_key, u32 *data_size, 2636 struct btrfs_key *cpu_key, u32 *data_size,
2636 u32 total_data, u32 total_size, int nr); 2637 u32 total_data, u32 total_size, int nr);
2637int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root 2638int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
2638 *root, struct btrfs_key *key, void *data, u32 data_size); 2639 *root, struct btrfs_key *key, void *data, u32 data_size);
2639int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, 2640int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
@@ -2911,7 +2912,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root);
2911void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, 2912void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
2912 struct btrfs_root *root); 2913 struct btrfs_root *root);
2913int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size); 2914int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size);
2914int btrfs_invalidate_inodes(struct btrfs_root *root); 2915void btrfs_invalidate_inodes(struct btrfs_root *root);
2915void btrfs_add_delayed_iput(struct inode *inode); 2916void btrfs_add_delayed_iput(struct inode *inode);
2916void btrfs_run_delayed_iputs(struct btrfs_root *root); 2917void btrfs_run_delayed_iputs(struct btrfs_root *root);
2917int btrfs_prealloc_file_range(struct inode *inode, int mode, 2918int btrfs_prealloc_file_range(struct inode *inode, int mode,
@@ -3021,10 +3022,10 @@ void btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
3021/* scrub.c */ 3022/* scrub.c */
3022int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, 3023int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end,
3023 struct btrfs_scrub_progress *progress, int readonly); 3024 struct btrfs_scrub_progress *progress, int readonly);
3024int btrfs_scrub_pause(struct btrfs_root *root); 3025void btrfs_scrub_pause(struct btrfs_root *root);
3025int btrfs_scrub_pause_super(struct btrfs_root *root); 3026void btrfs_scrub_pause_super(struct btrfs_root *root);
3026int btrfs_scrub_continue(struct btrfs_root *root); 3027void btrfs_scrub_continue(struct btrfs_root *root);
3027int btrfs_scrub_continue_super(struct btrfs_root *root); 3028void btrfs_scrub_continue_super(struct btrfs_root *root);
3028int btrfs_scrub_cancel(struct btrfs_root *root); 3029int btrfs_scrub_cancel(struct btrfs_root *root);
3029int btrfs_scrub_cancel_dev(struct btrfs_root *root, struct btrfs_device *dev); 3030int btrfs_scrub_cancel_dev(struct btrfs_root *root, struct btrfs_device *dev);
3030int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid); 3031int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid);
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index fe4cd0f1cef1..6829590d0fbb 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -836,10 +836,8 @@ static int btrfs_batch_insert_items(struct btrfs_trans_handle *trans,
836 btrfs_clear_path_blocking(path, NULL, 0); 836 btrfs_clear_path_blocking(path, NULL, 0);
837 837
838 /* insert the keys of the items */ 838 /* insert the keys of the items */
839 ret = setup_items_for_insert(trans, root, path, keys, data_size, 839 setup_items_for_insert(trans, root, path, keys, data_size,
840 total_data_size, total_size, nitems); 840 total_data_size, total_size, nitems);
841 if (ret)
842 goto error;
843 841
844 /* insert the dir index items */ 842 /* insert the dir index items */
845 slot = path->slots[0]; 843 slot = path->slots[0];
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 29ecd543d807..69f22e3ab3bc 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -420,7 +420,7 @@ update_existing_head_ref(struct btrfs_delayed_ref_node *existing,
420 * this does all the dirty work in terms of maintaining the correct 420 * this does all the dirty work in terms of maintaining the correct
421 * overall modification count. 421 * overall modification count.
422 */ 422 */
423static noinline int add_delayed_ref_head(struct btrfs_fs_info *fs_info, 423static noinline void add_delayed_ref_head(struct btrfs_fs_info *fs_info,
424 struct btrfs_trans_handle *trans, 424 struct btrfs_trans_handle *trans,
425 struct btrfs_delayed_ref_node *ref, 425 struct btrfs_delayed_ref_node *ref,
426 u64 bytenr, u64 num_bytes, 426 u64 bytenr, u64 num_bytes,
@@ -494,13 +494,12 @@ static noinline int add_delayed_ref_head(struct btrfs_fs_info *fs_info,
494 delayed_refs->num_entries++; 494 delayed_refs->num_entries++;
495 trans->delayed_ref_updates++; 495 trans->delayed_ref_updates++;
496 } 496 }
497 return 0;
498} 497}
499 498
500/* 499/*
501 * helper to insert a delayed tree ref into the rbtree. 500 * helper to insert a delayed tree ref into the rbtree.
502 */ 501 */
503static noinline int add_delayed_tree_ref(struct btrfs_fs_info *fs_info, 502static noinline void add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
504 struct btrfs_trans_handle *trans, 503 struct btrfs_trans_handle *trans,
505 struct btrfs_delayed_ref_node *ref, 504 struct btrfs_delayed_ref_node *ref,
506 u64 bytenr, u64 num_bytes, u64 parent, 505 u64 bytenr, u64 num_bytes, u64 parent,
@@ -554,13 +553,12 @@ static noinline int add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
554 delayed_refs->num_entries++; 553 delayed_refs->num_entries++;
555 trans->delayed_ref_updates++; 554 trans->delayed_ref_updates++;
556 } 555 }
557 return 0;
558} 556}
559 557
560/* 558/*
561 * helper to insert a delayed data ref into the rbtree. 559 * helper to insert a delayed data ref into the rbtree.
562 */ 560 */
563static noinline int add_delayed_data_ref(struct btrfs_fs_info *fs_info, 561static noinline void add_delayed_data_ref(struct btrfs_fs_info *fs_info,
564 struct btrfs_trans_handle *trans, 562 struct btrfs_trans_handle *trans,
565 struct btrfs_delayed_ref_node *ref, 563 struct btrfs_delayed_ref_node *ref,
566 u64 bytenr, u64 num_bytes, u64 parent, 564 u64 bytenr, u64 num_bytes, u64 parent,
@@ -616,7 +614,6 @@ static noinline int add_delayed_data_ref(struct btrfs_fs_info *fs_info,
616 delayed_refs->num_entries++; 614 delayed_refs->num_entries++;
617 trans->delayed_ref_updates++; 615 trans->delayed_ref_updates++;
618 } 616 }
619 return 0;
620} 617}
621 618
622/* 619/*
@@ -634,7 +631,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
634 struct btrfs_delayed_tree_ref *ref; 631 struct btrfs_delayed_tree_ref *ref;
635 struct btrfs_delayed_ref_head *head_ref; 632 struct btrfs_delayed_ref_head *head_ref;
636 struct btrfs_delayed_ref_root *delayed_refs; 633 struct btrfs_delayed_ref_root *delayed_refs;
637 int ret;
638 634
639 BUG_ON(extent_op && extent_op->is_data); 635 BUG_ON(extent_op && extent_op->is_data);
640 ref = kmalloc(sizeof(*ref), GFP_NOFS); 636 ref = kmalloc(sizeof(*ref), GFP_NOFS);
@@ -656,14 +652,12 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
656 * insert both the head node and the new ref without dropping 652 * insert both the head node and the new ref without dropping
657 * the spin lock 653 * the spin lock
658 */ 654 */
659 ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, 655 add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr,
660 num_bytes, action, 0); 656 num_bytes, action, 0);
661 BUG_ON(ret);
662 657
663 ret = add_delayed_tree_ref(fs_info, trans, &ref->node, bytenr, 658 add_delayed_tree_ref(fs_info, trans, &ref->node, bytenr,
664 num_bytes, parent, ref_root, level, action, 659 num_bytes, parent, ref_root, level, action,
665 for_cow); 660 for_cow);
666 BUG_ON(ret);
667 if (!need_ref_seq(for_cow, ref_root) && 661 if (!need_ref_seq(for_cow, ref_root) &&
668 waitqueue_active(&delayed_refs->seq_wait)) 662 waitqueue_active(&delayed_refs->seq_wait))
669 wake_up(&delayed_refs->seq_wait); 663 wake_up(&delayed_refs->seq_wait);
@@ -685,7 +679,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
685 struct btrfs_delayed_data_ref *ref; 679 struct btrfs_delayed_data_ref *ref;
686 struct btrfs_delayed_ref_head *head_ref; 680 struct btrfs_delayed_ref_head *head_ref;
687 struct btrfs_delayed_ref_root *delayed_refs; 681 struct btrfs_delayed_ref_root *delayed_refs;
688 int ret;
689 682
690 BUG_ON(extent_op && !extent_op->is_data); 683 BUG_ON(extent_op && !extent_op->is_data);
691 ref = kmalloc(sizeof(*ref), GFP_NOFS); 684 ref = kmalloc(sizeof(*ref), GFP_NOFS);
@@ -707,14 +700,12 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
707 * insert both the head node and the new ref without dropping 700 * insert both the head node and the new ref without dropping
708 * the spin lock 701 * the spin lock
709 */ 702 */
710 ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, 703 add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr,
711 num_bytes, action, 1); 704 num_bytes, action, 1);
712 BUG_ON(ret);
713 705
714 ret = add_delayed_data_ref(fs_info, trans, &ref->node, bytenr, 706 add_delayed_data_ref(fs_info, trans, &ref->node, bytenr,
715 num_bytes, parent, ref_root, owner, offset, 707 num_bytes, parent, ref_root, owner, offset,
716 action, for_cow); 708 action, for_cow);
717 BUG_ON(ret);
718 if (!need_ref_seq(for_cow, ref_root) && 709 if (!need_ref_seq(for_cow, ref_root) &&
719 waitqueue_active(&delayed_refs->seq_wait)) 710 waitqueue_active(&delayed_refs->seq_wait))
720 wake_up(&delayed_refs->seq_wait); 711 wake_up(&delayed_refs->seq_wait);
@@ -729,7 +720,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info,
729{ 720{
730 struct btrfs_delayed_ref_head *head_ref; 721 struct btrfs_delayed_ref_head *head_ref;
731 struct btrfs_delayed_ref_root *delayed_refs; 722 struct btrfs_delayed_ref_root *delayed_refs;
732 int ret;
733 723
734 head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); 724 head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS);
735 if (!head_ref) 725 if (!head_ref)
@@ -740,10 +730,9 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info,
740 delayed_refs = &trans->transaction->delayed_refs; 730 delayed_refs = &trans->transaction->delayed_refs;
741 spin_lock(&delayed_refs->lock); 731 spin_lock(&delayed_refs->lock);
742 732
743 ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, 733 add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr,
744 num_bytes, BTRFS_UPDATE_DELAYED_HEAD, 734 num_bytes, BTRFS_UPDATE_DELAYED_HEAD,
745 extent_op->is_data); 735 extent_op->is_data);
746 BUG_ON(ret);
747 736
748 if (waitqueue_active(&delayed_refs->seq_wait)) 737 if (waitqueue_active(&delayed_refs->seq_wait))
749 wake_up(&delayed_refs->seq_wait); 738 wake_up(&delayed_refs->seq_wait);
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 31d84e78129b..76743308bd9f 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -49,9 +49,8 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle
49 di = btrfs_match_dir_item_name(root, path, name, name_len); 49 di = btrfs_match_dir_item_name(root, path, name, name_len);
50 if (di) 50 if (di)
51 return ERR_PTR(-EEXIST); 51 return ERR_PTR(-EEXIST);
52 ret = btrfs_extend_item(trans, root, path, data_size); 52 btrfs_extend_item(trans, root, path, data_size);
53 } 53 } else if (ret < 0)
54 if (ret < 0)
55 return ERR_PTR(ret); 54 return ERR_PTR(ret);
56 WARN_ON(ret > 0); 55 WARN_ON(ret > 0);
57 leaf = path->nodes[0]; 56 leaf = path->nodes[0];
@@ -383,8 +382,8 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
383 start = btrfs_item_ptr_offset(leaf, path->slots[0]); 382 start = btrfs_item_ptr_offset(leaf, path->slots[0]);
384 memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, 383 memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
385 item_len - (ptr + sub_item_len - start)); 384 item_len - (ptr + sub_item_len - start));
386 ret = btrfs_truncate_item(trans, root, path, 385 btrfs_truncate_item(trans, root, path,
387 item_len - sub_item_len, 1); 386 item_len - sub_item_len, 1);
388 } 387 }
389 return ret; 388 return ret;
390} 389}
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 2e4428bd60ec..73ccadce90bc 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -50,12 +50,12 @@ static void end_workqueue_fn(struct btrfs_work *work);
50static void free_fs_root(struct btrfs_root *root); 50static void free_fs_root(struct btrfs_root *root);
51static void btrfs_check_super_valid(struct btrfs_fs_info *fs_info, 51static void btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
52 int read_only); 52 int read_only);
53static int btrfs_destroy_ordered_operations(struct btrfs_root *root); 53static void btrfs_destroy_ordered_operations(struct btrfs_root *root);
54static int btrfs_destroy_ordered_extents(struct btrfs_root *root); 54static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
55static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, 55static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
56 struct btrfs_root *root); 56 struct btrfs_root *root);
57static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); 57static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t);
58static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root); 58static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root);
59static int btrfs_destroy_marked_extents(struct btrfs_root *root, 59static int btrfs_destroy_marked_extents(struct btrfs_root *root,
60 struct extent_io_tree *dirty_pages, 60 struct extent_io_tree *dirty_pages,
61 int mark); 61 int mark);
@@ -1139,10 +1139,10 @@ void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1139 } 1139 }
1140} 1140}
1141 1141
1142static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, 1142static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
1143 u32 stripesize, struct btrfs_root *root, 1143 u32 stripesize, struct btrfs_root *root,
1144 struct btrfs_fs_info *fs_info, 1144 struct btrfs_fs_info *fs_info,
1145 u64 objectid) 1145 u64 objectid)
1146{ 1146{
1147 root->node = NULL; 1147 root->node = NULL;
1148 root->commit_root = NULL; 1148 root->commit_root = NULL;
@@ -1194,7 +1194,6 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
1194 root->defrag_running = 0; 1194 root->defrag_running = 0;
1195 root->root_key.objectid = objectid; 1195 root->root_key.objectid = objectid;
1196 root->anon_dev = 0; 1196 root->anon_dev = 0;
1197 return 0;
1198} 1197}
1199 1198
1200static int __must_check find_and_setup_root(struct btrfs_root *tree_root, 1199static int __must_check find_and_setup_root(struct btrfs_root *tree_root,
@@ -2897,7 +2896,7 @@ int write_ctree_super(struct btrfs_trans_handle *trans,
2897 return ret; 2896 return ret;
2898} 2897}
2899 2898
2900int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) 2899void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
2901{ 2900{
2902 spin_lock(&fs_info->fs_roots_radix_lock); 2901 spin_lock(&fs_info->fs_roots_radix_lock);
2903 radix_tree_delete(&fs_info->fs_roots_radix, 2902 radix_tree_delete(&fs_info->fs_roots_radix,
@@ -2910,7 +2909,6 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
2910 __btrfs_remove_free_space_cache(root->free_ino_pinned); 2909 __btrfs_remove_free_space_cache(root->free_ino_pinned);
2911 __btrfs_remove_free_space_cache(root->free_ino_ctl); 2910 __btrfs_remove_free_space_cache(root->free_ino_ctl);
2912 free_fs_root(root); 2911 free_fs_root(root);
2913 return 0;
2914} 2912}
2915 2913
2916static void free_fs_root(struct btrfs_root *root) 2914static void free_fs_root(struct btrfs_root *root)
@@ -2927,7 +2925,7 @@ static void free_fs_root(struct btrfs_root *root)
2927 kfree(root); 2925 kfree(root);
2928} 2926}
2929 2927
2930static int del_fs_roots(struct btrfs_fs_info *fs_info) 2928static void del_fs_roots(struct btrfs_fs_info *fs_info)
2931{ 2929{
2932 int ret; 2930 int ret;
2933 struct btrfs_root *gang[8]; 2931 struct btrfs_root *gang[8];
@@ -2956,7 +2954,6 @@ static int del_fs_roots(struct btrfs_fs_info *fs_info)
2956 for (i = 0; i < ret; i++) 2954 for (i = 0; i < ret; i++)
2957 btrfs_free_fs_root(fs_info, gang[i]); 2955 btrfs_free_fs_root(fs_info, gang[i]);
2958 } 2956 }
2959 return 0;
2960} 2957}
2961 2958
2962int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) 2959int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
@@ -3299,7 +3296,7 @@ int btrfs_error_commit_super(struct btrfs_root *root)
3299 return ret; 3296 return ret;
3300} 3297}
3301 3298
3302static int btrfs_destroy_ordered_operations(struct btrfs_root *root) 3299static void btrfs_destroy_ordered_operations(struct btrfs_root *root)
3303{ 3300{
3304 struct btrfs_inode *btrfs_inode; 3301 struct btrfs_inode *btrfs_inode;
3305 struct list_head splice; 3302 struct list_head splice;
@@ -3321,11 +3318,9 @@ static int btrfs_destroy_ordered_operations(struct btrfs_root *root)
3321 3318
3322 spin_unlock(&root->fs_info->ordered_extent_lock); 3319 spin_unlock(&root->fs_info->ordered_extent_lock);
3323 mutex_unlock(&root->fs_info->ordered_operations_mutex); 3320 mutex_unlock(&root->fs_info->ordered_operations_mutex);
3324
3325 return 0;
3326} 3321}
3327 3322
3328static int btrfs_destroy_ordered_extents(struct btrfs_root *root) 3323static void btrfs_destroy_ordered_extents(struct btrfs_root *root)
3329{ 3324{
3330 struct list_head splice; 3325 struct list_head splice;
3331 struct btrfs_ordered_extent *ordered; 3326 struct btrfs_ordered_extent *ordered;
@@ -3357,8 +3352,6 @@ static int btrfs_destroy_ordered_extents(struct btrfs_root *root)
3357 } 3352 }
3358 3353
3359 spin_unlock(&root->fs_info->ordered_extent_lock); 3354 spin_unlock(&root->fs_info->ordered_extent_lock);
3360
3361 return 0;
3362} 3355}
3363 3356
3364static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, 3357static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
@@ -3413,7 +3406,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
3413 return ret; 3406 return ret;
3414} 3407}
3415 3408
3416static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t) 3409static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t)
3417{ 3410{
3418 struct btrfs_pending_snapshot *snapshot; 3411 struct btrfs_pending_snapshot *snapshot;
3419 struct list_head splice; 3412 struct list_head splice;
@@ -3431,11 +3424,9 @@ static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t)
3431 3424
3432 kfree(snapshot); 3425 kfree(snapshot);
3433 } 3426 }
3434
3435 return 0;
3436} 3427}
3437 3428
3438static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root) 3429static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
3439{ 3430{
3440 struct btrfs_inode *btrfs_inode; 3431 struct btrfs_inode *btrfs_inode;
3441 struct list_head splice; 3432 struct list_head splice;
@@ -3455,8 +3446,6 @@ static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
3455 } 3446 }
3456 3447
3457 spin_unlock(&root->fs_info->delalloc_lock); 3448 spin_unlock(&root->fs_info->delalloc_lock);
3458
3459 return 0;
3460} 3449}
3461 3450
3462static int btrfs_destroy_marked_extents(struct btrfs_root *root, 3451static int btrfs_destroy_marked_extents(struct btrfs_root *root,
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index ca34237ae384..1608492d485f 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -64,7 +64,7 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
64int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); 64int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
65void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); 65void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr);
66void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); 66void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr);
67int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); 67void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root);
68void btrfs_mark_buffer_dirty(struct extent_buffer *buf); 68void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
69int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid); 69int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid);
70int btrfs_set_buffer_uptodate(struct extent_buffer *buf); 70int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c32a9bffe9e4..0daa1df16439 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1010,7 +1010,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle *trans,
1010 return ret; 1010 return ret;
1011 BUG_ON(ret); 1011 BUG_ON(ret);
1012 1012
1013 ret = btrfs_extend_item(trans, root, path, new_size); 1013 btrfs_extend_item(trans, root, path, new_size);
1014 1014
1015 leaf = path->nodes[0]; 1015 leaf = path->nodes[0];
1016 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1016 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1592,13 +1592,13 @@ out:
1592 * helper to add new inline back ref 1592 * helper to add new inline back ref
1593 */ 1593 */
1594static noinline_for_stack 1594static noinline_for_stack
1595int setup_inline_extent_backref(struct btrfs_trans_handle *trans, 1595void setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1596 struct btrfs_root *root, 1596 struct btrfs_root *root,
1597 struct btrfs_path *path, 1597 struct btrfs_path *path,
1598 struct btrfs_extent_inline_ref *iref, 1598 struct btrfs_extent_inline_ref *iref,
1599 u64 parent, u64 root_objectid, 1599 u64 parent, u64 root_objectid,
1600 u64 owner, u64 offset, int refs_to_add, 1600 u64 owner, u64 offset, int refs_to_add,
1601 struct btrfs_delayed_extent_op *extent_op) 1601 struct btrfs_delayed_extent_op *extent_op)
1602{ 1602{
1603 struct extent_buffer *leaf; 1603 struct extent_buffer *leaf;
1604 struct btrfs_extent_item *ei; 1604 struct btrfs_extent_item *ei;
@@ -1608,7 +1608,6 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1608 u64 refs; 1608 u64 refs;
1609 int size; 1609 int size;
1610 int type; 1610 int type;
1611 int ret;
1612 1611
1613 leaf = path->nodes[0]; 1612 leaf = path->nodes[0];
1614 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1613 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1617,7 +1616,7 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1617 type = extent_ref_type(parent, owner); 1616 type = extent_ref_type(parent, owner);
1618 size = btrfs_extent_inline_ref_size(type); 1617 size = btrfs_extent_inline_ref_size(type);
1619 1618
1620 ret = btrfs_extend_item(trans, root, path, size); 1619 btrfs_extend_item(trans, root, path, size);
1621 1620
1622 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1621 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1623 refs = btrfs_extent_refs(leaf, ei); 1622 refs = btrfs_extent_refs(leaf, ei);
@@ -1652,7 +1651,6 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1652 btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid); 1651 btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid);
1653 } 1652 }
1654 btrfs_mark_buffer_dirty(leaf); 1653 btrfs_mark_buffer_dirty(leaf);
1655 return 0;
1656} 1654}
1657 1655
1658static int lookup_extent_backref(struct btrfs_trans_handle *trans, 1656static int lookup_extent_backref(struct btrfs_trans_handle *trans,
@@ -1687,12 +1685,12 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans,
1687 * helper to update/remove inline back ref 1685 * helper to update/remove inline back ref
1688 */ 1686 */
1689static noinline_for_stack 1687static noinline_for_stack
1690int update_inline_extent_backref(struct btrfs_trans_handle *trans, 1688void update_inline_extent_backref(struct btrfs_trans_handle *trans,
1691 struct btrfs_root *root, 1689 struct btrfs_root *root,
1692 struct btrfs_path *path, 1690 struct btrfs_path *path,
1693 struct btrfs_extent_inline_ref *iref, 1691 struct btrfs_extent_inline_ref *iref,
1694 int refs_to_mod, 1692 int refs_to_mod,
1695 struct btrfs_delayed_extent_op *extent_op) 1693 struct btrfs_delayed_extent_op *extent_op)
1696{ 1694{
1697 struct extent_buffer *leaf; 1695 struct extent_buffer *leaf;
1698 struct btrfs_extent_item *ei; 1696 struct btrfs_extent_item *ei;
@@ -1703,7 +1701,6 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans,
1703 u32 item_size; 1701 u32 item_size;
1704 int size; 1702 int size;
1705 int type; 1703 int type;
1706 int ret;
1707 u64 refs; 1704 u64 refs;
1708 1705
1709 leaf = path->nodes[0]; 1706 leaf = path->nodes[0];
@@ -1745,10 +1742,9 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans,
1745 memmove_extent_buffer(leaf, ptr, ptr + size, 1742 memmove_extent_buffer(leaf, ptr, ptr + size,
1746 end - ptr - size); 1743 end - ptr - size);
1747 item_size -= size; 1744 item_size -= size;
1748 ret = btrfs_truncate_item(trans, root, path, item_size, 1); 1745 btrfs_truncate_item(trans, root, path, item_size, 1);
1749 } 1746 }
1750 btrfs_mark_buffer_dirty(leaf); 1747 btrfs_mark_buffer_dirty(leaf);
1751 return 0;
1752} 1748}
1753 1749
1754static noinline_for_stack 1750static noinline_for_stack
@@ -1768,13 +1764,13 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans,
1768 root_objectid, owner, offset, 1); 1764 root_objectid, owner, offset, 1);
1769 if (ret == 0) { 1765 if (ret == 0) {
1770 BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID); 1766 BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID);
1771 ret = update_inline_extent_backref(trans, root, path, iref, 1767 update_inline_extent_backref(trans, root, path, iref,
1772 refs_to_add, extent_op); 1768 refs_to_add, extent_op);
1773 } else if (ret == -ENOENT) { 1769 } else if (ret == -ENOENT) {
1774 ret = setup_inline_extent_backref(trans, root, path, iref, 1770 setup_inline_extent_backref(trans, root, path, iref, parent,
1775 parent, root_objectid, 1771 root_objectid, owner, offset,
1776 owner, offset, refs_to_add, 1772 refs_to_add, extent_op);
1777 extent_op); 1773 ret = 0;
1778 } 1774 }
1779 return ret; 1775 return ret;
1780} 1776}
@@ -1804,12 +1800,12 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
1804 struct btrfs_extent_inline_ref *iref, 1800 struct btrfs_extent_inline_ref *iref,
1805 int refs_to_drop, int is_data) 1801 int refs_to_drop, int is_data)
1806{ 1802{
1807 int ret; 1803 int ret = 0;
1808 1804
1809 BUG_ON(!is_data && refs_to_drop != 1); 1805 BUG_ON(!is_data && refs_to_drop != 1);
1810 if (iref) { 1806 if (iref) {
1811 ret = update_inline_extent_backref(trans, root, path, iref, 1807 update_inline_extent_backref(trans, root, path, iref,
1812 -refs_to_drop, NULL); 1808 -refs_to_drop, NULL);
1813 } else if (is_data) { 1809 } else if (is_data) {
1814 ret = remove_extent_data_ref(trans, root, path, refs_to_drop); 1810 ret = remove_extent_data_ref(trans, root, path, refs_to_drop);
1815 } else { 1811 } else {
@@ -4734,7 +4730,7 @@ static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
4734 return ret; 4730 return ret;
4735} 4731}
4736 4732
4737int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, 4733void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
4738 struct btrfs_root *root) 4734 struct btrfs_root *root)
4739{ 4735{
4740 struct btrfs_fs_info *fs_info = root->fs_info; 4736 struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4764,7 +4760,6 @@ int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
4764 up_write(&fs_info->extent_commit_sem); 4760 up_write(&fs_info->extent_commit_sem);
4765 4761
4766 update_global_block_rsv(fs_info); 4762 update_global_block_rsv(fs_info);
4767 return 0;
4768} 4763}
4769 4764
4770static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end) 4765static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end)
@@ -7189,7 +7184,7 @@ u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo)
7189 return free_bytes; 7184 return free_bytes;
7190} 7185}
7191 7186
7192int btrfs_set_block_group_rw(struct btrfs_root *root, 7187void btrfs_set_block_group_rw(struct btrfs_root *root,
7193 struct btrfs_block_group_cache *cache) 7188 struct btrfs_block_group_cache *cache)
7194{ 7189{
7195 struct btrfs_space_info *sinfo = cache->space_info; 7190 struct btrfs_space_info *sinfo = cache->space_info;
@@ -7205,7 +7200,6 @@ int btrfs_set_block_group_rw(struct btrfs_root *root,
7205 cache->ro = 0; 7200 cache->ro = 0;
7206 spin_unlock(&cache->lock); 7201 spin_unlock(&cache->lock);
7207 spin_unlock(&sinfo->lock); 7202 spin_unlock(&sinfo->lock);
7208 return 0;
7209} 7203}
7210 7204
7211/* 7205/*
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8368baa1f372..65216fabacbb 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -142,6 +142,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask)
142#endif 142#endif
143 atomic_set(&state->refs, 1); 143 atomic_set(&state->refs, 1);
144 init_waitqueue_head(&state->wq); 144 init_waitqueue_head(&state->wq);
145 trace_alloc_extent_state(state, mask, _RET_IP_);
145 return state; 146 return state;
146} 147}
147 148
@@ -159,6 +160,7 @@ void free_extent_state(struct extent_state *state)
159 list_del(&state->leak_list); 160 list_del(&state->leak_list);
160 spin_unlock_irqrestore(&leak_lock, flags); 161 spin_unlock_irqrestore(&leak_lock, flags);
161#endif 162#endif
163 trace_free_extent_state(state, _RET_IP_);
162 kmem_cache_free(extent_state_cache, state); 164 kmem_cache_free(extent_state_cache, state);
163 } 165 }
164} 166}
@@ -617,8 +619,8 @@ search_again:
617 goto again; 619 goto again;
618} 620}
619 621
620static int wait_on_state(struct extent_io_tree *tree, 622static void wait_on_state(struct extent_io_tree *tree,
621 struct extent_state *state) 623 struct extent_state *state)
622 __releases(tree->lock) 624 __releases(tree->lock)
623 __acquires(tree->lock) 625 __acquires(tree->lock)
624{ 626{
@@ -628,7 +630,6 @@ static int wait_on_state(struct extent_io_tree *tree,
628 schedule(); 630 schedule();
629 spin_lock(&tree->lock); 631 spin_lock(&tree->lock);
630 finish_wait(&state->wq, &wait); 632 finish_wait(&state->wq, &wait);
631 return 0;
632} 633}
633 634
634/* 635/*
@@ -636,7 +637,7 @@ static int wait_on_state(struct extent_io_tree *tree,
636 * The range [start, end] is inclusive. 637 * The range [start, end] is inclusive.
637 * The tree lock is taken by this function 638 * The tree lock is taken by this function
638 */ 639 */
639int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits) 640void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits)
640{ 641{
641 struct extent_state *state; 642 struct extent_state *state;
642 struct rb_node *node; 643 struct rb_node *node;
@@ -673,7 +674,6 @@ again:
673 } 674 }
674out: 675out:
675 spin_unlock(&tree->lock); 676 spin_unlock(&tree->lock);
676 return 0;
677} 677}
678 678
679static void set_state_bits(struct extent_io_tree *tree, 679static void set_state_bits(struct extent_io_tree *tree,
@@ -1359,9 +1359,9 @@ out:
1359 return found; 1359 return found;
1360} 1360}
1361 1361
1362static noinline int __unlock_for_delalloc(struct inode *inode, 1362static noinline void __unlock_for_delalloc(struct inode *inode,
1363 struct page *locked_page, 1363 struct page *locked_page,
1364 u64 start, u64 end) 1364 u64 start, u64 end)
1365{ 1365{
1366 int ret; 1366 int ret;
1367 struct page *pages[16]; 1367 struct page *pages[16];
@@ -1371,7 +1371,7 @@ static noinline int __unlock_for_delalloc(struct inode *inode,
1371 int i; 1371 int i;
1372 1372
1373 if (index == locked_page->index && end_index == index) 1373 if (index == locked_page->index && end_index == index)
1374 return 0; 1374 return;
1375 1375
1376 while (nr_pages > 0) { 1376 while (nr_pages > 0) {
1377 ret = find_get_pages_contig(inode->i_mapping, index, 1377 ret = find_get_pages_contig(inode->i_mapping, index,
@@ -1386,7 +1386,6 @@ static noinline int __unlock_for_delalloc(struct inode *inode,
1386 index += ret; 1386 index += ret;
1387 cond_resched(); 1387 cond_resched();
1388 } 1388 }
1389 return 0;
1390} 1389}
1391 1390
1392static noinline int lock_delalloc_pages(struct inode *inode, 1391static noinline int lock_delalloc_pages(struct inode *inode,
@@ -1777,39 +1776,34 @@ int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
1777 * helper function to set a given page up to date if all the 1776 * helper function to set a given page up to date if all the
1778 * extents in the tree for that page are up to date 1777 * extents in the tree for that page are up to date
1779 */ 1778 */
1780static int check_page_uptodate(struct extent_io_tree *tree, 1779static void check_page_uptodate(struct extent_io_tree *tree, struct page *page)
1781 struct page *page)
1782{ 1780{
1783 u64 start = (u64)page->index << PAGE_CACHE_SHIFT; 1781 u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
1784 u64 end = start + PAGE_CACHE_SIZE - 1; 1782 u64 end = start + PAGE_CACHE_SIZE - 1;
1785 if (test_range_bit(tree, start, end, EXTENT_UPTODATE, 1, NULL)) 1783 if (test_range_bit(tree, start, end, EXTENT_UPTODATE, 1, NULL))
1786 SetPageUptodate(page); 1784 SetPageUptodate(page);
1787 return 0;
1788} 1785}
1789 1786
1790/* 1787/*
1791 * helper function to unlock a page if all the extents in the tree 1788 * helper function to unlock a page if all the extents in the tree
1792 * for that page are unlocked 1789 * for that page are unlocked
1793 */ 1790 */
1794static int check_page_locked(struct extent_io_tree *tree, 1791static void check_page_locked(struct extent_io_tree *tree, struct page *page)
1795 struct page *page)
1796{ 1792{
1797 u64 start = (u64)page->index << PAGE_CACHE_SHIFT; 1793 u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
1798 u64 end = start + PAGE_CACHE_SIZE - 1; 1794 u64 end = start + PAGE_CACHE_SIZE - 1;
1799 if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL)) 1795 if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL))
1800 unlock_page(page); 1796 unlock_page(page);
1801 return 0;
1802} 1797}
1803 1798
1804/* 1799/*
1805 * helper function to end page writeback if all the extents 1800 * helper function to end page writeback if all the extents
1806 * in the tree for that page are done with writeback 1801 * in the tree for that page are done with writeback
1807 */ 1802 */
1808static int check_page_writeback(struct extent_io_tree *tree, 1803static void check_page_writeback(struct extent_io_tree *tree,
1809 struct page *page) 1804 struct page *page)
1810{ 1805{
1811 end_page_writeback(page); 1806 end_page_writeback(page);
1812 return 0;
1813} 1807}
1814 1808
1815/* 1809/*
@@ -3835,7 +3829,7 @@ void free_extent_buffer(struct extent_buffer *eb)
3835 WARN_ON(1); 3829 WARN_ON(1);
3836} 3830}
3837 3831
3838int clear_extent_buffer_dirty(struct extent_io_tree *tree, 3832void clear_extent_buffer_dirty(struct extent_io_tree *tree,
3839 struct extent_buffer *eb) 3833 struct extent_buffer *eb)
3840{ 3834{
3841 unsigned long i; 3835 unsigned long i;
@@ -3867,7 +3861,6 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,
3867 ClearPageError(page); 3861 ClearPageError(page);
3868 unlock_page(page); 3862 unlock_page(page);
3869 } 3863 }
3870 return 0;
3871} 3864}
3872 3865
3873int set_extent_buffer_dirty(struct extent_io_tree *tree, 3866int set_extent_buffer_dirty(struct extent_io_tree *tree,
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index cecc3518c121..f7f321ee4ba1 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -287,8 +287,8 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
287 unsigned long src_offset, unsigned long len); 287 unsigned long src_offset, unsigned long len);
288void memset_extent_buffer(struct extent_buffer *eb, char c, 288void memset_extent_buffer(struct extent_buffer *eb, char c,
289 unsigned long start, unsigned long len); 289 unsigned long start, unsigned long len);
290int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); 290void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits);
291int clear_extent_buffer_dirty(struct extent_io_tree *tree, 291void clear_extent_buffer_dirty(struct extent_io_tree *tree,
292 struct extent_buffer *eb); 292 struct extent_buffer *eb);
293int set_extent_buffer_dirty(struct extent_io_tree *tree, 293int set_extent_buffer_dirty(struct extent_io_tree *tree,
294 struct extent_buffer *eb); 294 struct extent_buffer *eb);
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index c7fb3a4247d3..edb69b4d5335 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -483,18 +483,17 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
483 * This calls btrfs_truncate_item with the correct args based on the 483 * This calls btrfs_truncate_item with the correct args based on the
484 * overlap, and fixes up the key as required. 484 * overlap, and fixes up the key as required.
485 */ 485 */
486static noinline int truncate_one_csum(struct btrfs_trans_handle *trans, 486static noinline void truncate_one_csum(struct btrfs_trans_handle *trans,
487 struct btrfs_root *root, 487 struct btrfs_root *root,
488 struct btrfs_path *path, 488 struct btrfs_path *path,
489 struct btrfs_key *key, 489 struct btrfs_key *key,
490 u64 bytenr, u64 len) 490 u64 bytenr, u64 len)
491{ 491{
492 struct extent_buffer *leaf; 492 struct extent_buffer *leaf;
493 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy); 493 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
494 u64 csum_end; 494 u64 csum_end;
495 u64 end_byte = bytenr + len; 495 u64 end_byte = bytenr + len;
496 u32 blocksize_bits = root->fs_info->sb->s_blocksize_bits; 496 u32 blocksize_bits = root->fs_info->sb->s_blocksize_bits;
497 int ret;
498 497
499 leaf = path->nodes[0]; 498 leaf = path->nodes[0];
500 csum_end = btrfs_item_size_nr(leaf, path->slots[0]) / csum_size; 499 csum_end = btrfs_item_size_nr(leaf, path->slots[0]) / csum_size;
@@ -510,7 +509,7 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
510 */ 509 */
511 u32 new_size = (bytenr - key->offset) >> blocksize_bits; 510 u32 new_size = (bytenr - key->offset) >> blocksize_bits;
512 new_size *= csum_size; 511 new_size *= csum_size;
513 ret = btrfs_truncate_item(trans, root, path, new_size, 1); 512 btrfs_truncate_item(trans, root, path, new_size, 1);
514 } else if (key->offset >= bytenr && csum_end > end_byte && 513 } else if (key->offset >= bytenr && csum_end > end_byte &&
515 end_byte > key->offset) { 514 end_byte > key->offset) {
516 /* 515 /*
@@ -522,15 +521,13 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
522 u32 new_size = (csum_end - end_byte) >> blocksize_bits; 521 u32 new_size = (csum_end - end_byte) >> blocksize_bits;
523 new_size *= csum_size; 522 new_size *= csum_size;
524 523
525 ret = btrfs_truncate_item(trans, root, path, new_size, 0); 524 btrfs_truncate_item(trans, root, path, new_size, 0);
526 525
527 key->offset = end_byte; 526 key->offset = end_byte;
528 ret = btrfs_set_item_key_safe(trans, root, path, key); 527 btrfs_set_item_key_safe(trans, root, path, key);
529 BUG_ON(ret);
530 } else { 528 } else {
531 BUG(); 529 BUG();
532 } 530 }
533 return 0;
534} 531}
535 532
536/* 533/*
@@ -639,9 +636,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
639 636
640 key.offset = end_byte - 1; 637 key.offset = end_byte - 1;
641 } else { 638 } else {
642 ret = truncate_one_csum(trans, root, path, 639 truncate_one_csum(trans, root, path, &key, bytenr, len);
643 &key, bytenr, len);
644 BUG_ON(ret);
645 if (key.offset < bytenr) 640 if (key.offset < bytenr)
646 break; 641 break;
647 } 642 }
@@ -772,7 +767,7 @@ again:
772 if (diff != csum_size) 767 if (diff != csum_size)
773 goto insert; 768 goto insert;
774 769
775 ret = btrfs_extend_item(trans, root, path, diff); 770 btrfs_extend_item(trans, root, path, diff);
776 goto csum; 771 goto csum;
777 } 772 }
778 773
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
index baa74f3db691..c0792409bb6a 100644
--- a/fs/btrfs/inode-item.c
+++ b/fs/btrfs/inode-item.c
@@ -128,7 +128,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
128 item_start = btrfs_item_ptr_offset(leaf, path->slots[0]); 128 item_start = btrfs_item_ptr_offset(leaf, path->slots[0]);
129 memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, 129 memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
130 item_size - (ptr + sub_item_len - item_start)); 130 item_size - (ptr + sub_item_len - item_start));
131 ret = btrfs_truncate_item(trans, root, path, 131 btrfs_truncate_item(trans, root, path,
132 item_size - sub_item_len, 1); 132 item_size - sub_item_len, 1);
133out: 133out:
134 btrfs_free_path(path); 134 btrfs_free_path(path);
@@ -165,7 +165,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
165 goto out; 165 goto out;
166 166
167 old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]); 167 old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
168 ret = btrfs_extend_item(trans, root, path, ins_len); 168 btrfs_extend_item(trans, root, path, ins_len);
169 ref = btrfs_item_ptr(path->nodes[0], path->slots[0], 169 ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
170 struct btrfs_inode_ref); 170 struct btrfs_inode_ref);
171 ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size); 171 ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5394bdb314ca..dc800eefdbc7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3164,8 +3164,8 @@ search_again:
3164 } 3164 }
3165 size = 3165 size =
3166 btrfs_file_extent_calc_inline_size(size); 3166 btrfs_file_extent_calc_inline_size(size);
3167 ret = btrfs_truncate_item(trans, root, path, 3167 btrfs_truncate_item(trans, root, path,
3168 size, 1); 3168 size, 1);
3169 } else if (root->ref_cows) { 3169 } else if (root->ref_cows) {
3170 inode_sub_bytes(inode, item_end + 1 - 3170 inode_sub_bytes(inode, item_end + 1 -
3171 found_key.offset); 3171 found_key.offset);
@@ -3782,7 +3782,7 @@ static void inode_tree_del(struct inode *inode)
3782 } 3782 }
3783} 3783}
3784 3784
3785int btrfs_invalidate_inodes(struct btrfs_root *root) 3785void btrfs_invalidate_inodes(struct btrfs_root *root)
3786{ 3786{
3787 struct rb_node *node; 3787 struct rb_node *node;
3788 struct rb_node *prev; 3788 struct rb_node *prev;
@@ -3842,7 +3842,6 @@ again:
3842 node = rb_next(node); 3842 node = rb_next(node);
3843 } 3843 }
3844 spin_unlock(&root->inode_lock); 3844 spin_unlock(&root->inode_lock);
3845 return 0;
3846} 3845}
3847 3846
3848static int btrfs_init_locked_inode(struct inode *inode, void *p) 3847static int btrfs_init_locked_inode(struct inode *inode, void *p)
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 5e178d8f7167..272f911203ff 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -208,7 +208,7 @@ void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb)
208 * take a spinning write lock. This will wait for both 208 * take a spinning write lock. This will wait for both
209 * blocking readers or writers 209 * blocking readers or writers
210 */ 210 */
211int btrfs_tree_lock(struct extent_buffer *eb) 211void btrfs_tree_lock(struct extent_buffer *eb)
212{ 212{
213again: 213again:
214 wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0); 214 wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0);
@@ -230,13 +230,12 @@ again:
230 atomic_inc(&eb->spinning_writers); 230 atomic_inc(&eb->spinning_writers);
231 atomic_inc(&eb->write_locks); 231 atomic_inc(&eb->write_locks);
232 eb->lock_owner = current->pid; 232 eb->lock_owner = current->pid;
233 return 0;
234} 233}
235 234
236/* 235/*
237 * drop a spinning or a blocking write lock. 236 * drop a spinning or a blocking write lock.
238 */ 237 */
239int btrfs_tree_unlock(struct extent_buffer *eb) 238void btrfs_tree_unlock(struct extent_buffer *eb)
240{ 239{
241 int blockers = atomic_read(&eb->blocking_writers); 240 int blockers = atomic_read(&eb->blocking_writers);
242 241
@@ -255,7 +254,6 @@ int btrfs_tree_unlock(struct extent_buffer *eb)
255 atomic_dec(&eb->spinning_writers); 254 atomic_dec(&eb->spinning_writers);
256 write_unlock(&eb->lock); 255 write_unlock(&eb->lock);
257 } 256 }
258 return 0;
259} 257}
260 258
261void btrfs_assert_tree_locked(struct extent_buffer *eb) 259void btrfs_assert_tree_locked(struct extent_buffer *eb)
diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h
index 17247ddb81a0..ca52681e5f40 100644
--- a/fs/btrfs/locking.h
+++ b/fs/btrfs/locking.h
@@ -24,8 +24,8 @@
24#define BTRFS_WRITE_LOCK_BLOCKING 3 24#define BTRFS_WRITE_LOCK_BLOCKING 3
25#define BTRFS_READ_LOCK_BLOCKING 4 25#define BTRFS_READ_LOCK_BLOCKING 4
26 26
27int btrfs_tree_lock(struct extent_buffer *eb); 27void btrfs_tree_lock(struct extent_buffer *eb);
28int btrfs_tree_unlock(struct extent_buffer *eb); 28void btrfs_tree_unlock(struct extent_buffer *eb);
29int btrfs_try_spin_lock(struct extent_buffer *eb); 29int btrfs_try_spin_lock(struct extent_buffer *eb);
30 30
31void btrfs_tree_read_lock(struct extent_buffer *eb); 31void btrfs_tree_read_lock(struct extent_buffer *eb);
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 2857f28e20e2..bbf6d0d9aebe 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -257,9 +257,9 @@ int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset,
257 * when an ordered extent is finished. If the list covers more than one 257 * when an ordered extent is finished. If the list covers more than one
258 * ordered extent, it is split across multiples. 258 * ordered extent, it is split across multiples.
259 */ 259 */
260int btrfs_add_ordered_sum(struct inode *inode, 260void btrfs_add_ordered_sum(struct inode *inode,
261 struct btrfs_ordered_extent *entry, 261 struct btrfs_ordered_extent *entry,
262 struct btrfs_ordered_sum *sum) 262 struct btrfs_ordered_sum *sum)
263{ 263{
264 struct btrfs_ordered_inode_tree *tree; 264 struct btrfs_ordered_inode_tree *tree;
265 265
@@ -267,7 +267,6 @@ int btrfs_add_ordered_sum(struct inode *inode,
267 spin_lock(&tree->lock); 267 spin_lock(&tree->lock);
268 list_add_tail(&sum->list, &entry->list); 268 list_add_tail(&sum->list, &entry->list);
269 spin_unlock(&tree->lock); 269 spin_unlock(&tree->lock);
270 return 0;
271} 270}
272 271
273/* 272/*
@@ -392,7 +391,7 @@ out:
392 * used to drop a reference on an ordered extent. This will free 391 * used to drop a reference on an ordered extent. This will free
393 * the extent if the last reference is dropped 392 * the extent if the last reference is dropped
394 */ 393 */
395int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) 394void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
396{ 395{
397 struct list_head *cur; 396 struct list_head *cur;
398 struct btrfs_ordered_sum *sum; 397 struct btrfs_ordered_sum *sum;
@@ -408,7 +407,6 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
408 } 407 }
409 kfree(entry); 408 kfree(entry);
410 } 409 }
411 return 0;
412} 410}
413 411
414/* 412/*
@@ -416,8 +414,8 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
416 * and you must wake_up entry->wait. You must hold the tree lock 414 * and you must wake_up entry->wait. You must hold the tree lock
417 * while you call this function. 415 * while you call this function.
418 */ 416 */
419static int __btrfs_remove_ordered_extent(struct inode *inode, 417static void __btrfs_remove_ordered_extent(struct inode *inode,
420 struct btrfs_ordered_extent *entry) 418 struct btrfs_ordered_extent *entry)
421{ 419{
422 struct btrfs_ordered_inode_tree *tree; 420 struct btrfs_ordered_inode_tree *tree;
423 struct btrfs_root *root = BTRFS_I(inode)->root; 421 struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -444,35 +442,30 @@ static int __btrfs_remove_ordered_extent(struct inode *inode,
444 list_del_init(&BTRFS_I(inode)->ordered_operations); 442 list_del_init(&BTRFS_I(inode)->ordered_operations);
445 } 443 }
446 spin_unlock(&root->fs_info->ordered_extent_lock); 444 spin_unlock(&root->fs_info->ordered_extent_lock);
447
448 return 0;
449} 445}
450 446
451/* 447/*
452 * remove an ordered extent from the tree. No references are dropped 448 * remove an ordered extent from the tree. No references are dropped
453 * but any waiters are woken. 449 * but any waiters are woken.
454 */ 450 */
455int btrfs_remove_ordered_extent(struct inode *inode, 451void btrfs_remove_ordered_extent(struct inode *inode,
456 struct btrfs_ordered_extent *entry) 452 struct btrfs_ordered_extent *entry)
457{ 453{
458 struct btrfs_ordered_inode_tree *tree; 454 struct btrfs_ordered_inode_tree *tree;
459 int ret;
460 455
461 tree = &BTRFS_I(inode)->ordered_tree; 456 tree = &BTRFS_I(inode)->ordered_tree;
462 spin_lock(&tree->lock); 457 spin_lock(&tree->lock);
463 ret = __btrfs_remove_ordered_extent(inode, entry); 458 __btrfs_remove_ordered_extent(inode, entry);
464 spin_unlock(&tree->lock); 459 spin_unlock(&tree->lock);
465 wake_up(&entry->wait); 460 wake_up(&entry->wait);
466
467 return ret;
468} 461}
469 462
470/* 463/*
471 * wait for all the ordered extents in a root. This is done when balancing 464 * wait for all the ordered extents in a root. This is done when balancing
472 * space between drives. 465 * space between drives.
473 */ 466 */
474int btrfs_wait_ordered_extents(struct btrfs_root *root, 467void btrfs_wait_ordered_extents(struct btrfs_root *root,
475 int nocow_only, int delay_iput) 468 int nocow_only, int delay_iput)
476{ 469{
477 struct list_head splice; 470 struct list_head splice;
478 struct list_head *cur; 471 struct list_head *cur;
@@ -520,7 +513,6 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root,
520 spin_lock(&root->fs_info->ordered_extent_lock); 513 spin_lock(&root->fs_info->ordered_extent_lock);
521 } 514 }
522 spin_unlock(&root->fs_info->ordered_extent_lock); 515 spin_unlock(&root->fs_info->ordered_extent_lock);
523 return 0;
524} 516}
525 517
526/* 518/*
@@ -533,7 +525,7 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root,
533 * extra check to make sure the ordered operation list really is empty 525 * extra check to make sure the ordered operation list really is empty
534 * before we return 526 * before we return
535 */ 527 */
536int btrfs_run_ordered_operations(struct btrfs_root *root, int wait) 528void btrfs_run_ordered_operations(struct btrfs_root *root, int wait)
537{ 529{
538 struct btrfs_inode *btrfs_inode; 530 struct btrfs_inode *btrfs_inode;
539 struct inode *inode; 531 struct inode *inode;
@@ -581,8 +573,6 @@ again:
581 573
582 spin_unlock(&root->fs_info->ordered_extent_lock); 574 spin_unlock(&root->fs_info->ordered_extent_lock);
583 mutex_unlock(&root->fs_info->ordered_operations_mutex); 575 mutex_unlock(&root->fs_info->ordered_operations_mutex);
584
585 return 0;
586} 576}
587 577
588/* 578/*
@@ -617,7 +607,7 @@ void btrfs_start_ordered_extent(struct inode *inode,
617/* 607/*
618 * Used to wait on ordered extents across a large range of bytes. 608 * Used to wait on ordered extents across a large range of bytes.
619 */ 609 */
620int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) 610void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
621{ 611{
622 u64 end; 612 u64 end;
623 u64 orig_end; 613 u64 orig_end;
@@ -672,7 +662,6 @@ again:
672 schedule_timeout(1); 662 schedule_timeout(1);
673 goto again; 663 goto again;
674 } 664 }
675 return 0;
676} 665}
677 666
678/* 667/*
@@ -956,9 +945,8 @@ out:
956 * If trans is not null, we'll do a friendly check for a transaction that 945 * If trans is not null, we'll do a friendly check for a transaction that
957 * is already flushing things and force the IO down ourselves. 946 * is already flushing things and force the IO down ourselves.
958 */ 947 */
959int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, 948void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
960 struct btrfs_root *root, 949 struct btrfs_root *root, struct inode *inode)
961 struct inode *inode)
962{ 950{
963 u64 last_mod; 951 u64 last_mod;
964 952
@@ -969,7 +957,7 @@ int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
969 * commit, we can safely return without doing anything 957 * commit, we can safely return without doing anything
970 */ 958 */
971 if (last_mod < root->fs_info->last_trans_committed) 959 if (last_mod < root->fs_info->last_trans_committed)
972 return 0; 960 return;
973 961
974 /* 962 /*
975 * the transaction is already committing. Just start the IO and 963 * the transaction is already committing. Just start the IO and
@@ -977,7 +965,7 @@ int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
977 */ 965 */
978 if (trans && root->fs_info->running_transaction->blocked) { 966 if (trans && root->fs_info->running_transaction->blocked) {
979 btrfs_wait_ordered_range(inode, 0, (u64)-1); 967 btrfs_wait_ordered_range(inode, 0, (u64)-1);
980 return 0; 968 return;
981 } 969 }
982 970
983 spin_lock(&root->fs_info->ordered_extent_lock); 971 spin_lock(&root->fs_info->ordered_extent_lock);
@@ -986,6 +974,4 @@ int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
986 &root->fs_info->ordered_operations); 974 &root->fs_info->ordered_operations);
987 } 975 }
988 spin_unlock(&root->fs_info->ordered_extent_lock); 976 spin_unlock(&root->fs_info->ordered_extent_lock);
989
990 return 0;
991} 977}
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index ff1f69aa1883..c355ad4dc1a6 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -138,8 +138,8 @@ btrfs_ordered_inode_tree_init(struct btrfs_ordered_inode_tree *t)
138 t->last = NULL; 138 t->last = NULL;
139} 139}
140 140
141int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); 141void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry);
142int btrfs_remove_ordered_extent(struct inode *inode, 142void btrfs_remove_ordered_extent(struct inode *inode,
143 struct btrfs_ordered_extent *entry); 143 struct btrfs_ordered_extent *entry);
144int btrfs_dec_test_ordered_pending(struct inode *inode, 144int btrfs_dec_test_ordered_pending(struct inode *inode,
145 struct btrfs_ordered_extent **cached, 145 struct btrfs_ordered_extent **cached,
@@ -154,14 +154,14 @@ int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset,
154int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset, 154int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset,
155 u64 start, u64 len, u64 disk_len, 155 u64 start, u64 len, u64 disk_len,
156 int type, int compress_type); 156 int type, int compress_type);
157int btrfs_add_ordered_sum(struct inode *inode, 157void btrfs_add_ordered_sum(struct inode *inode,
158 struct btrfs_ordered_extent *entry, 158 struct btrfs_ordered_extent *entry,
159 struct btrfs_ordered_sum *sum); 159 struct btrfs_ordered_sum *sum);
160struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, 160struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode,
161 u64 file_offset); 161 u64 file_offset);
162void btrfs_start_ordered_extent(struct inode *inode, 162void btrfs_start_ordered_extent(struct inode *inode,
163 struct btrfs_ordered_extent *entry, int wait); 163 struct btrfs_ordered_extent *entry, int wait);
164int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); 164void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len);
165struct btrfs_ordered_extent * 165struct btrfs_ordered_extent *
166btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset); 166btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset);
167struct btrfs_ordered_extent *btrfs_lookup_ordered_range(struct inode *inode, 167struct btrfs_ordered_extent *btrfs_lookup_ordered_range(struct inode *inode,
@@ -170,10 +170,10 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range(struct inode *inode,
170int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, 170int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
171 struct btrfs_ordered_extent *ordered); 171 struct btrfs_ordered_extent *ordered);
172int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); 172int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum);
173int btrfs_run_ordered_operations(struct btrfs_root *root, int wait); 173void btrfs_run_ordered_operations(struct btrfs_root *root, int wait);
174int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, 174void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
175 struct btrfs_root *root, 175 struct btrfs_root *root,
176 struct inode *inode); 176 struct inode *inode);
177int btrfs_wait_ordered_extents(struct btrfs_root *root, 177void btrfs_wait_ordered_extents(struct btrfs_root *root,
178 int nocow_only, int delay_iput); 178 int nocow_only, int delay_iput);
179#endif 179#endif
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index abc0fbffa510..a2e8aa40f3f5 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -948,12 +948,12 @@ static int scrub_checksum_super(struct scrub_bio *sbio, void *buffer)
948 return fail; 948 return fail;
949} 949}
950 950
951static int scrub_submit(struct scrub_dev *sdev) 951static void scrub_submit(struct scrub_dev *sdev)
952{ 952{
953 struct scrub_bio *sbio; 953 struct scrub_bio *sbio;
954 954
955 if (sdev->curr == -1) 955 if (sdev->curr == -1)
956 return 0; 956 return;
957 957
958 sbio = sdev->bios[sdev->curr]; 958 sbio = sdev->bios[sdev->curr];
959 sbio->err = 0; 959 sbio->err = 0;
@@ -961,8 +961,6 @@ static int scrub_submit(struct scrub_dev *sdev)
961 atomic_inc(&sdev->in_flight); 961 atomic_inc(&sdev->in_flight);
962 962
963 btrfsic_submit_bio(READ, sbio->bio); 963 btrfsic_submit_bio(READ, sbio->bio);
964
965 return 0;
966} 964}
967 965
968static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len, 966static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
@@ -1008,9 +1006,7 @@ again:
1008 sbio->bio = bio; 1006 sbio->bio = bio;
1009 } else if (sbio->physical + sbio->count * PAGE_SIZE != physical || 1007 } else if (sbio->physical + sbio->count * PAGE_SIZE != physical ||
1010 sbio->logical + sbio->count * PAGE_SIZE != logical) { 1008 sbio->logical + sbio->count * PAGE_SIZE != logical) {
1011 ret = scrub_submit(sdev); 1009 scrub_submit(sdev);
1012 if (ret)
1013 return ret;
1014 goto again; 1010 goto again;
1015 } 1011 }
1016 sbio->spag[sbio->count].flags = flags; 1012 sbio->spag[sbio->count].flags = flags;
@@ -1025,9 +1021,7 @@ again:
1025 ret = bio_add_page(sbio->bio, page, PAGE_SIZE, 0); 1021 ret = bio_add_page(sbio->bio, page, PAGE_SIZE, 0);
1026 if (!ret) { 1022 if (!ret) {
1027 __free_page(page); 1023 __free_page(page);
1028 ret = scrub_submit(sdev); 1024 scrub_submit(sdev);
1029 if (ret)
1030 return ret;
1031 goto again; 1025 goto again;
1032 } 1026 }
1033 1027
@@ -1036,13 +1030,8 @@ again:
1036 memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size); 1030 memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size);
1037 } 1031 }
1038 ++sbio->count; 1032 ++sbio->count;
1039 if (sbio->count == SCRUB_PAGES_PER_BIO || force) { 1033 if (sbio->count == SCRUB_PAGES_PER_BIO || force)
1040 int ret; 1034 scrub_submit(sdev);
1041
1042 ret = scrub_submit(sdev);
1043 if (ret)
1044 return ret;
1045 }
1046 1035
1047 return 0; 1036 return 0;
1048} 1037}
@@ -1656,7 +1645,7 @@ int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end,
1656 return ret; 1645 return ret;
1657} 1646}
1658 1647
1659int btrfs_scrub_pause(struct btrfs_root *root) 1648void btrfs_scrub_pause(struct btrfs_root *root)
1660{ 1649{
1661 struct btrfs_fs_info *fs_info = root->fs_info; 1650 struct btrfs_fs_info *fs_info = root->fs_info;
1662 1651
@@ -1671,29 +1660,24 @@ int btrfs_scrub_pause(struct btrfs_root *root)
1671 mutex_lock(&fs_info->scrub_lock); 1660 mutex_lock(&fs_info->scrub_lock);
1672 } 1661 }
1673 mutex_unlock(&fs_info->scrub_lock); 1662 mutex_unlock(&fs_info->scrub_lock);
1674
1675 return 0;
1676} 1663}
1677 1664
1678int btrfs_scrub_continue(struct btrfs_root *root) 1665void btrfs_scrub_continue(struct btrfs_root *root)
1679{ 1666{
1680 struct btrfs_fs_info *fs_info = root->fs_info; 1667 struct btrfs_fs_info *fs_info = root->fs_info;
1681 1668
1682 atomic_dec(&fs_info->scrub_pause_req); 1669 atomic_dec(&fs_info->scrub_pause_req);
1683 wake_up(&fs_info->scrub_pause_wait); 1670 wake_up(&fs_info->scrub_pause_wait);
1684 return 0;
1685} 1671}
1686 1672
1687int btrfs_scrub_pause_super(struct btrfs_root *root) 1673void btrfs_scrub_pause_super(struct btrfs_root *root)
1688{ 1674{
1689 down_write(&root->fs_info->scrub_super_lock); 1675 down_write(&root->fs_info->scrub_super_lock);
1690 return 0;
1691} 1676}
1692 1677
1693int btrfs_scrub_continue_super(struct btrfs_root *root) 1678void btrfs_scrub_continue_super(struct btrfs_root *root)
1694{ 1679{
1695 up_write(&root->fs_info->scrub_super_lock); 1680 up_write(&root->fs_info->scrub_super_lock);
1696 return 0;
1697} 1681}
1698 1682
1699int btrfs_scrub_cancel(struct btrfs_root *root) 1683int btrfs_scrub_cancel(struct btrfs_root *root)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9774e38a0532..ae7963b2d527 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1408,9 +1408,7 @@ static int __init init_btrfs_fs(void)
1408 if (err) 1408 if (err)
1409 return err; 1409 return err;
1410 1410
1411 err = btrfs_init_compress(); 1411 btrfs_init_compress();
1412 if (err)
1413 goto free_sysfs;
1414 1412
1415 err = btrfs_init_cachep(); 1413 err = btrfs_init_cachep();
1416 if (err) 1414 if (err)
@@ -1451,7 +1449,6 @@ free_cachep:
1451 btrfs_destroy_cachep(); 1449 btrfs_destroy_cachep();
1452free_compress: 1450free_compress:
1453 btrfs_exit_compress(); 1451 btrfs_exit_compress();
1454free_sysfs:
1455 btrfs_exit_sysfs(); 1452 btrfs_exit_sysfs();
1456 return err; 1453 return err;
1457} 1454}
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 04b77e3ceb7a..6e256d90fd2f 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1214,8 +1214,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1214 1214
1215 if (flush_on_commit || snap_pending) { 1215 if (flush_on_commit || snap_pending) {
1216 btrfs_start_delalloc_inodes(root, 1); 1216 btrfs_start_delalloc_inodes(root, 1);
1217 ret = btrfs_wait_ordered_extents(root, 0, 1); 1217 btrfs_wait_ordered_extents(root, 0, 1);
1218 BUG_ON(ret);
1219 } 1218 }
1220 1219
1221 ret = btrfs_run_delayed_items(trans, root); 1220 ret = btrfs_run_delayed_items(trans, root);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 966cc74f5d6c..37b52b8c6727 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -212,14 +212,13 @@ int btrfs_pin_log_trans(struct btrfs_root *root)
212 * indicate we're done making changes to the log tree 212 * indicate we're done making changes to the log tree
213 * and wake up anyone waiting to do a sync 213 * and wake up anyone waiting to do a sync
214 */ 214 */
215int btrfs_end_log_trans(struct btrfs_root *root) 215void btrfs_end_log_trans(struct btrfs_root *root)
216{ 216{
217 if (atomic_dec_and_test(&root->log_writers)) { 217 if (atomic_dec_and_test(&root->log_writers)) {
218 smp_mb(); 218 smp_mb();
219 if (waitqueue_active(&root->log_writer_wait)) 219 if (waitqueue_active(&root->log_writer_wait))
220 wake_up(&root->log_writer_wait); 220 wake_up(&root->log_writer_wait);
221 } 221 }
222 return 0;
223} 222}
224 223
225 224
@@ -378,12 +377,11 @@ insert:
378 u32 found_size; 377 u32 found_size;
379 found_size = btrfs_item_size_nr(path->nodes[0], 378 found_size = btrfs_item_size_nr(path->nodes[0],
380 path->slots[0]); 379 path->slots[0]);
381 if (found_size > item_size) { 380 if (found_size > item_size)
382 btrfs_truncate_item(trans, root, path, item_size, 1); 381 btrfs_truncate_item(trans, root, path, item_size, 1);
383 } else if (found_size < item_size) { 382 else if (found_size < item_size)
384 ret = btrfs_extend_item(trans, root, path, 383 btrfs_extend_item(trans, root, path,
385 item_size - found_size); 384 item_size - found_size);
386 }
387 } else if (ret) { 385 } else if (ret) {
388 return ret; 386 return ret;
389 } 387 }
@@ -1963,8 +1961,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans,
1963 return 0; 1961 return 0;
1964} 1962}
1965 1963
1966static int wait_for_writer(struct btrfs_trans_handle *trans, 1964static void wait_for_writer(struct btrfs_trans_handle *trans,
1967 struct btrfs_root *root) 1965 struct btrfs_root *root)
1968{ 1966{
1969 DEFINE_WAIT(wait); 1967 DEFINE_WAIT(wait);
1970 while (root->fs_info->last_trans_log_full_commit != 1968 while (root->fs_info->last_trans_log_full_commit !=
@@ -1978,7 +1976,6 @@ static int wait_for_writer(struct btrfs_trans_handle *trans,
1978 mutex_lock(&root->log_mutex); 1976 mutex_lock(&root->log_mutex);
1979 finish_wait(&root->log_writer_wait, &wait); 1977 finish_wait(&root->log_writer_wait, &wait);
1980 } 1978 }
1981 return 0;
1982} 1979}
1983 1980
1984/* 1981/*
diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
index 2270ac58d746..862ac813f6b8 100644
--- a/fs/btrfs/tree-log.h
+++ b/fs/btrfs/tree-log.h
@@ -38,7 +38,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
38 struct btrfs_root *root, 38 struct btrfs_root *root,
39 const char *name, int name_len, 39 const char *name, int name_len,
40 struct inode *inode, u64 dirid); 40 struct inode *inode, u64 dirid);
41int btrfs_end_log_trans(struct btrfs_root *root); 41void btrfs_end_log_trans(struct btrfs_root *root);
42int btrfs_pin_log_trans(struct btrfs_root *root); 42int btrfs_pin_log_trans(struct btrfs_root *root);
43int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, 43int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
44 struct btrfs_root *root, struct inode *inode, 44 struct btrfs_root *root, struct inode *inode,
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ef41f285a475..1c5f8a4a2bbd 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -67,7 +67,7 @@ static void free_fs_devices(struct btrfs_fs_devices *fs_devices)
67 kfree(fs_devices); 67 kfree(fs_devices);
68} 68}
69 69
70int btrfs_cleanup_fs_uuids(void) 70void btrfs_cleanup_fs_uuids(void)
71{ 71{
72 struct btrfs_fs_devices *fs_devices; 72 struct btrfs_fs_devices *fs_devices;
73 73
@@ -77,7 +77,6 @@ int btrfs_cleanup_fs_uuids(void)
77 list_del(&fs_devices->list); 77 list_del(&fs_devices->list);
78 free_fs_devices(fs_devices); 78 free_fs_devices(fs_devices);
79 } 79 }
80 return 0;
81} 80}
82 81
83static noinline struct btrfs_device *__find_device(struct list_head *head, 82static noinline struct btrfs_device *__find_device(struct list_head *head,
@@ -130,7 +129,7 @@ static void requeue_list(struct btrfs_pending_bios *pending_bios,
130 * the list if the block device is congested. This way, multiple devices 129 * the list if the block device is congested. This way, multiple devices
131 * can make progress from a single worker thread. 130 * can make progress from a single worker thread.
132 */ 131 */
133static noinline int run_scheduled_bios(struct btrfs_device *device) 132static noinline void run_scheduled_bios(struct btrfs_device *device)
134{ 133{
135 struct bio *pending; 134 struct bio *pending;
136 struct backing_dev_info *bdi; 135 struct backing_dev_info *bdi;
@@ -316,7 +315,6 @@ loop_lock:
316 315
317done: 316done:
318 blk_finish_plug(&plug); 317 blk_finish_plug(&plug);
319 return 0;
320} 318}
321 319
322static void pending_bios_fn(struct btrfs_work *work) 320static void pending_bios_fn(struct btrfs_work *work)
@@ -455,7 +453,7 @@ error:
455 return ERR_PTR(-ENOMEM); 453 return ERR_PTR(-ENOMEM);
456} 454}
457 455
458int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices) 456void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
459{ 457{
460 struct btrfs_device *device, *next; 458 struct btrfs_device *device, *next;
461 459
@@ -503,7 +501,6 @@ again:
503 fs_devices->latest_trans = latest_transid; 501 fs_devices->latest_trans = latest_transid;
504 502
505 mutex_unlock(&uuid_mutex); 503 mutex_unlock(&uuid_mutex);
506 return 0;
507} 504}
508 505
509static void __free_device(struct work_struct *work) 506static void __free_device(struct work_struct *work)
@@ -3967,7 +3964,7 @@ struct async_sched {
3967 * This will add one bio to the pending list for a device and make sure 3964 * This will add one bio to the pending list for a device and make sure
3968 * the work struct is scheduled. 3965 * the work struct is scheduled.
3969 */ 3966 */
3970static noinline int schedule_bio(struct btrfs_root *root, 3967static noinline void schedule_bio(struct btrfs_root *root,
3971 struct btrfs_device *device, 3968 struct btrfs_device *device,
3972 int rw, struct bio *bio) 3969 int rw, struct bio *bio)
3973{ 3970{
@@ -3979,7 +3976,7 @@ static noinline int schedule_bio(struct btrfs_root *root,
3979 bio_get(bio); 3976 bio_get(bio);
3980 btrfsic_submit_bio(rw, bio); 3977 btrfsic_submit_bio(rw, bio);
3981 bio_put(bio); 3978 bio_put(bio);
3982 return 0; 3979 return;
3983 } 3980 }
3984 3981
3985 /* 3982 /*
@@ -4013,7 +4010,6 @@ static noinline int schedule_bio(struct btrfs_root *root,
4013 if (should_queue) 4010 if (should_queue)
4014 btrfs_queue_worker(&root->fs_info->submit_workers, 4011 btrfs_queue_worker(&root->fs_info->submit_workers,
4015 &device->work); 4012 &device->work);
4016 return 0;
4017} 4013}
4018 4014
4019int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, 4015int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
@@ -4215,7 +4211,7 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
4215 return 0; 4211 return 0;
4216} 4212}
4217 4213
4218static int fill_device_from_item(struct extent_buffer *leaf, 4214static void fill_device_from_item(struct extent_buffer *leaf,
4219 struct btrfs_dev_item *dev_item, 4215 struct btrfs_dev_item *dev_item,
4220 struct btrfs_device *device) 4216 struct btrfs_device *device)
4221{ 4217{
@@ -4232,8 +4228,6 @@ static int fill_device_from_item(struct extent_buffer *leaf,
4232 4228
4233 ptr = (unsigned long)btrfs_device_uuid(dev_item); 4229 ptr = (unsigned long)btrfs_device_uuid(dev_item);
4234 read_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE); 4230 read_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE);
4235
4236 return 0;
4237} 4231}
4238 4232
4239static int open_seed_devices(struct btrfs_root *root, u8 *fsid) 4233static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 19ac95048b88..bb6b03f97aaa 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -260,12 +260,12 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
260int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, 260int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
261 struct btrfs_fs_devices **fs_devices_ret); 261 struct btrfs_fs_devices **fs_devices_ret);
262int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); 262int btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
263int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices); 263void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices);
264int btrfs_add_device(struct btrfs_trans_handle *trans, 264int btrfs_add_device(struct btrfs_trans_handle *trans,
265 struct btrfs_root *root, 265 struct btrfs_root *root,
266 struct btrfs_device *device); 266 struct btrfs_device *device);
267int btrfs_rm_device(struct btrfs_root *root, char *device_path); 267int btrfs_rm_device(struct btrfs_root *root, char *device_path);
268int btrfs_cleanup_fs_uuids(void); 268void btrfs_cleanup_fs_uuids(void);
269int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len); 269int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len);
270int btrfs_grow_device(struct btrfs_trans_handle *trans, 270int btrfs_grow_device(struct btrfs_trans_handle *trans,
271 struct btrfs_device *device, u64 new_size); 271 struct btrfs_device *device, u64 new_size);