diff options
Diffstat (limited to 'fs/jbd2/commit.c')
| -rw-r--r-- | fs/jbd2/commit.c | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 36345fefa3ff..70078096117d 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
| @@ -81,11 +81,11 @@ static void release_buffer_page(struct buffer_head *bh) | |||
| 81 | if (!trylock_page(page)) | 81 | if (!trylock_page(page)) |
| 82 | goto nope; | 82 | goto nope; |
| 83 | 83 | ||
| 84 | page_cache_get(page); | 84 | get_page(page); |
| 85 | __brelse(bh); | 85 | __brelse(bh); |
| 86 | try_to_free_buffers(page); | 86 | try_to_free_buffers(page); |
| 87 | unlock_page(page); | 87 | unlock_page(page); |
| 88 | page_cache_release(page); | 88 | put_page(page); |
| 89 | return; | 89 | return; |
| 90 | 90 | ||
| 91 | nope: | 91 | nope: |
| @@ -131,14 +131,12 @@ static int journal_submit_commit_record(journal_t *journal, | |||
| 131 | if (is_journal_aborted(journal)) | 131 | if (is_journal_aborted(journal)) |
| 132 | return 0; | 132 | return 0; |
| 133 | 133 | ||
| 134 | bh = jbd2_journal_get_descriptor_buffer(journal); | 134 | bh = jbd2_journal_get_descriptor_buffer(commit_transaction, |
| 135 | JBD2_COMMIT_BLOCK); | ||
| 135 | if (!bh) | 136 | if (!bh) |
| 136 | return 1; | 137 | return 1; |
| 137 | 138 | ||
| 138 | tmp = (struct commit_header *)bh->b_data; | 139 | tmp = (struct commit_header *)bh->b_data; |
| 139 | tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); | ||
| 140 | tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK); | ||
| 141 | tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid); | ||
| 142 | tmp->h_commit_sec = cpu_to_be64(now.tv_sec); | 140 | tmp->h_commit_sec = cpu_to_be64(now.tv_sec); |
| 143 | tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); | 141 | tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); |
| 144 | 142 | ||
| @@ -221,8 +219,10 @@ static int journal_submit_data_buffers(journal_t *journal, | |||
| 221 | 219 | ||
| 222 | spin_lock(&journal->j_list_lock); | 220 | spin_lock(&journal->j_list_lock); |
| 223 | list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { | 221 | list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { |
| 222 | if (!(jinode->i_flags & JI_WRITE_DATA)) | ||
| 223 | continue; | ||
| 224 | mapping = jinode->i_vfs_inode->i_mapping; | 224 | mapping = jinode->i_vfs_inode->i_mapping; |
| 225 | set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); | 225 | jinode->i_flags |= JI_COMMIT_RUNNING; |
| 226 | spin_unlock(&journal->j_list_lock); | 226 | spin_unlock(&journal->j_list_lock); |
| 227 | /* | 227 | /* |
| 228 | * submit the inode data buffers. We use writepage | 228 | * submit the inode data buffers. We use writepage |
| @@ -236,8 +236,8 @@ static int journal_submit_data_buffers(journal_t *journal, | |||
| 236 | ret = err; | 236 | ret = err; |
| 237 | spin_lock(&journal->j_list_lock); | 237 | spin_lock(&journal->j_list_lock); |
| 238 | J_ASSERT(jinode->i_transaction == commit_transaction); | 238 | J_ASSERT(jinode->i_transaction == commit_transaction); |
| 239 | clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); | 239 | jinode->i_flags &= ~JI_COMMIT_RUNNING; |
| 240 | smp_mb__after_atomic(); | 240 | smp_mb(); |
| 241 | wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); | 241 | wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); |
| 242 | } | 242 | } |
| 243 | spin_unlock(&journal->j_list_lock); | 243 | spin_unlock(&journal->j_list_lock); |
| @@ -258,7 +258,9 @@ static int journal_finish_inode_data_buffers(journal_t *journal, | |||
| 258 | /* For locking, see the comment in journal_submit_data_buffers() */ | 258 | /* For locking, see the comment in journal_submit_data_buffers() */ |
| 259 | spin_lock(&journal->j_list_lock); | 259 | spin_lock(&journal->j_list_lock); |
| 260 | list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { | 260 | list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { |
| 261 | set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); | 261 | if (!(jinode->i_flags & JI_WAIT_DATA)) |
| 262 | continue; | ||
| 263 | jinode->i_flags |= JI_COMMIT_RUNNING; | ||
| 262 | spin_unlock(&journal->j_list_lock); | 264 | spin_unlock(&journal->j_list_lock); |
| 263 | err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping); | 265 | err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping); |
| 264 | if (err) { | 266 | if (err) { |
| @@ -274,8 +276,8 @@ static int journal_finish_inode_data_buffers(journal_t *journal, | |||
| 274 | ret = err; | 276 | ret = err; |
| 275 | } | 277 | } |
| 276 | spin_lock(&journal->j_list_lock); | 278 | spin_lock(&journal->j_list_lock); |
| 277 | clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); | 279 | jinode->i_flags &= ~JI_COMMIT_RUNNING; |
| 278 | smp_mb__after_atomic(); | 280 | smp_mb(); |
| 279 | wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); | 281 | wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); |
| 280 | } | 282 | } |
| 281 | 283 | ||
| @@ -319,22 +321,6 @@ static void write_tag_block(journal_t *j, journal_block_tag_t *tag, | |||
| 319 | tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); | 321 | tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); |
| 320 | } | 322 | } |
| 321 | 323 | ||
| 322 | static void jbd2_descr_block_csum_set(journal_t *j, | ||
| 323 | struct buffer_head *bh) | ||
| 324 | { | ||
| 325 | struct jbd2_journal_block_tail *tail; | ||
| 326 | __u32 csum; | ||
| 327 | |||
| 328 | if (!jbd2_journal_has_csum_v2or3(j)) | ||
| 329 | return; | ||
| 330 | |||
| 331 | tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - | ||
| 332 | sizeof(struct jbd2_journal_block_tail)); | ||
| 333 | tail->t_checksum = 0; | ||
| 334 | csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize); | ||
| 335 | tail->t_checksum = cpu_to_be32(csum); | ||
| 336 | } | ||
| 337 | |||
| 338 | static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, | 324 | static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, |
| 339 | struct buffer_head *bh, __u32 sequence) | 325 | struct buffer_head *bh, __u32 sequence) |
| 340 | { | 326 | { |
| @@ -379,7 +365,6 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
| 379 | ktime_t start_time; | 365 | ktime_t start_time; |
| 380 | u64 commit_time; | 366 | u64 commit_time; |
| 381 | char *tagp = NULL; | 367 | char *tagp = NULL; |
| 382 | journal_header_t *header; | ||
| 383 | journal_block_tag_t *tag = NULL; | 368 | journal_block_tag_t *tag = NULL; |
| 384 | int space_left = 0; | 369 | int space_left = 0; |
| 385 | int first_tag = 0; | 370 | int first_tag = 0; |
| @@ -554,8 +539,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
| 554 | jbd2_journal_abort(journal, err); | 539 | jbd2_journal_abort(journal, err); |
| 555 | 540 | ||
| 556 | blk_start_plug(&plug); | 541 | blk_start_plug(&plug); |
| 557 | jbd2_journal_write_revoke_records(journal, commit_transaction, | 542 | jbd2_journal_write_revoke_records(commit_transaction, &log_bufs); |
| 558 | &log_bufs, WRITE_SYNC); | ||
| 559 | 543 | ||
| 560 | jbd_debug(3, "JBD2: commit phase 2b\n"); | 544 | jbd_debug(3, "JBD2: commit phase 2b\n"); |
| 561 | 545 | ||
| @@ -616,7 +600,9 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
| 616 | 600 | ||
| 617 | jbd_debug(4, "JBD2: get descriptor\n"); | 601 | jbd_debug(4, "JBD2: get descriptor\n"); |
| 618 | 602 | ||
| 619 | descriptor = jbd2_journal_get_descriptor_buffer(journal); | 603 | descriptor = jbd2_journal_get_descriptor_buffer( |
| 604 | commit_transaction, | ||
| 605 | JBD2_DESCRIPTOR_BLOCK); | ||
| 620 | if (!descriptor) { | 606 | if (!descriptor) { |
| 621 | jbd2_journal_abort(journal, -EIO); | 607 | jbd2_journal_abort(journal, -EIO); |
| 622 | continue; | 608 | continue; |
| @@ -625,11 +611,6 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
| 625 | jbd_debug(4, "JBD2: got buffer %llu (%p)\n", | 611 | jbd_debug(4, "JBD2: got buffer %llu (%p)\n", |
| 626 | (unsigned long long)descriptor->b_blocknr, | 612 | (unsigned long long)descriptor->b_blocknr, |
| 627 | descriptor->b_data); | 613 | descriptor->b_data); |
| 628 | header = (journal_header_t *)descriptor->b_data; | ||
| 629 | header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); | ||
| 630 | header->h_blocktype = cpu_to_be32(JBD2_DESCRIPTOR_BLOCK); | ||
| 631 | header->h_sequence = cpu_to_be32(commit_transaction->t_tid); | ||
| 632 | |||
| 633 | tagp = &descriptor->b_data[sizeof(journal_header_t)]; | 614 | tagp = &descriptor->b_data[sizeof(journal_header_t)]; |
| 634 | space_left = descriptor->b_size - | 615 | space_left = descriptor->b_size - |
| 635 | sizeof(journal_header_t); | 616 | sizeof(journal_header_t); |
| @@ -721,7 +702,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
| 721 | 702 | ||
| 722 | tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG); | 703 | tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG); |
| 723 | 704 | ||
| 724 | jbd2_descr_block_csum_set(journal, descriptor); | 705 | jbd2_descriptor_block_csum_set(journal, descriptor); |
| 725 | start_journal_io: | 706 | start_journal_io: |
| 726 | for (i = 0; i < bufs; i++) { | 707 | for (i = 0; i < bufs; i++) { |
| 727 | struct buffer_head *bh = wbuf[i]; | 708 | struct buffer_head *bh = wbuf[i]; |
