Skip to content

Commit 8339ee5

Browse files
committed
GFS2: Make resource groups "append only" during life of fs
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>
1 parent 7c9ca62 commit 8339ee5

9 files changed

Lines changed: 95 additions & 174 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
783783
else if (ip->i_depth)
784784
revokes = sdp->sd_inptrs;
785785

786-
if (ip != GFS2_I(sdp->sd_rindex))
787-
error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
788-
else if (!sdp->sd_rgrps)
789-
error = gfs2_ri_update(ip);
790-
791786
if (error)
792787
return error;
793788

@@ -887,8 +882,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
887882
out_rlist:
888883
gfs2_rlist_free(&rlist);
889884
out:
890-
if (ip != GFS2_I(sdp->sd_rindex))
891-
gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
892885
return error;
893886
}
894887

‎fs/gfs2/dir.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,10 +1807,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
18071807
if (error)
18081808
goto out_put;
18091809

1810-
error = gfs2_rindex_hold(sdp, &dip->i_alloc->al_ri_gh);
1811-
if (error)
1812-
goto out_qs;
1813-
18141810
/* Count the number of leaves */
18151811
bh = leaf_bh;
18161812

@@ -1889,8 +1885,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
18891885
gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs);
18901886
out_rlist:
18911887
gfs2_rlist_free(&rlist);
1892-
gfs2_glock_dq_uninit(&dip->i_alloc->al_ri_gh);
1893-
out_qs:
18941888
gfs2_quota_unhold(dip);
18951889
out_put:
18961890
gfs2_alloc_put(dip);

‎fs/gfs2/glops.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ void gfs2_ail_flush(struct gfs2_glock *gl)
134134
static void rgrp_go_sync(struct gfs2_glock *gl)
135135
{
136136
struct address_space *metamapping = gfs2_glock2aspace(gl);
137-
struct gfs2_rgrpd *rgd = gl->gl_object;
138-
unsigned int x;
137+
struct gfs2_rgrpd *rgd;
139138
int error;
140139

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

151-
if (!rgd)
152-
return;
153-
154-
for (x = 0; x < rgd->rd_length; x++) {
155-
struct gfs2_bitmap *bi = rgd->rd_bits + x;
156-
kfree(bi->bi_clone);
157-
bi->bi_clone = NULL;
158-
}
150+
spin_lock(&gl->gl_spin);
151+
rgd = gl->gl_object;
152+
if (rgd)
153+
gfs2_free_clones(rgd);
154+
spin_unlock(&gl->gl_spin);
159155
}
160156

161157
/**

‎fs/gfs2/incore.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ struct gfs2_alloc {
255255

256256
unsigned int al_line;
257257
char *al_file;
258-
struct gfs2_holder al_ri_gh;
259258
struct gfs2_holder al_rgd_gh;
260259
struct gfs2_rgrpd *al_rgd;
261260

‎fs/gfs2/inode.c‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,13 +1041,8 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
10411041
struct buffer_head *bh;
10421042
struct gfs2_holder ghs[3];
10431043
struct gfs2_rgrpd *rgd;
1044-
struct gfs2_holder ri_gh;
10451044
int error;
10461045

1047-
error = gfs2_rindex_hold(sdp, &ri_gh);
1048-
if (error)
1049-
return error;
1050-
10511046
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
10521047
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
10531048

@@ -1104,7 +1099,6 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
11041099
gfs2_glock_dq(ghs);
11051100
out_parent:
11061101
gfs2_holder_uninit(ghs);
1107-
gfs2_glock_dq_uninit(&ri_gh);
11081102
return error;
11091103
}
11101104

@@ -1222,7 +1216,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
12221216
struct gfs2_inode *ip = GFS2_I(odentry->d_inode);
12231217
struct gfs2_inode *nip = NULL;
12241218
struct gfs2_sbd *sdp = GFS2_SB(odir);
1225-
struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, }, ri_gh;
1219+
struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, };
12261220
struct gfs2_rgrpd *nrgd;
12271221
unsigned int num_gh;
12281222
int dir_rename = 0;
@@ -1236,10 +1230,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
12361230
return 0;
12371231
}
12381232

1239-
error = gfs2_rindex_hold(sdp, &ri_gh);
1240-
if (error)
1241-
return error;
1242-
12431233
if (odip != ndip) {
12441234
error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
12451235
0, &r_gh);
@@ -1376,7 +1366,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
13761366

13771367
al->al_requested = sdp->sd_max_dirres;
13781368

1379-
error = gfs2_inplace_reserve_ri(ndip);
1369+
error = gfs2_inplace_reserve(ndip);
13801370
if (error)
13811371
goto out_gunlock_q;
13821372

@@ -1447,7 +1437,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
14471437
if (r_gh.gh_gl)
14481438
gfs2_glock_dq_uninit(&r_gh);
14491439
out:
1450-
gfs2_glock_dq_uninit(&ri_gh);
14511440
return error;
14521441
}
14531442

0 commit comments

Comments
 (0)