diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-12 05:45:49 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-25 20:39:51 -0500 |
commit | 1362b5e347e27102ea0fa99c9932bca1ecde330f (patch) | |
tree | c7166c18990972677de0049a83c532c3802d3f60 | |
parent | dfb7c0ceab57fee7618f4c9c31c5a89254e8530a (diff) |
f2fs: fix wrong calculation on f_files in statfs
In f2fs_statfs(), f_files should be the total number of available inodes
instead of the currently allocated inodes.
So, this patch should resolve the reported bug below.
Note that, showing 10% usage is not a bug, since f2fs reveals whole volume size
as much as possible and shows the space overhead as *used*.
This policy is fair enough with respect to other file systems.
<Reported Bug>
(loop0 is backed by 1GiB file)
$ mkfs.f2fs /dev/loop0
F2FS-tools: Ver: 1.1.0 (2012-12-11)
Info: sector size = 512
Info: total sectors = 2097152 (in 512bytes)
Info: zone aligned segment0 blkaddr: 512
Info: format successful
$ mount /dev/loop0 mnt/
$ df mnt/
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 1046528 98312 929784 10%
/home/zeta/linux-devel/mtd-bench/mnt
$ df mnt/ -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/loop0 1 -465918 465919 - /home/zeta/linux-devel/mtd-bench/mnt
Notice IUsed is negative. Also, 10% usage on a fresh f2fs seems too
much to be correct.
Reported-and-Tested-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/super.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 13867322cf5a..f4d9e03723db 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -148,8 +148,8 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
148 | buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count; | 148 | buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count; |
149 | buf->f_bavail = user_block_count - valid_user_blocks(sbi); | 149 | buf->f_bavail = user_block_count - valid_user_blocks(sbi); |
150 | 150 | ||
151 | buf->f_files = valid_inode_count(sbi); | 151 | buf->f_files = sbi->total_node_count; |
152 | buf->f_ffree = sbi->total_node_count - valid_node_count(sbi); | 152 | buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi); |
153 | 153 | ||
154 | buf->f_namelen = F2FS_MAX_NAME_LEN; | 154 | buf->f_namelen = F2FS_MAX_NAME_LEN; |
155 | buf->f_fsid.val[0] = (u32)id; | 155 | buf->f_fsid.val[0] = (u32)id; |