Re: [RFC 2/3] vfs: get_next_ino(), support for the uniqueness

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

 



On Thu 22-05-14 03:48:59, hooanon05g@xxxxxxxxx wrote:
> From: "J. R. Okajima" <hooanon05g@xxxxxxxxx>
> 
> Add a feature to keep the uniqueness of inum in the superblock.
> In this commit, the parameter superblock sets NULL, so the feature is
> OFF. It will be ON individually be thier maintainer.
> 
> Signed-off-by: J. R. Okajima <hooanon05g@xxxxxxxxx>
...
> diff --git a/fs/inode.c b/fs/inode.c
> index a3e274a..1412607 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -834,8 +834,9 @@ repeat:
>  #define LAST_INO_BATCH 1024
>  static DEFINE_PER_CPU(unsigned int, last_ino);
>  
> -unsigned int get_next_ino(void)
> +static unsigned int do_get_next_ino(struct super_block *sb, int *pwrapped)
>  {
> +	static int wrapped;
>  	unsigned int *p = &get_cpu_var(last_ino);
>  	unsigned int res = *p;
>  
> @@ -850,10 +851,60 @@ unsigned int get_next_ino(void)
>  
>  	res++;
>  	/* never zero */
> -	if (unlikely(!res))
> +	if (unlikely(!res)) {
>  		res++;
> +		wrapped = 1;
> +	}
>  	*p = res;
>  	put_cpu_var(last_ino);
> +	*pwrapped = wrapped;
> +	return res;
> +}
> +
> +static int test_ino_sb(struct super_block *sb, unsigned long ino)
> +{
> +	int in_use;
> +	struct inode *inode, *next;
> +
> +	in_use = 0;
> +	spin_lock(&inode_sb_list_lock);
> +	list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
> +		if (inode->i_ino != ino)
> +			continue;
> +		in_use = 1;
> +		break;
> +	}
> +	spin_unlock(&inode_sb_list_lock);
> +
> +	return in_use;
> +}
  I don't think scanning the whole superblock list is really a viable
alternative. That is going to contend a lot on inode_sb_list_lock and burn
a lot of CPU when there is even moderate number of inodes in tmpfs. If we
ever have to really use unique inode numbers for tmpfs (but I'm not
convinced - see my other email), we should probably hash those inodes and
use iunique()...

								Honza
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
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