Commit e9b7fd4d authored by Jan Schmidt's avatar Jan Schmidt

Btrfs: add tree_mod_dont_log helper

Replace duplicate code by small inline helper function.
Signed-off-by: default avatarJan Schmidt <list.btrfs@jan-o-sch.net>
parent 926dd8a6
...@@ -455,14 +455,25 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm) ...@@ -455,14 +455,25 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
return ret; return ret;
} }
static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
struct extent_buffer *eb) {
smp_mb();
if (list_empty(&(fs_info)->tree_mod_seq_list))
return 1;
if (!eb)
return 0;
if (btrfs_header_level(eb) == 0)
return 1;
return 0;
}
static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags, static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
struct tree_mod_elem **tm_ret) struct tree_mod_elem **tm_ret)
{ {
struct tree_mod_elem *tm; struct tree_mod_elem *tm;
int seq; int seq;
smp_mb(); if (tree_mod_dont_log(fs_info, NULL))
if (list_empty(&fs_info->tree_mod_seq_list))
return 0; return 0;
tm = *tm_ret = kzalloc(sizeof(*tm), flags); tm = *tm_ret = kzalloc(sizeof(*tm), flags);
...@@ -643,8 +654,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst, ...@@ -643,8 +654,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst,
int ret; int ret;
int i; int i;
smp_mb(); if (tree_mod_dont_log(fs_info, NULL))
if (list_empty(&fs_info->tree_mod_seq_list))
return; return;
if (btrfs_header_level(dst) == 0 && btrfs_header_level(src) == 0) if (btrfs_header_level(dst) == 0 && btrfs_header_level(src) == 0)
...@@ -691,11 +701,7 @@ static void tree_mod_log_free_eb(struct btrfs_fs_info *fs_info, ...@@ -691,11 +701,7 @@ static void tree_mod_log_free_eb(struct btrfs_fs_info *fs_info,
int ret; int ret;
u32 nritems; u32 nritems;
smp_mb(); if (tree_mod_dont_log(fs_info, eb))
if (list_empty(&fs_info->tree_mod_seq_list))
return;
if (btrfs_header_level(eb) == 0)
return; return;
nritems = btrfs_header_nritems(eb); nritems = btrfs_header_nritems(eb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment