Skip to content

Commit b7eba89

Browse files
author
Andreas Gruenbacher
committed
gfs2: Eliminate redundant ip->i_rgd
GFS2 remembers the last rgrp used for allocations in ip->i_rgd. However, block allocations are made by way of a reservations structure, ip->i_res, which keeps the last rgrp in ip->i_res.rs_rgd, and ip->i_res is kept in sync with ip->i_res.rs_rgd, so it's redundant. Get rid of ip->i_rgd and just use ip->i_res.rs_rgd in its place. Based on patches by Robert Peterson. Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent 03f8c41 commit b7eba89

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

fs/gfs2/incore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ struct gfs2_inode {
397397
struct gfs2_holder i_gh; /* for prepare/commit_write only */
398398
struct gfs2_qadata *i_qadata; /* quota allocation data */
399399
struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
400-
struct gfs2_rgrpd *i_rgd;
401400
u64 i_goal; /* goal block for allocations */
402401
struct rw_semaphore i_rw_mutex;
403402
struct list_head i_ordered;

fs/gfs2/rgrp.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,8 +1992,9 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)
19921992
return -EINVAL;
19931993
if (gfs2_rs_active(rs)) {
19941994
begin = rs->rs_rbm.rgd;
1995-
} else if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) {
1996-
rs->rs_rbm.rgd = begin = ip->i_rgd;
1995+
} else if (rs->rs_rbm.rgd &&
1996+
rgrp_contains_block(rs->rs_rbm.rgd, ip->i_goal)) {
1997+
begin = rs->rs_rbm.rgd;
19971998
} else {
19981999
check_and_update_goal(ip);
19992000
rs->rs_rbm.rgd = begin = gfs2_blk2rgrpd(sdp, ip->i_goal, 1);
@@ -2057,8 +2058,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)
20572058
if (rs->rs_rbm.rgd->rd_free_clone >= ap->target ||
20582059
(loops == 2 && ap->min_target &&
20592060
rs->rs_rbm.rgd->rd_free_clone >= ap->min_target)) {
2060-
ip->i_rgd = rs->rs_rbm.rgd;
2061-
ap->allowed = ip->i_rgd->rd_free_clone;
2061+
ap->allowed = rs->rs_rbm.rgd->rd_free_clone;
20622062
return 0;
20632063
}
20642064
check_rgrp:
@@ -2336,7 +2336,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
23362336
{
23372337
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
23382338
struct buffer_head *dibh;
2339-
struct gfs2_rbm rbm = { .rgd = ip->i_rgd, };
2339+
struct gfs2_rbm rbm = { .rgd = ip->i_res.rs_rbm.rgd, };
23402340
unsigned int ndata;
23412341
u64 block; /* block, within the file system scope */
23422342
int error;
@@ -2569,7 +2569,7 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
25692569
return;
25702570
rgd = gfs2_blk2rgrpd(sdp, block, 1);
25712571
} else {
2572-
rgd = ip->i_rgd;
2572+
rgd = ip->i_res.rs_rbm.rgd;
25732573
if (!rgd || !rgrp_contains_block(rgd, block))
25742574
rgd = gfs2_blk2rgrpd(sdp, block, 1);
25752575
}
@@ -2579,7 +2579,6 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
25792579
(unsigned long long)block);
25802580
return;
25812581
}
2582-
ip->i_rgd = rgd;
25832582

25842583
for (x = 0; x < rlist->rl_rgrps; x++) {
25852584
if (rlist->rl_rgd[x] == rgd) {

fs/gfs2/super.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,6 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
17291729
if (ip) {
17301730
ip->i_flags = 0;
17311731
ip->i_gl = NULL;
1732-
ip->i_rgd = NULL;
17331732
memset(&ip->i_res, 0, sizeof(ip->i_res));
17341733
RB_CLEAR_NODE(&ip->i_res.rs_node);
17351734
ip->i_rahead = 0;

fs/gfs2/trans.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ struct gfs2_glock;
3030
* block, or all of the blocks in the rg, whichever is smaller */
3131
static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip, unsigned requested)
3232
{
33-
if (requested < ip->i_rgd->rd_length)
33+
struct gfs2_rgrpd *rgd = ip->i_res.rs_rbm.rgd;
34+
35+
if (requested < rgd->rd_length)
3436
return requested + 1;
35-
return ip->i_rgd->rd_length;
37+
return rgd->rd_length;
3638
}
3739

3840
extern int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,

0 commit comments

Comments
 (0)