diff options
Diffstat (limited to 'fs/ext2/super.c')
-rw-r--r-- | fs/ext2/super.c | 208 |
1 files changed, 133 insertions, 75 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1a9ffee47d56..42e4a303b675 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function, | |||
58 | } | 58 | } |
59 | 59 | ||
60 | va_start(args, fmt); | 60 | va_start(args, fmt); |
61 | printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function); | 61 | printk(KERN_CRIT "EXT2-fs (%s): error: %s: ", sb->s_id, function); |
62 | vprintk(fmt, args); | 62 | vprintk(fmt, args); |
63 | printk("\n"); | 63 | printk("\n"); |
64 | va_end(args); | 64 | va_end(args); |
65 | 65 | ||
66 | if (test_opt(sb, ERRORS_PANIC)) | 66 | if (test_opt(sb, ERRORS_PANIC)) |
67 | panic("EXT2-fs panic from previous error\n"); | 67 | panic("EXT2-fs: panic from previous error\n"); |
68 | if (test_opt(sb, ERRORS_RO)) { | 68 | if (test_opt(sb, ERRORS_RO)) { |
69 | printk("Remounting filesystem read-only\n"); | 69 | ext2_msg(sb, KERN_CRIT, |
70 | "error: remounting filesystem read-only"); | ||
70 | sb->s_flags |= MS_RDONLY; | 71 | sb->s_flags |= MS_RDONLY; |
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | void ext2_warning (struct super_block * sb, const char * function, | 75 | void ext2_msg(struct super_block *sb, const char *prefix, |
75 | const char * fmt, ...) | 76 | const char *fmt, ...) |
76 | { | 77 | { |
77 | va_list args; | 78 | va_list args; |
78 | 79 | ||
79 | va_start(args, fmt); | 80 | va_start(args, fmt); |
80 | printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ", | 81 | printk("%sEXT2-fs (%s): ", prefix, sb->s_id); |
81 | sb->s_id, function); | ||
82 | vprintk(fmt, args); | 82 | vprintk(fmt, args); |
83 | printk("\n"); | 83 | printk("\n"); |
84 | va_end(args); | 84 | va_end(args); |
@@ -91,9 +91,9 @@ void ext2_update_dynamic_rev(struct super_block *sb) | |||
91 | if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) | 91 | if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | ext2_warning(sb, __func__, | 94 | ext2_msg(sb, KERN_WARNING, |
95 | "updating to rev %d because of new feature flag, " | 95 | "warning: updating to rev %d because of " |
96 | "running e2fsck is recommended", | 96 | "new feature flag, running e2fsck is recommended", |
97 | EXT2_DYNAMIC_REV); | 97 | EXT2_DYNAMIC_REV); |
98 | 98 | ||
99 | es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO); | 99 | es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO); |
@@ -194,6 +194,8 @@ static void destroy_inodecache(void) | |||
194 | static void ext2_clear_inode(struct inode *inode) | 194 | static void ext2_clear_inode(struct inode *inode) |
195 | { | 195 | { |
196 | struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info; | 196 | struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info; |
197 | |||
198 | dquot_drop(inode); | ||
197 | ext2_discard_reservation(inode); | 199 | ext2_discard_reservation(inode); |
198 | EXT2_I(inode)->i_block_alloc_info = NULL; | 200 | EXT2_I(inode)->i_block_alloc_info = NULL; |
199 | if (unlikely(rsv)) | 201 | if (unlikely(rsv)) |
@@ -419,10 +421,10 @@ static const match_table_t tokens = { | |||
419 | {Opt_err, NULL} | 421 | {Opt_err, NULL} |
420 | }; | 422 | }; |
421 | 423 | ||
422 | static int parse_options (char * options, | 424 | static int parse_options(char *options, struct super_block *sb) |
423 | struct ext2_sb_info *sbi) | ||
424 | { | 425 | { |
425 | char * p; | 426 | char *p; |
427 | struct ext2_sb_info *sbi = EXT2_SB(sb); | ||
426 | substring_t args[MAX_OPT_ARGS]; | 428 | substring_t args[MAX_OPT_ARGS]; |
427 | int option; | 429 | int option; |
428 | 430 | ||
@@ -505,7 +507,8 @@ static int parse_options (char * options, | |||
505 | #else | 507 | #else |
506 | case Opt_user_xattr: | 508 | case Opt_user_xattr: |
507 | case Opt_nouser_xattr: | 509 | case Opt_nouser_xattr: |
508 | printk("EXT2 (no)user_xattr options not supported\n"); | 510 | ext2_msg(sb, KERN_INFO, "(no)user_xattr options" |
511 | "not supported"); | ||
509 | break; | 512 | break; |
510 | #endif | 513 | #endif |
511 | #ifdef CONFIG_EXT2_FS_POSIX_ACL | 514 | #ifdef CONFIG_EXT2_FS_POSIX_ACL |
@@ -518,14 +521,15 @@ static int parse_options (char * options, | |||
518 | #else | 521 | #else |
519 | case Opt_acl: | 522 | case Opt_acl: |
520 | case Opt_noacl: | 523 | case Opt_noacl: |
521 | printk("EXT2 (no)acl options not supported\n"); | 524 | ext2_msg(sb, KERN_INFO, |
525 | "(no)acl options not supported"); | ||
522 | break; | 526 | break; |
523 | #endif | 527 | #endif |
524 | case Opt_xip: | 528 | case Opt_xip: |
525 | #ifdef CONFIG_EXT2_FS_XIP | 529 | #ifdef CONFIG_EXT2_FS_XIP |
526 | set_opt (sbi->s_mount_opt, XIP); | 530 | set_opt (sbi->s_mount_opt, XIP); |
527 | #else | 531 | #else |
528 | printk("EXT2 xip option not supported\n"); | 532 | ext2_msg(sb, KERN_INFO, "xip option not supported"); |
529 | #endif | 533 | #endif |
530 | break; | 534 | break; |
531 | 535 | ||
@@ -542,19 +546,18 @@ static int parse_options (char * options, | |||
542 | case Opt_quota: | 546 | case Opt_quota: |
543 | case Opt_usrquota: | 547 | case Opt_usrquota: |
544 | case Opt_grpquota: | 548 | case Opt_grpquota: |
545 | printk(KERN_ERR | 549 | ext2_msg(sb, KERN_INFO, |
546 | "EXT2-fs: quota operations not supported.\n"); | 550 | "quota operations not supported"); |
547 | |||
548 | break; | 551 | break; |
549 | #endif | 552 | #endif |
550 | 553 | ||
551 | case Opt_reservation: | 554 | case Opt_reservation: |
552 | set_opt(sbi->s_mount_opt, RESERVATION); | 555 | set_opt(sbi->s_mount_opt, RESERVATION); |
553 | printk("reservations ON\n"); | 556 | ext2_msg(sb, KERN_INFO, "reservations ON"); |
554 | break; | 557 | break; |
555 | case Opt_noreservation: | 558 | case Opt_noreservation: |
556 | clear_opt(sbi->s_mount_opt, RESERVATION); | 559 | clear_opt(sbi->s_mount_opt, RESERVATION); |
557 | printk("reservations OFF\n"); | 560 | ext2_msg(sb, KERN_INFO, "reservations OFF"); |
558 | break; | 561 | break; |
559 | case Opt_ignore: | 562 | case Opt_ignore: |
560 | break; | 563 | break; |
@@ -573,34 +576,40 @@ static int ext2_setup_super (struct super_block * sb, | |||
573 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 576 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
574 | 577 | ||
575 | if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { | 578 | if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { |
576 | printk ("EXT2-fs warning: revision level too high, " | 579 | ext2_msg(sb, KERN_ERR, |
577 | "forcing read-only mode\n"); | 580 | "error: revision level too high, " |
581 | "forcing read-only mode"); | ||
578 | res = MS_RDONLY; | 582 | res = MS_RDONLY; |
579 | } | 583 | } |
580 | if (read_only) | 584 | if (read_only) |
581 | return res; | 585 | return res; |
582 | if (!(sbi->s_mount_state & EXT2_VALID_FS)) | 586 | if (!(sbi->s_mount_state & EXT2_VALID_FS)) |
583 | printk ("EXT2-fs warning: mounting unchecked fs, " | 587 | ext2_msg(sb, KERN_WARNING, |
584 | "running e2fsck is recommended\n"); | 588 | "warning: mounting unchecked fs, " |
589 | "running e2fsck is recommended"); | ||
585 | else if ((sbi->s_mount_state & EXT2_ERROR_FS)) | 590 | else if ((sbi->s_mount_state & EXT2_ERROR_FS)) |
586 | printk ("EXT2-fs warning: mounting fs with errors, " | 591 | ext2_msg(sb, KERN_WARNING, |
587 | "running e2fsck is recommended\n"); | 592 | "warning: mounting fs with errors, " |
593 | "running e2fsck is recommended"); | ||
588 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && | 594 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && |
589 | le16_to_cpu(es->s_mnt_count) >= | 595 | le16_to_cpu(es->s_mnt_count) >= |
590 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) | 596 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) |
591 | printk ("EXT2-fs warning: maximal mount count reached, " | 597 | ext2_msg(sb, KERN_WARNING, |
592 | "running e2fsck is recommended\n"); | 598 | "warning: maximal mount count reached, " |
599 | "running e2fsck is recommended"); | ||
593 | else if (le32_to_cpu(es->s_checkinterval) && | 600 | else if (le32_to_cpu(es->s_checkinterval) && |
594 | (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds())) | 601 | (le32_to_cpu(es->s_lastcheck) + |
595 | printk ("EXT2-fs warning: checktime reached, " | 602 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) |
596 | "running e2fsck is recommended\n"); | 603 | ext2_msg(sb, KERN_WARNING, |
604 | "warning: checktime reached, " | ||
605 | "running e2fsck is recommended"); | ||
597 | if (!le16_to_cpu(es->s_max_mnt_count)) | 606 | if (!le16_to_cpu(es->s_max_mnt_count)) |
598 | es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); | 607 | es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); |
599 | le16_add_cpu(&es->s_mnt_count, 1); | 608 | le16_add_cpu(&es->s_mnt_count, 1); |
600 | ext2_write_super(sb); | 609 | ext2_write_super(sb); |
601 | if (test_opt (sb, DEBUG)) | 610 | if (test_opt (sb, DEBUG)) |
602 | printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " | 611 | ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, " |
603 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", | 612 | "bpg=%lu, ipg=%lu, mo=%04lx]", |
604 | EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, | 613 | EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, |
605 | sbi->s_frag_size, | 614 | sbi->s_frag_size, |
606 | sbi->s_groups_count, | 615 | sbi->s_groups_count, |
@@ -767,7 +776,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
767 | */ | 776 | */ |
768 | blocksize = sb_min_blocksize(sb, BLOCK_SIZE); | 777 | blocksize = sb_min_blocksize(sb, BLOCK_SIZE); |
769 | if (!blocksize) { | 778 | if (!blocksize) { |
770 | printk ("EXT2-fs: unable to set blocksize\n"); | 779 | ext2_msg(sb, KERN_ERR, "error: unable to set blocksize"); |
771 | goto failed_sbi; | 780 | goto failed_sbi; |
772 | } | 781 | } |
773 | 782 | ||
@@ -783,7 +792,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
783 | } | 792 | } |
784 | 793 | ||
785 | if (!(bh = sb_bread(sb, logic_sb_block))) { | 794 | if (!(bh = sb_bread(sb, logic_sb_block))) { |
786 | printk ("EXT2-fs: unable to read superblock\n"); | 795 | ext2_msg(sb, KERN_ERR, "error: unable to read superblock"); |
787 | goto failed_sbi; | 796 | goto failed_sbi; |
788 | } | 797 | } |
789 | /* | 798 | /* |
@@ -826,7 +835,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
826 | 835 | ||
827 | set_opt(sbi->s_mount_opt, RESERVATION); | 836 | set_opt(sbi->s_mount_opt, RESERVATION); |
828 | 837 | ||
829 | if (!parse_options ((char *) data, sbi)) | 838 | if (!parse_options((char *) data, sb)) |
830 | goto failed_mount; | 839 | goto failed_mount; |
831 | 840 | ||
832 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 841 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
@@ -840,8 +849,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
840 | (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || | 849 | (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || |
841 | EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || | 850 | EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || |
842 | EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U))) | 851 | EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U))) |
843 | printk("EXT2-fs warning: feature flags set on rev 0 fs, " | 852 | ext2_msg(sb, KERN_WARNING, |
844 | "running e2fsck is recommended\n"); | 853 | "warning: feature flags set on rev 0 fs, " |
854 | "running e2fsck is recommended"); | ||
845 | /* | 855 | /* |
846 | * Check feature flags regardless of the revision level, since we | 856 | * Check feature flags regardless of the revision level, since we |
847 | * previously didn't change the revision level when setting the flags, | 857 | * previously didn't change the revision level when setting the flags, |
@@ -849,16 +859,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
849 | */ | 859 | */ |
850 | features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP); | 860 | features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP); |
851 | if (features) { | 861 | if (features) { |
852 | printk("EXT2-fs: %s: couldn't mount because of " | 862 | ext2_msg(sb, KERN_ERR, "error: couldn't mount because of " |
853 | "unsupported optional features (%x).\n", | 863 | "unsupported optional features (%x)", |
854 | sb->s_id, le32_to_cpu(features)); | 864 | le32_to_cpu(features)); |
855 | goto failed_mount; | 865 | goto failed_mount; |
856 | } | 866 | } |
857 | if (!(sb->s_flags & MS_RDONLY) && | 867 | if (!(sb->s_flags & MS_RDONLY) && |
858 | (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){ | 868 | (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){ |
859 | printk("EXT2-fs: %s: couldn't mount RDWR because of " | 869 | ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of " |
860 | "unsupported optional features (%x).\n", | 870 | "unsupported optional features (%x)", |
861 | sb->s_id, le32_to_cpu(features)); | 871 | le32_to_cpu(features)); |
862 | goto failed_mount; | 872 | goto failed_mount; |
863 | } | 873 | } |
864 | 874 | ||
@@ -866,7 +876,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
866 | 876 | ||
867 | if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) { | 877 | if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) { |
868 | if (!silent) | 878 | if (!silent) |
869 | printk("XIP: Unsupported blocksize\n"); | 879 | ext2_msg(sb, KERN_ERR, |
880 | "error: unsupported blocksize for xip"); | ||
870 | goto failed_mount; | 881 | goto failed_mount; |
871 | } | 882 | } |
872 | 883 | ||
@@ -875,7 +886,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
875 | brelse(bh); | 886 | brelse(bh); |
876 | 887 | ||
877 | if (!sb_set_blocksize(sb, blocksize)) { | 888 | if (!sb_set_blocksize(sb, blocksize)) { |
878 | printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n"); | 889 | ext2_msg(sb, KERN_ERR, "error: blocksize is too small"); |
879 | goto failed_sbi; | 890 | goto failed_sbi; |
880 | } | 891 | } |
881 | 892 | ||
@@ -883,14 +894,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
883 | offset = (sb_block*BLOCK_SIZE) % blocksize; | 894 | offset = (sb_block*BLOCK_SIZE) % blocksize; |
884 | bh = sb_bread(sb, logic_sb_block); | 895 | bh = sb_bread(sb, logic_sb_block); |
885 | if(!bh) { | 896 | if(!bh) { |
886 | printk("EXT2-fs: Couldn't read superblock on " | 897 | ext2_msg(sb, KERN_ERR, "error: couldn't read" |
887 | "2nd try.\n"); | 898 | "superblock on 2nd try"); |
888 | goto failed_sbi; | 899 | goto failed_sbi; |
889 | } | 900 | } |
890 | es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); | 901 | es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); |
891 | sbi->s_es = es; | 902 | sbi->s_es = es; |
892 | if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { | 903 | if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { |
893 | printk ("EXT2-fs: Magic mismatch, very weird !\n"); | 904 | ext2_msg(sb, KERN_ERR, "error: magic mismatch"); |
894 | goto failed_mount; | 905 | goto failed_mount; |
895 | } | 906 | } |
896 | } | 907 | } |
@@ -906,7 +917,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
906 | if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || | 917 | if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || |
907 | !is_power_of_2(sbi->s_inode_size) || | 918 | !is_power_of_2(sbi->s_inode_size) || |
908 | (sbi->s_inode_size > blocksize)) { | 919 | (sbi->s_inode_size > blocksize)) { |
909 | printk ("EXT2-fs: unsupported inode size: %d\n", | 920 | ext2_msg(sb, KERN_ERR, |
921 | "error: unsupported inode size: %d", | ||
910 | sbi->s_inode_size); | 922 | sbi->s_inode_size); |
911 | goto failed_mount; | 923 | goto failed_mount; |
912 | } | 924 | } |
@@ -943,29 +955,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
943 | 955 | ||
944 | if (sb->s_blocksize != bh->b_size) { | 956 | if (sb->s_blocksize != bh->b_size) { |
945 | if (!silent) | 957 | if (!silent) |
946 | printk ("VFS: Unsupported blocksize on dev " | 958 | ext2_msg(sb, KERN_ERR, "error: unsupported blocksize"); |
947 | "%s.\n", sb->s_id); | ||
948 | goto failed_mount; | 959 | goto failed_mount; |
949 | } | 960 | } |
950 | 961 | ||
951 | if (sb->s_blocksize != sbi->s_frag_size) { | 962 | if (sb->s_blocksize != sbi->s_frag_size) { |
952 | printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n", | 963 | ext2_msg(sb, KERN_ERR, |
964 | "error: fragsize %lu != blocksize %lu" | ||
965 | "(not supported yet)", | ||
953 | sbi->s_frag_size, sb->s_blocksize); | 966 | sbi->s_frag_size, sb->s_blocksize); |
954 | goto failed_mount; | 967 | goto failed_mount; |
955 | } | 968 | } |
956 | 969 | ||
957 | if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { | 970 | if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { |
958 | printk ("EXT2-fs: #blocks per group too big: %lu\n", | 971 | ext2_msg(sb, KERN_ERR, |
972 | "error: #blocks per group too big: %lu", | ||
959 | sbi->s_blocks_per_group); | 973 | sbi->s_blocks_per_group); |
960 | goto failed_mount; | 974 | goto failed_mount; |
961 | } | 975 | } |
962 | if (sbi->s_frags_per_group > sb->s_blocksize * 8) { | 976 | if (sbi->s_frags_per_group > sb->s_blocksize * 8) { |
963 | printk ("EXT2-fs: #fragments per group too big: %lu\n", | 977 | ext2_msg(sb, KERN_ERR, |
978 | "error: #fragments per group too big: %lu", | ||
964 | sbi->s_frags_per_group); | 979 | sbi->s_frags_per_group); |
965 | goto failed_mount; | 980 | goto failed_mount; |
966 | } | 981 | } |
967 | if (sbi->s_inodes_per_group > sb->s_blocksize * 8) { | 982 | if (sbi->s_inodes_per_group > sb->s_blocksize * 8) { |
968 | printk ("EXT2-fs: #inodes per group too big: %lu\n", | 983 | ext2_msg(sb, KERN_ERR, |
984 | "error: #inodes per group too big: %lu", | ||
969 | sbi->s_inodes_per_group); | 985 | sbi->s_inodes_per_group); |
970 | goto failed_mount; | 986 | goto failed_mount; |
971 | } | 987 | } |
@@ -979,13 +995,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
979 | EXT2_DESC_PER_BLOCK(sb); | 995 | EXT2_DESC_PER_BLOCK(sb); |
980 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); | 996 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); |
981 | if (sbi->s_group_desc == NULL) { | 997 | if (sbi->s_group_desc == NULL) { |
982 | printk ("EXT2-fs: not enough memory\n"); | 998 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); |
983 | goto failed_mount; | 999 | goto failed_mount; |
984 | } | 1000 | } |
985 | bgl_lock_init(sbi->s_blockgroup_lock); | 1001 | bgl_lock_init(sbi->s_blockgroup_lock); |
986 | sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); | 1002 | sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); |
987 | if (!sbi->s_debts) { | 1003 | if (!sbi->s_debts) { |
988 | printk ("EXT2-fs: not enough memory\n"); | 1004 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); |
989 | goto failed_mount_group_desc; | 1005 | goto failed_mount_group_desc; |
990 | } | 1006 | } |
991 | for (i = 0; i < db_count; i++) { | 1007 | for (i = 0; i < db_count; i++) { |
@@ -994,12 +1010,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
994 | if (!sbi->s_group_desc[i]) { | 1010 | if (!sbi->s_group_desc[i]) { |
995 | for (j = 0; j < i; j++) | 1011 | for (j = 0; j < i; j++) |
996 | brelse (sbi->s_group_desc[j]); | 1012 | brelse (sbi->s_group_desc[j]); |
997 | printk ("EXT2-fs: unable to read group descriptors\n"); | 1013 | ext2_msg(sb, KERN_ERR, |
1014 | "error: unable to read group descriptors"); | ||
998 | goto failed_mount_group_desc; | 1015 | goto failed_mount_group_desc; |
999 | } | 1016 | } |
1000 | } | 1017 | } |
1001 | if (!ext2_check_descriptors (sb)) { | 1018 | if (!ext2_check_descriptors (sb)) { |
1002 | printk ("EXT2-fs: group descriptors corrupted!\n"); | 1019 | ext2_msg(sb, KERN_ERR, "group descriptors corrupted"); |
1003 | goto failed_mount2; | 1020 | goto failed_mount2; |
1004 | } | 1021 | } |
1005 | sbi->s_gdb_count = db_count; | 1022 | sbi->s_gdb_count = db_count; |
@@ -1032,7 +1049,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1032 | ext2_count_dirs(sb)); | 1049 | ext2_count_dirs(sb)); |
1033 | } | 1050 | } |
1034 | if (err) { | 1051 | if (err) { |
1035 | printk(KERN_ERR "EXT2-fs: insufficient memory\n"); | 1052 | ext2_msg(sb, KERN_ERR, "error: insufficient memory"); |
1036 | goto failed_mount3; | 1053 | goto failed_mount3; |
1037 | } | 1054 | } |
1038 | /* | 1055 | /* |
@@ -1048,27 +1065,28 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1048 | } | 1065 | } |
1049 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 1066 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
1050 | iput(root); | 1067 | iput(root); |
1051 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); | 1068 | ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); |
1052 | goto failed_mount3; | 1069 | goto failed_mount3; |
1053 | } | 1070 | } |
1054 | 1071 | ||
1055 | sb->s_root = d_alloc_root(root); | 1072 | sb->s_root = d_alloc_root(root); |
1056 | if (!sb->s_root) { | 1073 | if (!sb->s_root) { |
1057 | iput(root); | 1074 | iput(root); |
1058 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | 1075 | ext2_msg(sb, KERN_ERR, "error: get root inode failed"); |
1059 | ret = -ENOMEM; | 1076 | ret = -ENOMEM; |
1060 | goto failed_mount3; | 1077 | goto failed_mount3; |
1061 | } | 1078 | } |
1062 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | 1079 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) |
1063 | ext2_warning(sb, __func__, | 1080 | ext2_msg(sb, KERN_WARNING, |
1064 | "mounting ext3 filesystem as ext2"); | 1081 | "warning: mounting ext3 filesystem as ext2"); |
1065 | ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 1082 | ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
1066 | return 0; | 1083 | return 0; |
1067 | 1084 | ||
1068 | cantfind_ext2: | 1085 | cantfind_ext2: |
1069 | if (!silent) | 1086 | if (!silent) |
1070 | printk("VFS: Can't find an ext2 filesystem on dev %s.\n", | 1087 | ext2_msg(sb, KERN_ERR, |
1071 | sb->s_id); | 1088 | "error: can't find an ext2 filesystem on dev %s.", |
1089 | sb->s_id); | ||
1072 | goto failed_mount; | 1090 | goto failed_mount; |
1073 | failed_mount3: | 1091 | failed_mount3: |
1074 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 1092 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
@@ -1089,9 +1107,30 @@ failed_sbi: | |||
1089 | return ret; | 1107 | return ret; |
1090 | } | 1108 | } |
1091 | 1109 | ||
1110 | static void ext2_clear_super_error(struct super_block *sb) | ||
1111 | { | ||
1112 | struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; | ||
1113 | |||
1114 | if (buffer_write_io_error(sbh)) { | ||
1115 | /* | ||
1116 | * Oh, dear. A previous attempt to write the | ||
1117 | * superblock failed. This could happen because the | ||
1118 | * USB device was yanked out. Or it could happen to | ||
1119 | * be a transient write error and maybe the block will | ||
1120 | * be remapped. Nothing we can do but to retry the | ||
1121 | * write and hope for the best. | ||
1122 | */ | ||
1123 | printk(KERN_ERR "EXT2-fs: %s previous I/O error to " | ||
1124 | "superblock detected", sb->s_id); | ||
1125 | clear_buffer_write_io_error(sbh); | ||
1126 | set_buffer_uptodate(sbh); | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1092 | static void ext2_commit_super (struct super_block * sb, | 1130 | static void ext2_commit_super (struct super_block * sb, |
1093 | struct ext2_super_block * es) | 1131 | struct ext2_super_block * es) |
1094 | { | 1132 | { |
1133 | ext2_clear_super_error(sb); | ||
1095 | es->s_wtime = cpu_to_le32(get_seconds()); | 1134 | es->s_wtime = cpu_to_le32(get_seconds()); |
1096 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); | 1135 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); |
1097 | sb->s_dirt = 0; | 1136 | sb->s_dirt = 0; |
@@ -1099,6 +1138,7 @@ static void ext2_commit_super (struct super_block * sb, | |||
1099 | 1138 | ||
1100 | static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) | 1139 | static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) |
1101 | { | 1140 | { |
1141 | ext2_clear_super_error(sb); | ||
1102 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); | 1142 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); |
1103 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); | 1143 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); |
1104 | es->s_wtime = cpu_to_le32(get_seconds()); | 1144 | es->s_wtime = cpu_to_le32(get_seconds()); |
@@ -1121,8 +1161,24 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) | |||
1121 | static int ext2_sync_fs(struct super_block *sb, int wait) | 1161 | static int ext2_sync_fs(struct super_block *sb, int wait) |
1122 | { | 1162 | { |
1123 | struct ext2_super_block *es = EXT2_SB(sb)->s_es; | 1163 | struct ext2_super_block *es = EXT2_SB(sb)->s_es; |
1164 | struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; | ||
1124 | 1165 | ||
1125 | lock_kernel(); | 1166 | lock_kernel(); |
1167 | if (buffer_write_io_error(sbh)) { | ||
1168 | /* | ||
1169 | * Oh, dear. A previous attempt to write the | ||
1170 | * superblock failed. This could happen because the | ||
1171 | * USB device was yanked out. Or it could happen to | ||
1172 | * be a transient write error and maybe the block will | ||
1173 | * be remapped. Nothing we can do but to retry the | ||
1174 | * write and hope for the best. | ||
1175 | */ | ||
1176 | ext2_msg(sb, KERN_ERR, | ||
1177 | "previous I/O error to superblock detected\n"); | ||
1178 | clear_buffer_write_io_error(sbh); | ||
1179 | set_buffer_uptodate(sbh); | ||
1180 | } | ||
1181 | |||
1126 | if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { | 1182 | if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { |
1127 | ext2_debug("setting valid to 0\n"); | 1183 | ext2_debug("setting valid to 0\n"); |
1128 | es->s_state &= cpu_to_le16(~EXT2_VALID_FS); | 1184 | es->s_state &= cpu_to_le16(~EXT2_VALID_FS); |
@@ -1170,7 +1226,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
1170 | /* | 1226 | /* |
1171 | * Allow the "check" option to be passed as a remount option. | 1227 | * Allow the "check" option to be passed as a remount option. |
1172 | */ | 1228 | */ |
1173 | if (!parse_options (data, sbi)) { | 1229 | if (!parse_options(data, sb)) { |
1174 | err = -EINVAL; | 1230 | err = -EINVAL; |
1175 | goto restore_opts; | 1231 | goto restore_opts; |
1176 | } | 1232 | } |
@@ -1182,7 +1238,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
1182 | EXT2_MOUNT_XIP if not */ | 1238 | EXT2_MOUNT_XIP if not */ |
1183 | 1239 | ||
1184 | if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) { | 1240 | if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) { |
1185 | printk("XIP: Unsupported blocksize\n"); | 1241 | ext2_msg(sb, KERN_WARNING, |
1242 | "warning: unsupported blocksize for xip"); | ||
1186 | err = -EINVAL; | 1243 | err = -EINVAL; |
1187 | goto restore_opts; | 1244 | goto restore_opts; |
1188 | } | 1245 | } |
@@ -1191,8 +1248,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
1191 | if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != | 1248 | if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != |
1192 | (old_mount_opt & EXT2_MOUNT_XIP)) && | 1249 | (old_mount_opt & EXT2_MOUNT_XIP)) && |
1193 | invalidate_inodes(sb)) { | 1250 | invalidate_inodes(sb)) { |
1194 | ext2_warning(sb, __func__, "refusing change of xip flag " | 1251 | ext2_msg(sb, KERN_WARNING, "warning: refusing change of " |
1195 | "with busy inodes while remounting"); | 1252 | "xip flag with busy inodes while remounting"); |
1196 | sbi->s_mount_opt &= ~EXT2_MOUNT_XIP; | 1253 | sbi->s_mount_opt &= ~EXT2_MOUNT_XIP; |
1197 | sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP; | 1254 | sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP; |
1198 | } | 1255 | } |
@@ -1216,9 +1273,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
1216 | __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, | 1273 | __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, |
1217 | ~EXT2_FEATURE_RO_COMPAT_SUPP); | 1274 | ~EXT2_FEATURE_RO_COMPAT_SUPP); |
1218 | if (ret) { | 1275 | if (ret) { |
1219 | printk("EXT2-fs: %s: couldn't remount RDWR because of " | 1276 | ext2_msg(sb, KERN_WARNING, |
1220 | "unsupported optional features (%x).\n", | 1277 | "warning: couldn't remount RDWR because of " |
1221 | sb->s_id, le32_to_cpu(ret)); | 1278 | "unsupported optional features (%x).", |
1279 | le32_to_cpu(ret)); | ||
1222 | err = -EROFS; | 1280 | err = -EROFS; |
1223 | goto restore_opts; | 1281 | goto restore_opts; |
1224 | } | 1282 | } |