From mboxrd@z Thu Jan 1 00:00:00 1970 From: Randy Dunlap Subject: Re: [RFC][PATCH] ensure i_ino uniqueness in filesystems without permanent inode numbers (via idr) Date: Fri, 01 Dec 2006 09:42:36 -0800 Message-ID: <4570698C.5060502@oracle.com> References: <457040C4.1000002@redhat.com> <20061201085227.2463b185.randy.dunlap@oracle.com> <20061201172136.GA11669@dantu.rdu.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: Received: from agminet01.oracle.com ([141.146.126.228]:51625 "EHLO agminet01.oracle.com") by vger.kernel.org with ESMTP id S1759190AbWLARmL (ORCPT ); Fri, 1 Dec 2006 12:42:11 -0500 To: Jeff Layton In-Reply-To: <20061201172136.GA11669@dantu.rdu.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Jeff Layton wrote: > On Fri, Dec 01, 2006 at 08:52:27AM -0800, Randy Dunlap wrote: > > Thanks for having a look, Randy... > >> s/idr_/iunique_/ > > Doh! Can you tell I cut and pasted this email from earlier ones? :-) > >>> - don't attempt to remove inodes with values <100 >> Please explain that one. (May be obvious to some, but not to me.) > > Actually, we probably don't need to do that now. My thought here was to add > a low range of i_ino numbers that could be used by the filesystem code without > needing to call iunique (in particular for things like the root inode in the > filesystem). It's probably best to not do this though and let the filesystem > handle it on its own. > >> Better to post patches inline (for review) rather than as attachments. > > Here's an updated (but untested) patch based on your suggestions. I also went > ahead and made the exported symbols GPL-only since that seems like it would be > appropriate here. Any further thoughts on it? Just needs new/updated patch description. and one "typo" fixed. > diff --git a/fs/inode.c b/fs/inode.c > index 26cdb11..e45cec9 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -706,6 +708,32 @@ retry: > > EXPORT_SYMBOL(iunique); > > +int iunique_register(struct inode *inode, int max_reserved) > +{ > + int rv; > + > + rv = idr_pre_get(&inode->i_sb->s_inode_ids, GFP_KERNEL); > + if (! rv) No space after !, just: if (!rv) > + return -ENOMEM; > + > + spin_lock(&inode->i_sb->s_inode_ids_lock); > + rv = idr_get_new_above(&inode->i_sb->s_inode_ids, inode, > + max_reserved+1, (int *) &inode->i_ino); > + inode->i_generation = inode->i_sb->s_generation++; > + spin_unlock(&inode->i_sb->s_inode_ids_lock); > + return rv; > +} Thanks. -- ~Randy