Lines Matching +full:pass +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0+
7 * Copyright 1999-2000 Red Hat Software --- All Rights Reserved
40 struct recovery_info *info, enum passtype pass);
49 while (--n >= 0) in journal_brelse_array()
62 * the readahead size, though. 128K is a purely arbitrary, good-enough
77 max = start + (128 * 1024 / journal->j_blocksize); in do_readahead()
78 if (max > journal->j_total_len) in do_readahead()
79 max = journal->j_total_len; in do_readahead()
95 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in do_readahead()
97 err = -ENOMEM; in do_readahead()
138 if (offset >= journal->j_total_len) { in jread()
140 return -EFSCORRUPTED; in jread()
151 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in jread()
153 return -ENOMEM; in jread()
172 return -EIO; in jread()
186 return 1; in jbd2_descriptor_block_csum_verify()
189 j->j_blocksize - sizeof(struct jbd2_journal_block_tail)); in jbd2_descriptor_block_csum_verify()
190 provided = tail->t_checksum; in jbd2_descriptor_block_csum_verify()
191 tail->t_checksum = 0; in jbd2_descriptor_block_csum_verify()
192 calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize); in jbd2_descriptor_block_csum_verify()
193 tail->t_checksum = provided; in jbd2_descriptor_block_csum_verify()
199 * Count the number of in-use tags in a journal descriptor block.
206 int nr = 0, size = journal->j_blocksize; in count_tags()
210 size -= sizeof(struct jbd2_journal_block_tail); in count_tags()
212 tagp = &bh->b_data[sizeof(journal_header_t)]; in count_tags()
214 while ((tagp - bh->b_data + tag_bytes) <= size) { in count_tags()
233 if (var >= (journal)->j_last) \
234 var -= ((journal)->j_last - (journal)->j_first); \
238 struct recovery_info *info, enum passtype pass) in fc_do_one_pass() argument
240 unsigned int expected_commit_id = info->end_transaction; in fc_do_one_pass()
245 next_fc_block = journal->j_fc_first; in fc_do_one_pass()
246 if (!journal->j_fc_replay_callback) in fc_do_one_pass()
249 while (next_fc_block <= journal->j_fc_last) { in fc_do_one_pass()
258 err = journal->j_fc_replay_callback(journal, bh, pass, in fc_do_one_pass()
259 next_fc_block - journal->j_fc_first, in fc_do_one_pass()
275 * jbd2_journal_recover - recovers a on-disk journal
281 * Recovery is done in three passes. In the first pass, we look for the
283 * blocks. In the third and final pass, we replay any un-revoked blocks
294 sb = journal->j_superblock; in jbd2_journal_recover()
301 if (!sb->s_start) { in jbd2_journal_recover()
302 jbd2_debug(1, "No recovery required, last transaction %d, head block %u\n", in jbd2_journal_recover()
303 be32_to_cpu(sb->s_sequence), be32_to_cpu(sb->s_head)); in jbd2_journal_recover()
304 journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1; in jbd2_journal_recover()
305 journal->j_head = be32_to_cpu(sb->s_head); in jbd2_journal_recover()
315 jbd2_debug(1, "JBD2: recovery, exit status %d, " in jbd2_journal_recover()
318 jbd2_debug(1, "JBD2: Replayed %d and revoked %d/%d blocks\n", in jbd2_journal_recover()
323 journal->j_transaction_sequence = ++info.end_transaction; in jbd2_journal_recover()
324 journal->j_head = info.head_block; in jbd2_journal_recover()
325 jbd2_debug(1, "JBD2: last transaction %d, head block %lu\n", in jbd2_journal_recover()
326 journal->j_transaction_sequence, journal->j_head); in jbd2_journal_recover()
329 err2 = sync_blockdev(journal->j_fs_dev); in jbd2_journal_recover()
333 if (journal->j_flags & JBD2_BARRIER) { in jbd2_journal_recover()
334 err2 = blkdev_issue_flush(journal->j_fs_dev); in jbd2_journal_recover()
342 * jbd2_journal_skip_recovery - Start journal and wipe exiting records
350 * We perform one pass over the journal to allow us to tell the user how
366 ++journal->j_transaction_sequence; in jbd2_journal_skip_recovery()
367 journal->j_head = journal->j_first; in jbd2_journal_skip_recovery()
370 int dropped = info.end_transaction - in jbd2_journal_skip_recovery()
371 be32_to_cpu(journal->j_superblock->s_sequence); in jbd2_journal_skip_recovery()
372 jbd2_debug(1, in jbd2_journal_skip_recovery()
374 dropped, (dropped == 1) ? "" : "s"); in jbd2_journal_skip_recovery()
376 journal->j_transaction_sequence = ++info.end_transaction; in jbd2_journal_skip_recovery()
377 journal->j_head = info.head_block; in jbd2_journal_skip_recovery()
380 journal->j_tail = 0; in jbd2_journal_skip_recovery()
387 unsigned long long block = be32_to_cpu(tag->t_blocknr); in read_tag_block()
389 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32; in read_tag_block()
406 *crc32_sum = crc32_be(*crc32_sum, (void *)bh->b_data, bh->b_size); in calc_chksums()
415 return 1; in calc_chksums()
417 *crc32_sum = crc32_be(*crc32_sum, (void *)obh->b_data, in calc_chksums()
418 obh->b_size); in calc_chksums()
432 return 1; in jbd2_commit_block_csum_verify()
435 provided = h->h_chksum[0]; in jbd2_commit_block_csum_verify()
436 h->h_chksum[0] = 0; in jbd2_commit_block_csum_verify()
437 calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize); in jbd2_commit_block_csum_verify()
438 h->h_chksum[0] = provided; in jbd2_commit_block_csum_verify()
451 return 1; in jbd2_block_tag_csum_verify()
454 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); in jbd2_block_tag_csum_verify()
455 csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize); in jbd2_block_tag_csum_verify()
458 return tag3->t_checksum == cpu_to_be32(csum32); in jbd2_block_tag_csum_verify()
460 return tag->t_checksum == cpu_to_be16(csum32); in jbd2_block_tag_csum_verify()
464 struct recovery_info *info, enum passtype pass) in do_one_pass() argument
487 sb = journal->j_superblock; in do_one_pass()
488 next_commit_ID = be32_to_cpu(sb->s_sequence); in do_one_pass()
489 next_log_block = be32_to_cpu(sb->s_start); in do_one_pass()
493 if (pass == PASS_SCAN) in do_one_pass()
494 info->start_transaction = first_commit_ID; in do_one_pass()
496 jbd2_debug(1, "Starting recovery pass %d\n", pass); in do_one_pass()
505 while (1) { in do_one_pass()
518 if (pass != PASS_SCAN) in do_one_pass()
519 if (tid_geq(next_commit_ID, info->end_transaction)) in do_one_pass()
523 next_commit_ID, next_log_block, journal->j_last); in do_one_pass()
543 tmp = (journal_header_t *)bh->b_data; in do_one_pass()
545 if (tmp->h_magic != cpu_to_be32(JBD2_MAGIC_NUMBER)) { in do_one_pass()
550 blocktype = be32_to_cpu(tmp->h_blocktype); in do_one_pass()
551 sequence = be32_to_cpu(tmp->h_sequence); in do_one_pass()
562 * to do with it? That depends on the pass... */ in do_one_pass()
572 bh->b_data)) { in do_one_pass()
577 if (pass != PASS_SCAN) { in do_one_pass()
580 err = -EFSBADCRC; in do_one_pass()
585 jbd2_debug(1, in do_one_pass()
591 * in pass REPLAY; if journal_checksums enabled, then in do_one_pass()
594 if (pass != PASS_REPLAY) { in do_one_pass()
595 if (pass == PASS_SCAN && in do_one_pass()
598 !info->end_transaction) { in do_one_pass()
618 tagp = &bh->b_data[sizeof(journal_header_t)]; in do_one_pass()
619 while ((tagp - bh->b_data + tag_bytes) in do_one_pass()
620 <= journal->j_blocksize - descr_csum_size) { in do_one_pass()
651 ++info->nr_revoke_hits; in do_one_pass()
658 obh->b_data, be32_to_cpu(tmp->h_sequence))) { in do_one_pass()
660 success = -EFSBADCRC; in do_one_pass()
665 block_error = 1; in do_one_pass()
671 nbh = __getblk(journal->j_fs_dev, in do_one_pass()
673 journal->j_blocksize); in do_one_pass()
678 err = -ENOMEM; in do_one_pass()
685 memcpy(nbh->b_data, obh->b_data, in do_one_pass()
686 journal->j_blocksize); in do_one_pass()
688 *((__be32 *)nbh->b_data) = in do_one_pass()
696 ++info->nr_replays; in do_one_pass()
728 * {(n+1)th transanction} in do_one_pass()
738 * and (n+1)th interrupted interrupted in do_one_pass()
746 ((struct commit_header *)bh->b_data)->h_commit_sec); in do_one_pass()
758 err = -EFSBADCRC; in do_one_pass()
767 jbd2_debug(1, "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n", in do_one_pass()
779 if (pass == PASS_SCAN && in do_one_pass()
782 (struct commit_header *)bh->b_data; in do_one_pass()
784 be32_to_cpu(cbh->h_chksum[0]); in do_one_pass()
786 if (info->end_transaction) { in do_one_pass()
787 journal->j_failed_commit = in do_one_pass()
788 info->end_transaction; in do_one_pass()
795 cbh->h_chksum_type == in do_one_pass()
797 cbh->h_chksum_size == in do_one_pass()
799 (cbh->h_chksum_type == 0 && in do_one_pass()
800 cbh->h_chksum_size == 0 && in do_one_pass()
806 if (pass == PASS_SCAN && in do_one_pass()
808 bh->b_data)) { in do_one_pass()
812 info->end_transaction = next_commit_ID; in do_one_pass()
813 info->head_block = head_block; in do_one_pass()
816 journal->j_failed_commit = in do_one_pass()
822 if (pass == PASS_SCAN) { in do_one_pass()
835 if (pass == PASS_SCAN && in do_one_pass()
837 bh->b_data)) { in do_one_pass()
838 jbd2_debug(1, "JBD2: invalid revoke block found in %lu\n", in do_one_pass()
842 /* If we aren't in the REVOKE pass, then we can in do_one_pass()
844 if (pass != PASS_REVOKE) { in do_one_pass()
872 if (pass == PASS_SCAN) { in do_one_pass()
873 if (!info->end_transaction) in do_one_pass()
874 info->end_transaction = next_commit_ID; in do_one_pass()
875 if (!info->head_block) in do_one_pass()
876 info->head_block = head_block; in do_one_pass()
880 if (info->end_transaction != next_commit_ID) { in do_one_pass()
881 printk(KERN_ERR "JBD2: recovery pass %d ended at " in do_one_pass()
883 pass, next_commit_ID, info->end_transaction); in do_one_pass()
885 success = -EIO; in do_one_pass()
889 if (jbd2_has_feature_fast_commit(journal) && pass != PASS_REVOKE) { in do_one_pass()
890 err = fc_do_one_pass(journal, info, pass); in do_one_pass()
896 success = -EIO; in do_one_pass()
914 header = (jbd2_journal_revoke_header_t *) bh->b_data; in scan_revoke_records()
916 rcount = be32_to_cpu(header->r_count); in scan_revoke_records()
920 if (rcount > journal->j_blocksize - csum_size) in scan_revoke_records()
921 return -EINVAL; in scan_revoke_records()
932 blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset))); in scan_revoke_records()
934 blocknr = be64_to_cpu(* ((__be64 *) (bh->b_data+offset))); in scan_revoke_records()
939 ++info->nr_revokes; in scan_revoke_records()