diff options
author | Vyacheslav Dubeyko <slava@dubeyko.com> | 2013-07-03 18:08:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:08:01 -0400 |
commit | c7ef972c440fc9f1eda28b450cd30ad15c4d60cf (patch) | |
tree | 5f415ed5b082632848cae6e5798a8ac986e0ed38 /fs/nilfs2/ifile.c | |
parent | e88b815e011bcacb7066f1156ce390f6b0adc9df (diff) |
nilfs2: implement calculation of free inodes count
Currently, NILFS2 returns 0 as free inodes count (f_ffree) and current
used inodes count as total file nodes in file system (f_files):
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/loop0 2 2 0 100% /mnt/nilfs2
This patch implements real calculation of free inodes count. First of
all, it is calculated total file nodes in file system as
(desc_blocks_count * groups_per_desc_block * entries_per_group). Then, it
is calculated free inodes count as difference the total file nodes and
used inodes count. As a result, we have such output for NILFS2:
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/loop0 4194304 2114701 2079603 51% /mnt/nilfs2
Reported-by: Clemens Eisserer <linuxhippy@gmail.com>
Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tested-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Cc: Joern Engel <joern@logfs.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/ifile.c')
-rw-r--r-- | fs/nilfs2/ifile.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c index d8e65bde083c..d788a5928351 100644 --- a/fs/nilfs2/ifile.c +++ b/fs/nilfs2/ifile.c | |||
@@ -160,6 +160,28 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino, | |||
160 | } | 160 | } |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * nilfs_ifile_count_free_inodes - calculate free inodes count | ||
164 | * @ifile: ifile inode | ||
165 | * @nmaxinodes: current maximum of available inodes count [out] | ||
166 | * @nfreeinodes: free inodes count [out] | ||
167 | */ | ||
168 | int nilfs_ifile_count_free_inodes(struct inode *ifile, | ||
169 | u64 *nmaxinodes, u64 *nfreeinodes) | ||
170 | { | ||
171 | u64 nused; | ||
172 | int err; | ||
173 | |||
174 | *nmaxinodes = 0; | ||
175 | *nfreeinodes = 0; | ||
176 | |||
177 | nused = atomic_read(&NILFS_I(ifile)->i_root->inodes_count); | ||
178 | err = nilfs_palloc_count_max_entries(ifile, nused, nmaxinodes); | ||
179 | if (likely(!err)) | ||
180 | *nfreeinodes = *nmaxinodes - nused; | ||
181 | return err; | ||
182 | } | ||
183 | |||
184 | /** | ||
163 | * nilfs_ifile_read - read or get ifile inode | 185 | * nilfs_ifile_read - read or get ifile inode |
164 | * @sb: super block instance | 186 | * @sb: super block instance |
165 | * @root: root object | 187 | * @root: root object |