diff options
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 1 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 22 |
3 files changed, 10 insertions, 14 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 4d546df58ac9..47d0bda5ac2b 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -644,7 +644,6 @@ struct gfs2_sbd { | |||
644 | 644 | ||
645 | int sd_rindex_uptodate; | 645 | int sd_rindex_uptodate; |
646 | spinlock_t sd_rindex_spin; | 646 | spinlock_t sd_rindex_spin; |
647 | struct mutex sd_rindex_mutex; | ||
648 | struct rb_root sd_rindex_tree; | 647 | struct rb_root sd_rindex_tree; |
649 | unsigned int sd_rgrps; | 648 | unsigned int sd_rgrps; |
650 | unsigned int sd_max_rg_data; | 649 | unsigned int sd_max_rg_data; |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index a55baa7f3239..ae5e0a40c9b3 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) | |||
83 | spin_lock_init(&sdp->sd_statfs_spin); | 83 | spin_lock_init(&sdp->sd_statfs_spin); |
84 | 84 | ||
85 | spin_lock_init(&sdp->sd_rindex_spin); | 85 | spin_lock_init(&sdp->sd_rindex_spin); |
86 | mutex_init(&sdp->sd_rindex_mutex); | ||
87 | sdp->sd_rindex_tree.rb_node = NULL; | 86 | sdp->sd_rindex_tree.rb_node = NULL; |
88 | 87 | ||
89 | INIT_LIST_HEAD(&sdp->sd_jindex_list); | 88 | INIT_LIST_HEAD(&sdp->sd_jindex_list); |
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 | ||
560 | static void rgd_insert(struct gfs2_rgrpd *rgd) | 558 | static 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 | ||
639 | fail: | 641 | fail: |
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); |
709 | out_unlock: | ||
710 | mutex_unlock(&sdp->sd_rindex_mutex); | ||
711 | } | 710 | } |
712 | 711 | ||
713 | |||
714 | return error; | 712 | return error; |
715 | } | 713 | } |
716 | 714 | ||