Patch to make ext2 mounts go faster....

From: tytso@mit.edu
Date: Mon Mar 20 2000 - 03:37:33 EST


Hi Linus,

        The following patches makes ext2 mounts go faster by removing
the pointless counting of all of the free blocks and inodes in the
bitmaps to make sure the match up with the block group descriptors. The
checks take a huge amount of time, and are completely duplicated by the
checks done by fsck. Furthermore, the things which they check (the free
blocks/inodes counts), if wrong, won't critically impact ext2
performance. Hence, by removing this check, we speed up the mounting of
ext2 filesystems significantly. I've been recommending that people
mount filesystems "-o check=none" for a while. This simply makes this
the default.

        The only reason why I've left the code in under an
#ifdef, instead of removing it completely, is because Stephen wants to
use it as a very quick sanity checking for ext3 journaling. It's useful
there as a warning that nothing bad happened when recovering the
journal. But for normal ext2 operations, it's simply not necessary.

        The following patches are versus 2.3.99-pre2. Could you apply
them into your sources? Thanks!!

                                                - Ted

Patch generated: on Sun Mar 19 21:40:28 EST 2000 by tytso@trampoline.thunk.org
against Linux version 2.3.99-pre2
 
===================================================================
RCS file: fs/ext2/RCS/super.c,v
retrieving revision 1.1
diff -u -r1.1 fs/ext2/super.c
--- fs/ext2/super.c 2000/03/19 03:09:31 1.1
+++ fs/ext2/super.c 2000/03/19 03:10:09
@@ -153,23 +153,14 @@
                         set_opt (*mount_options, NO_UID32);
                 }
                 else if (!strcmp (this_char, "check")) {
- if (!value || !*value)
- set_opt (*mount_options, CHECK_NORMAL);
- else if (!strcmp (value, "none")) {
- clear_opt (*mount_options, CHECK_NORMAL);
- clear_opt (*mount_options, CHECK_STRICT);
- }
- else if (!strcmp (value, "normal"))
- set_opt (*mount_options, CHECK_NORMAL);
- else if (!strcmp (value, "strict")) {
- set_opt (*mount_options, CHECK_NORMAL);
- set_opt (*mount_options, CHECK_STRICT);
- }
- else {
- printk ("EXT2-fs: Invalid check option: %s\n",
- value);
- return 0;
- }
+ if (!value || !*value || !strcmp (value, "none"))
+ clear_opt (*mount_options, CHECK);
+ else
+#ifdef CONFIG_EXT2_CHECK
+ set_opt (*mount_options, CHECK);
+#else
+ printk("EXT2 Check option not supported\n");
+#endif
                 }
                 else if (!strcmp (this_char, "debug"))
                         set_opt (*mount_options, DEBUG);
@@ -205,10 +196,6 @@
                         set_opt (*mount_options, GRPID);
                 else if (!strcmp (this_char, "minixdf"))
                         set_opt (*mount_options, MINIX_DF);
- else if (!strcmp (this_char, "nocheck")) {
- clear_opt (*mount_options, CHECK_NORMAL);
- clear_opt (*mount_options, CHECK_STRICT);
- }
                 else if (!strcmp (this_char, "nogrpid") ||
                          !strcmp (this_char, "sysvgroups"))
                         clear_opt (*mount_options, GRPID);
@@ -305,10 +292,12 @@
                                 EXT2_BLOCKS_PER_GROUP(sb),
                                 EXT2_INODES_PER_GROUP(sb),
                                 sb->u.ext2_sb.s_mount_opt);
+#ifdef CONFIG_EXT2_CHECK
                 if (test_opt (sb, CHECK)) {
                         ext2_check_blocks_bitmap (sb);
                         ext2_check_inodes_bitmap (sb);
                 }
+#endif
         }
 #if 0 /* ibasket's still have unresolved bugs... -DaveM */
 
@@ -398,7 +387,6 @@
           }
 
         sb->u.ext2_sb.s_mount_opt = 0;
