Skip to content

Commit 03f8c41

Browse files
author
Andreas Gruenbacher
committed
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 <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent ee9c7f9 commit 03f8c41

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

fs/gfs2/rgrp.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,19 +2559,35 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
25592559
if (gfs2_assert_warn(sdp, !rlist->rl_ghs))
25602560
return;
25612561

2562-
if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, block))
2563-
rgd = ip->i_rgd;
2564-
else
2562+
/*
2563+
* The resource group last accessed is kept in the last position.
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;
25652570
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+
25662577
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);
25682580
return;
25692581
}
25702582
ip->i_rgd = rgd;
25712583

2572-
for (x = 0; x < rlist->rl_rgrps; x++)
2573-
if (rlist->rl_rgd[x] == rgd)
2584+
for (x = 0; x < rlist->rl_rgrps; x++) {
2585+
if (rlist->rl_rgd[x] == rgd) {
2586+
swap(rlist->rl_rgd[x],
2587+
rlist->rl_rgd[rlist->rl_rgrps - 1]);
25742588
return;
2589+
}
2590+
}
25752591

25762592
if (rlist->rl_rgrps == rlist->rl_space) {
25772593
new_space = rlist->rl_space + 10;

0 commit comments

Comments
 (0)