Re: [PATCH 3/3] fs: rcu protect inode hash lookups

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Monday, November 1, 2010 - 2:38 am

Le lundi 01 novembre 2010 à 16:33 +1100, Dave Chinner a écrit :

You probably should copy Paul on this stuff, I added him in Cc, because
SLAB_DESTROY_BY_RCU is really tricky, and Paul review is a must.


Problem with SLAB_DESTROY_BY_RCU is the inode can be freed, and reused
immediately (no grace period) by another cpu.

So you need to recheck test(inode, data) _after_ getting a stable
reference on the inode (spin_lock() in this case), to make sure you
indeed found the inode you are looking for, not another one.

The test on inode->i_sb != sb can be omitted, _if_ each sb has its own
kmem_cache (but I am not sure, please check if this is the case)

Also, you should make sure the allocation of inode is careful of not
overwriting some fields (the i_lock in particular), since you could
break a concurrent lookup. This is really tricky, you cannot use
spin_lock_init(&inode->i_lock) anymore in inode_init_always().

You can read Documentation/RCU/rculist_nulls.txt for some doc I wrote
when adding SLAB_DESTROY_BY_RCU to UDP/TCP sockets. Sockets stable
reference is not a spinlock, but a refcount, so it was easier to init
this refcount. With a spinlock, I believe you might need to use SLAB
constructor, to initialize the spinlock only on fresh objects, not on
reused ones.


same here, you must recheck if (inode->i_ino != ino)


same here



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
fs: inode freeing and hash lookup via RCU, Dave Chinner, (Sun Oct 31, 10:33 pm)
[PATCH 3/3] fs: rcu protect inode hash lookups, Dave Chinner, (Sun Oct 31, 10:33 pm)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Eric Dumazet, (Mon Nov 1, 2:38 am)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Dave Chinner, (Mon Nov 1, 6:44 am)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Eric Dumazet, (Mon Nov 1, 8:29 am)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Dave Chinner, (Mon Nov 1, 5:01 pm)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Eric Dumazet, (Mon Nov 1, 9:46 pm)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Paul E. McKenney, (Tue Nov 2, 5:11 am)
Re: [PATCH 3/3] fs: rcu protect inode hash lookups, Paul E. McKenney, (Tue Nov 16, 4:56 pm)