diff mbox

[v2] btrfs: fix free space calculation in dump_space_info()

Message ID 20160711113004.4896-1-wangxg.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Xiaoguang Wang July 11, 2016, 11:30 a.m. UTC
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 minus btrfs_space_info's
bytes_may_use.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Duncan July 11, 2016, 3:59 p.m. UTC | #1
Wang Xiaoguang posted on Mon, 11 Jul 2016 19:30:04 +0800 as excerpted:

> 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 minus btrfs_space_info's
> bytes_may_use.
> 
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 4 ++--

I'm not a dev so won't evaluate the patch itself.  However, on kernel 
related mailing lists it's standard practice to include a short, often 
one-line per revision, revision changelog.  It helps reviewers keep track 
of what changed since the last time they looked at the patch.  See pretty 
much any on-list v2+ patch as an example.
David Sterba July 12, 2016, 4:12 p.m. UTC | #2
On Mon, Jul 11, 2016 at 07:30:04PM +0800, Wang Xiaoguang wrote:
> 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 minus btrfs_space_info's
> bytes_may_use.
> 
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 81310ff..f1cc8b8 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7694,8 +7694,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,