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: Nick Piggin
Date: Saturday, October 23, 2010 - 7:18 pm

On Fri, Oct 22, 2010 at 02:14:31PM +1100, Dave Chinner wrote:

I don't know what's so unclean or wrong about the locking order.  I'm
still leaning much further than Al as to putting locks inside i_lock.

With inode-rcu, we _always_ arrive at the inode _first_, before taking
_any_ other locks (because we either come in via an external reference,
or we can find the inode from any of the data structures using RCU
rather than taking their locks).

[The exception is hash insertion uniqueness enforcement, because we have
 no inode to lock, by definition. But in that case we're OK because the
 new inode we're about to insert has no concurrency on its i_lock so that
 can be initialised locked.]

So what we have is an inode, which we need to do stuff to. That stuff
involves moving it on or off data structures, and updating its refcount
and state, etc.

That suggests the i_lock -> data-structure-lock locking order.

And look at the flexibility -- I could implement that without changing
any other code or ordering in the icache. Sure you can reorder things
around to cope with different locking strategies, but I'm not actually
given a good reason _why_ i_lock first is not the "natural" ordering.
Doing that means we simply don't _need_ to change any ordering or
concurrency rules (although it doesn't prevent changes).

--
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: 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)
Re: [PATCH 16/21] fs: Protect inode->i_state with the inod ..., Nick Piggin, (Sat Oct 23, 7:18 pm)