Home | History | Annotate | Download | only in e2fsck

Lines Matching full: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, blk64_t block, unsigned long long *phys)
52 struct inode *inode = journal->j_inode;
193 /* if we had an error doing journal recovery, we need a full fsck */
200 * This is a helper function to check the validity of the journal.
237 journal_t *journal = NULL;
246 journal = e2fsck_allocate_memory(ctx, sizeof(journal_t), "journal");
247 if (!journal) {
262 journal->j_dev = dev_journal;
263 journal->j_fs_dev = dev_fs;
264 journal->j_inode = NULL;
265 journal->j_blocksize = ctx->fs->blocksize;
273 "journal inode");
306 if (EXT2_I_SIZE(&j_inode->i_ext2) / journal->j_blocksize <
327 journal->j_maxlen = EXT2_I_SIZE(&j_inode->i_ext2) /
328 journal->j_blocksize;
339 journal->j_inode = j_inode;
341 if ((retval = (errcode_t) journal_bmap(journal, 0, &start)) != 0)
363 jfs_debug(1, "Using journal file %s\n", journal_name);
420 /* Make sure the journal UUID is correct */
429 journal->j_maxlen = (maxlen < 1ULL << 32) ? maxlen : (1ULL << 32) - 1;
433 if (!(bh = getblk(dev_journal, start, journal->j_blocksize))) {
438 journal->j_sb_buffer = bh;
439 journal->j_superblock = (journal_superblock_t *)bh->b_data;
446 *ret_journal = journal;
456 if (journal)
457 ext2fs_free_mem(&journal);
471 /* The journal inode is bogus, remove and force full fsck */
475 printf("*** ext3 journal has been deleted - "
496 static void clear_v2_journal_fields(journal_t *journal)
498 e2fsck_t ctx = journal->j_dev->k_ctx;
506 memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
508 mark_buffer_dirty(journal->j_sb_buffer);
512 static errcode_t e2fsck_journal_load(journal_t *journal)
514 e2fsck_t ctx = journal->j_dev->k_ctx;
516 struct buffer_head *jbh = journal->j_sb_buffer;
524 _("reading journal superblock\n"));
528 jsb = journal->j_superblock;
535 journal->j_format_version = 1;
540 clear_v2_journal_fields(journal);
544 journal->j_format_version = 2;
547 clear_v2_journal_fields(journal);
555 * These should never appear in a journal super block, so if
556 * they do, the journal is badly corrupted.
570 if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
573 if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
576 /* We have now checked whether we know enough about the journal
579 if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
581 _("%s: no valid journal superblock found\n"),
586 if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
587 journal->j_maxlen = ntohl(jsb->s_maxlen);
588 else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
590 _("%s: journal too short\n"),
595 journal->j_tail_sequence = ntohl(jsb->s_sequence);
596 journal->j_transaction_sequence = journal->j_tail_sequence;
597 journal->j_tail = ntohl(jsb->s_start);
598 journal->j_first = ntohl(jsb->s_first);
599 journal->j_last = ntohl(jsb->s_maxlen);
605 journal_t *journal)
631 jsb->s_maxlen = htonl(journal->j_maxlen);
634 /* Initialize the journal sequence number so that there is "no"
635 * chance we will find old "valid" transactions in the journal.
636 * This avoids the need to zero the whole journal (slow to do,
644 mark_buffer_dirty(journal->j_sb_buffer);
645 ll_rw_block(WRITE, 1, &journal->j_sb_buffer);
649 journal_t *journal,
658 e2fsck_journal_reset_super(ctx, journal->j_superblock,
659 journal);
660 journal->j_transaction_sequence = 1;
671 static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
677 mark_buffer_clean(journal->j_sb_buffer);
679 jsb = journal->j_superblock;
680 jsb->s_sequence = htonl(journal->j_transaction_sequence);
682 jsb->s_start = 0; /* this marks the journal as empty */
683 mark_buffer_dirty(journal->j_sb_buffer);
685 brelse(journal->j_sb_buffer);
694 if (journal->j_inode)
695 ext2fs_free_mem(&journal->j_inode);
697 if (journal->j_fs_dev)
698 ext2fs_free_mem(&journal->j_fs_dev);
699 ext2fs_free_mem(&journal);
704 * journal are consistent.
709 journal_t *journal;
717 /* If we don't have any journal features, don't do anything more */
726 retval = e2fsck_get_journal(ctx, &journal);
736 retval = e2fsck_journal_load(journal);
747 retval = e2fsck_journal_fix_corrupt_super(ctx, journal,
749 e2fsck_journal_release(ctx, journal, 0, 1);
768 * journal stored on a reserved inode.
772 /* Clear all of the journal fields */
787 journal->j_superblock->s_start != 0) {
807 * ignore the fact that journal apparently has data;
814 * journal->j_superblock->s_start is mounted?
819 * If we don't need to do replay the journal, check to see if
820 * the journal's errno is set; if so, we need to mark the file
821 * system as being corrupt and clear the journal's s_errno.
824 journal->j_superblock->s_errno) {
827 journal->j_superblock->s_errno = 0;
828 mark_buffer_dirty(journal->j_sb_buffer);
831 e2fsck_journal_release(ctx, journal, reset, 0);
838 journal_t *journal;
844 retval = e2fsck_get_journal(ctx, &journal);
848 retval = e2fsck_journal_load(journal);
852 retval = journal_init_revoke(journal, 1024);
856 retval = -journal_recover(journal);
860 if (journal->j_failed_commit) {
861 pctx.ino = journal->j_failed_commit;
863 journal->j_superblock->s_errno = -EINVAL;
864 mark_buffer_dirty(journal->j_sb_buffer);
868 journal_destroy_revoke(journal);
870 e2fsck_journal_release(ctx, journal, 1, 0);
882 printf(_("%s: recovering journal\n"), ctx->device_name);
884 printf(_("%s: won't do journal recovery while read-only\n"),
896 * because journal recovery will change the filesystem under us.
924 * Do one last sanity check, and propagate journal->s_errno to
932 * This function will move the journal inode from a visible file in
936 ".journal", "journal", ".journal.dat", "journal.dat", 0 };
954 * journal, then do nothing.
962 * Read in the journal inode
968 * If it's necessary to backup the journal inode, do so.
985 * If the journal is already the hidden inode, then do nothing
991 * The journal inode had better have only one link and not be readable.
1005 * If we can't find the name of the journal inode, then do
1028 * journal inode. Errors at this point mean we need to force
1061 * journal is correct.