}
 }
 
-static int should_alloc_chunk(const struct btrfs_fs_info *fs_info,
-                             const struct btrfs_space_info *sinfo, int force)
+static bool should_alloc_chunk(const struct btrfs_fs_info *fs_info,
+                              const struct btrfs_space_info *sinfo, int force)
 {
        u64 bytes_used = btrfs_space_info_used(sinfo, false);
        u64 thresh;
 
        if (force == CHUNK_ALLOC_FORCE)
-               return 1;
+               return true;
 
        /*
         * in limited mode, we want to have some free space up to
                thresh = max_t(u64, SZ_64M, mult_perc(thresh, 1));
 
                if (sinfo->total_bytes - bytes_used < thresh)
-                       return 1;
+                       return true;
        }
 
        if (bytes_used + SZ_2M < mult_perc(sinfo->total_bytes, 80))
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, u64 type)
 
        return 0;
 }
 
-static inline int need_auto_defrag(struct btrfs_fs_info *fs_info)
+static inline bool need_auto_defrag(struct btrfs_fs_info *fs_info)
 {
        if (!btrfs_test_opt(fs_info, AUTO_DEFRAG))
-               return 0;
+               return false;
 
        if (btrfs_fs_closing(fs_info))
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 /*
 
        WARN_ON(btrfs_first_delayed_node(fs_info->delayed_root));
 }
 
-static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
+static bool could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
 {
        int val = atomic_read(&delayed_root->items_seq);
 
        if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
-               return 1;
+               return true;
 
        if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 void btrfs_balance_delayed_items(struct btrfs_fs_info *fs_info)
 
        return 0;
 }
 
-int __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace)
+bool __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace)
 {
        if (!dev_replace->is_valid)
-               return 0;
+               return false;
 
        switch (dev_replace->replace_state) {
        case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED:
        case BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED:
        case BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED:
-               return 0;
+               return false;
        case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
        case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
                /*
                 */
                break;
        }
-       return 1;
+       return true;
 }
 
 void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount)
 
 int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info);
 void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info);
 int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info);
-int __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace);
+bool __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace);
 bool btrfs_finish_block_group_to_copy(struct btrfs_device *srcdev,
                                      struct btrfs_block_group *cache,
                                      u64 physical);
 
                                    btrfs_extent_data_ref_offset(leaf, ref));
 }
 
-static int match_extent_data_ref(struct extent_buffer *leaf,
-                                struct btrfs_extent_data_ref *ref,
-                                u64 root_objectid, u64 owner, u64 offset)
+static bool match_extent_data_ref(struct extent_buffer *leaf,
+                                 struct btrfs_extent_data_ref *ref,
+                                 u64 root_objectid, u64 owner, u64 offset)
 {
        if (btrfs_extent_data_ref_root(leaf, ref) != root_objectid ||
            btrfs_extent_data_ref_objectid(leaf, ref) != owner ||
            btrfs_extent_data_ref_offset(leaf, ref) != offset)
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans,
 
        return ret;
 }
 
-static int extent_mergeable(struct extent_buffer *leaf, int slot,
-                           u64 objectid, u64 bytenr, u64 orig_offset,
-                           u64 *start, u64 *end)
+static bool extent_mergeable(struct extent_buffer *leaf, int slot, u64 objectid,
+                            u64 bytenr, u64 orig_offset, u64 *start, u64 *end)
 {
        struct btrfs_file_extent_item *fi;
        struct btrfs_key key;
        u64 extent_end;
 
        if (slot < 0 || slot >= btrfs_header_nritems(leaf))
-               return 0;
+               return false;
 
        btrfs_item_key_to_cpu(leaf, &key, slot);
        if (key.objectid != objectid || key.type != BTRFS_EXTENT_DATA_KEY)
-               return 0;
+               return false;
 
        fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
        if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_REG ||
            btrfs_file_extent_compression(leaf, fi) ||
            btrfs_file_extent_encryption(leaf, fi) ||
            btrfs_file_extent_other_encoding(leaf, fi))
-               return 0;
+               return false;
 
        extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi);
        if ((*start && *start != key.offset) || (*end && *end != extent_end))
-               return 0;
+               return false;
 
        *start = key.offset;
        *end = extent_end;
-       return 1;
+       return true;
 }
 
 /*
        return 0;
 }
 
-static int hole_mergeable(struct btrfs_inode *inode, struct extent_buffer *leaf,
-                         int slot, u64 start, u64 end)
+static bool hole_mergeable(struct btrfs_inode *inode, struct extent_buffer *leaf,
+                          int slot, u64 start, u64 end)
 {
        struct btrfs_file_extent_item *fi;
        struct btrfs_key key;
 
        if (slot < 0 || slot >= btrfs_header_nritems(leaf))
-               return 0;
+               return false;
 
        btrfs_item_key_to_cpu(leaf, &key, slot);
        if (key.objectid != btrfs_ino(inode) ||
            key.type != BTRFS_EXTENT_DATA_KEY)
-               return 0;
+               return false;
 
        fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
 
        if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_REG)
-               return 0;
+               return false;
 
        if (btrfs_file_extent_disk_bytenr(leaf, fi))
-               return 0;
+               return false;
 
        if (key.offset == end)
-               return 1;
+               return true;
        if (key.offset + btrfs_file_extent_num_bytes(leaf, fi) == start)
-               return 1;
-       return 0;
+               return true;
+       return false;
 }
 
 static int fill_holes(struct btrfs_trans_handle *trans,
 
  *
  * slot is the slot the inode is in, objectid is the objectid of the inode
  */
-static noinline int acls_after_inode_item(struct extent_buffer *leaf,
-                                         int slot, u64 objectid,
-                                         int *first_xattr_slot)
+static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
+                                          int slot, u64 objectid,
+                                          int *first_xattr_slot)
 {
        u32 nritems = btrfs_header_nritems(leaf);
        struct btrfs_key found_key;
 
                /* we found a different objectid, there must not be acls */
                if (found_key.objectid != objectid)
-                       return 0;
+                       return false;
 
                /* we found an xattr, assume we've got an acl */
                if (found_key.type == BTRFS_XATTR_ITEM_KEY) {
                                *first_xattr_slot = slot;
                        if (found_key.offset == xattr_access ||
                            found_key.offset == xattr_default)
-                               return 1;
+                               return true;
                }
 
                /*
                 * be any acls later on
                 */
                if (found_key.type > BTRFS_XATTR_ITEM_KEY)
-                       return 0;
+                       return false;
 
                slot++;
                scanned++;
         */
        if (*first_xattr_slot == -1)
                *first_xattr_slot = slot;
-       return 1;
+       return true;
 }
 
 static int btrfs_init_file_extent_tree(struct btrfs_inode *inode)
 
        return ret;
 }
 
-static noinline int key_in_sk(const struct btrfs_key *key,
-                             const struct btrfs_ioctl_search_key *sk)
+static noinline bool key_in_sk(const struct btrfs_key *key,
+                              const struct btrfs_ioctl_search_key *sk)
 {
        struct btrfs_key test;
        int ret;
 
        ret = btrfs_comp_cpu_keys(key, &test);
        if (ret < 0)
-               return 0;
+               return false;
 
        test.objectid = sk->max_objectid;
        test.type = sk->max_type;
 
        ret = btrfs_comp_cpu_keys(key, &test);
        if (ret > 0)
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 static noinline int copy_to_sk(struct btrfs_path *path,
 
 /*
  * Try-lock for read.
  *
- * Return 1 if the rwlock has been taken, 0 otherwise
+ * Return true if the rwlock has been taken, false otherwise
  */
-int btrfs_try_tree_read_lock(struct extent_buffer *eb)
+bool btrfs_try_tree_read_lock(struct extent_buffer *eb)
 {
        if (down_read_trylock(&eb->lock)) {
                trace_btrfs_try_tree_read_lock(eb);
-               return 1;
+               return true;
        }
-       return 0;
+       return false;
 }
 
 /*
 
 }
 
 void btrfs_tree_read_unlock(struct extent_buffer *eb);
-int btrfs_try_tree_read_lock(struct extent_buffer *eb);
+bool btrfs_try_tree_read_lock(struct extent_buffer *eb);
 struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
 struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root);
 struct extent_buffer *btrfs_try_read_lock_root_node(struct btrfs_root *root);
 
 /*
  * subvolumes are identified by ino 256
  */
-static inline int is_subvolume_inode(struct inode *inode)
+static inline bool is_subvolume_inode(struct inode *inode)
 {
        if (inode && inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)
-               return 1;
-       return 0;
+               return true;
+       return false;
 }
 
 static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
 
        }
 }
 
-static int may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
+static bool may_wait_transaction(struct btrfs_fs_info *fs_info, int type)
 {
        if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
-               return 0;
+               return false;
 
        if (type == TRANS_START)
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 static inline bool need_reserve_reloc_root(struct btrfs_root *root)
 
  * Balance filters.  Return 1 if chunk should be filtered out
  * (should not be balanced).
  */
-static int chunk_profiles_filter(u64 chunk_type,
-                                struct btrfs_balance_args *bargs)
+static bool chunk_profiles_filter(u64 chunk_type, struct btrfs_balance_args *bargs)
 {
        chunk_type = chunk_to_extended(chunk_type) &
                                BTRFS_EXTENDED_PROFILE_MASK;
 
        if (bargs->profiles & chunk_type)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
-static int chunk_usage_range_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
-                             struct btrfs_balance_args *bargs)
+static bool chunk_usage_range_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
+                                    struct btrfs_balance_args *bargs)
 {
        struct btrfs_block_group *cache;
        u64 chunk_used;
        u64 user_thresh_min;
        u64 user_thresh_max;
-       int ret = 1;
+       bool ret = true;
 
        cache = btrfs_lookup_block_group(fs_info, chunk_offset);
        chunk_used = cache->used;
                user_thresh_max = mult_perc(cache->length, bargs->usage_max);
 
        if (user_thresh_min <= chunk_used && chunk_used < user_thresh_max)
-               ret = 0;
+               ret = false;
 
        btrfs_put_block_group(cache);
        return ret;
 }
 
-static int chunk_usage_filter(struct btrfs_fs_info *fs_info,
-               u64 chunk_offset, struct btrfs_balance_args *bargs)
+static bool chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
+                              struct btrfs_balance_args *bargs)
 {
        struct btrfs_block_group *cache;
        u64 chunk_used, user_thresh;
-       int ret = 1;
+       bool ret = true;
 
        cache = btrfs_lookup_block_group(fs_info, chunk_offset);
        chunk_used = cache->used;
                user_thresh = mult_perc(cache->length, bargs->usage);
 
        if (chunk_used < user_thresh)
-               ret = 0;
+               ret = false;
 
        btrfs_put_block_group(cache);
        return ret;
 }
 
-static int chunk_devid_filter(struct extent_buffer *leaf,
-                             struct btrfs_chunk *chunk,
-                             struct btrfs_balance_args *bargs)
+static bool chunk_devid_filter(struct extent_buffer *leaf, struct btrfs_chunk *chunk,
+                              struct btrfs_balance_args *bargs)
 {
        struct btrfs_stripe *stripe;
        int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
        for (i = 0; i < num_stripes; i++) {
                stripe = btrfs_stripe_nr(chunk, i);
                if (btrfs_stripe_devid(leaf, stripe) == bargs->devid)
-                       return 0;
+                       return false;
        }
 
-       return 1;
+       return true;
 }
 
 static u64 calc_data_stripes(u64 type, int num_stripes)
 }
 
 /* [pstart, pend) */
-static int chunk_drange_filter(struct extent_buffer *leaf,
-                              struct btrfs_chunk *chunk,
-                              struct btrfs_balance_args *bargs)
+static bool chunk_drange_filter(struct extent_buffer *leaf, struct btrfs_chunk *chunk,
+                               struct btrfs_balance_args *bargs)
 {
        struct btrfs_stripe *stripe;
        int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
        int i;
 
        if (!(bargs->flags & BTRFS_BALANCE_ARGS_DEVID))
-               return 0;
+               return false;
 
        type = btrfs_chunk_type(leaf, chunk);
        factor = calc_data_stripes(type, num_stripes);
 
                if (stripe_offset < bargs->pend &&
                    stripe_offset + stripe_length > bargs->pstart)
-                       return 0;
+                       return false;
        }
 
-       return 1;
+       return true;
 }
 
 /* [vstart, vend) */
