|
|
Subscribe / Log in / New account

Re: [PATCH 15/17] fs: inode per-cpu last_ino allocator

From:  Andrew Morton <akpm-AT-linux-foundation.org>
To:  Eric Dumazet <eric.dumazet-AT-gmail.com>
Subject:  Re: [PATCH 15/17] fs: inode per-cpu last_ino allocator
Date:  Thu, 30 Sep 2010 01:14:17 -0700
Message-ID:  <20100930011417.6ca16ed7.akpm@linux-foundation.org>
Cc:  Dave Chinner <david-AT-fromorbit.com>, linux-fsdevel-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org
Archive‑link:  Article

On Thu, 30 Sep 2010 09:53:09 +0200 Eric Dumazet <eric.dumazet@gmail.com> wrote:

> Le jeudi 30 septembre 2010 __ 07:36 +0200, Eric Dumazet a __crit :
> > Le mercredi 29 septembre 2010 __ 21:53 -0700, Andrew Morton a __crit :
> 
> > > > +static unsigned int last_ino_get(void)
> > > > +{
> > > > +	static unsigned int last_ino;
> > > > +
> > > > +	return ++last_ino;
> > > > +}
> > > 
> > > This is racy with CONFIG_PREEMPT on some architectures, I suspect.  I'd
> > > suggest conversion to atomic_t with, of course, an explanatory comment ;)
> > > 
> > 
> 
> In fact this code was OK when I submitted my original patch back in
> 2008, since it replaced fs/inode.c
> 
> 	inode->i_ino = ++last_ino;
> 
> And this was protected by a surrounding spinlock
> (spin_lock(&inode_lock); at that time)
> 
> Even after Nick patches, preemption is still disabled (by two
> spinlocks... spin_lock(&sb_inode_list_lock); /
> spin_lock(&inode->i_lock);)

You know, if it took you and me this long to work that out then perhaps
the code isn't quite as clear as we would like it to be, no?

I think you know what's coming next ;)

As a general rule, if a reviewer's comment doesn't result in a code
change then it should result in a changelog fix or a code comment. 
Because if the code wasn't clear enough to the reviewer then it won't be
clear enough to later readers.

> So patch 15/17 seems good to me, I re-sign it as-is ;)
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> 
> If it happens preemption is re-enabled later (with future patches), we
> might need to change last_ino_get() too.

Perhaps

	WARN_ON_ONCE(preemptible());

if we had a developer-only version of WARN_ON_ONCE, which we don't.



to post comments


Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds