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;
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);
405 /* Make sure the journal UUID is correct */
413 journal->j_maxlen = jsuper.s_blocks_count;
417 if (!(bh = getblk(dev_journal, start, journal->j_blocksize))) {
422 journal->j_sb_buffer = bh;
423 journal->j_superblock = (journal_superblock_t *)bh->b_data;
430 *ret_journal = journal;
440 if (journal)
441 ext2fs_free_mem(&journal);
455 /* The journal inode is bogus, remove and force full fsck */
459 printf("*** ext3 journal has been deleted - "
480 static void clear_v2_journal_fields(journal_t *journal)
482 e2fsck_t ctx = journal->j_dev->k_ctx;
490 memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
492 mark_buffer_dirty(journal->j_sb_buffer);
496 static errcode_t e2fsck_journal_load(journal_t *journal)
498 e2fsck_t ctx = journal->j_dev->k_ctx;
500 struct buffer_head *jbh = journal->j_sb_buffer;
508 _("reading journal superblock\n"));
512 jsb = journal->j_superblock;
519 journal->j_format_version = 1;
524 clear_v2_journal_fields(journal);
528 journal->j_format_version = 2;
531 clear_v2_journal_fields(journal);
539 * These should never appear in a journal super block, so if
540 * they do, the journal is badly corrupted.
554 if (JFS_HAS_INCOMPAT_FEATURE(journal, ~JFS_KNOWN_INCOMPAT_FEATURES))
557 if (JFS_HAS_RO_COMPAT_FEATURE(journal, ~JFS_KNOWN_ROCOMPAT_FEATURES))
560 /* We have now checked whether we know enough about the journal
563 if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
565 _("%s: no valid journal superblock found\n"),
570 if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
571 journal->j_maxlen = ntohl(jsb->s_maxlen);
572 else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
574 _("%s: journal too short\n"),
579 journal->j_tail_sequence = ntohl(jsb->s_sequence);
580 journal->j_transaction_sequence = journal->j_tail_sequence;
581 journal->j_tail = ntohl(jsb->s_start);
582 journal->j_first = ntohl(jsb->s_first);
583 journal->j_last = ntohl(jsb->s_maxlen);
589 journal_t *journal)
615 jsb->s_maxlen = htonl(journal->j_maxlen);
618 /* Initialize the journal sequence number so that there is "no"
619 * chance we will find old "valid" transactions in the journal.
620 * This avoids the need to zero the whole journal (slow to do,
628 mark_buffer_dirty(journal->j_sb_buffer);
629 ll_rw_block(WRITE, 1, &journal->j_sb_buffer);
633 journal_t *journal,
642 e2fsck_journal_reset_super(ctx, journal->j_superblock,
643 journal);
644 journal->j_transaction_sequence = 1;
655 static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
661 mark_buffer_clean(journal->j_sb_buffer);
663 jsb = journal->j_superblock;
664 jsb->s_sequence = htonl(journal->j_transaction_sequence);
666 jsb->s_start = 0; /* this marks the journal as empty */
667 mark_buffer_dirty(journal->j_sb_buffer);
669 brelse(journal->j_sb_buffer);
678 if (journal->j_inode)
679 ext2fs_free_mem(&journal->j_inode);
681 if (journal->j_fs_dev)
682 ext2fs_free_mem(&journal->j_fs_dev);
683 ext2fs_free_mem(&journal);
688 * journal are consistent.
693 journal_t *journal;
701 /* If we don't have any journal features, don't do anything more */
710 retval = e2fsck_get_journal(ctx, &journal);
720 retval = e2fsck_journal_load(journal);
731 retval = e2fsck_journal_fix_corrupt_super(ctx, journal,
733 e2fsck_journal_release(ctx, journal, 0, 1);
752 * journal stored on a reserved inode.
756 /* Clear all of the journal fields */
771 journal->j_superblock->s_start != 0) {
791 * ignore the fact that journal apparently has data;
798 * journal->j_superblock->s_start is mounted?
803 * If we don't need to do replay the journal, check to see if
804 * the journal's errno is set; if so, we need to mark the file
805 * system as being corrupt and clear the journal's s_errno.
808 journal->j_superblock->s_errno) {
811 journal->j_superblock->s_errno = 0;
812 mark_buffer_dirty(journal->j_sb_buffer);
815 e2fsck_journal_release(ctx, journal, reset, 0);
822 journal_t *journal;
828 retval = e2fsck_get_journal(ctx, &journal);
832 retval = e2fsck_journal_load(journal);
836 retval = journal_init_revoke(journal, 1024);
840 retval = -journal_recover(journal);
844 if (journal->j_failed_commit) {
845 pctx.ino = journal->j_failed_commit;
847 journal->j_superblock->s_errno = -EINVAL;
848 mark_buffer_dirty(journal->j_sb_buffer);
852 journal_destroy_revoke(journal);
854 e2fsck_journal_release(ctx, journal, 1, 0);
866 printf(_("%s: recovering journal\n"), ctx->device_name);
868 printf(_("%s: won't do journal recovery while read-only\n"),
880 * because journal recovery will change the filesystem under us.
906 * Do one last sanity check, and propagate journal->s_errno to
914 * This function will move the journal inode from a visible file in
918 ".journal", "journal", ".journal.dat", "journal.dat", 0 };
935 * journal, then do nothing.
943 * Read in the journal inode
949 * If it's necessary to backup the journal inode, do so.
965 * If the journal is already the hidden inode, then do nothing
971 * The journal inode had better have only one link and not be readable.
985 * If we can't find the name of the journal inode, then do
1008 * journal inode. Errors at this point mean we need to force
1041 * journal is correct.