diff options
author | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-31 14:59:09 +0200 |
---|---|---|
committer | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-31 19:56:18 +0200 |
commit | e9b7fd4d8b7c915cff353ca085b83bd19737396b (patch) | |
tree | 44cb78d1d1a5d677b0c01fd082554150a2f0ce20 /fs | |
parent | 926dd8a640da1bbf7478eebea1c23a842fc9c890 (diff) | |
download | linux-3.10-e9b7fd4d8b7c915cff353ca085b83bd19737396b.tar.gz linux-3.10-e9b7fd4d8b7c915cff353ca085b83bd19737396b.tar.bz2 linux-3.10-e9b7fd4d8b7c915cff353ca085b83bd19737396b.zip |
Btrfs: add tree_mod_dont_log helper
Replace duplicate code by small inline helper function.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 26e8dc1681b..c7c48489b96 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -455,14 +455,25 @@ unlock: 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, struct tree_mod_elem **tm_ret) { struct tree_mod_elem *tm; int seq; - smp_mb(); - if (list_empty(&fs_info->tree_mod_seq_list)) + if (tree_mod_dont_log(fs_info, NULL)) return 0; 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, int ret; int i; - smp_mb(); - if (list_empty(&fs_info->tree_mod_seq_list)) + if (tree_mod_dont_log(fs_info, NULL)) return; 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, int ret; u32 nritems; - smp_mb(); - if (list_empty(&fs_info->tree_mod_seq_list)) - return; - - if (btrfs_header_level(eb) == 0) + if (tree_mod_dont_log(fs_info, eb)) return; nritems = btrfs_header_nritems(eb); |