Now that sdp->sd_log_tr is defined even when the transaction only indicates revokes, tr_reserved is equivalent to sd_log_blks_reserved, so we can remove it.
Signed-off-by: Andreas Gruenbacher <[email protected]> --- fs/gfs2/incore.h | 1 - fs/gfs2/log.c | 21 ++++++++++----------- fs/gfs2/log.h | 2 +- fs/gfs2/lops.c | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 5489140a52cf..4298df94768a 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -820,7 +820,6 @@ struct gfs2_sbd { spinlock_t sd_log_lock; struct gfs2_trans *sd_log_tr; - unsigned int sd_log_blks_reserved; atomic_t sd_log_pinned; unsigned int sd_log_num_revoke; diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 2d4defc9129d..2fed4b4a7a02 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -702,6 +702,7 @@ void gfs2_glock_remove_revoke(struct gfs2_glock *gl) /** * gfs2_add_aux_revokes - Add as many revokes to the system transaction as we can * @sdp: The GFS2 superblock + * @tr: The transaction * * Our usual strategy is to defer writing revokes as much as we can in the hope * that we'll eventually overwrite the journal, which will make those revokes @@ -711,7 +712,7 @@ void gfs2_glock_remove_revoke(struct gfs2_glock *gl) * been written back. This will basically come at no cost now, and will save * us from having to keep track of those blocks on the AIL2 list later. */ -void gfs2_add_aux_revokes(struct gfs2_sbd *sdp) +void gfs2_add_aux_revokes(struct gfs2_sbd *sdp, struct gfs2_trans *tr) { /* number of revokes we still have room for */ unsigned int max_revokes; @@ -726,7 +727,7 @@ void gfs2_add_aux_revokes(struct gfs2_sbd *sdp) atomic_dec(&sdp->sd_log_blks_free); /* If no blocks have been reserved, we need to also * reserve a block for the header */ - if (!sdp->sd_log_blks_reserved) { + if (!tr) { atomic_dec(&sdp->sd_log_blks_free); trace_gfs2_log_blocks(sdp, -2); } else { @@ -738,7 +739,7 @@ void gfs2_add_aux_revokes(struct gfs2_sbd *sdp) if (!sdp->sd_log_num_revoke) { atomic_inc(&sdp->sd_log_blks_free); - if (!sdp->sd_log_blks_reserved) { + if (!tr) { atomic_inc(&sdp->sd_log_blks_free); trace_gfs2_log_blocks(sdp, 2); } else { @@ -1017,7 +1018,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) gfs2_log_lock(sdp); gfs2_log_update_head(sdp); - sdp->sd_log_blks_reserved = 0; spin_lock(&sdp->sd_ail_lock); if (tr && !list_empty(&tr->tr_ail1_list)) { @@ -1082,6 +1082,7 @@ static void gfs2_merge_trans(struct gfs2_sbd *sdp, struct gfs2_trans *new) WARN_ON_ONCE(!test_bit(TR_ATTACHED, &old->tr_flags)); + old->tr_reserved += new->tr_reserved; old->tr_num_buf_new += new->tr_num_buf_new; old->tr_num_databuf_new += new->tr_num_databuf_new; old->tr_num_buf_rm += new->tr_num_buf_rm; @@ -1102,23 +1103,22 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) { unsigned int reserved; unsigned int unused; - unsigned int maxres; gfs2_log_lock(sdp); if (sdp->sd_log_tr) { gfs2_merge_trans(sdp, tr); + tr = sdp->sd_log_tr; } else { sdp->sd_log_tr = tr; set_bit(TR_ATTACHED, &tr->tr_flags); } - reserved = calc_reserved(sdp); - maxres = sdp->sd_log_blks_reserved + tr->tr_reserved; - gfs2_assert_withdraw(sdp, maxres >= reserved); - unused = maxres - reserved; + reserved = tr->tr_reserved; + tr->tr_reserved = calc_reserved(sdp); + gfs2_assert_withdraw(sdp, reserved >= tr->tr_reserved); + unused = reserved - tr->tr_reserved; gfs2_log_release(sdp, unused); - sdp->sd_log_blks_reserved = reserved; gfs2_log_unlock(sdp); } @@ -1156,7 +1156,6 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) static void gfs2_log_shutdown(struct gfs2_sbd *sdp) { - gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list)); diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index c7f894168600..911276be0e01 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -81,6 +81,6 @@ extern void log_flush_wait(struct gfs2_sbd *sdp); extern int gfs2_logd(void *data); extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); -extern void gfs2_add_aux_revokes(struct gfs2_sbd *sdp); +extern void gfs2_add_aux_revokes(struct gfs2_sbd *sdp, struct gfs2_trans *tr); #endif /* __LOG_DOT_H__ */ diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 3b4e51089bbd..4266195d1f1e 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -845,7 +845,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) struct page *page; unsigned int length; - gfs2_add_aux_revokes(sdp); + gfs2_add_aux_revokes(sdp, tr); if (!sdp->sd_log_num_revoke) return; -- 2.26.2
