Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Amir Goldstein and committed by
Theodore Ts'o
44183d42 9b8b7d35

+1 -36
+1 -30
fs/ext4/mballoc.c
··· 1130 1130 e4b->bd_group = group; 1131 1131 e4b->bd_buddy_page = NULL; 1132 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 - */ 1141 - repeat_load_buddy: 1142 - down_read(e4b->alloc_semp); 1143 1133 1144 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 1136 * we need full data about the group 1153 1137 * to make a good selection ··· 1139 1155 ret = ext4_mb_init_group(sb, group); 1140 1156 if (ret) 1141 1157 return ret; 1142 - goto repeat_load_buddy; 1143 1158 } 1144 1159 1145 1160 /* ··· 1230 1247 page_cache_release(e4b->bd_buddy_page); 1231 1248 e4b->bd_buddy = NULL; 1232 1249 e4b->bd_bitmap = NULL; 1233 - 1234 - /* Done with the buddy cache */ 1235 - up_read(e4b->alloc_semp); 1236 1250 return ret; 1237 1251 } 1238 1252 ··· 1239 1259 page_cache_release(e4b->bd_bitmap_page); 1240 1260 if (e4b->bd_buddy_page) 1241 1261 page_cache_release(e4b->bd_buddy_page); 1242 - /* Done with the buddy cache */ 1243 - if (e4b->alloc_semp) 1244 - up_read(e4b->alloc_semp); 1245 1262 } 1246 1263 1247 1264 ··· 1551 1574 get_page(ac->ac_bitmap_page); 1552 1575 ac->ac_buddy_page = e4b->bd_buddy_page; 1553 1576 get_page(ac->ac_buddy_page); 1554 - /* on allocation we use ac to track the held semaphore */ 1555 - ac->alloc_semp = e4b->alloc_semp; 1556 - e4b->alloc_semp = NULL; 1557 1577 /* store last allocated for subsequent stream allocation */ 1558 1578 if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) { 1559 1579 spin_lock(&sbi->s_md_lock); ··· 4162 4188 spin_unlock(&pa->pa_lock); 4163 4189 } 4164 4190 } 4165 - if (ac->alloc_semp) 4166 - up_read(ac->alloc_semp); 4167 4191 if (pa) { 4168 4192 /* 4169 4193 * We want to add the pa to the right bucket. 4170 4194 * Remove it from the list and while adding 4171 4195 * make sure the list to which we are adding 4172 - * doesn't grow big. We need to release 4173 - * alloc_semp before calling ext4_mb_add_n_trim() 4196 + * doesn't grow big. 4174 4197 */ 4175 4198 if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) { 4176 4199 spin_lock(pa->pa_obj_lock);
-6
fs/ext4/mballoc.h
··· 193 193 __u8 ac_op; /* operation, for history only */ 194 194 struct page *ac_bitmap_page; 195 195 struct page *ac_buddy_page; 196 - /* 197 - * pointer to the held semaphore upon successful 198 - * block allocation 199 - */ 200 - struct rw_semaphore *alloc_semp; 201 196 struct ext4_prealloc_space *ac_pa; 202 197 struct ext4_locality_group *ac_lg; 203 198 }; ··· 210 215 struct super_block *bd_sb; 211 216 __u16 bd_blkbits; 212 217 ext4_group_t bd_group; 213 - struct rw_semaphore *alloc_semp; 214 218 }; 215 219 #define EXT4_MB_BITMAP(e4b) ((e4b)->bd_bitmap) 216 220 #define EXT4_MB_BUDDY(e4b) ((e4b)->bd_buddy)