struct btrfs_free_space *bitmap_info);
 static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
                              struct btrfs_free_space *info, u64 offset,
-                             u64 bytes);
+                             u64 bytes, bool update_stats);
 
 static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
                                               struct btrfs_path *path,
                                                           bytes);
                                if (ret)
                                        break;
-                               bitmap_clear_bits(ctl, info, offset, bytes);
+                               bitmap_clear_bits(ctl, info, offset, bytes, true);
                                offset = info->offset;
                                bytes = ctl->unit;
                        }
        rb_add_cached(&info->bytes_index, &ctl->free_space_bytes, entry_less);
 }
 
-static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
-                                      struct btrfs_free_space *info,
-                                      u64 offset, u64 bytes)
+static inline void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
+                                    struct btrfs_free_space *info,
+                                    u64 offset, u64 bytes, bool update_stat)
 {
        unsigned long start, count, end;
        int extent_delta = -1;
                ctl->discardable_extents[BTRFS_STAT_CURR] += extent_delta;
                ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
        }
-}
 
-static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
-                             struct btrfs_free_space *info, u64 offset,
-                             u64 bytes)
-{
-       __bitmap_clear_bits(ctl, info, offset, bytes);
-       ctl->free_space -= bytes;
+       if (update_stat)
+               ctl->free_space -= bytes;
 }
 
 static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl,
        /* Cannot clear past the end of the bitmap */
        search_bytes = min(search_bytes, end - search_start + 1);
 
-       bitmap_clear_bits(ctl, bitmap_info, search_start, search_bytes);
+       bitmap_clear_bits(ctl, bitmap_info, search_start, search_bytes, true);
        *offset += search_bytes;
        *bytes -= search_bytes;
 
        if (!btrfs_free_space_trimmed(bitmap))
                info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
 
-       if (update_stat)
-               bitmap_clear_bits(ctl, bitmap, end, bytes);
-       else
-               __bitmap_clear_bits(ctl, bitmap, end, bytes);
+       bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat);
 
        if (!bitmap->bytes)
                free_bitmap(ctl, bitmap);
        if (!btrfs_free_space_trimmed(bitmap))
                info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
 
-       if (update_stat)
-               bitmap_clear_bits(ctl, bitmap, info->offset, bytes);
-       else
-               __bitmap_clear_bits(ctl, bitmap, info->offset, bytes);
+       bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat);
 
        if (!bitmap->bytes)
                free_bitmap(ctl, bitmap);
 
        ret = offset;
        if (entry->bitmap) {
-               bitmap_clear_bits(ctl, entry, offset, bytes);
+               bitmap_clear_bits(ctl, entry, offset, bytes, true);
 
                if (!btrfs_free_space_trimmed(entry))
                        atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
        }
 
        ret = search_start;
-       __bitmap_clear_bits(ctl, entry, ret, bytes);
+       bitmap_clear_bits(ctl, entry, ret, bytes, false);
 
        return ret;
 }
                    bytes > (max_discard_size + minlen))
                        bytes = max_discard_size;
 
-               bitmap_clear_bits(ctl, entry, start, bytes);
+               bitmap_clear_bits(ctl, entry, start, bytes, true);
                if (entry->bytes == 0)
                        free_bitmap(ctl, entry);