aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-08-20 06:36:46 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-08-21 16:57:06 -0400
commitc200b1aa6cb460ce8c3ecf6fdc690d3949c3cc5d (patch)
tree527fda78fcfcd4a879766e3c38cf8041fc10f1e8
parent04859dba50e6cd85c5d683d06010c5eafb27c893 (diff)
f2fs: fix incorrect calculation with total/free inode num
Theoretically, our total inodes number is the same as total node number, but there are three node ids are reserved in f2fs, they are 0, 1 (node nid), and 2 (meta nid), and they should never be used by user, so our total/free inode number calculated in ->statfs is wrong. This patch indroduces F2FS_RESERVED_NODE_NUM and then fixes this issue by recalculating total/free inode number with the macro. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/node.c2
-rw-r--r--fs/f2fs/super.c4
-rw-r--r--include/linux/f2fs_fs.h3
3 files changed, 6 insertions, 3 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b4d964029fc7..044395c20ee9 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1957,7 +1957,7 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
1957 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks; 1957 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks;
1958 1958
1959 /* not used nids: 0, node, meta, (and root counted as valid node) */ 1959 /* not used nids: 0, node, meta, (and root counted as valid node) */
1960 nm_i->available_nids = nm_i->max_nid - 3; 1960 nm_i->available_nids = nm_i->max_nid - F2FS_RESERVED_NODE_NUM;
1961 nm_i->fcnt = 0; 1961 nm_i->fcnt = 0;
1962 nm_i->nat_cnt = 0; 1962 nm_i->nat_cnt = 0;
1963 nm_i->ram_thresh = DEF_RAM_THRESHOLD; 1963 nm_i->ram_thresh = DEF_RAM_THRESHOLD;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ddb1e9d36363..0f61f5aa587c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -508,8 +508,8 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
508 buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count; 508 buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count;
509 buf->f_bavail = user_block_count - valid_user_blocks(sbi); 509 buf->f_bavail = user_block_count - valid_user_blocks(sbi);
510 510
511 buf->f_files = sbi->total_node_count; 511 buf->f_files = sbi->total_node_count - F2FS_RESERVED_NODE_NUM;
512 buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi); 512 buf->f_ffree = buf->f_files - valid_inode_count(sbi);
513 513
514 buf->f_namelen = F2FS_NAME_LEN; 514 buf->f_namelen = F2FS_NAME_LEN;
515 buf->f_fsid.val[0] = (u32)id; 515 buf->f_fsid.val[0] = (u32)id;
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index 6ff0b0b42d47..0ed77f32c9ac 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -24,6 +24,9 @@
24#define NULL_ADDR ((block_t)0) /* used as block_t addresses */ 24#define NULL_ADDR ((block_t)0) /* used as block_t addresses */
25#define NEW_ADDR ((block_t)-1) /* used as block_t addresses */ 25#define NEW_ADDR ((block_t)-1) /* used as block_t addresses */
26 26
27/* 0, 1(node nid), 2(meta nid) are reserved node id */
28#define F2FS_RESERVED_NODE_NUM 3
29
27#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num) 30#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num)
28#define F2FS_NODE_INO(sbi) (sbi->node_ino_num) 31#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
29#define F2FS_META_INO(sbi) (sbi->meta_ino_num) 32#define F2FS_META_INO(sbi) (sbi->meta_ino_num)