Josef Bacik
2013-Jul-01 13:30 UTC
[PATCH] Btrfs: make tree_mod_alloc return the struct its allocating
Lets try and be consistent with every other alloc() type function. Signed-off-by: Josef Bacik <jbacik@fusionio.com> --- fs/btrfs/ctree.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 7921e1d..32e30ad 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -544,8 +544,8 @@ static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info, * Returns <0 on error. * Returns >0 (the added sequence number) on success. */ -static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags, - struct tree_mod_elem **tm_ret) +static inline struct tree_mod_elem * +tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags) { struct tree_mod_elem *tm; @@ -555,13 +555,13 @@ static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags, */ tm = *tm_ret = kzalloc(sizeof(*tm), GFP_ATOMIC); if (!tm) - return -ENOMEM; + return NULL; spin_lock(&fs_info->tree_mod_seq_lock); tm->seq = btrfs_inc_tree_mod_seq_minor(fs_info); spin_unlock(&fs_info->tree_mod_seq_lock); - return tm->seq; + return tm; } static inline int @@ -572,9 +572,9 @@ __tree_mod_log_insert_key(struct btrfs_fs_info *fs_info, int ret; struct tree_mod_elem *tm; - ret = tree_mod_alloc(fs_info, flags, &tm); - if (ret < 0) - return ret; + tm = tree_mod_alloc(fs_info, flags); + if (!tm) + return -ENOMEM; tm->index = eb->start >> PAGE_CACHE_SHIFT; if (op != MOD_LOG_KEY_ADD) { @@ -642,9 +642,11 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info, BUG_ON(ret < 0); } - ret = tree_mod_alloc(fs_info, flags, &tm); - if (ret < 0) + tm = tree_mod_alloc(fs_info, flags); + if (!tm) { + ret = -ENOMEM; goto out; + } tm->index = eb->start >> PAGE_CACHE_SHIFT; tm->slot = src_slot; @@ -691,9 +693,11 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info, if (log_removal) __tree_mod_log_free_eb(fs_info, old_root); - ret = tree_mod_alloc(fs_info, flags, &tm); - if (ret < 0) + tm = tree_mod_alloc(fs_info, flags); + if (!tm) { + ret = -ENOMEM; goto out; + } tm->index = new_root->start >> PAGE_CACHE_SHIFT; tm->old_root.logical = old_root->start; -- 1.7.7.6 -- 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
Josef Bacik
2013-Jul-01 13:40 UTC
Re: [PATCH] Btrfs: make tree_mod_alloc return the struct its allocating
On Mon, Jul 01, 2013 at 09:30:43AM -0400, Josef Bacik wrote:> Lets try and be consistent with every other alloc() type function. > > Signed-off-by: Josef Bacik <jbacik@fusionio.com>Ignore this, I didn''t compile it and I should have, and I''m just going to delete this function anyway. Thanks, Josef -- 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