diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2015-10-17 16:18:45 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-10-17 16:18:45 -0400 |
commit | 56316a0d28f251dae6a3bc2b6d50e7c25389871f (patch) | |
tree | 3efd106c76cee48c0831930f75cf2b6c160368f6 /fs/jbd2/commit.c | |
parent | e2b911c53584a92266943f3b7f2cdbc19c1a4e80 (diff) |
jbd2: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags,
thereby replacing the wordy old macros. Furthermore, clean out the
places where we open-coded feature tests.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r-- | fs/jbd2/commit.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 362e5f614450..36345fefa3ff 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -142,8 +142,7 @@ static int journal_submit_commit_record(journal_t *journal, | |||
142 | tmp->h_commit_sec = cpu_to_be64(now.tv_sec); | 142 | tmp->h_commit_sec = cpu_to_be64(now.tv_sec); |
143 | tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); | 143 | tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); |
144 | 144 | ||
145 | if (JBD2_HAS_COMPAT_FEATURE(journal, | 145 | if (jbd2_has_feature_checksum(journal)) { |
146 | JBD2_FEATURE_COMPAT_CHECKSUM)) { | ||
147 | tmp->h_chksum_type = JBD2_CRC32_CHKSUM; | 146 | tmp->h_chksum_type = JBD2_CRC32_CHKSUM; |
148 | tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; | 147 | tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE; |
149 | tmp->h_chksum[0] = cpu_to_be32(crc32_sum); | 148 | tmp->h_chksum[0] = cpu_to_be32(crc32_sum); |
@@ -157,8 +156,7 @@ static int journal_submit_commit_record(journal_t *journal, | |||
157 | bh->b_end_io = journal_end_buffer_io_sync; | 156 | bh->b_end_io = journal_end_buffer_io_sync; |
158 | 157 | ||
159 | if (journal->j_flags & JBD2_BARRIER && | 158 | if (journal->j_flags & JBD2_BARRIER && |
160 | !JBD2_HAS_INCOMPAT_FEATURE(journal, | 159 | !jbd2_has_feature_async_commit(journal)) |
161 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) | ||
162 | ret = submit_bh(WRITE_SYNC | WRITE_FLUSH_FUA, bh); | 160 | ret = submit_bh(WRITE_SYNC | WRITE_FLUSH_FUA, bh); |
163 | else | 161 | else |
164 | ret = submit_bh(WRITE_SYNC, bh); | 162 | ret = submit_bh(WRITE_SYNC, bh); |
@@ -317,7 +315,7 @@ static void write_tag_block(journal_t *j, journal_block_tag_t *tag, | |||
317 | unsigned long long block) | 315 | unsigned long long block) |
318 | { | 316 | { |
319 | tag->t_blocknr = cpu_to_be32(block & (u32)~0); | 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); | 319 | tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); |
322 | } | 320 | } |
323 | 321 | ||
@@ -356,7 +354,7 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, | |||
356 | bh->b_size); | 354 | bh->b_size); |
357 | kunmap_atomic(addr); | 355 | kunmap_atomic(addr); |
358 | 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); | 358 | tag3->t_checksum = cpu_to_be32(csum32); |
361 | else | 359 | else |
362 | tag->t_checksum = cpu_to_be16(csum32); | 360 | tag->t_checksum = cpu_to_be16(csum32); |
@@ -730,8 +728,7 @@ start_journal_io: | |||
730 | /* | 728 | /* |
731 | * Compute checksum. | 729 | * Compute checksum. |
732 | */ | 730 | */ |
733 | if (JBD2_HAS_COMPAT_FEATURE(journal, | 731 | if (jbd2_has_feature_checksum(journal)) { |
734 | JBD2_FEATURE_COMPAT_CHECKSUM)) { | ||
735 | crc32_sum = | 732 | crc32_sum = |
736 | jbd2_checksum_data(crc32_sum, bh); | 733 | jbd2_checksum_data(crc32_sum, bh); |
737 | } | 734 | } |
@@ -797,8 +794,7 @@ start_journal_io: | |||
797 | blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL); | 794 | blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL); |
798 | 795 | ||
799 | /* Done it all: now write the commit record asynchronously. */ | 796 | /* Done it all: now write the commit record asynchronously. */ |
800 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, | 797 | if (jbd2_has_feature_async_commit(journal)) { |
801 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | ||
802 | err = journal_submit_commit_record(journal, commit_transaction, | 798 | err = journal_submit_commit_record(journal, commit_transaction, |
803 | &cbh, crc32_sum); | 799 | &cbh, crc32_sum); |
804 | if (err) | 800 | if (err) |
@@ -889,8 +885,7 @@ start_journal_io: | |||
889 | commit_transaction->t_state = T_COMMIT_JFLUSH; | 885 | commit_transaction->t_state = T_COMMIT_JFLUSH; |
890 | write_unlock(&journal->j_state_lock); | 886 | write_unlock(&journal->j_state_lock); |
891 | 887 | ||
892 | if (!JBD2_HAS_INCOMPAT_FEATURE(journal, | 888 | if (!jbd2_has_feature_async_commit(journal)) { |
893 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | ||
894 | err = journal_submit_commit_record(journal, commit_transaction, | 889 | err = journal_submit_commit_record(journal, commit_transaction, |
895 | &cbh, crc32_sum); | 890 | &cbh, crc32_sum); |
896 | if (err) | 891 | if (err) |
@@ -898,8 +893,7 @@ start_journal_io: | |||
898 | } | 893 | } |
899 | if (cbh) | 894 | if (cbh) |
900 | err = journal_wait_on_commit_record(journal, cbh); | 895 | err = journal_wait_on_commit_record(journal, cbh); |
901 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, | 896 | if (jbd2_has_feature_async_commit(journal) && |
902 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) && | ||
903 | journal->j_flags & JBD2_BARRIER) { | 897 | journal->j_flags & JBD2_BARRIER) { |
904 | blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL); | 898 | blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL); |
905 | } | 899 | } |