Loading fs/btrfs/async-thread.c +5 −10 Original line number Diff line number Diff line Loading @@ -171,11 +171,11 @@ static void check_pending_worker_creates(struct btrfs_worker_thread *worker) spin_unlock_irqrestore(&workers->lock, flags); } static noinline int run_ordered_completions(struct btrfs_workers *workers, static noinline void run_ordered_completions(struct btrfs_workers *workers, struct btrfs_work *work) { if (!workers->ordered) return 0; return; set_bit(WORK_DONE_BIT, &work->flags); Loading Loading @@ -213,7 +213,6 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers, } spin_unlock(&workers->order_lock); return 0; } static void put_worker(struct btrfs_worker_thread *worker) Loading Loading @@ -399,7 +398,7 @@ static int worker_loop(void *arg) /* * this will wait for all the worker threads to shutdown */ int btrfs_stop_workers(struct btrfs_workers *workers) void btrfs_stop_workers(struct btrfs_workers *workers) { struct list_head *cur; struct btrfs_worker_thread *worker; Loading Loading @@ -427,7 +426,6 @@ int btrfs_stop_workers(struct btrfs_workers *workers) put_worker(worker); } spin_unlock_irq(&workers->lock); return 0; } /* Loading Loading @@ -615,14 +613,14 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers) * it was taken from. It is intended for use with long running work functions * that make some progress and want to give the cpu up for others. */ int btrfs_requeue_work(struct btrfs_work *work) void btrfs_requeue_work(struct btrfs_work *work) { struct btrfs_worker_thread *worker = work->worker; unsigned long flags; int wake = 0; if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags)) goto out; return; spin_lock_irqsave(&worker->lock, flags); if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags)) Loading @@ -649,9 +647,6 @@ int btrfs_requeue_work(struct btrfs_work *work) if (wake) wake_up_process(worker->task); spin_unlock_irqrestore(&worker->lock, flags); out: return 0; } void btrfs_set_work_high_prio(struct btrfs_work *work) Loading fs/btrfs/async-thread.h +2 −2 Original line number Diff line number Diff line Loading @@ -111,9 +111,9 @@ struct btrfs_workers { void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); int btrfs_start_workers(struct btrfs_workers *workers); int btrfs_stop_workers(struct btrfs_workers *workers); void btrfs_stop_workers(struct btrfs_workers *workers); void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max, struct btrfs_workers *async_starter); int btrfs_requeue_work(struct btrfs_work *work); void btrfs_requeue_work(struct btrfs_work *work); void btrfs_set_work_high_prio(struct btrfs_work *work); #endif fs/btrfs/compression.c +3 −5 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ static void end_compressed_bio_read(struct bio *bio, int err) * Clear the writeback bits on all of the file * pages for a compressed write */ static noinline int end_compressed_writeback(struct inode *inode, u64 start, static noinline void end_compressed_writeback(struct inode *inode, u64 start, unsigned long ram_size) { unsigned long index = start >> PAGE_CACHE_SHIFT; Loading @@ -253,7 +253,6 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start, index += ret; } /* the inode may be gone now */ return 0; } /* Loading Loading @@ -734,7 +733,7 @@ struct btrfs_compress_op *btrfs_compress_op[] = { &btrfs_lzo_compress, }; int __init btrfs_init_compress(void) void __init btrfs_init_compress(void) { int i; Loading @@ -744,7 +743,6 @@ int __init btrfs_init_compress(void) atomic_set(&comp_alloc_workspace[i], 0); init_waitqueue_head(&comp_workspace_wait[i]); } return 0; } /* Loading fs/btrfs/compression.h +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ #ifndef __BTRFS_COMPRESSION_ #define __BTRFS_COMPRESSION_ int btrfs_init_compress(void); void btrfs_init_compress(void); void btrfs_exit_compress(void); int btrfs_compress_pages(int type, struct address_space *mapping, Loading fs/btrfs/ctree.c +67 −133 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *dst_buf, struct extent_buffer *src_buf); static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level, int slot); struct btrfs_path *btrfs_alloc_path(void) Loading Loading @@ -1010,10 +1010,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(right) == 0) { clean_tree_block(trans, root, right); btrfs_tree_unlock(right); wret = del_ptr(trans, root, path, level + 1, pslot + 1); if (wret) ret = wret; del_ptr(trans, root, path, level + 1, pslot + 1); root_sub_used(root, right->len); btrfs_free_tree_block(trans, root, right, 0, 1, 0); free_extent_buffer(right); Loading Loading @@ -1051,9 +1048,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(mid) == 0) { clean_tree_block(trans, root, mid); btrfs_tree_unlock(mid); wret = del_ptr(trans, root, path, level + 1, pslot); if (wret) ret = wret; del_ptr(trans, root, path, level + 1, pslot); root_sub_used(root, mid->len); btrfs_free_tree_block(trans, root, mid, 0, 1, 0); free_extent_buffer(mid); Loading Loading @@ -1881,15 +1876,12 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root * fixing up pointers when a given leaf/node is not in slot 0 of the * higher levels * * If this fails to write a tree block, it returns -1, but continues * fixing up the blocks in ram so the tree is consistent. */ static int fixup_low_keys(struct btrfs_trans_handle *trans, static void fixup_low_keys(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, int level) { int i; int ret = 0; struct extent_buffer *t; for (i = level; i < BTRFS_MAX_LEVEL; i++) { Loading @@ -1902,7 +1894,6 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans, if (tslot != 0) break; } return ret; } /* Loading @@ -1911,7 +1902,7 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans, * This function isn't completely safe. It's the caller's responsibility * that the new key won't break the order */ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *new_key) { Loading @@ -1923,13 +1914,11 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, slot = path->slots[0]; if (slot > 0) { btrfs_item_key(eb, &disk_key, slot - 1); if (comp_keys(&disk_key, new_key) >= 0) return -1; BUG_ON(comp_keys(&disk_key, new_key) >= 0); } if (slot < btrfs_header_nritems(eb) - 1) { btrfs_item_key(eb, &disk_key, slot + 1); if (comp_keys(&disk_key, new_key) <= 0) return -1; BUG_ON(comp_keys(&disk_key, new_key) <= 0); } btrfs_cpu_key_to_disk(&disk_key, new_key); Loading @@ -1937,7 +1926,6 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, btrfs_mark_buffer_dirty(eb); if (slot == 0) fixup_low_keys(trans, root, path, &disk_key, 1); return 0; } /* Loading Loading @@ -2140,12 +2128,11 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, * * slot and level indicate where you want the key to go, and * blocknr is the block the key points to. * * returns zero on success and < 0 on any error */ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, u64 bytenr, int slot, int level) static void insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, u64 bytenr, int slot, int level) { struct extent_buffer *lower; int nritems; Loading @@ -2155,8 +2142,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root lower = path->nodes[level]; nritems = btrfs_header_nritems(lower); BUG_ON(slot > nritems); if (nritems == BTRFS_NODEPTRS_PER_BLOCK(root)) BUG(); BUG_ON(nritems == BTRFS_NODEPTRS_PER_BLOCK(root)); if (slot != nritems) { memmove_extent_buffer(lower, btrfs_node_key_ptr_offset(slot + 1), Loading @@ -2169,7 +2155,6 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_set_node_ptr_generation(lower, slot, trans->transid); btrfs_set_header_nritems(lower, nritems + 1); btrfs_mark_buffer_dirty(lower); return 0; } /* Loading @@ -2190,7 +2175,6 @@ static noinline int split_node(struct btrfs_trans_handle *trans, struct btrfs_disk_key disk_key; int mid; int ret; int wret; u32 c_nritems; c = path->nodes[level]; Loading Loading @@ -2247,11 +2231,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans, btrfs_mark_buffer_dirty(c); btrfs_mark_buffer_dirty(split); wret = insert_ptr(trans, root, path, &disk_key, split->start, path->slots[level + 1] + 1, level + 1); if (wret) ret = wret; insert_ptr(trans, root, path, &disk_key, split->start, path->slots[level + 1] + 1, level + 1); if (path->slots[level] >= mid) { path->slots[level] -= mid; Loading Loading @@ -2537,7 +2518,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, u32 old_left_nritems; u32 nr; int ret = 0; int wret; u32 this_item_size; u32 old_left_item_size; Loading Loading @@ -2643,9 +2623,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, clean_tree_block(trans, root, right); btrfs_item_key(right, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, 1); /* then fixup the leaf pointer in the path */ if (path->slots[0] < push_items) { Loading Loading @@ -2738,10 +2716,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root /* * split the path's leaf in two, making sure there is at least data_size * available for the resulting leaf level of the path. * * returns 0 if all went well and < 0 on failure. */ static noinline int copy_for_split(struct btrfs_trans_handle *trans, static noinline void copy_for_split(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *l, Loading @@ -2751,8 +2727,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, int data_copy_size; int rt_data_off; int i; int ret = 0; int wret; struct btrfs_disk_key disk_key; nritems = nritems - mid; Loading Loading @@ -2780,12 +2754,9 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, } btrfs_set_header_nritems(l, mid); ret = 0; btrfs_item_key(right, &disk_key, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1] + 1, 1); if (wret) ret = wret; btrfs_mark_buffer_dirty(right); btrfs_mark_buffer_dirty(l); Loading @@ -2803,8 +2774,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, } BUG_ON(path->slots[0] < 0); return ret; } /* Loading Loading @@ -2993,12 +2962,8 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, if (split == 0) { if (mid <= slot) { btrfs_set_header_nritems(right, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1] + 1, 1); if (wret) ret = wret; btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; Loading @@ -3006,29 +2971,21 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, path->slots[1] += 1; } else { btrfs_set_header_nritems(right, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1], 1); if (wret) ret = wret; btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; path->slots[0] = 0; if (path->slots[1] == 0) { wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; } if (path->slots[1] == 0) fixup_low_keys(trans, root, path, &disk_key, 1); } btrfs_mark_buffer_dirty(right); return ret; } ret = copy_for_split(trans, root, path, l, right, slot, mid, nritems); BUG_ON(ret); copy_for_split(trans, root, path, l, right, slot, mid, nritems); if (split == 2) { BUG_ON(num_doubles != 0); Loading @@ -3036,7 +2993,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, goto again; } return ret; return 0; push_for_double: push_for_double_split(trans, root, path, data_size); Loading Loading @@ -3238,11 +3195,9 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, return ret; path->slots[0]++; ret = setup_items_for_insert(trans, root, path, new_key, &item_size, setup_items_for_insert(trans, root, path, new_key, &item_size, item_size, item_size + sizeof(struct btrfs_item), 1); BUG_ON(ret); leaf = path->nodes[0]; memcpy_extent_buffer(leaf, btrfs_item_ptr_offset(leaf, path->slots[0]), Loading @@ -3257,7 +3212,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, * off the end of the item or if we shift the item to chop bytes off * the front. */ int btrfs_truncate_item(struct btrfs_trans_handle *trans, void btrfs_truncate_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u32 new_size, int from_end) Loading @@ -3277,7 +3232,7 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, old_size = btrfs_item_size_nr(leaf, slot); if (old_size == new_size) return 0; return; nritems = btrfs_header_nritems(leaf); data_end = leaf_data_end(root, leaf); Loading Loading @@ -3350,13 +3305,12 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return 0; } /* * make the item pointed to by the path bigger, data_size is the new size. */ int btrfs_extend_item(struct btrfs_trans_handle *trans, void btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u32 data_size) { Loading Loading @@ -3416,7 +3370,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return 0; } /* Loading Loading @@ -3544,7 +3497,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans, ret = 0; if (slot == 0) { btrfs_cpu_key_to_disk(&disk_key, cpu_key); ret = fixup_low_keys(trans, root, path, &disk_key, 1); fixup_low_keys(trans, root, path, &disk_key, 1); } if (btrfs_leaf_free_space(root, leaf) < 0) { Loading @@ -3562,7 +3515,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans, * to save stack depth by doing the bulk of the work in a function * that doesn't call btrfs_search_slot */ int setup_items_for_insert(struct btrfs_trans_handle *trans, void setup_items_for_insert(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *cpu_key, u32 *data_size, u32 total_data, u32 total_size, int nr) Loading @@ -3572,7 +3525,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, u32 nritems; unsigned int data_end; struct btrfs_disk_key disk_key; int ret; struct extent_buffer *leaf; int slot; Loading Loading @@ -3633,10 +3585,9 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, btrfs_set_header_nritems(leaf, nritems + nr); ret = 0; if (slot == 0) { btrfs_cpu_key_to_disk(&disk_key, cpu_key); ret = fixup_low_keys(trans, root, path, &disk_key, 1); fixup_low_keys(trans, root, path, &disk_key, 1); } btrfs_unlock_up_safe(path, 1); btrfs_mark_buffer_dirty(leaf); Loading @@ -3645,7 +3596,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return ret; } /* Loading @@ -3672,16 +3622,14 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, if (ret == 0) return -EEXIST; if (ret < 0) goto out; return ret; slot = path->slots[0]; BUG_ON(slot < 0); ret = setup_items_for_insert(trans, root, path, cpu_key, data_size, setup_items_for_insert(trans, root, path, cpu_key, data_size, total_data, total_size, nr); out: return ret; return 0; } /* Loading Loading @@ -3717,13 +3665,11 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root * the tree should have been previously balanced so the deletion does not * empty a node. */ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level, int slot) { struct extent_buffer *parent = path->nodes[level]; u32 nritems; int ret = 0; int wret; nritems = btrfs_header_nritems(parent); if (slot != nritems - 1) { Loading @@ -3743,12 +3689,9 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_node_key(parent, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, level + 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, level + 1); } btrfs_mark_buffer_dirty(parent); return ret; } /* Loading @@ -3761,17 +3704,13 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, * The path must have already been setup for deleting the leaf, including * all the proper balancing. path->nodes[1] must be locked. */ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *leaf) { int ret; WARN_ON(btrfs_header_generation(leaf) != trans->transid); ret = del_ptr(trans, root, path, 1, path->slots[1]); if (ret) return ret; del_ptr(trans, root, path, 1, path->slots[1]); /* * btrfs_free_extent is expensive, we want to make sure we Loading @@ -3782,7 +3721,6 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, root_sub_used(root, leaf->len); btrfs_free_tree_block(trans, root, leaf, 0, 1, 0); return 0; } /* * delete the item at the leaf level in path. If that empties Loading Loading @@ -3839,8 +3777,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, } else { btrfs_set_path_blocking(path); clean_tree_block(trans, root, leaf); ret = btrfs_del_leaf(trans, root, path, leaf); BUG_ON(ret); btrfs_del_leaf(trans, root, path, leaf); } } else { int used = leaf_space_used(leaf, 0, nritems); Loading @@ -3848,10 +3785,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_item_key(leaf, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, 1); } /* delete the leaf if it is mostly empty */ Loading Loading @@ -3879,9 +3813,9 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, if (btrfs_header_nritems(leaf) == 0) { path->slots[1] = slot; ret = btrfs_del_leaf(trans, root, path, leaf); BUG_ON(ret); btrfs_del_leaf(trans, root, path, leaf); free_extent_buffer(leaf); ret = 0; } else { /* if we're still in the path, make sure * we're dirty. Otherwise, one of the Loading Loading
fs/btrfs/async-thread.c +5 −10 Original line number Diff line number Diff line Loading @@ -171,11 +171,11 @@ static void check_pending_worker_creates(struct btrfs_worker_thread *worker) spin_unlock_irqrestore(&workers->lock, flags); } static noinline int run_ordered_completions(struct btrfs_workers *workers, static noinline void run_ordered_completions(struct btrfs_workers *workers, struct btrfs_work *work) { if (!workers->ordered) return 0; return; set_bit(WORK_DONE_BIT, &work->flags); Loading Loading @@ -213,7 +213,6 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers, } spin_unlock(&workers->order_lock); return 0; } static void put_worker(struct btrfs_worker_thread *worker) Loading Loading @@ -399,7 +398,7 @@ static int worker_loop(void *arg) /* * this will wait for all the worker threads to shutdown */ int btrfs_stop_workers(struct btrfs_workers *workers) void btrfs_stop_workers(struct btrfs_workers *workers) { struct list_head *cur; struct btrfs_worker_thread *worker; Loading Loading @@ -427,7 +426,6 @@ int btrfs_stop_workers(struct btrfs_workers *workers) put_worker(worker); } spin_unlock_irq(&workers->lock); return 0; } /* Loading Loading @@ -615,14 +613,14 @@ static struct btrfs_worker_thread *find_worker(struct btrfs_workers *workers) * it was taken from. It is intended for use with long running work functions * that make some progress and want to give the cpu up for others. */ int btrfs_requeue_work(struct btrfs_work *work) void btrfs_requeue_work(struct btrfs_work *work) { struct btrfs_worker_thread *worker = work->worker; unsigned long flags; int wake = 0; if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags)) goto out; return; spin_lock_irqsave(&worker->lock, flags); if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags)) Loading @@ -649,9 +647,6 @@ int btrfs_requeue_work(struct btrfs_work *work) if (wake) wake_up_process(worker->task); spin_unlock_irqrestore(&worker->lock, flags); out: return 0; } void btrfs_set_work_high_prio(struct btrfs_work *work) Loading
fs/btrfs/async-thread.h +2 −2 Original line number Diff line number Diff line Loading @@ -111,9 +111,9 @@ struct btrfs_workers { void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); int btrfs_start_workers(struct btrfs_workers *workers); int btrfs_stop_workers(struct btrfs_workers *workers); void btrfs_stop_workers(struct btrfs_workers *workers); void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max, struct btrfs_workers *async_starter); int btrfs_requeue_work(struct btrfs_work *work); void btrfs_requeue_work(struct btrfs_work *work); void btrfs_set_work_high_prio(struct btrfs_work *work); #endif
fs/btrfs/compression.c +3 −5 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ static void end_compressed_bio_read(struct bio *bio, int err) * Clear the writeback bits on all of the file * pages for a compressed write */ static noinline int end_compressed_writeback(struct inode *inode, u64 start, static noinline void end_compressed_writeback(struct inode *inode, u64 start, unsigned long ram_size) { unsigned long index = start >> PAGE_CACHE_SHIFT; Loading @@ -253,7 +253,6 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start, index += ret; } /* the inode may be gone now */ return 0; } /* Loading Loading @@ -734,7 +733,7 @@ struct btrfs_compress_op *btrfs_compress_op[] = { &btrfs_lzo_compress, }; int __init btrfs_init_compress(void) void __init btrfs_init_compress(void) { int i; Loading @@ -744,7 +743,6 @@ int __init btrfs_init_compress(void) atomic_set(&comp_alloc_workspace[i], 0); init_waitqueue_head(&comp_workspace_wait[i]); } return 0; } /* Loading
fs/btrfs/compression.h +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ #ifndef __BTRFS_COMPRESSION_ #define __BTRFS_COMPRESSION_ int btrfs_init_compress(void); void btrfs_init_compress(void); void btrfs_exit_compress(void); int btrfs_compress_pages(int type, struct address_space *mapping, Loading
fs/btrfs/ctree.c +67 −133 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *dst_buf, struct extent_buffer *src_buf); static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level, int slot); struct btrfs_path *btrfs_alloc_path(void) Loading Loading @@ -1010,10 +1010,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(right) == 0) { clean_tree_block(trans, root, right); btrfs_tree_unlock(right); wret = del_ptr(trans, root, path, level + 1, pslot + 1); if (wret) ret = wret; del_ptr(trans, root, path, level + 1, pslot + 1); root_sub_used(root, right->len); btrfs_free_tree_block(trans, root, right, 0, 1, 0); free_extent_buffer(right); Loading Loading @@ -1051,9 +1048,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (btrfs_header_nritems(mid) == 0) { clean_tree_block(trans, root, mid); btrfs_tree_unlock(mid); wret = del_ptr(trans, root, path, level + 1, pslot); if (wret) ret = wret; del_ptr(trans, root, path, level + 1, pslot); root_sub_used(root, mid->len); btrfs_free_tree_block(trans, root, mid, 0, 1, 0); free_extent_buffer(mid); Loading Loading @@ -1881,15 +1876,12 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root * fixing up pointers when a given leaf/node is not in slot 0 of the * higher levels * * If this fails to write a tree block, it returns -1, but continues * fixing up the blocks in ram so the tree is consistent. */ static int fixup_low_keys(struct btrfs_trans_handle *trans, static void fixup_low_keys(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, int level) { int i; int ret = 0; struct extent_buffer *t; for (i = level; i < BTRFS_MAX_LEVEL; i++) { Loading @@ -1902,7 +1894,6 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans, if (tslot != 0) break; } return ret; } /* Loading @@ -1911,7 +1902,7 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans, * This function isn't completely safe. It's the caller's responsibility * that the new key won't break the order */ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *new_key) { Loading @@ -1923,13 +1914,11 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, slot = path->slots[0]; if (slot > 0) { btrfs_item_key(eb, &disk_key, slot - 1); if (comp_keys(&disk_key, new_key) >= 0) return -1; BUG_ON(comp_keys(&disk_key, new_key) >= 0); } if (slot < btrfs_header_nritems(eb) - 1) { btrfs_item_key(eb, &disk_key, slot + 1); if (comp_keys(&disk_key, new_key) <= 0) return -1; BUG_ON(comp_keys(&disk_key, new_key) <= 0); } btrfs_cpu_key_to_disk(&disk_key, new_key); Loading @@ -1937,7 +1926,6 @@ int btrfs_set_item_key_safe(struct btrfs_trans_handle *trans, btrfs_mark_buffer_dirty(eb); if (slot == 0) fixup_low_keys(trans, root, path, &disk_key, 1); return 0; } /* Loading Loading @@ -2140,12 +2128,11 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, * * slot and level indicate where you want the key to go, and * blocknr is the block the key points to. * * returns zero on success and < 0 on any error */ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, u64 bytenr, int slot, int level) static void insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, u64 bytenr, int slot, int level) { struct extent_buffer *lower; int nritems; Loading @@ -2155,8 +2142,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root lower = path->nodes[level]; nritems = btrfs_header_nritems(lower); BUG_ON(slot > nritems); if (nritems == BTRFS_NODEPTRS_PER_BLOCK(root)) BUG(); BUG_ON(nritems == BTRFS_NODEPTRS_PER_BLOCK(root)); if (slot != nritems) { memmove_extent_buffer(lower, btrfs_node_key_ptr_offset(slot + 1), Loading @@ -2169,7 +2155,6 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_set_node_ptr_generation(lower, slot, trans->transid); btrfs_set_header_nritems(lower, nritems + 1); btrfs_mark_buffer_dirty(lower); return 0; } /* Loading @@ -2190,7 +2175,6 @@ static noinline int split_node(struct btrfs_trans_handle *trans, struct btrfs_disk_key disk_key; int mid; int ret; int wret; u32 c_nritems; c = path->nodes[level]; Loading Loading @@ -2247,11 +2231,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans, btrfs_mark_buffer_dirty(c); btrfs_mark_buffer_dirty(split); wret = insert_ptr(trans, root, path, &disk_key, split->start, path->slots[level + 1] + 1, level + 1); if (wret) ret = wret; insert_ptr(trans, root, path, &disk_key, split->start, path->slots[level + 1] + 1, level + 1); if (path->slots[level] >= mid) { path->slots[level] -= mid; Loading Loading @@ -2537,7 +2518,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, u32 old_left_nritems; u32 nr; int ret = 0; int wret; u32 this_item_size; u32 old_left_item_size; Loading Loading @@ -2643,9 +2623,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, clean_tree_block(trans, root, right); btrfs_item_key(right, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, 1); /* then fixup the leaf pointer in the path */ if (path->slots[0] < push_items) { Loading Loading @@ -2738,10 +2716,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root /* * split the path's leaf in two, making sure there is at least data_size * available for the resulting leaf level of the path. * * returns 0 if all went well and < 0 on failure. */ static noinline int copy_for_split(struct btrfs_trans_handle *trans, static noinline void copy_for_split(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *l, Loading @@ -2751,8 +2727,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, int data_copy_size; int rt_data_off; int i; int ret = 0; int wret; struct btrfs_disk_key disk_key; nritems = nritems - mid; Loading Loading @@ -2780,12 +2754,9 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, } btrfs_set_header_nritems(l, mid); ret = 0; btrfs_item_key(right, &disk_key, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1] + 1, 1); if (wret) ret = wret; btrfs_mark_buffer_dirty(right); btrfs_mark_buffer_dirty(l); Loading @@ -2803,8 +2774,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, } BUG_ON(path->slots[0] < 0); return ret; } /* Loading Loading @@ -2993,12 +2962,8 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, if (split == 0) { if (mid <= slot) { btrfs_set_header_nritems(right, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1] + 1, 1); if (wret) ret = wret; btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; Loading @@ -3006,29 +2971,21 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, path->slots[1] += 1; } else { btrfs_set_header_nritems(right, 0); wret = insert_ptr(trans, root, path, &disk_key, right->start, insert_ptr(trans, root, path, &disk_key, right->start, path->slots[1], 1); if (wret) ret = wret; btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; path->slots[0] = 0; if (path->slots[1] == 0) { wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; } if (path->slots[1] == 0) fixup_low_keys(trans, root, path, &disk_key, 1); } btrfs_mark_buffer_dirty(right); return ret; } ret = copy_for_split(trans, root, path, l, right, slot, mid, nritems); BUG_ON(ret); copy_for_split(trans, root, path, l, right, slot, mid, nritems); if (split == 2) { BUG_ON(num_doubles != 0); Loading @@ -3036,7 +2993,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, goto again; } return ret; return 0; push_for_double: push_for_double_split(trans, root, path, data_size); Loading Loading @@ -3238,11 +3195,9 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, return ret; path->slots[0]++; ret = setup_items_for_insert(trans, root, path, new_key, &item_size, setup_items_for_insert(trans, root, path, new_key, &item_size, item_size, item_size + sizeof(struct btrfs_item), 1); BUG_ON(ret); leaf = path->nodes[0]; memcpy_extent_buffer(leaf, btrfs_item_ptr_offset(leaf, path->slots[0]), Loading @@ -3257,7 +3212,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans, * off the end of the item or if we shift the item to chop bytes off * the front. */ int btrfs_truncate_item(struct btrfs_trans_handle *trans, void btrfs_truncate_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u32 new_size, int from_end) Loading @@ -3277,7 +3232,7 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, old_size = btrfs_item_size_nr(leaf, slot); if (old_size == new_size) return 0; return; nritems = btrfs_header_nritems(leaf); data_end = leaf_data_end(root, leaf); Loading Loading @@ -3350,13 +3305,12 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return 0; } /* * make the item pointed to by the path bigger, data_size is the new size. */ int btrfs_extend_item(struct btrfs_trans_handle *trans, void btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u32 data_size) { Loading Loading @@ -3416,7 +3370,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return 0; } /* Loading Loading @@ -3544,7 +3497,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans, ret = 0; if (slot == 0) { btrfs_cpu_key_to_disk(&disk_key, cpu_key); ret = fixup_low_keys(trans, root, path, &disk_key, 1); fixup_low_keys(trans, root, path, &disk_key, 1); } if (btrfs_leaf_free_space(root, leaf) < 0) { Loading @@ -3562,7 +3515,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans, * to save stack depth by doing the bulk of the work in a function * that doesn't call btrfs_search_slot */ int setup_items_for_insert(struct btrfs_trans_handle *trans, void setup_items_for_insert(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key *cpu_key, u32 *data_size, u32 total_data, u32 total_size, int nr) Loading @@ -3572,7 +3525,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, u32 nritems; unsigned int data_end; struct btrfs_disk_key disk_key; int ret; struct extent_buffer *leaf; int slot; Loading Loading @@ -3633,10 +3585,9 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, btrfs_set_header_nritems(leaf, nritems + nr); ret = 0; if (slot == 0) { btrfs_cpu_key_to_disk(&disk_key, cpu_key); ret = fixup_low_keys(trans, root, path, &disk_key, 1); fixup_low_keys(trans, root, path, &disk_key, 1); } btrfs_unlock_up_safe(path, 1); btrfs_mark_buffer_dirty(leaf); Loading @@ -3645,7 +3596,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } return ret; } /* Loading @@ -3672,16 +3622,14 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, if (ret == 0) return -EEXIST; if (ret < 0) goto out; return ret; slot = path->slots[0]; BUG_ON(slot < 0); ret = setup_items_for_insert(trans, root, path, cpu_key, data_size, setup_items_for_insert(trans, root, path, cpu_key, data_size, total_data, total_size, nr); out: return ret; return 0; } /* Loading Loading @@ -3717,13 +3665,11 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root * the tree should have been previously balanced so the deletion does not * empty a node. */ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level, int slot) { struct extent_buffer *parent = path->nodes[level]; u32 nritems; int ret = 0; int wret; nritems = btrfs_header_nritems(parent); if (slot != nritems - 1) { Loading @@ -3743,12 +3689,9 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_node_key(parent, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, level + 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, level + 1); } btrfs_mark_buffer_dirty(parent); return ret; } /* Loading @@ -3761,17 +3704,13 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, * The path must have already been setup for deleting the leaf, including * all the proper balancing. path->nodes[1] must be locked. */ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *leaf) { int ret; WARN_ON(btrfs_header_generation(leaf) != trans->transid); ret = del_ptr(trans, root, path, 1, path->slots[1]); if (ret) return ret; del_ptr(trans, root, path, 1, path->slots[1]); /* * btrfs_free_extent is expensive, we want to make sure we Loading @@ -3782,7 +3721,6 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, root_sub_used(root, leaf->len); btrfs_free_tree_block(trans, root, leaf, 0, 1, 0); return 0; } /* * delete the item at the leaf level in path. If that empties Loading Loading @@ -3839,8 +3777,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, } else { btrfs_set_path_blocking(path); clean_tree_block(trans, root, leaf); ret = btrfs_del_leaf(trans, root, path, leaf); BUG_ON(ret); btrfs_del_leaf(trans, root, path, leaf); } } else { int used = leaf_space_used(leaf, 0, nritems); Loading @@ -3848,10 +3785,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_disk_key disk_key; btrfs_item_key(leaf, &disk_key, 0); wret = fixup_low_keys(trans, root, path, &disk_key, 1); if (wret) ret = wret; fixup_low_keys(trans, root, path, &disk_key, 1); } /* delete the leaf if it is mostly empty */ Loading Loading @@ -3879,9 +3813,9 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, if (btrfs_header_nritems(leaf) == 0) { path->slots[1] = slot; ret = btrfs_del_leaf(trans, root, path, leaf); BUG_ON(ret); btrfs_del_leaf(trans, root, path, leaf); free_extent_buffer(leaf); ret = 0; } else { /* if we're still in the path, make sure * we're dirty. Otherwise, one of the Loading