Commit f963e012 authored by David Sterba's avatar David Sterba
Browse files

btrfs: trivial conversion to return bool instead of int



Old code has a lot of int for bool return values, bool is recommended
and done in new code. Convert the trivial cases that do simple 0/false
and 1/true. Functions comment are updated if needed.

Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 73d6bcf4
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -3869,14 +3869,14 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
	}
}

static int should_alloc_chunk(const struct btrfs_fs_info *fs_info,
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
@@ -3887,12 +3887,12 @@ static int should_alloc_chunk(const struct btrfs_fs_info *fs_info,
		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)
+4 −4
Original line number Diff line number Diff line
@@ -105,15 +105,15 @@ static int btrfs_insert_inode_defrag(struct btrfs_inode *inode,
	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;
}

/*
+4 −4
Original line number Diff line number Diff line
@@ -1387,17 +1387,17 @@ void btrfs_assert_delayed_root_empty(struct btrfs_fs_info *fs_info)
	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)
+4 −4
Original line number Diff line number Diff line
@@ -1265,16 +1265,16 @@ static int btrfs_dev_replace_kthread(void *data)
	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:
		/*
@@ -1289,7 +1289,7 @@ int __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace)
		 */
		break;
	}
	return 1;
	return true;
}

void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount)
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
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);
Loading