linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@gmail.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] vfs: factor out inode hash head calculation
Date: Tue, 6 Apr 2021 18:06:49 -0400	[thread overview]
Message-ID: <YGzbeWxf1r+AivSJ@moria.home.lan> (raw)
In-Reply-To: <20210406123343.1739669-2-david@fromorbit.com>

On Tue, Apr 06, 2021 at 10:33:41PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> In preparation for changing the inode hash table implementation.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>

> ---
>  fs/inode.c | 44 +++++++++++++++++++++++++-------------------
>  1 file changed, 25 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index a047ab306f9a..b8d9eb3454dc 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -60,6 +60,22 @@ static unsigned int i_hash_shift __read_mostly;
>  static struct hlist_head *inode_hashtable __read_mostly;
>  static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock);
>  
> +static unsigned long hash(struct super_block *sb, unsigned long hashval)
> +{
> +	unsigned long tmp;
> +
> +	tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) /
> +			L1_CACHE_BYTES;
> +	tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> i_hash_shift);
> +	return tmp & i_hash_mask;
> +}
> +
> +static inline struct hlist_head *i_hash_head(struct super_block *sb,
> +		unsigned int hashval)
> +{
> +	return inode_hashtable + hash(sb, hashval);
> +}
> +
>  /*
>   * Empty aops. Can be used for the cases where the user does not
>   * define any of the address_space operations.
> @@ -475,16 +491,6 @@ static inline void inode_sb_list_del(struct inode *inode)
>  	}
>  }
>  
> -static unsigned long hash(struct super_block *sb, unsigned long hashval)
> -{
> -	unsigned long tmp;
> -
> -	tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) /
> -			L1_CACHE_BYTES;
> -	tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> i_hash_shift);
> -	return tmp & i_hash_mask;
> -}
> -
>  /**
>   *	__insert_inode_hash - hash an inode
>   *	@inode: unhashed inode
> @@ -1073,7 +1079,7 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval,
>  			    int (*test)(struct inode *, void *),
>  			    int (*set)(struct inode *, void *), void *data)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval);
> +	struct hlist_head *head = i_hash_head(inode->i_sb, hashval);
>  	struct inode *old;
>  	bool creating = inode->i_state & I_CREATING;
>  
> @@ -1173,7 +1179,7 @@ EXPORT_SYMBOL(iget5_locked);
>   */
>  struct inode *iget_locked(struct super_block *sb, unsigned long ino)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, ino);
> +	struct hlist_head *head = i_hash_head(sb, ino);
>  	struct inode *inode;
>  again:
>  	spin_lock(&inode_hash_lock);
> @@ -1241,7 +1247,7 @@ EXPORT_SYMBOL(iget_locked);
>   */
>  static int test_inode_iunique(struct super_block *sb, unsigned long ino)
>  {
> -	struct hlist_head *b = inode_hashtable + hash(sb, ino);
> +	struct hlist_head *b = i_hash_head(sb, ino);
>  	struct inode *inode;
>  
>  	hlist_for_each_entry_rcu(inode, b, i_hash) {
> @@ -1328,7 +1334,7 @@ EXPORT_SYMBOL(igrab);
>  struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,
>  		int (*test)(struct inode *, void *), void *data)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, hashval);
> +	struct hlist_head *head = i_hash_head(sb, hashval);
>  	struct inode *inode;
>  
>  	spin_lock(&inode_hash_lock);
> @@ -1383,7 +1389,7 @@ EXPORT_SYMBOL(ilookup5);
>   */
>  struct inode *ilookup(struct super_block *sb, unsigned long ino)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, ino);
> +	struct hlist_head *head = i_hash_head(sb, ino);
>  	struct inode *inode;
>  again:
>  	spin_lock(&inode_hash_lock);
> @@ -1432,7 +1438,7 @@ struct inode *find_inode_nowait(struct super_block *sb,
>  					     void *),
>  				void *data)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, hashval);
> +	struct hlist_head *head = i_hash_head(sb, hashval);
>  	struct inode *inode, *ret_inode = NULL;
>  	int mval;
>  
> @@ -1477,7 +1483,7 @@ EXPORT_SYMBOL(find_inode_nowait);
>  struct inode *find_inode_rcu(struct super_block *sb, unsigned long hashval,
>  			     int (*test)(struct inode *, void *), void *data)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, hashval);
> +	struct hlist_head *head = i_hash_head(sb, hashval);
>  	struct inode *inode;
>  
>  	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
> @@ -1515,7 +1521,7 @@ EXPORT_SYMBOL(find_inode_rcu);
>  struct inode *find_inode_by_ino_rcu(struct super_block *sb,
>  				    unsigned long ino)
>  {
> -	struct hlist_head *head = inode_hashtable + hash(sb, ino);
> +	struct hlist_head *head = i_hash_head(sb, ino);
>  	struct inode *inode;
>  
>  	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
> @@ -1535,7 +1541,7 @@ int insert_inode_locked(struct inode *inode)
>  {
>  	struct super_block *sb = inode->i_sb;
>  	ino_t ino = inode->i_ino;
> -	struct hlist_head *head = inode_hashtable + hash(sb, ino);
> +	struct hlist_head *head = i_hash_head(sb, ino);
>  
>  	while (1) {
>  		struct inode *old = NULL;
> -- 
> 2.31.0
> 

  reply	other threads:[~2021-04-06 22:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 12:33 [RFC PATCH 0/3] vfs: convert inode cache to hlist-bl Dave Chinner
2021-04-06 12:33 ` [PATCH 1/3] vfs: factor out inode hash head calculation Dave Chinner
2021-04-06 22:06   ` Kent Overstreet [this message]
2021-04-06 12:33 ` [PATCH 2/3] hlist-bl: add hlist_bl_fake() Dave Chinner
2021-04-06 22:07   ` Kent Overstreet
2021-04-06 12:33 ` [PATCH 3/3] vfs: inode cache conversion to hash-bl Dave Chinner
2021-04-06 13:28   ` bl_list and lockdep Matthew Wilcox
2021-04-06 21:22     ` Dave Chinner
2021-04-12 15:20       ` Thomas Gleixner
2021-04-12 22:15         ` Dave Chinner
2021-04-12 23:18           ` Thomas Gleixner
2021-04-13  9:58             ` Dave Chinner
2021-04-13 21:24               ` Thomas Gleixner
2021-04-06 22:16   ` [PATCH 3/3] vfs: inode cache conversion to hash-bl Kent Overstreet
2021-04-06 22:03 ` [RFC PATCH 0/3] vfs: convert inode cache to hlist-bl Kent Overstreet

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=YGzbeWxf1r+AivSJ@moria.home.lan \
    --to=kent.overstreet@gmail.com \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).