Lines Matching full:journal

9  * Journal recovery routines for the generic filesystem journaling code;
39 static int do_one_pass(journal_t *journal,
55 * When reading from the journal, we are going through the block device
67 static int do_readahead(journal_t *journal, unsigned int start) in do_readahead() argument
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()
87 err = jbd2_journal_bmap(journal, next, &blocknr); in do_readahead()
95 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in do_readahead()
126 * Read a block from the journal
129 static int jread(struct buffer_head **bhp, journal_t *journal, in jread() argument
138 if (offset >= journal->j_total_len) { in jread()
139 printk(KERN_ERR "JBD2: corrupted journal superblock\n"); in jread()
143 err = jbd2_journal_bmap(journal, offset, &blocknr); in jread()
151 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in jread()
164 do_readahead(journal, offset); in jread()
199 * Count the number of in-use tags in a journal descriptor block.
202 static int count_tags(journal_t *journal, struct buffer_head *bh) in count_tags() argument
206 int nr = 0, size = journal->j_blocksize; in count_tags()
207 int tag_bytes = journal_tag_bytes(journal); in count_tags()
209 if (jbd2_journal_has_csum_v2or3(journal)) in count_tags()
231 #define wrap(journal, var) \ argument
233 if (var >= (journal)->j_last) \
234 var -= ((journal)->j_last - (journal)->j_first); \
237 static int fc_do_one_pass(journal_t *journal, in fc_do_one_pass() argument
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()
252 err = jread(&bh, journal, next_fc_block); 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
276 * @journal: the journal to recover
286 int jbd2_journal_recover(journal_t *journal) in jbd2_journal_recover() argument
296 sb = journal->j_superblock; in jbd2_journal_recover()
299 * The journal superblock's s_start field (the current log head) in jbd2_journal_recover()
300 * is always zero if, and only if, the journal was cleanly in jbd2_journal_recover()
306 journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1; in jbd2_journal_recover()
307 journal->j_head = be32_to_cpu(sb->s_head); in jbd2_journal_recover()
312 mapping = journal->j_fs_dev->bd_inode->i_mapping; in jbd2_journal_recover()
314 err = do_one_pass(journal, &info, PASS_SCAN); in jbd2_journal_recover()
316 err = do_one_pass(journal, &info, PASS_REVOKE); in jbd2_journal_recover()
318 err = do_one_pass(journal, &info, PASS_REPLAY); in jbd2_journal_recover()
328 journal->j_transaction_sequence = ++info.end_transaction; in jbd2_journal_recover()
329 journal->j_head = info.head_block; in jbd2_journal_recover()
331 journal->j_transaction_sequence, journal->j_head); in jbd2_journal_recover()
333 jbd2_journal_clear_revoke(journal); in jbd2_journal_recover()
334 err2 = sync_blockdev(journal->j_fs_dev); in jbd2_journal_recover()
341 if (journal->j_flags & JBD2_BARRIER) { in jbd2_journal_recover()
342 err2 = blkdev_issue_flush(journal->j_fs_dev); in jbd2_journal_recover()
350 * jbd2_journal_skip_recovery - Start journal and wipe exiting records
351 * @journal: journal to startup
353 * Locate any valid recovery information from the journal and set up the
354 * journal structures in memory to ignore it (presumably because the
358 * We perform one pass over the journal to allow us to tell the user how
360 * the journal transaction sequence numbers to the next unused ID.
362 int jbd2_journal_skip_recovery(journal_t *journal) in jbd2_journal_skip_recovery() argument
370 err = do_one_pass(journal, &info, PASS_SCAN); in jbd2_journal_skip_recovery()
373 printk(KERN_ERR "JBD2: error %d scanning journal\n", err); in jbd2_journal_skip_recovery()
374 ++journal->j_transaction_sequence; in jbd2_journal_skip_recovery()
375 journal->j_head = journal->j_first; in jbd2_journal_skip_recovery()
379 be32_to_cpu(journal->j_superblock->s_sequence); in jbd2_journal_skip_recovery()
381 "JBD2: ignoring %d transaction%s from the journal.\n", in jbd2_journal_skip_recovery()
384 journal->j_transaction_sequence = ++info.end_transaction; in jbd2_journal_skip_recovery()
385 journal->j_head = info.head_block; in jbd2_journal_skip_recovery()
388 journal->j_tail = 0; in jbd2_journal_skip_recovery()
392 static inline unsigned long long read_tag_block(journal_t *journal, in read_tag_block() argument
396 if (jbd2_has_feature_64bit(journal)) in read_tag_block()
405 static int calc_chksums(journal_t *journal, struct buffer_head *bh, in calc_chksums() argument
412 num_blks = count_tags(journal, bh); in calc_chksums()
418 wrap(journal, *next_log_block); in calc_chksums()
419 err = jread(&obh, journal, io_block); in calc_chksums()
492 static int do_one_pass(journal_t *journal, in do_one_pass() argument
503 int tag_bytes = journal_tag_bytes(journal); in do_one_pass()
516 sb = journal->j_superblock; in do_one_pass()
552 next_commit_ID, next_log_block, journal->j_last); in do_one_pass()
559 err = jread(&bh, journal, next_log_block); in do_one_pass()
564 wrap(journal, next_log_block); in do_one_pass()
596 if (jbd2_journal_has_csum_v2or3(journal)) in do_one_pass()
600 !jbd2_descriptor_block_csum_verify(journal, in do_one_pass()
604 * journal init. Don't error out on those yet. in do_one_pass()
625 jbd2_has_feature_checksum(journal) && in do_one_pass()
628 if (calc_chksums(journal, bh, in do_one_pass()
637 next_log_block += count_tags(journal, bh); in do_one_pass()
638 wrap(journal, next_log_block); in do_one_pass()
649 <= journal->j_blocksize - descr_csum_size) { in do_one_pass()
656 wrap(journal, next_log_block); in do_one_pass()
657 err = jread(&obh, journal, io_block); in do_one_pass()
670 blocknr = read_tag_block(journal, in do_one_pass()
677 (journal, blocknr, in do_one_pass()
686 journal, &tag, (journal_block_tag3_t *)tagp, in do_one_pass()
700 nbh = __getblk(journal->j_fs_dev, in do_one_pass()
702 journal->j_blocksize); in do_one_pass()
715 journal->j_blocksize); in do_one_pass()
745 * and journal corruption ? in do_one_pass()
754 * | GO TO NEXT "Journal Corruption" in do_one_pass()
763 * "Journal Corruption" | in do_one_pass()
779 * commit_time is increasing, it's the same journal, in do_one_pass()
780 * otherwise it is stale journal block, just end this in do_one_pass()
793 * It likely does not belong to same journal, in do_one_pass()
809 jbd2_has_feature_checksum(journal)) { in do_one_pass()
816 journal->j_failed_commit = in do_one_pass()
836 !jbd2_commit_block_csum_verify(journal, in do_one_pass()
839 journal, in do_one_pass()
851 if (!jbd2_has_feature_async_commit(journal)) { in do_one_pass()
852 journal->j_failed_commit = in do_one_pass()
873 !jbd2_descriptor_block_csum_verify(journal, in do_one_pass()
887 err = scan_revoke_records(journal, bh, in do_one_pass()
927 if (jbd2_has_feature_fast_commit(journal) && pass != PASS_REVOKE) { in do_one_pass()
928 err = fc_do_one_pass(journal, info, pass); in do_one_pass()
943 static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, in scan_revoke_records() argument
956 if (jbd2_journal_has_csum_v2or3(journal)) in scan_revoke_records()
958 if (rcount > journal->j_blocksize - csum_size) in scan_revoke_records()
962 if (jbd2_has_feature_64bit(journal)) in scan_revoke_records()
974 err = jbd2_journal_set_revoke(journal, blocknr, sequence); in scan_revoke_records()