diff options
author | Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> | 2011-05-08 14:43:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-09 12:04:23 -0400 |
commit | 7d23ce36e3f52f9b83ac8da49296b73339c8b5b8 (patch) | |
tree | 0c3973efa632e3c58d056c5d949a38b4c475193f /fs/hpfs/alloc.c | |
parent | 7dd29d8d865efdb00c0542a5d2c87af8c52ea6c7 (diff) |
HPFS: Remove remaining locks
Remove remaining locks
Because of a new global per-fs lock, no other locks are needed
Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hpfs/alloc.c')
-rw-r--r-- | fs/hpfs/alloc.c | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 5503e2c28910..995472de92a0 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -8,8 +8,6 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | ||
12 | |||
13 | /* | 11 | /* |
14 | * Check if a sector is allocated in bitmap | 12 | * Check if a sector is allocated in bitmap |
15 | * This is really slow. Turned on only if chk==2 | 13 | * This is really slow. Turned on only if chk==2 |
@@ -75,7 +73,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
75 | hpfs_error(s, "Bad allocation size: %d", n); | 73 | hpfs_error(s, "Bad allocation size: %d", n); |
76 | return 0; | 74 | return 0; |
77 | } | 75 | } |
78 | lock_super(s); | ||
79 | if (bs != ~0x3fff) { | 76 | if (bs != ~0x3fff) { |
80 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; | 77 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; |
81 | } else { | 78 | } else { |
@@ -143,7 +140,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
143 | b: | 140 | b: |
144 | hpfs_brelse4(&qbh); | 141 | hpfs_brelse4(&qbh); |
145 | uls: | 142 | uls: |
146 | unlock_super(s); | ||
147 | return ret; | 143 | return ret; |
148 | } | 144 | } |
149 | 145 | ||
@@ -155,7 +151,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
155 | * sectors | 151 | * sectors |
156 | */ | 152 | */ |
157 | 153 | ||
158 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward, int lock) | 154 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) |
159 | { | 155 | { |
160 | secno sec; | 156 | secno sec; |
161 | int i; | 157 | int i; |
@@ -167,7 +163,6 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
167 | forward = -forward; | 163 | forward = -forward; |
168 | f_p = 1; | 164 | f_p = 1; |
169 | } | 165 | } |
170 | if (lock) hpfs_lock_creation(s); | ||
171 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; | 166 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; |
172 | if (near && near < sbi->sb_fs_size) { | 167 | if (near && near < sbi->sb_fs_size) { |
173 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; | 168 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; |
@@ -214,18 +209,17 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
214 | ret: | 209 | ret: |
215 | if (sec && f_p) { | 210 | if (sec && f_p) { |
216 | for (i = 0; i < forward; i++) { | 211 | for (i = 0; i < forward; i++) { |
217 | if (!hpfs_alloc_if_possible_nolock(s, sec + i + 1)) { | 212 | if (!hpfs_alloc_if_possible(s, sec + i + 1)) { |
218 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); | 213 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); |
219 | sec = 0; | 214 | sec = 0; |
220 | break; | 215 | break; |
221 | } | 216 | } |
222 | } | 217 | } |
223 | } | 218 | } |
224 | if (lock) hpfs_unlock_creation(s); | ||
225 | return sec; | 219 | return sec; |
226 | } | 220 | } |
227 | 221 | ||
228 | static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | 222 | static secno alloc_in_dirband(struct super_block *s, secno near) |
229 | { | 223 | { |
230 | unsigned nr = near; | 224 | unsigned nr = near; |
231 | secno sec; | 225 | secno sec; |
@@ -236,43 +230,29 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | |||
236 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; | 230 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; |
237 | nr -= sbi->sb_dirband_start; | 231 | nr -= sbi->sb_dirband_start; |
238 | nr >>= 2; | 232 | nr >>= 2; |
239 | if (lock) hpfs_lock_creation(s); | ||
240 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); | 233 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); |
241 | if (lock) hpfs_unlock_creation(s); | ||
242 | if (!sec) return 0; | 234 | if (!sec) return 0; |
243 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; | 235 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; |
244 | } | 236 | } |
245 | 237 | ||
246 | /* Alloc sector if it's free */ | 238 | /* Alloc sector if it's free */ |
247 | 239 | ||
248 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec) | 240 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) |
249 | { | 241 | { |
250 | struct quad_buffer_head qbh; | 242 | struct quad_buffer_head qbh; |
251 | unsigned *bmp; | 243 | unsigned *bmp; |
252 | lock_super(s); | ||
253 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; | 244 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; |
254 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { | 245 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { |
255 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); | 246 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); |
256 | hpfs_mark_4buffers_dirty(&qbh); | 247 | hpfs_mark_4buffers_dirty(&qbh); |
257 | hpfs_brelse4(&qbh); | 248 | hpfs_brelse4(&qbh); |
258 | unlock_super(s); | ||
259 | return 1; | 249 | return 1; |
260 | } | 250 | } |
261 | hpfs_brelse4(&qbh); | 251 | hpfs_brelse4(&qbh); |
262 | end: | 252 | end: |
263 | unlock_super(s); | ||
264 | return 0; | 253 | return 0; |
265 | } | 254 | } |
266 | 255 | ||
267 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) | ||
268 | { | ||
269 | int r; | ||
270 | hpfs_lock_creation(s); | ||
271 | r = hpfs_alloc_if_possible_nolock(s, sec); | ||
272 | hpfs_unlock_creation(s); | ||
273 | return r; | ||
274 | } | ||
275 | |||
276 | /* Free sectors in bitmaps */ | 256 | /* Free sectors in bitmaps */ |
277 | 257 | ||
278 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | 258 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) |
@@ -286,26 +266,22 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | |||
286 | hpfs_error(s, "Trying to free reserved sector %08x", sec); | 266 | hpfs_error(s, "Trying to free reserved sector %08x", sec); |
287 | return; | 267 | return; |
288 | } | 268 | } |
289 | lock_super(s); | ||
290 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; | 269 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; |
291 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; | 270 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; |
292 | new_map: | 271 | new_map: |
293 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { | 272 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { |
294 | unlock_super(s); | ||
295 | return; | 273 | return; |
296 | } | 274 | } |
297 | new_tst: | 275 | new_tst: |
298 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { | 276 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { |
299 | hpfs_error(s, "sector %08x not allocated", sec); | 277 | hpfs_error(s, "sector %08x not allocated", sec); |
300 | hpfs_brelse4(&qbh); | 278 | hpfs_brelse4(&qbh); |
301 | unlock_super(s); | ||
302 | return; | 279 | return; |
303 | } | 280 | } |
304 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); | 281 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); |
305 | if (!--n) { | 282 | if (!--n) { |
306 | hpfs_mark_4buffers_dirty(&qbh); | 283 | hpfs_mark_4buffers_dirty(&qbh); |
307 | hpfs_brelse4(&qbh); | 284 | hpfs_brelse4(&qbh); |
308 | unlock_super(s); | ||
309 | return; | 285 | return; |
310 | } | 286 | } |
311 | if (!(++sec & 0x3fff)) { | 287 | if (!(++sec & 0x3fff)) { |
@@ -381,29 +357,25 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno) | |||
381 | struct quad_buffer_head qbh; | 357 | struct quad_buffer_head qbh; |
382 | unsigned *bmp; | 358 | unsigned *bmp; |
383 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; | 359 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; |
384 | lock_super(s); | ||
385 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 360 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
386 | unlock_super(s); | ||
387 | return; | 361 | return; |
388 | } | 362 | } |
389 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); | 363 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); |
390 | hpfs_mark_4buffers_dirty(&qbh); | 364 | hpfs_mark_4buffers_dirty(&qbh); |
391 | hpfs_brelse4(&qbh); | 365 | hpfs_brelse4(&qbh); |
392 | unlock_super(s); | ||
393 | } | 366 | } |
394 | } | 367 | } |
395 | 368 | ||
396 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, | 369 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, |
397 | dnode_secno *dno, struct quad_buffer_head *qbh, | 370 | dnode_secno *dno, struct quad_buffer_head *qbh) |
398 | int lock) | ||
399 | { | 371 | { |
400 | struct dnode *d; | 372 | struct dnode *d; |
401 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { | 373 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { |
402 | if (!(*dno = alloc_in_dirband(s, near, lock))) | 374 | if (!(*dno = alloc_in_dirband(s, near))) |
403 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; | 375 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; |
404 | } else { | 376 | } else { |
405 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) | 377 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) |
406 | if (!(*dno = alloc_in_dirband(s, near, lock))) return NULL; | 378 | if (!(*dno = alloc_in_dirband(s, near))) return NULL; |
407 | } | 379 | } |
408 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { | 380 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { |
409 | hpfs_free_dnode(s, *dno); | 381 | hpfs_free_dnode(s, *dno); |
@@ -424,7 +396,7 @@ struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *f | |||
424 | struct buffer_head **bh) | 396 | struct buffer_head **bh) |
425 | { | 397 | { |
426 | struct fnode *f; | 398 | struct fnode *f; |
427 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD, 1))) return NULL; | 399 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; |
428 | if (!(f = hpfs_get_sector(s, *fno, bh))) { | 400 | if (!(f = hpfs_get_sector(s, *fno, bh))) { |
429 | hpfs_free_sectors(s, *fno, 1); | 401 | hpfs_free_sectors(s, *fno, 1); |
430 | return NULL; | 402 | return NULL; |
@@ -441,7 +413,7 @@ struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *a | |||
441 | struct buffer_head **bh) | 413 | struct buffer_head **bh) |
442 | { | 414 | { |
443 | struct anode *a; | 415 | struct anode *a; |
444 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD, 1))) return NULL; | 416 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; |
445 | if (!(a = hpfs_get_sector(s, *ano, bh))) { | 417 | if (!(a = hpfs_get_sector(s, *ano, bh))) { |
446 | hpfs_free_sectors(s, *ano, 1); | 418 | hpfs_free_sectors(s, *ano, 1); |
447 | return NULL; | 419 | return NULL; |