]> git.hungrycats.org Git - linux/commitdiff
btrfs: fix free space calculation in dump_space_info()
authorWang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Mon, 11 Jul 2016 11:30:04 +0000 (19:30 +0800)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Wed, 17 Aug 2016 02:28:20 +0000 (22:28 -0400)
In btrfs, btrfs_space_info's bytes_may_use is treated as fs used
space, as what we do in reserve_metadata_bytes() or
btrfs_alloc_data_chunk_ondemand(), so in dump_space_info(), when
calculating free space, we should also subtract btrfs_space_info's
bytes_may_use.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 39581a3a1af7e03af41dde62a6485a934deb109b)

fs/btrfs/extent-tree.c

index c13d4702a3989173e20aa9ca823fce1e5461df06..d6797bdb9a89c22d442b6df8d9463279d1c95a99 100644 (file)
@@ -7602,8 +7602,8 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
        printk(KERN_INFO "BTRFS: space_info %llu has %llu free, is %sfull\n",
               info->flags,
               info->total_bytes - info->bytes_used - info->bytes_pinned -
-              info->bytes_reserved - info->bytes_readonly,
-              (info->full) ? "" : "not ");
+              info->bytes_reserved - info->bytes_readonly -
+              info->bytes_may_use, (info->full) ? "" : "not ");
        printk(KERN_INFO "BTRFS: space_info total=%llu, used=%llu, pinned=%llu, "
               "reserved=%llu, may_use=%llu, readonly=%llu\n",
               info->total_bytes, info->bytes_used, info->bytes_pinned,