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

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>

authored by

Mikulas Patocka and committed by
Linus Torvalds
7d23ce36 7dd29d8d

+50 -155
+11 -39
fs/hpfs/alloc.c
··· 8 8 9 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 12 * Check if a sector is allocated in bitmap 15 13 * This is really slow. Turned on only if chk==2 ··· 73 75 hpfs_error(s, "Bad allocation size: %d", n); 74 76 return 0; 75 77 } 76 - lock_super(s); 77 78 if (bs != ~0x3fff) { 78 79 if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; 79 80 } else { ··· 140 143 b: 141 144 hpfs_brelse4(&qbh); 142 145 uls: 143 - unlock_super(s); 144 146 return ret; 145 147 } 146 148 ··· 151 155 * sectors 152 156 */ 153 157 154 - secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward, int lock) 158 + secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) 155 159 { 156 160 secno sec; 157 161 int i; ··· 163 167 forward = -forward; 164 168 f_p = 1; 165 169 } 166 - if (lock) hpfs_lock_creation(s); 167 170 n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; 168 171 if (near && near < sbi->sb_fs_size) { 169 172 if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; ··· 209 214 ret: 210 215 if (sec && f_p) { 211 216 for (i = 0; i < forward; i++) { 212 - if (!hpfs_alloc_if_possible_nolock(s, sec + i + 1)) { 217 + if (!hpfs_alloc_if_possible(s, sec + i + 1)) { 213 218 hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); 214 219 sec = 0; 215 220 break; 216 221 } 217 222 } 218 223 } 219 - if (lock) hpfs_unlock_creation(s); 220 224 return sec; 221 225 } 222 226 223 - static secno alloc_in_dirband(struct super_block *s, secno near, int lock) 227 + static secno alloc_in_dirband(struct super_block *s, secno near) 224 228 { 225 229 unsigned nr = near; 226 230 secno sec; ··· 230 236 nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; 231 237 nr -= sbi->sb_dirband_start; 232 238 nr >>= 2; 233 - if (lock) hpfs_lock_creation(s); 234 239 sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); 235 - if (lock) hpfs_unlock_creation(s); 236 240 if (!sec) return 0; 237 241 return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; 238 242 } 239 243 240 244 /* Alloc sector if it's free */ 241 245 242 - static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec) 246 + int hpfs_alloc_if_possible(struct super_block *s, secno sec) 243 247 { 244 248 struct quad_buffer_head qbh; 245 249 unsigned *bmp; 246 - lock_super(s); 247 250 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; 248 251 if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { 249 252 bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); 250 253 hpfs_mark_4buffers_dirty(&qbh); 251 254 hpfs_brelse4(&qbh); 252 - unlock_super(s); 253 255 return 1; 254 256 } 255 257 hpfs_brelse4(&qbh); 256 258 end: 257 - unlock_super(s); 258 259 return 0; 259 - } 260 - 261 - int hpfs_alloc_if_possible(struct super_block *s, secno sec) 262 - { 263 - int r; 264 - hpfs_lock_creation(s); 265 - r = hpfs_alloc_if_possible_nolock(s, sec); 266 - hpfs_unlock_creation(s); 267 - return r; 268 260 } 269 261 270 262 /* Free sectors in bitmaps */ ··· 266 286 hpfs_error(s, "Trying to free reserved sector %08x", sec); 267 287 return; 268 288 } 269 - lock_super(s); 270 289 sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; 271 290 if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; 272 291 new_map: 273 292 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { 274 - unlock_super(s); 275 293 return; 276 294 } 277 295 new_tst: 278 296 if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { 279 297 hpfs_error(s, "sector %08x not allocated", sec); 280 298 hpfs_brelse4(&qbh); 281 - unlock_super(s); 282 299 return; 283 300 } 284 301 bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); 285 302 if (!--n) { 286 303 hpfs_mark_4buffers_dirty(&qbh); 287 304 hpfs_brelse4(&qbh); 288 - unlock_super(s); 289 305 return; 290 306 } 291 307 if (!(++sec & 0x3fff)) { ··· 357 381 struct quad_buffer_head qbh; 358 382 unsigned *bmp; 359 383 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; 360 - lock_super(s); 361 384 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 362 - unlock_super(s); 363 385 return; 364 386 } 365 387 bmp[ssec >> 5] |= 1 << (ssec & 0x1f); 366 388 hpfs_mark_4buffers_dirty(&qbh); 367 389 hpfs_brelse4(&qbh); 368 - unlock_super(s); 369 390 } 370 391 } 371 392 372 393 struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, 373 - dnode_secno *dno, struct quad_buffer_head *qbh, 374 - int lock) 394 + dnode_secno *dno, struct quad_buffer_head *qbh) 375 395 { 376 396 struct dnode *d; 377 397 if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { 378 - if (!(*dno = alloc_in_dirband(s, near, lock))) 379 - if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; 398 + if (!(*dno = alloc_in_dirband(s, near))) 399 + if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; 380 400 } else { 381 - if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) 382 - if (!(*dno = alloc_in_dirband(s, near, lock))) return NULL; 401 + if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) 402 + if (!(*dno = alloc_in_dirband(s, near))) return NULL; 383 403 } 384 404 if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { 385 405 hpfs_free_dnode(s, *dno); ··· 396 424 struct buffer_head **bh) 397 425 { 398 426 struct fnode *f; 399 - if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD, 1))) return NULL; 427 + if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; 400 428 if (!(f = hpfs_get_sector(s, *fno, bh))) { 401 429 hpfs_free_sectors(s, *fno, 1); 402 430 return NULL; ··· 413 441 struct buffer_head **bh) 414 442 { 415 443 struct anode *a; 416 - if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD, 1))) return NULL; 444 + if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; 417 445 if (!(a = hpfs_get_sector(s, *ano, bh))) { 418 446 hpfs_free_sectors(s, *ano, 1); 419 447 return NULL;
+1 -1
fs/hpfs/anode.c
··· 115 115 } 116 116 se = !fnod ? node : (node + 16384) & ~16383; 117 117 } 118 - if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M, 1))) { 118 + if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M))) { 119 119 brelse(bh); 120 120 return -1; 121 121 }
-16
fs/hpfs/buffer.c
··· 9 9 #include <linux/slab.h> 10 10 #include "hpfs_fn.h" 11 11 12 - void hpfs_lock_creation(struct super_block *s) 13 - { 14 - #ifdef DEBUG_LOCKS 15 - printk("lock creation\n"); 16 - #endif 17 - mutex_lock(&hpfs_sb(s)->hpfs_creation_de); 18 - } 19 - 20 - void hpfs_unlock_creation(struct super_block *s) 21 - { 22 - #ifdef DEBUG_LOCKS 23 - printk("unlock creation\n"); 24 - #endif 25 - mutex_unlock(&hpfs_sb(s)->hpfs_creation_de); 26 - } 27 - 28 12 /* Map a sector into a buffer and return pointers to it and to the buffer. */ 29 13 30 14 void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp,
+25 -32
fs/hpfs/dnode.c
··· 145 145 } 146 146 } 147 147 if (ptr) { 148 - if ((d->first_free += 4) > 2048) { 149 - hpfs_error(s,"set_last_pointer: too long dnode %08x", d->self); 150 - d->first_free -= 4; 148 + d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); 149 + if (le32_to_cpu(d->first_free) > 2048) { 150 + hpfs_error(s, "set_last_pointer: too long dnode %08x", d->self); 151 + d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4); 151 152 return; 152 153 } 153 154 de->length = 36; ··· 185 184 de->not_8x3 = hpfs_is_name_long(name, namelen); 186 185 de->namelen = namelen; 187 186 memcpy(de->name, name, namelen); 188 - d->first_free += d_size; 187 + d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + d_size); 189 188 return de; 190 189 } 191 190 ··· 198 197 hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); 199 198 return; 200 199 } 201 - d->first_free -= de->length; 202 - memmove(de, de_next_de(de), d->first_free + (char *)d - (char *)de); 200 + d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - de->length); 201 + memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); 203 202 } 204 203 205 204 static void fix_up_ptrs(struct super_block *s, struct dnode *d) ··· 263 262 kfree(nname); 264 263 return 1; 265 264 } 266 - if (d->first_free + de_size(namelen, down_ptr) <= 2048) { 265 + if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) { 267 266 loff_t t; 268 267 copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); 269 268 t = get_pos(d, de); ··· 287 286 kfree(nname); 288 287 return 1; 289 288 } 290 - memcpy(nd, d, d->first_free); 289 + memcpy(nd, d, le32_to_cpu(d->first_free)); 291 290 copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); 292 291 for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); 293 292 h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; 294 - if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1, 0))) { 293 + if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1))) { 295 294 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); 296 295 hpfs_brelse4(&qbh); 297 296 kfree(nd); ··· 314 313 down_ptr = adno; 315 314 set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); 316 315 de = de_next_de(de); 317 - memmove((char *)nd + 20, de, nd->first_free + (char *)nd - (char *)de); 318 - nd->first_free -= (char *)de - (char *)nd - 20; 319 - memcpy(d, nd, nd->first_free); 316 + memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); 317 + nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - (char *)de - (char *)nd - 20); 318 + memcpy(d, nd, le32_to_cpu(nd->first_free)); 320 319 for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); 321 320 fix_up_ptrs(i->i_sb, ad); 322 321 if (!d->root_dnode) { ··· 327 326 hpfs_brelse4(&qbh1); 328 327 goto go_up; 329 328 } 330 - if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2, 0))) { 329 + if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2))) { 331 330 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); 332 331 hpfs_brelse4(&qbh); 333 332 hpfs_brelse4(&qbh1); ··· 374 373 375 374 int hpfs_add_dirent(struct inode *i, 376 375 const unsigned char *name, unsigned namelen, 377 - struct hpfs_dirent *new_de, int cdepth) 376 + struct hpfs_dirent *new_de) 378 377 { 379 378 struct hpfs_inode_info *hpfs_inode = hpfs_i(i); 380 379 struct dnode *d; ··· 404 403 } 405 404 } 406 405 hpfs_brelse4(&qbh); 407 - if (!cdepth) hpfs_lock_creation(i->i_sb); 408 406 if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { 409 407 c = 1; 410 408 goto ret; ··· 411 411 i->i_version++; 412 412 c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); 413 413 ret: 414 - if (!cdepth) hpfs_unlock_creation(i->i_sb); 415 414 return c; 416 415 } 417 416 ··· 473 474 hpfs_brelse4(&qbh); 474 475 return 0; 475 476 } 476 - dnode->first_free -= 4; 477 + dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); 477 478 de->length -= 4; 478 479 de->down = 0; 479 480 hpfs_mark_4buffers_dirty(&qbh); ··· 516 517 try_it_again: 517 518 if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; 518 519 if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; 519 - if (dnode->first_free > 56) goto end; 520 - if (dnode->first_free == 52 || dnode->first_free == 56) { 520 + if (le32_to_cpu(dnode->first_free) > 56) goto end; 521 + if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { 521 522 struct hpfs_dirent *de_end; 522 523 int root = dnode->root_dnode; 523 524 up = dnode->up; ··· 570 571 if (!down) { 571 572 de->down = 0; 572 573 de->length -= 4; 573 - dnode->first_free -= 4; 574 + dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); 574 575 memmove(de_next_de(de), (char *)de_next_de(de) + 4, 575 - (char *)dnode + dnode->first_free - (char *)de_next_de(de)); 576 + (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); 576 577 } else { 577 578 struct dnode *d1; 578 579 struct quad_buffer_head qbh1; ··· 584 585 } 585 586 } 586 587 } else { 587 - hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, dnode->first_free); 588 + hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free)); 588 589 goto end; 589 590 } 590 591 ··· 634 635 struct hpfs_dirent *del = dnode_last_de(d1); 635 636 dlp = del->down ? de_down_pointer(del) : 0; 636 637 if (!dlp && down) { 637 - if (d1->first_free > 2044) { 638 + if (le32_to_cpu(d1->first_free) > 2044) { 638 639 if (hpfs_sb(i->i_sb)->sb_chk >= 2) { 639 640 printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); 640 641 printk("HPFS: warning: terminating balancing operation\n"); ··· 648 649 } 649 650 del->length += 4; 650 651 del->down = 1; 651 - d1->first_free += 4; 652 + d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); 652 653 } 653 654 if (dlp && !down) { 654 655 del->length -= 4; 655 656 del->down = 0; 656 - d1->first_free -= 4; 657 + d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); 657 658 } else if (down) 658 659 *(dnode_secno *) ((void *) del + del->length - 4) = down; 659 660 } else goto endm; ··· 669 670 if (!de_prev->down) { 670 671 de_prev->length += 4; 671 672 de_prev->down = 1; 672 - dnode->first_free += 4; 673 + dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); 673 674 } 674 675 *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; 675 676 hpfs_mark_4buffers_dirty(&qbh); ··· 700 701 { 701 702 struct dnode *dnode = qbh->data; 702 703 dnode_secno down = 0; 703 - int lock = 0; 704 704 loff_t t; 705 705 if (de->first || de->last) { 706 706 hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); ··· 708 710 } 709 711 if (de->down) down = de_down_pointer(de); 710 712 if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { 711 - lock = 1; 712 - hpfs_lock_creation(i->i_sb); 713 713 if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { 714 714 hpfs_brelse4(qbh); 715 - hpfs_unlock_creation(i->i_sb); 716 715 return 2; 717 716 } 718 717 } ··· 722 727 dnode_secno a = move_to_top(i, down, dno); 723 728 for_all_poss(i, hpfs_pos_subst, 5, t); 724 729 if (a) delete_empty_dnode(i, a); 725 - if (lock) hpfs_unlock_creation(i->i_sb); 726 730 return !a; 727 731 } 728 732 delete_empty_dnode(i, dno); 729 - if (lock) hpfs_unlock_creation(i->i_sb); 730 733 return 0; 731 734 } 732 735
+3 -3
fs/hpfs/ea.c
··· 266 266 secno n; 267 267 struct buffer_head *bh; 268 268 char *data; 269 - if (!(n = hpfs_alloc_sector(s, fno, 1, 0, 1))) return; 269 + if (!(n = hpfs_alloc_sector(s, fno, 1, 0))) return; 270 270 if (!(data = hpfs_get_sector(s, n, &bh))) { 271 271 hpfs_free_sectors(s, n, 1); 272 272 return; ··· 284 284 if (pos >= 30000) goto bail; 285 285 while (((pos + 511) >> 9) > len) { 286 286 if (!len) { 287 - if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0, 1))) 287 + if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0))) 288 288 goto bail; 289 289 fnode->ea_anode = 0; 290 290 len++; ··· 312 312 fnode->ea_secno = a_s;*/ 313 313 secno new_sec; 314 314 int i; 315 - if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9), 1))) 315 + if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9)))) 316 316 goto bail; 317 317 for (i = 0; i < len; i++) { 318 318 struct buffer_head *bh1, *bh2;
+3 -9
fs/hpfs/hpfs_fn.h
··· 56 56 unsigned i_ea_uid : 1; /* file's uid is stored in ea */ 57 57 unsigned i_ea_gid : 1; /* file's gid is stored in ea */ 58 58 unsigned i_dirty : 1; 59 - struct mutex i_mutex; 60 - struct mutex i_parent_mutex; 61 59 loff_t **i_rddir_off; 62 60 struct inode vfs_inode; 63 61 }; ··· 86 88 unsigned *sb_bmp_dir; /* main bitmap directory */ 87 89 unsigned sb_c_bitmap; /* current bitmap */ 88 90 unsigned sb_max_fwd_alloc; /* max forwad allocation */ 89 - struct mutex hpfs_creation_de; /* when creating dirents, nobody else 90 - can alloc blocks */ 91 91 /*unsigned sb_mounting : 1;*/ 92 92 int sb_timeshift; 93 93 }; ··· 197 201 /* alloc.c */ 198 202 199 203 int hpfs_chk_sectors(struct super_block *, secno, int, char *); 200 - secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int, int); 204 + secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int); 201 205 int hpfs_alloc_if_possible(struct super_block *, secno); 202 206 void hpfs_free_sectors(struct super_block *, secno, unsigned); 203 207 int hpfs_check_free_dnodes(struct super_block *, int); 204 208 void hpfs_free_dnode(struct super_block *, secno); 205 - struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *, int); 209 + struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *); 206 210 struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); 207 211 struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); 208 212 ··· 219 223 220 224 /* buffer.c */ 221 225 222 - void hpfs_lock_creation(struct super_block *); 223 - void hpfs_unlock_creation(struct super_block *); 224 226 void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); 225 227 void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); 226 228 void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); ··· 242 248 struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, 243 249 const unsigned char *, unsigned, secno); 244 250 int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, 245 - struct hpfs_dirent *, int); 251 + struct hpfs_dirent *); 246 252 int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); 247 253 void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); 248 254 dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno);
-5
fs/hpfs/inode.c
··· 187 187 kfree(hpfs_inode->i_rddir_off); 188 188 hpfs_inode->i_rddir_off = NULL; 189 189 } 190 - mutex_lock(&hpfs_inode->i_parent_mutex); 191 190 if (!i->i_nlink) { 192 - mutex_unlock(&hpfs_inode->i_parent_mutex); 193 191 return; 194 192 } 195 193 parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); ··· 198 200 hpfs_read_inode(parent); 199 201 unlock_new_inode(parent); 200 202 } 201 - mutex_lock(&hpfs_inode->i_mutex); 202 203 hpfs_write_inode_nolock(i); 203 - mutex_unlock(&hpfs_inode->i_mutex); 204 204 iput(parent); 205 205 } else { 206 206 mark_inode_dirty(i); 207 207 } 208 - mutex_unlock(&hpfs_inode->i_parent_mutex); 209 208 } 210 209 211 210 void hpfs_write_inode_nolock(struct inode *i)
+7 -46
fs/hpfs/namei.c
··· 29 29 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); 30 30 if (!fnode) 31 31 goto bail; 32 - dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); 32 + dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0); 33 33 if (!dnode) 34 34 goto bail1; 35 35 memset(&dee, 0, sizeof dee); ··· 60 60 if (dee.read_only) 61 61 result->i_mode &= ~0222; 62 62 63 - mutex_lock(&hpfs_i(dir)->i_mutex); 64 - r = hpfs_add_dirent(dir, name, len, &dee, 0); 63 + r = hpfs_add_dirent(dir, name, len, &dee); 65 64 if (r == 1) 66 65 goto bail3; 67 66 if (r == -1) { ··· 100 101 hpfs_write_inode_nolock(result); 101 102 } 102 103 d_instantiate(dentry, result); 103 - mutex_unlock(&hpfs_i(dir)->i_mutex); 104 104 hpfs_unlock(dir->i_sb); 105 105 return 0; 106 106 bail3: 107 - mutex_unlock(&hpfs_i(dir)->i_mutex); 108 107 iput(result); 109 108 bail2: 110 109 hpfs_brelse4(&qbh0); ··· 165 168 result->i_data.a_ops = &hpfs_aops; 166 169 hpfs_i(result)->mmu_private = 0; 167 170 168 - mutex_lock(&hpfs_i(dir)->i_mutex); 169 - r = hpfs_add_dirent(dir, name, len, &dee, 0); 171 + r = hpfs_add_dirent(dir, name, len, &dee); 170 172 if (r == 1) 171 173 goto bail2; 172 174 if (r == -1) { ··· 189 193 hpfs_write_inode_nolock(result); 190 194 } 191 195 d_instantiate(dentry, result); 192 - mutex_unlock(&hpfs_i(dir)->i_mutex); 193 196 hpfs_unlock(dir->i_sb); 194 197 return 0; 195 198 196 199 bail2: 197 - mutex_unlock(&hpfs_i(dir)->i_mutex); 198 200 iput(result); 199 201 bail1: 200 202 brelse(bh); ··· 248 254 result->i_blocks = 1; 249 255 init_special_inode(result, mode, rdev); 250 256 251 - mutex_lock(&hpfs_i(dir)->i_mutex); 252 - r = hpfs_add_dirent(dir, name, len, &dee, 0); 257 + r = hpfs_add_dirent(dir, name, len, &dee); 253 258 if (r == 1) 254 259 goto bail2; 255 260 if (r == -1) { ··· 264 271 265 272 hpfs_write_inode_nolock(result); 266 273 d_instantiate(dentry, result); 267 - mutex_unlock(&hpfs_i(dir)->i_mutex); 268 274 brelse(bh); 269 275 hpfs_unlock(dir->i_sb); 270 276 return 0; 271 277 bail2: 272 - mutex_unlock(&hpfs_i(dir)->i_mutex); 273 278 iput(result); 274 279 bail1: 275 280 brelse(bh); ··· 324 333 result->i_op = &page_symlink_inode_operations; 325 334 result->i_data.a_ops = &hpfs_symlink_aops; 326 335 327 - mutex_lock(&hpfs_i(dir)->i_mutex); 328 - r = hpfs_add_dirent(dir, name, len, &dee, 0); 336 + r = hpfs_add_dirent(dir, name, len, &dee); 329 337 if (r == 1) 330 338 goto bail2; 331 339 if (r == -1) { ··· 342 352 343 353 hpfs_write_inode_nolock(result); 344 354 d_instantiate(dentry, result); 345 - mutex_unlock(&hpfs_i(dir)->i_mutex); 346 355 hpfs_unlock(dir->i_sb); 347 356 return 0; 348 357 bail2: 349 - mutex_unlock(&hpfs_i(dir)->i_mutex); 350 358 iput(result); 351 359 bail1: 352 360 brelse(bh); ··· 370 382 hpfs_lock(dir->i_sb); 371 383 hpfs_adjust_length(name, &len); 372 384 again: 373 - mutex_lock(&hpfs_i(inode)->i_parent_mutex); 374 - mutex_lock(&hpfs_i(dir)->i_mutex); 375 385 err = -ENOENT; 376 386 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); 377 387 if (!de) ··· 396 410 if (rep++) 397 411 break; 398 412 399 - mutex_unlock(&hpfs_i(dir)->i_mutex); 400 - mutex_unlock(&hpfs_i(inode)->i_parent_mutex); 401 413 dentry_unhash(dentry); 402 414 if (!d_unhashed(dentry)) { 403 415 dput(dentry); ··· 429 445 out1: 430 446 hpfs_brelse4(&qbh); 431 447 out: 432 - mutex_unlock(&hpfs_i(dir)->i_mutex); 433 - mutex_unlock(&hpfs_i(inode)->i_parent_mutex); 434 448 hpfs_unlock(dir->i_sb); 435 449 return err; 436 450 } ··· 448 466 449 467 hpfs_adjust_length(name, &len); 450 468 hpfs_lock(dir->i_sb); 451 - mutex_lock(&hpfs_i(inode)->i_parent_mutex); 452 - mutex_lock(&hpfs_i(dir)->i_mutex); 453 469 err = -ENOENT; 454 470 de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); 455 471 if (!de) ··· 485 505 out1: 486 506 hpfs_brelse4(&qbh); 487 507 out: 488 - mutex_unlock(&hpfs_i(dir)->i_mutex); 489 - mutex_unlock(&hpfs_i(inode)->i_parent_mutex); 490 508 hpfs_unlock(dir->i_sb); 491 509 return err; 492 510 } ··· 546 568 547 569 hpfs_lock(i->i_sb); 548 570 /* order doesn't matter, due to VFS exclusion */ 549 - mutex_lock(&hpfs_i(i)->i_parent_mutex); 550 - if (new_inode) 551 - mutex_lock(&hpfs_i(new_inode)->i_parent_mutex); 552 - mutex_lock(&hpfs_i(old_dir)->i_mutex); 553 - if (new_dir != old_dir) 554 - mutex_lock(&hpfs_i(new_dir)->i_mutex); 555 571 556 572 /* Erm? Moving over the empty non-busy directory is perfectly legal */ 557 573 if (new_inode && S_ISDIR(new_inode->i_mode)) { ··· 582 610 583 611 if (new_dir == old_dir) hpfs_brelse4(&qbh); 584 612 585 - hpfs_lock_creation(i->i_sb); 586 - if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) { 587 - hpfs_unlock_creation(i->i_sb); 613 + if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) { 588 614 if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); 589 615 err = r == 1 ? -ENOSPC : -EFSERROR; 590 616 if (new_dir != old_dir) hpfs_brelse4(&qbh); ··· 591 621 592 622 if (new_dir == old_dir) 593 623 if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { 594 - hpfs_unlock_creation(i->i_sb); 595 624 hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); 596 625 err = -ENOENT; 597 626 goto end1; 598 627 } 599 628 600 629 if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { 601 - hpfs_unlock_creation(i->i_sb); 602 630 hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); 603 631 err = r == 2 ? -ENOSPC : -EFSERROR; 604 632 goto end1; 605 633 } 606 - hpfs_unlock_creation(i->i_sb); 607 - 634 + 608 635 end: 609 636 hpfs_i(i)->i_parent_dir = new_dir->i_ino; 610 637 if (S_ISDIR(i->i_mode)) { ··· 619 652 hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; 620 653 hpfs_decide_conv(i, new_name, new_len); 621 654 end1: 622 - if (old_dir != new_dir) 623 - mutex_unlock(&hpfs_i(new_dir)->i_mutex); 624 - mutex_unlock(&hpfs_i(old_dir)->i_mutex); 625 - mutex_unlock(&hpfs_i(i)->i_parent_mutex); 626 - if (new_inode) 627 - mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); 628 655 hpfs_unlock(i->i_sb); 629 656 return err; 630 657 }
-4
fs/hpfs/super.c
··· 191 191 { 192 192 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 193 193 194 - mutex_init(&ei->i_mutex); 195 - mutex_init(&ei->i_parent_mutex); 196 194 inode_init_once(&ei->vfs_inode); 197 195 } 198 196 ··· 493 495 494 496 mutex_init(&sbi->hpfs_mutex); 495 497 hpfs_lock(s); 496 - 497 - mutex_init(&sbi->hpfs_creation_de); 498 498 499 499 uid = current_uid(); 500 500 gid = current_gid();