Re: [PATCH v3] nilfs2: implement calculation of free inodes count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 16 May 2013 02:46:02 +0900 (JST), Ryusuke Konishi wrote:
> On Wed, 15 May 2013 17:32:10 +0400, Vyacheslav Dubeyko wrote:
>> Hi Ryusuke,
>> 
>> This is third version of the patch.
>> 
>> v2->v3
>>  * Trivial BUG_ON checks were removed.
>>  * Whole calculation algorithm was moved into
>>    nilfs_palloc_count_max_entries() method.
>>  * Improve error processing in the code.
>>  * The nilfs_palloc_mdt_file_can_grow() method was simplified.
>>  * The nilfs_ifile_count_free_inodes() method was simplified.
>> 
>> v1->v2
>>  * Change __statfs_word on u64 type.
>>  * Rename nilfs_count_free_inodes() into nilfs_ifile_count_free_inodes()
>>    method.
>>  * Introduce auxiliary functions: nilfs_palloc_count_max_entries(),
>>    nilfs_palloc_count_desc_blocks(), nilfs_palloc_mdt_file_can_grow().
>>  * Rework processing of returned error from nilfs_ifile_count_free_inodes()
>>    in nilfs_statfs().
>> 
>> With the best regards,
>> Vyacheslav Dubeyko.
>> ---
>> From: Vyacheslav Dubeyko <slava@xxxxxxxxxxx>
>> Subject: [PATCH v3] 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@xxxxxxxxx>
>> Signed-off-by: Vyacheslav Dubeyko <slava@xxxxxxxxxxx>
>> CC: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx>
>> Tested-by: Vyacheslav Dubeyko <slava@xxxxxxxxxxx>
> 
> This patch still has a potential overflow issue that I pointed out in
> the previous comment; the patch handles the number of descriptor
> blocks in 32-bit wide variables without checking its upper limit.
> 
> If you won't to add checks for the number of descriptor blocks, I
> propose you to change the definition of nilfs_palloc_groups_count() instead:
> 
>   static inline unsigned long
>   nilfs_palloc_groups_count(const struct inode *inode)
>   {
> - 	return 1UL << (BITS_PER_LONG - (inode->i_blkbits + 3 /* log2(8) */));
> + 	return nilfs_palloc_groups_per_desc_block(inode) << 32;
>   }
> 
> This implies the maximum number of descriptor block is 1 ^ 32.
> 
> Because the above diff changes the maximum number of groups, I think
> it should be inserted as a separate patch.

Oops, sorry, this change can overflow in 32-bit architectures
because the type of return value is still unsigned long.
That calculation should be revised more carefully.

Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux