diff options
author | Bob Peterson <rpeterso@redhat.com> | 2017-01-25 18:57:42 +0100 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2017-01-27 14:20:41 +0100 |
commit | 192738b711d3e41a7326347db5d6923d2136b6d0 (patch) | |
tree | abe4a58b3e7f4208c1cfc419afff3018ed249c70 /fs/gfs2 | |
parent | GFS2: Switch tr_touched to flag in transaction (diff) | |
download | linux-192738b711d3e41a7326347db5d6923d2136b6d0.tar.xz linux-192738b711d3e41a7326347db5d6923d2136b6d0.zip |
GFS2: Inline function meta_lo_add
This patch simply combines function meta_lo_add with its only
caller, trans_add_meta. This makes the code easier to read and
will make it easier to reduce contention on gfs2_log_lock.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/trans.c | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 5d7f5b08d600..483c5a7e16d4 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -195,16 +195,35 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) unlock_buffer(bh); } -static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) +void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) { + + struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; + struct gfs2_bufdata *bd; struct gfs2_meta_header *mh; struct gfs2_trans *tr; enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); + lock_buffer(bh); + gfs2_log_lock(sdp); + bd = bh->b_private; + if (bd == NULL) { + gfs2_log_unlock(sdp); + unlock_buffer(bh); + lock_page(bh->b_page); + if (bh->b_private == NULL) + bd = gfs2_alloc_bufdata(gl, bh, &gfs2_buf_lops); + else + bd = bh->b_private; + unlock_page(bh->b_page); + lock_buffer(bh); + gfs2_log_lock(sdp); + } + gfs2_assert(sdp, bd->bd_gl == gl); tr = current->journal_info; set_bit(TR_TOUCHED, &tr->tr_flags); if (!list_empty(&bd->bd_list)) - return; + goto out_unlock; set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); mh = (struct gfs2_meta_header *)bd->bd_bh->b_data; @@ -222,31 +241,7 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); list_add(&bd->bd_list, &tr->tr_buf); tr->tr_num_buf_new++; -} - -void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh) -{ - - struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; - struct gfs2_bufdata *bd; - - lock_buffer(bh); - gfs2_log_lock(sdp); - bd = bh->b_private; - if (bd == NULL) { - gfs2_log_unlock(sdp); - unlock_buffer(bh); - lock_page(bh->b_page); - if (bh->b_private == NULL) - bd = gfs2_alloc_bufdata(gl, bh, &gfs2_buf_lops); - else - bd = bh->b_private; - unlock_page(bh->b_page); - lock_buffer(bh); - gfs2_log_lock(sdp); - } - gfs2_assert(sdp, bd->bd_gl == gl); - meta_lo_add(sdp, bd); +out_unlock: gfs2_log_unlock(sdp); unlock_buffer(bh); } |