Home | History | Annotate | Download | only in e2fsck

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;
186 /* if we had an error doing journal recovery, we need a full fsck */
193 * This is a helper function to check the validity of the journal.
230 journal_t *journal = NULL;
239 journal = e2fsck_allocate_memory(ctx, sizeof(journal_t), "journal");
240 if (!journal) {
255 journal->j_dev = dev_journal;
256 journal->j_fs_dev = dev_fs;
257 journal->j_inode = NULL;
258 journal->j_blocksize = ctx->fs->blocksize;
266 "journal inode");
298 if (j_inode->i_ext2.i_size / journal->j_blocksize <
319 journal->j_maxlen = j_inode->i_ext2.i_size / journal->j_blocksize;
330 journal->j_inode = j_inode;
332 if ((retval = journal_bmap(journal, 0, &start)) != 0)
354 jfs_debug(1, "Using journal file %s\n", journal_name);
398 /* Make sure the journal UUID is correct */
406 journal->j_maxlen = jsuper.s_blocks_count;
410 if (!(bh = getblk(dev_journal, start, journal->j_blocksize))) {
415 journal->j_sb_buffer = bh;
416 journal->j_superblock = (journal_superblock_t *)bh->b_data;
423 *ret_journal = journal;
433 if (journal)
434 ext2fs_free_mem(&journal);
448 /* The journal inode is bogus, remove and force full fsck */
452 printf("*** ext3 journal has been deleted - "
473 static void clear_v2_journal_fields(journal_t *journal)
475 e2fsck_t ctx = journal->j_dev->k_ctx;
483 memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
485 mark_buffer_dirty(journal->j_sb_buffer);
489 static errcode_t e2fsck_journal_load(journal_t *journal)
491 e2fsck_t ctx = journal->j_dev->k_ctx;
493 struct buffer_head *jbh = journal->j_sb_buffer;
501 _("reading journal superblock\n"));
505 jsb = journal->j_superblock;
512 journal->j_format_version = 1;
517 clear_v2_journal_fields(journal);
521 journal->j_format_version = 2;
524 clear_v2_journal_fields(journal);
532 * These should never appear in a journal super block, so if
533 * they do, the journal is badly corrupted.
547 if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
550 if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
553 /* We have now checked whether we know enough about the journal
556 if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
558 _("%s: no valid journal superblock found\n"),
563 if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
564 journal->j_maxlen = ntohl(jsb->s_maxlen);
565 else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
567 _("%s: journal too short\n"),
572 journal->j_tail_sequence = ntohl(jsb->s_sequence);
573 journal->j_transaction_sequence = journal->j_tail_sequence;
574 journal->j_tail = ntohl(jsb->s_start);
575 journal->j_first = ntohl(jsb->s_first);
576 journal->j_last = ntohl(jsb->s_maxlen);
582 journal_t *journal)
608 jsb->s_maxlen = htonl(journal->j_maxlen);
611 /* Initialize the journal sequence number so that there is "no"
612 * chance we will find old "valid" transactions in the journal.
613 * This avoids the need to zero the whole journal (slow to do,
621 mark_buffer_dirty(journal->j_sb_buffer);
622 ll_rw_block(WRITE, 1, &journal->j_sb_buffer);
626 journal_t *journal,
635 e2fsck_journal_reset_super(ctx, journal->j_superblock,
636 journal);
637 journal->j_transaction_sequence = 1;
648 static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
654 mark_buffer_clean(journal->j_sb_buffer);
656 jsb = journal->j_superblock;
657 jsb->s_sequence = htonl(journal->j_transaction_sequence);
659 jsb->s_start = 0; /* this marks the journal as empty */
660 mark_buffer_dirty(journal->j_sb_buffer);
662 brelse(journal->j_sb_buffer);
671 if (journal->j_inode)
672 ext2fs_free_mem(&journal->j_inode);
674 if (journal->j_fs_dev)
675 ext2fs_free_mem(&journal->j_fs_dev);
676 ext2fs_free_mem(&journal);
681 * journal are consistent.
686 journal_t *journal;
694 /* If we don't have any journal features, don't do anything more */
703 retval = e2fsck_get_journal(ctx, &journal);
713 retval = e2fsck_journal_load(journal);
724 retval = e2fsck_journal_fix_corrupt_super(ctx, journal,
726 e2fsck_journal_release(ctx, journal, 0, 1);
745 * journal stored on a reserved inode.
749 /* Clear all of the journal fields */
764 journal->j_superblock->s_start != 0) {
784 * ignore the fact that journal apparently has data;
791 * journal->j_superblock->s_start is mounted?
795 e2fsck_journal_release(ctx, journal, reset, 0);
801 journal_t *journal;
805 retval = e2fsck_get_journal(ctx, &journal);
809 retval = e2fsck_journal_load(journal);
813 retval = journal_init_revoke(journal, 1024);
817 retval = -journal_recover(journal);
821 if (journal->j_superblock->s_errno) {
824 journal->j_superblock->s_errno = 0;
825 mark_buffer_dirty(journal->j_sb_buffer);
829 journal_destroy_revoke(journal);
831 e2fsck_journal_release(ctx, journal, 1, 0);
841 printf(_("%s: recovering journal\n"), ctx->device_name);
843 printf(_("%s: won't do journal recovery while read-only\n"),
855 * because journal recovery will change the filesystem under us.
878 * This function will move the journal inode from a visible file in
882 ".journal", "journal", ".journal.dat", "journal.dat", 0 };
899 * journal, then do nothing.
907 * Read in the journal inode
913 * If it's necessary to backup the journal inode, do so.
929 * If the journal is already the hidden inode, then do nothing
935 * The journal inode had better have only one link and not be readable.
949 * If we can't find the name of the journal inode, then do
972 * journal inode. Errors at this point mean we need to force
1004 * journal is correct.