@@ -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;
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(-)