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/dnode.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/dnode.c')
-rw-r--r-- | fs/hpfs/dnode.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 9b2ffadfc8c4..07711c392f8b 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -145,9 +145,10 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
145 | } | 145 | } |
146 | } | 146 | } |
147 | if (ptr) { | 147 | if (ptr) { |
148 | if ((d->first_free += 4) > 2048) { | 148 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); |
149 | hpfs_error(s,"set_last_pointer: too long dnode %08x", d->self); | 149 | if (le32_to_cpu(d->first_free) > 2048) { |
150 | d->first_free -= 4; | 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 | return; | 152 | return; |
152 | } | 153 | } |
153 | de->length = 36; | 154 | de->length = 36; |
@@ -184,7 +185,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
184 | de->not_8x3 = hpfs_is_name_long(name, namelen); | 185 | de->not_8x3 = hpfs_is_name_long(name, namelen); |
185 | de->namelen = namelen; | 186 | de->namelen = namelen; |
186 | memcpy(de->name, name, namelen); | 187 | memcpy(de->name, name, namelen); |
187 | d->first_free += d_size; | 188 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + d_size); |
188 | return de; | 189 | return de; |
189 | } | 190 | } |
190 | 191 | ||
@@ -197,8 +198,8 @@ static void hpfs_delete_de(struct super_block *s, struct dnode *d, | |||
197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); | 198 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); |
198 | return; | 199 | return; |
199 | } | 200 | } |
200 | d->first_free -= de->length; | 201 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - de->length); |
201 | memmove(de, de_next_de(de), d->first_free + (char *)d - (char *)de); | 202 | memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); |
202 | } | 203 | } |
203 | 204 | ||
204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) | 205 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) |
@@ -262,7 +263,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
262 | kfree(nname); | 263 | kfree(nname); |
263 | return 1; | 264 | return 1; |
264 | } | 265 | } |
265 | if (d->first_free + de_size(namelen, down_ptr) <= 2048) { | 266 | if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) { |
266 | loff_t t; | 267 | loff_t t; |
267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); | 268 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); |
268 | t = get_pos(d, de); | 269 | t = get_pos(d, de); |
@@ -286,11 +287,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
286 | kfree(nname); | 287 | kfree(nname); |
287 | return 1; | 288 | return 1; |
288 | } | 289 | } |
289 | memcpy(nd, d, d->first_free); | 290 | memcpy(nd, d, le32_to_cpu(d->first_free)); |
290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); | 291 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); |
291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); | 292 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); |
292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; | 293 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; |
293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1, 0))) { | 294 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1))) { |
294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 295 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
295 | hpfs_brelse4(&qbh); | 296 | hpfs_brelse4(&qbh); |
296 | kfree(nd); | 297 | kfree(nd); |
@@ -313,9 +314,9 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
313 | down_ptr = adno; | 314 | down_ptr = adno; |
314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); | 315 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); |
315 | de = de_next_de(de); | 316 | de = de_next_de(de); |
316 | memmove((char *)nd + 20, de, nd->first_free + (char *)nd - (char *)de); | 317 | memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); |
317 | nd->first_free -= (char *)de - (char *)nd - 20; | 318 | nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - (char *)de - (char *)nd - 20); |
318 | memcpy(d, nd, nd->first_free); | 319 | memcpy(d, nd, le32_to_cpu(nd->first_free)); |
319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); | 320 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); |
320 | fix_up_ptrs(i->i_sb, ad); | 321 | fix_up_ptrs(i->i_sb, ad); |
321 | if (!d->root_dnode) { | 322 | if (!d->root_dnode) { |
@@ -326,7 +327,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
326 | hpfs_brelse4(&qbh1); | 327 | hpfs_brelse4(&qbh1); |
327 | goto go_up; | 328 | goto go_up; |
328 | } | 329 | } |
329 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2, 0))) { | 330 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2))) { |
330 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 331 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
331 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
332 | hpfs_brelse4(&qbh1); | 333 | hpfs_brelse4(&qbh1); |
@@ -373,7 +374,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
373 | 374 | ||
374 | int hpfs_add_dirent(struct inode *i, | 375 | int hpfs_add_dirent(struct inode *i, |
375 | const unsigned char *name, unsigned namelen, | 376 | const unsigned char *name, unsigned namelen, |
376 | struct hpfs_dirent *new_de, int cdepth) | 377 | struct hpfs_dirent *new_de) |
377 | { | 378 | { |
378 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 379 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
379 | struct dnode *d; | 380 | struct dnode *d; |
@@ -403,7 +404,6 @@ int hpfs_add_dirent(struct inode *i, | |||
403 | } | 404 | } |
404 | } | 405 | } |
405 | hpfs_brelse4(&qbh); | 406 | hpfs_brelse4(&qbh); |
406 | if (!cdepth) hpfs_lock_creation(i->i_sb); | ||
407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { | 407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { |
408 | c = 1; | 408 | c = 1; |
409 | goto ret; | 409 | goto ret; |
@@ -411,7 +411,6 @@ int hpfs_add_dirent(struct inode *i, | |||
411 | i->i_version++; | 411 | i->i_version++; |
412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); | 412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); |
413 | ret: | 413 | ret: |
414 | if (!cdepth) hpfs_unlock_creation(i->i_sb); | ||
415 | return c; | 414 | return c; |
416 | } | 415 | } |
417 | 416 | ||
@@ -474,7 +473,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
474 | hpfs_brelse4(&qbh); | 473 | hpfs_brelse4(&qbh); |
475 | return 0; | 474 | return 0; |
476 | } | 475 | } |
477 | dnode->first_free -= 4; | 476 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
478 | de->length -= 4; | 477 | de->length -= 4; |
479 | de->down = 0; | 478 | de->down = 0; |
480 | hpfs_mark_4buffers_dirty(&qbh); | 479 | hpfs_mark_4buffers_dirty(&qbh); |
@@ -517,8 +516,8 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
517 | try_it_again: | 516 | try_it_again: |
518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; | 517 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; |
519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; | 518 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; |
520 | if (dnode->first_free > 56) goto end; | 519 | if (le32_to_cpu(dnode->first_free) > 56) goto end; |
521 | if (dnode->first_free == 52 || dnode->first_free == 56) { | 520 | if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { |
522 | struct hpfs_dirent *de_end; | 521 | struct hpfs_dirent *de_end; |
523 | int root = dnode->root_dnode; | 522 | int root = dnode->root_dnode; |
524 | up = dnode->up; | 523 | up = dnode->up; |
@@ -571,9 +570,9 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
571 | if (!down) { | 570 | if (!down) { |
572 | de->down = 0; | 571 | de->down = 0; |
573 | de->length -= 4; | 572 | de->length -= 4; |
574 | dnode->first_free -= 4; | 573 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, | 574 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, |
576 | (char *)dnode + dnode->first_free - (char *)de_next_de(de)); | 575 | (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); |
577 | } else { | 576 | } else { |
578 | struct dnode *d1; | 577 | struct dnode *d1; |
579 | struct quad_buffer_head qbh1; | 578 | struct quad_buffer_head qbh1; |
@@ -585,7 +584,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
585 | } | 584 | } |
586 | } | 585 | } |
587 | } else { | 586 | } else { |
588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, dnode->first_free); | 587 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free)); |
589 | goto end; | 588 | goto end; |
590 | } | 589 | } |
591 | 590 | ||
@@ -635,7 +634,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
635 | struct hpfs_dirent *del = dnode_last_de(d1); | 634 | struct hpfs_dirent *del = dnode_last_de(d1); |
636 | dlp = del->down ? de_down_pointer(del) : 0; | 635 | dlp = del->down ? de_down_pointer(del) : 0; |
637 | if (!dlp && down) { | 636 | if (!dlp && down) { |
638 | if (d1->first_free > 2044) { | 637 | if (le32_to_cpu(d1->first_free) > 2044) { |
639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 638 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 639 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
641 | printk("HPFS: warning: terminating balancing operation\n"); | 640 | printk("HPFS: warning: terminating balancing operation\n"); |
@@ -649,12 +648,12 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
649 | } | 648 | } |
650 | del->length += 4; | 649 | del->length += 4; |
651 | del->down = 1; | 650 | del->down = 1; |
652 | d1->first_free += 4; | 651 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); |
653 | } | 652 | } |
654 | if (dlp && !down) { | 653 | if (dlp && !down) { |
655 | del->length -= 4; | 654 | del->length -= 4; |
656 | del->down = 0; | 655 | del->down = 0; |
657 | d1->first_free -= 4; | 656 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); |
658 | } else if (down) | 657 | } else if (down) |
659 | *(dnode_secno *) ((void *) del + del->length - 4) = down; | 658 | *(dnode_secno *) ((void *) del + del->length - 4) = down; |
660 | } else goto endm; | 659 | } else goto endm; |
@@ -670,7 +669,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
670 | if (!de_prev->down) { | 669 | if (!de_prev->down) { |
671 | de_prev->length += 4; | 670 | de_prev->length += 4; |
672 | de_prev->down = 1; | 671 | de_prev->down = 1; |
673 | dnode->first_free += 4; | 672 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); |
674 | } | 673 | } |
675 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; | 674 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; |
676 | hpfs_mark_4buffers_dirty(&qbh); | 675 | hpfs_mark_4buffers_dirty(&qbh); |
@@ -701,7 +700,6 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
701 | { | 700 | { |
702 | struct dnode *dnode = qbh->data; | 701 | struct dnode *dnode = qbh->data; |
703 | dnode_secno down = 0; | 702 | dnode_secno down = 0; |
704 | int lock = 0; | ||
705 | loff_t t; | 703 | loff_t t; |
706 | if (de->first || de->last) { | 704 | if (de->first || de->last) { |
707 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); | 705 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); |
@@ -710,11 +708,8 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
710 | } | 708 | } |
711 | if (de->down) down = de_down_pointer(de); | 709 | if (de->down) down = de_down_pointer(de); |
712 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { | 710 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { |
713 | lock = 1; | ||
714 | hpfs_lock_creation(i->i_sb); | ||
715 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { | 711 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { |
716 | hpfs_brelse4(qbh); | 712 | hpfs_brelse4(qbh); |
717 | hpfs_unlock_creation(i->i_sb); | ||
718 | return 2; | 713 | return 2; |
719 | } | 714 | } |
720 | } | 715 | } |
@@ -727,11 +722,9 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
727 | dnode_secno a = move_to_top(i, down, dno); | 722 | dnode_secno a = move_to_top(i, down, dno); |
728 | for_all_poss(i, hpfs_pos_subst, 5, t); | 723 | for_all_poss(i, hpfs_pos_subst, 5, t); |
729 | if (a) delete_empty_dnode(i, a); | 724 | if (a) delete_empty_dnode(i, a); |
730 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
731 | return !a; | 725 | return !a; |
732 | } | 726 | } |
733 | delete_empty_dnode(i, dno); | 727 | delete_empty_dnode(i, dno); |
734 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
735 | return 0; | 728 | return 0; |
736 | } | 729 | } |
737 | 730 | ||