GFS2: Move log buffer accounting to transaction
From 928b2a81bde301e52f9dba2cae56e7b99ded07df Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Fri, 21 Feb 2014 21:55:33 +0000
Subject: GFS2: Move log buffer accounting to transaction
Now we have a master transaction into which other transactions are merged, the accounting can be done using this master transaction. We no longer require the superblock fields which were being used for this function.
In addition, this allows for a clean up in calc_reserved() making it rather easier understand. Also, by reducing the number of variables used to track the buffers being added and removed from the journal, a number of error checks are now no longer required.
Signed-off-by Steven Whitehouse <[email protected]>
fs/gfs2/incore.h +0 -5
@@ -748,15 +748,10 @@ struct gfs2_sbd {struct gfs2_trans *sd_log_tr;unsigned int sd_log_blks_reserved; -unsigned int sd_log_commited_buf; -unsigned int sd_log_commited_databuf;int sd_log_commited_revoke;atomic_t sd_log_pinned; -unsigned int sd_log_num_buf;unsigned int sd_log_num_revoke; -unsigned int sd_log_num_rg; -unsigned int sd_log_num_databuf;struct list_head sd_log_le_revoke;struct list_head sd_log_le_ordered;
fs/gfs2/log.c +24 -43
113 lines not on this page · raw message
fs/gfs2/lops.c +7 -8
@@ -494,9 +494,11 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,static void buf_lo_before_commit (struct gfs2_sbd *sdp,struct gfs2_trans *tr) {unsigned int limit =buf_limit (sdp);/* 503 for 4k blocks */ +unsigned int nbuf;if (tr ==NULL )return ; -gfs2_before_commit (sdp, limit, sdp->sd_log_num_buf, &tr->tr_buf,0 ); + nbuf = tr->tr_num_buf_new - tr->tr_num_buf_rm; +gfs2_before_commit (sdp, limit, nbuf, &tr->tr_buf,0 ); }static void buf_lo_after_commit (struct gfs2_sbd *sdp,struct gfs2_trans *tr)
@@ -511,11 +513,8 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)while (!list_empty (head)) { bd = list_entry(head->next, struct gfs2_bufdata, bd_list);list_del_init (&bd->bd_list); - sdp->sd_log_num_buf--; -gfs2_unpin (sdp, bd->bd_bh, tr); } -gfs2_assert_warn (sdp, !sdp->sd_log_num_buf); } static void buf_lo_before_scan(struct gfs2_jdesc *jd,
@@ -761,10 +760,12 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)static void databuf_lo_before_commit (struct gfs2_sbd *sdp,struct gfs2_trans *tr) { -unsigned int limit =buf_limit (sdp) /2 ; +unsigned int limit =databuf_limit (sdp); +unsigned int nbuf;if (tr ==NULL )return ; -gfs2_before_commit (sdp, limit, sdp->sd_log_num_databuf, &tr->tr_databuf,1 ); + nbuf = tr->tr_num_databuf_new - tr->tr_num_databuf_rm; +gfs2_before_commit (sdp, limit, nbuf, &tr->tr_databuf,1 ); } static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -849,10 +850,8 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)while (!list_empty (head)) { bd = list_entry(head->next, struct gfs2_bufdata, bd_list);list_del_init (&bd->bd_list); - sdp->sd_log_num_databuf--;gfs2_unpin (sdp, bd->bd_bh, tr); } -gfs2_assert_warn (sdp, !sdp->sd_log_num_databuf); }
fs/gfs2/meta_io.c +2 -7
@@ -267,15 +267,10 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, inttrace_gfs2_pin (bd,0 );atomic_dec (&sdp->sd_log_pinned);list_del_init (&bd->bd_list); -if (meta) { -gfs2_assert_warn (sdp, sdp->sd_log_num_buf); - sdp->sd_log_num_buf--; +if (meta) tr->tr_num_buf_rm++; - }else { -gfs2_assert_warn (sdp, sdp->sd_log_num_databuf); - sdp->sd_log_num_databuf--; +else tr->tr_num_databuf_rm++; - } tr->tr_touched =1 ; was_pinned =1 ;brelse (bh);
fs/gfs2/trans.c +0 -2
@@ -213,7 +213,6 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)set_bit (GLF_DIRTY , &bd->bd_gl->gl_flags);gfs2_pin (sdp, bd->bd_bh); tr->tr_num_databuf_new++; - sdp->sd_log_num_databuf++;list_add_tail (&bd->bd_list, &tr->tr_databuf); }gfs2_log_unlock (sdp);
@@ -241,7 +240,6 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)gfs2_pin (sdp, bd->bd_bh); mh->__pad0 =cpu_to_be64 (0 ); mh->mh_jid =cpu_to_be32 (sdp->sd_jdesc->jd_jid); - sdp->sd_log_num_buf++;list_add (&bd->bd_list, &tr->tr_buf); tr->tr_num_buf_new++; }
Signature · 1 line
1.8.3.1