[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101016172924.GA3519@amd>
Date: Sun, 17 Oct 2010 04:29:24 +1100
From: Nick Piggin <npiggin@...nel.dk>
To: Christoph Hellwig <hch@...radead.org>
Cc: Nick Piggin <npiggin@...nel.dk>,
Dave Chinner <david@...morbit.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 04/19] fs: Implement lazy LRU updates for inodes.
On Sat, Oct 16, 2010 at 12:59:30PM -0400, Christoph Hellwig wrote:
> On Sat, Oct 16, 2010 at 08:29:16PM +1100, Nick Piggin wrote:
> > On Sat, Oct 16, 2010 at 07:13:58PM +1100, Dave Chinner wrote:
> > > @@ -502,11 +527,15 @@ static void prune_icache(int nr_to_scan)
> > > iput(inode);
> > > spin_lock(&inode_lock);
> > >
> > > - if (inode != list_entry(inode_unused.next,
> > > - struct inode, i_list))
> > > - continue; /* wrong inode or list_empty */
> > > - if (!can_unuse(inode))
> > > + /*
> > > + * if we can't reclaim this inode immediately, give it
> > > + * another pass through the free list so we don't spin
> > > + * on it.
> > > + */
> > > + if (!can_unuse(inode)) {
> > > + list_move(&inode->i_list, &inode_unused);
> > > continue;
> > > + }
> > > }
> > > list_move(&inode->i_list, &freeable);
> > > WARN_ON(inode->i_state & I_NEW);
> >
> > This is a bug, actually 2 bugs, which is why I omitted it in the version
> > you picked up. I agree we want the optimisation though, so I've added it
> > back in my tree.
> >
> > After you iput() and then re take the inode lock, you can't reference
> > the inode because you don't know what happened to it. You need to keep
> > that pointer check to verify it is still there.
>
> I don't think the pointer check will work either. By the time we retake
> the lru lock the inode might already have been reaped through a call
> to invalidate_inodes. There's no way we can do anything with it after
I don't think you're right. If we re take inode_lock, ensure it is on
the LRU, and call the can_unuse checks, there is no more problem than
the regular loop taking items from the LRU, AFAIKS.
> iput. What we could do is using variant of can_unuse to decide to move
> the inode to the front of the lru before doing the iput. That way
> we'll get to it next after retaking the lru lock if it's still there.
This might actually be the better approach anyway (even for upstream)
-- it means we don't have to worry about the "check head element"
heuristic of the LRU check which could get false negatives if there is
a lot of concurrency on the LRU.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists