Commit e317ffcb authored by Steven Whitehouse's avatar Steven Whitehouse

[GFS2] Remove uneeded memory allocation

For every filesystem operation where we need a transaction, we
now make one less memory allocation.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent b3f58d8f
...@@ -360,7 +360,7 @@ struct gfs2_trans { ...@@ -360,7 +360,7 @@ struct gfs2_trans {
unsigned int tr_revokes; unsigned int tr_revokes;
unsigned int tr_reserved; unsigned int tr_reserved;
struct gfs2_holder *tr_t_gh; struct gfs2_holder tr_t_gh;
int tr_touched; int tr_touched;
......
...@@ -53,18 +53,15 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, ...@@ -53,18 +53,15 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks,
sizeof(uint64_t)); sizeof(uint64_t));
INIT_LIST_HEAD(&tr->tr_list_buf); INIT_LIST_HEAD(&tr->tr_list_buf);
error = -ENOMEM; gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED,
tr->tr_t_gh = gfs2_holder_get(sdp->sd_trans_gl, LM_ST_SHARED, GL_NEVER_RECURSE, &tr->tr_t_gh);
GL_NEVER_RECURSE, GFP_NOFS);
if (!tr->tr_t_gh)
goto fail;
error = gfs2_glock_nq(tr->tr_t_gh); error = gfs2_glock_nq(&tr->tr_t_gh);
if (error) if (error)
goto fail_holder_put; goto fail_holder_uninit;
if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
tr->tr_t_gh->gh_flags |= GL_NOCACHE; tr->tr_t_gh.gh_flags |= GL_NOCACHE;
error = -EROFS; error = -EROFS;
goto fail_gunlock; goto fail_gunlock;
} }
...@@ -78,12 +75,10 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, ...@@ -78,12 +75,10 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks,
return 0; return 0;
fail_gunlock: fail_gunlock:
gfs2_glock_dq(tr->tr_t_gh); gfs2_glock_dq(&tr->tr_t_gh);
fail_holder_put: fail_holder_uninit:
gfs2_holder_put(tr->tr_t_gh); gfs2_holder_uninit(&tr->tr_t_gh);
fail:
kfree(tr); kfree(tr);
return error; return error;
...@@ -100,16 +95,15 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) ...@@ -100,16 +95,15 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
if (gfs2_assert_warn(sdp, tr)) if (gfs2_assert_warn(sdp, tr))
return; return;
t_gh = tr->tr_t_gh; t_gh = &tr->tr_t_gh;
tr->tr_t_gh = NULL;
if (!tr->tr_touched) { if (!tr->tr_touched) {
gfs2_log_release(sdp, tr->tr_reserved); gfs2_log_release(sdp, tr->tr_reserved);
kfree(tr);
gfs2_glock_dq(t_gh); gfs2_glock_dq(t_gh);
gfs2_holder_put(t_gh); gfs2_holder_uninit(t_gh);
kfree(tr);
return; return;
} }
...@@ -127,7 +121,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) ...@@ -127,7 +121,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
gfs2_log_commit(sdp, tr); gfs2_log_commit(sdp, tr);
gfs2_glock_dq(t_gh); gfs2_glock_dq(t_gh);
gfs2_holder_put(t_gh); gfs2_holder_uninit(t_gh);
if (sdp->sd_vfs->s_flags & MS_SYNCHRONOUS) if (sdp->sd_vfs->s_flags & MS_SYNCHRONOUS)
gfs2_log_flush(sdp); gfs2_log_flush(sdp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment