diff options
-rw-r--r-- | fs/gfs2/incore.h | 5 | ||||
-rw-r--r-- | fs/gfs2/log.c | 67 | ||||
-rw-r--r-- | fs/gfs2/lops.c | 15 | ||||
-rw-r--r-- | fs/gfs2/meta_io.c | 9 | ||||
-rw-r--r-- | fs/gfs2/trans.c | 2 |
5 files changed, 33 insertions, 65 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 99aab64c771a..d0c3928b2dea 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -748,15 +748,10 @@ struct gfs2_sbd { | |||
748 | 748 | ||
749 | struct gfs2_trans *sd_log_tr; | 749 | struct gfs2_trans *sd_log_tr; |
750 | unsigned int sd_log_blks_reserved; | 750 | unsigned int sd_log_blks_reserved; |
751 | unsigned int sd_log_commited_buf; | ||
752 | unsigned int sd_log_commited_databuf; | ||
753 | int sd_log_commited_revoke; | 751 | int sd_log_commited_revoke; |
754 | 752 | ||
755 | atomic_t sd_log_pinned; | 753 | atomic_t sd_log_pinned; |
756 | unsigned int sd_log_num_buf; | ||
757 | unsigned int sd_log_num_revoke; | 754 | unsigned int sd_log_num_revoke; |
758 | unsigned int sd_log_num_rg; | ||
759 | unsigned int sd_log_num_databuf; | ||
760 | 755 | ||
761 | struct list_head sd_log_le_revoke; | 756 | struct list_head sd_log_le_revoke; |
762 | struct list_head sd_log_le_ordered; | 757 | struct list_head sd_log_le_ordered; |
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 975712c6660b..c1c9a29fda9c 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -414,24 +414,22 @@ static inline unsigned int log_distance(struct gfs2_sbd *sdp, unsigned int newer | |||
414 | static unsigned int calc_reserved(struct gfs2_sbd *sdp) | 414 | static unsigned int calc_reserved(struct gfs2_sbd *sdp) |
415 | { | 415 | { |
416 | unsigned int reserved = 0; | 416 | unsigned int reserved = 0; |
417 | unsigned int mbuf_limit, metabufhdrs_needed; | 417 | unsigned int mbuf; |
418 | unsigned int dbuf_limit, databufhdrs_needed; | 418 | unsigned int dbuf; |
419 | unsigned int revokes = 0; | 419 | struct gfs2_trans *tr = sdp->sd_log_tr; |
420 | 420 | ||
421 | mbuf_limit = buf_limit(sdp); | 421 | if (tr) { |
422 | metabufhdrs_needed = (sdp->sd_log_commited_buf + | 422 | mbuf = tr->tr_num_buf_new - tr->tr_num_buf_rm; |
423 | (mbuf_limit - 1)) / mbuf_limit; | 423 | dbuf = tr->tr_num_databuf_new - tr->tr_num_databuf_rm; |
424 | dbuf_limit = databuf_limit(sdp); | 424 | reserved = mbuf + dbuf; |
425 | databufhdrs_needed = (sdp->sd_log_commited_databuf + | 425 | /* Account for header blocks */ |
426 | (dbuf_limit - 1)) / dbuf_limit; | 426 | reserved += DIV_ROUND_UP(mbuf, buf_limit(sdp)); |
427 | reserved += DIV_ROUND_UP(dbuf, databuf_limit(sdp)); | ||
428 | } | ||
427 | 429 | ||
428 | if (sdp->sd_log_commited_revoke > 0) | 430 | if (sdp->sd_log_commited_revoke > 0) |
429 | revokes = gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke, | 431 | reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke, |
430 | sizeof(u64)); | 432 | sizeof(u64)); |
431 | |||
432 | reserved = sdp->sd_log_commited_buf + metabufhdrs_needed + | ||
433 | sdp->sd_log_commited_databuf + databufhdrs_needed + | ||
434 | revokes; | ||
435 | /* One for the overall header */ | 433 | /* One for the overall header */ |
436 | if (reserved) | 434 | if (reserved) |
437 | reserved++; | 435 | reserved++; |
@@ -693,16 +691,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl) | |||
693 | INIT_LIST_HEAD(&tr->tr_ail2_list); | 691 | INIT_LIST_HEAD(&tr->tr_ail2_list); |
694 | } | 692 | } |
695 | 693 | ||
696 | if (sdp->sd_log_num_buf != sdp->sd_log_commited_buf) { | ||
697 | printk(KERN_INFO "GFS2: log buf %u %u\n", sdp->sd_log_num_buf, | ||
698 | sdp->sd_log_commited_buf); | ||
699 | gfs2_assert_withdraw(sdp, 0); | ||
700 | } | ||
701 | if (sdp->sd_log_num_databuf != sdp->sd_log_commited_databuf) { | ||
702 | printk(KERN_INFO "GFS2: log databuf %u %u\n", | ||
703 | sdp->sd_log_num_databuf, sdp->sd_log_commited_databuf); | ||
704 | gfs2_assert_withdraw(sdp, 0); | ||
705 | } | ||
706 | gfs2_assert_withdraw(sdp, | 694 | gfs2_assert_withdraw(sdp, |
707 | sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); | 695 | sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); |
708 | 696 | ||
@@ -727,8 +715,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl) | |||
727 | gfs2_log_lock(sdp); | 715 | gfs2_log_lock(sdp); |
728 | sdp->sd_log_head = sdp->sd_log_flush_head; | 716 | sdp->sd_log_head = sdp->sd_log_flush_head; |
729 | sdp->sd_log_blks_reserved = 0; | 717 | sdp->sd_log_blks_reserved = 0; |
730 | sdp->sd_log_commited_buf = 0; | ||
731 | sdp->sd_log_commited_databuf = 0; | ||
732 | sdp->sd_log_commited_revoke = 0; | 718 | sdp->sd_log_commited_revoke = 0; |
733 | 719 | ||
734 | spin_lock(&sdp->sd_ail_lock); | 720 | spin_lock(&sdp->sd_ail_lock); |
@@ -769,31 +755,29 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | |||
769 | { | 755 | { |
770 | unsigned int reserved; | 756 | unsigned int reserved; |
771 | unsigned int unused; | 757 | unsigned int unused; |
758 | unsigned int maxres; | ||
772 | 759 | ||
773 | gfs2_log_lock(sdp); | 760 | gfs2_log_lock(sdp); |
774 | 761 | ||
775 | sdp->sd_log_commited_buf += tr->tr_num_buf_new - tr->tr_num_buf_rm; | 762 | if (sdp->sd_log_tr) { |
776 | sdp->sd_log_commited_databuf += tr->tr_num_databuf_new - | 763 | gfs2_merge_trans(sdp->sd_log_tr, tr); |
777 | tr->tr_num_databuf_rm; | 764 | } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) { |
778 | gfs2_assert_withdraw(sdp, (((int)sdp->sd_log_commited_buf) >= 0) || | 765 | gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl); |
779 | (((int)sdp->sd_log_commited_databuf) >= 0)); | 766 | sdp->sd_log_tr = tr; |
767 | tr->tr_attached = 1; | ||
768 | } | ||
769 | |||
780 | sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm; | 770 | sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm; |
781 | reserved = calc_reserved(sdp); | 771 | reserved = calc_reserved(sdp); |
782 | gfs2_assert_withdraw(sdp, sdp->sd_log_blks_reserved + tr->tr_reserved >= reserved); | 772 | maxres = sdp->sd_log_blks_reserved + tr->tr_reserved; |
783 | unused = sdp->sd_log_blks_reserved - reserved + tr->tr_reserved; | 773 | gfs2_assert_withdraw(sdp, maxres >= reserved); |
774 | unused = maxres - reserved; | ||
784 | atomic_add(unused, &sdp->sd_log_blks_free); | 775 | atomic_add(unused, &sdp->sd_log_blks_free); |
785 | trace_gfs2_log_blocks(sdp, unused); | 776 | trace_gfs2_log_blocks(sdp, unused); |
786 | gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <= | 777 | gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <= |
787 | sdp->sd_jdesc->jd_blocks); | 778 | sdp->sd_jdesc->jd_blocks); |
788 | sdp->sd_log_blks_reserved = reserved; | 779 | sdp->sd_log_blks_reserved = reserved; |
789 | 780 | ||
790 | if (sdp->sd_log_tr) { | ||
791 | gfs2_merge_trans(sdp->sd_log_tr, tr); | ||
792 | } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) { | ||
793 | gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl); | ||
794 | sdp->sd_log_tr = tr; | ||
795 | tr->tr_attached = 1; | ||
796 | } | ||
797 | gfs2_log_unlock(sdp); | 781 | gfs2_log_unlock(sdp); |
798 | } | 782 | } |
799 | 783 | ||
@@ -833,10 +817,7 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp) | |||
833 | down_write(&sdp->sd_log_flush_lock); | 817 | down_write(&sdp->sd_log_flush_lock); |
834 | 818 | ||
835 | gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); | 819 | gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); |
836 | gfs2_assert_withdraw(sdp, !sdp->sd_log_num_buf); | ||
837 | gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); | 820 | gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); |
838 | gfs2_assert_withdraw(sdp, !sdp->sd_log_num_rg); | ||
839 | gfs2_assert_withdraw(sdp, !sdp->sd_log_num_databuf); | ||
840 | gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list)); | 821 | gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list)); |
841 | 822 | ||
842 | sdp->sd_log_flush_head = sdp->sd_log_head; | 823 | sdp->sd_log_flush_head = sdp->sd_log_head; |
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index ee9ec7fa3011..23c6e72f5164 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -494,9 +494,11 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit, | |||
494 | static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | 494 | static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) |
495 | { | 495 | { |
496 | unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */ | 496 | unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */ |
497 | unsigned int nbuf; | ||
497 | if (tr == NULL) | 498 | if (tr == NULL) |
498 | return; | 499 | return; |
499 | gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf, &tr->tr_buf, 0); | 500 | nbuf = tr->tr_num_buf_new - tr->tr_num_buf_rm; |
501 | gfs2_before_commit(sdp, limit, nbuf, &tr->tr_buf, 0); | ||
500 | } | 502 | } |
501 | 503 | ||
502 | static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | 504 | 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) | |||
511 | while (!list_empty(head)) { | 513 | while (!list_empty(head)) { |
512 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); | 514 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); |
513 | list_del_init(&bd->bd_list); | 515 | list_del_init(&bd->bd_list); |
514 | sdp->sd_log_num_buf--; | ||
515 | |||
516 | gfs2_unpin(sdp, bd->bd_bh, tr); | 516 | gfs2_unpin(sdp, bd->bd_bh, tr); |
517 | } | 517 | } |
518 | gfs2_assert_warn(sdp, !sdp->sd_log_num_buf); | ||
519 | } | 518 | } |
520 | 519 | ||
521 | static void buf_lo_before_scan(struct gfs2_jdesc *jd, | 520 | 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) | |||
761 | 760 | ||
762 | static void databuf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | 761 | static void databuf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) |
763 | { | 762 | { |
764 | unsigned int limit = buf_limit(sdp) / 2; | 763 | unsigned int limit = databuf_limit(sdp); |
764 | unsigned int nbuf; | ||
765 | if (tr == NULL) | 765 | if (tr == NULL) |
766 | return; | 766 | return; |
767 | gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf, &tr->tr_databuf, 1); | 767 | nbuf = tr->tr_num_databuf_new - tr->tr_num_databuf_rm; |
768 | gfs2_before_commit(sdp, limit, nbuf, &tr->tr_databuf, 1); | ||
768 | } | 769 | } |
769 | 770 | ||
770 | static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, | 771 | 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) | |||
849 | while (!list_empty(head)) { | 850 | while (!list_empty(head)) { |
850 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); | 851 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); |
851 | list_del_init(&bd->bd_list); | 852 | list_del_init(&bd->bd_list); |
852 | sdp->sd_log_num_databuf--; | ||
853 | gfs2_unpin(sdp, bd->bd_bh, tr); | 853 | gfs2_unpin(sdp, bd->bd_bh, tr); |
854 | } | 854 | } |
855 | gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf); | ||
856 | } | 855 | } |
857 | 856 | ||
858 | 857 | ||
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index c7f24690ed05..005e4686af0d 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -267,15 +267,10 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, int | |||
267 | trace_gfs2_pin(bd, 0); | 267 | trace_gfs2_pin(bd, 0); |
268 | atomic_dec(&sdp->sd_log_pinned); | 268 | atomic_dec(&sdp->sd_log_pinned); |
269 | list_del_init(&bd->bd_list); | 269 | list_del_init(&bd->bd_list); |
270 | if (meta) { | 270 | if (meta) |
271 | gfs2_assert_warn(sdp, sdp->sd_log_num_buf); | ||
272 | sdp->sd_log_num_buf--; | ||
273 | tr->tr_num_buf_rm++; | 271 | tr->tr_num_buf_rm++; |
274 | } else { | 272 | else |
275 | gfs2_assert_warn(sdp, sdp->sd_log_num_databuf); | ||
276 | sdp->sd_log_num_databuf--; | ||
277 | tr->tr_num_databuf_rm++; | 273 | tr->tr_num_databuf_rm++; |
278 | } | ||
279 | tr->tr_touched = 1; | 274 | tr->tr_touched = 1; |
280 | was_pinned = 1; | 275 | was_pinned = 1; |
281 | brelse(bh); | 276 | brelse(bh); |
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index e0464a22908c..295f400f35ab 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c | |||
@@ -213,7 +213,6 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) | |||
213 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); | 213 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); |
214 | gfs2_pin(sdp, bd->bd_bh); | 214 | gfs2_pin(sdp, bd->bd_bh); |
215 | tr->tr_num_databuf_new++; | 215 | tr->tr_num_databuf_new++; |
216 | sdp->sd_log_num_databuf++; | ||
217 | list_add_tail(&bd->bd_list, &tr->tr_databuf); | 216 | list_add_tail(&bd->bd_list, &tr->tr_databuf); |
218 | } | 217 | } |
219 | gfs2_log_unlock(sdp); | 218 | gfs2_log_unlock(sdp); |
@@ -241,7 +240,6 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) | |||
241 | gfs2_pin(sdp, bd->bd_bh); | 240 | gfs2_pin(sdp, bd->bd_bh); |
242 | mh->__pad0 = cpu_to_be64(0); | 241 | mh->__pad0 = cpu_to_be64(0); |
243 | mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); | 242 | mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); |
244 | sdp->sd_log_num_buf++; | ||
245 | list_add(&bd->bd_list, &tr->tr_buf); | 243 | list_add(&bd->bd_list, &tr->tr_buf); |
246 | tr->tr_num_buf_new++; | 244 | tr->tr_num_buf_new++; |
247 | } | 245 | } |