Lines Matching refs:journal

2  * journal.c --- code for handling the "ext3" journal
7 * Parts of the code are based on fs/jfs/journal.c by Stephen C. Tweedie
42 /* Kernel compatibility functions for handling the journal. These allow us
46 int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys)
52 struct inode *inode = journal->j_inode;
192 /* if we had an error doing journal recovery, we need a full fsck */
199 * This is a helper function to check the validity of the journal.
236 journal_t *journal = NULL;
245 journal = e2fsck_allocate_memory(ctx, sizeof(journal_t), "journal");
246 if (!journal) {
261 journal->j_dev = dev_journal;
262 journal->j_fs_dev = dev_fs;
263 journal->j_inode = NULL;
264 journal->j_blocksize = ctx->fs->blocksize;
272 "journal inode");
304 if (j_inode->i_ext2.i_size / journal->j_blocksize <
325 journal->j_maxlen = j_inode->i_ext2.i_size / journal->j_blocksize;
336 journal->j_inode = j_inode;
338 if ((retval = journal_bmap(journal, 0, &start)) != 0)
360 jfs_debug(1, "Using journal file %s\n", journal_name);
404 /* Make sure the journal UUID is correct */
412 journal->j_maxlen = jsuper.s_blocks_count;
416 if (!(bh = getblk(dev_journal, start, journal->j_blocksize))) {
421 journal->j_sb_buffer = bh;
422 journal->j_superblock = (journal_superblock_t *)bh->b_data;
429 *ret_journal = journal;
439 if (journal)
440 ext2fs_free_mem(&journal);
454 /* The journal inode is bogus, remove and force full fsck */
458 printf("*** ext3 journal has been deleted - "
479 static void clear_v2_journal_fields(journal_t *journal)
481 e2fsck_t ctx = journal->j_dev->k_ctx;
489 memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
491 mark_buffer_dirty(journal->j_sb_buffer);
495 static errcode_t e2fsck_journal_load(journal_t *journal)
497 e2fsck_t ctx = journal->j_dev->k_ctx;
499 struct buffer_head *jbh = journal->j_sb_buffer;
507 _("reading journal superblock\n"));
511 jsb = journal->j_superblock;
518 journal->j_format_version = 1;
523 clear_v2_journal_fields(journal);
527 journal->j_format_version = 2;
530 clear_v2_journal_fields(journal);
538 * These should never appear in a journal super block, so if
539 * they do, the journal is badly corrupted.
553 if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
556 if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
559 /* We have now checked whether we know enough about the journal
562 if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
564 _("%s: no valid journal superblock found\n"),
569 if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
570 journal->j_maxlen = ntohl(jsb->s_maxlen);
571 else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
573 _("%s: journal too short\n"),
578 journal->j_tail_sequence = ntohl(jsb->s_sequence);
579 journal->j_transaction_sequence = journal->j_tail_sequence;
580 journal->j_tail = ntohl(jsb->s_start);
581 journal->j_first = ntohl(jsb->s_first);
582 journal->j_last = ntohl(jsb->s_maxlen);
588 journal_t *journal)
614 jsb->s_maxlen = htonl(journal->j_maxlen);
617 /* Initialize the journal sequence number so that there is "no"
618 * chance we will find old "valid" transactions in the journal.
619 * This avoids the need to zero the whole journal (slow to do,
627 mark_buffer_dirty(journal->j_sb_buffer);
628 ll_rw_block(WRITE, 1, &journal->j_sb_buffer);
632 journal_t *journal,
641 e2fsck_journal_reset_super(ctx, journal->j_superblock,
642 journal);
643 journal->j_transaction_sequence = 1;
654 static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
660 mark_buffer_clean(journal->j_sb_buffer);
662 jsb = journal->j_superblock;
663 jsb->s_sequence = htonl(journal->j_transaction_sequence);
665 jsb->s_start = 0; /* this marks the journal as empty */
666 mark_buffer_dirty(journal->j_sb_buffer);
668 brelse(journal->j_sb_buffer);
677 if (journal->j_inode)
678 ext2fs_free_mem(&journal->j_inode);
680 if (journal->j_fs_dev)
681 ext2fs_free_mem(&journal->j_fs_dev);
682 ext2fs_free_mem(&journal);
687 * journal are consistent.
692 journal_t *journal;
700 /* If we don't have any journal features, don't do anything more */
709 retval = e2fsck_get_journal(ctx, &journal);
719 retval = e2fsck_journal_load(journal);
730 retval = e2fsck_journal_fix_corrupt_super(ctx, journal,
732 e2fsck_journal_release(ctx, journal, 0, 1);
751 * journal stored on a reserved inode.
755 /* Clear all of the journal fields */
770 journal->j_superblock->s_start != 0) {
790 * ignore the fact that journal apparently has data;
797 * journal->j_superblock->s_start is mounted?
802 * If we don't need to do replay the journal, check to see if
803 * the journal's errno is set; if so, we need to mark the file
804 * system as being corrupt and clear the journal's s_errno.
807 journal->j_superblock->s_errno) {
810 journal->j_superblock->s_errno = 0;
811 mark_buffer_dirty(journal->j_sb_buffer);
814 e2fsck_journal_release(ctx, journal, reset, 0);
821 journal_t *journal;
827 retval = e2fsck_get_journal(ctx, &journal);
831 retval = e2fsck_journal_load(journal);
835 retval = journal_init_revoke(journal, 1024);
839 retval = -journal_recover(journal);
843 if (journal->j_failed_commit) {
844 pctx.ino = journal->j_failed_commit;
846 journal->j_superblock->s_errno = -EINVAL;
847 mark_buffer_dirty(journal->j_sb_buffer);
851 journal_destroy_revoke(journal);
853 e2fsck_journal_release(ctx, journal, 1, 0);
865 printf(_("%s: recovering journal\n"), ctx->device_name);
867 printf(_("%s: won't do journal recovery while read-only\n"),
879 * because journal recovery will change the filesystem under us.
905 * Do one last sanity check, and propagate journal->s_errno to
913 * This function will move the journal inode from a visible file in
917 ".journal", "journal", ".journal.dat", "journal.dat", 0 };
934 * journal, then do nothing.
942 * Read in the journal inode
948 * If it's necessary to backup the journal inode, do so.
964 * If the journal is already the hidden inode, then do nothing
970 * The journal inode had better have only one link and not be readable.
984 * If we can't find the name of the journal inode, then do
1007 * journal inode. Errors at this point mean we need to force
1040 * journal is correct.