Whamcloud - gitweb
LU-6722 jbd: double minimum journal size for RHEL7 v1.42.13.wc3
authorFan Yong <fan.yong@intel.com>
Fri, 26 Jun 2015 15:29:59 +0000 (23:29 +0800)
committerAndreas Dilger <adilger@dilger.ca>
Fri, 28 Aug 2015 17:09:01 +0000 (11:09 -0600)
In RHEL7 (kernel version >= 3.10.0), the maximum journal transaction
size is reduced to half of the RHEL6 case. That may cause Lustre to
complain that the declared transaction credits too large for very
small journal device. This patch increases the minimum journal size
from 4MB to 8MB for RHEL7 case, then counteract the above limitation
about the journal transaction size.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Iec8a2c561416cb7b5acce342c8ebcb845c8d7a19
Reviewed-on: http://review.whamcloud.com/15401
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lib/ext2fs/ext2fsP.h
lib/ext2fs/mkjournal.c
misc/mke2fs.c
misc/util.c
tests/run_e2fsck
tests/test_config

index a88db93..51fe930 100644 (file)
@@ -145,3 +145,6 @@ extern int ext2fs_mem_is_zero(const char *mem, size_t len);
 extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
                                            struct ext2_inode *inode,
                                            blk64_t offset);
+
+extern int ext2fs_is_before_linux_ver(unsigned int major, unsigned int minor,
+                                     unsigned int rev);
index e6d04c4..76ef910 100644 (file)
 #if HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
+#ifdef __linux__
+#include <sys/utsname.h>
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
 
 #include "ext2_fs.h"
 #include "e2p/e2p.h"
@@ -405,6 +409,54 @@ out2:
        return retval;
 }
 
+#ifdef __linux__
+static int parse_version_number(const char *s)
+{
+       int     major, minor, rev;
+       char    *endptr;
+       const char *cp = s;
+
+       if (!s)
+               return 0;
+       major = strtol(cp, &endptr, 10);
+       if (cp == endptr || *endptr != '.')
+               return 0;
+       cp = endptr + 1;
+       minor = strtol(cp, &endptr, 10);
+       if (cp == endptr || *endptr != '.')
+               return 0;
+       cp = endptr + 1;
+       rev = strtol(cp, &endptr, 10);
+       if (cp == endptr)
+               return 0;
+       return KERNEL_VERSION(major, minor, rev);
+}
+
+int ext2fs_is_before_linux_ver(unsigned int major, unsigned int minor,
+                              unsigned int rev)
+{
+       struct          utsname ut;
+       static int      linux_version_code = -1;
+
+       if (uname(&ut)) {
+               perror("uname");
+               exit(1);
+       }
+       if (linux_version_code < 0)
+               linux_version_code = parse_version_number(ut.release);
+       if (linux_version_code == 0)
+               return 0;
+
+       return linux_version_code < KERNEL_VERSION(major, minor, rev);
+}
+#else
+int ext2fs_is_before_linux_ver(unsigned int major, unsigned int minor,
+                              unsigned int rev)
+{
+       return 0;
+}
+#endif
+
 /*
  * Find a reasonable journal file size (in blocks) given the number of blocks
  * in the filesystem.  For very small filesystems, it is not reasonable to
@@ -414,8 +466,10 @@ int ext2fs_default_journal_size(__u64 num_blocks)
 {
        if (num_blocks < 2048)
                return -1;
-       if (num_blocks < 32768)
+       if (num_blocks <= 8192)
                return (1024);
+       if (num_blocks < 32768)
+               return (2048);
        if (num_blocks < 256*1024)
                return (4096);
        if (num_blocks < 512*1024)
index c0bf012..273273e 100644 (file)
 #include <fcntl.h>
 #include <ctype.h>
 #include <time.h>
-#ifdef __linux__
-#include <sys/utsname.h>
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #else
@@ -155,54 +151,6 @@ int int_log10(unsigned long long arg)
        return l;
 }
 
-#ifdef __linux__
-static int parse_version_number(const char *s)
-{
-       int     major, minor, rev;
-       char    *endptr;
-       const char *cp = s;
-
-       if (!s)
-               return 0;
-       major = strtol(cp, &endptr, 10);
-       if (cp == endptr || *endptr != '.')
-               return 0;
-       cp = endptr + 1;
-       minor = strtol(cp, &endptr, 10);
-       if (cp == endptr || *endptr != '.')
-               return 0;
-       cp = endptr + 1;
-       rev = strtol(cp, &endptr, 10);
-       if (cp == endptr)
-               return 0;
-       return KERNEL_VERSION(major, minor, rev);
-}
-
-static int is_before_linux_ver(unsigned int major, unsigned int minor,
-                              unsigned int rev)
-{
-       struct          utsname ut;
-       static int      linux_version_code = -1;
-
-       if (uname(&ut)) {
-               perror("uname");
-               exit(1);
-       }
-       if (linux_version_code < 0)
-               linux_version_code = parse_version_number(ut.release);
-       if (linux_version_code == 0)
-               return 0;
-
-       return linux_version_code < KERNEL_VERSION(major, minor, rev);
-}
-#else
-static int is_before_linux_ver(unsigned int major, unsigned int minor,
-                              unsigned int rev)
-{
-       return 0;
-}
-#endif
-
 /*
  * Helper function for read_bb_file and test_disk
  */
