diff options
Diffstat (limited to 'fs/ufs/balloc.c')
-rw-r--r-- | fs/ufs/balloc.c | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 343eaf4542f8..7a4735f591bc 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c | |||
@@ -21,14 +21,6 @@ | |||
21 | #include "swab.h" | 21 | #include "swab.h" |
22 | #include "util.h" | 22 | #include "util.h" |
23 | 23 | ||
24 | #undef UFS_BALLOC_DEBUG | ||
25 | |||
26 | #ifdef UFS_BALLOC_DEBUG | ||
27 | #define UFSD(x) printk("(%s, %d), %s:", __FILE__, __LINE__, __FUNCTION__); printk x; | ||
28 | #else | ||
29 | #define UFSD(x) | ||
30 | #endif | ||
31 | |||
32 | static unsigned ufs_add_fragments (struct inode *, unsigned, unsigned, unsigned, int *); | 24 | static unsigned ufs_add_fragments (struct inode *, unsigned, unsigned, unsigned, int *); |
33 | static unsigned ufs_alloc_fragments (struct inode *, unsigned, unsigned, unsigned, int *); | 25 | static unsigned ufs_alloc_fragments (struct inode *, unsigned, unsigned, unsigned, int *); |
34 | static unsigned ufs_alloccg_block (struct inode *, struct ufs_cg_private_info *, unsigned, int *); | 26 | static unsigned ufs_alloccg_block (struct inode *, struct ufs_cg_private_info *, unsigned, int *); |
@@ -52,7 +44,7 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count) | |||
52 | uspi = UFS_SB(sb)->s_uspi; | 44 | uspi = UFS_SB(sb)->s_uspi; |
53 | usb1 = ubh_get_usb_first(uspi); | 45 | usb1 = ubh_get_usb_first(uspi); |
54 | 46 | ||
55 | UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) | 47 | UFSD("ENTER, fragment %u, count %u\n", fragment, count); |
56 | 48 | ||
57 | if (ufs_fragnum(fragment) + count > uspi->s_fpg) | 49 | if (ufs_fragnum(fragment) + count > uspi->s_fpg) |
58 | ufs_error (sb, "ufs_free_fragments", "internal error"); | 50 | ufs_error (sb, "ufs_free_fragments", "internal error"); |
@@ -123,12 +115,12 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count) | |||
123 | sb->s_dirt = 1; | 115 | sb->s_dirt = 1; |
124 | 116 | ||
125 | unlock_super (sb); | 117 | unlock_super (sb); |
126 | UFSD(("EXIT\n")) | 118 | UFSD("EXIT\n"); |
127 | return; | 119 | return; |
128 | 120 | ||
129 | failed: | 121 | failed: |
130 | unlock_super (sb); | 122 | unlock_super (sb); |
131 | UFSD(("EXIT (FAILED)\n")) | 123 | UFSD("EXIT (FAILED)\n"); |
132 | return; | 124 | return; |
133 | } | 125 | } |
134 | 126 | ||
@@ -148,7 +140,7 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count) | |||
148 | uspi = UFS_SB(sb)->s_uspi; | 140 | uspi = UFS_SB(sb)->s_uspi; |
149 | usb1 = ubh_get_usb_first(uspi); | 141 | usb1 = ubh_get_usb_first(uspi); |
150 | 142 | ||
151 | UFSD(("ENTER, fragment %u, count %u\n", fragment, count)) | 143 | UFSD("ENTER, fragment %u, count %u\n", fragment, count); |
152 | 144 | ||
153 | if ((fragment & uspi->s_fpbmask) || (count & uspi->s_fpbmask)) { | 145 | if ((fragment & uspi->s_fpbmask) || (count & uspi->s_fpbmask)) { |
154 | ufs_error (sb, "ufs_free_blocks", "internal error, " | 146 | ufs_error (sb, "ufs_free_blocks", "internal error, " |
@@ -215,12 +207,12 @@ do_more: | |||
215 | 207 | ||
216 | sb->s_dirt = 1; | 208 | sb->s_dirt = 1; |
217 | unlock_super (sb); | 209 | unlock_super (sb); |
218 | UFSD(("EXIT\n")) | 210 | UFSD("EXIT\n"); |
219 | return; | 211 | return; |
220 | 212 | ||
221 | failed: | 213 | failed: |
222 | unlock_super (sb); | 214 | unlock_super (sb); |
223 | UFSD(("EXIT (FAILED)\n")) | 215 | UFSD("EXIT (FAILED)\n"); |
224 | return; | 216 | return; |
225 | } | 217 | } |
226 | 218 | ||
@@ -290,8 +282,8 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int count, | |||
290 | 282 | ||
291 | baseblk = ((i_size_read(inode) - 1) >> inode->i_blkbits) + 1 - count; | 283 | baseblk = ((i_size_read(inode) - 1) >> inode->i_blkbits) + 1 - count; |
292 | 284 | ||
293 | UFSD(("ENTER, ino %lu, count %u, oldb %u, newb %u\n", | 285 | UFSD("ENTER, ino %lu, count %u, oldb %u, newb %u\n", |
294 | inode->i_ino, count, oldb, newb)); | 286 | inode->i_ino, count, oldb, newb); |
295 | 287 | ||
296 | BUG_ON(!PageLocked(locked_page)); | 288 | BUG_ON(!PageLocked(locked_page)); |
297 | 289 | ||
@@ -326,7 +318,7 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int count, | |||
326 | page_cache_release(page); | 318 | page_cache_release(page); |
327 | } | 319 | } |
328 | } | 320 | } |
329 | UFSD(("EXIT\n")); | 321 | UFSD("EXIT\n"); |
330 | } | 322 | } |
331 | 323 | ||
332 | unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | 324 | unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, |
@@ -337,7 +329,7 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
337 | struct ufs_super_block_first * usb1; | 329 | struct ufs_super_block_first * usb1; |
338 | unsigned cgno, oldcount, newcount, tmp, request, result; | 330 | unsigned cgno, oldcount, newcount, tmp, request, result; |
339 | 331 | ||
340 | UFSD(("ENTER, ino %lu, fragment %u, goal %u, count %u\n", inode->i_ino, fragment, goal, count)) | 332 | UFSD("ENTER, ino %lu, fragment %u, goal %u, count %u\n", inode->i_ino, fragment, goal, count); |
341 | 333 | ||
342 | sb = inode->i_sb; | 334 | sb = inode->i_sb; |
343 | uspi = UFS_SB(sb)->s_uspi; | 335 | uspi = UFS_SB(sb)->s_uspi; |
@@ -366,14 +358,14 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
366 | return (unsigned)-1; | 358 | return (unsigned)-1; |
367 | } | 359 | } |
368 | if (fragment < UFS_I(inode)->i_lastfrag) { | 360 | if (fragment < UFS_I(inode)->i_lastfrag) { |
369 | UFSD(("EXIT (ALREADY ALLOCATED)\n")) | 361 | UFSD("EXIT (ALREADY ALLOCATED)\n"); |
370 | unlock_super (sb); | 362 | unlock_super (sb); |
371 | return 0; | 363 | return 0; |
372 | } | 364 | } |
373 | } | 365 | } |
374 | else { | 366 | else { |
375 | if (tmp) { | 367 | if (tmp) { |
376 | UFSD(("EXIT (ALREADY ALLOCATED)\n")) | 368 | UFSD("EXIT (ALREADY ALLOCATED)\n"); |
377 | unlock_super(sb); | 369 | unlock_super(sb); |
378 | return 0; | 370 | return 0; |
379 | } | 371 | } |
@@ -384,7 +376,7 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
384 | */ | 376 | */ |
385 | if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(usb1, UFS_MINFREE) <= 0) { | 377 | if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(usb1, UFS_MINFREE) <= 0) { |
386 | unlock_super (sb); | 378 | unlock_super (sb); |
387 | UFSD(("EXIT (FAILED)\n")) | 379 | UFSD("EXIT (FAILED)\n"); |
388 | return 0; | 380 | return 0; |
389 | } | 381 | } |
390 | 382 | ||
@@ -407,7 +399,7 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
407 | UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); | 399 | UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); |
408 | } | 400 | } |
409 | unlock_super(sb); | 401 | unlock_super(sb); |
410 | UFSD(("EXIT, result %u\n", result)) | 402 | UFSD("EXIT, result %u\n", result); |
411 | return result; | 403 | return result; |
412 | } | 404 | } |
413 | 405 | ||
@@ -420,7 +412,7 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
420 | inode->i_blocks += count << uspi->s_nspfshift; | 412 | inode->i_blocks += count << uspi->s_nspfshift; |
421 | UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); | 413 | UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); |
422 | unlock_super(sb); | 414 | unlock_super(sb); |
423 | UFSD(("EXIT, result %u\n", result)) | 415 | UFSD("EXIT, result %u\n", result); |
424 | return result; | 416 | return result; |
425 | } | 417 | } |
426 | 418 | ||
@@ -458,12 +450,12 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, | |||
458 | if (newcount < request) | 450 | if (newcount < request) |
459 | ufs_free_fragments (inode, result + newcount, request - newcount); | 451 | ufs_free_fragments (inode, result + newcount, request - newcount); |
460 | ufs_free_fragments (inode, tmp, oldcount); | 452 | ufs_free_fragments (inode, tmp, oldcount); |
461 | UFSD(("EXIT, result %u\n", result)) | 453 | UFSD("EXIT, result %u\n", result); |
462 | return result; | 454 | return result; |
463 | } | 455 | } |
464 | 456 | ||
465 | unlock_super(sb); | 457 | unlock_super(sb); |
466 | UFSD(("EXIT (FAILED)\n")) | 458 | UFSD("EXIT (FAILED)\n"); |
467 | return 0; | 459 | return 0; |
468 | } | 460 | } |
469 | 461 | ||
@@ -478,7 +470,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, | |||
478 | struct ufs_cylinder_group * ucg; | 470 | struct ufs_cylinder_group * ucg; |
479 | unsigned cgno, fragno, fragoff, count, fragsize, i; | 471 | unsigned cgno, fragno, fragoff, count, fragsize, i; |
480 | 472 | ||
481 | UFSD(("ENTER, fragment %u, oldcount %u, newcount %u\n", fragment, oldcount, newcount)) | 473 | UFSD("ENTER, fragment %u, oldcount %u, newcount %u\n", fragment, oldcount, newcount); |
482 | 474 | ||
483 | sb = inode->i_sb; | 475 | sb = inode->i_sb; |
484 | uspi = UFS_SB(sb)->s_uspi; | 476 | uspi = UFS_SB(sb)->s_uspi; |
@@ -538,7 +530,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, | |||
538 | } | 530 | } |
539 | sb->s_dirt = 1; | 531 | sb->s_dirt = 1; |
540 | 532 | ||
541 | UFSD(("EXIT, fragment %u\n", fragment)) | 533 | UFSD("EXIT, fragment %u\n", fragment); |
542 | 534 | ||
543 | return fragment; | 535 | return fragment; |
544 | } | 536 | } |
@@ -561,7 +553,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, | |||
561 | struct ufs_cylinder_group * ucg; | 553 | struct ufs_cylinder_group * ucg; |
562 | unsigned oldcg, i, j, k, result, allocsize; | 554 | unsigned oldcg, i, j, k, result, allocsize; |
563 | 555 | ||
564 | UFSD(("ENTER, ino %lu, cgno %u, goal %u, count %u\n", inode->i_ino, cgno, goal, count)) | 556 | UFSD("ENTER, ino %lu, cgno %u, goal %u, count %u\n", inode->i_ino, cgno, goal, count); |
565 | 557 | ||
566 | sb = inode->i_sb; | 558 | sb = inode->i_sb; |
567 | uspi = UFS_SB(sb)->s_uspi; | 559 | uspi = UFS_SB(sb)->s_uspi; |
@@ -595,7 +587,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, | |||
595 | UFS_TEST_FREE_SPACE_CG | 587 | UFS_TEST_FREE_SPACE_CG |
596 | } | 588 | } |
597 | 589 | ||
598 | UFSD(("EXIT (FAILED)\n")) | 590 | UFSD("EXIT (FAILED)\n"); |
599 | return 0; | 591 | return 0; |
600 | 592 | ||
601 | cg_found: | 593 | cg_found: |
@@ -664,7 +656,7 @@ succed: | |||
664 | sb->s_dirt = 1; | 656 | sb->s_dirt = 1; |
665 | 657 | ||
666 | result += cgno * uspi->s_fpg; | 658 | result += cgno * uspi->s_fpg; |
667 | UFSD(("EXIT3, result %u\n", result)) | 659 | UFSD("EXIT3, result %u\n", result); |
668 | return result; | 660 | return result; |
669 | } | 661 | } |
670 | 662 | ||
@@ -677,7 +669,7 @@ static unsigned ufs_alloccg_block (struct inode * inode, | |||
677 | struct ufs_cylinder_group * ucg; | 669 | struct ufs_cylinder_group * ucg; |
678 | unsigned result, cylno, blkno; | 670 | unsigned result, cylno, blkno; |
679 | 671 | ||
680 | UFSD(("ENTER, goal %u\n", goal)) | 672 | UFSD("ENTER, goal %u\n", goal); |
681 | 673 | ||
682 | sb = inode->i_sb; | 674 | sb = inode->i_sb; |
683 | uspi = UFS_SB(sb)->s_uspi; | 675 | uspi = UFS_SB(sb)->s_uspi; |
@@ -721,7 +713,7 @@ gotit: | |||
721 | fs16_sub(sb, &ubh_cg_blks(ucpi, cylno, ufs_cbtorpos(result)), 1); | 713 | fs16_sub(sb, &ubh_cg_blks(ucpi, cylno, ufs_cbtorpos(result)), 1); |
722 | fs32_sub(sb, &ubh_cg_blktot(ucpi, cylno), 1); | 714 | fs32_sub(sb, &ubh_cg_blktot(ucpi, cylno), 1); |
723 | 715 | ||
724 | UFSD(("EXIT, result %u\n", result)) | 716 | UFSD("EXIT, result %u\n", result); |
725 | 717 | ||
726 | return result; | 718 | return result; |
727 | } | 719 | } |
@@ -781,7 +773,7 @@ static unsigned ufs_bitmap_search(struct super_block *sb, | |||
781 | unsigned start, length, loc, result; | 773 | unsigned start, length, loc, result; |
782 | unsigned pos, want, blockmap, mask, end; | 774 | unsigned pos, want, blockmap, mask, end; |
783 | 775 | ||
784 | UFSD(("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count)); | 776 | UFSD("ENTER, cg %u, goal %u, count %u\n", ucpi->c_cgx, goal, count); |
785 | 777 | ||
786 | usb1 = ubh_get_usb_first (uspi); | 778 | usb1 = ubh_get_usb_first (uspi); |
787 | ucg = ubh_get_ucg(UCPI_UBH(ucpi)); | 779 | ucg = ubh_get_ucg(UCPI_UBH(ucpi)); |
@@ -825,7 +817,7 @@ static unsigned ufs_bitmap_search(struct super_block *sb, | |||
825 | want = want_arr[count]; | 817 | want = want_arr[count]; |
826 | for (pos = 0; pos <= uspi->s_fpb - count; pos++) { | 818 | for (pos = 0; pos <= uspi->s_fpb - count; pos++) { |
827 | if ((blockmap & mask) == want) { | 819 | if ((blockmap & mask) == want) { |
828 | UFSD(("EXIT, result %u\n", result)); | 820 | UFSD("EXIT, result %u\n", result); |
829 | return result + pos; | 821 | return result + pos; |
830 | } | 822 | } |
831 | mask <<= 1; | 823 | mask <<= 1; |
@@ -835,7 +827,7 @@ static unsigned ufs_bitmap_search(struct super_block *sb, | |||
835 | 827 | ||
836 | ufs_error(sb, "ufs_bitmap_search", "block not in map on cg %u\n", | 828 | ufs_error(sb, "ufs_bitmap_search", "block not in map on cg %u\n", |
837 | ucpi->c_cgx); | 829 | ucpi->c_cgx); |
838 | UFSD(("EXIT (FAILED)\n")); | 830 | UFSD("EXIT (FAILED)\n"); |
839 | return (unsigned)-1; | 831 | return (unsigned)-1; |
840 | } | 832 | } |
841 | 833 | ||