aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/ext2.txt2
-rw-r--r--fs/ext2/balloc.c73
-rw-r--r--fs/ext2/ialloc.c40
-rw-r--r--fs/ext2/super.c16
-rw-r--r--fs/ext3/balloc.c73
-rw-r--r--fs/ext3/ialloc.c41
-rw-r--r--fs/ext3/super.c17
7 files changed, 2 insertions, 260 deletions
diff --git a/Documentation/filesystems/ext2.txt b/Documentation/filesystems/ext2.txt
index d16334ec48ba..a8edb376b041 100644
--- a/Documentation/filesystems/ext2.txt
+++ b/Documentation/filesystems/ext2.txt
@@ -17,8 +17,6 @@ set using tune2fs(8). Kernel-determined defaults are indicated by (*).
17bsddf (*) Makes `df' act like BSD. 17bsddf (*) Makes `df' act like BSD.
18minixdf Makes `df' act like Minix. 18minixdf Makes `df' act like Minix.
19 19
20check Check block and inode bitmaps at mount time
21 (requires CONFIG_EXT2_CHECK).
22check=none, nocheck (*) Don't do extra checking of bitmaps on mount 20check=none, nocheck (*) Don't do extra checking of bitmaps on mount
23 (check=normal and check=strict options removed) 21 (check=normal and check=strict options removed)
24 22
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 6591abef64d0..bb6908066494 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -624,76 +624,3 @@ unsigned long ext2_bg_num_gdb(struct super_block *sb, int group)
624 return EXT2_SB(sb)->s_gdb_count; 624 return EXT2_SB(sb)->s_gdb_count;
625} 625}
626 626
627#ifdef CONFIG_EXT2_CHECK
628/* Called at mount-time, super-block is locked */
629void ext2_check_blocks_bitmap (struct super_block * sb)
630{
631 struct buffer_head *bitmap_bh = NULL;
632 struct ext2_super_block * es;
633 unsigned long desc_count, bitmap_count, x, j;
634 unsigned long desc_blocks;
635 struct ext2_group_desc * desc;
636 int i;
637
638 es = EXT2_SB(sb)->s_es;
639 desc_count = 0;
640 bitmap_count = 0;
641 desc = NULL;
642 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
643 desc = ext2_get_group_desc (sb, i, NULL);
644 if (!desc)
645 continue;
646 desc_count += le16_to_cpu(desc->bg_free_blocks_count);
647 brelse(bitmap_bh);
648 bitmap_bh = read_block_bitmap(sb, i);
649 if (!bitmap_bh)
650 continue;
651
652 if (ext2_bg_has_super(sb, i) &&
653 !ext2_test_bit(0, bitmap_bh->b_data))
654 ext2_error(sb, __FUNCTION__,
655 "Superblock in group %d is marked free", i);
656
657 desc_blocks = ext2_bg_num_gdb(sb, i);
658 for (j = 0; j < desc_blocks; j++)
659 if (!ext2_test_bit(j + 1, bitmap_bh->b_data))
660 ext2_error(sb, __FUNCTION__,
661 "Descriptor block #%ld in group "
662 "%d is marked free", j, i);
663
664 if (!block_in_use(le32_to_cpu(desc->bg_block_bitmap),
665 sb, bitmap_bh->b_data))
666 ext2_error(sb, "ext2_check_blocks_bitmap",
667 "Block bitmap for group %d is marked free",
668 i);
669
670 if (!block_in_use(le32_to_cpu(desc->bg_inode_bitmap),
671 sb, bitmap_bh->b_data))
672 ext2_error(sb, "ext2_check_blocks_bitmap",
673 "Inode bitmap for group %d is marked free",
674 i);
675
676 for (j = 0; j < EXT2_SB(sb)->s_itb_per_group; j++)
677 if (!block_in_use(le32_to_cpu(desc->bg_inode_table) + j,
678 sb, bitmap_bh->b_data))
679 ext2_error (sb, "ext2_check_blocks_bitmap",
680 "Block #%ld of the inode table in "
681 "group %d is marked free", j, i);
682
683 x = ext2_count_free(bitmap_bh, sb->s_blocksize);
684 if (le16_to_cpu(desc->bg_free_blocks_count) != x)
685 ext2_error (sb, "ext2_check_blocks_bitmap",
686 "Wrong free blocks count for group %d, "
687 "stored = %d, counted = %lu", i,
688 le16_to_cpu(desc->bg_free_blocks_count), x);
689 bitmap_count += x;
690 }
691 if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count)
692 ext2_error (sb, "ext2_check_blocks_bitmap",
693 "Wrong free blocks count in super block, "
694 "stored = %lu, counted = %lu",
695 (unsigned long)le32_to_cpu(es->s_free_blocks_count),
696 bitmap_count);
697 brelse(bitmap_bh);
698}
699#endif
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index e2d6208633a7..74714af4ae69 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -700,43 +700,3 @@ unsigned long ext2_count_dirs (struct super_block * sb)
700 return count; 700 return count;
701} 701}
702 702
703#ifdef CONFIG_EXT2_CHECK
704/* Called at mount-time, super-block is locked */
705void ext2_check_inodes_bitmap (struct super_block * sb)
706{
707 struct ext2_super_block * es = EXT2_SB(sb)->s_es;
708 unsigned long desc_count = 0, bitmap_count = 0;
709 struct buffer_head *bitmap_bh = NULL;
710 int i;
711
712 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
713 struct ext2_group_desc *desc;
714 unsigned x;
715
716 desc = ext2_get_group_desc(sb, i, NULL);
717 if (!desc)
718 continue;
719 desc_count += le16_to_cpu(desc->bg_free_inodes_count);
720 brelse(bitmap_bh);
721 bitmap_bh = read_inode_bitmap(sb, i);
722 if (!bitmap_bh)
723 continue;
724
725 x = ext2_count_free(bitmap_bh, EXT2_INODES_PER_GROUP(sb) / 8);
726 if (le16_to_cpu(desc->bg_free_inodes_count) != x)
727 ext2_error (sb, "ext2_check_inodes_bitmap",
728 "Wrong free inodes count in group %d, "
729 "stored = %d, counted = %lu", i,
730 le16_to_cpu(desc->bg_free_inodes_count), x);
731 bitmap_count += x;
732 }
733 brelse(bitmap_bh);
734 if (percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter) !=
735 bitmap_count)
736 ext2_error(sb, "ext2_check_inodes_bitmap",
737 "Wrong free inodes count in super block, "
738 "stored = %lu, counted = %lu",
739 (unsigned long)le32_to_cpu(es->s_free_inodes_count),
740 bitmap_count);
741}
742#endif
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 3c0c7c6a5b44..e4ed4b31a433 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -281,7 +281,7 @@ static unsigned long get_sb_block(void **data)
281enum { 281enum {
282 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, 282 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
283 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, 283 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic,
284 Opt_err_ro, Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, 284 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
285 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, 285 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
286 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota, 286 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
287 Opt_usrquota, Opt_grpquota 287 Opt_usrquota, Opt_grpquota
@@ -303,7 +303,6 @@ static match_table_t tokens = {
303 {Opt_nouid32, "nouid32"}, 303 {Opt_nouid32, "nouid32"},
304 {Opt_nocheck, "check=none"}, 304 {Opt_nocheck, "check=none"},
305 {Opt_nocheck, "nocheck"}, 305 {Opt_nocheck, "nocheck"},
306 {Opt_check, "check"},
307 {Opt_debug, "debug"}, 306 {Opt_debug, "debug"},
308 {Opt_oldalloc, "oldalloc"}, 307 {Opt_oldalloc, "oldalloc"},
309 {Opt_orlov, "orlov"}, 308 {Opt_orlov, "orlov"},
@@ -376,13 +375,6 @@ static int parse_options (char * options,
376 case Opt_nouid32: 375 case Opt_nouid32:
377 set_opt (sbi->s_mount_opt, NO_UID32); 376 set_opt (sbi->s_mount_opt, NO_UID32);
378 break; 377 break;
379 case Opt_check:
380#ifdef CONFIG_EXT2_CHECK
381 set_opt (sbi->s_mount_opt, CHECK);
382#else
383 printk("EXT2 Check option not supported\n");
384#endif
385 break;
386 case Opt_nocheck: 378 case Opt_nocheck:
387 clear_opt (sbi->s_mount_opt, CHECK); 379 clear_opt (sbi->s_mount_opt, CHECK);
388 break; 380 break;
@@ -503,12 +495,6 @@ static int ext2_setup_super (struct super_block * sb,
503 EXT2_BLOCKS_PER_GROUP(sb), 495 EXT2_BLOCKS_PER_GROUP(sb),
504 EXT2_INODES_PER_GROUP(sb), 496 EXT2_INODES_PER_GROUP(sb),
505 sbi->s_mount_opt); 497 sbi->s_mount_opt);
506#ifdef CONFIG_EXT2_CHECK
507 if (test_opt (sb, CHECK)) {
508 ext2_check_blocks_bitmap (sb);
509 ext2_check_inodes_bitmap (sb);
510 }
511#endif
512 return res; 498 return res;
513} 499}
514 500
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 7992d21e0e09..ae1148c24c53 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1517,76 +1517,3 @@ unsigned long ext3_bg_num_gdb(struct super_block *sb, int group)
1517 return EXT3_SB(sb)->s_gdb_count; 1517 return EXT3_SB(sb)->s_gdb_count;
1518} 1518}
1519 1519
1520#ifdef CONFIG_EXT3_CHECK
1521/* Called at mount-time, super-block is locked */
1522void ext3_check_blocks_bitmap (struct super_block * sb)
1523{
1524 struct ext3_super_block *es;
1525 unsigned long desc_count, bitmap_count, x, j;
1526 unsigned long desc_blocks;
1527 struct buffer_head *bitmap_bh = NULL;
1528 struct ext3_group_desc *gdp;
1529 int i;
1530
1531 es = EXT3_SB(sb)->s_es;
1532 desc_count = 0;
1533 bitmap_count = 0;
1534 gdp = NULL;
1535 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
1536 gdp = ext3_get_group_desc (sb, i, NULL);
1537 if (!gdp)
1538 continue;
1539 desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
1540 brelse(bitmap_bh);
1541 bitmap_bh = read_block_bitmap(sb, i);
1542 if (bitmap_bh == NULL)
1543 continue;
1544
1545 if (ext3_bg_has_super(sb, i) &&
1546 !ext3_test_bit(0, bitmap_bh->b_data))
1547 ext3_error(sb, __FUNCTION__,
1548 "Superblock in group %d is marked free", i);
1549
1550 desc_blocks = ext3_bg_num_gdb(sb, i);
1551 for (j = 0; j < desc_blocks; j++)
1552 if (!ext3_test_bit(j + 1, bitmap_bh->b_data))
1553 ext3_error(sb, __FUNCTION__,
1554 "Descriptor block #%ld in group "
1555 "%d is marked free", j, i);
1556
1557 if (!block_in_use (le32_to_cpu(gdp->bg_block_bitmap),
1558 sb, bitmap_bh->b_data))
1559 ext3_error (sb, "ext3_check_blocks_bitmap",
1560 "Block bitmap for group %d is marked free",
1561 i);
1562
1563 if (!block_in_use (le32_to_cpu(gdp->bg_inode_bitmap),
1564 sb, bitmap_bh->b_data))
1565 ext3_error (sb, "ext3_check_blocks_bitmap",
1566 "Inode bitmap for group %d is marked free",
1567 i);
1568
1569 for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++)
1570 if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j,
1571 sb, bitmap_bh->b_data))
1572 ext3_error (sb, "ext3_check_blocks_bitmap",
1573 "Block #%d of the inode table in "
1574 "group %d is marked free", j, i);
1575
1576 x = ext3_count_free(bitmap_bh, sb->s_blocksize);
1577 if (le16_to_cpu(gdp->bg_free_blocks_count) != x)
1578 ext3_error (sb, "ext3_check_blocks_bitmap",
1579 "Wrong free blocks count for group %d, "
1580 "stored = %d, counted = %lu", i,
1581 le16_to_cpu(gdp->bg_free_blocks_count), x);
1582 bitmap_count += x;
1583 }
1584 brelse(bitmap_bh);
1585 if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count)
1586 ext3_error (sb, "ext3_check_blocks_bitmap",
1587 "Wrong free blocks count in super block, "
1588 "stored = %lu, counted = %lu",
1589 (unsigned long)le32_to_cpu(es->s_free_blocks_count),
1590 bitmap_count);
1591}
1592#endif
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index df3f517c54ac..9e4a24376210 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -756,44 +756,3 @@ unsigned long ext3_count_dirs (struct super_block * sb)
756 return count; 756 return count;
757} 757}
758 758
759#ifdef CONFIG_EXT3_CHECK
760/* Called at mount-time, super-block is locked */
761void ext3_check_inodes_bitmap (struct super_block * sb)
762{
763 struct ext3_super_block * es;
764 unsigned long desc_count, bitmap_count, x;
765 struct buffer_head *bitmap_bh = NULL;
766 struct ext3_group_desc * gdp;
767 int i;
768
769 es = EXT3_SB(sb)->s_es;
770 desc_count = 0;
771 bitmap_count = 0;
772 gdp = NULL;
773 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
774 gdp = ext3_get_group_desc (sb, i, NULL);
775 if (!gdp)
776 continue;
777 desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
778 brelse(bitmap_bh);
779 bitmap_bh = read_inode_bitmap(sb, i);
780 if (!bitmap_bh)
781 continue;
782
783 x = ext3_count_free(bitmap_bh, EXT3_INODES_PER_GROUP(sb) / 8);
784 if (le16_to_cpu(gdp->bg_free_inodes_count) != x)
785 ext3_error (sb, "ext3_check_inodes_bitmap",
786 "Wrong free inodes count in group %d, "
787 "stored = %d, counted = %lu", i,
788 le16_to_cpu(gdp->bg_free_inodes_count), x);
789 bitmap_count += x;
790 }
791 brelse(bitmap_bh);
792 if (le32_to_cpu(es->s_free_inodes_count) != bitmap_count)
793 ext3_error (sb, "ext3_check_inodes_bitmap",
794 "Wrong free inodes count in super block, "
795 "stored = %lu, counted = %lu",
796 (unsigned long)le32_to_cpu(es->s_free_inodes_count),
797 bitmap_count);
798}
799#endif
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index f594989ccb7a..4e6730622d90 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -625,7 +625,7 @@ static struct export_operations ext3_export_ops = {
625enum { 625enum {
626 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, 626 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
627 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, 627 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
628 Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, 628 Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,
629 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, 629 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
630 Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, 630 Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh,
631 Opt_commit, Opt_journal_update, Opt_journal_inum, 631 Opt_commit, Opt_journal_update, Opt_journal_inum,
@@ -652,7 +652,6 @@ static match_table_t tokens = {
652 {Opt_nouid32, "nouid32"}, 652 {Opt_nouid32, "nouid32"},
653 {Opt_nocheck, "nocheck"}, 653 {Opt_nocheck, "nocheck"},
654 {Opt_nocheck, "check=none"}, 654 {Opt_nocheck, "check=none"},
655 {Opt_check, "check"},
656 {Opt_debug, "debug"}, 655 {Opt_debug, "debug"},
657 {Opt_oldalloc, "oldalloc"}, 656 {Opt_oldalloc, "oldalloc"},
658 {Opt_orlov, "orlov"}, 657 {Opt_orlov, "orlov"},
@@ -773,14 +772,6 @@ static int parse_options (char * options, struct super_block *sb,
773 case Opt_nouid32: 772 case Opt_nouid32:
774 set_opt (sbi->s_mount_opt, NO_UID32); 773 set_opt (sbi->s_mount_opt, NO_UID32);
775 break; 774 break;
776 case Opt_check:
777#ifdef CONFIG_EXT3_CHECK
778 set_opt (sbi->s_mount_opt, CHECK);
779#else
780 printk(KERN_ERR
781 "EXT3 Check option not supported\n");
782#endif
783 break;
784 case Opt_nocheck: 775 case Opt_nocheck:
785 clear_opt (sbi->s_mount_opt, CHECK); 776 clear_opt (sbi->s_mount_opt, CHECK);
786 break; 777 break;
@@ -1115,12 +1106,6 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1115 } else { 1106 } else {
1116 printk("internal journal\n"); 1107 printk("internal journal\n");
1117 } 1108 }
1118#ifdef CONFIG_EXT3_CHECK
1119 if (test_opt (sb, CHECK)) {
1120 ext3_check_blocks_bitmap (sb);
1121 ext3_check_inodes_bitmap (sb);
1122 }
1123#endif
1124 return res; 1109 return res;
1125} 1110}
1126 1111