diff options
Diffstat (limited to 'fs/gfs2/lops.c')
-rw-r--r-- | fs/gfs2/lops.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index f82d84d05d23..aff70f0698fd 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #include "gfs2.h" | 18 | #include "gfs2.h" |
19 | #include "incore.h" | 19 | #include "incore.h" |
20 | #include "inode.h" | ||
20 | #include "glock.h" | 21 | #include "glock.h" |
21 | #include "log.h" | 22 | #include "log.h" |
22 | #include "lops.h" | 23 | #include "lops.h" |
@@ -117,15 +118,13 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) | |||
117 | struct gfs2_log_descriptor *ld; | 118 | struct gfs2_log_descriptor *ld; |
118 | struct gfs2_bufdata *bd1 = NULL, *bd2; | 119 | struct gfs2_bufdata *bd1 = NULL, *bd2; |
119 | unsigned int total = sdp->sd_log_num_buf; | 120 | unsigned int total = sdp->sd_log_num_buf; |
120 | unsigned int offset = sizeof(struct gfs2_log_descriptor); | 121 | unsigned int offset = BUF_OFFSET; |
121 | unsigned int limit; | 122 | unsigned int limit; |
122 | unsigned int num; | 123 | unsigned int num; |
123 | unsigned n; | 124 | unsigned n; |
124 | __be64 *ptr; | 125 | __be64 *ptr; |
125 | 126 | ||
126 | offset += sizeof(__be64) - 1; | 127 | limit = buf_limit(sdp); |
127 | offset &= ~(sizeof(__be64) - 1); | ||
128 | limit = (sdp->sd_sb.sb_bsize - offset)/sizeof(__be64); | ||
129 | /* for 4k blocks, limit = 503 */ | 128 | /* for 4k blocks, limit = 503 */ |
130 | 129 | ||
131 | bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list); | 130 | bd1 = bd2 = list_prepare_entry(bd1, &sdp->sd_log_le_buf, bd_le.le_list); |
@@ -134,7 +133,6 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) | |||
134 | if (total > limit) | 133 | if (total > limit) |
135 | num = limit; | 134 | num = limit; |
136 | bh = gfs2_log_get_buf(sdp); | 135 | bh = gfs2_log_get_buf(sdp); |
137 | sdp->sd_log_num_hdrs++; | ||
138 | ld = (struct gfs2_log_descriptor *)bh->b_data; | 136 | ld = (struct gfs2_log_descriptor *)bh->b_data; |
139 | ptr = (__be64 *)(bh->b_data + offset); | 137 | ptr = (__be64 *)(bh->b_data + offset); |
140 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | 138 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
@@ -469,25 +467,28 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
469 | struct gfs2_inode *ip = GFS2_I(mapping->host); | 467 | struct gfs2_inode *ip = GFS2_I(mapping->host); |
470 | 468 | ||
471 | gfs2_log_lock(sdp); | 469 | gfs2_log_lock(sdp); |
470 | if (!list_empty(&bd->bd_list_tr)) { | ||
471 | gfs2_log_unlock(sdp); | ||
472 | return; | ||
473 | } | ||
472 | tr->tr_touched = 1; | 474 | tr->tr_touched = 1; |
473 | if (list_empty(&bd->bd_list_tr) && | 475 | if (gfs2_is_jdata(ip)) { |
474 | (ip->i_di.di_flags & GFS2_DIF_JDATA)) { | ||
475 | tr->tr_num_buf++; | 476 | tr->tr_num_buf++; |
476 | list_add(&bd->bd_list_tr, &tr->tr_list_buf); | 477 | list_add(&bd->bd_list_tr, &tr->tr_list_buf); |
477 | gfs2_log_unlock(sdp); | ||
478 | gfs2_pin(sdp, bd->bd_bh); | ||
479 | tr->tr_num_buf_new++; | ||
480 | } else { | ||
481 | gfs2_log_unlock(sdp); | ||
482 | } | 478 | } |
479 | gfs2_log_unlock(sdp); | ||
480 | if (!list_empty(&le->le_list)) | ||
481 | return; | ||
482 | |||
483 | gfs2_trans_add_gl(bd->bd_gl); | 483 | gfs2_trans_add_gl(bd->bd_gl); |
484 | gfs2_log_lock(sdp); | 484 | if (gfs2_is_jdata(ip)) { |
485 | if (list_empty(&le->le_list)) { | 485 | sdp->sd_log_num_jdata++; |
486 | if (ip->i_di.di_flags & GFS2_DIF_JDATA) | 486 | gfs2_pin(sdp, bd->bd_bh); |
487 | sdp->sd_log_num_jdata++; | 487 | tr->tr_num_databuf_new++; |
488 | sdp->sd_log_num_databuf++; | ||
489 | list_add(&le->le_list, &sdp->sd_log_le_databuf); | ||
490 | } | 488 | } |
489 | sdp->sd_log_num_databuf++; | ||
490 | gfs2_log_lock(sdp); | ||
491 | list_add(&le->le_list, &sdp->sd_log_le_databuf); | ||
491 | gfs2_log_unlock(sdp); | 492 | gfs2_log_unlock(sdp); |
492 | } | 493 | } |
493 | 494 | ||
@@ -520,7 +521,6 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
520 | LIST_HEAD(started); | 521 | LIST_HEAD(started); |
521 | struct gfs2_bufdata *bd1 = NULL, *bd2, *bdt; | 522 | struct gfs2_bufdata *bd1 = NULL, *bd2, *bdt; |
522 | struct buffer_head *bh = NULL,*bh1 = NULL; | 523 | struct buffer_head *bh = NULL,*bh1 = NULL; |
523 | unsigned int offset = sizeof(struct gfs2_log_descriptor); | ||
524 | struct gfs2_log_descriptor *ld; | 524 | struct gfs2_log_descriptor *ld; |
525 | unsigned int limit; | 525 | unsigned int limit; |
526 | unsigned int total_dbuf = sdp->sd_log_num_databuf; | 526 | unsigned int total_dbuf = sdp->sd_log_num_databuf; |
@@ -528,9 +528,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
528 | unsigned int num, n; | 528 | unsigned int num, n; |
529 | __be64 *ptr = NULL; | 529 | __be64 *ptr = NULL; |
530 | 530 | ||
531 | offset += 2*sizeof(__be64) - 1; | 531 | limit = databuf_limit(sdp); |
532 | offset &= ~(2*sizeof(__be64) - 1); | ||
533 | limit = (sdp->sd_sb.sb_bsize - offset)/sizeof(__be64); | ||
534 | 532 | ||
535 | /* | 533 | /* |
536 | * Start writing ordered buffers, write journaled buffers | 534 | * Start writing ordered buffers, write journaled buffers |
@@ -581,10 +579,10 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
581 | gfs2_log_unlock(sdp); | 579 | gfs2_log_unlock(sdp); |
582 | if (!bh) { | 580 | if (!bh) { |
583 | bh = gfs2_log_get_buf(sdp); | 581 | bh = gfs2_log_get_buf(sdp); |
584 | sdp->sd_log_num_hdrs++; | ||
585 | ld = (struct gfs2_log_descriptor *) | 582 | ld = (struct gfs2_log_descriptor *) |
586 | bh->b_data; | 583 | bh->b_data; |
587 | ptr = (__be64 *)(bh->b_data + offset); | 584 | ptr = (__be64 *)(bh->b_data + |
585 | DATABUF_OFFSET); | ||
588 | ld->ld_header.mh_magic = | 586 | ld->ld_header.mh_magic = |
589 | cpu_to_be32(GFS2_MAGIC); | 587 | cpu_to_be32(GFS2_MAGIC); |
590 | ld->ld_header.mh_type = | 588 | ld->ld_header.mh_type = |
@@ -605,7 +603,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
605 | if (unlikely(magic != 0)) | 603 | if (unlikely(magic != 0)) |
606 | set_buffer_escaped(bh1); | 604 | set_buffer_escaped(bh1); |
607 | gfs2_log_lock(sdp); | 605 | gfs2_log_lock(sdp); |
608 | if (n++ > num) | 606 | if (++n >= num) |
609 | break; | 607 | break; |
610 | } else if (!bh1) { | 608 | } else if (!bh1) { |
611 | total_dbuf--; | 609 | total_dbuf--; |
@@ -622,6 +620,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
622 | } | 620 | } |
623 | gfs2_log_unlock(sdp); | 621 | gfs2_log_unlock(sdp); |
624 | if (bh) { | 622 | if (bh) { |
623 | set_buffer_mapped(bh); | ||
625 | set_buffer_dirty(bh); | 624 | set_buffer_dirty(bh); |
626 | ll_rw_block(WRITE, 1, &bh); | 625 | ll_rw_block(WRITE, 1, &bh); |
627 | bh = NULL; | 626 | bh = NULL; |