aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@users.sf.net>2011-05-09 21:52:36 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-05-09 21:52:36 -0400
commit44183d4231a52a797beb477f962e1d361e31299d (patch)
tree51ab7183ba8592db316cc189b063d49d8109d58f /fs/ext4/mballoc.c
parent9b8b7d353f5f9bea758398c3af679ffa105e5cfe (diff)
ext4: remove alloc_semp
After taking care of all group init races, all that remains is to remove alloc_semp from ext4_allocation_context and ext4_buddy structs. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 1816eafb0a05..254f1f9fc4eb 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1130,24 +1130,8 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
1130 e4b->bd_group = group; 1130 e4b->bd_group = group;
1131 e4b->bd_buddy_page = NULL; 1131 e4b->bd_buddy_page = NULL;
1132 e4b->bd_bitmap_page = NULL; 1132 e4b->bd_bitmap_page = NULL;
1133 e4b->alloc_semp = &grp->alloc_sem;
1134
1135 /* Take the read lock on the group alloc
1136 * sem. This would make sure a parallel
1137 * ext4_mb_init_group happening on other
1138 * groups mapped by the page is blocked
1139 * till we are done with allocation
1140 */
1141repeat_load_buddy:
1142 down_read(e4b->alloc_semp);
1143 1133
1144 if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { 1134 if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
1145 /* we need to check for group need init flag
1146 * with alloc_semp held so that we can be sure
1147 * that new blocks didn't get added to the group
1148 * when we are loading the buddy cache
1149 */
1150 up_read(e4b->alloc_semp);
1151 /* 1135 /*
1152 * we need full data about the group 1136 * we need full data about the group
1153 * to make a good selection 1137 * to make a good selection
@@ -1155,7 +1139,6 @@ repeat_load_buddy:
1155 ret = ext4_mb_init_group(sb, group); 1139 ret = ext4_mb_init_group(sb, group);
1156 if (ret) 1140 if (ret)
1157 return ret; 1141 return ret;
1158 goto repeat_load_buddy;
1159 } 1142 }
1160 1143
1161 /* 1144 /*
@@ -1247,9 +1230,6 @@ err:
1247 page_cache_release(e4b->bd_buddy_page); 1230 page_cache_release(e4b->bd_buddy_page);
1248 e4b->bd_buddy = NULL; 1231 e4b->bd_buddy = NULL;
1249 e4b->bd_bitmap = NULL; 1232 e4b->bd_bitmap = NULL;
1250
1251 /* Done with the buddy cache */
1252 up_read(e4b->alloc_semp);
1253 return ret; 1233 return ret;
1254} 1234}
1255 1235
@@ -1259,9 +1239,6 @@ static void ext4_mb_unload_buddy(struct ext4_buddy *e4b)
1259 page_cache_release(e4b->bd_bitmap_page); 1239 page_cache_release(e4b->bd_bitmap_page);
1260 if (e4b->bd_buddy_page) 1240 if (e4b->bd_buddy_page)
1261 page_cache_release(e4b->bd_buddy_page); 1241 page_cache_release(e4b->bd_buddy_page);
1262 /* Done with the buddy cache */
1263 if (e4b->alloc_semp)
1264 up_read(e4b->alloc_semp);
1265} 1242}
1266 1243
1267 1244
@@ -1574,9 +1551,6 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
1574 get_page(ac->ac_bitmap_page); 1551 get_page(ac->ac_bitmap_page);
1575 ac->ac_buddy_page = e4b->bd_buddy_page; 1552 ac->ac_buddy_page = e4b->bd_buddy_page;
1576 get_page(ac->ac_buddy_page); 1553 get_page(ac->ac_buddy_page);
1577 /* on allocation we use ac to track the held semaphore */
1578 ac->alloc_semp = e4b->alloc_semp;
1579 e4b->alloc_semp = NULL;
1580 /* store last allocated for subsequent stream allocation */ 1554 /* store last allocated for subsequent stream allocation */
1581 if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { 1555 if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) {
1582 spin_lock(&sbi->s_md_lock); 1556 spin_lock(&sbi->s_md_lock);
@@ -4188,15 +4162,12 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
4188 spin_unlock(&pa->pa_lock); 4162 spin_unlock(&pa->pa_lock);
4189 } 4163 }
4190 } 4164 }
4191 if (ac->alloc_semp)
4192 up_read(ac->alloc_semp);
4193 if (pa) { 4165 if (pa) {
4194 /* 4166 /*
4195 * We want to add the pa to the right bucket. 4167 * We want to add the pa to the right bucket.
4196 * Remove it from the list and while adding 4168 * Remove it from the list and while adding
4197 * make sure the list to which we are adding 4169 * make sure the list to which we are adding
4198 * doesn't grow big. We need to release 4170 * doesn't grow big.
4199 * alloc_semp before calling ext4_mb_add_n_trim()
4200 */ 4171 */
4201 if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) { 4172 if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) {
4202 spin_lock(pa->pa_obj_lock); 4173 spin_lock(pa->pa_obj_lock);