From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [RFC 2/3] vfs: get_next_ino(), support for the uniqueness Date: Thu, 22 May 2014 13:56:57 +0200 Message-ID: <20140522115657.GD7999@quack.suse.cz> References: <1400698140-25853-1-git-send-email-hooanon05g@gmail.com> <1400698140-25853-3-git-send-email-hooanon05g@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, adilger@dilger.ca, hch@lst.de, dchinner@redhat.com, viro@zeniv.linux.org.uk, jlbec@evilplan.org, gregkh@linuxfoundation.org, hughd@google.com To: hooanon05g@gmail.com Return-path: Received: from cantor2.suse.de ([195.135.220.15]:37392 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754016AbaEVL47 (ORCPT ); Thu, 22 May 2014 07:56:59 -0400 Content-Disposition: inline In-Reply-To: <1400698140-25853-3-git-send-email-hooanon05g@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu 22-05-14 03:48:59, hooanon05g@gmail.com wrote: > From: "J. R. Okajima" > > 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 ... > 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 SUSE Labs, CR