-static int chunk_vrange_filter(struct extent_buffer *leaf,
-                              struct btrfs_chunk *chunk,
-                              u64 chunk_offset,
-                              struct btrfs_balance_args *bargs)
+static bool chunk_vrange_filter(struct extent_buffer *leaf, struct btrfs_chunk *chunk,
+                               u64 chunk_offset, struct btrfs_balance_args *bargs)
 {
        if (chunk_offset < bargs->vend &&
            chunk_offset + btrfs_chunk_length(leaf, chunk) > bargs->vstart)
                /* at least part of the chunk is inside this vrange */
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
-static int chunk_stripes_range_filter(struct extent_buffer *leaf,
-                              struct btrfs_chunk *chunk,
-                              struct btrfs_balance_args *bargs)
+static bool chunk_stripes_range_filter(struct extent_buffer *leaf,
+                                      struct btrfs_chunk *chunk,
+                                      struct btrfs_balance_args *bargs)
 {
        int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
 
        if (bargs->stripes_min <= num_stripes
                        && num_stripes <= bargs->stripes_max)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
-static int chunk_soft_convert_filter(u64 chunk_type,
-                                    struct btrfs_balance_args *bargs)
+static bool chunk_soft_convert_filter(u64 chunk_type, struct btrfs_balance_args *bargs)
 {
        if (!(bargs->flags & BTRFS_BALANCE_ARGS_CONVERT))
-               return 0;
+               return false;
 
        chunk_type = chunk_to_extended(chunk_type) &
                                BTRFS_EXTENDED_PROFILE_MASK;
 
        if (bargs->target == chunk_type)
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
-static int should_balance_chunk(struct extent_buffer *leaf,
-                               struct btrfs_chunk *chunk, u64 chunk_offset)
+static bool should_balance_chunk(struct extent_buffer *leaf, struct btrfs_chunk *chunk,
+                                u64 chunk_offset)
 {
        struct btrfs_fs_info *fs_info = leaf->fs_info;
        struct btrfs_balance_control *bctl = fs_info->balance_ctl;
        /* type filter */
        if (!((chunk_type & BTRFS_BLOCK_GROUP_TYPE_MASK) &
              (bctl->flags & BTRFS_BALANCE_TYPE_MASK))) {
-               return 0;
+               return false;
        }
 
        if (chunk_type & BTRFS_BLOCK_GROUP_DATA)
        /* profiles filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_PROFILES) &&
            chunk_profiles_filter(chunk_type, bargs)) {
-               return 0;
+               return false;
        }
 
        /* usage filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_USAGE) &&
            chunk_usage_filter(fs_info, chunk_offset, bargs)) {
-               return 0;
+               return false;
        } else if ((bargs->flags & BTRFS_BALANCE_ARGS_USAGE_RANGE) &&
            chunk_usage_range_filter(fs_info, chunk_offset, bargs)) {
-               return 0;
+               return false;
        }
 
        /* devid filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_DEVID) &&
            chunk_devid_filter(leaf, chunk, bargs)) {
-               return 0;
+               return false;
        }
 
        /* drange filter, makes sense only with devid filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_DRANGE) &&
            chunk_drange_filter(leaf, chunk, bargs)) {
-               return 0;
+               return false;
        }
 
        /* vrange filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_VRANGE) &&
            chunk_vrange_filter(leaf, chunk, chunk_offset, bargs)) {
-               return 0;
+               return false;
        }
 
        /* stripes filter */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_STRIPES_RANGE) &&
            chunk_stripes_range_filter(leaf, chunk, bargs)) {
-               return 0;
+               return false;
        }
 
        /* soft profile changing mode */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_SOFT) &&
            chunk_soft_convert_filter(chunk_type, bargs)) {
-               return 0;
+               return false;
        }
 
        /*
         */
        if ((bargs->flags & BTRFS_BALANCE_ARGS_LIMIT)) {
                if (bargs->limit == 0)
-                       return 0;
+                       return false;
                else
                        bargs->limit--;
        } else if ((bargs->flags & BTRFS_BALANCE_ARGS_LIMIT_RANGE)) {
                 * about the count of all chunks that satisfy the filters.
                 */
                if (bargs->limit_max == 0)
-                       return 0;
+                       return false;
                else
                        bargs->limit_max--;
        }
 
-       return 1;
+       return true;
 }
 
 static int __btrfs_balance(struct btrfs_fs_info *fs_info)