From 4496ea49de004da21be8c469355776ed3f03c3eb Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Tue, 8 Jan 2013 23:55:59 -0500 Subject: [PATCH] LU-2555 ldiskfs: fix ext4_mb_add_n_trim() In ext4_mb_add_n_trim(), lg_prealloc_lock should be taken when changing the lg_prealloc_list. Signed-off-by: Niu Yawei Change-Id: I4f3a4b8bc9697b7ccdeade43f5bfd10960533fca Reviewed-on: http://review.whamcloud.com/4978 Reviewed-by: Alex Zhuravlev Reviewed-by: Bobi Jam Tested-by: Hudson Tested-by: Maloo --- .../patches/ext4-fix-ext4_mb_add_n_trim.patch | 22 ++++++++++++++++++++++ .../series/ldiskfs-2.6-rhel5-ext4.series | 1 + .../kernel_patches/series/ldiskfs-2.6-rhel6.series | 1 + .../series/ldiskfs-2.6-sles11.series | 1 + 4 files changed, 25 insertions(+) create mode 100644 ldiskfs/kernel_patches/patches/ext4-fix-ext4_mb_add_n_trim.patch diff --git a/ldiskfs/kernel_patches/patches/ext4-fix-ext4_mb_add_n_trim.patch b/ldiskfs/kernel_patches/patches/ext4-fix-ext4_mb_add_n_trim.patch new file mode 100644 index 0000000..a394e18 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/ext4-fix-ext4_mb_add_n_trim.patch @@ -0,0 +1,22 @@ +Index: linux-stage/fs/ext4/mballoc.c +=================================================================== +--- linux-stage.orig/fs/ext4/mballoc.c ++++ linux-stage/fs/ext4/mballoc.c +@@ -4352,7 +4352,7 @@ static void ext4_mb_add_n_trim(struct ex + /* The max size of hash table is PREALLOC_TB_SIZE */ + order = PREALLOC_TB_SIZE - 1; + /* Add the prealloc space to lg */ +- rcu_read_lock(); ++ spin_lock(&lg->lg_prealloc_lock); + list_for_each_entry_rcu(tmp_pa, &lg->lg_prealloc_list[order], + pa_inode_list) { + spin_lock(&tmp_pa->pa_lock); +@@ -4376,7 +4376,7 @@ static void ext4_mb_add_n_trim(struct ex + if (!added) + list_add_tail_rcu(&pa->pa_inode_list, + &lg->lg_prealloc_list[order]); +- rcu_read_unlock(); ++ spin_unlock(&lg->lg_prealloc_lock); + + /* Now trim the list to be not more than 8 elements */ + if (lg_prealloc_count > 8) { diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series index cc7e316..51fb676 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series @@ -35,3 +35,4 @@ ext4-export-64bit-name-hash.patch ext4-vmalloc-rhel5.patch ext4-mballoc-group_check-rhel5.patch ext4-store-tree-generation-at-find.patch +ext4-fix-ext4_mb_add_n_trim.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series index 2c64eda..7f35a60 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel6.series @@ -31,3 +31,4 @@ ext4-back-dquot-to-rhel6.patch ext4-nocmtime-2.6-rhel5.patch ext4-vmalloc-rhel6.patch ext4-store-tree-generation-at-find.patch +ext4-fix-ext4_mb_add_n_trim.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series index 192c262..a3aec58 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series @@ -34,3 +34,4 @@ ext4-hash-indexed-dir-dotdot-update.patch ext4-disable-write-bar-by-default.patch ext4-mballoc-pa_free-mismatch.patch ext4-export-64bit-name-hash.patch +ext4-fix-ext4_mb_add_n_trim.patch -- 1.8.3.1