cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH] GFS2: Eliminate sd_rindex_mutex
Date: Mon, 05 Mar 2012 12:20:43 +0000	[thread overview]
Message-ID: <1330950043.2699.26.camel@menhir> (raw)
In-Reply-To: <4140d273-491b-4f98-8dc7-dea0be323c03@zmail12.collab.prod.int.phx2.redhat.com>

Hi,

On Fri, 2012-03-02 at 14:28 -0500, Bob Peterson wrote:
> Hi,
> 
> This patch eliminates the sd_rindex_mutex altogether.
> See comments below:
> 
> Regards,
> 
> Bob Peterson
> Red Hat File Systems
> 
> Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
> --
> GFS2: Eliminate sd_rindex_mutex
> 
> Over time, we've slowly eliminated the use of sd_rindex_mutex.
> Up to this point, it was only used in two places: function
> gfs2_ri_total (which totals the file system size by reading
> and parsing the rindex file) and function gfs2_rindex_update
> which updates the rgrps in memory. Both of these functions have
> the rindex glock to protect them, so the rindex mutex is unnecessary.
> --
> diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
> index 4d546df..47d0bda 100644
> --- a/fs/gfs2/incore.h
> +++ b/fs/gfs2/incore.h
> @@ -644,7 +644,6 @@ struct gfs2_sbd {
>  
>  	int sd_rindex_uptodate;
>  	spinlock_t sd_rindex_spin;
> -	struct mutex sd_rindex_mutex;
>  	struct rb_root sd_rindex_tree;
>  	unsigned int sd_rgrps;
>  	unsigned int sd_max_rg_data;
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index a55baa7..ae5e0a4 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -83,7 +83,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
>  	spin_lock_init(&sdp->sd_statfs_spin);
>  
>  	spin_lock_init(&sdp->sd_rindex_spin);
> -	mutex_init(&sdp->sd_rindex_mutex);
>  	sdp->sd_rindex_tree.rb_node = NULL;
>  
>  	INIT_LIST_HEAD(&sdp->sd_jindex_list);
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index e09370e..f9bf429 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -540,7 +540,6 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
>  	struct file_ra_state ra_state;
>  	int error, rgrps;
>  
> -	mutex_lock(&sdp->sd_rindex_mutex);
>  	file_ra_state_init(&ra_state, inode->i_mapping);
>  	for (rgrps = 0;; rgrps++) {
>  		loff_t pos = rgrps * sizeof(struct gfs2_rindex);
> @@ -553,7 +552,6 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
>  			break;
>  		total_data += be32_to_cpu(((struct gfs2_rindex *)buf)->ri_data);
>  	}
> -	mutex_unlock(&sdp->sd_rindex_mutex);
>  	return total_data;
>  }
>  
> @@ -695,22 +693,18 @@ int gfs2_rindex_update(struct gfs2_sbd *sdp)
>  
>  	/* Read new copy from disk if we don't have the latest */
>  	if (!sdp->sd_rindex_uptodate) {
> -		mutex_lock(&sdp->sd_rindex_mutex);
>  		if (!gfs2_glock_is_locked_by_me(gl)) {
>  			error = gfs2_glock_nq_init(gl, LM_ST_SHARED, 0, &ri_gh);
>  			if (error)
> -				goto out_unlock;
> +				return error;
>  			unlock_required = 1;
>  		}
>  		if (!sdp->sd_rindex_uptodate)
>  			error = gfs2_ri_update(ip);
>  		if (unlock_required)
>  			gfs2_glock_dq_uninit(&ri_gh);
> -out_unlock:
> -		mutex_unlock(&sdp->sd_rindex_mutex);
>  	}
>  
> -
>  	return error;
>  }
>  
> 


Bearing in mind that the mutex is an exclusive lock and the glock is
only a shared lock, do we have any other protection against the rgrp
tree being updated simultaneously?

Steve.




  reply	other threads:[~2012-03-05 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <950f35d3-b138-4bd6-b4eb-240106d088cc@zmail12.collab.prod.int.phx2.redhat.com>
2012-03-02 19:28 ` [Cluster-devel] [GFS2 PATCH] GFS2: Eliminate sd_rindex_mutex Bob Peterson
2012-03-05 12:20   ` Steven Whitehouse [this message]
2012-03-05 13:33     ` Bob Peterson
2012-03-05 13:49       ` [Cluster-devel] [GFS2 PATCH TRY #2] " Bob Peterson
2012-03-05 14:20         ` [Cluster-devel] [GFS2 PATCH TRY #3] " Bob Peterson
2012-03-05 16:24           ` Steven Whitehouse
2012-03-05 13:51       ` [Cluster-devel] [GFS2 PATCH] " Steven Whitehouse

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=1330950043.2699.26.camel@menhir \
    --to=swhiteho@redhat.com \
    /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).