Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8339ee54 authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

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: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 7c9ca621
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -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;

@@ -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;
}

+0 −6
Original line number Diff line number Diff line
@@ -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;

@@ -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);
+6 −10
Original line number Diff line number Diff line
@@ -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))
@@ -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);
}

/**
+0 −1
Original line number Diff line number Diff line
@@ -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;

+2 −13
Original line number Diff line number Diff line
@@ -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);

@@ -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;
}

@@ -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;
@@ -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);
@@ -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;

@@ -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;
}

Loading