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>
This commit is contained in:

committed by
Linus Torvalds

parent
e88b815e01
commit
c7ef972c44
@@ -159,6 +159,28 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* nilfs_ifile_count_free_inodes - calculate free inodes count
|
||||
* @ifile: ifile inode
|
||||
* @nmaxinodes: current maximum of available inodes count [out]
|
||||
* @nfreeinodes: free inodes count [out]
|
||||
*/
|
||||
int nilfs_ifile_count_free_inodes(struct inode *ifile,
|
||||
u64 *nmaxinodes, u64 *nfreeinodes)
|
||||
{
|
||||
u64 nused;
|
||||
int err;
|
||||
|
||||
*nmaxinodes = 0;
|
||||
*nfreeinodes = 0;
|
||||
|
||||
nused = atomic_read(&NILFS_I(ifile)->i_root->inodes_count);
|
||||
err = nilfs_palloc_count_max_entries(ifile, nused, nmaxinodes);
|
||||
if (likely(!err))
|
||||
*nfreeinodes = *nmaxinodes - nused;
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* nilfs_ifile_read - read or get ifile inode
|
||||
* @sb: super block instance
|
||||
|
Reference in New Issue
Block a user