diff options
author | Bob Peterson <rpeterso@redhat.com> | 2012-05-01 12:00:34 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2012-05-02 04:14:36 -0400 |
commit | c0752aa7e4d48cc19e167ccb0092bea8e5b6ca3a (patch) | |
tree | 2ff43322a35871364f9be2c2e4a6427db7db8a0f /fs/gfs2/lops.c | |
parent | 1c47f09592148ba629edb2020d4dd94f81b16d11 (diff) |
GFS2: eliminate log elements and simplify
This patch eliminates the gfs2_log_element data structure and
rolls its two components into the gfs2_bufdata. This makes the code
easier to understand and makes it easier to migrate to a rbtree
to keep the list sorted.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/lops.c')
-rw-r--r-- | fs/gfs2/lops.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 11fedb569225..852c1be1dd3b 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -388,9 +388,8 @@ static struct page *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type, | |||
388 | return page; | 388 | return page; |
389 | } | 389 | } |
390 | 390 | ||
391 | static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | 391 | static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) |
392 | { | 392 | { |
393 | struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); | ||
394 | struct gfs2_meta_header *mh; | 393 | struct gfs2_meta_header *mh; |
395 | struct gfs2_trans *tr; | 394 | struct gfs2_trans *tr; |
396 | 395 | ||
@@ -398,7 +397,7 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
398 | gfs2_log_lock(sdp); | 397 | gfs2_log_lock(sdp); |
399 | tr = current->journal_info; | 398 | tr = current->journal_info; |
400 | tr->tr_touched = 1; | 399 | tr->tr_touched = 1; |
401 | if (!list_empty(&le->le_list)) | 400 | if (!list_empty(&bd->bd_list)) |
402 | goto out; | 401 | goto out; |
403 | set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); | 402 | set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); |
404 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); | 403 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); |
@@ -408,7 +407,7 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
408 | mh->__pad0 = cpu_to_be64(0); | 407 | mh->__pad0 = cpu_to_be64(0); |
409 | mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); | 408 | mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); |
410 | sdp->sd_log_num_buf++; | 409 | sdp->sd_log_num_buf++; |
411 | list_add(&le->le_list, &sdp->sd_log_le_buf); | 410 | list_add(&bd->bd_list, &sdp->sd_log_le_buf); |
412 | tr->tr_num_buf_new++; | 411 | tr->tr_num_buf_new++; |
413 | out: | 412 | out: |
414 | gfs2_log_unlock(sdp); | 413 | gfs2_log_unlock(sdp); |
@@ -440,7 +439,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit, | |||
440 | __be64 *ptr; | 439 | __be64 *ptr; |
441 | 440 | ||
442 | gfs2_log_lock(sdp); | 441 | gfs2_log_lock(sdp); |
443 | bd1 = bd2 = list_prepare_entry(bd1, blist, bd_le.le_list); | 442 | bd1 = bd2 = list_prepare_entry(bd1, blist, bd_list); |
444 | while(total) { | 443 | while(total) { |
445 | num = total; | 444 | num = total; |
446 | if (total > limit) | 445 | if (total > limit) |
@@ -452,7 +451,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit, | |||
452 | ptr = (__be64 *)(ld + 1); | 451 | ptr = (__be64 *)(ld + 1); |
453 | 452 | ||
454 | n = 0; | 453 | n = 0; |
455 | list_for_each_entry_continue(bd1, blist, bd_le.le_list) { | 454 | list_for_each_entry_continue(bd1, blist, bd_list) { |
456 | *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); | 455 | *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); |
457 | if (is_databuf) { | 456 | if (is_databuf) { |
458 | gfs2_check_magic(bd1->bd_bh); | 457 | gfs2_check_magic(bd1->bd_bh); |
@@ -467,7 +466,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit, | |||
467 | gfs2_log_lock(sdp); | 466 | gfs2_log_lock(sdp); |
468 | 467 | ||
469 | n = 0; | 468 | n = 0; |
470 | list_for_each_entry_continue(bd2, blist, bd_le.le_list) { | 469 | list_for_each_entry_continue(bd2, blist, bd_list) { |
471 | get_bh(bd2->bd_bh); | 470 | get_bh(bd2->bd_bh); |
472 | gfs2_log_unlock(sdp); | 471 | gfs2_log_unlock(sdp); |
473 | lock_buffer(bd2->bd_bh); | 472 | lock_buffer(bd2->bd_bh); |
@@ -513,8 +512,8 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |||
513 | struct gfs2_bufdata *bd; | 512 | struct gfs2_bufdata *bd; |
514 | 513 | ||
515 | while (!list_empty(head)) { | 514 | while (!list_empty(head)) { |
516 | bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); | 515 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); |
517 | list_del_init(&bd->bd_le.le_list); | 516 | list_del_init(&bd->bd_list); |
518 | sdp->sd_log_num_buf--; | 517 | sdp->sd_log_num_buf--; |
519 | 518 | ||
520 | gfs2_unpin(sdp, bd->bd_bh, ai); | 519 | gfs2_unpin(sdp, bd->bd_bh, ai); |
@@ -601,9 +600,8 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) | |||
601 | jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); | 600 | jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); |
602 | } | 601 | } |
603 | 602 | ||
604 | static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | 603 | static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) |
605 | { | 604 | { |
606 | struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); | ||
607 | struct gfs2_glock *gl = bd->bd_gl; | 605 | struct gfs2_glock *gl = bd->bd_gl; |
608 | struct gfs2_trans *tr; | 606 | struct gfs2_trans *tr; |
609 | 607 | ||
@@ -613,7 +611,7 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
613 | sdp->sd_log_num_revoke++; | 611 | sdp->sd_log_num_revoke++; |
614 | atomic_inc(&gl->gl_revokes); | 612 | atomic_inc(&gl->gl_revokes); |
615 | set_bit(GLF_LFLUSH, &gl->gl_flags); | 613 | set_bit(GLF_LFLUSH, &gl->gl_flags); |
616 | list_add(&le->le_list, &sdp->sd_log_le_revoke); | 614 | list_add(&bd->bd_list, &sdp->sd_log_le_revoke); |
617 | } | 615 | } |
618 | 616 | ||
619 | static void revoke_lo_before_commit(struct gfs2_sbd *sdp) | 617 | static void revoke_lo_before_commit(struct gfs2_sbd *sdp) |
@@ -634,7 +632,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) | |||
634 | ld = page_address(page); | 632 | ld = page_address(page); |
635 | offset = sizeof(struct gfs2_log_descriptor); | 633 | offset = sizeof(struct gfs2_log_descriptor); |
636 | 634 | ||
637 | list_for_each_entry(bd, head, bd_le.le_list) { | 635 | list_for_each_entry(bd, head, bd_list) { |
638 | sdp->sd_log_num_revoke--; | 636 | sdp->sd_log_num_revoke--; |
639 | 637 | ||
640 | if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) { | 638 | if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) { |
@@ -664,8 +662,8 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |||
664 | struct gfs2_glock *gl; | 662 | struct gfs2_glock *gl; |
665 | 663 | ||
666 | while (!list_empty(head)) { | 664 | while (!list_empty(head)) { |
667 | bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); | 665 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); |
668 | list_del_init(&bd->bd_le.le_list); | 666 | list_del_init(&bd->bd_list); |
669 | gl = bd->bd_gl; | 667 | gl = bd->bd_gl; |
670 | atomic_dec(&gl->gl_revokes); | 668 | atomic_dec(&gl->gl_revokes); |
671 | clear_bit(GLF_LFLUSH, &gl->gl_flags); | 669 | clear_bit(GLF_LFLUSH, &gl->gl_flags); |
@@ -768,9 +766,8 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) | |||
768 | * blocks, which isn't an enormous overhead but twice as much as | 766 | * blocks, which isn't an enormous overhead but twice as much as |
769 | * for normal metadata blocks. | 767 | * for normal metadata blocks. |
770 | */ | 768 | */ |
771 | static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | 769 | static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) |
772 | { | 770 | { |
773 | struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); | ||
774 | struct gfs2_trans *tr = current->journal_info; | 771 | struct gfs2_trans *tr = current->journal_info; |
775 | struct address_space *mapping = bd->bd_bh->b_page->mapping; | 772 | struct address_space *mapping = bd->bd_bh->b_page->mapping; |
776 | struct gfs2_inode *ip = GFS2_I(mapping->host); | 773 | struct gfs2_inode *ip = GFS2_I(mapping->host); |
@@ -779,7 +776,7 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
779 | gfs2_log_lock(sdp); | 776 | gfs2_log_lock(sdp); |
780 | if (tr) | 777 | if (tr) |
781 | tr->tr_touched = 1; | 778 | tr->tr_touched = 1; |
782 | if (!list_empty(&le->le_list)) | 779 | if (!list_empty(&bd->bd_list)) |
783 | goto out; | 780 | goto out; |
784 | set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); | 781 | set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); |
785 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); | 782 | set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); |
@@ -787,9 +784,9 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) | |||
787 | gfs2_pin(sdp, bd->bd_bh); | 784 | gfs2_pin(sdp, bd->bd_bh); |
788 | tr->tr_num_databuf_new++; | 785 | tr->tr_num_databuf_new++; |
789 | sdp->sd_log_num_databuf++; | 786 | sdp->sd_log_num_databuf++; |
790 | list_add_tail(&le->le_list, &sdp->sd_log_le_databuf); | 787 | list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf); |
791 | } else { | 788 | } else { |
792 | list_add_tail(&le->le_list, &sdp->sd_log_le_ordered); | 789 | list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered); |
793 | } | 790 | } |
794 | out: | 791 | out: |
795 | gfs2_log_unlock(sdp); | 792 | gfs2_log_unlock(sdp); |
@@ -885,8 +882,8 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |||
885 | struct gfs2_bufdata *bd; | 882 | struct gfs2_bufdata *bd; |
886 | 883 | ||
887 | while (!list_empty(head)) { | 884 | while (!list_empty(head)) { |
888 | bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); | 885 | bd = list_entry(head->next, struct gfs2_bufdata, bd_list); |
889 | list_del_init(&bd->bd_le.le_list); | 886 | list_del_init(&bd->bd_list); |
890 | sdp->sd_log_num_databuf--; | 887 | sdp->sd_log_num_databuf--; |
891 | gfs2_unpin(sdp, bd->bd_bh, ai); | 888 | gfs2_unpin(sdp, bd->bd_bh, ai); |
892 | } | 889 | } |