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

btrfs: split btrfs_fs_closing() and change return type to bool



There are two tests in btrfs_fs_closing() but checking the
BTRFS_FS_CLOSING_DONE bit is done only in one place
load_extent_tree_free(). As this is an inline we can reduce size of the
generated code. The types can be also changed to bool as this becomes a
simple condition.

   text    data     bss     dec     hex filename
1674006  146704   15560 1836270  1c04ee pre/btrfs.ko
1673772  146704   15560 1836036  1c0404 post/btrfs.ko

DELTA: -234

Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 59615e2c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -761,7 +761,7 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
	nritems = btrfs_header_nritems(leaf);

	while (1) {
		if (btrfs_fs_closing(fs_info) > 1) {
		if (btrfs_fs_closing_done(fs_info)) {
			last = (u64)-1;
			break;
		}
+10 −8
Original line number Diff line number Diff line
@@ -1118,15 +1118,17 @@ void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
#define btrfs_test_opt(fs_info, opt)	((fs_info)->mount_opt & \
					 BTRFS_MOUNT_##opt)

static inline int btrfs_fs_closing(const struct btrfs_fs_info *fs_info)
static inline bool btrfs_fs_closing(const struct btrfs_fs_info *fs_info)
{
	/* Do it this way so we only ever do one test_bit in the normal case. */
	if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
		if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
			return 2;
		return 1;
	return unlikely(test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags));
}
	return 0;

static inline bool btrfs_fs_closing_done(const struct btrfs_fs_info *fs_info)
{
	if (btrfs_fs_closing(fs_info) && test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
		return true;

	return false;
}

/*