提交 905d2aef 编写于 作者: B Bob Peterson 提交者: Steven Whitehouse

[GFS2] Move some code inside the log lock

This is the first of five patches for bug #248176:

There were still some critical variables being manipulated outside
the log_lock spinlock.  That usually resulted in a hang.
Signed-off-by: NBob Peterson <rpeterso@redhat.com>
Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
上级 7b08fc62
...@@ -117,7 +117,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -117,7 +117,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
struct buffer_head *bh; struct buffer_head *bh;
struct gfs2_log_descriptor *ld; struct gfs2_log_descriptor *ld;
struct gfs2_bufdata *bd1 = NULL, *bd2; struct gfs2_bufdata *bd1 = NULL, *bd2;
unsigned int total = sdp->sd_log_num_buf; unsigned int total;
unsigned int offset = BUF_OFFSET; unsigned int offset = BUF_OFFSET;
unsigned int limit; unsigned int limit;
unsigned int num; unsigned int num;
...@@ -127,12 +127,16 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -127,12 +127,16 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
limit = buf_limit(sdp); limit = buf_limit(sdp);
/* for 4k blocks, limit = 503 */ /* for 4k blocks, limit = 503 */
gfs2_log_lock(sdp);
total = sdp->sd_log_num_buf;
bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list); bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list);
while(total) { while(total) {
num = total; num = total;
if (total > limit) if (total > limit)
num = limit; num = limit;
gfs2_log_unlock(sdp);
bh = gfs2_log_get_buf(sdp); bh = gfs2_log_get_buf(sdp);
gfs2_log_lock(sdp);
ld = (struct gfs2_log_descriptor *)bh->b_data; ld = (struct gfs2_log_descriptor *)bh->b_data;
ptr = (__be64 *)(bh->b_data + offset); ptr = (__be64 *)(bh->b_data + offset);
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
...@@ -152,21 +156,27 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -152,21 +156,27 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
break; break;
} }
gfs2_log_unlock(sdp);
set_buffer_dirty(bh); set_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh); ll_rw_block(WRITE, 1, &bh);
gfs2_log_lock(sdp);
n = 0; n = 0;
list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf, list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf,
bd_le.le_list) { bd_le.le_list) {
gfs2_log_unlock(sdp);
bh = gfs2_log_fake_buf(sdp, bd2->bd_bh); bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
set_buffer_dirty(bh); set_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh); ll_rw_block(WRITE, 1, &bh);
gfs2_log_lock(sdp);
if (++n >= num) if (++n >= num)
break; break;
} }
BUG_ON(total < num);
total -= num; total -= num;
} }
gfs2_log_unlock(sdp);
} }
static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
...@@ -524,7 +534,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -524,7 +534,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
struct gfs2_log_descriptor *ld; struct gfs2_log_descriptor *ld;
unsigned int limit; unsigned int limit;
unsigned int total_dbuf; unsigned int total_dbuf;
unsigned int total_jdata = sdp->sd_log_num_jdata; unsigned int total_jdata;
unsigned int num, n; unsigned int num, n;
__be64 *ptr = NULL; __be64 *ptr = NULL;
...@@ -536,6 +546,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -536,6 +546,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
*/ */
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
total_dbuf = sdp->sd_log_num_databuf; total_dbuf = sdp->sd_log_num_databuf;
total_jdata = sdp->sd_log_num_jdata;
bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf,
bd_le.le_list); bd_le.le_list);
while(total_dbuf) { while(total_dbuf) {
...@@ -621,10 +632,10 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) ...@@ -621,10 +632,10 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
} }
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
if (bh) { if (bh) {
set_buffer_mapped(bh);
set_buffer_dirty(bh); set_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh); ll_rw_block(WRITE, 1, &bh);
bh = NULL; bh = NULL;
ptr = NULL;
} }
n = 0; n = 0;
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册