diff options
author | Jan Kara <jack@suse.cz> | 2013-06-04 12:06:01 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-06-04 12:06:01 -0400 |
commit | e5a120aeb57f40ae568a5ca1dd6ace53d0213582 (patch) | |
tree | 4381bec9a9ef322a7feb8c29ff0912b8edbf0407 /fs/jbd2/commit.c | |
parent | f5113effc2a2ee6b86a4b345ce557353dcbcfffe (diff) |
jbd2: remove journal_head from descriptor buffers
Similarly as for metadata buffers, also log descriptor buffers don't
really need the journal head. So strip it and remove BJ_LogCtl list.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r-- | fs/jbd2/commit.c | 78 |
1 files changed, 31 insertions, 47 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 57bd2ff97888..7c6f7eea2316 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -85,8 +85,7 @@ nope: | |||
85 | __brelse(bh); | 85 | __brelse(bh); |
86 | } | 86 | } |
87 | 87 | ||
88 | static void jbd2_commit_block_csum_set(journal_t *j, | 88 | static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh) |
89 | struct journal_head *descriptor) | ||
90 | { | 89 | { |
91 | struct commit_header *h; | 90 | struct commit_header *h; |
92 | __u32 csum; | 91 | __u32 csum; |
@@ -94,12 +93,11 @@ static void jbd2_commit_block_csum_set(journal_t *j, | |||
94 | if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) | 93 | if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) |
95 | return; | 94 | return; |
96 | 95 | ||
97 | h = (struct commit_header *)(jh2bh(descriptor)->b_data); | 96 | h = (struct commit_header *)(bh->b_data); |
98 | h->h_chksum_type = 0; | 97 | h->h_chksum_type = 0; |
99 | h->h_chksum_size = 0; | 98 | h->h_chksum_size = 0; |
100 | h->h_chksum[0] = 0; | 99 | h->h_chksum[0] = 0; |
101 | csum = jbd2_chksum(j, j->j_csum_seed, jh2bh(descriptor)->b_data, | 100 | csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize); |
102 | j->j_blocksize); | ||
103 | h->h_chksum[0] = cpu_to_be32(csum); | 101 | h->h_chksum[0] = cpu_to_be32(csum); |
104 | } | 102 | } |
105 | 103 | ||
@@ -116,7 +114,6 @@ static int journal_submit_commit_record(journal_t *journal, | |||
116 | struct buffer_head **cbh, | 114 | struct buffer_head **cbh, |
117 | __u32 crc32_sum) | 115 | __u32 crc32_sum) |
118 | { | 116 | { |
119 | struct journal_head *descriptor; | ||
120 | struct commit_header *tmp; | 117 | struct commit_header *tmp; |
121 | struct buffer_head *bh; | 118 | struct buffer_head *bh; |
122 | int ret; | 119 | int ret; |
@@ -127,12 +124,10 @@ static int journal_submit_commit_record(journal_t *journal, | |||
127 | if (is_journal_aborted(journal)) | 124 | if (is_journal_aborted(journal)) |
128 | return 0; | 125 | return 0; |
129 | 126 | ||
130 | descriptor = jbd2_journal_get_descriptor_buffer(journal); | 127 | bh = jbd2_journal_get_descriptor_buffer(journal); |
131 | if (!descriptor) | 128 | if (!bh) |
132 | return 1; | 129 | return 1; |
133 | 130 | ||
134 | bh = jh2bh(descriptor); | ||
135 | |||
136 | tmp = (struct commit_header *)bh->b_data; | 131 | tmp = (struct commit_header *)bh->b_data; |
137 | tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); | 132 | tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); |
138 | tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK); | 133 | tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK); |
@@ -146,9 +141,9 @@ static int journal_submit_commit_record(journal_t *journal, | |||
146 | tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; | 141 | tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; |
147 | tmp->h_chksum[0] = cpu_to_be32(crc32_sum); | 142 | tmp->h_chksum[0] = cpu_to_be32(crc32_sum); |
148 | } | 143 | } |
149 | jbd2_commit_block_csum_set(journal, descriptor); | 144 | jbd2_commit_block_csum_set(journal, bh); |
150 | 145 | ||
151 | JBUFFER_TRACE(descriptor, "submit commit block"); | 146 | BUFFER_TRACE(bh, "submit commit block"); |
152 | lock_buffer(bh); | 147 | lock_buffer(bh); |
153 | clear_buffer_dirty(bh); | 148 | clear_buffer_dirty(bh); |
154 | set_buffer_uptodate(bh); | 149 | set_buffer_uptodate(bh); |
@@ -180,7 +175,6 @@ static int journal_wait_on_commit_record(journal_t *journal, | |||
180 | if (unlikely(!buffer_uptodate(bh))) | 175 | if (unlikely(!buffer_uptodate(bh))) |
181 | ret = -EIO; | 176 | ret = -EIO; |
182 | put_bh(bh); /* One for getblk() */ | 177 | put_bh(bh); /* One for getblk() */ |
183 | jbd2_journal_put_journal_head(bh2jh(bh)); | ||
184 | 178 | ||
185 | return ret; | 179 | return ret; |
186 | } | 180 | } |
@@ -321,7 +315,7 @@ static void write_tag_block(int tag_bytes, journal_block_tag_t *tag, | |||
321 | } | 315 | } |
322 | 316 | ||
323 | static void jbd2_descr_block_csum_set(journal_t *j, | 317 | static void jbd2_descr_block_csum_set(journal_t *j, |
324 | struct journal_head *descriptor) | 318 | struct buffer_head *bh) |
325 | { | 319 | { |
326 | struct jbd2_journal_block_tail *tail; | 320 | struct jbd2_journal_block_tail *tail; |
327 | __u32 csum; | 321 | __u32 csum; |
@@ -329,12 +323,10 @@ static void jbd2_descr_block_csum_set(journal_t *j, | |||
329 | if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) | 323 | if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) |
330 | return; | 324 | return; |
331 | 325 | ||
332 | tail = (struct jbd2_journal_block_tail *) | 326 | tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - |
333 | (jh2bh(descriptor)->b_data + j->j_blocksize - | ||
334 | sizeof(struct jbd2_journal_block_tail)); | 327 | sizeof(struct jbd2_journal_block_tail)); |
335 | tail->t_checksum = 0; | 328 | tail->t_checksum = 0; |
336 | csum = jbd2_chksum(j, j->j_csum_seed, jh2bh(descriptor)->b_data, | 329 | csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize); |
337 | j->j_blocksize); | ||
338 | tail->t_checksum = cpu_to_be32(csum); | 330 | tail->t_checksum = cpu_to_be32(csum); |
339 | } | 331 | } |
340 | 332 | ||
@@ -369,7 +361,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
369 | { | 361 | { |
370 | struct transaction_stats_s stats; | 362 | struct transaction_stats_s stats; |
371 | transaction_t *commit_transaction; | 363 | transaction_t *commit_transaction; |
372 | struct journal_head *jh, *descriptor; | 364 | struct journal_head *jh; |
365 | struct buffer_head *descriptor; | ||
373 | struct buffer_head **wbuf = journal->j_wbuf; | 366 | struct buffer_head **wbuf = journal->j_wbuf; |
374 | int bufs; | 367 | int bufs; |
375 | int flags; | 368 | int flags; |
@@ -394,6 +387,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
394 | int update_tail; | 387 | int update_tail; |
395 | int csum_size = 0; | 388 | int csum_size = 0; |
396 | LIST_HEAD(io_bufs); | 389 | LIST_HEAD(io_bufs); |
390 | LIST_HEAD(log_bufs); | ||
397 | 391 | ||
398 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) | 392 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) |
399 | csum_size = sizeof(struct jbd2_journal_block_tail); | 393 | csum_size = sizeof(struct jbd2_journal_block_tail); |
@@ -547,7 +541,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
547 | 541 | ||
548 | blk_start_plug(&plug); | 542 | blk_start_plug(&plug); |
549 | jbd2_journal_write_revoke_records(journal, commit_transaction, | 543 | jbd2_journal_write_revoke_records(journal, commit_transaction, |
550 | WRITE_SYNC); | 544 | &log_bufs, WRITE_SYNC); |
551 | blk_finish_plug(&plug); | 545 | blk_finish_plug(&plug); |
552 | 546 | ||
553 | jbd_debug(3, "JBD2: commit phase 2\n"); | 547 | jbd_debug(3, "JBD2: commit phase 2\n"); |
@@ -573,8 +567,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
573 | atomic_read(&commit_transaction->t_outstanding_credits)); | 567 | atomic_read(&commit_transaction->t_outstanding_credits)); |
574 | 568 | ||
575 | err = 0; | 569 | err = 0; |
576 | descriptor = NULL; | ||
577 | bufs = 0; | 570 | bufs = 0; |
571 | descriptor = NULL; | ||
578 | blk_start_plug(&plug); | 572 | blk_start_plug(&plug); |
579 | while (commit_transaction->t_buffers) { | 573 | while (commit_transaction->t_buffers) { |
580 | 574 | ||
@@ -606,8 +600,6 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
606 | record the metadata buffer. */ | 600 | record the metadata buffer. */ |
607 | 601 | ||
608 | if (!descriptor) { | 602 | if (!descriptor) { |
609 | struct buffer_head *bh; | ||
610 | |||
611 | J_ASSERT (bufs == 0); | 603 | J_ASSERT (bufs == 0); |
612 | 604 | ||
613 | jbd_debug(4, "JBD2: get descriptor\n"); | 605 | jbd_debug(4, "JBD2: get descriptor\n"); |
@@ -618,26 +610,26 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
618 | continue; | 610 | continue; |
619 | } | 611 | } |
620 | 612 | ||
621 | bh = jh2bh(descriptor); | ||
622 | jbd_debug(4, "JBD2: got buffer %llu (%p)\n", | 613 | jbd_debug(4, "JBD2: got buffer %llu (%p)\n", |
623 | (unsigned long long)bh->b_blocknr, bh->b_data); | 614 | (unsigned long long)descriptor->b_blocknr, |
624 | header = (journal_header_t *)&bh->b_data[0]; | 615 | descriptor->b_data); |
616 | header = (journal_header_t *)descriptor->b_data; | ||
625 | header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); | 617 | header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); |
626 | header->h_blocktype = cpu_to_be32(JBD2_DESCRIPTOR_BLOCK); | 618 | header->h_blocktype = cpu_to_be32(JBD2_DESCRIPTOR_BLOCK); |
627 | header->h_sequence = cpu_to_be32(commit_transaction->t_tid); | 619 | header->h_sequence = cpu_to_be32(commit_transaction->t_tid); |
628 | 620 | ||
629 | tagp = &bh->b_data[sizeof(journal_header_t)]; | 621 | tagp = &descriptor->b_data[sizeof(journal_header_t)]; |
630 | space_left = bh->b_size - sizeof(journal_header_t); | 622 | space_left = descriptor->b_size - |
623 | sizeof(journal_header_t); | ||
631 | first_tag = 1; | 624 | first_tag = 1; |
632 | set_buffer_jwrite(bh); | 625 | set_buffer_jwrite(descriptor); |
633 | set_buffer_dirty(bh); | 626 | set_buffer_dirty(descriptor); |
634 | wbuf[bufs++] = bh; | 627 | wbuf[bufs++] = descriptor; |
635 | 628 | ||
636 | /* Record it so that we can wait for IO | 629 | /* Record it so that we can wait for IO |
637 | completion later */ | 630 | completion later */ |
638 | BUFFER_TRACE(bh, "ph3: file as descriptor"); | 631 | BUFFER_TRACE(descriptor, "ph3: file as descriptor"); |
639 | jbd2_journal_file_buffer(descriptor, commit_transaction, | 632 | jbd2_file_log_bh(&log_bufs, descriptor); |
640 | BJ_LogCtl); | ||
641 | } | 633 | } |
642 | 634 | ||
643 | /* Where is the buffer to be written? */ | 635 | /* Where is the buffer to be written? */ |
@@ -864,26 +856,19 @@ start_journal_io: | |||
864 | jbd_debug(3, "JBD2: commit phase 4\n"); | 856 | jbd_debug(3, "JBD2: commit phase 4\n"); |
865 | 857 | ||
866 | /* Here we wait for the revoke record and descriptor record buffers */ | 858 | /* Here we wait for the revoke record and descriptor record buffers */ |
867 | wait_for_ctlbuf: | 859 | while (!list_empty(&log_bufs)) { |
868 | while (commit_transaction->t_log_list != NULL) { | ||
869 | struct buffer_head *bh; | 860 | struct buffer_head *bh; |
870 | 861 | ||
871 | jh = commit_transaction->t_log_list->b_tprev; | 862 | bh = list_entry(log_bufs.prev, struct buffer_head, b_assoc_buffers); |
872 | bh = jh2bh(jh); | 863 | wait_on_buffer(bh); |
873 | if (buffer_locked(bh)) { | 864 | cond_resched(); |
874 | wait_on_buffer(bh); | ||
875 | goto wait_for_ctlbuf; | ||
876 | } | ||
877 | if (cond_resched()) | ||
878 | goto wait_for_ctlbuf; | ||
879 | 865 | ||
880 | if (unlikely(!buffer_uptodate(bh))) | 866 | if (unlikely(!buffer_uptodate(bh))) |
881 | err = -EIO; | 867 | err = -EIO; |
882 | 868 | ||
883 | BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile"); | 869 | BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile"); |
884 | clear_buffer_jwrite(bh); | 870 | clear_buffer_jwrite(bh); |
885 | jbd2_journal_unfile_buffer(journal, jh); | 871 | jbd2_unfile_log_bh(bh); |
886 | jbd2_journal_put_journal_head(jh); | ||
887 | __brelse(bh); /* One for getblk */ | 872 | __brelse(bh); /* One for getblk */ |
888 | /* AKPM: bforget here */ | 873 | /* AKPM: bforget here */ |
889 | } | 874 | } |
@@ -934,7 +919,6 @@ start_journal_io: | |||
934 | J_ASSERT(commit_transaction->t_buffers == NULL); | 919 | J_ASSERT(commit_transaction->t_buffers == NULL); |
935 | J_ASSERT(commit_transaction->t_checkpoint_list == NULL); | 920 | J_ASSERT(commit_transaction->t_checkpoint_list == NULL); |
936 | J_ASSERT(commit_transaction->t_shadow_list == NULL); | 921 | J_ASSERT(commit_transaction->t_shadow_list == NULL); |
937 | J_ASSERT(commit_transaction->t_log_list == NULL); | ||
938 | 922 | ||
939 | restart_loop: | 923 | restart_loop: |
940 | /* | 924 | /* |