Re: [PATCH 16/21] fs: Protect inode->i_state with the inode->i_lock

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dave Chinner
Date: Thursday, October 21, 2010 - 8:14 pm

On Fri, Oct 22, 2010 at 02:56:22AM +0100, Al Viro wrote:

Nothing - I hadn't considered that as a potential inode freeing
race window, so my assumption that it was OK to do this is wrong. It
definitely needs fixing.


Yes, I knew that bit - I went wrong making the same assumptions
through the unused path.


I left it outside i_lock to be consistent with all the new
locks being introduced. fs/fs-writeback.c::sync_inode() has a
similar inode life-time wart when adding clean inodes to the lru
which I was never really happy about. I suspect it has similar
problems.

I had a bit of a think about playing refcounting games to avoid
doing the LRU add without holding the i_lock (to avoid the above
freeing problem), but that ends up with more complex and messy iput/
iput_final interactions.  Likewise, adding trylocks into the lru
list add sites is doesn't solve the inode-goes-away-after-i_lock-
is-dropped problems.  A couple of other ideas I had also drowned in
complexity at birth.

AFAICT, moving the inode_lru_lock inside i_lock doesn't affect the
locking order of anything else, and I agree that putting a single
trylock in the prune_icache loop is definitely cleaner than anything
else I've been able to think of that retains the current locking
order. It will also remove the wart in sync_inode().

So, I'll swallow my rhetoric and agree with you that inode_lru_lock
inside the i_lock is the natural and easiest way to nest these
locks. I'll rework the series to do this. 

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Inode Lock Scalability V6, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 04/21] fs: Implement lazy LRU updates for inodes, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 05/21] fs: inode split IO and LRU lists, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 06/21] fs: Clean up inode reference counting, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 08/21] fs: rework icount to be a locked variable, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 13/21] fs: Introduce per-bucket inode hash locks, Dave Chinner, (Wed Oct 20, 5:49 pm)
[PATCH 19/21] fs: icache remove inode_lock, Dave Chinner, (Wed Oct 20, 5:49 pm)
Re: [PATCH 06/21] fs: Clean up inode reference counting, Christoph Hellwig, (Wed Oct 20, 6:41 pm)
Re: Inode Lock Scalability V7 (was V6), Dave Chinner, (Wed Oct 20, 10:04 pm)
Re: [PATCH 04/21] fs: Implement lazy LRU updates for inodes, Christoph Hellwig, (Thu Oct 21, 5:22 am)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 6:20 am)
Re: Inode Lock Scalability V7 (was V6), Dave Chinner, (Thu Oct 21, 4:52 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 5:45 pm)
Re: Inode Lock Scalability V7 (was V6), Al Viro, (Thu Oct 21, 7:20 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 7:41 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 7:48 pm)
Re: Inode Lock Scalability V7 (was V6), Al Viro, (Thu Oct 21, 8:07 pm)
Re: Inode Lock Scalability V7 (was V6), Al Viro, (Thu Oct 21, 8:12 pm)
Re: [PATCH 16/21] fs: Protect inode->i_state with the inod ..., Dave Chinner, (Thu Oct 21, 8:14 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 9:46 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 9:48 pm)
Re: Inode Lock Scalability V7 (was V6), Nick Piggin, (Thu Oct 21, 10:01 pm)