Re: [PATCH 3/6] vfs: Allow searching of the icache under RCU conditions [ver #2]

From: Al Viro
Date: Thu Apr 25 2019 - 11:19:30 EST


On Thu, Apr 25, 2019 at 04:02:11PM +0100, David Howells wrote:
> Allow searching of the inode cache under RCU conditions - but with a
> footnote that this is redone under lock under certain conditions.
>
> The following changes are made:
>
> (1) Use hlist_add_head_rcu() and hlist_del_init_rcu() to add and remove
> an inode to/from a bucket.
>
> (2) In rehash_inode(), called by Coda to change the identifying parameters
> on an inode during resolution of disconnected operation, lock
> inode_hash_lock with write_seqlock(), which takes the spinlock and
> bumps the sequence counter.
>
> (3) Provide __find_inode_rcu() and __find_inode_by_ino rcu() which do an
> RCU-safe crawl through a hash bucket.
>
> (4) Provide find_inode_rcu() and find_inode_by_ino_rcu() which do a
> read_seqbegin_or_lock() conditional lock-loop on inode_hash_lock to
> cover searching the icache. Normally this will work without needing
> to retry, but in case (4), where an inode may be moved between lists,
> we need to retry with the lock held.

Hmm... Why do these stores to ->i_state need WRITE_ONCE, while an arseload
of similar in fs/fs-writeback.c does not?