- set_opt (sb->u.ext2_sb.s_mount_opt, CHECK_NORMAL);
         if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
             &sb->u.ext2_sb.s_mount_opt)) {
                 return NULL;
@@ -674,7 +662,6 @@
         /*
          * Allow the "check" option to be passed as a remount option.
          */
- new_mount_opt = EXT2_MOUNT_CHECK_NORMAL;
         if (!parse_options (data, &tmp, &resuid, &resgid,
                             &new_mount_opt))
                 return -EINVAL;
===================================================================
RCS file: fs/ext2/RCS/balloc.c,v
retrieving revision 1.1
diff -u -r1.1 fs/ext2/balloc.c
--- fs/ext2/balloc.c 2000/03/19 03:09:31 1.1
+++ fs/ext2/balloc.c 2000/03/19 03:10:09
@@ -300,21 +300,20 @@
         if (!gdp)
                 goto error_return;
 
- if (test_opt (sb, CHECK_STRICT) &&
- (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) ||
- in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) ||
- in_range (block, le32_to_cpu(gdp->bg_inode_table),
- sb->u.ext2_sb.s_itb_per_group) ||
- in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table),
- sb->u.ext2_sb.s_itb_per_group)))
- ext2_panic (sb, "ext2_free_blocks",
+ if (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) ||
+ in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) ||
+ in_range (block, le32_to_cpu(gdp->bg_inode_table),
+ sb->u.ext2_sb.s_itb_per_group) ||
+ in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table),
+ sb->u.ext2_sb.s_itb_per_group))
+ ext2_error (sb, "ext2_free_blocks",
                             "Freeing blocks in system zones - "
                             "Block = %lu, count = %lu",
                             block, count);
 
         for (i = 0; i < count; i++) {
                 if (!ext2_clear_bit (bit + i, bh->b_data))
- ext2_warning (sb, "ext2_free_blocks",
+ ext2_error (sb, "ext2_free_blocks",
                                       "bit already cleared for block %lu",
                                       block);
                 else {
@@ -527,11 +526,11 @@
 
         tmp = j + i * EXT2_BLOCKS_PER_GROUP(sb) + le32_to_cpu(es->s_first_data_block);
 
- if (test_opt (sb, CHECK_STRICT) &&
- (tmp == le32_to_cpu(gdp->bg_block_bitmap) ||
- tmp == le32_to_cpu(gdp->bg_inode_bitmap) ||
- in_range (tmp, le32_to_cpu(gdp->bg_inode_table), sb->u.ext2_sb.s_itb_per_group)))
- ext2_panic (sb, "ext2_new_block",
+ if (tmp == le32_to_cpu(gdp->bg_block_bitmap) ||
+ tmp == le32_to_cpu(gdp->bg_inode_bitmap) ||
+ in_range (tmp, le32_to_cpu(gdp->bg_inode_table),
+ sb->u.ext2_sb.s_itb_per_group))
+ ext2_error (sb, "ext2_new_block",
                             "Allocating block in system zone - "
                             "block = %u", tmp);
 
@@ -679,6 +678,7 @@
                 test_root(group, 7));
 }
 
+#ifdef CONFIG_EXT2_CHECK
 /* Called at mount-time, super-block is locked */
 void ext2_check_blocks_bitmap (struct super_block * sb)
 {
@@ -753,3 +753,4 @@
                             "stored = %lu, counted = %lu",
                             (unsigned long) le32_to_cpu(es->s_free_blocks_count), bitmap_count);
 }
+#endif
===================================================================
RCS file: fs/ext2/RCS/ialloc.c,v
retrieving revision 1.1
diff -u -r1.1 fs/ext2/ialloc.c
--- fs/ext2/ialloc.c 2000/03/19 03:09:31 1.1
+++ fs/ext2/ialloc.c 2000/03/19 03:10:09
@@ -236,7 +236,7 @@
 
         /* Ok, now we can actually update the inode bitmaps.. */
         if (!ext2_clear_bit (bit, bh->b_data))
- ext2_warning (sb, "ext2_free_inode",
+ ext2_error (sb, "ext2_free_inode",
                               "bit already cleared for inode %lu", ino);
         else {
                 gdp = ext2_get_group_desc (sb, block_group, &bh2);
@@ -401,7 +401,7 @@
                                       EXT2_INODES_PER_GROUP(sb))) <
             EXT2_INODES_PER_GROUP(sb)) {
                 if (ext2_set_bit (j, bh->b_data)) {
- ext2_warning (sb, "ext2_new_inode",
+ ext2_error (sb, "ext2_new_inode",
                                       "bit already set for inode %d", j);
                         goto repeat;
                 }
@@ -527,6 +527,7 @@
 #endif
 }
 
+#ifdef CONFIG_EXT2_CHECK
 /* Called at mount-time, super-block is locked */
 void ext2_check_inodes_bitmap (struct super_block * sb)
 {
@@ -565,3 +566,4 @@
                             (unsigned long) le32_to_cpu(es->s_free_inodes_count),
                             bitmap_count);
 }
+#endif
===================================================================
RCS file: include/linux/RCS/ext2_fs.h,v
retrieving revision 1.1
diff -u -r1.1 include/linux/ext2_fs.h
--- include/linux/ext2_fs.h 2000/03/19 03:09:31 1.1
+++ include/linux/ext2_fs.h 2000/03/19 03:30:37
@@ -306,10 +306,7 @@
 /*
  * Mount flags
  */
-#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */
-#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */
-#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \
- EXT2_MOUNT_CHECK_STRICT)
+#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
 #define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
 #define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
 #define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:28 EST