aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r--fs/jbd2/commit.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 36345fefa3ff..517f2de784cf 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -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
@@ -222,7 +220,7 @@ static int journal_submit_data_buffers(journal_t *journal,
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) {
224 mapping = jinode->i_vfs_inode->i_mapping; 222 mapping = jinode->i_vfs_inode->i_mapping;
225 set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); 223 jinode->i_flags |= JI_COMMIT_RUNNING;
226 spin_unlock(&journal->j_list_lock); 224 spin_unlock(&journal->j_list_lock);
227 /* 225 /*
228 * submit the inode data buffers. We use writepage 226 * submit the inode data buffers. We use writepage
@@ -236,8 +234,8 @@ static int journal_submit_data_buffers(journal_t *journal,
236 ret = err; 234 ret = err;
237 spin_lock(&journal->j_list_lock); 235 spin_lock(&journal->j_list_lock);
238 J_ASSERT(jinode->i_transaction == commit_transaction); 236 J_ASSERT(jinode->i_transaction == commit_transaction);
239 clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); 237 jinode->i_flags &= ~JI_COMMIT_RUNNING;
240 smp_mb__after_atomic(); 238 smp_mb();
241 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); 239 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
242 } 240 }
243 spin_unlock(&journal->j_list_lock); 241 spin_unlock(&journal->j_list_lock);
@@ -258,7 +256,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
258 /* For locking, see the comment in journal_submit_data_buffers() */ 256 /* For locking, see the comment in journal_submit_data_buffers() */
259 spin_lock(&journal->j_list_lock); 257 spin_lock(&journal->j_list_lock);
260 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { 258 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
261 set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); 259 jinode->i_flags |= JI_COMMIT_RUNNING;
262 spin_unlock(&journal->j_list_lock); 260 spin_unlock(&journal->j_list_lock);
263 err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping); 261 err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping);
264 if (err) { 262 if (err) {
@@ -274,8 +272,8 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
274 ret = err; 272 ret = err;
275 } 273 }
276 spin_lock(&journal->j_list_lock); 274 spin_lock(&journal->j_list_lock);
277 clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); 275 jinode->i_flags &= ~JI_COMMIT_RUNNING;
278 smp_mb__after_atomic(); 276 smp_mb();
279 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); 277 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
280 } 278 }
281 279
@@ -319,22 +317,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); 317 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
320} 318}
321 319
322static 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
338static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, 320static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
339 struct buffer_head *bh, __u32 sequence) 321 struct buffer_head *bh, __u32 sequence)
340{ 322{
@@ -379,7 +361,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
379 ktime_t start_time; 361 ktime_t start_time;
380 u64 commit_time; 362 u64 commit_time;
381 char *tagp = NULL; 363 char *tagp = NULL;
382 journal_header_t *header;
383 journal_block_tag_t *tag = NULL; 364 journal_block_tag_t *tag = NULL;
384 int space_left = 0; 365 int space_left = 0;
385 int first_tag = 0; 366 int first_tag = 0;
@@ -554,8 +535,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
554 jbd2_journal_abort(journal, err); 535 jbd2_journal_abort(journal, err);
555 536
556 blk_start_plug(&plug); 537 blk_start_plug(&plug);
557 jbd2_journal_write_revoke_records(journal, commit_transaction, 538 jbd2_journal_write_revoke_records(commit_transaction, &log_bufs);
558 &log_bufs, WRITE_SYNC);
559 539
560 jbd_debug(3, "JBD2: commit phase 2b\n"); 540 jbd_debug(3, "JBD2: commit phase 2b\n");
561 541
@@ -616,7 +596,9 @@ void jbd2_journal_commit_transaction(journal_t *journal)
616 596
617 jbd_debug(4, "JBD2: get descriptor\n"); 597 jbd_debug(4, "JBD2: get descriptor\n");
618 598
619 descriptor = jbd2_journal_get_descriptor_buffer(journal); 599 descriptor = jbd2_journal_get_descriptor_buffer(
600 commit_transaction,
601 JBD2_DESCRIPTOR_BLOCK);
620 if (!descriptor) { 602 if (!descriptor) {
621 jbd2_journal_abort(journal, -EIO); 603 jbd2_journal_abort(journal, -EIO);
622 continue; 604 continue;
@@ -625,11 +607,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
625 jbd_debug(4, "JBD2: got buffer %llu (%p)\n", 607 jbd_debug(4, "JBD2: got buffer %llu (%p)\n",
626 (unsigned long long)descriptor->b_blocknr, 608 (unsigned long long)descriptor->b_blocknr,
627 descriptor->b_data); 609 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)]; 610 tagp = &descriptor->b_data[sizeof(journal_header_t)];
634 space_left = descriptor->b_size - 611 space_left = descriptor->b_size -
635 sizeof(journal_header_t); 612 sizeof(journal_header_t);
@@ -721,7 +698,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
721 698
722 tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG); 699 tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG);
723 700
724 jbd2_descr_block_csum_set(journal, descriptor); 701 jbd2_descriptor_block_csum_set(journal, descriptor);
725start_journal_io: 702start_journal_io:
726 for (i = 0; i < bufs; i++) { 703 for (i = 0; i < bufs; i++) {
727 struct buffer_head *bh = wbuf[i]; 704 struct buffer_head *bh = wbuf[i];