aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/journal.c
diff options
context:
space:
mode:
authorEdward Shishkin <edward@namesys.com>2007-10-17 02:30:30 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:43:01 -0400
commitcf3d0b8182f0746dbb9ed3609e3aa0c3802f45e8 (patch)
tree79e3ed35239b8b5ac6b1f6e64f31915ed89ae2a7 /fs/reiserfs/journal.c
parentf4a1c2bce002f683801bcdbbc9fd89804614fb6b (diff)
reiserfs: do not repair wrong journal params
When mounting a file system with wrong journal params do not try to repair them, suggest fsck instead. Signed-off-by: Edward Shishkin <edward@namesys.com> Cc: Jeff Mahoney <jeffm@suse.com> Cc: Chris Mason <chris.mason@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/journal.c')
-rw-r--r--fs/reiserfs/journal.c100
1 files changed, 57 insertions, 43 deletions
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 6c1d0c35f9e9..4cad9e75ef56 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2649,6 +2649,61 @@ static int journal_init_dev(struct super_block *super,
2649 return result; 2649 return result;
2650} 2650}
2651 2651
2652/**
2653 * When creating/tuning a file system user can assign some
2654 * journal params within boundaries which depend on the ratio
2655 * blocksize/standard_blocksize.
2656 *
2657 * For blocks >= standard_blocksize transaction size should
2658 * be not less then JOURNAL_TRANS_MIN_DEFAULT, and not more
2659 * then JOURNAL_TRANS_MAX_DEFAULT.
2660 *
2661 * For blocks < standard_blocksize these boundaries should be
2662 * decreased proportionally.
2663 */
2664#define REISERFS_STANDARD_BLKSIZE (4096)
2665
2666static int check_advise_trans_params(struct super_block *p_s_sb,
2667 struct reiserfs_journal *journal)
2668{
2669 if (journal->j_trans_max) {
2670 /* Non-default journal params.
2671 Do sanity check for them. */
2672 int ratio = 1;
2673 if (p_s_sb->s_blocksize < REISERFS_STANDARD_BLKSIZE)
2674 ratio = REISERFS_STANDARD_BLKSIZE / p_s_sb->s_blocksize;
2675
2676 if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio ||
2677 journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio ||
2678 SB_ONDISK_JOURNAL_SIZE(p_s_sb) / journal->j_trans_max <
2679 JOURNAL_MIN_RATIO) {
2680 reiserfs_warning(p_s_sb,
2681 "sh-462: bad transaction max size (%u). FSCK?",
2682 journal->j_trans_max);
2683 return 1;
2684 }
2685 if (journal->j_max_batch != (journal->j_trans_max) *
2686 JOURNAL_MAX_BATCH_DEFAULT/JOURNAL_TRANS_MAX_DEFAULT) {
2687 reiserfs_warning(p_s_sb,
2688 "sh-463: bad transaction max batch (%u). FSCK?",
2689 journal->j_max_batch);
2690 return 1;
2691 }
2692 } else {
2693 /* Default journal params.
2694 The file system was created by old version
2695 of mkreiserfs, so some fields contain zeros,
2696 and we need to advise proper values for them */
2697 if (p_s_sb->s_blocksize != REISERFS_STANDARD_BLKSIZE)
2698 reiserfs_panic(p_s_sb, "sh-464: bad blocksize (%u)",
2699 p_s_sb->s_blocksize);
2700 journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT;
2701 journal->j_max_batch = JOURNAL_MAX_BATCH_DEFAULT;
2702 journal->j_max_commit_age = JOURNAL_MAX_COMMIT_AGE;
2703 }
2704 return 0;
2705}
2706
2652/* 2707/*
2653** must be called once on fs mount. calls journal_read for you 2708** must be called once on fs mount. calls journal_read for you
2654*/ 2709*/
@@ -2744,49 +2799,8 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2744 le32_to_cpu(jh->jh_journal.jp_journal_max_commit_age); 2799 le32_to_cpu(jh->jh_journal.jp_journal_max_commit_age);
2745 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE; 2800 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
2746 2801
2747 if (journal->j_trans_max) { 2802 if (check_advise_trans_params(p_s_sb, journal) != 0)
2748 /* make sure these parameters are available, assign it if they are not */ 2803 goto free_and_return;
2749 __u32 initial = journal->j_trans_max;
2750 __u32 ratio = 1;
2751
2752 if (p_s_sb->s_blocksize < 4096)
2753 ratio = 4096 / p_s_sb->s_blocksize;
2754
2755 if (SB_ONDISK_JOURNAL_SIZE(p_s_sb) / journal->j_trans_max <
2756 JOURNAL_MIN_RATIO)
2757 journal->j_trans_max =
2758 SB_ONDISK_JOURNAL_SIZE(p_s_sb) / JOURNAL_MIN_RATIO;
2759 if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio)
2760 journal->j_trans_max =
2761 JOURNAL_TRANS_MAX_DEFAULT / ratio;
2762 if (journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio)
2763 journal->j_trans_max =
2764 JOURNAL_TRANS_MIN_DEFAULT / ratio;
2765
2766 if (journal->j_trans_max != initial)
2767 reiserfs_warning(p_s_sb,
2768 "sh-461: journal_init: wrong transaction max size (%u). Changed to %u",
2769 initial, journal->j_trans_max);
2770
2771 journal->j_max_batch = journal->j_trans_max *
2772 JOURNAL_MAX_BATCH_DEFAULT / JOURNAL_TRANS_MAX_DEFAULT;
2773 }
2774
2775 if (!journal->j_trans_max) {
2776 /*we have the file system was created by old version of mkreiserfs
2777 so this field contains zero value */
2778 journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT;
2779 journal->j_max_batch = JOURNAL_MAX_BATCH_DEFAULT;
2780 journal->j_max_commit_age = JOURNAL_MAX_COMMIT_AGE;
2781
2782 /* for blocksize >= 4096 - max transaction size is 1024. For block size < 4096
2783 trans max size is decreased proportionally */
2784 if (p_s_sb->s_blocksize < 4096) {
2785 journal->j_trans_max /= (4096 / p_s_sb->s_blocksize);
2786 journal->j_max_batch = (journal->j_trans_max) * 9 / 10;
2787 }
2788 }
2789
2790 journal->j_default_max_commit_age = journal->j_max_commit_age; 2804 journal->j_default_max_commit_age = journal->j_max_commit_age;
2791 2805
2792 if (commit_max_age != 0) { 2806 if (commit_max_age != 0) {