Skip to content

Commit 58bfe2c

Browse files
josefbacikkdave
authored andcommitted
btrfs: properly report 0 avail for very full file systems
A user reported some issues with smaller file systems that get very full. While investigating this issue I noticed that df wasn't showing 100% full, despite having 0 chunk space and having < 1MiB of available metadata space. This turns out to be an overflow issue, we're doing: total_available_metadata_space - SZ_4M < global_block_rsv_size to determine if there's not enough space to make metadata allocations, which overflows if total_available_metadata_space is < 4M. Fix this by checking to see if our available space is greater than the 4M threshold. This makes df properly report 100% usage on the file system. CC: [email protected] # 4.14+ Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 8ec0a4a commit 58bfe2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
21172117
* calculated f_bavail.
21182118
*/
21192119
if (!mixed && block_rsv->space_info->full &&
2120-
total_free_meta - thresh < block_rsv->size)
2120+
(total_free_meta < thresh || total_free_meta - thresh < block_rsv->size))
21212121
buf->f_bavail = 0;
21222122

21232123
buf->f_type = BTRFS_SUPER_MAGIC;

0 commit comments

Comments
 (0)