aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2018-06-21 08:22:12 -0400
committerAndreas Gruenbacher <agruenba@redhat.com>2018-07-04 16:38:42 -0400
commit03f8c41c73da849ec2b73aa678ce6380e8318920 (patch)
tree40109f5cb0c25276a6d14da5c4cbbb27e731475a
parentee9c7f9ae3d4fb9fb5c9cacbe3880d5dd66feb16 (diff)
gfs2: Stop messing with ip->i_rgd in the rlist code
In the resource group list code, keep the last resource group added in the last position in the array. Check against that instead of messing with ip->i_rgd. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r--fs/gfs2/rgrp.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7a001f6e8aee..ecdc4cb5b6ad 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2559,19 +2559,35 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
2559 if (gfs2_assert_warn(sdp, !rlist->rl_ghs)) 2559 if (gfs2_assert_warn(sdp, !rlist->rl_ghs))
2560 return; 2560 return;
2561 2561
2562 if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, block)) 2562 /*
2563 rgd = ip->i_rgd; 2563 * The resource group last accessed is kept in the last position.
2564 else 2564 */
2565
2566 if (rlist->rl_rgrps) {
2567 rgd = rlist->rl_rgd[rlist->rl_rgrps - 1];
2568 if (rgrp_contains_block(rgd, block))
2569 return;
2565 rgd = gfs2_blk2rgrpd(sdp, block, 1); 2570 rgd = gfs2_blk2rgrpd(sdp, block, 1);
2571 } else {
2572 rgd = ip->i_rgd;
2573 if (!rgd || !rgrp_contains_block(rgd, block))
2574 rgd = gfs2_blk2rgrpd(sdp, block, 1);
2575 }
2576
2566 if (!rgd) { 2577 if (!rgd) {
2567 fs_err(sdp, "rlist_add: no rgrp for block %llu\n", (unsigned long long)block); 2578 fs_err(sdp, "rlist_add: no rgrp for block %llu\n",
2579 (unsigned long long)block);
2568 return; 2580 return;
2569 } 2581 }
2570 ip->i_rgd = rgd; 2582 ip->i_rgd = rgd;
2571 2583
2572 for (x = 0; x < rlist->rl_rgrps; x++) 2584 for (x = 0; x < rlist->rl_rgrps; x++) {
2573 if (rlist->rl_rgd[x] == rgd) 2585 if (rlist->rl_rgd[x] == rgd) {
2586 swap(rlist->rl_rgd[x],
2587 rlist->rl_rgd[rlist->rl_rgrps - 1]);
2574 return; 2588 return;
2589 }
2590 }
2575 2591
2576 if (rlist->rl_rgrps == rlist->rl_space) { 2592 if (rlist->rl_rgrps == rlist->rl_space) {
2577 new_space = rlist->rl_space + 10; 2593 new_space = rlist->rl_space + 10;