linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, eric.dumazet@gmail.com,
	paulmck@linux.vnet.ibm.com
Subject: Re: [PATCH 4/4] fs: rcu protect inode hash lookups
Date: Mon, 8 Nov 2010 06:10:23 -0500	[thread overview]
Message-ID: <20101108111023.GA1797@infradead.org> (raw)
In-Reply-To: <1289201305-14866-5-git-send-email-david@fromorbit.com>

> -	hlist_add_fake(&inode->i_hash);
> +	hlist_nulls_add_fake(&inode->i_hash);

Please add a preparatory inode_fake_hash/inode_mark_hashed or similar
helper to isolate filesystems from the implementation details of the
hash list.

> +	/*
> +	 * reset the inode number so during RCU traversals we do not match this
> +	 * inode in any lookups until it is fully re-initialised again during
> +	 * allocation.
> +	 */
> +	inode->i_ino = 0;

There is no hard rule that i_ino is an invalid inode number.  It can
happen quite easily for inodes using the generic last_ino allocator,
and I would not be surprised if there's some filesystems using it as
part of the on disk layour either.

> +			rcu_read_unlock();
> +			if (locked)
> +				spin_unlock(&inode_hash_lock);
>  			__wait_on_freeing_inode(inode);
> +			if (locked)
> +				spin_lock(&inode_hash_lock);

I can't say I like the locked argument, but I don't see an easy way
around it.  Can you at least keept the unlocking/relocking inside
__wait_on_freeing_inode so that it's centralized in a single place for
both find_inode pathes?

While at it moving __wait_on_freeing_inode to be above ifind would
making changes in this area a lot easier to read, so maybe you can throw
in a patch for that, too?

>  static struct inode *ifind(struct super_block *sb,
> -		struct hlist_head *head, int (*test)(struct inode *, void *),
> +		struct hlist_nulls_head *head, int chain,
> +		int (*test)(struct inode *, void *),
>  		void *data, const int wait)
>  {
>  	struct inode *inode;
>  
> -	spin_lock(&inode_hash_lock);
> -	inode = find_inode(sb, head, test, data);
> +	inode = find_inode(sb, head, chain, test, data, false);
>  	if (inode) {
> -		spin_unlock(&inode_hash_lock);
>  		if (likely(wait))
>  			wait_on_inode(inode);
>  		return inode;
>  	}
> -	spin_unlock(&inode_hash_lock);
>  	return NULL;
>  }

This is starting to get a rather pointless helper.  I'd suggest just
killing ifind/ifind_fast and opencoding them in the caller, possibly
as a preparatory patch.

      parent reply	other threads:[~2010-11-08 11:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-08  7:28 fs: inode rcu freeing and hash walking V2 Dave Chinner
2010-11-08  7:28 ` [PATCH 1/4] fs: pull inode->i_lock up out of writeback_single_inode Dave Chinner
2010-11-08  7:28 ` [PATCH 2/4] fs: Convert inode slab creation to use consistent parameters Dave Chinner
2011-04-25 17:46   ` Christoph Hellwig
2010-11-08  7:28 ` [PATCH 3/4] fs: Use RCU freeing of inodes via SLAB_DESTROY_BY_RCU Dave Chinner
2010-11-08  7:28 ` [PATCH 4/4] fs: rcu protect inode hash lookups Dave Chinner
2010-11-08  8:53   ` Eric Dumazet
2010-11-08 11:10   ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101108111023.GA1797@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).