@@ -1501,7 +1449,7 @@ profile_error:
        memset(&fs_param, 0, sizeof(struct ext2_super_block));
        fs_param.s_rev_level = 1;  /* Create revision 1 filesystems now */
 
-       if (is_before_linux_ver(2, 2, 0))
+       if (ext2fs_is_before_linux_ver(2, 2, 0))
                fs_param.s_rev_level = 0;
 
        if (argc && *argv) {
@@ -1933,7 +1881,8 @@ profile_error:
 
                if (use_bsize == -1) {
                        use_bsize = sys_page_size;
-                       if (is_before_linux_ver(2, 6, 0) && use_bsize > 4096)
+                       if (ext2fs_is_before_linux_ver(2, 6, 0) &&
+                           use_bsize > 4096)
                                use_bsize = 4096;
                }
                if (lsector_size && use_bsize < lsector_size)
@@ -2132,7 +2081,7 @@ profile_error:
         * On newer kernels we do have lazy_itable_init support. So pick the
         * right default in case ext4 module is not loaded.
         */
-       if (is_before_linux_ver(2, 6, 37))
+       if (ext2fs_is_before_linux_ver(2, 6, 37))
                lazy_itable_init = 0;
        else
                lazy_itable_init = 1;
index 2898830..501e3d2 100644 (file)
@@ -436,13 +436,20 @@ unsigned int figure_journal_size(int size, ext2_filsys fs)
        }
 
        if (size > 0) {
+               int min_size;
+
+               if (ext2fs_is_before_linux_ver(3, 10, 0) ||
+                   ext2fs_blocks_count(fs->super) <= 8192)
+                       min_size = 1024;
+               else
+                       min_size = 2048;
+
                j_blocks = size * 1024 / (fs->blocksize / 1024);
-               if (j_blocks < 1024 || j_blocks > 10240000) {
+               if (j_blocks < min_size || j_blocks > 10240000) {
                        fprintf(stderr, _("\nThe requested journal "
                                "size is %d blocks; it must be\n"
-                               "between 1024 and 10240000 blocks.  "
-                               "Aborting.\n"),
-                               j_blocks);
+                               "between %d and 10240000 blocks.  "
+                               "Aborting.\n"), j_blocks, min_size);
                        exit(1);
                }
                if ((unsigned) j_blocks > ext2fs_free_blocks_count(fs->super) / 2) {
index 5f28d92..553e70a 100644 (file)
@@ -27,6 +27,8 @@ if [ "$EXP1"x = x ]; then
                gunzip < $test_dir/expect.1.gz > $EXP1
        else
                EXP1=$test_dir/expect.1
+               [ "$CHECK_RHEL7" = "true" -a -f $test_dir/expect_rhel7.1 ] &&
+                       EXP1=$test_dir/expect_rhel7.1 || true
        fi
 fi
 
@@ -36,6 +38,8 @@ if [ "$EXP2"x = x ]; then
                gunzip < $test_dir/expect.2.gz > $EXP2
        else
                EXP2=$test_dir/expect.2
+               [ "$CHECK_RHEL7" = "true" -a -f $test_dir/expect_rhel7.2 ] &&
+                       EXP2=$test_dir/expect_rhel7.2 || true
        fi
 fi
 
index 56dee97..66f1eaa 100644 (file)
@@ -38,3 +38,13 @@ E2FSPROGS_SKIP_PROGRESS=yes
 export E2FSPROGS_SKIP_PROGRESS
 EXT2FS_NO_MTAB_OK=yes
 export EXT2FS_NO_MTAB_OK
+
+if [ "$(uname -s)" = "Linux" ]; then
+       LINUX_VERSION1=`uname -r | awk -F . '{ printf $1 }'`
+       LINUX_VERSION2=`uname -r | awk -F . '{ printf $2 }'`
+       [ $LINUX_VERSION1 -ge 3 -a $LINUX_VERSION2 -ge 10 ] &&
+               CHECK_RHEL7=true || CHECK_RHEL7=false
+else
+       CHECK_RHEL7=false
+fi
+export CHECK_RHEL7