aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/rgrp.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2012-03-05 09:20:59 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2012-03-05 10:06:56 -0500
commit6aad1c3d3eba3db38b3a1200e2b02ff3af501c5a (patch)
tree08643be75568eac3745f9fddce4f6fef27a6de70 /fs/gfs2/rgrp.c
parenta08fd280b58836c910a4af10eee2066e358d16db (diff)
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 is unnecessary. Since gfs2_grow writes to the rindex via the meta_fs, the mutex is in the wrong order according to the normal rules. This patch eliminates the mutex entirely to avoid the problem. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r--fs/gfs2/rgrp.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index e09370eec590..6ff9f17f9ac2 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -540,7 +540,6 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
540 struct file_ra_state ra_state; 540 struct file_ra_state ra_state;
541 int error, rgrps; 541 int error, rgrps;
542 542
543 mutex_lock(&sdp->sd_rindex_mutex);
544 file_ra_state_init(&ra_state, inode->i_mapping); 543 file_ra_state_init(&ra_state, inode->i_mapping);
545 for (rgrps = 0;; rgrps++) { 544 for (rgrps = 0;; rgrps++) {
546 loff_t pos = rgrps * sizeof(struct gfs2_rindex); 545 loff_t pos = rgrps * sizeof(struct gfs2_rindex);
@@ -553,11 +552,10 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
553 break; 552 break;
554 total_data += be32_to_cpu(((struct gfs2_rindex *)buf)->ri_data); 553 total_data += be32_to_cpu(((struct gfs2_rindex *)buf)->ri_data);
555 } 554 }
556 mutex_unlock(&sdp->sd_rindex_mutex);
557 return total_data; 555 return total_data;
558} 556}
559 557
560static void rgd_insert(struct gfs2_rgrpd *rgd) 558static int rgd_insert(struct gfs2_rgrpd *rgd)
561{ 559{
562 struct gfs2_sbd *sdp = rgd->rd_sbd; 560 struct gfs2_sbd *sdp = rgd->rd_sbd;
563 struct rb_node **newn = &sdp->sd_rindex_tree.rb_node, *parent = NULL; 561 struct rb_node **newn = &sdp->sd_rindex_tree.rb_node, *parent = NULL;
@@ -573,11 +571,13 @@ static void rgd_insert(struct gfs2_rgrpd *rgd)
573 else if (rgd->rd_addr > cur->rd_addr) 571 else if (rgd->rd_addr > cur->rd_addr)
574 newn = &((*newn)->rb_right); 572 newn = &((*newn)->rb_right);
575 else 573 else
576 return; 574 return -EEXIST;
577 } 575 }
578 576
579 rb_link_node(&rgd->rd_node, parent, newn); 577 rb_link_node(&rgd->rd_node, parent, newn);
580 rb_insert_color(&rgd->rd_node, &sdp->sd_rindex_tree); 578 rb_insert_color(&rgd->rd_node, &sdp->sd_rindex_tree);
579 sdp->sd_rgrps++;
580 return 0;
581} 581}
582 582
583/** 583/**
@@ -631,10 +631,12 @@ static int read_rindex_entry(struct gfs2_inode *ip,
631 if (rgd->rd_data > sdp->sd_max_rg_data) 631 if (rgd->rd_data > sdp->sd_max_rg_data)
632 sdp->sd_max_rg_data = rgd->rd_data; 632 sdp->sd_max_rg_data = rgd->rd_data;
633 spin_lock(&sdp->sd_rindex_spin); 633 spin_lock(&sdp->sd_rindex_spin);
634 rgd_insert(rgd); 634 error = rgd_insert(rgd);
635 sdp->sd_rgrps++;
636 spin_unlock(&sdp->sd_rindex_spin); 635 spin_unlock(&sdp->sd_rindex_spin);
637 return error; 636 if (!error)
637 return 0;
638
639 error = 0; /* someone else read in the rgrp; free it and ignore it */
638 640
639fail: 641fail:
640 kfree(rgd->rd_bits); 642 kfree(rgd->rd_bits);
@@ -695,22 +697,18 @@ int gfs2_rindex_update(struct gfs2_sbd *sdp)
695 697
696 /* Read new copy from disk if we don't have the latest */ 698 /* Read new copy from disk if we don't have the latest */
697 if (!sdp->sd_rindex_uptodate) { 699 if (!sdp->sd_rindex_uptodate) {
698 mutex_lock(&sdp->sd_rindex_mutex);
699 if (!gfs2_glock_is_locked_by_me(gl)) { 700 if (!gfs2_glock_is_locked_by_me(gl)) {
700 error = gfs2_glock_nq_init(gl, LM_ST_SHARED, 0, &ri_gh); 701 error = gfs2_glock_nq_init(gl, LM_ST_SHARED, 0, &ri_gh);
701 if (error) 702 if (error)
702 goto out_unlock; 703 return error;
703 unlock_required = 1; 704 unlock_required = 1;
704 } 705 }
705 if (!sdp->sd_rindex_uptodate) 706 if (!sdp->sd_rindex_uptodate)
706 error = gfs2_ri_update(ip); 707 error = gfs2_ri_update(ip);
707 if (unlock_required) 708 if (unlock_required)
708 gfs2_glock_dq_uninit(&ri_gh); 709 gfs2_glock_dq_uninit(&ri_gh);
709out_unlock:
710 mutex_unlock(&sdp->sd_rindex_mutex);
711 } 710 }
712 711
713
714 return error; 712 return error;
715} 713}
716 714