Here''s my current error handling patchset, against Chris''s current for-linus branch. As before, it''s almost all in preparation for actual error handling. After a chat with Chris last week about some of the bits I thought might be contentious, I went ahead with the next step and converted struct extent_state allocations to use a mempool in front of the slab cache it was using already. This means that non-atomic callers can''t catch an -ENOMEM and that means that non-atomic version of {set,clear,convert}_extent_bit can return void. This changes the previous patch set quite a bit since the {set,clear,convert}_extent_bit error push-up patches are now entirely obsolete. The run down: - extent_state allocations -> mempool - delayed_ref allocations -> mempool - a ton of int -> void changes - add btrfs_panic - a few cleanups where I ran into them -Jeff -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
As part of the effort to eliminate BUG_ON as an error handling technique, we need to determine which errors are actual logic errors, which are on-disk corruption, and which are normal runtime errors e.g. -ENOMEM. Annotating these error cases is helpful to understand and report them. This patch adds a btrfs_panic() routine that will either panic or BUG depending on the new -ofatal_errors={panic,bug} mount option. Since there are still so many BUG_ONs, it defaults to BUG for now but I expect that to change once the error handling effort has made significant progress. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 11 +++++++++++ fs/btrfs/super.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1413,6 +1413,7 @@ struct btrfs_ioctl_defrag_range_args { #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) #define BTRFS_MOUNT_RECOVERY (1 << 18) +#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 19) #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) @@ -2771,6 +2772,16 @@ do { \ __btrfs_std_error((fs_info), __func__, __LINE__, (errno));\ } while (0) +void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, + unsigned int line, int errno, const char *fmt, ...); + +#define btrfs_panic(fs_info, errno, fmt, args...) \ +do { \ + struct btrfs_fs_info *_i = (fs_info); \ + __btrfs_panic(_i, __func__, __LINE__, errno, fmt, ##args); \ + BUG_ON(!(_i->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)); \ +} while (0) + /* acl.c */ #ifdef CONFIG_BTRFS_FS_POSIX_ACL struct posix_acl *btrfs_get_acl(struct inode *inode, int type); --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -76,6 +76,9 @@ static const char *btrfs_decode_error(st case -EROFS: errstr = "Readonly filesystem"; break; + case -EEXIST: + errstr = "Object already exists"; + break; default: if (nbuf) { if (snprintf(nbuf, 16, "error %d", -errno) >= 0) @@ -145,6 +148,36 @@ void __btrfs_std_error(struct btrfs_fs_i btrfs_handle_error(fs_info); } +/* + * __btrfs_panic decodes unexpected, fatal errors from the caller, + * issues an alert, and either panics or BUGs, depending on mount options. + */ +void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, + unsigned int line, int errno, const char *fmt, ...) +{ + char nbuf[16]; + char *s_id = "<unknown>"; + const char *errstr; + struct va_format vaf = { .fmt = fmt }; + va_list args; + + if (fs_info) + s_id = fs_info->sb->s_id; + + va_start(args, fmt); + vaf.va = &args; + + errstr = btrfs_decode_error(fs_info, errno, nbuf); + if (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR) + panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", + s_id, function, line, &vaf, errstr); + + printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", + s_id, function, line, &vaf, errstr); + va_end(args); + /* Caller calls BUG() */ +} + static void btrfs_put_super(struct super_block *sb) { struct btrfs_root *root = btrfs_sb(sb); @@ -164,7 +197,8 @@ enum { Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, - Opt_inode_cache, Opt_no_space_cache, Opt_recovery, Opt_err, + Opt_inode_cache, Opt_no_space_cache, Opt_recovery, Opt_fatal_errors, + Opt_err, }; static match_table_t tokens = { @@ -199,6 +233,7 @@ static match_table_t tokens = { {Opt_inode_cache, "inode_cache"}, {Opt_no_space_cache, "nospace_cache"}, {Opt_recovery, "recovery"}, + {Opt_fatal_errors, "fatal_errors=%s"}, {Opt_err, NULL}, }; @@ -397,6 +432,18 @@ int btrfs_parse_options(struct btrfs_roo printk(KERN_INFO "btrfs: enabling auto recovery"); btrfs_set_opt(info->mount_opt, RECOVERY); break; + case Opt_fatal_errors: + if (strcmp(args[0].from, "panic") == 0) + btrfs_set_opt(info->mount_opt, + PANIC_ON_FATAL_ERROR); + else if (strcmp(args[0].from, "bug") == 0) + btrfs_clear_opt(info->mount_opt, + PANIC_ON_FATAL_ERROR); + else { + ret = -EINVAL; + goto out; + } + break; case Opt_err: printk(KERN_INFO "btrfs: unrecognized mount option " "''%s''\n", p); @@ -722,6 +769,8 @@ static int btrfs_show_options(struct seq seq_puts(seq, ",autodefrag"); if (btrfs_test_opt(root, INODE_MAP_CACHE)) seq_puts(seq, ",inode_cache"); + if (btrfs_test_opt(root, PANIC_ON_FATAL_ERROR)) + seq_puts(seq, ",fatal_errors=panic"); return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 02/99] btrfs: Catch locking failures in {set,clear,convert}_extent_bit
The *_state functions can only return 0 or -EEXIST. This patch addresses the cases where those functions returning -EEXIST represent a locking failure. It handles them by panicking with an appropriate error message. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 58 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 20 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -51,6 +51,12 @@ struct extent_page_data { unsigned int sync_io:1; }; +static inline struct btrfs_fs_info * +tree_fs_info(struct extent_io_tree *tree) +{ + return btrfs_sb(tree->mapping->host->i_sb)->fs_info; +} + int __init extent_io_init(void) { extent_state_cache = kmem_cache_create("extent_state", @@ -437,6 +443,13 @@ alloc_extent_state_atomic(struct extent_ return prealloc; } +NORET_TYPE void extent_io_tree_panic(struct extent_io_tree *tree, int err) +{ + btrfs_panic(tree_fs_info(tree), err, "Locking error: " + "Extent tree was modified by another " + "thread while locked."); +} + /* * clear some bits on a range in the tree. This may require splitting * or inserting elements in the tree, so the gfp mask is used to @@ -531,7 +544,9 @@ hit_next: prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, start); - BUG_ON(err == -EEXIST); + if (err) + extent_io_tree_panic(tree, err); + prealloc = NULL; if (err) goto out; @@ -553,7 +568,9 @@ hit_next: prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, end + 1); - BUG_ON(err == -EEXIST); + if (err) + extent_io_tree_panic(tree, err); + if (wake) wake_up(&state->wq); @@ -736,8 +753,10 @@ again: prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = insert_state(tree, prealloc, start, end, &bits); + if (err) + extent_io_tree_panic(tree, err); + prealloc = NULL; - BUG_ON(err == -EEXIST); goto out; } state = rb_entry(node, struct extent_state, rb_node); @@ -803,7 +822,9 @@ hit_next: prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, start); - BUG_ON(err == -EEXIST); + if (err) + extent_io_tree_panic(tree, err); + prealloc = NULL; if (err) goto out; @@ -840,12 +861,9 @@ hit_next: */ err = insert_state(tree, prealloc, start, this_end, &bits); - BUG_ON(err == -EEXIST); - if (err) { - free_extent_state(prealloc); - prealloc = NULL; - goto out; - } + if (err) + extent_io_tree_panic(tree, err); + cache_state(prealloc, cached_state); prealloc = NULL; start = this_end + 1; @@ -867,7 +885,8 @@ hit_next: prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, end + 1); - BUG_ON(err == -EEXIST); + if (err) + extent_io_tree_panic(tree, err); set_state_bits(tree, prealloc, &bits); cache_state(prealloc, cached_state); #@@ -938,7 +957,8 @@ again: # return -ENOMEM; # err = insert_state(tree, prealloc, start, end, &bits); # prealloc = NULL; #- BUG_ON(err == -EEXIST); #+ if (err) #+ extent_io_tree_panic(tree, err); # goto out; # } # state = rb_entry(node, struct extent_state, rb_node); #@@ -994,7 +1014,8 @@ hit_next: # if (!prealloc) # return -ENOMEM; # err = split_state(tree, state, prealloc, start); #- BUG_ON(err == -EEXIST); #+ if (err) #+ extent_io_tree_panic(tree, err); # prealloc = NULL; # if (err) # goto out; #@@ -1032,12 +1053,8 @@ hit_next: # */ # err = insert_state(tree, prealloc, start, this_end, # &bits); #- BUG_ON(err == -EEXIST); #- if (err) { #- free_extent_state(prealloc); #- prealloc = NULL; #- goto out; #- } #+ if (err) #+ extent_io_tree_panic(tree, err); # prealloc = NULL; # start = this_end + 1; # goto search_again; #@@ -1054,7 +1071,8 @@ hit_next: # return -ENOMEM; # # err = split_state(tree, state, prealloc, end + 1); #- BUG_ON(err == -EEXIST); #+ if (err) #+ extent_io_tree_panic(tree, err); # # set_state_bits(tree, prealloc, &bits); # clear_state_bit(tree, prealloc, &clear_bits, 0); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
The ordered data and relocation trees have BUG_ONs to protect against bad tree operations. This patch replaces them with a panic that will report the problem. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 12 ++++++++++-- fs/btrfs/relocation.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index a1c9404..5a53d94 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -59,6 +59,14 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, return NULL; } +NORET_TYPE static void ordered_data_tree_panic(struct inode *inode, int errno, + u64 offset) +{ + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb)->fs_info; + btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at offset " + "%llu\n", offset); +} + /* * look for a given offset in the tree, and if it can''t be found return the * first lesser offset @@ -207,7 +215,8 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, spin_lock(&tree->lock); node = tree_insert(&tree->tree, file_offset, &entry->rb_node); - BUG_ON(node); + if (node) + ordered_data_tree_panic(inode, -EEXIST, file_offset); spin_unlock(&tree->lock); spin_lock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); @@ -215,7 +224,6 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, &BTRFS_I(inode)->root->fs_info->ordered_extents); spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); - BUG_ON(node); return 0; } diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 7fa090f..a222957 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -326,6 +326,19 @@ static struct rb_node *tree_search(struct rb_root *root, u64 bytenr) return NULL; } +NORET_TYPE static void backref_tree_panic(struct rb_node *rb_node, int errno, + u64 bytenr) +{ + + struct btrfs_fs_info *fs_info = NULL; + struct backref_node *bnode = rb_entry(rb_node, struct backref_node, + rb_node); + if (bnode->root) + fs_info = bnode->root->fs_info; + btrfs_panic(fs_info, errno, "Inconsistency in backref cache " + "found at offset %llu\n", bytenr); +} + /* * walk up backref nodes until reach node presents tree root */ @@ -452,7 +465,8 @@ static void update_backref_node(struct backref_cache *cache, rb_erase(&node->rb_node, &cache->rb_root); node->bytenr = bytenr; rb_node = tree_insert(&cache->rb_root, node->bytenr, &node->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, bytenr); } /* @@ -999,7 +1013,8 @@ next: if (!cowonly) { rb_node = tree_insert(&cache->rb_root, node->bytenr, &node->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, node->bytenr); list_add_tail(&node->lower, &cache->leaves); } @@ -1034,7 +1049,9 @@ next: if (!cowonly) { rb_node = tree_insert(&cache->rb_root, upper->bytenr, &upper->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, + upper->bytenr); } list_add_tail(&edge->list[UPPER], &upper->lower); @@ -1178,7 +1195,8 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, rb_node = tree_insert(&cache->rb_root, new_node->bytenr, &new_node->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, new_node->bytenr); if (!new_node->lowest) { list_for_each_entry(new_edge, &new_node->lower, list[UPPER]) { @@ -1250,7 +1268,8 @@ static int __update_reloc_root(struct btrfs_root *root, int del) rb_node = tree_insert(&rc->reloc_root_tree.rb_root, node->bytenr, &node->rb_node); spin_unlock(&rc->reloc_root_tree.lock); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, node->bytenr); } else { list_del_init(&root->root_list); kfree(node); @@ -3151,7 +3170,8 @@ static int add_tree_block(struct reloc_control *rc, block->key_ready = 0; rb_node = tree_insert(blocks, block->bytenr, &block->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, block->bytenr); return 0; } @@ -3420,7 +3440,9 @@ static int find_data_references(struct reloc_control *rc, block->key_ready = 1; rb_node = tree_insert(blocks, block->bytenr, &block->rb_node); - BUG_ON(rb_node); + if (rb_node) + backref_tree_panic(rb_node, -EEXIST, + block->bytenr); } if (counted) added = 1; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
btrfs_insert_root is just a wrapper for btrfs_insert_item. Just return the error directly. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/root-tree.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index f409990..1fd93d6 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -116,13 +116,10 @@ out: return ret; } -int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root - *root, struct btrfs_key *key, struct btrfs_root_item - *item) +int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct btrfs_key *key, struct btrfs_root_item *item) { - int ret; - ret = btrfs_insert_item(trans, root, key, item, sizeof(*item)); - return ret; + return btrfs_insert_item(trans, root, key, item, sizeof(*item)); } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 05/99] btrfs: Remove set bits return from clear_extent_bit
There is only one caller of clear_extent_bit that checks the return value and it only checks if it''s negative. Since there are no users of the returned bits functionality of clear_extent_bit, stop returning it and avoid complicating error handling. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -460,8 +460,7 @@ NORET_TYPE void extent_io_tree_panic(str * * the range [start, end] is inclusive. * - * This takes the tree lock, and returns < 0 on error, > 0 if any of the - * bits were already set, or zero if none of the bits were already set. + * This takes the tree lock, and returns 0 on success and < 0 on error. */ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, @@ -475,7 +474,6 @@ int clear_extent_bit(struct extent_io_tr struct rb_node *node; u64 last_end; int err; - int set = 0; int clear = 0; if (delete) @@ -551,7 +549,7 @@ hit_next: if (err) goto out; if (state->end <= end) { - set |= clear_state_bit(tree, state, &bits, wake); + clear_state_bit(tree, state, &bits, wake); if (last_end == (u64)-1) goto out; start = last_end + 1; @@ -574,7 +572,7 @@ hit_next: if (wake) wake_up(&state->wq); - set |= clear_state_bit(tree, prealloc, &bits, wake); + clear_state_bit(tree, prealloc, &bits, wake); prealloc = NULL; goto out; @@ -585,7 +583,7 @@ hit_next: else next_node = NULL; - set |= clear_state_bit(tree, state, &bits, wake); + clear_state_bit(tree, state, &bits, wake); if (last_end == (u64)-1) goto out; start = last_end + 1; @@ -602,7 +600,7 @@ out: if (prealloc) free_extent_state(prealloc); - return set; + return 0; search_again: if (start > end) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 06/99] btrfs: Add extent_state alloc/free tracing
While debugging the error handling patches, I found it useful to trace the allocation and freeing of extent_state structures. As a side note, a huge number of allocations have lifetimes in the < 10 us range. This patch adds the trace, including caller and object address. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 2 + include/trace/events/btrfs.h | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -141,6 +141,7 @@ static struct extent_state *alloc_extent #endif atomic_set(&state->refs, 1); init_waitqueue_head(&state->wq); + trace_alloc_extent_state(state, mask, _RET_IP_); return state; } @@ -158,6 +159,7 @@ void free_extent_state(struct extent_sta list_del(&state->leak_list); spin_unlock_irqrestore(&leak_lock, flags); #endif + trace_free_extent_state(state, _RET_IP_); kmem_cache_free(extent_state_cache, state); } } --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -6,6 +6,7 @@ #include <linux/writeback.h> #include <linux/tracepoint.h> +#include <trace/events/gfpflags.h> struct btrfs_root; struct btrfs_fs_info; @@ -661,6 +662,49 @@ DEFINE_EVENT(btrfs__reserved_extent, bt TP_ARGS(root, start, len) ); +struct extent_state; +TRACE_EVENT(alloc_extent_state, + + TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP), + + TP_ARGS(state, mask, IP), + + TP_STRUCT__entry( + __field(struct extent_state *, state) + __field(gfp_t, mask) + __field(unsigned long, ip) + ), + + TP_fast_assign( + __entry->state = state, + __entry->mask = mask, + __entry->ip = IP + ), + + TP_printk("state=%p; mask = %s; caller = %pF", __entry->state, + show_gfp_flags(__entry->mask), (void *)__entry->ip) +); + +TRACE_EVENT(free_extent_state, + + TP_PROTO(struct extent_state *state, unsigned long IP), + + TP_ARGS(state, IP), + + TP_STRUCT__entry( + __field(struct extent_state *, state) + __field(unsigned long, ip) + ), + + TP_fast_assign( + __entry->state = state, + __entry->ip = IP + ), + + TP_printk(" state=%p; caller = %pF", __entry->state, + (void *)__entry->ip) +); + #endif /* _TRACE_BTRFS_H */ /* This part must be outside protection */ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 07/99] btrfs: Use mempools for extent_state structures
The extent_state structure is used at the core of the extent i/o code for managing flags, locking, etc. It requires allocations deep in the write code and if failures occur they are difficult to recover from. We avoid most of the failures by using a mempool, which can sleep when required, to honor the allocations. This allows future patches to convert most of the {set,clear,convert}_extent_bit and derivatives to return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 71 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 20 deletions(-) Index: source/fs/btrfs/extent_io.c ==================================================================--- source.orig/fs/btrfs/extent_io.c 2011-11-21 14:13:55.000000000 -0500 +++ source/fs/btrfs/extent_io.c 2011-11-21 14:38:23.000000000 -0500 @@ -12,6 +12,7 @@ #include <linux/pagevec.h> #include <linux/prefetch.h> #include <linux/cleancache.h> +#include <linux/mempool.h> #include "extent_io.h" #include "extent_map.h" #include "compat.h" @@ -21,6 +22,8 @@ static struct kmem_cache *extent_state_cache; static struct kmem_cache *extent_buffer_cache; +static mempool_t *extent_state_pool; +#define EXTENT_STATE_POOL_SIZE (64*1024) static LIST_HEAD(buffers); static LIST_HEAD(states); @@ -61,18 +64,28 @@ tree_fs_info(struct extent_io_tree *tree int __init extent_io_init(void) { extent_state_cache = kmem_cache_create("extent_state", - sizeof(struct extent_state), 0, - SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL); + sizeof(struct extent_state), 0, + SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, + NULL); if (!extent_state_cache) return -ENOMEM; + extent_state_pool = mempool_create_slab_pool( + EXTENT_STATE_POOL_SIZE / + sizeof(struct extent_state), + extent_state_cache); + if (!extent_state_pool) + goto free_state_cache; + extent_buffer_cache = kmem_cache_create("extent_buffers", sizeof(struct extent_buffer), 0, SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL); if (!extent_buffer_cache) - goto free_state_cache; + goto free_state_mempool; return 0; +free_state_mempool: + mempool_destroy(extent_state_pool); free_state_cache: kmem_cache_destroy(extent_state_cache); return -ENOMEM; @@ -103,6 +116,8 @@ void extent_io_exit(void) list_del(&eb->leak_list); kmem_cache_free(extent_buffer_cache, eb); } + if (extent_state_pool) + mempool_destroy(extent_state_pool); if (extent_state_cache) kmem_cache_destroy(extent_state_cache); if (extent_buffer_cache) @@ -128,7 +143,7 @@ static struct extent_state *alloc_extent unsigned long flags; #endif - state = kmem_cache_alloc(extent_state_cache, mask); + state = mempool_alloc(extent_state_pool, mask); if (!state) return state; state->state = 0; @@ -145,6 +160,12 @@ static struct extent_state *alloc_extent return state; } +static struct extent_state *alloc_extent_state_nofail(gfp_t mask) +{ + BUG_ON(!(mask & __GFP_WAIT)); + return alloc_extent_state(mask); +} + void free_extent_state(struct extent_state *state) { if (!state) @@ -160,7 +181,7 @@ void free_extent_state(struct extent_sta spin_unlock_irqrestore(&leak_lock, flags); #endif trace_free_extent_state(state, _RET_IP_); - kmem_cache_free(extent_state_cache, state); + mempool_free(state, extent_state_pool); } } @@ -437,6 +458,12 @@ static int clear_state_bit(struct extent return ret; } +static void +assert_atomic_alloc(struct extent_state *prealloc, gfp_t mask) +{ + WARN_ON(!prealloc && (mask & __GFP_WAIT)); +} + static struct extent_state * alloc_extent_state_atomic(struct extent_state *prealloc) { @@ -464,6 +491,7 @@ NORET_TYPE void extent_io_tree_panic(str * the range [start, end] is inclusive. * * This takes the tree lock, and returns 0 on success and < 0 on error. + * If (mask & __GFP_WAIT) == 0, there are no error conditions. */ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, @@ -486,11 +514,8 @@ int clear_extent_bit(struct extent_io_tr if (bits & (EXTENT_IOBITS | EXTENT_BOUNDARY)) clear = 1; again: - if (!prealloc && (mask & __GFP_WAIT)) { - prealloc = alloc_extent_state(mask); - if (!prealloc) - return -ENOMEM; - } + if (!prealloc && (mask & __GFP_WAIT)) + prealloc = alloc_extent_state_nofail(mask); spin_lock(&tree->lock); if (cached_state) { @@ -542,6 +567,7 @@ hit_next: */ if (state->start < start) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, start); @@ -566,6 +592,7 @@ hit_next: * on the first half */ if (state->start <= end && state->end > end) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, end + 1); @@ -726,15 +753,14 @@ int set_extent_bit(struct extent_io_tree struct extent_state *prealloc = NULL; struct rb_node *node; int err = 0; + int wait = mask & __GFP_WAIT; u64 last_start; u64 last_end; bits |= EXTENT_FIRST_DELALLOC; again: - if (!prealloc && (mask & __GFP_WAIT)) { - prealloc = alloc_extent_state(mask); - BUG_ON(!prealloc); - } + if (!prealloc && wait) + prealloc = alloc_extent_state_nofail(mask); spin_lock(&tree->lock); if (cached_state && *cached_state) { @@ -751,6 +777,7 @@ again: */ node = tree_search(tree, start); if (!node) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = insert_state(tree, prealloc, start, end, &bits); @@ -820,6 +847,7 @@ hit_next: goto out; } + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, start); @@ -853,6 +881,7 @@ hit_next: else this_end = last_start - 1; + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); @@ -883,6 +912,7 @@ hit_next: goto out; } + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, end + 1); @@ -909,7 +939,7 @@ search_again: if (start > end) goto out; spin_unlock(&tree->lock); - if (mask & __GFP_WAIT) + if (wait) cond_resched(); goto again; } @@ -940,11 +970,8 @@ int convert_extent_bit(struct extent_io_ u64 last_end; again: - if (!prealloc && (mask & __GFP_WAIT)) { - prealloc = alloc_extent_state(mask); - if (!prealloc) - return -ENOMEM; - } + if (!prealloc && (mask & __GFP_WAIT)) + prealloc = alloc_extent_state_nofail(mask); spin_lock(&tree->lock); /* @@ -953,6 +980,7 @@ again: */ node = tree_search(tree, start); if (!node) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); if (!prealloc) return -ENOMEM; @@ -1010,6 +1038,7 @@ hit_next: * desired bit on it. */ if (state->start < start) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); if (!prealloc) return -ENOMEM; @@ -1042,6 +1071,7 @@ hit_next: else this_end = last_start - 1; + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); if (!prealloc) return -ENOMEM; @@ -1069,6 +1099,7 @@ hit_next: * on the first half */ if (state->start <= end && state->end > end) { + assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); if (!prealloc) return -ENOMEM; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 08/99] btrfs: clear_extent_bit should return void with __GFP_WAIT set
Now that allocations that are allowed to sleep can''t fail, clear_extent_bit has no more error conditions and we can assume the return value will be 0 and return void to callers. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 126 +++++++++++++++++++++++++++++---------------------- fs/btrfs/extent_io.h | 28 +++++------ 2 files changed, 88 insertions(+), 66 deletions(-) Index: linux-3.0-SLE11-SP2/fs/btrfs/extent_io.c ==================================================================--- linux-3.0-SLE11-SP2.orig/fs/btrfs/extent_io.c 2011-11-21 14:15:28.000000000 -0500 +++ linux-3.0-SLE11-SP2/fs/btrfs/extent_io.c 2011-11-21 14:22:41.000000000 -0500 @@ -494,10 +494,9 @@ NORET_TYPE void extent_io_tree_panic(str * This takes the tree lock, and returns 0 on success and < 0 on error. * If (mask & __GFP_WAIT) == 0, there are no error conditions. */ -int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int wake, int delete, - struct extent_state **cached_state, - gfp_t mask) +static int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int wake, int delete, + struct extent_state **cached_state, gfp_t mask) { struct extent_state *state; struct extent_state *cached; @@ -642,6 +641,31 @@ search_again: goto again; } +/* + * With __GFP_WAIT set, the memory allocations will wait until they can + * be honored. With -ENOMEM out of the way, we don''t have errors to return. + */ +void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int wake, int delete, + struct extent_state **cached_state, gfp_t mask) +{ + int ret; + WARN_ON(!(mask & __GFP_WAIT)); + ret = __clear_extent_bit(tree, start, end, bits, wake, delete, + cached_state, mask); + BUG_ON(ret < 0); +} + +static int __must_check +clear_extent_bit_atomic(struct extent_io_tree *tree, u64 start, + u64 end, int bits, int wake, int delete, + struct extent_state **cached_state, gfp_t mask) +{ + WARN_ON(mask & __GFP_WAIT); + return __clear_extent_bit(tree, start, end, bits, wake, delete, + cached_state, mask); +} + static int wait_on_state(struct extent_io_tree *tree, struct extent_state *state) __releases(tree->lock) @@ -1149,10 +1173,10 @@ int set_extent_bits(struct extent_io_tre NULL, mask); } -int clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, +void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask) { - return clear_extent_bit(tree, start, end, bits, 0, 0, NULL, mask); + clear_extent_bit(tree, start, end, bits, 0, 0, NULL, mask); } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, @@ -1163,12 +1187,11 @@ int set_extent_delalloc(struct extent_io 0, NULL, cached_state, mask); } -int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, +void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) { - return clear_extent_bit(tree, start, end, - EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, NULL, mask); + clear_extent_bit(tree, start, end, EXTENT_DIRTY | EXTENT_DELALLOC | + EXTENT_DO_ACCOUNTING, 0, 0, NULL, mask); } int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, @@ -1185,12 +1208,12 @@ int set_extent_uptodate(struct extent_io NULL, cached_state, mask); } -static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, - u64 end, struct extent_state **cached_state, - gfp_t mask) +static void clear_extent_uptodate(struct extent_io_tree *tree, u64 start, + u64 end, struct extent_state **cached_state, + gfp_t mask) { - return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, - cached_state, mask); + clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, + cached_state, mask); } /* @@ -1231,9 +1254,19 @@ int try_lock_extent(struct extent_io_tre err = set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED, &failed_start, NULL, mask); if (err == -EEXIST) { - if (failed_start > start) - clear_extent_bit(tree, start, failed_start - 1, - EXTENT_LOCKED, 1, 0, NULL, mask); + if (failed_start > start) { + if (mask & __GFP_WAIT) + clear_extent_bit(tree, start, failed_start - 1, + EXTENT_LOCKED, 1, 0, NULL, + mask); + else { + err = clear_extent_bit_atomic(tree, start, + failed_start - 1, + EXTENT_LOCKED, 1, 0, + NULL, mask); + BUG_ON(err < 0); + } + } return 0; } return 1; @@ -1242,14 +1275,14 @@ int try_lock_extent(struct extent_io_tre int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached, gfp_t mask) { - return clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached, - mask); + return __clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, + cached, mask); } int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) { - return clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, - mask); + return __clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, + NULL, mask); } /* @@ -1567,10 +1600,10 @@ out_failed: return found; } -int extent_clear_unlock_delalloc(struct inode *inode, - struct extent_io_tree *tree, - u64 start, u64 end, struct page *locked_page, - unsigned long op) +void extent_clear_unlock_delalloc(struct inode *inode, + struct extent_io_tree *tree, + u64 start, u64 end, struct page *locked_page, + unsigned long op) { int ret; struct page *pages[16]; @@ -1592,7 +1625,7 @@ int extent_clear_unlock_delalloc(struct if (!(op & (EXTENT_CLEAR_UNLOCK_PAGE | EXTENT_CLEAR_DIRTY | EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK | EXTENT_SET_PRIVATE2))) - return 0; + return; while (nr_pages > 0) { ret = find_get_pages_contig(inode->i_mapping, index, @@ -1621,7 +1654,6 @@ int extent_clear_unlock_delalloc(struct index += ret; cond_resched(); } - return 0; } /* @@ -1858,30 +1890,21 @@ struct io_failure_record { int in_validation; }; -static int free_io_failure(struct inode *inode, struct io_failure_record *rec, +static void free_io_failure(struct inode *inode, struct io_failure_record *rec, int did_repair) { - int ret; - int err = 0; struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree; set_state_private(failure_tree, rec->start, 0); - ret = clear_extent_bits(failure_tree, rec->start, - rec->start + rec->len - 1, - EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); - if (ret) - err = ret; + clear_extent_bits(failure_tree, rec->start, rec->start + rec->len - 1, + EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); - if (did_repair) { - ret = clear_extent_bits(&BTRFS_I(inode)->io_tree, rec->start, - rec->start + rec->len - 1, - EXTENT_DAMAGED, GFP_NOFS); - if (ret && !err) - err = ret; - } + if (did_repair) + clear_extent_bits(&BTRFS_I(inode)->io_tree, rec->start, + rec->start + rec->len - 1, + EXTENT_DAMAGED, GFP_NOFS); kfree(rec); - return err; } static void repair_io_failure_callback(struct bio *bio, int err) @@ -2013,7 +2036,7 @@ static int clean_io_failure(u64 start, s out: if (!ret) - ret = free_io_failure(inode, failrec, did_repair); + free_io_failure(inode, failrec, did_repair); return ret; } @@ -3284,9 +3307,9 @@ int try_release_extent_state(struct exte * at this point we can safely clear everything except the * locked bit and the nodatasum bit */ - ret = clear_extent_bit(tree, start, end, - ~(EXTENT_LOCKED | EXTENT_NODATASUM), - 0, 0, NULL, mask); + ret = __clear_extent_bit(tree, start, end, + ~(EXTENT_LOCKED | EXTENT_NODATASUM), + 0, 0, NULL, mask); /* if clear_extent_bit failed for enomem reasons, * we can''t allow the release to continue. @@ -3868,9 +3891,9 @@ static int eb_straddles_pages(struct ext return __eb_straddles_pages(eb->start, eb->len); } -int clear_extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state **cached_state) +void clear_extent_buffer_uptodate(struct extent_io_tree *tree, + struct extent_buffer *eb, + struct extent_state **cached_state) { unsigned long i; struct page *page; @@ -3888,7 +3911,6 @@ int clear_extent_buffer_uptodate(struct if (page) ClearPageUptodate(page); } - return 0; } int set_extent_buffer_uptodate(struct extent_io_tree *tree, Index: linux-3.0-SLE11-SP2/fs/btrfs/extent_io.h ==================================================================--- linux-3.0-SLE11-SP2.orig/fs/btrfs/extent_io.h 2011-11-21 14:12:50.000000000 -0500 +++ linux-3.0-SLE11-SP2/fs/btrfs/extent_io.h 2011-11-21 14:21:24.000000000 -0500 @@ -200,11 +200,11 @@ u64 count_range_bits(struct extent_io_tr void free_extent_state(struct extent_state *state); int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int filled, struct extent_state *cached_state); -int clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask); -int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int wake, int delete, struct extent_state **cached, - gfp_t mask); +void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, + int bits, gfp_t mask); +void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int wake, int delete, + struct extent_state **cached, gfp_t mask); int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask); int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, @@ -216,8 +216,8 @@ int set_extent_new(struct extent_io_tree gfp_t mask); int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); -int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask); int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int clear_bits, gfp_t mask); int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, @@ -292,9 +292,9 @@ int set_extent_buffer_dirty(struct exten struct extent_buffer *eb); int set_extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb); -int clear_extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb, - struct extent_state **cached_state); +void clear_extent_buffer_uptodate(struct extent_io_tree *tree, + struct extent_buffer *eb, + struct extent_state **cached_state); int extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb, struct extent_state *cached_state); @@ -304,10 +304,10 @@ int map_private_extent_buffer(struct ext unsigned long *map_len); int extent_range_uptodate(struct extent_io_tree *tree, u64 start, u64 end); -int extent_clear_unlock_delalloc(struct inode *inode, - struct extent_io_tree *tree, - u64 start, u64 end, struct page *locked_page, - unsigned long op); +void extent_clear_unlock_delalloc(struct inode *inode, + struct extent_io_tree *tree, + u64 start, u64 end, struct page *locked_page, + unsigned long op); struct bio * btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs, gfp_t gfp_flags); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Now that clear_extent_bit can return void when gfp_t & __GFP_WAIT, we can use that to convert unlock_extent to return void to callers as well. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 5 ++--- fs/btrfs/extent_io.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1266,10 +1266,9 @@ int unlock_extent_cached(struct extent_i cached, mask); } -int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) +void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) { - return __clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, - NULL, mask); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, mask); } /* --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -183,7 +183,7 @@ int try_release_extent_state(struct exte int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, struct extent_state **cached, gfp_t mask); -int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); +void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached, gfp_t mask); int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 10/99] btrfs: Split unlock_extent_cached into sleeping and atomic versions
There are 28 callers of unlock_extent_cached that call it with GFP_NOFS and only 1 that calls it with GFP_ATOMIC (the bio_endio callback). Since unlock_extent_cached is a simple wrapper around clear_extent_bit, we can create a new unlock_extent_cached_atomic to handle the atomic case and let unlock_extent_cached return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 19 ++++++++++++++----- fs/btrfs/extent_io.h | 8 ++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1259,11 +1259,18 @@ int try_lock_extent(struct extent_io_tre return 1; } -int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, gfp_t mask) +void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached, gfp_t mask) { - return __clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, - cached, mask); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached, mask); +} + +int unlock_extent_cached_atomic(struct extent_io_tree *tree, u64 start, + u64 end, struct extent_state **cached, + gfp_t mask) +{ + return clear_extent_bit_atomic(tree, start, end, EXTENT_LOCKED, 1, 0, + cached, mask); } void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) @@ -2368,7 +2375,9 @@ static void end_bio_extent_readpage(stru set_extent_uptodate(tree, start, end, &cached, GFP_ATOMIC); } - unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC); + ret = unlock_extent_cached_atomic(tree, start, end, + &cached, GFP_ATOMIC); + BUG_ON(ret < 0); if (whole_page) { if (uptodate) { --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -184,8 +184,12 @@ int lock_extent(struct extent_io_tree *t int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, struct extent_state **cached, gfp_t mask); void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); -int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, gfp_t mask); +int __must_check unlock_extent_cached_atomic(struct extent_io_tree *tree, + u64 start, u64 end, + struct extent_state **cached, + gfp_t mask); +void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached, gfp_t mask); int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int extent_read_full_page(struct extent_io_tree *tree, struct page *page, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 11/99] btrfs: unlock_extent can drop gfp_t argument
All of the callers of unlock_extent call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from unlock_extent itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/compression.c | 4 ++-- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 33 ++++++++++++++++----------------- fs/btrfs/extent_io.h | 7 +++---- fs/btrfs/file.c | 13 ++++++------- fs/btrfs/free-space-cache.c | 4 ++-- fs/btrfs/inode.c | 36 +++++++++++++++++------------------- fs/btrfs/ioctl.c | 11 +++++------ fs/btrfs/relocation.c | 11 +++++------ 9 files changed, 57 insertions(+), 64 deletions(-) --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -507,7 +507,7 @@ static noinline int add_ra_bio_pages(str (last_offset + PAGE_CACHE_SIZE > extent_map_end(em)) || (em->block_start >> 9) != cb->orig_bio->bi_sector) { free_extent_map(em); - unlock_extent(tree, last_offset, end, GFP_NOFS); + unlock_extent(tree, last_offset, end); unlock_page(page); page_cache_release(page); break; @@ -535,7 +535,7 @@ static noinline int add_ra_bio_pages(str nr_pages++; page_cache_release(page); } else { - unlock_extent(tree, last_offset, end, GFP_NOFS); + unlock_extent(tree, last_offset, end); unlock_page(page); page_cache_release(page); break; --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -346,7 +346,7 @@ static int verify_parent_transid(struct clear_extent_buffer_uptodate(io_tree, eb, &cached_state); out: unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1, - &cached_state, GFP_NOFS); + &cached_state); return ret; } --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1260,22 +1260,22 @@ int try_lock_extent(struct extent_io_tre } void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, gfp_t mask) + struct extent_state **cached) { - clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached, mask); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached, + GFP_NOFS); } int unlock_extent_cached_atomic(struct extent_io_tree *tree, u64 start, - u64 end, struct extent_state **cached, - gfp_t mask) + u64 end, struct extent_state **cached) { return clear_extent_bit_atomic(tree, start, end, EXTENT_LOCKED, 1, 0, - cached, mask); + cached, GFP_ATOMIC); } -void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) +void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end) { - clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, mask); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, GFP_NOFS); } /* @@ -1580,7 +1580,7 @@ again: EXTENT_DELALLOC, 1, cached_state); if (!ret) { unlock_extent_cached(tree, delalloc_start, delalloc_end, - &cached_state, GFP_NOFS); + &cached_state); __unlock_for_delalloc(inode, locked_page, delalloc_start, delalloc_end); cond_resched(); @@ -2375,8 +2375,7 @@ static void end_bio_extent_readpage(stru set_extent_uptodate(tree, start, end, &cached, GFP_ATOMIC); } - ret = unlock_extent_cached_atomic(tree, start, end, - &cached, GFP_ATOMIC); + ret = unlock_extent_cached_atomic(tree, start, end, &cached); BUG_ON(ret < 0); if (whole_page) { @@ -2571,7 +2570,7 @@ static int __extent_read_full_page(struc ordered = btrfs_lookup_ordered_extent(inode, start); if (!ordered) break; - unlock_extent(tree, start, end, GFP_NOFS); + unlock_extent(tree, start, end); btrfs_start_ordered_extent(inode, ordered, 1); btrfs_put_ordered_extent(ordered); } @@ -2601,14 +2600,14 @@ static int __extent_read_full_page(struc set_extent_uptodate(tree, cur, cur + iosize - 1, &cached, GFP_NOFS); unlock_extent_cached(tree, cur, cur + iosize - 1, - &cached, GFP_NOFS); + &cached); break; } em = get_extent(inode, page, pg_offset, cur, end - cur + 1, 0); if (IS_ERR_OR_NULL(em)) { SetPageError(page); - unlock_extent(tree, cur, end, GFP_NOFS); + unlock_extent(tree, cur, end); break; } extent_offset = cur - em->start; @@ -2651,7 +2650,7 @@ static int __extent_read_full_page(struc set_extent_uptodate(tree, cur, cur + iosize - 1, &cached, GFP_NOFS); unlock_extent_cached(tree, cur, cur + iosize - 1, - &cached, GFP_NOFS); + &cached); cur = cur + iosize; pg_offset += iosize; continue; @@ -2660,7 +2659,7 @@ static int __extent_read_full_page(struc if (test_range_bit(tree, cur, cur_end, EXTENT_UPTODATE, 1, NULL)) { check_page_uptodate(tree, page); - unlock_extent(tree, cur, cur + iosize - 1, GFP_NOFS); + unlock_extent(tree, cur, cur + iosize - 1); cur = cur + iosize; pg_offset += iosize; continue; @@ -2670,7 +2669,7 @@ static int __extent_read_full_page(struc */ if (block_start == EXTENT_MAP_INLINE) { SetPageError(page); - unlock_extent(tree, cur, cur + iosize - 1, GFP_NOFS); + unlock_extent(tree, cur, cur + iosize - 1); cur = cur + iosize; pg_offset += iosize; continue; @@ -3573,7 +3572,7 @@ out_free: free_extent_map(em); out: unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len, - &cached_state, GFP_NOFS); + &cached_state); return ret; } --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -183,13 +183,12 @@ int try_release_extent_state(struct exte int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, struct extent_state **cached, gfp_t mask); -void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); +void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end); int __must_check unlock_extent_cached_atomic(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, - gfp_t mask); + struct extent_state **cached); void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached, gfp_t mask); + struct extent_state **cached); int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int extent_read_full_page(struct extent_io_tree *tree, struct page *page, --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1115,7 +1115,7 @@ again: btrfs_put_ordered_extent(ordered); unlock_extent_cached(&BTRFS_I(inode)->io_tree, start_pos, last_pos - 1, - &cached_state, GFP_NOFS); + &cached_state); for (i = 0; i < num_pages; i++) { unlock_page(pages[i]); page_cache_release(pages[i]); @@ -1132,8 +1132,7 @@ again: EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, GFP_NOFS); unlock_extent_cached(&BTRFS_I(inode)->io_tree, - start_pos, last_pos - 1, &cached_state, - GFP_NOFS); + start_pos, last_pos - 1, &cached_state); } for (i = 0; i < num_pages; i++) { clear_page_dirty_for_io(pages[i]); @@ -1633,7 +1632,7 @@ static long btrfs_fallocate(struct file btrfs_put_ordered_extent(ordered); unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, - &cached_state, GFP_NOFS); + &cached_state); /* * we can''t wait on the range with the transaction * running or with the extent lock held @@ -1705,8 +1704,8 @@ static long btrfs_fallocate(struct file break; } } - unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, - &cached_state, GFP_NOFS); + unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, + locked_end, &cached_state); out: mutex_unlock(&inode->i_mutex); return ret; @@ -1819,7 +1818,7 @@ static int find_desired_extent(struct in *offset = min(*offset, inode->i_size); out: unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend, - &cached_state, GFP_NOFS); + &cached_state); return ret; } --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -957,7 +957,7 @@ int __btrfs_write_out_cache(struct btrfs 0, i_size_read(inode), &cached_state); io_ctl_drop_pages(&io_ctl); unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0, - i_size_read(inode) - 1, &cached_state, GFP_NOFS); + i_size_read(inode) - 1, &cached_state); if (ret) goto out; @@ -1022,7 +1022,7 @@ out_nospc: } io_ctl_drop_pages(&io_ctl); unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0, - i_size_read(inode) - 1, &cached_state, GFP_NOFS); + i_size_read(inode) - 1, &cached_state); goto out; } --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -648,7 +648,7 @@ retry: async_extent->pages = NULL; unlock_extent(io_tree, async_extent->start, async_extent->start + - async_extent->ram_size - 1, GFP_NOFS); + async_extent->ram_size - 1); goto retry; } @@ -1578,7 +1578,7 @@ again: ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, - page_end, &cached_state, GFP_NOFS); + page_end, &cached_state); unlock_page(page); btrfs_start_ordered_extent(inode, ordered, 1); goto again; @@ -1589,7 +1589,7 @@ again: ClearPageChecked(page); out: unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + &cached_state); out_page: unlock_page(page); page_cache_release(page); @@ -1786,7 +1786,7 @@ static int btrfs_finish_ordered_io(struc } unlock_extent_cached(io_tree, ordered_extent->file_offset, ordered_extent->file_offset + - ordered_extent->len - 1, &cached_state, GFP_NOFS); + ordered_extent->len - 1, &cached_state); add_pending_csums(trans, inode, ordered_extent->file_offset, &ordered_extent->list); @@ -3237,7 +3237,7 @@ again: ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + &cached_state); unlock_page(page); page_cache_release(page); btrfs_start_ordered_extent(inode, ordered, 1); @@ -3253,7 +3253,7 @@ again: &cached_state); if (ret) { unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + &cached_state); goto out_unlock; } @@ -3266,8 +3266,7 @@ again: } ClearPageChecked(page); set_page_dirty(page); - unlock_extent_cached(io_tree, page_start, page_end, &cached_state, - GFP_NOFS); + unlock_extent_cached(io_tree, page_start, page_end, &cached_state); out_unlock: if (ret) @@ -3312,7 +3311,7 @@ int btrfs_cont_expand(struct inode *inod if (!ordered) break; unlock_extent_cached(io_tree, hole_start, block_end - 1, - &cached_state, GFP_NOFS); + &cached_state); btrfs_put_ordered_extent(ordered); } @@ -3363,8 +3362,7 @@ int btrfs_cont_expand(struct inode *inod } free_extent_map(em); - unlock_extent_cached(io_tree, hole_start, block_end - 1, &cached_state, - GFP_NOFS); + unlock_extent_cached(io_tree, hole_start, block_end - 1, &cached_state); return err; } @@ -5463,7 +5461,7 @@ static int btrfs_get_blocks_direct(struc free_extent_map(em); /* DIO will do one hole at a time, so just unlock a sector */ unlock_extent(&BTRFS_I(inode)->io_tree, start, - start + root->sectorsize - 1, GFP_NOFS); + start + root->sectorsize - 1); return 0; } @@ -5604,7 +5602,7 @@ static void btrfs_endio_direct_read(stru } while (bvec <= bvec_end); unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, - dip->logical_offset + dip->bytes - 1, GFP_NOFS); + dip->logical_offset + dip->bytes - 1); bio->bi_private = dip->private; kfree(dip->csums); @@ -5692,7 +5690,7 @@ again: out_unlock: unlock_extent_cached(&BTRFS_I(inode)->io_tree, ordered->file_offset, ordered->file_offset + ordered->len - 1, - &cached_state, GFP_NOFS); + &cached_state); out: btrfs_delalloc_release_metadata(inode, ordered->len); btrfs_end_transaction(trans, root); @@ -6080,8 +6078,8 @@ static ssize_t btrfs_direct_IO(int rw, s lockend - lockstart + 1); if (!ordered) break; - unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend, - &cached_state, GFP_NOFS); + unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, + lockend, &cached_state); btrfs_start_ordered_extent(inode, ordered, 1); btrfs_put_ordered_extent(ordered); cond_resched(); @@ -6327,7 +6325,7 @@ again: ordered = btrfs_lookup_ordered_extent(inode, page_start); if (ordered) { unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + &cached_state); unlock_page(page); btrfs_start_ordered_extent(inode, ordered, 1); btrfs_put_ordered_extent(ordered); @@ -6349,7 +6347,7 @@ again: &cached_state); if (ret) { unlock_extent_cached(io_tree, page_start, page_end, - &cached_state, GFP_NOFS); + &cached_state); ret = VM_FAULT_SIGBUS; goto out_unlock; } @@ -6374,7 +6372,7 @@ again: BTRFS_I(inode)->last_trans = root->fs_info->generation; BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid; - unlock_extent_cached(io_tree, page_start, page_end, &cached_state, GFP_NOFS); + unlock_extent_cached(io_tree, page_start, page_end, &cached_state); out_unlock: if (!ret) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -790,7 +790,7 @@ static int should_defrag_range(struct in /* get the big lock and read metadata off disk */ lock_extent(io_tree, start, start + len - 1, GFP_NOFS); em = btrfs_get_extent(inode, NULL, 0, start, len, 0); - unlock_extent(io_tree, start, start + len - 1, GFP_NOFS); + unlock_extent(io_tree, start, start + len - 1); if (IS_ERR(em)) return 0; @@ -922,7 +922,7 @@ again: btrfs_put_ordered_extent(ordered); unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end - 1, - &cached_state, GFP_NOFS); + &cached_state); for (i = 0; i < i_done; i++) { unlock_page(pages[i]); page_cache_release(pages[i]); @@ -952,8 +952,7 @@ again: &cached_state); unlock_extent_cached(&BTRFS_I(inode)->io_tree, - page_start, page_end - 1, &cached_state, - GFP_NOFS); + page_start, page_end - 1, &cached_state); for (i = 0; i < i_done; i++) { clear_page_dirty_for_io(pages[i]); @@ -2281,7 +2280,7 @@ static noinline long btrfs_ioctl_clone(s !test_range_bit(&BTRFS_I(src)->io_tree, off, off+len, EXTENT_DELALLOC, 0, NULL)) break; - unlock_extent(&BTRFS_I(src)->io_tree, off, off+len, GFP_NOFS); + unlock_extent(&BTRFS_I(src)->io_tree, off, off+len); if (ordered) btrfs_put_ordered_extent(ordered); btrfs_wait_ordered_range(src, off, len); @@ -2500,7 +2499,7 @@ next: ret = 0; out: btrfs_release_path(path); - unlock_extent(&BTRFS_I(src)->io_tree, off, off+len, GFP_NOFS); + unlock_extent(&BTRFS_I(src)->io_tree, off, off+len); out_unlock: mutex_unlock(&src->i_mutex); mutex_unlock(&inode->i_mutex); --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1604,7 +1604,7 @@ int replace_file_extents(struct btrfs_tr btrfs_drop_extent_cache(inode, key.offset, end, 1); unlock_extent(&BTRFS_I(inode)->io_tree, - key.offset, end, GFP_NOFS); + key.offset, end); } } @@ -1975,7 +1975,7 @@ static int invalidate_extent_cache(struc /* the lock_extent waits for readpage to complete */ lock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); btrfs_drop_extent_cache(inode, start, end, 1); - unlock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, start, end); } return 0; } @@ -2884,7 +2884,7 @@ int prealloc_file_extent_cluster(struct ret = btrfs_prealloc_file_range(inode, 0, start, num_bytes, num_bytes, end + 1, &alloc_hint); - unlock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, start, end); if (ret) break; nr++; @@ -2927,7 +2927,7 @@ int setup_extent_mapping(struct inode *i } btrfs_drop_extent_cache(inode, start, end, 0); } - unlock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, start, end); return ret; } @@ -3023,8 +3023,7 @@ static int relocate_file_extent_cluster( btrfs_set_extent_delalloc(inode, page_start, page_end, NULL); set_page_dirty(page); - unlock_extent(&BTRFS_I(inode)->io_tree, - page_start, page_end, GFP_NOFS); + unlock_extent(&BTRFS_I(inode)->io_tree, page_start, page_end); unlock_page(page); page_cache_release(page); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 12/99] btrfs: clear_extent_dirty can drop gfp_t argument
All of the callers of clear_extent_dirty call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from clear_extent_dirty itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/extent_io.c | 5 ++--- fs/btrfs/extent_io.h | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3370,7 +3370,7 @@ static int btrfs_destroy_pinned_extent(s end + 1 - start, NULL); - clear_extent_dirty(unpin, start, end, GFP_NOFS); + clear_extent_dirty(unpin, start, end); btrfs_error_unpin_extent_range(root, start, end); cond_resched(); } --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4602,7 +4602,7 @@ int btrfs_finish_extent_commit(struct bt ret = btrfs_discard_extent(root, start, end + 1 - start, NULL); - clear_extent_dirty(unpin, start, end, GFP_NOFS); + clear_extent_dirty(unpin, start, end); unpin_extent_range(root, start, end); cond_resched(); } --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1174,11 +1174,10 @@ int set_extent_delalloc(struct extent_io 0, NULL, cached_state, mask); } -void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) { clear_extent_bit(tree, start, end, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, NULL, mask); + EXTENT_DO_ACCOUNTING, 0, 0, NULL, GFP_NOFS); } int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -226,8 +226,7 @@ int set_extent_new(struct extent_io_tree gfp_t mask); int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); -void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int clear_bits, gfp_t mask); int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 13/99] btrfs: clear_extent_uptodate can drop gfp_t argumetn
All of the callers of clear_extent_uptodate call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from clear_extent_uptodate itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1203,11 +1203,10 @@ int set_extent_uptodate(struct extent_io } static void clear_extent_uptodate(struct extent_io_tree *tree, u64 start, - u64 end, struct extent_state **cached_state, - gfp_t mask) + u64 end, struct extent_state **cached_state) { clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, - cached_state, mask); + cached_state, GFP_NOFS); } /* @@ -2285,7 +2284,7 @@ static void end_bio_extent_writepage(str } if (!uptodate) { - clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS); + clear_extent_uptodate(tree, start, end, NULL); ClearPageUptodate(page); SetPageError(page); } @@ -3917,7 +3916,7 @@ void clear_extent_buffer_uptodate(struct if (eb_straddles_pages(eb)) { clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, - cached_state, GFP_NOFS); + cached_state); } for (i = 0; i < num_pages; i++) { page = extent_buffer_page(eb, i); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 14/99] btrfs: clear_extent_bits can drop gfp_t argumetn
All of the callers of clear_extent_bits call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from clear_extent_bits itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 4 ++-- fs/btrfs/extent_io.c | 12 ++++++------ fs/btrfs/extent_io.h | 5 ++++- fs/btrfs/inode.c | 3 +-- fs/btrfs/relocation.c | 3 +-- fs/btrfs/scrub.c | 2 +- fs/btrfs/transaction.c | 2 +- fs/btrfs/tree-log.c | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3309,7 +3309,7 @@ static int btrfs_destroy_marked_extents( if (ret) break; - clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); + clear_extent_bits(dirty_pages, start, end, mark); while (start <= end) { index = start >> PAGE_CACHE_SHIFT; start = (u64)(index + 1) << PAGE_CACHE_SHIFT; --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -226,9 +226,9 @@ static void free_excluded_extents(struct end = start + cache->key.offset - 1; clear_extent_bits(&root->fs_info->freed_extents[0], - start, end, EXTENT_UPTODATE, GFP_NOFS); + start, end, EXTENT_UPTODATE); clear_extent_bits(&root->fs_info->freed_extents[1], - start, end, EXTENT_UPTODATE, GFP_NOFS); + start, end, EXTENT_UPTODATE); } static int exclude_super_stripes(struct btrfs_root *root, --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1154,9 +1154,9 @@ int set_extent_bits(struct extent_io_tre } void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask) + int bits) { - clear_extent_bit(tree, start, end, bits, 0, 0, NULL, mask); + clear_extent_bit(tree, start, end, bits, 0, 0, NULL, GFP_NOFS); } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, @@ -1903,12 +1903,12 @@ static void free_io_failure(struct inode set_state_private(failure_tree, rec->start, 0); clear_extent_bits(failure_tree, rec->start, rec->start + rec->len - 1, - EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); + EXTENT_LOCKED | EXTENT_DIRTY); if (did_repair) clear_extent_bits(&BTRFS_I(inode)->io_tree, rec->start, rec->start + rec->len - 1, - EXTENT_DAMAGED, GFP_NOFS); + EXTENT_DAMAGED); kfree(rec); } --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -205,7 +205,7 @@ u64 count_range_bits(struct extent_io_tr int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int filled, struct extent_state *cached_state); void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask); + int bits); void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, struct extent_state **cached, gfp_t mask); --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1851,8 +1851,7 @@ static int btrfs_readpage_end_io_hook(st if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID && test_range_bit(io_tree, start, end, EXTENT_NODATASUM, 1, NULL)) { - clear_extent_bits(io_tree, start, end, EXTENT_NODATASUM, - GFP_NOFS); + clear_extent_bits(io_tree, start, end, EXTENT_NODATASUM); return 0; } --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -3842,8 +3842,7 @@ restart: } btrfs_release_path(path); - clear_extent_bits(&rc->processed_blocks, 0, (u64)-1, EXTENT_DIRTY, - GFP_NOFS); + clear_extent_bits(&rc->processed_blocks, 0, (u64)-1, EXTENT_DIRTY); if (trans) { nr = trans->blocks_used; --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -443,7 +443,7 @@ static int scrub_fixup_readpage(u64 inum end, EXTENT_DAMAGED, 0, NULL); if (!corrected) clear_extent_bits(&BTRFS_I(inode)->io_tree, offset, end, - EXTENT_DAMAGED, GFP_NOFS); + EXTENT_DAMAGED); } out: --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -612,7 +612,7 @@ int btrfs_wait_marked_extents(struct btr while (!find_first_extent_bit(dirty_pages, start, &start, &end, EXTENT_NEED_WAIT)) { - clear_extent_bits(dirty_pages, start, end, EXTENT_NEED_WAIT, GFP_NOFS); + clear_extent_bits(dirty_pages, start, end, EXTENT_NEED_WAIT); err = filemap_fdatawait_range(mapping, start, end); if (err) werr = err; --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2180,7 +2180,7 @@ static void free_log_tree(struct btrfs_t break; clear_extent_bits(&log->dirty_log_pages, start, end, - EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS); + EXTENT_DIRTY | EXTENT_NEW); } free_extent_buffer(log->node); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 15/99] btrfs: try_lock_extent can drop gfp_t argumetn
All of the callers of try_lock_extent call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from try_lock_extent itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 22 ++++++---------------- fs/btrfs/extent_io.h | 4 ++-- fs/btrfs/relocation.c | 3 +-- 3 files changed, 9 insertions(+), 20 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1238,28 +1238,18 @@ int lock_extent(struct extent_io_tree *t return lock_extent_bits(tree, start, end, 0, NULL, mask); } -int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end) { int err; u64 failed_start; err = set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED, - &failed_start, NULL, mask); + &failed_start, NULL, GFP_NOFS); if (err == -EEXIST) { - if (failed_start > start) { - if (mask & __GFP_WAIT) - clear_extent_bit(tree, start, failed_start - 1, - EXTENT_LOCKED, 1, 0, NULL, - mask); - else { - err = clear_extent_bit_atomic(tree, start, - failed_start - 1, - EXTENT_LOCKED, 1, 0, - NULL, mask); - BUG_ON(err < 0); - } - } + if (failed_start > start) + clear_extent_bit(tree, start, failed_start - 1, + EXTENT_LOCKED, 1, 0, NULL, + GFP_NOFS); return 0; } return 1; --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -191,8 +191,8 @@ int __must_check unlock_extent_cached_at struct extent_state **cached); void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached); -int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +int __must_check try_lock_extent(struct extent_io_tree *tree, u64 start, + u64 end); int extent_read_full_page(struct extent_io_tree *tree, struct page *page, get_extent_t *get_extent, int mirror_num); int __init extent_io_init(void); --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1596,8 +1596,7 @@ int replace_file_extents(struct btrfs_tr WARN_ON(!IS_ALIGNED(end, root->sectorsize)); end--; ret = try_lock_extent(&BTRFS_I(inode)->io_tree, - key.offset, end, - GFP_NOFS); + key.offset, end); if (!ret) continue; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 16/99] btrfs: clear_extent_bit can drop gfp_t argument
Now that all of the callers of clear_extent_bit use with GFP_ATOMIC or GFP_NOFS, we can drop the gfp_t argument entirely and allow clear_extent_bit to always pass GFP_NOFS and clear_extent_bit_atomic to always pass GFP_ATOMIC. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 43 +++++++++++++++++++------------------------ fs/btrfs/extent_io.h | 5 ++--- fs/btrfs/file.c | 3 +-- fs/btrfs/free-space-cache.c | 5 ++--- fs/btrfs/inode.c | 20 +++++++++----------- fs/btrfs/ioctl.c | 3 +-- 6 files changed, 34 insertions(+), 45 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -636,23 +636,22 @@ search_again: */ void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { int ret; - WARN_ON(!(mask & __GFP_WAIT)); + might_sleep(); ret = __clear_extent_bit(tree, start, end, bits, wake, delete, - cached_state, mask); + cached_state, GFP_NOFS); BUG_ON(ret < 0); } static int __must_check clear_extent_bit_atomic(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { - WARN_ON(mask & __GFP_WAIT); return __clear_extent_bit(tree, start, end, bits, wake, delete, - cached_state, mask); + cached_state, GFP_ATOMIC); } static int wait_on_state(struct extent_io_tree *tree, @@ -1157,7 +1156,7 @@ int clear_extent_bits_atomic(struct exte void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits) { - clear_extent_bit(tree, start, end, bits, 0, 0, NULL, GFP_NOFS); + clear_extent_bit(tree, start, end, bits, 0, 0, NULL); } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, @@ -1178,7 +1177,7 @@ int clear_extent_dirty_atomic(struct ext void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) { clear_extent_bit(tree, start, end, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, NULL, GFP_NOFS); + EXTENT_DO_ACCOUNTING, 0, 0, NULL); } int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, @@ -1206,7 +1204,7 @@ static void clear_extent_uptodate(struct u64 end, struct extent_state **cached_state) { clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, - cached_state, GFP_NOFS); + cached_state); } /* @@ -1248,8 +1246,7 @@ int try_lock_extent(struct extent_io_tre if (err == -EEXIST) { if (failed_start > start) clear_extent_bit(tree, start, failed_start - 1, - EXTENT_LOCKED, 1, 0, NULL, - GFP_NOFS); + EXTENT_LOCKED, 1, 0, NULL); return 0; } return 1; @@ -1258,20 +1255,19 @@ int try_lock_extent(struct extent_io_tre void unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached) { - clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached, - GFP_NOFS); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached); } int unlock_extent_cached_atomic(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached) { return clear_extent_bit_atomic(tree, start, end, EXTENT_LOCKED, 1, 0, - cached, GFP_ATOMIC); + cached); } void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end) { - clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, GFP_NOFS); + clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL); } /* @@ -1617,7 +1612,7 @@ void extent_clear_unlock_delalloc(struct if (op & EXTENT_CLEAR_DELALLOC) clear_bits |= EXTENT_DELALLOC; - clear_extent_bit(tree, start, end, clear_bits, 1, 0, NULL, GFP_NOFS); + clear_extent_bit(tree, start, end, clear_bits, 1, 0, NULL); if (!(op & (EXTENT_CLEAR_UNLOCK_PAGE | EXTENT_CLEAR_DIRTY | EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK | EXTENT_SET_PRIVATE2))) @@ -3277,7 +3272,7 @@ int extent_invalidatepage(struct extent_ clear_extent_bit(tree, start, end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 1, 1, &cached_state, GFP_NOFS); + 1, 1, &cached_state); return 0; } --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -213,7 +213,7 @@ void clear_extent_bits(struct extent_io_ int bits); void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, - struct extent_state **cached, gfp_t mask); + struct extent_state **cached); int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask); int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1129,8 +1129,7 @@ again: clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, last_pos - 1, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, - GFP_NOFS); + EXTENT_DO_ACCOUNTING, 0, 0, &cached_state); unlock_extent_cached(&BTRFS_I(inode)->io_tree, start_pos, last_pos - 1, &cached_state); } --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -974,8 +974,7 @@ int __btrfs_write_out_cache(struct btrfs ret = btrfs_search_slot(trans, root, &key, path, 0, 1); if (ret < 0) { clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1, - EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL, - GFP_NOFS); + EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL); goto out; } leaf = path->nodes[0]; @@ -989,7 +988,7 @@ int __btrfs_write_out_cache(struct btrfs clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1, EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, - NULL, GFP_NOFS); + NULL); btrfs_release_path(path); goto out; } --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -965,7 +965,7 @@ static int cow_file_range_async(struct i int limit = 10 * 1024 * 1042; clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, EXTENT_LOCKED, - 1, 0, NULL, GFP_NOFS); + 1, 0, NULL); while (start < end) { async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); BUG_ON(!async_cow); @@ -3246,7 +3246,7 @@ again: clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 0, 0, &cached_state, GFP_NOFS); + 0, 0, &cached_state); ret = btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); @@ -5526,7 +5526,7 @@ must_cow: unlock: clear_extent_bit(&BTRFS_I(inode)->io_tree, start, start + len - 1, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DIRTY, 1, - 0, NULL, GFP_NOFS); + 0, NULL); map: bh_result->b_blocknr = (em->block_start + (start - em->start)) >> inode->i_blkbits; @@ -6096,7 +6096,7 @@ static ssize_t btrfs_direct_IO(int rw, s if (ret) { clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, EXTENT_LOCKED | write_bits, - 1, 0, &cached_state, GFP_NOFS); + 1, 0, &cached_state); goto out; } } @@ -6112,8 +6112,7 @@ static ssize_t btrfs_direct_IO(int rw, s if (ret < 0 && ret != -EIOCBQUEUED) { clear_extent_bit(&BTRFS_I(inode)->io_tree, offset, offset + iov_length(iov, nr_segs) - 1, - EXTENT_LOCKED | write_bits, 1, 0, - &cached_state, GFP_NOFS); + EXTENT_LOCKED | write_bits, 1, 0, &cached_state); } else if (ret >= 0 && ret < iov_length(iov, nr_segs)) { /* * We''re falling back to buffered, unlock the section we didn''t @@ -6121,8 +6120,7 @@ static ssize_t btrfs_direct_IO(int rw, s */ clear_extent_bit(&BTRFS_I(inode)->io_tree, offset + ret, offset + iov_length(iov, nr_segs) - 1, - EXTENT_LOCKED | write_bits, 1, 0, - &cached_state, GFP_NOFS); + EXTENT_LOCKED | write_bits, 1, 0, &cached_state); } out: free_extent_state(cached_state); @@ -6233,7 +6231,7 @@ static void btrfs_invalidatepage(struct clear_extent_bit(tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_LOCKED | EXTENT_DO_ACCOUNTING, 1, 0, - &cached_state, GFP_NOFS); + &cached_state); /* * whoever cleared the private bit is responsible * for the finish_ordered_io @@ -6249,7 +6247,7 @@ static void btrfs_invalidatepage(struct } clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 1, 1, &cached_state, GFP_NOFS); + EXTENT_DO_ACCOUNTING, 1, 1, &cached_state); __btrfs_releasepage(page, GFP_NOFS); ClearPageChecked(page); @@ -6340,7 +6338,7 @@ again: */ clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end, EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, - 0, 0, &cached_state, GFP_NOFS); + 0, 0, &cached_state); ret = btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -936,8 +936,7 @@ again: clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC | - EXTENT_DO_ACCOUNTING, 0, 0, &cached_state, - GFP_NOFS); + EXTENT_DO_ACCOUNTING, 0, 0, &cached_state); if (i_done != num_pages) { spin_lock(&BTRFS_I(inode)->lock); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 17/99] btrfs: set_extent_bit: split exclusive mode out
There are many callers of set_extent_bit but the exclusive_bits argument is only used by lock_extent and try_lock_extent. This patch eliminates the exclusive_bits argument from set_extent_bit and creates a new set_extent_bit_excl for use from the locking functions. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 44 +++++++++++++++++++++++++++++++------------- fs/btrfs/extent_io.h | 7 ++++++- fs/btrfs/inode.c | 2 +- 3 files changed, 38 insertions(+), 15 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -757,9 +757,10 @@ static void uncache_state(struct extent_ * [start, end] is inclusive This takes the tree lock. */ -int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int exclusive_bits, u64 *failed_start, - struct extent_state **cached_state, gfp_t mask) +static int __must_check +__set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int exclusive_bits, u64 *failed_start, + struct extent_state **cached_state, gfp_t mask) { struct extent_state *state; struct extent_state *prealloc = NULL; @@ -952,6 +953,22 @@ search_again: goto again; } +int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, + u64 *failed_start, struct extent_state **cached_state, + gfp_t mask) +{ + return __set_extent_bit(tree, start, end, bits, 0, + failed_start, cached_state, mask); +} + +int set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int exclusive_bits, u64 *failed_start, + struct extent_state **cached_state, gfp_t mask) +{ + return __set_extent_bit(tree, start, end, bits, exclusive_bits, + failed_start, cached_state, mask); +} + /** * convert_extent - convert all bits in a given range from one bit to another * @tree: the io tree to search @@ -1141,14 +1158,14 @@ search_again: int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_DIRTY, 0, NULL, + return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, mask); } int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask) { - return set_extent_bit(tree, start, end, bits, 0, NULL, + return set_extent_bit(tree, start, end, bits, NULL, NULL, mask); } @@ -1170,7 +1187,7 @@ int set_extent_delalloc(struct extent_io { return set_extent_bit(tree, start, end, EXTENT_DELALLOC | EXTENT_UPTODATE, - 0, NULL, cached_state, mask); + NULL, cached_state, mask); } void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) @@ -1182,14 +1199,14 @@ void clear_extent_dirty(struct extent_io int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_NEW, 0, NULL, + return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL, mask); } int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state, gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, + return set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL, cached_state, mask); } @@ -1210,9 +1227,9 @@ int lock_extent_bits(struct extent_io_tr int err; u64 failed_start; while (1) { - err = set_extent_bit(tree, start, end, EXTENT_LOCKED | bits, - EXTENT_LOCKED, &failed_start, - cached_state, mask); + err = set_extent_bit_excl(tree, start, end, + EXTENT_LOCKED | bits, EXTENT_LOCKED, + &failed_start, cached_state, mask); if (err == -EEXIST && (mask & __GFP_WAIT)) { wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED); start = failed_start; @@ -1234,8 +1251,9 @@ int try_lock_extent(struct extent_io_tre int err; u64 failed_start; - err = set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED, - &failed_start, NULL, GFP_NOFS); + err = set_extent_bit_excl(tree, start, end, EXTENT_LOCKED, + EXTENT_LOCKED, &failed_start, NULL, + GFP_NOFS); if (err == -EEXIST) { if (failed_start > start) clear_extent_bit(tree, start, failed_start - 1, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -222,8 +222,13 @@ int __must_check __set_extent_bit(struct struct extent_state **cached); int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask); +int __must_check set_extent_bit_excl(struct extent_io_tree *tree, u64 start, + u64 end, int bits, int exclusive_bits, + u64 *failed_start, + struct extent_state **cached_state, + gfp_t mask); int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int exclusive_bits, u64 *failed_start, + int bits, u64 *failed_start, struct extent_state **cached_state, gfp_t mask); int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state, gfp_t mask); --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6091,7 +6091,7 @@ static ssize_t btrfs_direct_IO(int rw, s if (writing) { write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING; ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, - EXTENT_DELALLOC, 0, NULL, &cached_state, + EXTENT_DELALLOC, NULL, &cached_state, GFP_NOFS); if (ret) { clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 18/99] btrfs: set_extent_bit should return void with __GFP_WAIT set
Now that allocations that are allowed to sleep can''t fail, set_extent_bit has no more error conditions and we can assume the return value will be 0 and return void to callers. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 4 +- fs/btrfs/disk-io.c | 5 +- fs/btrfs/disk-io.h | 2 - fs/btrfs/extent_io.c | 90 ++++++++++++++++++++++++++++----------------------- fs/btrfs/extent_io.h | 34 +++++++++++-------- fs/btrfs/file.c | 6 --- fs/btrfs/inode.c | 38 +++++---------------- fs/btrfs/scrub.c | 11 +----- 8 files changed, 89 insertions(+), 101 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2675,8 +2675,8 @@ int btrfs_truncate_inode_items(struct bt u32 min_type); int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); -int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, - struct extent_state **cached_state); +void btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, + struct extent_state **cached_state); int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc); int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2971,11 +2971,10 @@ int btrfs_buffer_uptodate(struct extent_ return !ret; } -int btrfs_set_buffer_uptodate(struct extent_buffer *buf) +void btrfs_set_buffer_uptodate(struct extent_buffer *buf) { struct inode *btree_inode = buf->first_page->mapping->host; - return set_extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, - buf); + set_extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf); } void btrfs_mark_buffer_dirty(struct extent_buffer *buf) --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -67,7 +67,7 @@ void __btrfs_btree_balance_dirty(struct int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); void btrfs_mark_buffer_dirty(struct extent_buffer *buf); int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid); -int btrfs_set_buffer_uptodate(struct extent_buffer *buf); +void btrfs_set_buffer_uptodate(struct extent_buffer *buf); int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid); u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len); void btrfs_csum_final(u32 crc, char *result); --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -953,12 +953,24 @@ search_again: goto again; } -int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, - u64 *failed_start, struct extent_state **cached_state, - gfp_t mask) +int set_extent_bit_atomic(struct extent_io_tree *tree, u64 start, u64 end, + int bits, u64 *failed_start, + struct extent_state **cached_state, gfp_t mask) +{ + WARN_ON(mask & __GFP_WAIT); + return __set_extent_bit(tree, start, end, bits, 0, failed_start, + cached_state, mask); +} + +void set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, + u64 *failed_start, struct extent_state **cached_state, + gfp_t mask) { - return __set_extent_bit(tree, start, end, bits, 0, - failed_start, cached_state, mask); + int ret; + WARN_ON(!(mask & __GFP_WAIT)); + ret = __set_extent_bit(tree, start, end, bits, 0, + failed_start, cached_state, mask); + BUG_ON(ret < 0); } int set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, @@ -1155,18 +1167,16 @@ search_again: } /* wrappers around set/clear extent bit */ -int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, - NULL, mask); + set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, mask); } -int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask) +void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, + int bits, gfp_t mask) { - return set_extent_bit(tree, start, end, bits, NULL, - NULL, mask); + set_extent_bit(tree, start, end, bits, NULL, NULL, mask); } void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, @@ -1182,12 +1192,11 @@ void clear_extent_bits(struct extent_io_ clear_extent_bit(tree, start, end, bits, 0, 0, NULL); } -int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) +void set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached_state, gfp_t mask) { - return set_extent_bit(tree, start, end, - EXTENT_DELALLOC | EXTENT_UPTODATE, - NULL, cached_state, mask); + set_extent_bit(tree, start, end, EXTENT_DELALLOC | EXTENT_UPTODATE, + NULL, cached_state, mask); } void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) @@ -1196,18 +1205,24 @@ void clear_extent_dirty(struct extent_io EXTENT_DO_ACCOUNTING, 0, 0, NULL); } -int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, - NULL, mask); + set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL, mask); } -int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) +int set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached_state, gfp_t mask) { - return set_extent_bit(tree, start, end, EXTENT_UPTODATE, - NULL, cached_state, mask); + return set_extent_bit_atomic(tree, start, end, EXTENT_UPTODATE, NULL, + cached_state, mask); +} + +void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached_state, gfp_t mask) +{ + set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL, cached_state, + mask); } static void clear_extent_uptodate(struct extent_io_tree *tree, u64 start, @@ -2107,19 +2122,16 @@ static int bio_readpage_error(struct bio free_extent_map(em); /* set the bits in the private failure tree */ - ret = set_extent_bits(failure_tree, start, end, - EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); - if (ret >= 0) - ret = set_state_private(failure_tree, start, - (u64)(unsigned long)failrec); - /* set the bits in the inode''s tree */ - if (ret >= 0) - ret = set_extent_bits(tree, start, end, EXTENT_DAMAGED, - GFP_NOFS); + set_extent_bits(failure_tree, start, end, + EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); + ret = set_state_private(failure_tree, start, + (u64)(unsigned long)failrec); if (ret < 0) { kfree(failrec); return ret; } + /* set the bits in the inode''s tree */ + set_extent_bits(tree, start, end, EXTENT_DAMAGED, GFP_NOFS); } else { failrec = (struct io_failure_record *)(unsigned long)private; pr_debug("bio_readpage_error: (found) logical=%llu, " @@ -2375,8 +2387,9 @@ static void end_bio_extent_readpage(stru } if (uptodate) { - set_extent_uptodate(tree, start, end, &cached, - GFP_ATOMIC); + ret = set_extent_uptodate_atomic(tree, start, end, + &cached, GFP_ATOMIC); + BUG_ON(ret < 0); } ret = unlock_extent_cached_atomic(tree, start, end, &cached); BUG_ON(ret < 0); @@ -3919,10 +3932,9 @@ int set_extent_buffer_uptodate(struct ex num_pages = num_extent_pages(eb->start, eb->len); - if (eb_straddles_pages(eb)) { + if (eb_straddles_pages(eb)) set_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, NULL, GFP_NOFS); - } for (i = 0; i < num_pages; i++) { page = extent_buffer_page(eb, i); if ((i == 0 && (eb->start & (PAGE_CACHE_SIZE - 1))) || --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -215,27 +215,35 @@ int __must_check clear_extent_bit_atomic void clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int wake, int delete, struct extent_state **cached); -int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask); +void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, + int bits, gfp_t mask); int __must_check set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, int bits, int exclusive_bits, u64 *failed_start, struct extent_state **cached_state, gfp_t mask); -int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, u64 *failed_start, - struct extent_state **cached_state, gfp_t mask); -int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask); -int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); -int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +int __must_check set_extent_bit_atomic(struct extent_io_tree *tree, u64 start, + u64 end, int bits, u64 *failed_start, + struct extent_state **cached_state, + gfp_t mask); +void set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, + u64 *failed_start, struct extent_state **cached_state, + gfp_t mask); +int __must_check set_extent_uptodate_atomic(struct extent_io_tree *tree, + u64 start, u64 end, + struct extent_state **cached_state, + gfp_t mask); +void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached_state, gfp_t mask); +void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask); +void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask); void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int clear_bits, gfp_t mask); -int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask); +void set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, + struct extent_state **cached_state, gfp_t mask); int find_first_extent_bit(struct extent_io_tree *tree, u64 start, u64 *start_ret, u64 *end_ret, int bits); struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree, --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -390,7 +390,6 @@ int btrfs_dirty_pages(struct btrfs_root loff_t pos, size_t write_bytes, struct extent_state **cached) { - int err = 0; int i; u64 num_bytes; u64 start_pos; @@ -403,10 +402,7 @@ int btrfs_dirty_pages(struct btrfs_root root->sectorsize - 1) & ~((u64)root->sectorsize - 1); end_of_last_block = start_pos + num_bytes - 1; - err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, - cached); - if (err) - return err; + btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, cached); for (i = 0; i < num_pages; i++) { struct page *p = pages[i]; --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1530,13 +1530,13 @@ static noinline int add_pending_csums(st return 0; } -int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, - struct extent_state **cached_state) +void btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, + struct extent_state **cached_state) { if ((end & (PAGE_CACHE_SIZE - 1)) == 0) WARN_ON(1); - return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, - cached_state, GFP_NOFS); + set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, + cached_state, GFP_NOFS); } /* see btrfs_writepage_start_hook for details on why this is required */ @@ -3248,13 +3248,7 @@ again: EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, 0, 0, &cached_state); - ret = btrfs_set_extent_delalloc(inode, page_start, page_end, - &cached_state); - if (ret) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state); - goto out_unlock; - } + btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); ret = 0; if (offset != PAGE_CACHE_SIZE) { @@ -4210,7 +4204,7 @@ void btrfs_dirty_inode(struct inode *ino trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) { printk_ratelimited(KERN_ERR "btrfs: fail to " - "dirty inode %llu error %ld\n", + "dirty inode %llu error %ld (trans)\n", (unsigned long long)btrfs_ino(inode), PTR_ERR(trans)); return; @@ -6090,15 +6084,8 @@ static ssize_t btrfs_direct_IO(int rw, s */ if (writing) { write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING; - ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, - EXTENT_DELALLOC, NULL, &cached_state, - GFP_NOFS); - if (ret) { - clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, - lockend, EXTENT_LOCKED | write_bits, - 1, 0, &cached_state); - goto out; - } + set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, + EXTENT_DELALLOC, NULL, &cached_state, GFP_NOFS); } free_extent_state(cached_state); @@ -6340,14 +6327,7 @@ again: EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING, 0, 0, &cached_state); - ret = btrfs_set_extent_delalloc(inode, page_start, page_end, - &cached_state); - if (ret) { - unlock_extent_cached(io_tree, page_start, page_end, - &cached_state); - ret = VM_FAULT_SIGBUS; - goto out_unlock; - } + btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); ret = 0; /* page is wholly or partially inside EOF */ --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -424,15 +424,8 @@ static int scrub_fixup_readpage(u64 inum * will call repair_io_failure for us, we just have to make * sure we read the bad mirror. */ - ret = set_extent_bits(&BTRFS_I(inode)->io_tree, offset, end, - EXTENT_DAMAGED, GFP_NOFS); - if (ret) { - /* set_extent_bits should give proper error */ - WARN_ON(ret > 0); - if (ret > 0) - ret = -EFAULT; - goto out; - } + set_extent_bits(&BTRFS_I(inode)->io_tree, offset, end, + EXTENT_DAMAGED, GFP_NOFS); ret = extent_read_full_page(&BTRFS_I(inode)->io_tree, page, btrfs_get_extent, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 19/99] btrfs: lock_extent can drop gfp_t argument
All of the callers of lock_extent call it with gfp_t == GFP_NOFS. This patch simplifies the call sites by calling clear_extent_bit with GFP_NOFS from lock_extent itself. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/compression.c | 2 +- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 19 ++++++++++--------- fs/btrfs/extent_io.h | 4 ++-- fs/btrfs/file.c | 7 +++---- fs/btrfs/free-space-cache.c | 2 +- fs/btrfs/inode.c | 27 +++++++++++---------------- fs/btrfs/ioctl.c | 7 +++---- fs/btrfs/relocation.c | 8 ++++---- 9 files changed, 36 insertions(+), 42 deletions(-) --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -497,7 +497,7 @@ static noinline int add_ra_bio_pages(str * sure they map to this compressed extent on disk. */ set_page_extent_mapped(page); - lock_extent(tree, last_offset, end, GFP_NOFS); + lock_extent(tree, last_offset, end); read_lock(&em_tree->lock); em = lookup_extent_mapping(em_tree, last_offset, PAGE_CACHE_SIZE); --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -331,7 +331,7 @@ static int verify_parent_transid(struct return 0; lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1, - 0, &cached_state, GFP_NOFS); + 0, &cached_state); if (extent_buffer_uptodate(io_tree, eb, cached_state) && btrfs_header_generation(eb) == parent_transid) { ret = 0; --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1239,15 +1239,16 @@ static void clear_extent_uptodate(struct * us if waiting is desired. */ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, struct extent_state **cached_state, gfp_t mask) + int bits, struct extent_state **cached_state) { int err; u64 failed_start; while (1) { err = set_extent_bit_excl(tree, start, end, EXTENT_LOCKED | bits, EXTENT_LOCKED, - &failed_start, cached_state, mask); - if (err == -EEXIST && (mask & __GFP_WAIT)) { + &failed_start, cached_state, + GFP_NOFS); + if (err == -EEXIST) { wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED); start = failed_start; } else { @@ -1258,9 +1259,9 @@ int lock_extent_bits(struct extent_io_tr return err; } -int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) +int lock_extent(struct extent_io_tree *tree, u64 start, u64 end) { - return lock_extent_bits(tree, start, end, 0, NULL, mask); + return lock_extent_bits(tree, start, end, 0, NULL); } int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end) @@ -1593,7 +1594,7 @@ again: /* step three, lock the state bits for the whole range */ lock_extent_bits(tree, delalloc_start, delalloc_end, - 0, &cached_state, GFP_NOFS); + 0, &cached_state); /* then test to make sure it is all still delalloc */ ret = test_range_bit(tree, delalloc_start, delalloc_end, @@ -2584,7 +2585,7 @@ static int __extent_read_full_page(struc end = page_end; while (1) { - lock_extent(tree, start, end, GFP_NOFS); + lock_extent(tree, start, end); ordered = btrfs_lookup_ordered_extent(inode, start); if (!ordered) break; @@ -3287,7 +3288,7 @@ int extent_invalidatepage(struct extent_ if (start > end) return 0; - lock_extent_bits(tree, start, end, 0, &cached_state, GFP_NOFS); + lock_extent_bits(tree, start, end, 0, &cached_state); wait_on_page_writeback(page); clear_extent_bit(tree, start, end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | @@ -3503,7 +3504,7 @@ int extent_fiemap(struct inode *inode, s } lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0, - &cached_state, GFP_NOFS); + &cached_state); em = get_extent_skip_holes(inode, start, last_for_get_extent, get_extent); --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -180,9 +180,9 @@ int try_release_extent_buffer(struct ext int try_release_extent_state(struct extent_map_tree *map, struct extent_io_tree *tree, struct page *page, gfp_t mask); -int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); +int lock_extent(struct extent_io_tree *tree, u64 start, u64 end); int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, struct extent_state **cached, gfp_t mask); + int bits, struct extent_state **cached); void unlock_extent(struct extent_io_tree *tree, u64 start, u64 end); int __must_check unlock_extent_cached_atomic(struct extent_io_tree *tree, u64 start, u64 end, --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1101,8 +1101,7 @@ again: if (start_pos < inode->i_size) { struct btrfs_ordered_extent *ordered; lock_extent_bits(&BTRFS_I(inode)->io_tree, - start_pos, last_pos - 1, 0, &cached_state, - GFP_NOFS); + start_pos, last_pos - 1, 0, &cached_state); ordered = btrfs_lookup_first_ordered_extent(inode, last_pos - 1); if (ordered && @@ -1618,7 +1617,7 @@ static long btrfs_fallocate(struct file * transaction */ lock_extent_bits(&BTRFS_I(inode)->io_tree, alloc_start, - locked_end, 0, &cached_state, GFP_NOFS); + locked_end, 0, &cached_state); ordered = btrfs_lookup_first_ordered_extent(inode, alloc_end - 1); if (ordered && @@ -1730,7 +1729,7 @@ static int find_desired_extent(struct in return -ENXIO; lock_extent_bits(&BTRFS_I(inode)->io_tree, lockstart, lockend, 0, - &cached_state, GFP_NOFS); + &cached_state); /* * Delalloc is such a pain. If we have a hole and we have pending --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -862,7 +862,7 @@ int __btrfs_write_out_cache(struct btrfs io_ctl_prepare_pages(&io_ctl, inode, 0); lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1, - 0, &cached_state, GFP_NOFS); + 0, &cached_state); /* * When searching for pinned extents, we need to start at our start --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -596,7 +596,7 @@ retry: lock_extent(io_tree, async_extent->start, async_extent->start + - async_extent->ram_size - 1, GFP_NOFS); + async_extent->ram_size - 1); /* allocate blocks */ ret = cow_file_range(inode, async_cow->locked_page, @@ -624,8 +624,7 @@ retry: } lock_extent(io_tree, async_extent->start, - async_extent->start + async_extent->ram_size - 1, - GFP_NOFS); + async_extent->start + async_extent->ram_size - 1); trans = btrfs_join_transaction(root); BUG_ON(IS_ERR(trans)); @@ -1569,7 +1568,7 @@ again: page_end = page_offset(page) + PAGE_CACHE_SIZE - 1; lock_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end, 0, - &cached_state, GFP_NOFS); + &cached_state); /* already ordered? We''re done */ if (PagePrivate2(page)) @@ -1751,7 +1750,7 @@ static int btrfs_finish_ordered_io(struc lock_extent_bits(io_tree, ordered_extent->file_offset, ordered_extent->file_offset + ordered_extent->len - 1, - 0, &cached_state, GFP_NOFS); + 0, &cached_state); if (nolock) trans = btrfs_join_transaction_nolock(root); @@ -3229,8 +3228,7 @@ again: } wait_on_page_writeback(page); - lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state); set_page_extent_mapped(page); ordered = btrfs_lookup_ordered_extent(inode, page_start); @@ -3299,7 +3297,7 @@ int btrfs_cont_expand(struct inode *inod btrfs_wait_ordered_range(inode, hole_start, block_end - hole_start); lock_extent_bits(io_tree, hole_start, block_end - 1, 0, - &cached_state, GFP_NOFS); + &cached_state); ordered = btrfs_lookup_ordered_extent(inode, hole_start); if (!ordered) break; @@ -5646,7 +5644,7 @@ again: lock_extent_bits(&BTRFS_I(inode)->io_tree, ordered->file_offset, ordered->file_offset + ordered->len - 1, 0, - &cached_state, GFP_NOFS); + &cached_state); if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags)) { ret = btrfs_mark_extent_written(trans, inode, @@ -6061,7 +6059,7 @@ static ssize_t btrfs_direct_IO(int rw, s while (1) { lock_extent_bits(&BTRFS_I(inode)->io_tree, lockstart, lockend, - 0, &cached_state, GFP_NOFS); + 0, &cached_state); /* * We''re concerned with the entire range that we''re going to be * doing DIO to, so we need to make sure theres no ordered @@ -6206,8 +6204,7 @@ static void btrfs_invalidatepage(struct btrfs_releasepage(page, GFP_NOFS); return; } - lock_extent_bits(tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent_bits(tree, page_start, page_end, 0, &cached_state); ordered = btrfs_lookup_ordered_extent(page->mapping->host, page_offset(page)); if (ordered) { @@ -6229,8 +6226,7 @@ static void btrfs_invalidatepage(struct } btrfs_put_ordered_extent(ordered); cached_state = NULL; - lock_extent_bits(tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent_bits(tree, page_start, page_end, 0, &cached_state); } clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC | @@ -6298,8 +6294,7 @@ again: } wait_on_page_writeback(page); - lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state, - GFP_NOFS); + lock_extent_bits(io_tree, page_start, page_end, 0, &cached_state); set_page_extent_mapped(page); /* --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -788,7 +788,7 @@ static int should_defrag_range(struct in if (!em) { /* get the big lock and read metadata off disk */ - lock_extent(io_tree, start, start + len - 1, GFP_NOFS); + lock_extent(io_tree, start, start + len - 1); em = btrfs_get_extent(inode, NULL, 0, start, len, 0); unlock_extent(io_tree, start, start + len - 1); @@ -913,8 +913,7 @@ again: page_end = page_offset(pages[i_done - 1]) + PAGE_CACHE_SIZE; lock_extent_bits(&BTRFS_I(inode)->io_tree, - page_start, page_end - 1, 0, &cached_state, - GFP_NOFS); + page_start, page_end - 1, 0, &cached_state); ordered = btrfs_lookup_first_ordered_extent(inode, page_end - 1); if (ordered && ordered->file_offset + ordered->len > page_start && @@ -2273,7 +2272,7 @@ static noinline long btrfs_ioctl_clone(s another, and lock file content */ while (1) { struct btrfs_ordered_extent *ordered; - lock_extent(&BTRFS_I(src)->io_tree, off, off+len, GFP_NOFS); + lock_extent(&BTRFS_I(src)->io_tree, off, off+len); ordered = btrfs_lookup_first_ordered_extent(src, off+len); if (!ordered && !test_range_bit(&BTRFS_I(src)->io_tree, off, off+len, --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1972,7 +1972,7 @@ static int invalidate_extent_cache(struc } /* the lock_extent waits for readpage to complete */ - lock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, start, end); btrfs_drop_extent_cache(inode, start, end, 1); unlock_extent(&BTRFS_I(inode)->io_tree, start, end); } @@ -2878,7 +2878,7 @@ int prealloc_file_extent_cluster(struct else end = cluster->end - offset; - lock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, start, end); num_bytes = end + 1 - start; ret = btrfs_prealloc_file_range(inode, 0, start, num_bytes, num_bytes, @@ -2915,7 +2915,7 @@ int setup_extent_mapping(struct inode *i em->bdev = root->fs_info->fs_devices->latest_bdev; set_bit(EXTENT_FLAG_PINNED, &em->flags); - lock_extent(&BTRFS_I(inode)->io_tree, start, end, GFP_NOFS); + lock_extent(&BTRFS_I(inode)->io_tree, start, end); while (1) { write_lock(&em_tree->lock); ret = add_extent_mapping(em_tree, em); @@ -3007,7 +3007,7 @@ static int relocate_file_extent_cluster( page_end = page_start + PAGE_CACHE_SIZE - 1; lock_extent(&BTRFS_I(inode)->io_tree, - page_start, page_end, GFP_NOFS); + page_start, page_end); set_page_extent_mapped(page); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 20/99] btrfs: set_extent_dirty can drop gfp_t argument
Now that all of the callers of set_extent_dirty use GFP_NOFS, we can drop the gfp_t argument entirely and allow set_extent_dirty to always pass GFP_NOFS. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 9 ++++----- fs/btrfs/extent_io.c | 5 ++--- fs/btrfs/extent_io.h | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4363,8 +4363,7 @@ static int update_block_group(struct btr spin_unlock(&cache->space_info->lock); set_extent_dirty(info->pinned_extents, - bytenr, bytenr + num_bytes - 1, - GFP_NOFS | __GFP_NOFAIL); + bytenr, bytenr + num_bytes - 1); } btrfs_put_block_group(cache); total -= num_bytes; @@ -4404,7 +4403,7 @@ static int pin_down_extent(struct btrfs_ spin_unlock(&cache->space_info->lock); set_extent_dirty(root->fs_info->pinned_extents, bytenr, - bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL); + bytenr + num_bytes - 1); return 0; } @@ -5866,13 +5865,13 @@ struct extent_buffer *btrfs_init_new_buf */ if (root->log_transid % 2 == 0) set_extent_dirty(&root->dirty_log_pages, buf->start, - buf->start + buf->len - 1, GFP_NOFS); + buf->start + buf->len - 1); else set_extent_new(&root->dirty_log_pages, buf->start, buf->start + buf->len - 1, GFP_NOFS); } else { set_extent_dirty(&trans->transaction->dirty_pages, buf->start, - buf->start + buf->len - 1, GFP_NOFS); + buf->start + buf->len - 1); } trans->blocks_used++; /* this returns a buffer locked for blocking */ --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1167,10 +1167,9 @@ search_again: } /* wrappers around set/clear extent bit */ -void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) { - set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, mask); + set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, GFP_NOFS); } void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -237,8 +237,7 @@ void set_extent_uptodate(struct extent_i struct extent_state **cached_state, gfp_t mask); void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); -void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int clear_bits, gfp_t mask); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 21/99] btrfs: set_extent_bits can drop gfp_t argument
Now that all of the callers of set_extent_bits use GFP_NOFS, we can drop the gfp_t argument entirely and allow set_extent_bits to always pass GFP_NOFS. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 4 ++-- fs/btrfs/extent_io.c | 9 ++++----- fs/btrfs/extent_io.h | 2 +- fs/btrfs/file-item.c | 2 +- fs/btrfs/relocation.c | 4 ++-- fs/btrfs/scrub.c | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -211,9 +211,9 @@ static int add_excluded_extent(struct bt { u64 end = start + num_bytes - 1; set_extent_bits(&root->fs_info->freed_extents[0], - start, end, EXTENT_UPTODATE, GFP_NOFS); + start, end, EXTENT_UPTODATE); set_extent_bits(&root->fs_info->freed_extents[1], - start, end, EXTENT_UPTODATE, GFP_NOFS); + start, end, EXTENT_UPTODATE); return 0; } --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1172,10 +1172,9 @@ void set_extent_dirty(struct extent_io_t set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, GFP_NOFS); } -void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask) +void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits) { - set_extent_bit(tree, start, end, bits, NULL, NULL, mask); + set_extent_bit(tree, start, end, bits, NULL, NULL, GFP_NOFS); } void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, @@ -2125,7 +2124,7 @@ static int bio_readpage_error(struct bio /* set the bits in the private failure tree */ set_extent_bits(failure_tree, start, end, - EXTENT_LOCKED | EXTENT_DIRTY, GFP_NOFS); + EXTENT_LOCKED | EXTENT_DIRTY); ret = set_state_private(failure_tree, start, (u64)(unsigned long)failrec); if (ret < 0) { @@ -2133,7 +2132,7 @@ static int bio_readpage_error(struct bio return ret; } /* set the bits in the inode''s tree */ - set_extent_bits(tree, start, end, EXTENT_DAMAGED, GFP_NOFS); + set_extent_bits(tree, start, end, EXTENT_DAMAGED); } else { failrec = (struct io_failure_record *)(unsigned long)private; pr_debug("bio_readpage_error: (found) logical=%llu, " --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -216,7 +216,7 @@ void clear_extent_bit(struct extent_io_t int bits, int wake, int delete, struct extent_state **cached); void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, - int bits, gfp_t mask); + int bits); int __must_check set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, int bits, int exclusive_bits, u64 *failed_start, --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -214,7 +214,7 @@ static int __btrfs_lookup_bio_sums(struc BTRFS_DATA_RELOC_TREE_OBJECTID) { set_extent_bits(io_tree, offset, offset + bvec->bv_len - 1, - EXTENT_NODATASUM, GFP_NOFS); + EXTENT_NODATASUM); } else { printk(KERN_INFO "btrfs no csum found " "for inode %llu start %llu\n", --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2645,7 +2645,7 @@ static void mark_block_processed(struct u64 bytenr, u32 blocksize) { set_extent_bits(&rc->processed_blocks, bytenr, bytenr + blocksize - 1, - EXTENT_DIRTY, GFP_NOFS); + EXTENT_DIRTY); } static void __mark_block_processed(struct reloc_control *rc, @@ -3015,7 +3015,7 @@ static int relocate_file_extent_cluster( page_start + offset == cluster->boundary[nr]) { set_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end, - EXTENT_BOUNDARY, GFP_NOFS); + EXTENT_BOUNDARY); nr++; } --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -425,7 +425,7 @@ static int scrub_fixup_readpage(u64 inum * sure we read the bad mirror. */ set_extent_bits(&BTRFS_I(inode)->io_tree, offset, end, - EXTENT_DAMAGED, GFP_NOFS); + EXTENT_DAMAGED); ret = extent_read_full_page(&BTRFS_I(inode)->io_tree, page, btrfs_get_extent, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 22/99] btrfs: set_extent_delalloc can drop gfp_t argument
Now that all of the callers of set_extent_delalloc use GFP_NOFS, we can drop the gfp_t argument entirely and allow set_extent_delalloc to always pass GFP_NOFS. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1191,10 +1191,10 @@ void clear_extent_bits(struct extent_io_ } void set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { set_extent_bit(tree, start, end, EXTENT_DELALLOC | EXTENT_UPTODATE, - NULL, cached_state, mask); + NULL, cached_state, GFP_NOFS); } void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -242,7 +242,7 @@ void clear_extent_dirty(struct extent_io int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, int clear_bits, gfp_t mask); void set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask); + struct extent_state **cached_state); int find_first_extent_bit(struct extent_io_tree *tree, u64 start, u64 *start_ret, u64 *end_ret, int bits); struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree, --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1535,7 +1535,7 @@ void btrfs_set_extent_delalloc(struct in if ((end & (PAGE_CACHE_SIZE - 1)) == 0) WARN_ON(1); set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, - cached_state, GFP_NOFS); + cached_state); } /* see btrfs_writepage_start_hook for details on why this is required */ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 23/99] btrfs: set_extent_new can drop gfp_t argument
Now that all of the callers of set_extent_new use GFP_NOFS, we can drop the gfp_t argument entirely and allow set_extent_new to always pass GFP_NOFS. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are new callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/extent_io.c | 5 ++--- fs/btrfs/extent_io.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5868,7 +5868,7 @@ struct extent_buffer *btrfs_init_new_buf buf->start + buf->len - 1); else set_extent_new(&root->dirty_log_pages, buf->start, - buf->start + buf->len - 1, GFP_NOFS); + buf->start + buf->len - 1); } else { set_extent_dirty(&trans->transaction->dirty_pages, buf->start, buf->start + buf->len - 1); --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1203,10 +1203,9 @@ void clear_extent_dirty(struct extent_io EXTENT_DO_ACCOUNTING, 0, 0, NULL); } -void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask) +void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end) { - set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL, mask); + set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL, GFP_NOFS); } int set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -235,8 +235,7 @@ int __must_check set_extent_uptodate_ato gfp_t mask); void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state, gfp_t mask); -void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, - gfp_t mask); +void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end); void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 24/99] btrfs: set_extent_uptodate can drop gfp_t argument
Now that all of the callers of set_extent_uptodate use GFP_NOFS or GFP_ATOMIC, we can drop the gfp_t argument entirely and allow set_extent_uptodate to always pass GFP_NOFS to set_extent_bit or GFP_ATOMIC to set_extent_bit_atomic. Since the extent io code will probably never be used outside of a file system, this is generally ok. If there are uptodate callers, they can add their own version or re-genericize it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 16 ++++++++-------- fs/btrfs/extent_io.h | 5 ++--- fs/btrfs/inode.c | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1214,17 +1214,17 @@ void set_extent_new(struct extent_io_tre } int set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { return set_extent_bit_atomic(tree, start, end, EXTENT_UPTODATE, NULL, - cached_state, mask); + cached_state, GFP_ATOMIC); } void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL, cached_state, - mask); + GFP_NOFS); } static void clear_extent_uptodate(struct extent_io_tree *tree, u64 start, @@ -2391,7 +2391,7 @@ static void end_bio_extent_readpage(stru if (uptodate) { ret = set_extent_uptodate_atomic(tree, start, end, - &cached, GFP_ATOMIC); + &cached); BUG_ON(ret < 0); } ret = unlock_extent_cached_atomic(tree, start, end, &cached); @@ -2617,7 +2617,7 @@ static int __extent_read_full_page(struc flush_dcache_page(page); kunmap_atomic(userpage, KM_USER0); set_extent_uptodate(tree, cur, cur + iosize - 1, - &cached, GFP_NOFS); + &cached); unlock_extent_cached(tree, cur, cur + iosize - 1, &cached); break; @@ -2667,7 +2667,7 @@ static int __extent_read_full_page(struc kunmap_atomic(userpage, KM_USER0); set_extent_uptodate(tree, cur, cur + iosize - 1, - &cached, GFP_NOFS); + &cached); unlock_extent_cached(tree, cur, cur + iosize - 1, &cached); cur = cur + iosize; @@ -3937,7 +3937,7 @@ int set_extent_buffer_uptodate(struct ex if (eb_straddles_pages(eb)) set_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, - NULL, GFP_NOFS); + NULL); for (i = 0; i < num_pages; i++) { page = extent_buffer_page(eb, i); if ((i == 0 && (eb->start & (PAGE_CACHE_SIZE - 1))) || --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -231,10 +231,9 @@ void set_extent_bit(struct extent_io_tre gfp_t mask); int __must_check set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, - gfp_t mask); + struct extent_state **cached_state); void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, - struct extent_state **cached_state, gfp_t mask); + struct extent_state **cached_state); void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end); void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5021,7 +5021,7 @@ again: btrfs_mark_buffer_dirty(leaf); } set_extent_uptodate(io_tree, em->start, - extent_map_end(em) - 1, NULL, GFP_NOFS); + extent_map_end(em) - 1, NULL); goto insert; } else { printk(KERN_ERR "btrfs unknown found_type %d\n", found_type); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 25/99] btrfs: set_extent_bit can drop gfp_t argument
Now that all of the callers of set_extent_bit use GFP_NOFS and all callers of set_extent_bit_atomic use GFP_ATOMIC, we can drop the gfp_t argument to both. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 35 +++++++++++++++-------------------- fs/btrfs/extent_io.h | 9 +++------ fs/btrfs/inode.c | 2 +- 3 files changed, 19 insertions(+), 27 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -960,30 +960,28 @@ search_again: int set_extent_bit_atomic(struct extent_io_tree *tree, u64 start, u64 end, int bits, u64 *failed_start, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { - WARN_ON(mask & __GFP_WAIT); return __set_extent_bit(tree, start, end, bits, 0, failed_start, - cached_state, mask); + cached_state, GFP_ATOMIC); } void set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, - u64 *failed_start, struct extent_state **cached_state, - gfp_t mask) + u64 *failed_start, struct extent_state **cached_state) { int ret; - WARN_ON(!(mask & __GFP_WAIT)); + might_sleep(); ret = __set_extent_bit(tree, start, end, bits, 0, - failed_start, cached_state, mask); + failed_start, cached_state, GFP_NOFS); BUG_ON(ret < 0); } int set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, int bits, int exclusive_bits, u64 *failed_start, - struct extent_state **cached_state, gfp_t mask) + struct extent_state **cached_state) { return __set_extent_bit(tree, start, end, bits, exclusive_bits, - failed_start, cached_state, mask); + failed_start, cached_state, GFP_NOFS); } /** @@ -1174,12 +1172,12 @@ search_again: /* wrappers around set/clear extent bit */ void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) { - set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, GFP_NOFS); + set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL); } void set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits) { - set_extent_bit(tree, start, end, bits, NULL, NULL, GFP_NOFS); + set_extent_bit(tree, start, end, bits, NULL, NULL); } void clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, @@ -1199,7 +1197,7 @@ void set_extent_delalloc(struct extent_i struct extent_state **cached_state) { set_extent_bit(tree, start, end, EXTENT_DELALLOC | EXTENT_UPTODATE, - NULL, cached_state, GFP_NOFS); + NULL, cached_state); } void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) @@ -1210,21 +1208,20 @@ void clear_extent_dirty(struct extent_io void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end) { - set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL, GFP_NOFS); + set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL); } int set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state) { return set_extent_bit_atomic(tree, start, end, EXTENT_UPTODATE, NULL, - cached_state, GFP_ATOMIC); + cached_state); } void set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state) { - set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL, cached_state, - GFP_NOFS); + set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL, cached_state); } static void clear_extent_uptodate(struct extent_io_tree *tree, u64 start, @@ -1246,8 +1243,7 @@ int lock_extent_bits(struct extent_io_tr while (1) { err = set_extent_bit_excl(tree, start, end, EXTENT_LOCKED | bits, EXTENT_LOCKED, - &failed_start, cached_state, - GFP_NOFS); + &failed_start, cached_state); if (err == -EEXIST) { wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED); start = failed_start; @@ -1270,8 +1266,7 @@ int try_lock_extent(struct extent_io_tre u64 failed_start; err = set_extent_bit_excl(tree, start, end, EXTENT_LOCKED, - EXTENT_LOCKED, &failed_start, NULL, - GFP_NOFS); + EXTENT_LOCKED, &failed_start, NULL); if (err == -EEXIST) { if (failed_start > start) clear_extent_bit(tree, start, failed_start - 1, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -220,15 +220,12 @@ void set_extent_bits(struct extent_io_tr int __must_check set_extent_bit_excl(struct extent_io_tree *tree, u64 start, u64 end, int bits, int exclusive_bits, u64 *failed_start, - struct extent_state **cached_state, - gfp_t mask); + struct extent_state **cached_state); int __must_check set_extent_bit_atomic(struct extent_io_tree *tree, u64 start, u64 end, int bits, u64 *failed_start, - struct extent_state **cached_state, - gfp_t mask); + struct extent_state **cached_state); void set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, - u64 *failed_start, struct extent_state **cached_state, - gfp_t mask); + u64 *failed_start, struct extent_state **cached_state); int __must_check set_extent_uptodate_atomic(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state); --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6083,7 +6083,7 @@ static ssize_t btrfs_direct_IO(int rw, s if (writing) { write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING; set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, - EXTENT_DELALLOC, NULL, &cached_state, GFP_NOFS); + EXTENT_DELALLOC, NULL, &cached_state); } free_extent_state(cached_state); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:35 UTC
[patch 26/99] btrfs: set_extent_buffer_uptodate should return void
set_extent_buffer_uptodate has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3940,7 +3940,7 @@ void clear_extent_buffer_uptodate(struct } } -int set_extent_buffer_uptodate(struct extent_io_tree *tree, +void set_extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb) { unsigned long i; @@ -3962,7 +3962,6 @@ int set_extent_buffer_uptodate(struct ex } SetPageUptodate(page); } - return 0; } int extent_range_uptodate(struct extent_io_tree *tree, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -310,8 +310,8 @@ int clear_extent_buffer_dirty(struct ext struct extent_buffer *eb); int set_extent_buffer_dirty(struct extent_io_tree *tree, struct extent_buffer *eb); -int set_extent_buffer_uptodate(struct extent_io_tree *tree, - struct extent_buffer *eb); +void set_extent_buffer_uptodate(struct extent_io_tree *tree, + struct extent_buffer *eb); void clear_extent_buffer_uptodate(struct extent_io_tree *tree, struct extent_buffer *eb, struct extent_state **cached_state); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 27/99] btrfs: set_extent_bit should return -ENOMEM on GFP_ATOMIC failures
The only failure condition is for GFP_ATOMIC allocations. Push up to callers which are already handling it. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) Index: linux-3.0-SLE11-SP2/fs/btrfs/extent_io.c ==================================================================--- linux-3.0-SLE11-SP2.orig/fs/btrfs/extent_io.c 2011-11-21 14:09:59.000000000 -0500 +++ linux-3.0-SLE11-SP2/fs/btrfs/extent_io.c 2011-11-21 14:11:54.000000000 -0500 @@ -765,6 +765,9 @@ static void uncache_state(struct extent_ * part of the range already has the desired bits set. The start of the * existing range is returned in failed_start in this case. * + * It may also fail with -ENOMEM if memory cannot be obtained for extent_state + * structures when called with mask == GFP_ATOMIC. + * * [start, end] is inclusive This takes the tree lock. */ @@ -803,7 +806,11 @@ again: if (!node) { assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } + err = insert_state(tree, prealloc, start, end, &bits); if (err) extent_io_tree_panic(tree, err); @@ -873,7 +880,11 @@ hit_next: assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } + err = split_state(tree, state, prealloc, start); if (err) extent_io_tree_panic(tree, err); @@ -907,7 +918,10 @@ hit_next: assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } /* * Avoid to free ''prealloc'' if it can be merged with @@ -938,7 +952,11 @@ hit_next: assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } + err = split_state(tree, state, prealloc, end + 1); if (err) extent_io_tree_panic(tree, err); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
clear_extent_bit can fail with -ENOMEM for a specific case but will BUG on other memory allocation failures. This patch returns -ENOMEM for memory allocation failures and handles them with BUG_ON in callers which don''t handle it already. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) Index: source/fs/btrfs/extent_io.c ==================================================================--- source.orig/fs/btrfs/extent_io.c 2011-11-21 14:40:44.000000000 -0500 +++ source/fs/btrfs/extent_io.c 2011-11-21 14:40:45.000000000 -0500 @@ -503,7 +503,7 @@ static int __clear_extent_bit(struct ext struct rb_node *next_node; struct rb_node *node; u64 last_end; - int err; + int err = 0; int clear = 0; if (delete) @@ -568,7 +568,10 @@ hit_next: if (state->start < start) { assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } err = split_state(tree, state, prealloc, start); if (err) extent_io_tree_panic(tree, err); @@ -593,7 +596,10 @@ hit_next: if (state->start <= end && state->end > end) { assert_atomic_alloc(prealloc, mask); prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } err = split_state(tree, state, prealloc, end + 1); if (err) extent_io_tree_panic(tree, err); @@ -629,7 +635,7 @@ out: if (prealloc) free_extent_state(prealloc); - return 0; + return err; search_again: if (start > end) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 29/99] btrfs: convert_extent_bit should return void with __GFP_WAIT set
Now that allocations that are allowed to sleep can''t fail, convert_extent_bit has no more error conditions and we can assume the return value will be 0 and return void to callers. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 18 ++++++++++++++---- fs/btrfs/extent_io.h | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1011,8 +1011,8 @@ int set_extent_bit_excl(struct extent_io * converting from say DELALLOC to DIRTY. This is not meant to be used with * boundary bits like LOCK. */ -int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int clear_bits, gfp_t mask) +static int __convert_extent_bit(struct extent_io_tree *tree, u64 start, + u64 end, int bits, int clear_bits, gfp_t mask) { struct extent_state *state; struct extent_state *prealloc = NULL; @@ -1020,9 +1020,10 @@ int convert_extent_bit(struct extent_io_ int err = 0; u64 last_start; u64 last_end; + int wait = mask & __GFP_WAIT; again: - if (!prealloc && (mask & __GFP_WAIT)) + if (!prealloc && !wait) prealloc = alloc_extent_state_nofail(mask); spin_lock(&tree->lock); @@ -1176,11 +1177,20 @@ search_again: if (start > end) goto out; spin_unlock(&tree->lock); - if (mask & __GFP_WAIT) + if (wait) cond_resched(); goto again; } +void convert_extent_bit(struct extent_io_tree *tree, u64 start, + u64 end, int bits, int clear_bits, gfp_t mask) +{ + int ret; + WARN_ON(!(mask & __GFP_WAIT)); + ret = __convert_extent_bit(tree, start, end, bits, clear_bits, mask); + BUG_ON(ret < 0); +} + /* wrappers around set/clear extent bit */ void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end) { --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -233,8 +233,8 @@ void set_extent_uptodate(struct extent_i void set_extent_new(struct extent_io_tree *tree, u64 start, u64 end); void set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); void clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end); -int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int clear_bits, gfp_t mask); +void convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, + int bits, int clear_bits, gfp_t mask); void set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, struct extent_state **cached_state); int find_first_extent_bit(struct extent_io_tree *tree, u64 start, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 30/99] btrfs: pin_down_extent should return void
pin_down_extent performs some operations which can''t fail and then calls set_extent_dirty, which has two failure cases via set_extent_bit: 1) Return -EEXIST if exclusive bits are set - Since it doesn''t use any exclusive bits, this failure case can''t occur. 2) Return -ENOMEM if memory can''t be allocated - Since it''s called with gfp_flags & __GFP_NOFAIL, this failure case can''t occur. With no failure cases, it should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4290,9 +4290,9 @@ static u64 first_logical_byte(struct btr return bytenr; } -static int pin_down_extent(struct btrfs_root *root, - struct btrfs_block_group_cache *cache, - u64 bytenr, u64 num_bytes, int reserved) +static void pin_down_extent(struct btrfs_root *root, + struct btrfs_block_group_cache *cache, + u64 bytenr, u64 num_bytes, int reserved) { spin_lock(&cache->space_info->lock); spin_lock(&cache->lock); @@ -4311,7 +4311,6 @@ static int pin_down_extent(struct btrfs_ set_extent_dirty(root->fs_info->pinned_extents, bytenr, bytenr + num_bytes - 1); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
btrfs_pin_extent looks up a block group and then calls pin_down_extent with it. If the lookup fails, it should return -ENOENT to allow callers to handle the error condition. For the three existing callers, it is a logic error if the lookup fails and a panic will occur. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 11 ++++++----- fs/btrfs/extent-tree.c | 23 +++++++++++++++++------ fs/btrfs/tree-log.c | 8 ++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2155,11 +2155,12 @@ int btrfs_lookup_extent(struct btrfs_roo int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytenr, u64 num_bytes, u64 *refs, u64 *flags); -int btrfs_pin_extent(struct btrfs_root *root, - u64 bytenr, u64 num, int reserved); -int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytenr, u64 num_bytes); +int __must_check btrfs_pin_extent(struct btrfs_root *root, u64 bytenr, + u64 num, int reserved); +int __must_check btrfs_pin_extent_for_log_replay( + struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 bytenr, u64 num_bytes); int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, u64 offset, u64 bytenr); --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2101,8 +2101,14 @@ static int run_one_delayed_ref(struct bt BUG_ON(extent_op); head = btrfs_delayed_node_to_head(node); if (insert_reserved) { - btrfs_pin_extent(root, node->bytenr, - node->num_bytes, 1); + ret = btrfs_pin_extent(root, node->bytenr, + node->num_bytes, 1); + if (ret) + btrfs_panic(root->fs_info, ret, + "Cannot pin extent in range " + "%llu(%llu)\n", + node->bytenr, node->num_bytes); + if (head->is_data) { ret = btrfs_del_csums(trans, root, node->bytenr, @@ -4347,7 +4353,8 @@ int btrfs_pin_extent(struct btrfs_root * struct btrfs_block_group_cache *cache; cache = btrfs_lookup_block_group(root->fs_info, bytenr); - BUG_ON(!cache); + if (cache == NULL) + return -ENOENT; pin_down_extent(root, cache, bytenr, num_bytes, reserved); @@ -4365,7 +4372,8 @@ int btrfs_pin_extent_for_log_replay(stru struct btrfs_block_group_cache *cache; cache = btrfs_lookup_block_group(root->fs_info, bytenr); - BUG_ON(!cache); + if (cache == NULL) + return -ENOENT; /* * pull in the free space cache (if any) so that our pin @@ -4871,8 +4879,11 @@ int btrfs_free_extent(struct btrfs_trans if (root_objectid == BTRFS_TREE_LOG_OBJECTID) { WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID); /* unlocks the pinned mutex */ - btrfs_pin_extent(root, bytenr, num_bytes, 1); - ret = 0; + ret = btrfs_pin_extent(root, bytenr, num_bytes, 1); + if (ret) + btrfs_panic(root->fs_info, ret, "Cannot pin " + "extent in range %llu(%llu)\n", + bytenr, num_bytes); } else if (owner < BTRFS_FIRST_FREE_OBJECTID) { ret = btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes, parent, root_objectid, (int)owner, --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -275,10 +275,14 @@ static int process_one_buffer(struct btr struct extent_buffer *eb, struct walk_control *wc, u64 gen) { - if (wc->pin) - btrfs_pin_extent_for_log_replay(wc->trans, + if (wc->pin) { + int ret = btrfs_pin_extent_for_log_replay(wc->trans, log->fs_info->extent_root, eb->start, eb->len); + if (ret) + btrfs_panic(log->fs_info, ret, "Cannot pin extent in " + "range %llu(%llu)\n", eb->start, eb->len); + } if (btrfs_buffer_uptodate(eb, gen)) { if (wc->write) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 32/99] btrfs: btrfs_drop_snapshot should return int
Commit cb1b69f4 (Btrfs: forced readonly when btrfs_drop_snapshot() fails) made btrfs_drop_snapshot return void because there were no callers checking the return value. That is the wrong order to handle error propogation since the caller will have no idea that an error has occured and continue on as if nothing went wrong. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 5 +++-- fs/btrfs/extent-tree.c | 6 +++--- fs/btrfs/relocation.c | 3 ++- fs/btrfs/transaction.c | 7 +++++-- 4 files changed, 13 insertions(+), 8 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2367,8 +2367,9 @@ static inline int btrfs_insert_empty_ite int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); -void btrfs_drop_snapshot(struct btrfs_root *root, - struct btrfs_block_rsv *block_rsv, int update_ref); +int __must_check btrfs_drop_snapshot(struct btrfs_root *root, + struct btrfs_block_rsv *block_rsv, + int update_ref); int btrfs_drop_subtree(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *node, --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6347,8 +6347,8 @@ static noinline int walk_up_tree(struct * also make sure backrefs for the shared block and all lower level * blocks are properly updated. */ -void btrfs_drop_snapshot(struct btrfs_root *root, - struct btrfs_block_rsv *block_rsv, int update_ref) +int btrfs_drop_snapshot(struct btrfs_root *root, + struct btrfs_block_rsv *block_rsv, int update_ref) { struct btrfs_path *path; struct btrfs_trans_handle *trans; @@ -6513,7 +6513,7 @@ out_free: out: if (err) btrfs_std_error(root->fs_info, err); - return; + return err; } /* --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2269,7 +2269,8 @@ again: } else { list_del_init(&reloc_root->root_list); } - btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0); + ret = btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0); + BUG_ON(ret < 0); } if (found) { --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1375,6 +1375,8 @@ int btrfs_clean_old_snapshots(struct btr spin_unlock(&fs_info->trans_lock); while (!list_empty(&list)) { + int ret; + root = list_entry(list.next, struct btrfs_root, root_list); list_del(&root->root_list); @@ -1382,9 +1384,10 @@ int btrfs_clean_old_snapshots(struct btr if (btrfs_header_backref_rev(root->node) < BTRFS_MIXED_BACKREF_REV) - btrfs_drop_snapshot(root, NULL, 0); + ret = btrfs_drop_snapshot(root, NULL, 0); else - btrfs_drop_snapshot(root, NULL, 1); + ret = btrfs_drop_snapshot(root, NULL, 1); + BUG_ON(ret < 0); } return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 33/99] btrfs: btrfs_start_transaction non-looped error push-up
This patch handles btrfs_start_transaction failures that don''t occur in a loop and are obvious to simply push up. In all cases except the mark_garbage_root case, the error is already handled by BUG_ON in the caller. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 6 +++++- fs/btrfs/relocation.c | 6 ++++-- fs/btrfs/tree-log.c | 5 ++++- fs/btrfs/volumes.c | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6374,7 +6374,11 @@ int btrfs_drop_snapshot(struct btrfs_roo } trans = btrfs_start_transaction(tree_root, 0); - BUG_ON(IS_ERR(trans)); + if (IS_ERR(trans)) { + kfree(wc); + btrfs_free_path(path); + return PTR_ERR(trans); + } if (block_rsv) trans->block_rsv = block_rsv; --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4118,7 +4118,8 @@ static noinline_for_stack int mark_garba int ret; trans = btrfs_start_transaction(root->fs_info->tree_root, 0); - BUG_ON(IS_ERR(trans)); + if (IS_ERR(trans)) + return PTR_ERR(trans); memset(&root->root_item.drop_progress, 0, sizeof(root->root_item.drop_progress)); @@ -4198,7 +4199,8 @@ int btrfs_recover_relocation(struct btrf err = ret; goto out; } - mark_garbage_root(reloc_root); + ret = mark_garbage_root(reloc_root); + BUG_ON(ret); } } --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3171,7 +3171,10 @@ int btrfs_recover_log_trees(struct btrfs fs_info->log_root_recovering = 1; trans = btrfs_start_transaction(fs_info->tree_root, 0); - BUG_ON(IS_ERR(trans)); + if (IS_ERR(trans)) { + btrfs_free_path(path); + return PTR_ERR(trans); + } wc.trans = trans; wc.pin = 1; --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1932,7 +1932,8 @@ static int btrfs_relocate_chunk(struct b return ret; trans = btrfs_start_transaction(root, 0); - BUG_ON(IS_ERR(trans)); + if (IS_ERR(trans)) + return PTR_ERR(trans); lock_chunks(root); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
find_and_setup_root BUGs when it encounters an error from btrfs_find_last_root, which can occur if a path can''t be allocated. This patch pushes it up to its callers where it is already handled. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1117,10 +1117,10 @@ static int __setup_root(u32 nodesize, u3 return 0; } -static int find_and_setup_root(struct btrfs_root *tree_root, - struct btrfs_fs_info *fs_info, - u64 objectid, - struct btrfs_root *root) +static int __must_check find_and_setup_root(struct btrfs_root *tree_root, + struct btrfs_fs_info *fs_info, + u64 objectid, + struct btrfs_root *root) { int ret; u32 blocksize; @@ -1133,7 +1133,8 @@ static int find_and_setup_root(struct bt &root->root_item, &root->root_key); if (ret > 0) return -ENOENT; - BUG_ON(ret); + else if (ret < 0) + return ret; generation = btrfs_root_generation(&root->root_item); blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
btrfs_update_root BUG''s when it can''t alloc a path, yet it can recover from a search error. This patch returns -ENOMEM instead. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 7 ++++--- fs/btrfs/root-tree.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2400,9 +2400,10 @@ int btrfs_del_root(struct btrfs_trans_ha int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key, struct btrfs_root_item *item); -int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root - *root, struct btrfs_key *key, struct btrfs_root_item - *item); +int __must_check btrfs_update_root(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_key *key, + struct btrfs_root_item *item); int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct btrfs_root_item *item, struct btrfs_key *key); int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -93,7 +93,9 @@ int btrfs_update_root(struct btrfs_trans unsigned long ptr; path = btrfs_alloc_path(); - BUG_ON(!path); + if (!path) + return -ENOMEM; + ret = btrfs_search_slot(trans, root, key, path, 0, 1); if (ret < 0) goto out; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 36/99] btrfs: set_range_writeback should return void
set_range_writeback has no error conditions and should return void. Its callers already ignore the error code anyway. There are internal error conditions but they are fatal and will cause a panic. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1253,7 +1253,7 @@ int unlock_extent(struct extent_io_tree /* * helper function to set both pages and extents in the tree writeback */ -static int set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end) +static void set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end) { unsigned long index = start >> PAGE_CACHE_SHIFT; unsigned long end_index = end >> PAGE_CACHE_SHIFT; @@ -1261,12 +1261,14 @@ static int set_range_writeback(struct ex while (index <= end_index) { page = find_get_page(tree->mapping, index); - BUG_ON(!page); + if (!page) + btrfs_panic(tree_fs_info(tree), -ENOENT, + "Page not found in extent io tree at " + "offset %llu", index << PAGE_CACHE_SHIFT); set_page_writeback(page); page_cache_release(page); index++; } - return 0; } /* find the first state struct with ''bits'' set after ''start'', and -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
wait_on_state has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -621,8 +621,8 @@ search_again: cached_state, GFP_ATOMIC); } -static int wait_on_state(struct extent_io_tree *tree, - struct extent_state *state) +static void wait_on_state(struct extent_io_tree *tree, + struct extent_state *state) __releases(tree->lock) __acquires(tree->lock) { @@ -632,7 +632,6 @@ static int wait_on_state(struct extent_i schedule(); spin_lock(&tree->lock); finish_wait(&state->wq, &wait); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 38/99] btrfs: wait_extent_bit should return void
wait_extent_bit has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -639,7 +639,7 @@ static void wait_on_state(struct extent_ * The range [start, end] is inclusive. * The tree lock is taken by this function */ -int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits) +void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits) { struct extent_state *state; struct rb_node *node; @@ -676,7 +676,6 @@ again: } out: spin_unlock(&tree->lock); - return 0; } static void set_state_bits(struct extent_io_tree *tree, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -277,7 +277,7 @@ void memmove_extent_buffer(struct extent unsigned long src_offset, unsigned long len); void memset_extent_buffer(struct extent_buffer *eb, char c, unsigned long start, unsigned long len); -int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); +void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); int clear_extent_buffer_dirty(struct extent_io_tree *tree, struct extent_buffer *eb); int set_extent_buffer_dirty(struct extent_io_tree *tree, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 39/99] btrfs: __unlock_for_delalloc should return void
__unlock_for_delalloc has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1384,9 +1384,9 @@ out: return found; } -static noinline int __unlock_for_delalloc(struct inode *inode, - struct page *locked_page, - u64 start, u64 end) +static noinline void __unlock_for_delalloc(struct inode *inode, + struct page *locked_page, + u64 start, u64 end) { int ret; struct page *pages[16]; @@ -1396,7 +1396,7 @@ static noinline int __unlock_for_delallo int i; if (index == locked_page->index && end_index == index) - return 0; + return; while (nr_pages > 0) { ret = find_get_pages_contig(inode->i_mapping, index, @@ -1411,7 +1411,6 @@ static noinline int __unlock_for_delallo index += ret; cond_resched(); } - return 0; } static noinline int lock_delalloc_pages(struct inode *inode, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 40/99] btrfs: check_page_uptodate should return void
check_page_uptodate has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1805,14 +1805,12 @@ int test_range_bit(struct extent_io_tree * helper function to set a given page up to date if all the * extents in the tree for that page are up to date */ -static int check_page_uptodate(struct extent_io_tree *tree, - struct page *page) +static void check_page_uptodate(struct extent_io_tree *tree, struct page *page) { u64 start = (u64)page->index << PAGE_CACHE_SHIFT; u64 end = start + PAGE_CACHE_SIZE - 1; if (test_range_bit(tree, start, end, EXTENT_UPTODATE, 1, NULL)) SetPageUptodate(page); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 41/99] btrfs: check_page_locked should return void
check_page_locked has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1817,14 +1817,12 @@ static void check_page_uptodate(struct e * helper function to unlock a page if all the extents in the tree * for that page are unlocked */ -static int check_page_locked(struct extent_io_tree *tree, - struct page *page) +static void check_page_locked(struct extent_io_tree *tree, struct page *page) { u64 start = (u64)page->index << PAGE_CACHE_SHIFT; u64 end = start + PAGE_CACHE_SIZE - 1; if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL)) unlock_page(page); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 42/99] btrfs: check_page_writeback should return void
check_page_writeback has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1829,11 +1829,10 @@ static void check_page_locked(struct ext * helper function to end page writeback if all the extents * in the tree for that page are done with writeback */ -static int check_page_writeback(struct extent_io_tree *tree, - struct page *page) +static void check_page_writeback(struct extent_io_tree *tree, + struct page *page) { end_page_writeback(page); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 43/99] btrfs: clear_extent_buffer_dirty should return void
clear_extent_buffer_dirty has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3436,7 +3436,7 @@ void free_extent_buffer(struct extent_bu WARN_ON(1); } -int clear_extent_buffer_dirty(struct extent_io_tree *tree, +void clear_extent_buffer_dirty(struct extent_io_tree *tree, struct extent_buffer *eb) { unsigned long i; @@ -3467,7 +3467,6 @@ int clear_extent_buffer_dirty(struct ext ClearPageError(page); unlock_page(page); } - return 0; } int set_extent_buffer_dirty(struct extent_io_tree *tree, --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -278,7 +278,7 @@ void memmove_extent_buffer(struct extent void memset_extent_buffer(struct extent_buffer *eb, char c, unsigned long start, unsigned long len); void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); -int clear_extent_buffer_dirty(struct extent_io_tree *tree, +void clear_extent_buffer_dirty(struct extent_io_tree *tree, struct extent_buffer *eb); int set_extent_buffer_dirty(struct extent_io_tree *tree, struct extent_buffer *eb); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 44/99] btrfs: btrfs_cleanup_fs_uuids should return void
btrfs_cleanup_fs_uuids has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/volumes.c | 3 +-- fs/btrfs/volumes.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -65,7 +65,7 @@ static void free_fs_devices(struct btrfs kfree(fs_devices); } -int btrfs_cleanup_fs_uuids(void) +void btrfs_cleanup_fs_uuids(void) { struct btrfs_fs_devices *fs_devices; @@ -75,7 +75,6 @@ int btrfs_cleanup_fs_uuids(void) list_del(&fs_devices->list); free_fs_devices(fs_devices); } - return 0; } static noinline struct btrfs_device *__find_device(struct list_head *head, --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -202,7 +202,7 @@ int btrfs_add_device(struct btrfs_trans_ struct btrfs_root *root, struct btrfs_device *device); int btrfs_rm_device(struct btrfs_root *root, char *device_path); -int btrfs_cleanup_fs_uuids(void); +void btrfs_cleanup_fs_uuids(void); int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len); int btrfs_grow_device(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 new_size); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 45/99] btrfs: run_scheduled_bios should return void
run_scheduled_bios has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/volumes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -127,7 +127,7 @@ static void requeue_list(struct btrfs_pe * the list if the block device is congested. This way, multiple devices * can make progress from a single worker thread. */ -static noinline int run_scheduled_bios(struct btrfs_device *device) +static noinline void run_scheduled_bios(struct btrfs_device *device) { struct bio *pending; struct backing_dev_info *bdi; @@ -307,7 +307,6 @@ loop_lock: done: blk_finish_plug(&plug); - return 0; } static void pending_bios_fn(struct btrfs_work *work) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 46/99] btrfs: btrfs_close_extra_devices should return void
btrfs_close_extra_devices has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/volumes.c | 3 +-- fs/btrfs/volumes.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -437,7 +437,7 @@ error: return ERR_PTR(-ENOMEM); } -int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices) +void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices) { struct btrfs_device *device, *next; @@ -470,7 +470,6 @@ again: } mutex_unlock(&uuid_mutex); - return 0; } static void __free_device(struct work_struct *work) --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -197,7 +197,7 @@ int btrfs_open_devices(struct btrfs_fs_d int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, struct btrfs_fs_devices **fs_devices_ret); int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); -int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices); +void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices); int btrfs_add_device(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_device *device); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
schedule_bio has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/volumes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3268,7 +3268,7 @@ struct async_sched { * This will add one bio to the pending list for a device and make sure * the work struct is scheduled. */ -static noinline int schedule_bio(struct btrfs_root *root, +static noinline void schedule_bio(struct btrfs_root *root, struct btrfs_device *device, int rw, struct bio *bio) { @@ -3280,7 +3280,6 @@ static noinline int schedule_bio(struct bio_get(bio); submit_bio(rw, bio); bio_put(bio); - return 0; } /* @@ -3314,7 +3313,6 @@ static noinline int schedule_bio(struct if (should_queue) btrfs_queue_worker(&root->fs_info->submit_workers, &device->work); - return 0; } int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 48/99] btrfs: fill_device_from_item should return void
fill_device_from_item has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/volumes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3513,7 +3513,7 @@ static int read_one_chunk(struct btrfs_r return 0; } -static int fill_device_from_item(struct extent_buffer *leaf, +static void fill_device_from_item(struct extent_buffer *leaf, struct btrfs_dev_item *dev_item, struct btrfs_device *device) { @@ -3530,8 +3530,6 @@ static int fill_device_from_item(struct ptr = (unsigned long)btrfs_device_uuid(dev_item); read_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE); - - return 0; } static int open_seed_devices(struct btrfs_root *root, u8 *fsid) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 49/99] btrfs: btrfs_queue_worker should return void
btrfs_queue_worker has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/async-thread.c | 14 ++++---------- fs/btrfs/async-thread.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -95,7 +95,6 @@ static void start_new_worker_func(struct static int start_new_worker(struct btrfs_workers *queue) { struct worker_start *start; - int ret; start = kzalloc(sizeof(*start), GFP_NOFS); if (!start) @@ -103,10 +102,8 @@ static int start_new_worker(struct btrfs start->work.func = start_new_worker_func; start->queue = queue; - ret = btrfs_queue_worker(queue->atomic_worker_start, &start->work); - if (ret) - kfree(start); - return ret; + btrfs_queue_worker(queue->atomic_worker_start, &start->work); + return 0; } /* @@ -665,7 +662,7 @@ void btrfs_set_work_high_prio(struct btr /* * places a struct btrfs_work into the pending queue of one of the kthreads */ -int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work) +void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work) { struct btrfs_worker_thread *worker; unsigned long flags; @@ -673,7 +670,7 @@ int btrfs_queue_worker(struct btrfs_work /* don''t requeue something already on a list */ if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags)) - goto out; + return; worker = find_worker(workers); if (workers->ordered) { @@ -712,7 +709,4 @@ int btrfs_queue_worker(struct btrfs_work if (wake) wake_up_process(worker->task); spin_unlock_irqrestore(&worker->lock, flags); - -out: - return 0; } --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h @@ -109,7 +109,7 @@ struct btrfs_workers { char *name; }; -int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); +void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); int btrfs_start_workers(struct btrfs_workers *workers, int num_workers); int btrfs_stop_workers(struct btrfs_workers *workers); void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 50/99] btrfs: run_ordered_completions should return void
run_ordered_completions has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/async-thread.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -174,11 +174,11 @@ out: 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); @@ -216,7 +216,6 @@ static noinline int run_ordered_completi } spin_unlock(&workers->order_lock); - return 0; } static void put_worker(struct btrfs_worker_thread *worker) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 51/99] btrfs: btrfs_stop_workers should return void
btrfs_stop_workers has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/async-thread.c | 3 +-- fs/btrfs/async-thread.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -401,7 +401,7 @@ again: /* * 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; @@ -429,7 +429,6 @@ int btrfs_stop_workers(struct btrfs_work put_worker(worker); } spin_unlock_irq(&workers->lock); - return 0; } /* --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h @@ -111,7 +111,7 @@ struct btrfs_workers { void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); int btrfs_start_workers(struct btrfs_workers *workers, int num_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); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 52/99] btrfs: btrfs_requeue_work should return void
btrfs_requeue_work has no error conditions and should return void. Its callers ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/async-thread.c | 7 ++----- fs/btrfs/async-thread.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -613,14 +613,14 @@ found: * 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)) @@ -647,9 +647,6 @@ int btrfs_requeue_work(struct btrfs_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) --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h @@ -114,6 +114,6 @@ int btrfs_start_workers(struct btrfs_wor 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 53/99] btrfs: btrfs_end_log_trans should return void
btrfs_end_log_trans has no error conditions and should return void. Its callers ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/tree-log.c | 3 +-- fs/btrfs/tree-log.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 483e280..2c45b3d 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) * indicate we''re done making changes to the log tree * and wake up anyone waiting to do a sync */ -int btrfs_end_log_trans(struct btrfs_root *root) +void btrfs_end_log_trans(struct btrfs_root *root) { if (atomic_dec_and_test(&root->log_writers)) { smp_mb(); if (waitqueue_active(&root->log_writer_wait)) wake_up(&root->log_writer_wait); } - return 0; } diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h index 2270ac5..862ac81 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, struct btrfs_root *root, const char *name, int name_len, struct inode *inode, u64 dirid); -int btrfs_end_log_trans(struct btrfs_root *root); +void btrfs_end_log_trans(struct btrfs_root *root); int btrfs_pin_log_trans(struct btrfs_root *root); int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct inode *inode, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 54/99] btrfs: wait_for_writer should return void
wait_for_writer has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/tree-log.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 2c45b3d..aac743b 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1964,8 +1964,8 @@ static int wait_log_commit(struct btrfs_trans_handle *trans, return 0; } -static int wait_for_writer(struct btrfs_trans_handle *trans, - struct btrfs_root *root) +static void wait_for_writer(struct btrfs_trans_handle *trans, + struct btrfs_root *root) { DEFINE_WAIT(wait); while (atomic_read(&root->log_writers)) { @@ -1978,7 +1978,6 @@ static int wait_for_writer(struct btrfs_trans_handle *trans, mutex_lock(&root->log_mutex); finish_wait(&root->log_writer_wait, &wait); } - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 55/99] btrfs: btrfs_init_compress should return void
btrfs_init_compress doesn''t have any failure conditions, so return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/compression.c | 3 +-- fs/btrfs/compression.h | 2 +- fs/btrfs/super.c | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index cca501b..0c0e842 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -734,7 +734,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; @@ -744,7 +744,6 @@ int __init btrfs_init_compress(void) atomic_set(&comp_alloc_workspace[i], 0); init_waitqueue_head(&comp_workspace_wait[i]); } - return 0; } /* diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index a12059f..9afb0a6 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -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, diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0152207..26e1dcf 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1347,9 +1347,7 @@ static int __init init_btrfs_fs(void) if (err) return err; - err = btrfs_init_compress(); - if (err) - goto free_sysfs; + btrfs_init_compress(); err = btrfs_init_cachep(); if (err) @@ -1390,7 +1388,6 @@ free_cachep: btrfs_destroy_cachep(); free_compress: btrfs_exit_compress(); -free_sysfs: btrfs_exit_sysfs(); return err; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 56/99] btrfs: btrfs_invalidate_inodes should return void
btrfs_invalidate_inodes has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 7d90a9c..e8f0689 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2584,7 +2584,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root); void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, struct btrfs_root *root); int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size); -int btrfs_invalidate_inodes(struct btrfs_root *root); +void btrfs_invalidate_inodes(struct btrfs_root *root); void btrfs_add_delayed_iput(struct inode *inode); void btrfs_run_delayed_iputs(struct btrfs_root *root); int btrfs_prealloc_file_range(struct inode *inode, int mode, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 321c9cf..59c681b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3861,7 +3861,7 @@ static void inode_tree_del(struct inode *inode) } } -int btrfs_invalidate_inodes(struct btrfs_root *root) +void btrfs_invalidate_inodes(struct btrfs_root *root) { struct rb_node *node; struct rb_node *prev; @@ -3921,7 +3921,6 @@ again: node = rb_next(node); } spin_unlock(&root->inode_lock); - return 0; } static int btrfs_init_locked_inode(struct inode *inode, void *p) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
__setup_root has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1058,10 +1058,10 @@ int clean_tree_block(struct btrfs_trans_ return 0; } -static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, - u32 stripesize, struct btrfs_root *root, - struct btrfs_fs_info *fs_info, - u64 objectid) +static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, + u32 stripesize, struct btrfs_root *root, + struct btrfs_fs_info *fs_info, + u64 objectid) { root->node = NULL; root->commit_root = NULL; @@ -1114,7 +1114,6 @@ static int __setup_root(u32 nodesize, u3 root->defrag_running = 0; root->root_key.objectid = objectid; root->anon_dev = 0; - return 0; } static int __must_check find_and_setup_root(struct btrfs_root *tree_root, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 58/99] btrfs: btrfs_destroy_delalloc_inodes should return void
btrfs_destroy_delalloc_inodes has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -54,7 +54,7 @@ static int btrfs_destroy_ordered_extents static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, struct btrfs_root *root); static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); -static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root); +static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root); static int btrfs_destroy_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, int mark); @@ -2939,7 +2939,7 @@ static int btrfs_destroy_pending_snapsho return 0; } -static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root) +static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) { struct btrfs_inode *btrfs_inode; struct list_head splice; @@ -2959,8 +2959,6 @@ static int btrfs_destroy_delalloc_inodes } spin_unlock(&root->fs_info->delalloc_lock); - - return 0; } static int btrfs_destroy_marked_extents(struct btrfs_root *root, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 59/99] btrfs: btrfs_prepare_extent_commit should return void
btrfs_prepare_extent_commit has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/extent-tree.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2207,8 +2207,8 @@ int btrfs_free_extent(struct btrfs_trans int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, u64 start, u64 len); -int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, - struct btrfs_root *root); +void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, + struct btrfs_root *root); int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct btrfs_root *root); int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4385,7 +4385,7 @@ static int btrfs_update_reserved_bytes(s return ret; } -int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, +void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, struct btrfs_root *root) { struct btrfs_fs_info *fs_info = root->fs_info; @@ -4415,7 +4415,6 @@ int btrfs_prepare_extent_commit(struct b up_write(&fs_info->extent_commit_sem); update_global_block_rsv(fs_info); - return 0; } static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 60/99] btrfs: btrfs_set_block_group_rw should return void
btrfs_set_block_group_rw has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/extent-tree.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2263,8 +2263,8 @@ void btrfs_block_rsv_release(struct btrf u64 num_bytes); int btrfs_set_block_group_ro(struct btrfs_root *root, struct btrfs_block_group_cache *cache); -int btrfs_set_block_group_rw(struct btrfs_root *root, - struct btrfs_block_group_cache *cache); +void btrfs_set_block_group_rw(struct btrfs_root *root, + struct btrfs_block_group_cache *cache); void btrfs_put_block_group_cache(struct btrfs_fs_info *info); u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo); int btrfs_error_unpin_extent_range(struct btrfs_root *root, --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6769,7 +6769,7 @@ u64 btrfs_account_ro_block_groups_free_s return free_bytes; } -int btrfs_set_block_group_rw(struct btrfs_root *root, +void btrfs_set_block_group_rw(struct btrfs_root *root, struct btrfs_block_group_cache *cache) { struct btrfs_space_info *sinfo = cache->space_info; @@ -6785,7 +6785,6 @@ int btrfs_set_block_group_rw(struct btrf cache->ro = 0; spin_unlock(&cache->lock); spin_unlock(&sinfo->lock); - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 61/99] btrfs: setup_inline_extent_backref should return void
setup_inline_extent_backref has no error conditions and should return void. We set ret = 0 explicitly in insert_inline_extent_backref since it would have been set using the return value, which would have been 0. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1556,13 +1556,13 @@ out: * helper to add new inline back ref */ static noinline_for_stack -int setup_inline_extent_backref(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct btrfs_path *path, - struct btrfs_extent_inline_ref *iref, - u64 parent, u64 root_objectid, - u64 owner, u64 offset, int refs_to_add, - struct btrfs_delayed_extent_op *extent_op) +void setup_inline_extent_backref(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + struct btrfs_extent_inline_ref *iref, + u64 parent, u64 root_objectid, + u64 owner, u64 offset, int refs_to_add, + struct btrfs_delayed_extent_op *extent_op) { struct extent_buffer *leaf; struct btrfs_extent_item *ei; @@ -1616,7 +1616,6 @@ int setup_inline_extent_backref(struct b btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid); } btrfs_mark_buffer_dirty(leaf); - return 0; } static int lookup_extent_backref(struct btrfs_trans_handle *trans, @@ -1735,10 +1734,10 @@ int insert_inline_extent_backref(struct ret = update_inline_extent_backref(trans, root, path, iref, refs_to_add, extent_op); } else if (ret == -ENOENT) { - ret = setup_inline_extent_backref(trans, root, path, iref, - parent, root_objectid, - owner, offset, refs_to_add, - extent_op); + setup_inline_extent_backref(trans, root, path, iref, parent, + root_objectid, owner, offset, + refs_to_add, extent_op); + ret = 0; } return ret; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 62/99] btrfs: btrfs_run_defrag_inodes should return void
btrfs_run_defrag_inodes has no error conditions and should return void. Its callers already ignore the error codes anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 2 +- fs/btrfs/file.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2606,7 +2606,7 @@ int btrfs_defrag_file(struct inode *inod /* file.c */ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, struct inode *inode); -int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info); +void btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info); int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync); int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, int skip_pinned); --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -193,7 +193,7 @@ struct inode_defrag *btrfs_find_defrag_i * run through the list of inodes in the FS that need * defragging */ -int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info) +void btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info) { struct inode_defrag *defrag; struct btrfs_root *inode_root; @@ -296,7 +296,6 @@ next_free: * wait for the defragger to stop */ wake_up(&fs_info->transaction_wait); - return 0; } /* simple helper to fault in pages and copy. This should go away -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
btrfs_submit_bio_hook currently calls btrfs_bio_wq_end_io in either case of an if statement that determines one of the arguments. This patch moves the function call outside of the if statement and uses it to only determine the different argument. This allows us to catch an error in one place in a more visually obvious way. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/inode.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 59c681b..c0dc599 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1479,13 +1479,14 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, struct btrfs_root *root = BTRFS_I(inode)->root; int ret = 0; int skip_sum; + int metadata = 0; skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; if (btrfs_is_free_space_inode(root, inode)) - ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2); - else - ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); + metadata = 2; + + ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata); BUG_ON(ret); if (!(rw & REQ_WRITE)) { -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 64/99] btrfs: Factor out tree->ops->merge_bio_hook call
In submit_extent_page, there''s a visually noisy if statement that, in the midst of other conditions, does the tree dependency for tree->ops and tree->ops->merge_bio_hook before calling it, and then another condition afterwards. If an error is returned from merge_bio_hook, there''s no way to catch it. It''s considered a routine "1" return value instead of a failure. This patch factors out the dependency check into a new local merge_bio routine and BUG''s on an error. The if statement is less noisy as a side- effect. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent_io.c | 17 ++++++++++++++--- fs/btrfs/inode.c | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0575792..09095b8 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2058,6 +2058,19 @@ static int submit_one_bio(int rw, struct bio *bio, int mirror_num, return ret; } +static int merge_bio(struct extent_io_tree *tree, struct page *page, + unsigned long offset, size_t size, struct bio *bio, + unsigned long bio_flags) +{ + int ret = 0; + if (tree->ops && tree->ops->merge_bio_hook) + ret = tree->ops->merge_bio_hook(page, offset, size, bio, + bio_flags); + BUG_ON(ret < 0); + return ret; + +} + static int submit_extent_page(int rw, struct extent_io_tree *tree, struct page *page, sector_t sector, size_t size, unsigned long offset, @@ -2086,9 +2099,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, sector; if (prev_bio_flags != bio_flags || !contig || - (tree->ops && tree->ops->merge_bio_hook && - tree->ops->merge_bio_hook(page, offset, page_size, bio, - bio_flags)) || + merge_bio(tree, page, offset, page_size, bio, bio_flags) || bio_add_page(bio, page, page_size, offset) < page_size) { ret = submit_one_bio(rw, bio, mirror_num, prev_bio_flags); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c0dc599..a06cb64 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1425,10 +1425,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, map_length = length; ret = btrfs_map_block(map_tree, READ, logical, &map_length, NULL, 0); - + /* Will always return 0 or 1 with map_multi == NULL */ + BUG_ON(ret < 0); if (map_length < length + size) return 1; - return ret; + return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This pushes failures from the submit_bio_hook callbacks, btrfs_submit_bio_hook and btree_submit_bio_hook into the callers, including callers of submit_one_bio where it catches the failures with BUG_ON. It also pushes up through the ->readpage_io_failed_hook to end_bio_extent_writepage where the error is already caught with BUG_ON. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 6 +++--- fs/btrfs/extent_io.c | 33 +++++++++++++++++++++++---------- fs/btrfs/inode.c | 3 ++- 3 files changed, 28 insertions(+), 14 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -811,9 +811,9 @@ static int btree_submit_bio_hook(struct { int ret; - ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, - bio, 1); - BUG_ON(ret); + ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, bio, 1); + if (ret) + return ret; if (!(rw & REQ_WRITE)) { /* --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1888,6 +1888,7 @@ static void end_bio_extent_writepage(str uptodate = (err == 0); continue; } + BUG_ON(ret < 0); } if (!uptodate) { @@ -1980,6 +1981,7 @@ static void end_bio_extent_readpage(stru uncache_state(&cached); continue; } + BUG_ON(ret < 0); } if (uptodate) { @@ -2034,8 +2036,8 @@ btrfs_bio_alloc(struct block_device *bde return bio; } -static int submit_one_bio(int rw, struct bio *bio, int mirror_num, - unsigned long bio_flags) +static int __must_check submit_one_bio(int rw, struct bio *bio, + int mirror_num, unsigned long bio_flags) { int ret = 0; struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; @@ -2105,6 +2107,7 @@ static int submit_extent_page(int rw, st bio_add_page(bio, page, page_size, offset) < page_size) { ret = submit_one_bio(rw, bio, mirror_num, prev_bio_flags); + BUG_ON(ret < 0); bio = NULL; } else { return 0; @@ -2125,8 +2128,10 @@ static int submit_extent_page(int rw, st if (bio_ret) *bio_ret = bio; - else + else { ret = submit_one_bio(rw, bio, mirror_num, bio_flags); + BUG_ON(ret < 0); + } return ret; } @@ -2349,8 +2354,10 @@ int extent_read_full_page(struct extent_ ret = __extent_read_full_page(tree, page, get_extent, &bio, mirror_num, &bio_flags); - if (bio) + if (bio) { ret = submit_one_bio(READ, bio, mirror_num, bio_flags); + BUG_ON(ret < 0); + } return ret; } @@ -2752,10 +2759,12 @@ retry: static void flush_epd_write_bio(struct extent_page_data *epd) { if (epd->bio) { + int ret; if (epd->sync_io) - submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); + ret = submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); else - submit_one_bio(WRITE, epd->bio, 0, 0); + ret = submit_one_bio(WRITE, epd->bio, 0, 0); + BUG_ON(ret < 0); epd->bio = NULL; } } @@ -2871,8 +2880,10 @@ int extent_readpages(struct extent_io_tr page_cache_release(page); } BUG_ON(!list_empty(pages)); - if (bio) - submit_one_bio(READ, bio, 0, bio_flags); + if (bio) { + int ret = submit_one_bio(READ, bio, 0, bio_flags); + BUG_ON(ret < 0); + } return 0; } @@ -3704,8 +3715,10 @@ int read_extent_buffer_pages(struct exte } } - if (bio) - submit_one_bio(READ, bio, mirror_num, bio_flags); + if (bio) { + err = submit_one_bio(READ, bio, mirror_num, bio_flags); + BUG_ON(err < 0); + } if (ret || wait != WAIT_COMPLETE) return ret; --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1488,7 +1488,8 @@ static int btrfs_submit_bio_hook(struct metadata = 2; ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata); - BUG_ON(ret); + if (ret) + return ret; if (!(rw & REQ_WRITE)) { if (bio_flags & EXTENT_BIO_COMPRESSED) { -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This patch pushes kmalloc errors up to the caller and BUGs in the caller. The BUG_ON for duplicate reloc tree root insertion is replaced with a panic explaining the issue. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/relocation.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1219,14 +1219,15 @@ fail: /* * helper to add ''address of tree root -> reloc tree'' mapping */ -static int __add_reloc_root(struct btrfs_root *root) +static int __must_check __add_reloc_root(struct btrfs_root *root) { struct rb_node *rb_node; struct mapping_node *node; struct reloc_control *rc = root->fs_info->reloc_ctl; node = kmalloc(sizeof(*node), GFP_NOFS); - BUG_ON(!node); + if (!node) + return -ENOMEM; node->bytenr = root->node->start; node->data = root; @@ -1235,7 +1236,12 @@ static int __add_reloc_root(struct btrfs rb_node = tree_insert(&rc->reloc_root_tree.rb_root, node->bytenr, &node->rb_node); spin_unlock(&rc->reloc_root_tree.lock); - BUG_ON(rb_node); + if (rb_node) { + kfree(node); + btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found " + "for start=%llu while inserting into relocation " + "tree\n"); + } list_add_tail(&root->root_list, &rc->reloc_roots); return 0; @@ -1351,6 +1357,7 @@ int btrfs_init_reloc_root(struct btrfs_t struct btrfs_root *reloc_root; struct reloc_control *rc = root->fs_info->reloc_ctl; int clear_rsv = 0; + int ret; if (root->reloc_root) { reloc_root = root->reloc_root; @@ -1370,7 +1377,8 @@ int btrfs_init_reloc_root(struct btrfs_t if (clear_rsv) trans->block_rsv = NULL; - __add_reloc_root(reloc_root); + ret = __add_reloc_root(reloc_root); + BUG_ON(ret < 0); root->reloc_root = reloc_root; return 0; } @@ -4248,7 +4256,8 @@ int btrfs_recover_relocation(struct btrf reloc_root->root_key.offset); BUG_ON(IS_ERR(fs_root)); - __add_reloc_root(reloc_root); + err = __add_reloc_root(reloc_root); + BUG_ON(err < 0); fs_root->reloc_root = reloc_root; } @@ -4450,7 +4459,8 @@ void btrfs_reloc_post_snapshot(struct bt reloc_root = create_reloc_root(trans, root->reloc_root, new_root->root_key.objectid); - __add_reloc_root(reloc_root); + ret = __add_reloc_root(reloc_root); + BUG_ON(ret < 0); new_root->reloc_root = reloc_root; if (rc->create_reloc_tree) { -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
fixup_low_keys has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 39 +++++++++++---------------------------- 1 files changed, 11 insertions(+), 28 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 011cab3..dedd3a1 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1864,15 +1864,12 @@ done: * 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, - struct btrfs_root *root, struct btrfs_path *path, - struct btrfs_disk_key *key, int level) +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++) { @@ -1885,7 +1882,6 @@ static int fixup_low_keys(struct btrfs_trans_handle *trans, if (tslot != 0) break; } - return ret; } /* @@ -2626,9 +2622,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) { @@ -2999,12 +2993,9 @@ again: 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; @@ -3527,7 +3518,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) { @@ -3555,7 +3546,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; @@ -3616,10 +3606,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); @@ -3706,7 +3695,6 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *parent = path->nodes[level]; u32 nritems; int ret = 0; - int wret; nritems = btrfs_header_nritems(parent); if (slot != nritems - 1) { @@ -3726,9 +3714,7 @@ 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; @@ -3831,10 +3817,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 */ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 68/99] btrfs: setup_items_for_insert should return void
setup_items_for_insert now has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 26 ++++++++++---------------- fs/btrfs/ctree.h | 8 ++++---- fs/btrfs/delayed-inode.c | 6 ++---- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index dedd3a1..fdaddcc 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2516,7 +2516,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; @@ -3212,11 +3211,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, - item_size, item_size + - sizeof(struct btrfs_item), 1); - BUG_ON(ret); - + setup_items_for_insert(trans, root, path, new_key, &item_size, + item_size, item_size + + sizeof(struct btrfs_item), 1); leaf = path->nodes[0]; memcpy_extent_buffer(leaf, btrfs_item_ptr_offset(leaf, path->slots[0]), @@ -3536,10 +3533,10 @@ out: * 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, - struct btrfs_root *root, struct btrfs_path *path, - struct btrfs_key *cpu_key, u32 *data_size, - u32 total_data, u32 total_size, int nr) +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) { struct btrfs_item *item; int i; @@ -3617,7 +3614,6 @@ int setup_items_for_insert(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } - return ret; } /* @@ -3644,16 +3640,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; } /* diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c866167..ea47c73 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2344,10 +2344,10 @@ static inline int btrfs_del_item(struct btrfs_trans_handle *trans, return btrfs_del_items(trans, root, path, path->slots[0], 1); } -int 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); +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); int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key, void *data, u32 data_size); int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index b52c672..6211997 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -738,10 +738,8 @@ static int btrfs_batch_insert_items(struct btrfs_trans_handle *trans, btrfs_clear_path_blocking(path, NULL, 0); /* insert the keys of the items */ - ret = setup_items_for_insert(trans, root, path, keys, data_size, - total_data_size, total_size, nitems); - if (ret) - goto error; + setup_items_for_insert(trans, root, path, keys, data_size, + total_data_size, total_size, nitems); /* insert the dir index items */ slot = path->slots[0]; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
With fixup_low_keys now returning void, there are no error conditions for del_ptr to report so it should return void. We set ret = 0 explicitly in btrfs_del_items but I''m not convinced that the error handling code already there is correct. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 39 +++++++++++++-------------------------- 1 files changed, 13 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index fdaddcc..c605fb3 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, 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) @@ -994,10 +994,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); free_extent_buffer(right); @@ -1035,9 +1032,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); free_extent_buffer(mid); @@ -3683,12 +3678,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, - struct btrfs_path *path, int level, int slot) +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; nritems = btrfs_header_nritems(parent); if (slot != nritems - 1) { @@ -3711,7 +3705,6 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, fixup_low_keys(trans, root, path, &disk_key, level + 1); } btrfs_mark_buffer_dirty(parent); - return ret; } /* @@ -3724,17 +3717,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, - struct btrfs_root *root, - struct btrfs_path *path, - struct extent_buffer *leaf) +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 @@ -3745,7 +3734,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); - return 0; } /* * delete the item at the leaf level in path. If that empties @@ -3802,8 +3790,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); @@ -3839,9 +3826,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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
insert_ptr has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 46 +++++++++++++--------------------------------- 1 files changed, 13 insertions(+), 33 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index c605fb3..2604ec4 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2114,12 +2114,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; @@ -2129,8 +2128,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), @@ -2143,7 +2141,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; } /* @@ -2164,7 +2161,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]; @@ -2221,11 +2217,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; @@ -2722,8 +2715,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; @@ -2751,12 +2742,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, - path->slots[1] + 1, 1); - if (wret) - ret = wret; + insert_ptr(trans, root, path, &disk_key, right->start, + path->slots[1] + 1, 1); btrfs_mark_buffer_dirty(right); btrfs_mark_buffer_dirty(l); @@ -2775,7 +2763,7 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, BUG_ON(path->slots[0] < 0); - return ret; + return 0; } /* @@ -2964,12 +2952,8 @@ again: if (split == 0) { if (mid <= slot) { btrfs_set_header_nritems(right, 0); - wret = insert_ptr(trans, root, path, - &disk_key, right->start, - path->slots[1] + 1, 1); - if (wret) - ret = wret; - + insert_ptr(trans, root, path, &disk_key, right->start, + path->slots[1] + 1, 1); btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; @@ -2977,12 +2961,8 @@ again: path->slots[1] += 1; } else { btrfs_set_header_nritems(right, 0); - wret = insert_ptr(trans, root, path, - &disk_key, - right->start, - path->slots[1], 1); + 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; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 71/99] btrfs: add_delayed_ref_head should return void
add_delayed_ref_head has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/delayed-ref.c | 29 ++++++++++------------------- 1 files changed, 10 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 125cf76..caa9ade 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -390,10 +390,10 @@ update_existing_head_ref(struct btrfs_delayed_ref_node *existing, * this does all the dirty work in terms of maintaining the correct * overall modification count. */ -static noinline int add_delayed_ref_head(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_node *ref, - u64 bytenr, u64 num_bytes, - int action, int is_data) +static noinline void add_delayed_ref_head(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_node *ref, + u64 bytenr, u64 num_bytes, + int action, int is_data) { struct btrfs_delayed_ref_node *existing; struct btrfs_delayed_ref_head *head_ref = NULL; @@ -462,7 +462,6 @@ static noinline int add_delayed_ref_head(struct btrfs_trans_handle *trans, delayed_refs->num_entries++; trans->delayed_ref_updates++; } - return 0; } /* @@ -610,10 +609,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, * insert both the head node and the new ref without dropping * the spin lock */ - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, - action, 0); - BUG_ON(ret); - + add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, + action, 0); ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, parent, ref_root, level, action); BUG_ON(ret); @@ -655,10 +652,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, * insert both the head node and the new ref without dropping * the spin lock */ - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, - action, 1); - BUG_ON(ret); - + add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, + action, 1); ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, parent, ref_root, owner, offset, action); BUG_ON(ret); @@ -672,7 +667,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, { struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); if (!head_ref) @@ -683,11 +677,8 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, delayed_refs = &trans->transaction->delayed_refs; spin_lock(&delayed_refs->lock); - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, - num_bytes, BTRFS_UPDATE_DELAYED_HEAD, - extent_op->is_data); - BUG_ON(ret); - + add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, + BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data); spin_unlock(&delayed_refs->lock); return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 72/99] btrfs: add_delayed_tree_ref should return void
add_delayed_tree_ref has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/delayed-ref.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index caa9ade..3ae2401 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -467,10 +467,10 @@ static noinline void add_delayed_ref_head(struct btrfs_trans_handle *trans, /* * helper to insert a delayed tree ref into the rbtree. */ -static noinline int add_delayed_tree_ref(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_node *ref, - u64 bytenr, u64 num_bytes, u64 parent, - u64 ref_root, int level, int action) +static noinline void add_delayed_tree_ref(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_node *ref, + u64 bytenr, u64 num_bytes, u64 parent, + u64 ref_root, int level, int action) { struct btrfs_delayed_ref_node *existing; struct btrfs_delayed_tree_ref *full_ref; @@ -515,7 +515,6 @@ static noinline int add_delayed_tree_ref(struct btrfs_trans_handle *trans, delayed_refs->num_entries++; trans->delayed_ref_updates++; } - return 0; } /* @@ -587,7 +586,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_tree_ref *ref; struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; BUG_ON(extent_op && extent_op->is_data); ref = kmalloc(sizeof(*ref), GFP_NOFS); @@ -611,9 +609,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, */ add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, action, 0); - ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, - parent, ref_root, level, action); - BUG_ON(ret); + add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, parent, + ref_root, level, action); spin_unlock(&delayed_refs->lock); return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 73/99] btrfs: add_delayed_data_ref should return void
add_delayed_data_ref has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/delayed-ref.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 3ae2401..b004960 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -520,11 +520,11 @@ static noinline void add_delayed_tree_ref(struct btrfs_trans_handle *trans, /* * helper to insert a delayed data ref into the rbtree. */ -static noinline int add_delayed_data_ref(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_node *ref, - u64 bytenr, u64 num_bytes, u64 parent, - u64 ref_root, u64 owner, u64 offset, - int action) +static noinline void add_delayed_data_ref(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_node *ref, + u64 bytenr, u64 num_bytes, u64 parent, + u64 ref_root, u64 owner, u64 offset, + int action) { struct btrfs_delayed_ref_node *existing; struct btrfs_delayed_data_ref *full_ref; @@ -570,7 +570,6 @@ static noinline int add_delayed_data_ref(struct btrfs_trans_handle *trans, delayed_refs->num_entries++; trans->delayed_ref_updates++; } - return 0; } /* @@ -627,7 +626,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_data_ref *ref; struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; BUG_ON(extent_op && !extent_op->is_data); ref = kmalloc(sizeof(*ref), GFP_NOFS); @@ -651,9 +649,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, */ add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, action, 1); - ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, - parent, ref_root, owner, offset, action); - BUG_ON(ret); + add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, parent, + ref_root, owner, offset, action); spin_unlock(&delayed_refs->lock); return 0; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 74/99] btrfs: Fix kfree of member instead of structure
Correctness fix: The kfree calls in the add_delayed_* functions free the node that''s passed into it, but the node is a member of another structure. It works because it''s always the first member of the containing structure, but it should really be using the containing structure itself. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/delayed-ref.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index b004960..e388ca3 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -455,7 +455,7 @@ static noinline void add_delayed_ref_head(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(ref); + kfree(head_ref); } else { delayed_refs->num_heads++; delayed_refs->num_heads_ready++; @@ -510,7 +510,7 @@ static noinline void add_delayed_tree_ref(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(ref); + kfree(full_ref); } else { delayed_refs->num_entries++; trans->delayed_ref_updates++; @@ -565,7 +565,7 @@ static noinline void add_delayed_data_ref(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(ref); + kfree(full_ref); } else { delayed_refs->num_entries++; trans->delayed_ref_updates++; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This patch converts the delayed ref code to use slab cache-backed mempools for allocating its nodes. The allocations happen deep in the call path where error recovery is impossible. By using mempools, we ensure that the allocations can''t fail. Each mempool keeps a page of structures available for each type. This also has an advantage of eliminating the error path from a big chunk of code, simplifying the error handling. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/delayed-ref.c | 119 ++++++++++++++++++++++++++++++++++++++---------- fs/btrfs/delayed-ref.h | 6 ++- fs/btrfs/super.c | 9 +++- 3 files changed, 107 insertions(+), 27 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index e388ca3..a70c40d 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -18,11 +18,20 @@ #include <linux/sched.h> #include <linux/slab.h> +#include <linux/mempool.h> #include <linux/sort.h> #include "ctree.h" #include "delayed-ref.h" #include "transaction.h" +static struct kmem_cache *ref_head_cache; +static struct kmem_cache *tree_ref_cache; +static struct kmem_cache *data_ref_cache; + +static mempool_t *ref_head_pool; +static mempool_t *tree_ref_pool; +static mempool_t *data_ref_pool; + /* * delayed back reference update tracking. For subvolume trees * we queue up extent allocations and backref maintenance for @@ -455,7 +464,7 @@ static noinline void add_delayed_ref_head(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(head_ref); + mempool_free(head_ref, ref_head_pool); } else { delayed_refs->num_heads++; delayed_refs->num_heads_ready++; @@ -510,7 +519,7 @@ static noinline void add_delayed_tree_ref(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(full_ref); + mempool_free(full_ref, tree_ref_pool); } else { delayed_refs->num_entries++; trans->delayed_ref_updates++; @@ -565,7 +574,7 @@ static noinline void add_delayed_data_ref(struct btrfs_trans_handle *trans, * we''ve updated the existing ref, free the newly * allocated ref */ - kfree(full_ref); + mempool_free(full_ref, data_ref_pool); } else { delayed_refs->num_entries++; trans->delayed_ref_updates++; @@ -587,15 +596,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_root *delayed_refs; BUG_ON(extent_op && extent_op->is_data); - ref = kmalloc(sizeof(*ref), GFP_NOFS); - if (!ref) - return -ENOMEM; - - head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); - if (!head_ref) { - kfree(ref); - return -ENOMEM; - } + ref = mempool_alloc(tree_ref_pool, GFP_NOFS); + head_ref = mempool_alloc(ref_head_pool, GFP_NOFS); head_ref->extent_op = extent_op; @@ -628,15 +630,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_root *delayed_refs; BUG_ON(extent_op && !extent_op->is_data); - ref = kmalloc(sizeof(*ref), GFP_NOFS); - if (!ref) - return -ENOMEM; - - head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); - if (!head_ref) { - kfree(ref); - return -ENOMEM; - } + ref = mempool_alloc(data_ref_pool, GFP_NOFS); + head_ref = mempool_alloc(ref_head_pool, GFP_NOFS); head_ref->extent_op = extent_op; @@ -662,10 +657,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); - if (!head_ref) - return -ENOMEM; - + head_ref = mempool_alloc(ref_head_pool, GFP_NOFS); head_ref->extent_op = extent_op; delayed_refs = &trans->transaction->delayed_refs; @@ -694,3 +686,80 @@ btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr) return btrfs_delayed_node_to_head(ref); return NULL; } + +void btrfs_free_delayed_ref(struct btrfs_delayed_ref_node *ref) +{ + if (!ref->type) + mempool_free(ref, ref_head_pool); + else if (ref->type == BTRFS_SHARED_BLOCK_REF_KEY || + ref->type == BTRFS_TREE_BLOCK_REF_KEY) + mempool_free(ref, tree_ref_pool); + else if (ref->type == BTRFS_SHARED_DATA_REF_KEY || + ref->type == BTRFS_EXTENT_DATA_REF_KEY) + mempool_free(ref, data_ref_pool); + else + BUG(); +} + +void +btrfs_destroy_delayed_ref_caches(void) +{ + if (data_ref_pool) + mempool_destroy(data_ref_pool); + if (data_ref_cache) + kmem_cache_destroy(data_ref_cache); + + if (tree_ref_pool) + mempool_destroy(tree_ref_pool); + if (tree_ref_cache) + kmem_cache_destroy(tree_ref_cache); + + if (ref_head_pool) + mempool_destroy(ref_head_pool); + if (ref_head_cache) + kmem_cache_destroy(ref_head_cache); +} + +int __init +btrfs_create_delayed_ref_caches(void) +{ + int objsize = sizeof(struct btrfs_delayed_ref_head); + ref_head_cache = kmem_cache_create("btrfs_delayed_ref_head", objsize, + 0, 0, NULL); + if (!ref_head_cache) + goto error; + + ref_head_pool = mempool_create_slab_pool(PAGE_SIZE/objsize, + ref_head_cache); + if (!ref_head_pool) + goto error; + + + objsize = sizeof(struct btrfs_delayed_tree_ref); + tree_ref_cache = kmem_cache_create("btrfs_delayed_tree_ref", objsize, + 0, 0, NULL); + if (!tree_ref_cache) + goto error; + + tree_ref_pool = mempool_create_slab_pool(PAGE_SIZE/objsize, + tree_ref_cache); + if (!tree_ref_pool) + goto error; + + + objsize = sizeof(struct btrfs_delayed_data_ref); + data_ref_cache = kmem_cache_create("btrfs_delayed_data_ref", objsize, + 0, 0, NULL); + if (!data_ref_cache) + goto error; + + data_ref_pool = mempool_create_slab_pool(PAGE_SIZE/objsize, + data_ref_cache); + if (!data_ref_pool) + goto error; + + return 0; +error: + btrfs_destroy_delayed_ref_caches(); + return -ENOMEM; +} diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index e287e3b..6c41d8d 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -142,12 +142,13 @@ struct btrfs_delayed_ref_root { u64 run_delayed_start; }; +void btrfs_free_delayed_ref(struct btrfs_delayed_ref_node *ref); static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref) { WARN_ON(atomic_read(&ref->refs) == 0); if (atomic_dec_and_test(&ref->refs)) { WARN_ON(ref->in_tree); - kfree(ref); + btrfs_free_delayed_ref(ref); } } @@ -202,4 +203,7 @@ btrfs_delayed_node_to_head(struct btrfs_delayed_ref_node *node) WARN_ON(!btrfs_delayed_ref_is_head(node)); return container_of(node, struct btrfs_delayed_ref_head, node); } + +int btrfs_create_delayed_ref_caches(void); +void btrfs_destroy_delayed_ref_caches(void); #endif diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 26e1dcf..9719312 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1369,13 +1369,19 @@ static int __init init_btrfs_fs(void) if (err) goto free_delayed_inode; - err = register_filesystem(&btrfs_fs_type); + err = btrfs_create_delayed_ref_caches(); if (err) goto unregister_ioctl; + err = register_filesystem(&btrfs_fs_type); + if (err) + goto free_delayed_ref_caches; + printk(KERN_INFO "%s loaded\n", BTRFS_BUILD_VERSION); return 0; +free_delayed_ref_caches: + btrfs_destroy_delayed_ref_caches(); unregister_ioctl: btrfs_interface_exit(); free_delayed_inode: @@ -1394,6 +1400,7 @@ free_compress: static void __exit exit_btrfs_fs(void) { + btrfs_destroy_delayed_ref_caches(); btrfs_destroy_cachep(); btrfs_delayed_inode_exit(); extent_map_exit(); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 76/99] btrfs: Delayed ref mempool functions should return void
Now that the delayed ref code uses mempools, allocations can''t fail, and there are no more error conditions to report. This patch makes the following functions return void: - btrfs_alloc_reserved_file_extent - btrfs_add_delayed_tree_ref - btrfs_add_delayed_data_ref - btrfs_add_delayed_extent_op Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 8 ++-- fs/btrfs/delayed-ref.c | 27 +++++++--------- fs/btrfs/delayed-ref.h | 24 +++++++------- fs/btrfs/extent-tree.c | 78 ++++++++++++++++++++--------------------------- fs/btrfs/inode.c | 6 +-- 5 files changed, 63 insertions(+), 80 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index ea47c73..f704253 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2179,10 +2179,10 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytenr, u32 blocksize, int level); -int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 root_objectid, u64 owner, - u64 offset, struct btrfs_key *ins); +void btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 root_objectid, u64 owner, + u64 offset, struct btrfs_key *ins); int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 root_objectid, u64 owner, u64 offset, diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index a70c40d..16aea4e 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -586,10 +586,10 @@ static noinline void add_delayed_data_ref(struct btrfs_trans_handle *trans, * to make sure the delayed ref is eventually processed before this * transaction commits. */ -int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, u64 parent, - u64 ref_root, int level, int action, - struct btrfs_delayed_extent_op *extent_op) +void btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, u64 parent, + u64 ref_root, int level, int action, + struct btrfs_delayed_extent_op *extent_op) { struct btrfs_delayed_tree_ref *ref; struct btrfs_delayed_ref_head *head_ref; @@ -613,17 +613,16 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, parent, ref_root, level, action); spin_unlock(&delayed_refs->lock); - return 0; } /* * add a delayed data ref. it''s similar to btrfs_add_delayed_tree_ref. */ -int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, - u64 parent, u64 ref_root, - u64 owner, u64 offset, int action, - struct btrfs_delayed_extent_op *extent_op) +void btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, + u64 parent, u64 ref_root, + u64 owner, u64 offset, int action, + struct btrfs_delayed_extent_op *extent_op) { struct btrfs_delayed_data_ref *ref; struct btrfs_delayed_ref_head *head_ref; @@ -647,12 +646,11 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, parent, ref_root, owner, offset, action); spin_unlock(&delayed_refs->lock); - return 0; } -int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, - struct btrfs_delayed_extent_op *extent_op) +void btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, + struct btrfs_delayed_extent_op *extent_op) { struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; @@ -666,7 +664,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data); spin_unlock(&delayed_refs->lock); - return 0; } /* diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index 6c41d8d..8b2cec2 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -152,18 +152,18 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref) } } -int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, u64 parent, - u64 ref_root, int level, int action, - struct btrfs_delayed_extent_op *extent_op); -int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, - u64 parent, u64 ref_root, - u64 owner, u64 offset, int action, - struct btrfs_delayed_extent_op *extent_op); -int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, - u64 bytenr, u64 num_bytes, - struct btrfs_delayed_extent_op *extent_op); +void btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, u64 parent, + u64 ref_root, int level, int action, + struct btrfs_delayed_extent_op *extent_op); +void btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, + u64 parent, u64 ref_root, + u64 owner, u64 offset, int action, + struct btrfs_delayed_extent_op *extent_op); +void btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, + u64 bytenr, u64 num_bytes, + struct btrfs_delayed_extent_op *extent_op); struct btrfs_delayed_ref_head * btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a706480..fe95f37 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1837,20 +1837,19 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, u64 owner, u64 offset) { - int ret; BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID && root_objectid == BTRFS_TREE_LOG_OBJECTID); if (owner < BTRFS_FIRST_FREE_OBJECTID) { - ret = btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes, - parent, root_objectid, (int)owner, - BTRFS_ADD_DELAYED_REF, NULL); + btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes, parent, + root_objectid, (int)owner, + BTRFS_ADD_DELAYED_REF, NULL); } else { - ret = btrfs_add_delayed_data_ref(trans, bytenr, num_bytes, - parent, root_objectid, owner, offset, - BTRFS_ADD_DELAYED_REF, NULL); + btrfs_add_delayed_data_ref(trans, bytenr, num_bytes, parent, + root_objectid, owner, offset, + BTRFS_ADD_DELAYED_REF, NULL); } - return ret; + return 0; } static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, @@ -2363,7 +2362,6 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, int is_data) { struct btrfs_delayed_extent_op *extent_op; - int ret; extent_op = kmalloc(sizeof(*extent_op), GFP_NOFS); if (!extent_op) @@ -2374,10 +2372,8 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, extent_op->update_key = 0; extent_op->is_data = is_data ? 1 : 0; - ret = btrfs_add_delayed_extent_op(trans, bytenr, num_bytes, extent_op); - if (ret) - kfree(extent_op); - return ret; + btrfs_add_delayed_extent_op(trans, bytenr, num_bytes, extent_op); + return 0; } static noinline int check_delayed_ref(struct btrfs_trans_handle *trans, @@ -4767,11 +4763,10 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, int ret; if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { - ret = btrfs_add_delayed_tree_ref(trans, buf->start, buf->len, - parent, root->root_key.objectid, - btrfs_header_level(buf), - BTRFS_DROP_DELAYED_REF, NULL); - BUG_ON(ret); + btrfs_add_delayed_tree_ref(trans, buf->start, buf->len, + parent, root->root_key.objectid, + btrfs_header_level(buf), + BTRFS_DROP_DELAYED_REF, NULL); } if (!last_ref) @@ -4824,18 +4819,15 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, btrfs_panic(root->fs_info, ret, "Cannot pin " "extent in range %llu(%llu)\n", bytenr, num_bytes); - } else if (owner < BTRFS_FIRST_FREE_OBJECTID) { - ret = btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes, - parent, root_objectid, (int)owner, - BTRFS_DROP_DELAYED_REF, NULL); - BUG_ON(ret); - } else { - ret = btrfs_add_delayed_data_ref(trans, bytenr, num_bytes, - parent, root_objectid, owner, - offset, BTRFS_DROP_DELAYED_REF, NULL); - BUG_ON(ret); - } - return ret; + } else if (owner < BTRFS_FIRST_FREE_OBJECTID) + btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes, parent, + root_objectid, (int)owner, + BTRFS_DROP_DELAYED_REF, NULL); + else + btrfs_add_delayed_data_ref(trans, bytenr, num_bytes, parent, + root_objectid, owner, offset, + BTRFS_DROP_DELAYED_REF, NULL); + return 0; } static u64 stripe_align(struct btrfs_root *root, u64 val) @@ -5624,19 +5616,16 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, return ret; } -int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 root_objectid, u64 owner, - u64 offset, struct btrfs_key *ins) +void btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 root_objectid, u64 owner, + u64 offset, struct btrfs_key *ins) { - int ret; - BUG_ON(root_objectid == BTRFS_TREE_LOG_OBJECTID); - ret = btrfs_add_delayed_data_ref(trans, ins->objectid, ins->offset, - 0, root_objectid, owner, offset, - BTRFS_ADD_DELAYED_EXTENT, NULL); - return ret; + btrfs_add_delayed_data_ref(trans, ins->objectid, ins->offset, + 0, root_objectid, owner, offset, + BTRFS_ADD_DELAYED_EXTENT, NULL); } /* @@ -5851,11 +5840,10 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, extent_op->update_flags = 1; extent_op->is_data = 0; - ret = btrfs_add_delayed_tree_ref(trans, ins.objectid, - ins.offset, parent, root_objectid, - level, BTRFS_ADD_DELAYED_EXTENT, - extent_op); - BUG_ON(ret); + btrfs_add_delayed_tree_ref(trans, ins.objectid, + ins.offset, parent, root_objectid, + level, BTRFS_ADD_DELAYED_EXTENT, + extent_op); } return buf; } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1a9574f..46f3d4a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1706,10 +1706,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, ins.objectid = disk_bytenr; ins.offset = disk_num_bytes; ins.type = BTRFS_EXTENT_ITEM_KEY; - ret = btrfs_alloc_reserved_file_extent(trans, root, - root->root_key.objectid, - btrfs_ino(inode), file_pos, &ins); - BUG_ON(ret); + btrfs_alloc_reserved_file_extent(trans, root, root->root_key.objectid, + btrfs_ino(inode), file_pos, &ins); btrfs_free_path(path); return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 77/99] btrfs: btrfs_inc_extent_ref void return prep
btrfs_inc_extent_ref has no error conditions, but is used via process_func in __btrfs_mod_ref which requires it to return an int. This patch cleans up the callers to eliminate error handling that will never be used. A later patch in this series makes both btrfs_inc_extent_ref and the other function used via process_func, btrfs_inc_extent_ref, return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/file.c | 18 ++++++++---------- fs/btrfs/ioctl.c | 3 +-- fs/btrfs/relocation.c | 34 ++++++++++++++-------------------- fs/btrfs/tree-log.c | 9 ++++----- 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 74f50ba..314c08e 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -673,12 +673,11 @@ next_slot: btrfs_mark_buffer_dirty(leaf); if (disk_bytenr > 0) { - ret = btrfs_inc_extent_ref(trans, root, - disk_bytenr, num_bytes, 0, - root->root_key.objectid, - new_key.objectid, - start - extent_offset); - BUG_ON(ret); + btrfs_inc_extent_ref(trans, root, + disk_bytenr, num_bytes, 0, + root->root_key.objectid, + new_key.objectid, + start - extent_offset); *hint_byte = disk_bytenr; } key.offset = start; @@ -959,10 +958,9 @@ again: extent_end - split); btrfs_mark_buffer_dirty(leaf); - ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, - root->root_key.objectid, - ino, orig_offset); - BUG_ON(ret); + btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, + root->root_key.objectid, + ino, orig_offset); if (split == start) { key.offset = start; diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a7450b3..4cef4f1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2402,12 +2402,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, datal); if (disko) { inode_add_bytes(inode, datal); - ret = btrfs_inc_extent_ref(trans, root, + btrfs_inc_extent_ref(trans, root, disko, diskl, 0, root->root_key.objectid, btrfs_ino(inode), new_key.offset - datao); - BUG_ON(ret); } } else if (type == BTRFS_FILE_EXTENT_INLINE) { u64 skip = 0; diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index f2ff530..4c65c4e 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1628,11 +1628,10 @@ int replace_file_extents(struct btrfs_trans_handle *trans, dirty = 1; key.offset -= btrfs_file_extent_offset(leaf, fi); - ret = btrfs_inc_extent_ref(trans, root, new_bytenr, - num_bytes, parent, - btrfs_header_owner(leaf), - key.objectid, key.offset); - BUG_ON(ret); + btrfs_inc_extent_ref(trans, root, new_bytenr, + num_bytes, parent, + btrfs_header_owner(leaf), + key.objectid, key.offset); ret = btrfs_free_extent(trans, root, bytenr, num_bytes, parent, btrfs_header_owner(leaf), @@ -1803,15 +1802,11 @@ again: path->slots[level], old_ptr_gen); btrfs_mark_buffer_dirty(path->nodes[level]); - ret = btrfs_inc_extent_ref(trans, src, old_bytenr, blocksize, - path->nodes[level]->start, - src->root_key.objectid, level - 1, 0); - BUG_ON(ret); - ret = btrfs_inc_extent_ref(trans, dest, new_bytenr, blocksize, - 0, dest->root_key.objectid, level - 1, - 0); - BUG_ON(ret); - + btrfs_inc_extent_ref(trans, src, old_bytenr, blocksize, + path->nodes[level]->start, + src->root_key.objectid, level - 1, 0); + btrfs_inc_extent_ref(trans, dest, new_bytenr, blocksize, + 0, dest->root_key.objectid, level - 1, 0); ret = btrfs_free_extent(trans, src, new_bytenr, blocksize, path->nodes[level]->start, src->root_key.objectid, level - 1, 0); @@ -2588,12 +2583,11 @@ static int do_relocation(struct btrfs_trans_handle *trans, trans->transid); btrfs_mark_buffer_dirty(upper->eb); - ret = btrfs_inc_extent_ref(trans, root, - node->eb->start, blocksize, - upper->eb->start, - btrfs_header_owner(upper->eb), - node->level, 0); - BUG_ON(ret); + btrfs_inc_extent_ref(trans, root, + node->eb->start, blocksize, + upper->eb->start, + btrfs_header_owner(upper->eb), + node->level, 0); ret = btrfs_drop_subtree(trans, root, eb, upper->eb); BUG_ON(ret); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index aac743b..feb4575 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -588,11 +588,10 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ret = btrfs_lookup_extent(root, ins.objectid, ins.offset); if (ret == 0) { - ret = btrfs_inc_extent_ref(trans, root, - ins.objectid, ins.offset, - 0, root->root_key.objectid, - key->objectid, offset); - BUG_ON(ret); + btrfs_inc_extent_ref(trans, root, ins.objectid, + ins.offset, 0, + root->root_key.objectid, + key->objectid, offset); } else { /* * insert the extent pointer in the extent -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 78/99] btrfs: btrfs_free_extent void return prep
btrfs_free_extent has no error conditions, but is used via process_func in __btrfs_mod_ref which requires it to return an int. This patch cleans up the callers to eliminate error handling that will never be used. The next patch makes both btrfs_free_extent and the other function used via process_func, btrfs_inc_extent_ref, return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 8 +++----- fs/btrfs/file.c | 23 +++++++++-------------- fs/btrfs/inode.c | 9 ++++----- fs/btrfs/relocation.c | 23 +++++++++-------------- 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index fe95f37..dc91e4d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4805,13 +4805,12 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, u64 owner, u64 offset) { - int ret; - /* * tree log blocks never actually go into the extent allocation * tree, just update pinning info and exit early. */ if (root_objectid == BTRFS_TREE_LOG_OBJECTID) { + int ret; WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID); /* unlocks the pinned mutex */ ret = btrfs_pin_extent(root, bytenr, num_bytes, 1); @@ -6142,9 +6141,8 @@ skip: parent = 0; } - ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent, - root->root_key.objectid, level - 1, 0); - BUG_ON(ret); + btrfs_free_extent(trans, root, bytenr, blocksize, parent, + root->root_key.objectid, level - 1, 0); } btrfs_tree_unlock(next); free_extent_buffer(next); diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 314c08e..fa8f83e 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -747,12 +747,11 @@ next_slot: extent_end = ALIGN(extent_end, root->sectorsize); } else if (disk_bytenr > 0) { - ret = btrfs_free_extent(trans, root, - disk_bytenr, num_bytes, 0, - root->root_key.objectid, - key.objectid, key.offset - - extent_offset); - BUG_ON(ret); + btrfs_free_extent(trans, root, + disk_bytenr, num_bytes, 0, + root->root_key.objectid, + key.objectid, key.offset - + extent_offset); inode_sub_bytes(inode, extent_end - key.offset); *hint_byte = disk_bytenr; @@ -984,10 +983,8 @@ again: extent_end = other_end; del_slot = path->slots[0] + 1; del_nr++; - ret = btrfs_free_extent(trans, root, bytenr, num_bytes, - 0, root->root_key.objectid, - ino, orig_offset); - BUG_ON(ret); + btrfs_free_extent(trans, root, bytenr, num_bytes, 0, + root->root_key.objectid, ino, orig_offset); } other_start = 0; other_end = start; @@ -1001,10 +998,8 @@ again: key.offset = other_start; del_slot = path->slots[0]; del_nr++; - ret = btrfs_free_extent(trans, root, bytenr, num_bytes, - 0, root->root_key.objectid, - ino, orig_offset); - BUG_ON(ret); + btrfs_free_extent(trans, root, bytenr, num_bytes, 0, + root->root_key.objectid, ino, orig_offset); } if (del_nr == 0) { fi = btrfs_item_ptr(leaf, path->slots[0], diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 46f3d4a..d8bb54e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3270,11 +3270,10 @@ delete: if (found_extent && (root->ref_cows || root == root->fs_info->tree_root)) { btrfs_set_path_blocking(path); - ret = btrfs_free_extent(trans, root, extent_start, - extent_num_bytes, 0, - btrfs_header_owner(leaf), - ino, extent_offset); - BUG_ON(ret); + btrfs_free_extent(trans, root, extent_start, + extent_num_bytes, 0, + btrfs_header_owner(leaf), + ino, extent_offset); } if (found_type == BTRFS_INODE_ITEM_KEY) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 4c65c4e..c59eb2c 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1633,10 +1633,9 @@ int replace_file_extents(struct btrfs_trans_handle *trans, btrfs_header_owner(leaf), key.objectid, key.offset); - ret = btrfs_free_extent(trans, root, bytenr, num_bytes, - parent, btrfs_header_owner(leaf), - key.objectid, key.offset); - BUG_ON(ret); + btrfs_free_extent(trans, root, bytenr, num_bytes, + parent, btrfs_header_owner(leaf), + key.objectid, key.offset); } if (dirty) btrfs_mark_buffer_dirty(leaf); @@ -1807,16 +1806,12 @@ again: src->root_key.objectid, level - 1, 0); btrfs_inc_extent_ref(trans, dest, new_bytenr, blocksize, 0, dest->root_key.objectid, level - 1, 0); - ret = btrfs_free_extent(trans, src, new_bytenr, blocksize, - path->nodes[level]->start, - src->root_key.objectid, level - 1, 0); - BUG_ON(ret); - - ret = btrfs_free_extent(trans, dest, old_bytenr, blocksize, - 0, dest->root_key.objectid, level - 1, - 0); - BUG_ON(ret); - + btrfs_free_extent(trans, src, new_bytenr, blocksize, + path->nodes[level]->start, + src->root_key.objectid, level - 1, 0); + btrfs_free_extent(trans, dest, old_bytenr, blocksize, + 0, dest->root_key.objectid, level - 1, + 0); btrfs_unlock_up_safe(path, 0); ret = level; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 79/99] btrfs: __btrfs_mod_refs process_func should return void
__btrfs_mod_ref''s process_func function pointer calls btrfs_free_extent and btrfs_inc_extent_ref, which now both return only 0. This patches makes them return void and eliminates the error condition in __btrfs_mod_ref. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.h | 16 ++++++++-------- fs/btrfs/extent-tree.c | 39 ++++++++++++++------------------------- 2 files changed, 22 insertions(+), 33 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2201,22 +2201,22 @@ int btrfs_set_disk_extent_flags(struct b struct btrfs_root *root, u64 bytenr, u64 num_bytes, u64 flags, int is_data); -int btrfs_free_extent(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytenr, u64 num_bytes, u64 parent, - u64 root_objectid, u64 owner, u64 offset); +void btrfs_free_extent(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 bytenr, u64 num_bytes, u64 parent, + u64 root_objectid, u64 owner, u64 offset); int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, u64 start, u64 len); void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, struct btrfs_root *root); int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct btrfs_root *root); -int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytenr, u64 num_bytes, u64 parent, - u64 root_objectid, u64 owner, u64 offset); +void btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 bytenr, u64 num_bytes, u64 parent, + u64 root_objectid, u64 owner, u64 offset); int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, struct btrfs_root *root); --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1832,10 +1832,10 @@ static int btrfs_discard_extent(struct b return ret; } -int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytenr, u64 num_bytes, u64 parent, - u64 root_objectid, u64 owner, u64 offset) +void btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 bytenr, u64 num_bytes, u64 parent, + u64 root_objectid, u64 owner, u64 offset) { BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID && root_objectid == BTRFS_TREE_LOG_OBJECTID); @@ -1849,7 +1849,6 @@ int btrfs_inc_extent_ref(struct btrfs_tr root_objectid, owner, offset, BTRFS_ADD_DELAYED_REF, NULL); } - return 0; } static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, @@ -2566,9 +2565,8 @@ static int __btrfs_mod_ref(struct btrfs_ struct btrfs_file_extent_item *fi; int i; int level; - int ret = 0; - int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *, - u64, u64, u64, u64, u64, u64); + void (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *, + u64, u64, u64, u64, u64, u64); ref_root = btrfs_header_owner(buf); nritems = btrfs_header_nritems(buf); @@ -2603,24 +2601,16 @@ static int __btrfs_mod_ref(struct btrfs_ num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi); key.offset -= btrfs_file_extent_offset(buf, fi); - ret = process_func(trans, root, bytenr, num_bytes, - parent, ref_root, key.objectid, - key.offset); - if (ret) - goto fail; + process_func(trans, root, bytenr, num_bytes, parent, + ref_root, key.objectid, key.offset); } else { bytenr = btrfs_node_blockptr(buf, i); num_bytes = btrfs_level_size(root, level - 1); - ret = process_func(trans, root, bytenr, num_bytes, - parent, ref_root, level - 1, 0); - if (ret) - goto fail; + process_func(trans, root, bytenr, num_bytes, parent, + ref_root, level - 1, 0); } } return 0; -fail: - BUG(); - return ret; } int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, @@ -4800,10 +4790,10 @@ out: btrfs_put_block_group(cache); } -int btrfs_free_extent(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytenr, u64 num_bytes, u64 parent, - u64 root_objectid, u64 owner, u64 offset) +void btrfs_free_extent(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + u64 bytenr, u64 num_bytes, u64 parent, + u64 root_objectid, u64 owner, u64 offset) { /* * tree log blocks never actually go into the extent allocation @@ -4826,7 +4816,6 @@ int btrfs_free_extent(struct btrfs_trans btrfs_add_delayed_data_ref(trans, bytenr, num_bytes, parent, root_objectid, owner, offset, BTRFS_DROP_DELAYED_REF, NULL); - return 0; } static u64 stripe_align(struct btrfs_root *root, u64 val) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 80/99] btrfs: __btrfs_mod_ref should return void
Now that process_func can''t return an error, __btrfs_mod_ref has no more error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 30 ++++++++++-------------------- fs/btrfs/ctree.h | 8 ++++---- fs/btrfs/extent-tree.c | 34 +++++++++++++++------------------- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 2604ec4..bdaf3ad 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -224,7 +224,6 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, struct extent_buffer **cow_ret, u64 new_root_objectid) { struct extent_buffer *cow; - int ret = 0; int level; struct btrfs_disk_key disk_key; @@ -261,12 +260,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, WARN_ON(btrfs_header_generation(buf) > trans->transid); if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) - ret = btrfs_inc_ref(trans, root, cow, 1); + btrfs_inc_ref(trans, root, cow, 1); else - ret = btrfs_inc_ref(trans, root, cow, 0); - - if (ret) - return ret; + btrfs_inc_ref(trans, root, cow, 0); btrfs_mark_buffer_dirty(cow); *cow_ret = cow; @@ -350,25 +346,21 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, if ((owner == root->root_key.objectid || root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) && !(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) { - ret = btrfs_inc_ref(trans, root, buf, 1); - BUG_ON(ret); + btrfs_inc_ref(trans, root, buf, 1); if (root->root_key.objectid = BTRFS_TREE_RELOC_OBJECTID) { - ret = btrfs_dec_ref(trans, root, buf, 0); - BUG_ON(ret); - ret = btrfs_inc_ref(trans, root, cow, 1); - BUG_ON(ret); + btrfs_dec_ref(trans, root, buf, 0); + btrfs_inc_ref(trans, root, cow, 1); } new_flags |= BTRFS_BLOCK_FLAG_FULL_BACKREF; } else { if (root->root_key.objectid = BTRFS_TREE_RELOC_OBJECTID) - ret = btrfs_inc_ref(trans, root, cow, 1); + btrfs_inc_ref(trans, root, cow, 1); else - ret = btrfs_inc_ref(trans, root, cow, 0); - BUG_ON(ret); + btrfs_inc_ref(trans, root, cow, 0); } if (new_flags != 0) { ret = btrfs_set_disk_extent_flags(trans, root, @@ -381,12 +373,10 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) { if (root->root_key.objectid = BTRFS_TREE_RELOC_OBJECTID) - ret = btrfs_inc_ref(trans, root, cow, 1); + btrfs_inc_ref(trans, root, cow, 1); else - ret = btrfs_inc_ref(trans, root, cow, 0); - BUG_ON(ret); - ret = btrfs_dec_ref(trans, root, buf, 1); - BUG_ON(ret); + btrfs_inc_ref(trans, root, cow, 0); + btrfs_dec_ref(trans, root, buf, 1); } clean_tree_block(trans, root, buf); *last_ref = 1; diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index b791b8f..51f2840 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2193,10 +2193,10 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans, u64 empty_size, u64 hint_byte, u64 search_end, struct btrfs_key *ins, u64 data); -int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct extent_buffer *buf, int full_backref); -int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct extent_buffer *buf, int full_backref); +void btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct extent_buffer *buf, int full_backref); +void btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct extent_buffer *buf, int full_backref); int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytenr, u64 num_bytes, u64 flags, diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index c2dcfd8..fac996d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2551,10 +2551,10 @@ out: return ret; } -static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct extent_buffer *buf, - int full_backref, int inc) +static void __btrfs_mod_ref(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct extent_buffer *buf, + int full_backref, int inc) { u64 bytenr; u64 num_bytes; @@ -2573,7 +2573,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, level = btrfs_header_level(buf); if (!root->ref_cows && level == 0) - return 0; + return; if (inc) process_func = btrfs_inc_extent_ref; @@ -2610,19 +2610,18 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ref_root, level - 1, 0); } } - return 0; } -int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct extent_buffer *buf, int full_backref) +void btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct extent_buffer *buf, int full_backref) { - return __btrfs_mod_ref(trans, root, buf, full_backref, 1); + __btrfs_mod_ref(trans, root, buf, full_backref, 1); } -int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct extent_buffer *buf, int full_backref) +void btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct extent_buffer *buf, int full_backref) { - return __btrfs_mod_ref(trans, root, buf, full_backref, 0); + __btrfs_mod_ref(trans, root, buf, full_backref, 0); } static int write_one_cache_group(struct btrfs_trans_handle *trans, @@ -5985,10 +5984,8 @@ static noinline int walk_down_proc(struct btrfs_trans_handle *trans, /* wc->stage == UPDATE_BACKREF */ if (!(wc->flags[level] & flag)) { BUG_ON(!path->locks[level]); - ret = btrfs_inc_ref(trans, root, eb, 1); - BUG_ON(ret); - ret = btrfs_dec_ref(trans, root, eb, 0); - BUG_ON(ret); + btrfs_inc_ref(trans, root, eb, 1); + btrfs_dec_ref(trans, root, eb, 0); ret = btrfs_set_disk_extent_flags(trans, root, eb->start, eb->len, flag, 0); BUG_ON(ret); @@ -6204,10 +6201,9 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans, if (wc->refs[level] == 1) { if (level == 0) { if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) - ret = btrfs_dec_ref(trans, root, eb, 1); + btrfs_dec_ref(trans, root, eb, 1); else - ret = btrfs_dec_ref(trans, root, eb, 0); - BUG_ON(ret); + btrfs_dec_ref(trans, root, eb, 0); } /* make block locked assertion in clean_tree_block happy */ if (!path->locks[level] && -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 81/99] btrfs: clean_tree_block should return void
clean_tree_block has no error conditions and should return void. Its callers already ignore the error codes. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 5 ++--- fs/btrfs/disk-io.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index fcb0f7f..e16a3e9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1033,8 +1033,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, } -int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, - struct extent_buffer *buf) +void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, + struct extent_buffer *buf) { struct inode *btree_inode = root->fs_info->btree_inode; if (btrfs_header_generation(buf) =@@ -1055,7 +1055,6 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf); } - return 0; } static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index bec3ea4..5a2604a 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -42,8 +42,8 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, int mirror_num, struct extent_buffer **eb); struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize); -int clean_tree_block(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct extent_buffer *buf); +void clean_tree_block(struct btrfs_trans_handle *trans, + struct btrfs_root *root, struct extent_buffer *buf); struct btrfs_root *open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_devices, char *options); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 82/99] btrfs: btrfs_truncate_item should return void
btrfs_truncate_item has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 11 +++++------ fs/btrfs/ctree.h | 8 ++++---- fs/btrfs/dir-item.c | 4 ++-- fs/btrfs/extent-tree.c | 3 +-- fs/btrfs/file-item.c | 4 ++-- fs/btrfs/inode-item.c | 3 +-- fs/btrfs/inode.c | 4 ++-- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index bdaf3ad..12c66ea 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -3193,10 +3193,10 @@ 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, - struct btrfs_root *root, - struct btrfs_path *path, - u32 new_size, int from_end) +void btrfs_truncate_item(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + u32 new_size, int from_end) { int slot; struct extent_buffer *leaf; @@ -3213,7 +3213,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); @@ -3286,7 +3286,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } - return 0; } /* diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 51f2840..5d1e06c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2307,10 +2307,10 @@ int btrfs_block_can_be_shared(struct btrfs_root *root, struct extent_buffer *buf); int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u32 data_size); -int btrfs_truncate_item(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct btrfs_path *path, - u32 new_size, int from_end); +void btrfs_truncate_item(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + u32 new_size, int from_end); int btrfs_split_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index 31d84e7..c95fc70 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c @@ -383,8 +383,8 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, start = btrfs_item_ptr_offset(leaf, path->slots[0]); memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, item_len - (ptr + sub_item_len - start)); - ret = btrfs_truncate_item(trans, root, path, - item_len - sub_item_len, 1); + btrfs_truncate_item(trans, root, path, + item_len - sub_item_len, 1); } return ret; } diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index fac996d..4ab965d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1666,7 +1666,6 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans, u32 item_size; int size; int type; - int ret; u64 refs; leaf = path->nodes[0]; @@ -1708,7 +1707,7 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans, memmove_extent_buffer(leaf, ptr, ptr + size, end - ptr - size); item_size -= size; - ret = btrfs_truncate_item(trans, root, path, item_size, 1); + btrfs_truncate_item(trans, root, path, item_size, 1); } btrfs_mark_buffer_dirty(leaf); return 0; diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 8d5272d..319129e 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -514,7 +514,7 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans, */ u32 new_size = (bytenr - key->offset) >> blocksize_bits; new_size *= csum_size; - ret = btrfs_truncate_item(trans, root, path, new_size, 1); + btrfs_truncate_item(trans, root, path, new_size, 1); } else if (key->offset >= bytenr && csum_end > end_byte && end_byte > key->offset) { /* @@ -526,7 +526,7 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans, u32 new_size = (csum_end - end_byte) >> blocksize_bits; new_size *= csum_size; - ret = btrfs_truncate_item(trans, root, path, new_size, 0); + btrfs_truncate_item(trans, root, path, new_size, 0); key->offset = end_byte; ret = btrfs_set_item_key_safe(trans, root, path, key); diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index baa74f3..c04018c 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c @@ -128,8 +128,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, item_start = btrfs_item_ptr_offset(leaf, path->slots[0]); memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, item_size - (ptr + sub_item_len - item_start)); - ret = btrfs_truncate_item(trans, root, path, - item_size - sub_item_len, 1); + btrfs_truncate_item(trans, root, path, item_size - sub_item_len, 1); out: btrfs_free_path(path); return ret; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d8bb54e..96a0fbd 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3243,8 +3243,8 @@ search_again: } size btrfs_file_extent_calc_inline_size(size); - ret = btrfs_truncate_item(trans, root, path, - size, 1); + btrfs_truncate_item(trans, root, path, + size, 1); } else if (root->ref_cows) { inode_sub_bytes(inode, item_end + 1 - found_key.offset); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 83/99] btrfs: btrfs_extend_item should return void
btrfs_extend_item has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 7 +++---- fs/btrfs/ctree.h | 5 +++-- fs/btrfs/dir-item.c | 5 ++--- fs/btrfs/extent-tree.c | 5 ++--- fs/btrfs/file-item.c | 2 +- fs/btrfs/inode-item.c | 2 +- fs/btrfs/tree-log.c | 9 ++++----- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 12c66ea..4c9dc73 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -3291,9 +3291,9 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans, /* * make the item pointed to by the path bigger, data_size is the new size. */ -int btrfs_extend_item(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct btrfs_path *path, - u32 data_size) +void btrfs_extend_item(struct btrfs_trans_handle *trans, + struct btrfs_root *root, struct btrfs_path *path, + u32 data_size) { int slot; struct extent_buffer *leaf; @@ -3351,7 +3351,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans, btrfs_print_leaf(root, leaf); BUG(); } - return 0; } /* diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5d1e06c..5dee97f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2305,8 +2305,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, struct extent_buffer **cow_ret, u64 new_root_objectid); int btrfs_block_can_be_shared(struct btrfs_root *root, struct extent_buffer *buf); -int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root - *root, struct btrfs_path *path, u32 data_size); +void btrfs_extend_item(struct btrfs_trans_handle *trans, + struct btrfs_root *root, struct btrfs_path *path, + u32 data_size); void btrfs_truncate_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index c95fc70..7674330 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 di = btrfs_match_dir_item_name(root, path, name, name_len); if (di) return ERR_PTR(-EEXIST); - ret = btrfs_extend_item(trans, root, path, data_size); - } - if (ret < 0) + btrfs_extend_item(trans, root, path, data_size); + } else if (ret < 0) return ERR_PTR(ret); WARN_ON(ret > 0); leaf = path->nodes[0]; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4ab965d..201822d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -974,7 +974,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle *trans, return ret; BUG_ON(ret); - ret = btrfs_extend_item(trans, root, path, new_size); + btrfs_extend_item(trans, root, path, new_size); leaf = path->nodes[0]; item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); @@ -1572,7 +1572,6 @@ void setup_inline_extent_backref(struct btrfs_trans_handle *trans, u64 refs; int size; int type; - int ret; leaf = path->nodes[0]; ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); @@ -1581,7 +1580,7 @@ void setup_inline_extent_backref(struct btrfs_trans_handle *trans, type = extent_ref_type(parent, owner); size = btrfs_extent_inline_ref_size(type); - ret = btrfs_extend_item(trans, root, path, size); + btrfs_extend_item(trans, root, path, size); ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); refs = btrfs_extent_refs(leaf, ei); diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 319129e..4a73745 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -778,7 +778,7 @@ again: if (diff != csum_size) goto insert; - ret = btrfs_extend_item(trans, root, path, diff); + btrfs_extend_item(trans, root, path, diff); goto csum; } diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index c04018c..9f0d038 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c @@ -164,7 +164,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, goto out; old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]); - ret = btrfs_extend_item(trans, root, path, ins_len); + btrfs_extend_item(trans, root, path, ins_len); ref = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_inode_ref); ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index feb4575..22e7da6 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -380,12 +380,11 @@ insert: u32 found_size; found_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]); - if (found_size > item_size) { + if (found_size > item_size) btrfs_truncate_item(trans, root, path, item_size, 1); - } else if (found_size < item_size) { - ret = btrfs_extend_item(trans, root, path, - item_size - found_size); - } + else if (found_size < item_size) + btrfs_extend_item(trans, root, path, + item_size - found_size); } else if (ret) { return ret; } -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 84/99] btrfs: end_compressed_writeback should return void
end_compressed_writeback has no error conditions and should return void. Its callers already ignore the error code anyway. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/compression.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 0c0e842..6c4d228 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -225,8 +225,8 @@ out: * 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, - unsigned long ram_size) +static noinline void end_compressed_writeback(struct inode *inode, u64 start, + unsigned long ram_size) { unsigned long index = start >> PAGE_CACHE_SHIFT; unsigned long end_index = (start + ram_size - 1) >> PAGE_CACHE_SHIFT; @@ -252,7 +252,6 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start, index += ret; } /* the inode may be gone now */ - return 0; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
copy_for_split has no error conditions and should return void. We return 0 from split_leaf instead of ret since ret would have been set using the return value from copy_for_split which would have been 0. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ctree.c | 19 ++++++++----------- 1 files changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 4c9dc73..263abce 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2695,12 +2695,12 @@ out: * * returns 0 if all went well and < 0 on failure. */ -static noinline int copy_for_split(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct btrfs_path *path, - struct extent_buffer *l, - struct extent_buffer *right, - int slot, int mid, int nritems) +static noinline void copy_for_split(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + struct extent_buffer *l, + struct extent_buffer *right, + int slot, int mid, int nritems) { int data_copy_size; int rt_data_off; @@ -2752,8 +2752,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, } BUG_ON(path->slots[0] < 0); - - return 0; } /* @@ -2965,8 +2963,7 @@ again: 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); @@ -2974,7 +2971,7 @@ again: goto again; } - return ret; + return 0; push_for_double: push_for_double_split(trans, root, path, data_size); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:36 UTC
[patch 86/99] btrfs: update_inline_extent_backref should return void
Now that btrfs_truncate_item returns void, there are no more error conditions in update_inline_extent_backref and it should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1649,12 +1649,12 @@ static int lookup_extent_backref(struct * helper to update/remove inline back ref */ static noinline_for_stack -int update_inline_extent_backref(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct btrfs_path *path, - struct btrfs_extent_inline_ref *iref, - int refs_to_mod, - struct btrfs_delayed_extent_op *extent_op) +void update_inline_extent_backref(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct btrfs_path *path, + struct btrfs_extent_inline_ref *iref, + int refs_to_mod, + struct btrfs_delayed_extent_op *extent_op) { struct extent_buffer *leaf; struct btrfs_extent_item *ei; @@ -1709,7 +1709,6 @@ int update_inline_extent_backref(struct btrfs_truncate_item(trans, root, path, item_size, 1); } btrfs_mark_buffer_dirty(leaf); - return 0; } static noinline_for_stack @@ -1729,8 +1728,8 @@ int insert_inline_extent_backref(struct root_objectid, owner, offset, 1); if (ret == 0) { BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID); - ret = update_inline_extent_backref(trans, root, path, iref, - refs_to_add, extent_op); + update_inline_extent_backref(trans, root, path, iref, + refs_to_add, extent_op); } else if (ret == -ENOENT) { setup_inline_extent_backref(trans, root, path, iref, parent, root_objectid, owner, offset, @@ -1765,12 +1764,12 @@ static int remove_extent_backref(struct struct btrfs_extent_inline_ref *iref, int refs_to_drop, int is_data) { - int ret; + int ret = 0; BUG_ON(!is_data && refs_to_drop != 1); if (iref) { - ret = update_inline_extent_backref(trans, root, path, iref, - -refs_to_drop, NULL); + update_inline_extent_backref(trans, root, path, iref, + -refs_to_drop, NULL); } else if (is_data) { ret = remove_extent_data_ref(trans, root, path, refs_to_drop); } else { -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 87/99] btrfs: btrfs_put_ordered_extent should return void
btrfs_put_ordered_extent has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 3 +-- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -392,7 +392,7 @@ out: * used to drop a reference on an ordered extent. This will free * the extent if the last reference is dropped */ -int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) +void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) { struct list_head *cur; struct btrfs_ordered_sum *sum; @@ -408,7 +408,6 @@ int btrfs_put_ordered_extent(struct btrf } kfree(entry); } - return 0; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -138,7 +138,7 @@ btrfs_ordered_inode_tree_init(struct btr t->last = NULL; } -int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); +void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); int btrfs_remove_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *entry); int btrfs_dec_test_ordered_pending(struct inode *inode, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 88/99] btrfs: __btrfs_remove_ordered_extent should return void
__btrfs_remove_ordered_extent has no error conditions and should return void. Once that happens, btrfs_remove_ordered_extent has no error conditions can can also return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 15 +++++---------- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -415,8 +415,8 @@ void btrfs_put_ordered_extent(struct btr * and you must wake_up entry->wait. You must hold the tree lock * while you call this function. */ -static int __btrfs_remove_ordered_extent(struct inode *inode, - struct btrfs_ordered_extent *entry) +static void __btrfs_remove_ordered_extent(struct inode *inode, + struct btrfs_ordered_extent *entry) { struct btrfs_ordered_inode_tree *tree; struct btrfs_root *root = BTRFS_I(inode)->root; @@ -443,27 +443,22 @@ static int __btrfs_remove_ordered_extent list_del_init(&BTRFS_I(inode)->ordered_operations); } spin_unlock(&root->fs_info->ordered_extent_lock); - - return 0; } /* * remove an ordered extent from the tree. No references are dropped * but any waiters are woken. */ -int btrfs_remove_ordered_extent(struct inode *inode, - struct btrfs_ordered_extent *entry) +void btrfs_remove_ordered_extent(struct inode *inode, + struct btrfs_ordered_extent *entry) { struct btrfs_ordered_inode_tree *tree; - int ret; tree = &BTRFS_I(inode)->ordered_tree; spin_lock(&tree->lock); - ret = __btrfs_remove_ordered_extent(inode, entry); + __btrfs_remove_ordered_extent(inode, entry); spin_unlock(&tree->lock); wake_up(&entry->wait); - - return ret; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -139,7 +139,7 @@ btrfs_ordered_inode_tree_init(struct btr } void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); -int btrfs_remove_ordered_extent(struct inode *inode, +void btrfs_remove_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *entry); int btrfs_dec_test_ordered_pending(struct inode *inode, struct btrfs_ordered_extent **cached, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 89/99] btrfs: btrfs_wait_ordered_extents should return void
btrfs_wait_ordered_extents has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 5 ++--- fs/btrfs/ordered-data.h | 4 ++-- fs/btrfs/transaction.c | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -465,8 +465,8 @@ void btrfs_remove_ordered_extent(struct * wait for all the ordered extents in a root. This is done when balancing * space between drives. */ -int btrfs_wait_ordered_extents(struct btrfs_root *root, - int nocow_only, int delay_iput) +void btrfs_wait_ordered_extents(struct btrfs_root *root, + int nocow_only, int delay_iput) { struct list_head splice; struct list_head *cur; @@ -514,7 +514,6 @@ int btrfs_wait_ordered_extents(struct bt spin_lock(&root->fs_info->ordered_extent_lock); } spin_unlock(&root->fs_info->ordered_extent_lock); - return 0; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -174,6 +174,6 @@ int btrfs_run_ordered_operations(struct int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct inode *inode); -int btrfs_wait_ordered_extents(struct btrfs_root *root, - int nocow_only, int delay_iput); +void btrfs_wait_ordered_extents(struct btrfs_root *root, + int nocow_only, int delay_iput); #endif --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1207,8 +1207,7 @@ int btrfs_commit_transaction(struct btrf if (flush_on_commit || snap_pending) { btrfs_start_delalloc_inodes(root, 1); - ret = btrfs_wait_ordered_extents(root, 0, 1); - BUG_ON(ret); + btrfs_wait_ordered_extents(root, 0, 1); } ret = btrfs_run_delayed_items(trans, root); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 90/99] btrfs: btrfs_wait_ordered_range should return void
btrfs_wait_ordered_range has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 3 +-- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -610,7 +610,7 @@ void btrfs_start_ordered_extent(struct i /* * Used to wait on ordered extents across a large range of bytes. */ -int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) +void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) { u64 end; u64 orig_end; @@ -665,7 +665,6 @@ again: schedule_timeout(1); goto again; } - return 0; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -161,7 +161,7 @@ struct btrfs_ordered_extent *btrfs_looku u64 file_offset); void btrfs_start_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *entry, int wait); -int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); +void btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); struct btrfs_ordered_extent * btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset); struct btrfs_ordered_extent *btrfs_lookup_ordered_range(struct inode *inode, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 91/99] btrfs: btrfs_run_ordered_operations should return void
btrfs_run_ordered_operations has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 4 +--- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -526,7 +526,7 @@ void btrfs_wait_ordered_extents(struct b * extra check to make sure the ordered operation list really is empty * before we return */ -int btrfs_run_ordered_operations(struct btrfs_root *root, int wait) +void btrfs_run_ordered_operations(struct btrfs_root *root, int wait) { struct btrfs_inode *btrfs_inode; struct inode *inode; @@ -574,8 +574,6 @@ again: spin_unlock(&root->fs_info->ordered_extent_lock); mutex_unlock(&root->fs_info->ordered_operations_mutex); - - return 0; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -170,7 +170,7 @@ struct btrfs_ordered_extent *btrfs_looku int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, struct btrfs_ordered_extent *ordered); int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); -int btrfs_run_ordered_operations(struct btrfs_root *root, int wait); +void btrfs_run_ordered_operations(struct btrfs_root *root, int wait); int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct inode *inode); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 92/99] btrfs: btrfs_add_ordered_operation should return void
btrfs_add_ordered_operation has no error conditions and should return void Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 11 ++++------- fs/btrfs/ordered-data.h | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -946,9 +946,8 @@ out: * If trans is not null, we''ll do a friendly check for a transaction that * is already flushing things and force the IO down ourselves. */ -int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct inode *inode) +void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, + struct btrfs_root *root, struct inode *inode) { u64 last_mod; @@ -959,7 +958,7 @@ int btrfs_add_ordered_operation(struct b * commit, we can safely return without doing anything */ if (last_mod < root->fs_info->last_trans_committed) - return 0; + return; /* * the transaction is already committing. Just start the IO and @@ -967,7 +966,7 @@ int btrfs_add_ordered_operation(struct b */ if (trans && root->fs_info->running_transaction->blocked) { btrfs_wait_ordered_range(inode, 0, (u64)-1); - return 0; + return; } spin_lock(&root->fs_info->ordered_extent_lock); @@ -976,6 +975,4 @@ int btrfs_add_ordered_operation(struct b &root->fs_info->ordered_operations); } spin_unlock(&root->fs_info->ordered_extent_lock); - - return 0; } --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -171,9 +171,9 @@ int btrfs_ordered_update_i_size(struct i struct btrfs_ordered_extent *ordered); int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); void btrfs_run_ordered_operations(struct btrfs_root *root, int wait); -int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - struct inode *inode); +void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct inode *inode); void btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only, int delay_iput); #endif -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 93/99] btrfs: btrfs_add_ordered_sum should return void
btrfs_add_ordered_sum has no error conditions and should return void Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/ordered-data.c | 7 +++---- fs/btrfs/ordered-data.h | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -257,9 +257,9 @@ int btrfs_add_ordered_extent_compress(st * when an ordered extent is finished. If the list covers more than one * ordered extent, it is split across multiples. */ -int btrfs_add_ordered_sum(struct inode *inode, - struct btrfs_ordered_extent *entry, - struct btrfs_ordered_sum *sum) +void btrfs_add_ordered_sum(struct inode *inode, + struct btrfs_ordered_extent *entry, + struct btrfs_ordered_sum *sum) { struct btrfs_ordered_inode_tree *tree; @@ -267,7 +267,6 @@ int btrfs_add_ordered_sum(struct inode * spin_lock(&tree->lock); list_add_tail(&sum->list, &entry->list); spin_unlock(&tree->lock); - return 0; } /* --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -154,9 +154,9 @@ int btrfs_add_ordered_extent_dio(struct int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset, u64 start, u64 len, u64 disk_len, int type, int compress_type); -int btrfs_add_ordered_sum(struct inode *inode, - struct btrfs_ordered_extent *entry, - struct btrfs_ordered_sum *sum); +void btrfs_add_ordered_sum(struct inode *inode, + struct btrfs_ordered_extent *entry, + struct btrfs_ordered_sum *sum); struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, u64 file_offset); void btrfs_start_ordered_extent(struct inode *inode, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 94/99] btrfs: btrfs_free_fs_root should return void
btrfs_free_fs_root has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 3 +-- fs/btrfs/disk-io.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2733,7 +2733,7 @@ int write_ctree_super(struct btrfs_trans return ret; } -int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) +void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) { spin_lock(&fs_info->fs_roots_radix_lock); radix_tree_delete(&fs_info->fs_roots_radix, @@ -2746,7 +2746,6 @@ int btrfs_free_fs_root(struct btrfs_fs_i __btrfs_remove_free_space_cache(root->free_ino_pinned); __btrfs_remove_free_space_cache(root->free_ino_ctl); free_fs_root(root); - return 0; } static void free_fs_root(struct btrfs_root *root) --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -64,7 +64,7 @@ struct btrfs_root *btrfs_read_fs_root_no int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); -int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); +void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); void btrfs_mark_buffer_dirty(struct extent_buffer *buf); int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid); void btrfs_set_buffer_uptodate(struct extent_buffer *buf); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
del_fs_roots has no error conditions and should return void Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2764,7 +2764,7 @@ static void free_fs_root(struct btrfs_ro kfree(root); } -static int del_fs_roots(struct btrfs_fs_info *fs_info) +static void del_fs_roots(struct btrfs_fs_info *fs_info) { int ret; struct btrfs_root *gang[8]; @@ -2793,7 +2793,6 @@ static int del_fs_roots(struct btrfs_fs_ for (i = 0; i < ret; i++) btrfs_free_fs_root(fs_info, gang[i]); } - return 0; } int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 96/99] btrfs: btrfs_destroy_ordered_operations should return void
btrfs_destroy_ordered_operations has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -49,7 +49,7 @@ static void end_workqueue_fn(struct btrf static void free_fs_root(struct btrfs_root *root); static void btrfs_check_super_valid(struct btrfs_fs_info *fs_info, int read_only); -static int btrfs_destroy_ordered_operations(struct btrfs_root *root); +static void btrfs_destroy_ordered_operations(struct btrfs_root *root); static int btrfs_destroy_ordered_extents(struct btrfs_root *root); static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, struct btrfs_root *root); @@ -3129,7 +3129,7 @@ int btrfs_error_commit_super(struct btrf return ret; } -static int btrfs_destroy_ordered_operations(struct btrfs_root *root) +static void btrfs_destroy_ordered_operations(struct btrfs_root *root) { struct btrfs_inode *btrfs_inode; struct list_head splice; @@ -3151,8 +3151,6 @@ static int btrfs_destroy_ordered_operati spin_unlock(&root->fs_info->ordered_extent_lock); mutex_unlock(&root->fs_info->ordered_operations_mutex); - - return 0; } static int btrfs_destroy_ordered_extents(struct btrfs_root *root) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 97/99] btrfs: btrfs_destroy_ordered_extents should return void
btrfs_destroy_ordered_extents has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -50,7 +50,7 @@ static void free_fs_root(struct btrfs_ro static void btrfs_check_super_valid(struct btrfs_fs_info *fs_info, int read_only); static void btrfs_destroy_ordered_operations(struct btrfs_root *root); -static int btrfs_destroy_ordered_extents(struct btrfs_root *root); +static void btrfs_destroy_ordered_extents(struct btrfs_root *root); static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, struct btrfs_root *root); static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); @@ -3153,7 +3153,7 @@ static void btrfs_destroy_ordered_operat mutex_unlock(&root->fs_info->ordered_operations_mutex); } -static int btrfs_destroy_ordered_extents(struct btrfs_root *root) +static void btrfs_destroy_ordered_extents(struct btrfs_root *root) { struct list_head splice; struct btrfs_ordered_extent *ordered; @@ -3185,8 +3185,6 @@ static int btrfs_destroy_ordered_extents } spin_unlock(&root->fs_info->ordered_extent_lock); - - return 0; } static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 98/99] btrfs: btrfs_destroy_pending_snapshots should return void
btrfs_destroy_pending_snapshots has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -53,7 +53,7 @@ static void btrfs_destroy_ordered_operat static void btrfs_destroy_ordered_extents(struct btrfs_root *root); static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, struct btrfs_root *root); -static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); +static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root); static int btrfs_destroy_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, @@ -3239,7 +3239,7 @@ static int btrfs_destroy_delayed_refs(st return ret; } -static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t) +static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t) { struct btrfs_pending_snapshot *snapshot; struct list_head splice; @@ -3257,8 +3257,6 @@ static int btrfs_destroy_pending_snapsho kfree(snapshot); } - - return 0; } static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-24 00:37 UTC
[patch 99/99] btrfs: add_excluded_extent should return void
add_excluded_extent has no error conditions and should return void. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- fs/btrfs/extent-tree.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -206,15 +206,14 @@ block_group_cache_tree_search(struct btr return ret; } -static int add_excluded_extent(struct btrfs_root *root, - u64 start, u64 num_bytes) +static void add_excluded_extent(struct btrfs_root *root, + u64 start, u64 num_bytes) { u64 end = start + num_bytes - 1; set_extent_bits(&root->fs_info->freed_extents[0], start, end, EXTENT_UPTODATE); set_extent_bits(&root->fs_info->freed_extents[1], start, end, EXTENT_UPTODATE); - return 0; } static void free_excluded_extents(struct btrfs_root *root, @@ -242,9 +241,7 @@ static int exclude_super_stripes(struct if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) { stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid; cache->bytes_super += stripe_len; - ret = add_excluded_extent(root, cache->key.objectid, - stripe_len); - BUG_ON(ret); + add_excluded_extent(root, cache->key.objectid, stripe_len); } for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { @@ -256,9 +253,7 @@ static int exclude_super_stripes(struct while (nr--) { cache->bytes_super += stripe_len; - ret = add_excluded_extent(root, logical[nr], - stripe_len); - BUG_ON(ret); + add_excluded_extent(root, logical[nr], stripe_len); } kfree(logical); @@ -5789,8 +5784,7 @@ int btrfs_alloc_logged_file_extent(struc mutex_lock(&caching_ctl->mutex); if (start >= caching_ctl->progress) { - ret = add_excluded_extent(root, start, num_bytes); - BUG_ON(ret); + add_excluded_extent(root, start, num_bytes); } else if (start + num_bytes <= caching_ctl->progress) { ret = btrfs_remove_free_space(block_group, start, num_bytes); @@ -5804,8 +5798,7 @@ int btrfs_alloc_logged_file_extent(struc start = caching_ctl->progress; num_bytes = ins->objectid + ins->offset - caching_ctl->progress; - ret = add_excluded_extent(root, start, num_bytes); - BUG_ON(ret); + add_excluded_extent(root, start, num_bytes); } mutex_unlock(&caching_ctl->mutex); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Nov 23, 2011 at 07:35:34PM -0500, Jeff Mahoney wrote:> As part of the effort to eliminate BUG_ON as an error handling > technique, we need to determine which errors are actual logic errors, > which are on-disk corruption, and which are normal runtime errors > e.g. -ENOMEM. > > Annotating these error cases is helpful to understand and report them. > > This patch adds a btrfs_panic() routine that will either panic > or BUG depending on the new -ofatal_errors={panic,bug} mount option. > Since there are still so many BUG_ONs, it defaults to BUG for now but I > expect that to change once the error handling effort has made > significant progress.Any reason all of the commit text is indented in this series? David -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/23/2011 09:05 PM, David Brown wrote:> On Wed, Nov 23, 2011 at 07:35:34PM -0500, Jeff Mahoney wrote: >> As part of the effort to eliminate BUG_ON as an error handling >> technique, we need to determine which errors are actual logic >> errors, which are on-disk corruption, and which are normal >> runtime errors e.g. -ENOMEM. >> >> Annotating these error cases is helpful to understand and report >> them. >> >> This patch adds a btrfs_panic() routine that will either panic or >> BUG depending on the new -ofatal_errors={panic,bug} mount >> option. Since there are still so many BUG_ONs, it defaults to BUG >> for now but I expect that to change once the error handling >> effort has made significant progress. > > Any reason all of the commit text is indented in this series?Our internal patches have a bunch of RFC822-style headers associated with them. For me, indenting the body is a style thing. I like having the body appear separate from the headers. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOzapOAAoJEB57S2MheeWyiwcQAKEBdb94MUHYxGBWvRcOLrfI exj387YgPsNuXTRS8FjOW/3q4lIlt4F/35o8AqH8xJZFK4XcCX9/Mmz6HPlK9CfX uQqtL0rGLW0t3rziArddVJmdab7/5xjG7ZgiVkLNePhZS7mKitLf7MeZh7CAQ3UL ZyeG2NdkcY5jDkseY+kZbF9UKcpv4aGIetzSbej9GH/bvF6g3QB3d3BNqJ3opp+J rciqtN2ZKVS5uA82KkXGkjnPcAkQfyfOJgZKKTCc68oMjJZNbPp5Ovcum0XF9mZZ ZEfOc1kTogsBfB5wR/1lR4Q5HR8JT7YF61ZUceaF6pd420FZmn2HIX6Lphj2pU/a CR4lrie9Nb/F4Sc+iB1pHyc9r9VhvWb9pQiW1W7hdQl9XoVi2zp5reUEbEsQ7oX6 8SUQHxtm7eceqs8WO+d6XIKCyI3iXBVQ74QSsPjDHH0LvAa7zQcaNuQurvvpoqH3 5p5vTXjUQ2knwJpyccuzNuDKqg5+8kXKHo+tdojT6+8rtLnp7A6N0z7ctvqkaMmR 5L8a+GK15Sd910l1bJbTVagXbolYYCSaYC/ykByXNGEHeOwX2fcCmO4AK/40N4S6 /jdoliJb+Ku19SsSQnDPH1Xb3Mzf+6BDeEUZ9kl2OewtqNxfWpwOkNW/f5iDfBTw BCncwA37zJPDrhFE5cGg =A5RF -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Nov 23, 2011 at 09:22:06PM -0500, Jeff Mahoney wrote:>-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 11/23/2011 09:05 PM, David Brown wrote: >> On Wed, Nov 23, 2011 at 07:35:34PM -0500, Jeff Mahoney wrote: >>> As part of the effort to eliminate BUG_ON as an error handling >>> technique, we need to determine which errors are actual logic >>> errors, which are on-disk corruption, and which are normal >>> runtime errors e.g. -ENOMEM. >>> >>> Annotating these error cases is helpful to understand and report >>> them. >>> >>> This patch adds a btrfs_panic() routine that will either panic or >>> BUG depending on the new -ofatal_errors={panic,bug} mount >>> option. Since there are still so many BUG_ONs, it defaults to BUG >>> for now but I expect that to change once the error handling >>> effort has made significant progress. >> >> Any reason all of the commit text is indented in this series? > >Our internal patches have a bunch of RFC822-style headers associated >with them. For me, indenting the body is a style thing. I like having >the body appear separate from the headers.Probably best not to, it makes them inconsistent with the rest of the kernel''s history when imported into git. The body becomes the commit text directly. David -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2011-Nov-24 23:41 UTC
Re: [patch 03/99] btrfs: Panic on bad rbtree operations
On Wed, Nov 23, 2011 at 07:35:36PM -0500, Jeff Mahoney wrote:> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c > index a1c9404..5a53d94 100644 > --- a/fs/btrfs/ordered-data.c > +++ b/fs/btrfs/ordered-data.c > @@ -59,6 +59,14 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, > return NULL; > } > > +NORET_TYPE static void ordered_data_tree_panic(struct inode *inode, int errno, > + u64 offset) > +{ > + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb)->fs_info; > + btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at offset " > + "%llu\n", offset);^^^^ this will need a cast to (unsigned long long)> +} > + > /* > * look for a given offset in the tree, and if it can''t be found return the > * first lesser offset > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -326,6 +326,19 @@ static struct rb_node *tree_search(struct rb_root *root, u64 bytenr) > return NULL; > } > > +NORET_TYPE static void backref_tree_panic(struct rb_node *rb_node, int errno, > + u64 bytenr) > +{ > + > + struct btrfs_fs_info *fs_info = NULL; > + struct backref_node *bnode = rb_entry(rb_node, struct backref_node, > + rb_node); > + if (bnode->root) > + fs_info = bnode->root->fs_info; > + btrfs_panic(fs_info, errno, "Inconsistency in backref cache " > + "found at offset %llu\n", bytenr);same here> +} > +-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2011-Nov-24 23:57 UTC
Re: [patch 13/99] btrfs: clear_extent_uptodate can drop gfp_t argumetn
Subject: Re: [patch 13/99] btrfs: clear_extent_uptodate can drop gfp_t argumetn typo in subject s/argumetn/argument/, same in the next 2 patches -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2011-Nov-25 00:46 UTC
Re: [patch 65/99] btrfs: ->submit_bio_hook error push-up
On Wed, Nov 23, 2011 at 07:36:38PM -0500, Jeff Mahoney wrote:> --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -2752,10 +2759,12 @@ retry: > static void flush_epd_write_bio(struct extent_page_data *epd) > { > if (epd->bio) { > + int ret; > if (epd->sync_io) > - submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); > + ret = submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); > else > - submit_one_bio(WRITE, epd->bio, 0, 0); > + ret = submit_one_bio(WRITE, epd->bio, 0, 0); > + BUG_ON(ret < 0);this if/else could be transfomed in the same way as in "63/99 btrfs: Simplify btrfs_submit_bio_hook" int rw = WRITE; if (epd->sync_io) rw = WRITE_SYNC; ret = submit_one_bio(rw, ...); -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-25 02:13 UTC
Re: [patch 03/99] btrfs: Panic on bad rbtree operations
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/24/2011 06:41 PM, David Sterba wrote:> On Wed, Nov 23, 2011 at 07:35:36PM -0500, Jeff Mahoney wrote: >> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c >> index a1c9404..5a53d94 100644 --- a/fs/btrfs/ordered-data.c +++ >> b/fs/btrfs/ordered-data.c @@ -59,6 +59,14 @@ static struct >> rb_node *tree_insert(struct rb_root *root, u64 file_offset, >> return NULL; } >> >> +NORET_TYPE static void ordered_data_tree_panic(struct inode >> *inode, int errno, + u64 offset) +{ + struct >> btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb)->fs_info; + >> btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at >> offset " + "%llu\n", offset); > ^^^^ this will need a cast to (unsigned long long) > >> +} + /* * look for a given offset in the tree, and if it can''t be >> found return the * first lesser offset --- >> a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -326,6 >> +326,19 @@ static struct rb_node *tree_search(struct rb_root >> *root, u64 bytenr) return NULL; } >> >> +NORET_TYPE static void backref_tree_panic(struct rb_node >> *rb_node, int errno, + u64 bytenr) +{ + + struct >> btrfs_fs_info *fs_info = NULL; + struct backref_node *bnode >> rb_entry(rb_node, struct backref_node, + rb_node); + if >> (bnode->root) + fs_info = bnode->root->fs_info; + >> btrfs_panic(fs_info, errno, "Inconsistency in backref cache " + >> "found at offset %llu\n", bytenr); > > same here > >> +} + >Thanks. Fixed. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOzvm5AAoJEB57S2MheeWyQfcQAJXzeVYbLwLoJ0EqUSZBRzSZ L5s4qWNTgdf6XVl4ZE8WgDJNDq1gMbdsjCug40QtQR8/f9btqbcz7oPnNeQDgfD8 PxZCiarOsm4fAiWDkchm/JDah9YTQCRzvV7Pg/362FnJJl7+a2muecvEMuXXgPdD otE5BgYz7mJ5imZxpg3JnGwGXUhSiQD4tsprorY8A5I64QUSfGDBkdHNqRe2sVWn PdN95UZb1z1wz3KZokslczJFsiOQkiOGurvnO+2J8L/+HH6pItKymT7j2F9q3EzQ vtFP7tFFINfgdJUJyhpDRanhETfuAfwAuSqKVDFmujsPM38zdglSk3nXhh6yIucz k067pYzHBA2gSJ2ZjRUgMlSMfcbiiYLuXhgFSMZosemoKBpn9RNW8hfxvX3kvBuh w+oPmaOobRnwQV+ImPQlug2k7a1XpZUbrnJHoflbzEs2APrsmL863B4xHhb8vp+C 7SnlbGmW1Fk2vmsDfTWZHz7/Eb8atTZSdz3m/8lO6S420oBJ3xh7NIWq3sQLUnvg +kDUfn3FjSRUwq4J/ETAf8fxarCuhDLpUo9MU11oaJ2qz50QUQI5W21bgrvBhbq7 fkQTZoAGirBIK3KIeV1cqeVDFkc5WilOc/moECX1Vicf1TUaUYe/A+Jko+6ObE5K RH+fOkuY34cb34ccxV9r =jxMY -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-25 02:14 UTC
Re: [patch 13/99] btrfs: clear_extent_uptodate can drop gfp_t argumetn
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/24/2011 06:57 PM, David Sterba wrote:> Subject: Re: [patch 13/99] btrfs: clear_extent_uptodate can drop > gfp_t argumetn > > typo in subject s/argumetn/argument/, same in the next 2 patches >Thanks. Fixed. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOzvoIAAoJEB57S2MheeWyQAUP/1bGJ04fHNzRGtscLj88YAHx 95AaqQUlf78kXT9nhX3VJIHF/SrQDbZ3wuHa4kXRTrvRivsRbRF+5S5UgANygtaG rCt+RgP5ZcK2W69gVJWMjcfWGSTn+o6GztDdTHueVzJz2ACemKZmrcrnOBp3Lbco FbhrB8KwzN+TLWF3uoZKtnrOgItVicischl8yJjik1rMhxGApPoFvEfmRXrHeyWA jo5zaLyE08VXw0BNT5SXxknVzgf5vjHAERVf+iiHj3kAFEM/A2iV10B/JtxKaE1r qEY+GZdKJ1ur8CsQggqYE/0adfzHdkIXFO22KyO2XhRtpmfh387azEhc3tA8JptR tCjp90od4ZnWHb+te2BcKgluNoZ1scxoB7R8mHCYSpjCBKeVtSGq1TevfC0l+GHp 7X5uO8PX8DbEiqboLdmqxhJjxdNX2jtH+9o2hgoUEPDfteDcwZ8oA2px7yT6wQXl TaiYmYxZCL2S656l6ylAwSxcZqPO910BbqsHGNntsKAZ0mJ1fRqj5Zzzlyl4fgqx TnOyG8YKP5GmQlA50naBY2V5Om3Ge3rEXxUbjPU9hhaJZPL4DnWvwgJ6PNKcZST+ lOkelnz+5mZX2dj1OhjQQQCKpXufk/I+TGKQ84VGn2oUtHePfIxr3Y6+BBOIl8BQ o1Ysr+N5VpMhY7GejIbT =Q/Yt -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-25 02:17 UTC
Re: [patch 65/99] btrfs: ->submit_bio_hook error push-up
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/24/2011 07:46 PM, David Sterba wrote:> On Wed, Nov 23, 2011 at 07:36:38PM -0500, Jeff Mahoney wrote: >> --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2752,10 >> +2759,12 @@ retry: static void flush_epd_write_bio(struct >> extent_page_data *epd) { if (epd->bio) { + int ret; if >> (epd->sync_io) - submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); + >> ret = submit_one_bio(WRITE_SYNC, epd->bio, 0, 0); else - >> submit_one_bio(WRITE, epd->bio, 0, 0); + ret >> submit_one_bio(WRITE, epd->bio, 0, 0); + BUG_ON(ret < 0); > > this if/else could be transfomed in the same way as in > > "63/99 btrfs: Simplify btrfs_submit_bio_hook" > > int rw = WRITE; > > if (epd->sync_io) rw = WRITE_SYNC; > > ret = submit_one_bio(rw, ...); >Yep. Thanks. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOzvrJAAoJEB57S2MheeWykzkP/R1hl05O57yxOTQXtYuJhvUF RtL6RDD9nw/9QMWFHUXKFvaWtkuygi5BlcLKdXK0Zmsyk+hd7tzv8YfD1uLS2XS0 gioapvFNEmR6aRh1mMk6fJ429LiFgUrGGrCYQ28VTAgbe/RvMGedLAD6oqps5OJj dsCkyUCBxl7ta6cFRlR37gj+rzKwDTEjRz3E2gx8oBjJWA/zXIoInBA+gEC1P3qn YfmWyt31JwyOD3Oa2NQoCZGS7+MzotSe0RvAHbt5jc/DUDgJe+avv8Q5o4Bd2A7N DAlAty/G8k9rUtEUOp53BclZdq2pDQ5hV/EEDMp743+Y5BoKTmpmXV1p4k7oVhvu yOLTdYFtAo45c1pEeEzHm2GiowbdOemkmW3ySoFV8afRIVqkdgOfKMoUg6/c4B+o StaAtihxBwSjZbmWSOtlwr8vHkqDK332nh5I6WF9OBcgEI4ZuH6GnmP2NEC5G9aj 03MFyyJuq53FBmM1CRHE94zc299ZwRxOxIkcSffR9Fm8ANXHlrELfXbVbkmWQf3e bKs2skbAQmqbZE7yPbEHuN5vTElgP+MC56FBuVvJ+Lz4NO7HVV4KdfJKiM7J2QzA qRsITdnnesKCfpkQTz4ShHZh+O3Y5ZgeP/wBNa9pK2+SZxA0HL3t8RaC/q/yjpYm PBOaqH8nwVot+RBwI/Pv =/8rB -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/24/2011 01:37 AM, David Brown wrote:> On Wed, Nov 23, 2011 at 09:22:06PM -0500, Jeff Mahoney wrote: >> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >> >> On 11/23/2011 09:05 PM, David Brown wrote: >>> On Wed, Nov 23, 2011 at 07:35:34PM -0500, Jeff Mahoney wrote: >>>> As part of the effort to eliminate BUG_ON as an error >>>> handling technique, we need to determine which errors are >>>> actual logic errors, which are on-disk corruption, and which >>>> are normal runtime errors e.g. -ENOMEM. >>>> >>>> Annotating these error cases is helpful to understand and >>>> report them. >>>> >>>> This patch adds a btrfs_panic() routine that will either >>>> panic or BUG depending on the new -ofatal_errors={panic,bug} >>>> mount option. Since there are still so many BUG_ONs, it >>>> defaults to BUG for now but I expect that to change once the >>>> error handling effort has made significant progress. >>> >>> Any reason all of the commit text is indented in this series? >> >> Our internal patches have a bunch of RFC822-style headers >> associated with them. For me, indenting the body is a style >> thing. I like having the body appear separate from the headers. > > Probably best not to, it makes them inconsistent with the rest of > the kernel''s history when imported into git. The body becomes the > commit text directly.I''ll change them to do this since you''re obviously correct. You''re the first person in 10+ years to notice (or at least comment on) it, though. ;) - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOzv9HAAoJEB57S2MheeWyTgsP+wUEW1gJkxyvuVymaL2qTXkz ZFDzEIjzmb5x3/jt48yx+iD6ElshVUGYAimoeNkurBVPpi4lJ0n9ydpNm67To/cx K9u2/5ld0/Ua+s8uTXjBxDQG/WSOPRk8pc3Y4gIIWyDn+dYQAUb5SvDc6/qWS0BS aQT0faX1FO3g+Hp6ZbLbYgXa/5rqrm0L9Ek13f7bq6T8l3wzDlsgWnS8KtYhwnpr 4rPAU5eythJYj9OGMB34/YoOeDs61tJbbvvNW6TysdiEEdzqf6UQ1EF61r9G41aW wXsA4f8oSYsM2t97eH5fGrk+0j2sXPf6CoxIG73DU51L3X4htY4fPc1SQyz0SwSR t7CKt+ffT/oa9nCXuHsfwXZBCpDdIRFiVXgibL/rBX9akWXt61W9jZnZXISOU3QZ kTOl9VaNAKCWfOMDbKq40cKbYANE16zQ37aXaWMilagsVHCkJH47HJJ17h0IlFqy n+zu7++/iPYwclVxCEs/bUr4XyCxSDrqRsUM8s68u7BoZP3EWrmhtMmH11XXkg8e iznttk4/lU8Chg0+yoS03tOQquOa3+y7rYgbq9r2h35f2tv1N+s4me8iO+hSJXwO 0vS7Akvf9n8583jd/y8F3UTl1G7obKAN7ooNURewHo0AzsmNVkK9FyK9SY07I1eS w/Zu4uB9dQPxCqM5I5fm =ZhyI -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Nov 24, 2011 at 09:36:55PM -0500, Jeff Mahoney wrote:>> Probably best not to, it makes them inconsistent with the rest of >> the kernel''s history when imported into git. The body becomes the >> commit text directly. > >I''ll change them to do this since you''re obviously correct. You''re the >first person in 10+ years to notice (or at least comment on) it, >though. ;)Some maintainers (and Linus as well) appears to have just fixed them up when applying the patches. David -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Andi Kleen
2011-Nov-28 23:53 UTC
Re: [patch 07/99] btrfs: Use mempools for extent_state structures
Jeff Mahoney <jeffm@suse.com> writes:> The extent_state structure is used at the core of the extent i/o code > for managing flags, locking, etc. It requires allocations deep in the > write code and if failures occur they are difficult to recover from. > > We avoid most of the failures by using a mempool, which can sleep when > required, to honor the allocations. This allows future patches to convert > most of the {set,clear,convert}_extent_bit and derivatives to return > void.Is this really safe? iirc if there''s any operation that needs multiple mempool objects you can get into the following ABBA style deadlock: thread 1 thread 2 get object A from pool 1 get object C from pool 2 get object B from pool 2 pool 2 full -> block get object D from pool 2 pool1 full -> block Now for thread 1 to make progress it needs thread 2 to free its object first, but that needs thread 1 to free its object also first, which is a deadlock. It would still work if there are other users which eventually make progress, but if you''re really unlucky either pool 1 or 2 is complete used by threads doing a multiple object operation. So you got a nasty rare deadlock ... The only way to handle this would be to always preallocate all objects needed for a operation in an atomic way. Or never use more than one object. -Andi -- ak@linux.intel.com -- Speaking for myself only -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Nov-29 00:04 UTC
Re: [patch 07/99] btrfs: Use mempools for extent_state structures
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/28/2011 06:53 PM, Andi Kleen wrote:> Jeff Mahoney <jeffm@suse.com> writes: > >> The extent_state structure is used at the core of the extent i/o >> code for managing flags, locking, etc. It requires allocations >> deep in the write code and if failures occur they are difficult >> to recover from. >> >> We avoid most of the failures by using a mempool, which can sleep >> when required, to honor the allocations. This allows future >> patches to convert most of the {set,clear,convert}_extent_bit and >> derivatives to return void. > > Is this really safe? > > iirc if there''s any operation that needs multiple mempool objects > you can get into the following ABBA style deadlock: > > thread 1 thread 2 > > get object A from pool 1 get object C from pool 2 get object B from > pool 2 pool 2 full -> block get object D from pool 2^ pool1, i assume> pool1 full -> block > > > Now for thread 1 to make progress it needs thread 2 to free its > object first, but that needs thread 1 to free its object also > first, which is a deadlock. > > It would still work if there are other users which eventually make > progress, but if you''re really unlucky either pool 1 or 2 is > complete used by threads doing a multiple object operation. So you > got a nasty rare deadlock ...Yes, I think you''re right. I think the risk is probably there and I''m not sure it can be totally mitigated. We''d be stuck if there is a string of pathological cases and both mempool are empty. The only way I can see to try to help the situation is to make the mempool fairly substantial, which is what I did here. I''d prefer to make the mempools per-fs but that would require pretty heavy modifications in order to pass around a per-fs struct. In any case, the risk isn''t totally eliminated.> The only way to handle this would be to always preallocate all > objects needed for a operation in an atomic way.This was how I wanted to do it at first but I couldn''t see a way to make it work in a manner that wouldn''t kill performance since the calculations effectively need to be done twice and are pretty common. The other issue is that operations can be pretty complex and preallocating for all cases will either be really wasteful or really error prone.> Or never use more than one object.I need to do some analysis here to see if that is even possible. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIbBAEBAgAGBQJO1CFxAAoJEB57S2MheeWyL1EP+Pd+c1hodWEA6StTnE1pG+Tl u5Rg+VBmN8AdcfdOzvyoyfZgPaCxtHzaJVX2y3PzHtY1INEMp2EoijaL1X9afKQF lJP1BmpIARARMrQrYbqvZrl+DGUeIwIhC2LBuNffYifbMAn3KdTLRhkvcGehTmQO Vik1bgmo6ZKjAIP/FLViGdB4hITITwHtT7n4bDyZ9ATgqgq5sGUWnw7f0sILeBqR NOt8QVgaCmzZIF5foUr2UsBBxjo0joiW2V7YWs4roJeCtDx+6mwyRifQFTGuN2xi 1CVTnTT+FYXkD8IB6mKNHptIDLu7q29RaikSFsgV684IYAp510OBStgBuCpBeeNc Xd77XJkf9UCYSXWs1j587MnOqaeV818OqvwxHAGZnavBHZ/+8AFOJ77GAVaP1Xlm M6gYP1TXjL0yjJEWNVtP0kBjimKUFw5ECv86DCQllRTY/5oWmAxjyJviEzVgJBiM EDtzf17APyiTSWawRZlDc6a46kG2Jm6QiNmx4MyAlSFu81Qv0EDOpC4TAwiRDZKa KLjaW10TKcC5TDwZXcOBiF/PrpvBCvJjd0N3sCFVD0Tn0cdqME9BuFUP1hI1ku+T L5VyzHsp07ndCk+H6gGWkCZzEtSSyWFG4gHkFcV7z/IF5bPpsyxcxdGXGzBGbYUh 9NdrCz5lMb49VTBBSaY=ZXGi -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Dec-01 19:55 UTC
Re: [patch 07/99] btrfs: Use mempools for extent_state structures
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/28/2011 07:04 PM, Jeff Mahoney wrote:> On 11/28/2011 06:53 PM, Andi Kleen wrote: >> Jeff Mahoney <jeffm@suse.com> writes: > >>> The extent_state structure is used at the core of the extent >>> i/o code for managing flags, locking, etc. It requires >>> allocations deep in the write code and if failures occur they >>> are difficult to recover from. >>> >>> We avoid most of the failures by using a mempool, which can >>> sleep when required, to honor the allocations. This allows >>> future patches to convert most of the >>> {set,clear,convert}_extent_bit and derivatives to return void. > >> Is this really safe? > >> iirc if there''s any operation that needs multiple mempool >> objects you can get into the following ABBA style deadlock: > >> thread 1 thread 2 > >> get object A from pool 1 get object C from pool 2 get object B >> from pool 2 pool 2 full -> block get object D from pool 2 > ^ pool1, i assume >> pool1 full -> block > > >> Now for thread 1 to make progress it needs thread 2 to free its >> object first, but that needs thread 1 to free its object also >> first, which is a deadlock. > >> It would still work if there are other users which eventually >> make progress, but if you''re really unlucky either pool 1 or 2 >> is complete used by threads doing a multiple object operation. So >> you got a nasty rare deadlock ... > > Yes, I think you''re right. I think the risk is probably there and > I''m not sure it can be totally mitigated. We''d be stuck if there is > a string of pathological cases and both mempool are empty. The only > way I can see to try to help the situation is to make the mempool > fairly substantial, which is what I did here. I''d prefer to make > the mempools per-fs but that would require pretty heavy > modifications in order to pass around a per-fs struct. In any case, > the risk isn''t totally eliminated.The more I look into it, the more I don''t think this is an uncommon scenario in the kernel. Device mapper draws from a number of mempools that can be interspersed with allocations from the bio pool. Even without stacking different types of dm devices, I think we can run into this scenario. The DM scenario is probably even worse since the allocs are GFP_NOIO instead of the (relatively) more relaxed GFP_NOFS. I''m not saying it''s ok, just that there are similar sites already that seem to be easier to hit but we haven''t heard of issues there either. It seems to be a behavior that is largely mitigated by establishing mempools of sufficient size. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJO19ueAAoJEB57S2MheeWyDb4QAKZ3T9JGTXZN9MikO0Q8aH08 KE0X4NSnagn/goS/88+6Hj9Z165gQ3ERUaoW4+VsdpLOAaJuNo4YtMShoN7pgC9X HeaddX1cQb8aducWPt9o7sglkpERJHzdSNKO4rJaYQbJLZFBQ1KLQEISRjS1ZAiu 74Y/t3tESiJO8W5XV1b06pythUKG4sLPK8+ssBvpYt+qrfhfp//dse/sKPE3L1k5 zHP0GIePRazhkE9RUB8+5rjItUR7MSvECJviCKKhxyY/TsQRm4g27AhbL717Ew/9 V3LyyZe5ojhXWNDyaCeLUu4j/xOcYVftkxuQLHcVltTDaAzxCkaRBnzxoz5nouc+ SusUzVYy/aR14QyNbtFpfJVAB3E9djXsaA3EZO2ar+NPeBch28LEJRfC8hoItej3 O39PAFpviYRSHa12GDIqJ0x3q9auTeU5DRPt3gnpstT26t4vICkFn4B/cp9EzpQI G1Gm09ftkehpSdBiFFSBXCpPg/7qTAMPnaF1Yq3ueQoWbAqVEtnPnaWQLfH4IBBj 5fp6ei0/zAS2qr1iBKZnWUKJKCIAyvCkEeLusTcLymFzLzVMpywYWchU+EW0AZ5G 98tx8Dgzi77ImHG4uF9uWuNJ80G7iR+nGgE+8dKIoEKLETHdoQMRgTCc05o9tTHM Gk0GUwRESn97r/ytUm8n =zdAv -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Mahoney
2011-Dec-03 04:53 UTC
Re: [patch 07/99] btrfs: Use mempools for extent_state structures
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/01/2011 02:55 PM, Jeff Mahoney wrote:> On 11/28/2011 07:04 PM, Jeff Mahoney wrote: >> On 11/28/2011 06:53 PM, Andi Kleen wrote: >>> Jeff Mahoney <jeffm@suse.com> writes: > >>>> The extent_state structure is used at the core of the extent >>>> i/o code for managing flags, locking, etc. It requires >>>> allocations deep in the write code and if failures occur >>>> they are difficult to recover from. >>>> >>>> We avoid most of the failures by using a mempool, which can >>>> sleep when required, to honor the allocations. This allows >>>> future patches to convert most of the >>>> {set,clear,convert}_extent_bit and derivatives to return >>>> void. > >>> Is this really safe? > >>> iirc if there''s any operation that needs multiple mempool >>> objects you can get into the following ABBA style deadlock: > >>> thread 1 thread 2 > >>> get object A from pool 1 get object C from pool 2 get object B >>> from pool 2 pool 2 full -> block get object D from pool 2 >> ^ pool1, i assume >>> pool1 full -> block > > >>> Now for thread 1 to make progress it needs thread 2 to free its >>> object first, but that needs thread 1 to free its object also >>> first, which is a deadlock. > >>> It would still work if there are other users which eventually >>> make progress, but if you''re really unlucky either pool 1 or 2 >>> is complete used by threads doing a multiple object operation. >>> So you got a nasty rare deadlock ... > >> Yes, I think you''re right. I think the risk is probably there >> and I''m not sure it can be totally mitigated. We''d be stuck if >> there is a string of pathological cases and both mempool are >> empty. The only way I can see to try to help the situation is to >> make the mempool fairly substantial, which is what I did here. >> I''d prefer to make the mempools per-fs but that would require >> pretty heavy modifications in order to pass around a per-fs >> struct. In any case, the risk isn''t totally eliminated. > > The more I look into it, the more I don''t think this is an > uncommon scenario in the kernel. Device mapper draws from a number > of mempools that can be interspersed with allocations from the bio > pool. Even without stacking different types of dm devices, I think > we can run into this scenario. The DM scenario is probably even > worse since the allocs are GFP_NOIO instead of the (relatively) > more relaxed GFP_NOFS. > > I''m not saying it''s ok, just that there are similar sites already > that seem to be easier to hit but we haven''t heard of issues there > either. It seems to be a behavior that is largely mitigated by > establishing mempools of sufficient size.... and the next installment: My understanding of mempools is inaccurate and the pathological case can be hit much more quickly than I anticipated, or at least have a performance impact I''d rather not see. It turns out that the pool will be depleted *before* the other pathological cases are hit. In fact, the pool is hit before reclaim starts at all. Rather than: normal alloc with gfp_t (normal alloc fails after trying reclaim) pool alloc (pool alloc fails) (wait, timeout, retry) it is: normal alloc with gfp_t & ~(__GFP_WAIT|__GFP_IO) (which is GFP_NOFS & ~GFP_NOFS for the common case) .. so: normal alloc with GFP_NOWAIT (normal alloc fails) (much more often) pool alloc (pool alloc fails) ((wait until an object is freed or timeout) and retry with GFP_NOFS) So, using mempools for all cases as I''d hoped isn''t what I want. I''ll work up another set of patches that use a straight kmem_cache_alloc where possible. The good news is that slab-backed mempools can be replenished with objects from the slab that weren''t allocated from the pool. So there''s that. - -Jeff - -- Jeff Mahoney SUSE Labs -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJO2atEAAoJEB57S2MheeWy2CYP/iix4znJVqBkN8wUg31MELGB UpodfZkwlhrD/8PfJrisjA1wLLKpK5GzJ0m6rhKCYvkBau28yCSAWGW9sJIfGM0I 4fLAoupncoJqmYyQvrZIczxztDVwMu37bL7fNfCkC64HoaETChQbaDbrwu+L8Rn2 Lls7EtkUNWrpY+J4F0zq9b8eE46WjbpZBKhI/PuqAE0LfSXK8nd46Z5qA/MM7fab tFftC0AyBLP2dq8R0H1IX0yjri6YD0xwwfdHdbzVAoJ/tINVbfiQxntYyONgNnBF 6sNogCtcskpTSDHZyVK7ATuJJL6ZAIFO0ZUJjZYFc+q0q1oYMfmbhNs9Qq5le7bZ Ig6pcMgHqGOqkis95jqzgStl2A1OIYPZsn6K1329N44fvZ8PjxDVCHS83FzBY0qw YuEgBNd8vRrdjtcMax2QOs9yaSmvEXDkws1+tLWg/ZV0Ik8crbW0ctVqsyDpWwPN 2dSyrlxGbAJyXzELUg498dLORw+chHokUhsEvwYEmL1HGLsZGFoXAV3H5df4v6Mx wsKZeT+Nsp16CyYOXVCAWGRyp6FPDWECJAUxygjyEaIGWmiJjMKU1GizL9J4fgc+ 59fantrAMbFwPpRwJxfHumCdnQOi55qtrcP1UvCB3o9jBH4QsUofP4sGQsIAw4oQ ctuvtI1R7zcub0906BwP =h+a2 -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html