From: Hongchao Zhang Date: Sun, 6 Apr 2014 02:12:18 +0000 (+0800) Subject: LU-4557 ext4: recalc percpu counters after journal X-Git-Tag: 2.5.59~81 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=db63362b7a25434cadccb01a2237a1f5368887b1;p=fs%2Flustre-release.git LU-4557 ext4: recalc percpu counters after journal 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 Reviewed-on: http://review.whamcloud.com/9908 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: James Simmons --- 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 index 777a225..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-init-statfs-after-journal.patch +++ /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 index 0000000..f54fc1a --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-recalc-percpu-counters-after-journal.patch @@ -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 index 31c89d4..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-init-statfs-after-journal.patch +++ /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)) { diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series index 3d90e9c..3f7db37 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.4.series @@ -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 diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series index b2e9827..fbbac67 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.5.series @@ -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 diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series index a231a6f..5c819ea 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series @@ -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 diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series index 81f6a0e..1fc8869 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series @@ -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 diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series index 99bb623..e69fa59 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series @@ -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