summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorNiu Yawei <yawei.niu@gmail.com>2013-02-01 21:31:27 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-04 06:09:05 +0800
commitfd80f53550720f200ca0469e9419c750f895ab50 (patch)
tree9f38972a5c4df24ae1e780df97f5c85cffdbbf0f /fs/ext4
parent5dec43e3d688390256df3343bb444e7ed0022f44 (diff)
downloadlwn-fd80f53550720f200ca0469e9419c750f895ab50.tar.gz
lwn-fd80f53550720f200ca0469e9419c750f895ab50.zip
ext4: fix race in ext4_mb_add_n_trim()
commit f1167009711032b0d747ec89a632a626c901a1ad upstream. In ext4_mb_add_n_trim(), lg_prealloc_lock should be taken when changing the lg_prealloc_list. Signed-off-by: Niu Yawei <yawei.niu@intel.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/mballoc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index b6adf68a5c02..31bbdb52b899 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4111,7 +4111,7 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
/* 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);
@@ -4135,12 +4135,12 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
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) {
ext4_mb_discard_lg_preallocations(sb, lg,
- order, lg_prealloc_count);
+ order, lg_prealloc_count);
return;
}
return ;