commit.c (c7d77a7980e434c3af17de19e3348157f9b9ccce) | commit.c (56316a0d28f251dae6a3bc2b6d50e7c25389871f) |
---|---|
1/* 2 * linux/fs/jbd2/commit.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 128 unchanged lines hidden (view full) --- 137 138 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); 143 tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); 144 | 1/* 2 * linux/fs/jbd2/commit.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 128 unchanged lines hidden (view full) --- 137 138 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); 143 tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); 144 |
145 if (JBD2_HAS_COMPAT_FEATURE(journal, 146 JBD2_FEATURE_COMPAT_CHECKSUM)) { | 145 if (jbd2_has_feature_checksum(journal)) { |
147 tmp->h_chksum_type = JBD2_CRC32_CHKSUM; 148 tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; 149 tmp->h_chksum[0] = cpu_to_be32(crc32_sum); 150 } 151 jbd2_commit_block_csum_set(journal, bh); 152 153 BUFFER_TRACE(bh, "submit commit block"); 154 lock_buffer(bh); 155 clear_buffer_dirty(bh); 156 set_buffer_uptodate(bh); 157 bh->b_end_io = journal_end_buffer_io_sync; 158 159 if (journal->j_flags & JBD2_BARRIER && | 146 tmp->h_chksum_type = JBD2_CRC32_CHKSUM; 147 tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; 148 tmp->h_chksum[0] = cpu_to_be32(crc32_sum); 149 } 150 jbd2_commit_block_csum_set(journal, bh); 151 152 BUFFER_TRACE(bh, "submit commit block"); 153 lock_buffer(bh); 154 clear_buffer_dirty(bh); 155 set_buffer_uptodate(bh); 156 bh->b_end_io = journal_end_buffer_io_sync; 157 158 if (journal->j_flags & JBD2_BARRIER && |
160 !JBD2_HAS_INCOMPAT_FEATURE(journal, 161 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) | 159 !jbd2_has_feature_async_commit(journal)) |
162 ret = submit_bh(WRITE_SYNC | WRITE_FLUSH_FUA, bh); 163 else 164 ret = submit_bh(WRITE_SYNC, bh); 165 166 *cbh = bh; 167 return ret; 168} 169 --- 142 unchanged lines hidden (view full) --- 312 313 return checksum; 314} 315 316static void write_tag_block(journal_t *j, journal_block_tag_t *tag, 317 unsigned long long block) 318{ 319 tag->t_blocknr = cpu_to_be32(block & (u32)~0); | 160 ret = submit_bh(WRITE_SYNC | WRITE_FLUSH_FUA, bh); 161 else 162 ret = submit_bh(WRITE_SYNC, bh); 163 164 *cbh = bh; 165 return ret; 166} 167 --- 142 unchanged lines hidden (view full) --- 310 311 return checksum; 312} 313 314static void write_tag_block(journal_t *j, journal_block_tag_t *tag, 315 unsigned long long block) 316{ 317 tag->t_blocknr = cpu_to_be32(block & (u32)~0); |
320 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_64BIT)) | 318 if (jbd2_has_feature_64bit(j)) |
321 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); 322} 323 324static void jbd2_descr_block_csum_set(journal_t *j, 325 struct buffer_head *bh) 326{ 327 struct jbd2_journal_block_tail *tail; 328 __u32 csum; --- 22 unchanged lines hidden (view full) --- 351 352 seq = cpu_to_be32(sequence); 353 addr = kmap_atomic(page); 354 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); 355 csum32 = jbd2_chksum(j, csum32, addr + offset_in_page(bh->b_data), 356 bh->b_size); 357 kunmap_atomic(addr); 358 | 319 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); 320} 321 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; --- 22 unchanged lines hidden (view full) --- 349 350 seq = cpu_to_be32(sequence); 351 addr = kmap_atomic(page); 352 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); 353 csum32 = jbd2_chksum(j, csum32, addr + offset_in_page(bh->b_data), 354 bh->b_size); 355 kunmap_atomic(addr); 356 |
359 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3)) | 357 if (jbd2_has_feature_csum3(j)) |
360 tag3->t_checksum = cpu_to_be32(csum32); 361 else 362 tag->t_checksum = cpu_to_be16(csum32); 363} 364/* 365 * jbd2_journal_commit_transaction 366 * 367 * The primary function for committing a transaction to the log. This --- 357 unchanged lines hidden (view full) --- 725 726 jbd2_descr_block_csum_set(journal, descriptor); 727start_journal_io: 728 for (i = 0; i < bufs; i++) { 729 struct buffer_head *bh = wbuf[i]; 730 /* 731 * Compute checksum. 732 */ | 358 tag3->t_checksum = cpu_to_be32(csum32); 359 else 360 tag->t_checksum = cpu_to_be16(csum32); 361} 362/* 363 * jbd2_journal_commit_transaction 364 * 365 * The primary function for committing a transaction to the log. This --- 357 unchanged lines hidden (view full) --- 723 724 jbd2_descr_block_csum_set(journal, descriptor); 725start_journal_io: 726 for (i = 0; i < bufs; i++) { 727 struct buffer_head *bh = wbuf[i]; 728 /* 729 * Compute checksum. 730 */ |
733 if (JBD2_HAS_COMPAT_FEATURE(journal, 734 JBD2_FEATURE_COMPAT_CHECKSUM)) { | 731 if (jbd2_has_feature_checksum(journal)) { |
735 crc32_sum = 736 jbd2_checksum_data(crc32_sum, bh); 737 } 738 739 lock_buffer(bh); 740 clear_buffer_dirty(bh); 741 set_buffer_uptodate(bh); 742 bh->b_end_io = journal_end_buffer_io_sync; --- 49 unchanged lines hidden (view full) --- 792 * the commit record 793 */ 794 if (commit_transaction->t_need_data_flush && 795 (journal->j_fs_dev != journal->j_dev) && 796 (journal->j_flags & JBD2_BARRIER)) 797 blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL); 798 799 /* Done it all: now write the commit record asynchronously. */ | 732 crc32_sum = 733 jbd2_checksum_data(crc32_sum, bh); 734 } 735 736 lock_buffer(bh); 737 clear_buffer_dirty(bh); 738 set_buffer_uptodate(bh); 739 bh->b_end_io = journal_end_buffer_io_sync; --- 49 unchanged lines hidden (view full) --- 789 * the commit record 790 */ 791 if (commit_transaction->t_need_data_flush && 792 (journal->j_fs_dev != journal->j_dev) && 793 (journal->j_flags & JBD2_BARRIER)) 794 blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL); 795 796 /* Done it all: now write the commit record asynchronously. */ |
800 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 801 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 797 if (jbd2_has_feature_async_commit(journal)) { |
802 err = journal_submit_commit_record(journal, commit_transaction, 803 &cbh, crc32_sum); 804 if (err) 805 __jbd2_journal_abort_hard(journal); 806 } 807 808 blk_finish_plug(&plug); 809 --- 74 unchanged lines hidden (view full) --- 884 jbd2_journal_abort(journal, err); 885 886 jbd_debug(3, "JBD2: commit phase 5\n"); 887 write_lock(&journal->j_state_lock); 888 J_ASSERT(commit_transaction->t_state == T_COMMIT_DFLUSH); 889 commit_transaction->t_state = T_COMMIT_JFLUSH; 890 write_unlock(&journal->j_state_lock); 891 | 798 err = journal_submit_commit_record(journal, commit_transaction, 799 &cbh, crc32_sum); 800 if (err) 801 __jbd2_journal_abort_hard(journal); 802 } 803 804 blk_finish_plug(&plug); 805 --- 74 unchanged lines hidden (view full) --- 880 jbd2_journal_abort(journal, err); 881 882 jbd_debug(3, "JBD2: commit phase 5\n"); 883 write_lock(&journal->j_state_lock); 884 J_ASSERT(commit_transaction->t_state == T_COMMIT_DFLUSH); 885 commit_transaction->t_state = T_COMMIT_JFLUSH; 886 write_unlock(&journal->j_state_lock); 887 |
892 if (!JBD2_HAS_INCOMPAT_FEATURE(journal, 893 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 888 if (!jbd2_has_feature_async_commit(journal)) { |
894 err = journal_submit_commit_record(journal, commit_transaction, 895 &cbh, crc32_sum); 896 if (err) 897 __jbd2_journal_abort_hard(journal); 898 } 899 if (cbh) 900 err = journal_wait_on_commit_record(journal, cbh); | 889 err = journal_submit_commit_record(journal, commit_transaction, 890 &cbh, crc32_sum); 891 if (err) 892 __jbd2_journal_abort_hard(journal); 893 } 894 if (cbh) 895 err = journal_wait_on_commit_record(journal, cbh); |
901 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 902 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) && | 896 if (jbd2_has_feature_async_commit(journal) && |
903 journal->j_flags & JBD2_BARRIER) { 904 blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL); 905 } 906 907 if (err) 908 jbd2_journal_abort(journal, err); 909 910 /* --- 254 unchanged lines hidden --- | 897 journal->j_flags & JBD2_BARRIER) { 898 blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL); 899 } 900 901 if (err) 902 jbd2_journal_abort(journal, err); 903 904 /* --- 254 unchanged lines hidden --- |