Whamcloud - gitweb
LU-4557 ext4: recalc percpu counters after journal 08/9908/3
authorHongchao Zhang <hongchao.zhang@intel.com>
Sun, 6 Apr 2014 02:12:18 +0000 (10:12 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 28 Apr 2014 14:21:42 +0000 (14:21 +0000)
the percpu counters is initialized before replaying the journal,
but after the journal it should be recalculate to deal with the
possibility of the percpu counters getting updated by the journal
replay.

the issue has been fixed in the new kernels (RHEL6 2.6.32-431.5.1,
SLES11SP3 3.0.101-0.15), then it is not needed for these kernels.

Change-Id: I5dfa0696b5ccd404b1add9ad6e2b0877d86a35b2
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-on: http://review.whamcloud.com/9908
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
ldiskfs/kernel_patches/patches/rhel6.3/ext4-init-statfs-after-journal.patch [deleted file]
ldiskfs/kernel_patches/patches/rhel6.3/ext4-recalc-percpu-counters-after-journal.patch [new file with mode: 0644]
ldiskfs/kernel_patches/patches/sles11sp2/ext4-init-statfs-after-journal.patch [deleted file]
ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series
ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series
ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series
ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series
ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series

diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-init-statfs-after-journal.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-init-statfs-after-journal.patch
deleted file mode 100644 (file)
index 777a225..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
---- linux-stage.orig/fs/ext4/super.c   2014-02-14 04:48:50.707992991 +0800
-+++ linux-stage/fs/ext4/super.c        2014-02-14 04:49:53.341999568 +0800
-@@ -3456,24 +3456,6 @@ static int ext4_fill_super(struct super_
-       get_random_bytes(&sbi->s_next_generation, sizeof(u32));
-       spin_lock_init(&sbi->s_next_gen_lock);
--      err = percpu_counter_init(&sbi->s_freeblocks_counter,
--                      ext4_count_free_blocks(sb));
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_freeinodes_counter,
--                              ext4_count_free_inodes(sb));
--      }
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_dirs_counter,
--                              ext4_count_dirs(sb));
--      }
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
--      }
--      if (err) {
--              ext4_msg(sb, KERN_ERR, "insufficient memory");
--              goto failed_mount3;
--      }
--
-       sbi->s_stripe = ext4_get_stripe_size(sbi);
-       sbi->s_max_writeback_mb_bump = 128;
-@@ -3555,6 +3537,24 @@ static int ext4_fill_super(struct super_
-               goto no_journal;
-       }
-+      err = percpu_counter_init(&sbi->s_freeblocks_counter,
-+                      ext4_count_free_blocks(sb));
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_freeinodes_counter,
-+                              ext4_count_free_inodes(sb));
-+      }
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_dirs_counter,
-+                              ext4_count_dirs(sb));
-+      }
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
-+      }
-+      if (err) {
-+              ext4_msg(sb, KERN_ERR, "insufficient memory");
-+              goto failed_mount4;
-+      }
-+
-       if (ext4_blocks_count(es) > 0xffffffffULL &&
-           !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
-                                      JBD2_FEATURE_INCOMPAT_64BIT)) {
diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-recalc-percpu-counters-after-journal.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-recalc-percpu-counters-after-journal.patch
new file mode 100644 (file)
index 0000000..f54fc1a
--- /dev/null
@@ -0,0 +1,21 @@
+--- linux-stage.orig/fs/ext4/super.c
++++ linux-stage/fs/ext4/super.c
+@@ -3613,6 +3613,18 @@ static int ext4_fill_super(struct super_
+       sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
++      /*
++       * The journal may have updated the bg summary counts, so we
++       * need to update the global counters.
++       */
++      percpu_counter_set(&sbi->s_freeblocks_counter,
++                         ext4_count_free_blocks(sb));
++      percpu_counter_set(&sbi->s_freeinodes_counter,
++                         ext4_count_free_inodes(sb));
++      percpu_counter_set(&sbi->s_dirs_counter,
++                         ext4_count_dirs(sb));
++      percpu_counter_set(&sbi->s_dirtyblocks_counter, 0);
++
+ no_journal:
+       if (test_opt(sb, NOBH)) {
diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-init-statfs-after-journal.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-init-statfs-after-journal.patch
deleted file mode 100644 (file)
index 31c89d4..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
---- linux-stage.orig/fs/ext4/super.c
-+++ linux-stage/fs/ext4/super.c
-@@ -3383,24 +3424,6 @@ static int ext4_fill_super(struct super_
-       get_random_bytes(&sbi->s_next_generation, sizeof(u32));
-       spin_lock_init(&sbi->s_next_gen_lock);
--      err = percpu_counter_init(&sbi->s_freeblocks_counter,
--                      ext4_count_free_blocks(sb));
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_freeinodes_counter,
--                              ext4_count_free_inodes(sb));
--      }
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_dirs_counter,
--                              ext4_count_dirs(sb));
--      }
--      if (!err) {
--              err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
--      }
--      if (err) {
--              ext4_msg(sb, KERN_ERR, "insufficient memory");
--              goto failed_mount3;
--      }
--
-       sbi->s_stripe = ext4_get_stripe_size(sbi);
-       sbi->s_max_writeback_mb_bump = 128;
-@@ -3482,6 +3505,24 @@ static int ext4_fill_super(struct super_
-               goto no_journal;
-       }
-+      err = percpu_counter_init(&sbi->s_freeblocks_counter,
-+                      ext4_count_free_blocks(sb));
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_freeinodes_counter,
-+                              ext4_count_free_inodes(sb));
-+      }
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_dirs_counter,
-+                              ext4_count_dirs(sb));
-+      }
-+      if (!err) {
-+              err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
-+      }
-+      if (err) {
-+              ext4_msg(sb, KERN_ERR, "insufficient memory");
-+              goto failed_mount3;
-+      }
-+
-       if (ext4_blocks_count(es) > 0xffffffffULL &&
-           !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
-                                      JBD2_FEATURE_INCOMPAT_64BIT)) {
index 3d90e9c..3f7db37 100644 (file)
@@ -47,4 +47,4 @@ rhel6.3/ext4-max-dir-size.patch
 rhel6.4/ext4-max-dir-size-options.patch
 rhel6.3/ext4-not-discard-preallocation-umount.patch
 rhel6.3/ext4-journal-path-opt.patch
-rhel6.3/ext4-init-statfs-after-journal.patch
+rhel6.3/ext4-recalc-percpu-counters-after-journal.patch
index b2e9827..fbbac67 100644 (file)
@@ -48,4 +48,3 @@ rhel6.3/ext4-max-dir-size.patch
 rhel6.4/ext4-max-dir-size-options.patch
 rhel6.3/ext4-not-discard-preallocation-umount.patch
 rhel6.3/ext4-journal-path-opt.patch
-rhel6.3/ext4-init-statfs-after-journal.patch
index a231a6f..5c819ea 100644 (file)
@@ -46,4 +46,4 @@ rhel6.3/ext4-max-dir-size.patch
 rhel6.3/ext4-max-dir-size-options.patch
 rhel6.3/ext4-not-discard-preallocation-umount.patch
 rhel6.3/ext4-journal-path-opt.patch
-rhel6.3/ext4-init-statfs-after-journal.patch
+rhel6.3/ext4-recalc-percpu-counters-after-journal.patch
index 81f6a0e..1fc8869 100644 (file)
@@ -46,4 +46,4 @@ rhel6.3/ext4-max-dir-size.patch
 sles11sp1/ext4-max-dir-size-options.patch
 rhel6.3/ext4-not-discard-preallocation-umount.patch
 rhel6.3/ext4-journal-path-opt.patch
-rhel6.3/ext4-init-statfs-after-journal.patch
+rhel6.3/ext4-recalc-percpu-counters-after-journal.patch
index 99bb623..e69fa59 100644 (file)
@@ -43,4 +43,3 @@ rhel6.3/ext4-max-dir-size.patch
 sles11sp2/ext4-max-dir-size-options.patch
 rhel6.3/ext4-not-discard-preallocation-umount.patch
 rhel6.3/ext4-journal-path-opt.patch
-sles11sp2/ext4-init-statfs-after-journal.patch