diff options
author | Amir Goldstein <amir73il@users.sf.net> | 2011-05-09 21:52:36 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-05-09 21:52:36 -0400 |
commit | 44183d4231a52a797beb477f962e1d361e31299d (patch) | |
tree | 51ab7183ba8592db316cc189b063d49d8109d58f | |
parent | 9b8b7d353f5f9bea758398c3af679ffa105e5cfe (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>
-rw-r--r-- | fs/ext4/mballoc.c | 31 | ||||
-rw-r--r-- | fs/ext4/mballoc.h | 6 |
2 files changed, 1 insertions, 36 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 | */ | ||
1141 | repeat_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); |
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h index 22bd4d7f289b..20b5e7bfebd1 100644 --- a/fs/ext4/mballoc.h +++ b/fs/ext4/mballoc.h | |||
@@ -193,11 +193,6 @@ struct ext4_allocation_context { | |||
193 | __u8 ac_op; /* operation, for history only */ | 193 | __u8 ac_op; /* operation, for history only */ |
194 | struct page *ac_bitmap_page; | 194 | struct page *ac_bitmap_page; |
195 | struct page *ac_buddy_page; | 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 | struct ext4_prealloc_space *ac_pa; | 196 | struct ext4_prealloc_space *ac_pa; |
202 | struct ext4_locality_group *ac_lg; | 197 | struct ext4_locality_group *ac_lg; |
203 | }; | 198 | }; |
@@ -215,7 +210,6 @@ struct ext4_buddy { | |||
215 | struct super_block *bd_sb; | 210 | struct super_block *bd_sb; |
216 | __u16 bd_blkbits; | 211 | __u16 bd_blkbits; |
217 | ext4_group_t bd_group; | 212 | ext4_group_t bd_group; |
218 | struct rw_semaphore *alloc_semp; | ||
219 | }; | 213 | }; |
220 | #define EXT4_MB_BITMAP(e4b) ((e4b)->bd_bitmap) | 214 | #define EXT4_MB_BITMAP(e4b) ((e4b)->bd_bitmap) |
221 | #define EXT4_MB_BUDDY(e4b) ((e4b)->bd_buddy) | 215 | #define EXT4_MB_BUDDY(e4b) ((e4b)->bd_buddy) |