Skip to content

Commit

Permalink
GFS2: Make resource groups "append only" during life of fs
Browse files Browse the repository at this point in the history
Since we have ruled out supporting online filesystem shrink,
it is possible to make the resource group list append only
during the life of a super block. This gives several benefits:

Firstly, we only need to read new rindex elements as they are added
rather than needing to reread the whole rindex file each time one
element is added.

Secondly, the rindex glock can be held for much shorter periods of
time, and is completely removed from the fast path for allocations.
The lock is taken in shared mode only when updating the resource
groups when the first allocation occurs, and after a grow has
taken place.

Thirdly, this results in a reduction in code size, and everything
gets a lot simpler to understand in this area.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Steven Whitehouse committed Oct 21, 2011
1 parent 7c9ca62 commit 8339ee5
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 174 deletions.
7 changes: 0 additions & 7 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
else if (ip->i_depth)
revokes = sdp->sd_inptrs;

if (ip != GFS2_I(sdp->sd_rindex))
error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
else if (!sdp->sd_rgrps)
error = gfs2_ri_update(ip);

if (error)
return error;

Expand Down Expand Up @@ -887,8 +882,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
out_rlist:
gfs2_rlist_free(&rlist);
out:
if (ip != GFS2_I(sdp->sd_rindex))
gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
return error;
}

Expand Down
6 changes: 0 additions & 6 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,10 +1807,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
if (error)
goto out_put;

error = gfs2_rindex_hold(sdp, &dip->i_alloc->al_ri_gh);
if (error)
goto out_qs;

/* Count the number of leaves */
bh = leaf_bh;

Expand Down Expand Up @@ -1889,8 +1885,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs);
out_rlist:
gfs2_rlist_free(&rlist);
gfs2_glock_dq_uninit(&dip->i_alloc->al_ri_gh);
out_qs:
gfs2_quota_unhold(dip);
out_put:
gfs2_alloc_put(dip);
Expand Down
16 changes: 6 additions & 10 deletions fs/gfs2/glops.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ void gfs2_ail_flush(struct gfs2_glock *gl)
static void rgrp_go_sync(struct gfs2_glock *gl)
{
struct address_space *metamapping = gfs2_glock2aspace(gl);
struct gfs2_rgrpd *rgd = gl->gl_object;
unsigned int x;
struct gfs2_rgrpd *rgd;
int error;

if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
Expand All @@ -148,14 +147,11 @@ static void rgrp_go_sync(struct gfs2_glock *gl)
mapping_set_error(metamapping, error);
gfs2_ail_empty_gl(gl);

if (!rgd)
return;

for (x = 0; x < rgd->rd_length; x++) {
struct gfs2_bitmap *bi = rgd->rd_bits + x;
kfree(bi->bi_clone);
bi->bi_clone = NULL;
}
spin_lock(&gl->gl_spin);
rgd = gl->gl_object;
if (rgd)
gfs2_free_clones(rgd);
spin_unlock(&gl->gl_spin);
}

/**
Expand Down
1 change: 0 additions & 1 deletion fs/gfs2/incore.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ struct gfs2_alloc {

unsigned int al_line;
char *al_file;
struct gfs2_holder al_ri_gh;
struct gfs2_holder al_rgd_gh;
struct gfs2_rgrpd *al_rgd;

Expand Down
15 changes: 2 additions & 13 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,13 +1041,8 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
struct buffer_head *bh;
struct gfs2_holder ghs[3];
struct gfs2_rgrpd *rgd;
struct gfs2_holder ri_gh;
int error;

error = gfs2_rindex_hold(sdp, &ri_gh);
if (error)
return error;

gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);

Expand Down Expand Up @@ -1104,7 +1099,6 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
gfs2_glock_dq(ghs);
out_parent:
gfs2_holder_uninit(ghs);
gfs2_glock_dq_uninit(&ri_gh);
return error;
}

Expand Down Expand Up @@ -1222,7 +1216,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
struct gfs2_inode *ip = GFS2_I(odentry->d_inode);
struct gfs2_inode *nip = NULL;
struct gfs2_sbd *sdp = GFS2_SB(odir);
struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, }, ri_gh;
struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, };
struct gfs2_rgrpd *nrgd;
unsigned int num_gh;
int dir_rename = 0;
Expand All @@ -1236,10 +1230,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
return 0;
}

error = gfs2_rindex_hold(sdp, &ri_gh);
if (error)
return error;

if (odip != ndip) {
error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
0, &r_gh);
Expand Down Expand Up @@ -1376,7 +1366,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,

al->al_requested = sdp->sd_max_dirres;

error = gfs2_inplace_reserve_ri(ndip);
error = gfs2_inplace_reserve(ndip);
if (error)
goto out_gunlock_q;

Expand Down Expand Up @@ -1447,7 +1437,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
if (r_gh.gh_gl)
gfs2_glock_dq_uninit(&r_gh);
out:
gfs2_glock_dq_uninit(&ri_gh);
return error;
}

Expand Down
Loading

0 comments on commit 8339ee5

Please sign in to comment.