aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs
diff options
context:
space:
mode:
authorEvgeniy Dushistov <dushistov@mail.ru>2006-06-25 08:47:22 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:02 -0400
commit9695ef16ed4e00b59303f39f9a4a422a2c6a3b89 (patch)
treefba8946e86a523a5d53936cf5ec9e0a150037f73 /fs/ufs
parentb71034e5e67d1577424cebe7bbb7d0ce134a4cd8 (diff)
[PATCH] ufs: wrong type cast
There are two ugly macros in ufs code: #define UCPI_UBH ((struct ufs_buffer_head *)ucpi) #define USPI_UBH ((struct ufs_buffer_head *)uspi) when uspi looks like struct { struct ufs_buffer_head ; } and USPI_UBH has some sence, ucpi looks like struct { struct not_ufs_buffer_head; } To prevent bugs in future, this patch convert macros to inline function and fix "ucpi" structure. Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/balloc.c84
-rw-r--r--fs/ufs/cylinder.c18
-rw-r--r--fs/ufs/ialloc.c28
-rw-r--r--fs/ufs/super.c8
-rw-r--r--fs/ufs/util.c20
-rw-r--r--fs/ufs/util.h16
6 files changed, 90 insertions, 84 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index 06f970d02e3d..68de1312e4b6 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -69,7 +69,7 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
69 ucpi = ufs_load_cylinder (sb, cgno); 69 ucpi = ufs_load_cylinder (sb, cgno);
70 if (!ucpi) 70 if (!ucpi)
71 goto failed; 71 goto failed;
72 ucg = ubh_get_ucg (UCPI_UBH); 72 ucg = ubh_get_ucg (UCPI_UBH(ucpi));
73 if (!ufs_cg_chkmagic(sb, ucg)) { 73 if (!ufs_cg_chkmagic(sb, ucg)) {
74 ufs_panic (sb, "ufs_free_fragments", "internal error, bad magic number on cg %u", cgno); 74 ufs_panic (sb, "ufs_free_fragments", "internal error, bad magic number on cg %u", cgno);
75 goto failed; 75 goto failed;
@@ -77,11 +77,11 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
77 77
78 end_bit = bit + count; 78 end_bit = bit + count;
79 bbase = ufs_blknum (bit); 79 bbase = ufs_blknum (bit);
80 blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase); 80 blkmap = ubh_blkmap (UCPI_UBH(ucpi), ucpi->c_freeoff, bbase);
81 ufs_fragacct (sb, blkmap, ucg->cg_frsum, -1); 81 ufs_fragacct (sb, blkmap, ucg->cg_frsum, -1);
82 for (i = bit; i < end_bit; i++) { 82 for (i = bit; i < end_bit; i++) {
83 if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i)) 83 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, i))
84 ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i); 84 ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, i);
85 else 85 else
86 ufs_error (sb, "ufs_free_fragments", 86 ufs_error (sb, "ufs_free_fragments",
87 "bit already cleared for fragment %u", i); 87 "bit already cleared for fragment %u", i);
@@ -93,14 +93,14 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
93 fs32_add(sb, &ucg->cg_cs.cs_nffree, count); 93 fs32_add(sb, &ucg->cg_cs.cs_nffree, count);
94 fs32_add(sb, &usb1->fs_cstotal.cs_nffree, count); 94 fs32_add(sb, &usb1->fs_cstotal.cs_nffree, count);
95 fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); 95 fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count);
96 blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase); 96 blkmap = ubh_blkmap (UCPI_UBH(ucpi), ucpi->c_freeoff, bbase);
97 ufs_fragacct(sb, blkmap, ucg->cg_frsum, 1); 97 ufs_fragacct(sb, blkmap, ucg->cg_frsum, 1);
98 98
99 /* 99 /*
100 * Trying to reassemble free fragments into block 100 * Trying to reassemble free fragments into block
101 */ 101 */
102 blkno = ufs_fragstoblks (bbase); 102 blkno = ufs_fragstoblks (bbase);
103 if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) { 103 if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) {
104 fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); 104 fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb);
105 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, uspi->s_fpb); 105 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, uspi->s_fpb);
106 fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); 106 fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb);
@@ -114,11 +114,11 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
114 fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); 114 fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1);
115 } 115 }
116 116
117 ubh_mark_buffer_dirty (USPI_UBH); 117 ubh_mark_buffer_dirty (USPI_UBH(uspi));
118 ubh_mark_buffer_dirty (UCPI_UBH); 118 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
119 if (sb->s_flags & MS_SYNCHRONOUS) { 119 if (sb->s_flags & MS_SYNCHRONOUS) {
120 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); 120 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
121 ubh_wait_on_buffer (UCPI_UBH); 121 ubh_wait_on_buffer (UCPI_UBH(ucpi));
122 } 122 }
123 sb->s_dirt = 1; 123 sb->s_dirt = 1;
124 124
@@ -176,7 +176,7 @@ do_more:
176 ucpi = ufs_load_cylinder (sb, cgno); 176 ucpi = ufs_load_cylinder (sb, cgno);
177 if (!ucpi) 177 if (!ucpi)
178 goto failed; 178 goto failed;
179 ucg = ubh_get_ucg (UCPI_UBH); 179 ucg = ubh_get_ucg (UCPI_UBH(ucpi));
180 if (!ufs_cg_chkmagic(sb, ucg)) { 180 if (!ufs_cg_chkmagic(sb, ucg)) {
181 ufs_panic (sb, "ufs_free_blocks", "internal error, bad magic number on cg %u", cgno); 181 ufs_panic (sb, "ufs_free_blocks", "internal error, bad magic number on cg %u", cgno);
182 goto failed; 182 goto failed;
@@ -184,10 +184,10 @@ do_more:
184 184
185 for (i = bit; i < end_bit; i += uspi->s_fpb) { 185 for (i = bit; i < end_bit; i += uspi->s_fpb) {
186 blkno = ufs_fragstoblks(i); 186 blkno = ufs_fragstoblks(i);
187 if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) { 187 if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) {
188 ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); 188 ufs_error(sb, "ufs_free_blocks", "freeing free fragment");
189 } 189 }
190 ubh_setblock(UCPI_UBH, ucpi->c_freeoff, blkno); 190 ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
191 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) 191 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
192 ufs_clusteracct (sb, ucpi, blkno, 1); 192 ufs_clusteracct (sb, ucpi, blkno, 1);
193 DQUOT_FREE_BLOCK(inode, uspi->s_fpb); 193 DQUOT_FREE_BLOCK(inode, uspi->s_fpb);
@@ -200,11 +200,11 @@ do_more:
200 fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); 200 fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1);
201 } 201 }
202 202
203 ubh_mark_buffer_dirty (USPI_UBH); 203 ubh_mark_buffer_dirty (USPI_UBH(uspi));
204 ubh_mark_buffer_dirty (UCPI_UBH); 204 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
205 if (sb->s_flags & MS_SYNCHRONOUS) { 205 if (sb->s_flags & MS_SYNCHRONOUS) {
206 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); 206 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
207 ubh_wait_on_buffer (UCPI_UBH); 207 ubh_wait_on_buffer (UCPI_UBH(ucpi));
208 } 208 }
209 209
210 if (overflow) { 210 if (overflow) {
@@ -493,7 +493,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
493 ucpi = ufs_load_cylinder (sb, cgno); 493 ucpi = ufs_load_cylinder (sb, cgno);
494 if (!ucpi) 494 if (!ucpi)
495 return 0; 495 return 0;
496 ucg = ubh_get_ucg (UCPI_UBH); 496 ucg = ubh_get_ucg (UCPI_UBH(ucpi));
497 if (!ufs_cg_chkmagic(sb, ucg)) { 497 if (!ufs_cg_chkmagic(sb, ucg)) {
498 ufs_panic (sb, "ufs_add_fragments", 498 ufs_panic (sb, "ufs_add_fragments",
499 "internal error, bad magic number on cg %u", cgno); 499 "internal error, bad magic number on cg %u", cgno);
@@ -503,14 +503,14 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
503 fragno = ufs_dtogd (fragment); 503 fragno = ufs_dtogd (fragment);
504 fragoff = ufs_fragnum (fragno); 504 fragoff = ufs_fragnum (fragno);
505 for (i = oldcount; i < newcount; i++) 505 for (i = oldcount; i < newcount; i++)
506 if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, fragno + i)) 506 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
507 return 0; 507 return 0;
508 /* 508 /*
509 * Block can be extended 509 * Block can be extended
510 */ 510 */
511 ucg->cg_time = cpu_to_fs32(sb, get_seconds()); 511 ucg->cg_time = cpu_to_fs32(sb, get_seconds());
512 for (i = newcount; i < (uspi->s_fpb - fragoff); i++) 512 for (i = newcount; i < (uspi->s_fpb - fragoff); i++)
513 if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, fragno + i)) 513 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
514 break; 514 break;
515 fragsize = i - oldcount; 515 fragsize = i - oldcount;
516 if (!fs32_to_cpu(sb, ucg->cg_frsum[fragsize])) 516 if (!fs32_to_cpu(sb, ucg->cg_frsum[fragsize]))
@@ -520,7 +520,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
520 if (fragsize != count) 520 if (fragsize != count)
521 fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); 521 fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1);
522 for (i = oldcount; i < newcount; i++) 522 for (i = oldcount; i < newcount; i++)
523 ubh_clrbit (UCPI_UBH, ucpi->c_freeoff, fragno + i); 523 ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i);
524 if(DQUOT_ALLOC_BLOCK(inode, count)) { 524 if(DQUOT_ALLOC_BLOCK(inode, count)) {
525 *err = -EDQUOT; 525 *err = -EDQUOT;
526 return 0; 526 return 0;
@@ -530,11 +530,11 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
530 fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); 530 fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count);
531 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count); 531 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count);
532 532
533 ubh_mark_buffer_dirty (USPI_UBH); 533 ubh_mark_buffer_dirty (USPI_UBH(uspi));
534 ubh_mark_buffer_dirty (UCPI_UBH); 534 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
535 if (sb->s_flags & MS_SYNCHRONOUS) { 535 if (sb->s_flags & MS_SYNCHRONOUS) {
536 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); 536 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
537 ubh_wait_on_buffer (UCPI_UBH); 537 ubh_wait_on_buffer (UCPI_UBH(ucpi));
538 } 538 }
539 sb->s_dirt = 1; 539 sb->s_dirt = 1;
540 540
@@ -602,7 +602,7 @@ cg_found:
602 ucpi = ufs_load_cylinder (sb, cgno); 602 ucpi = ufs_load_cylinder (sb, cgno);
603 if (!ucpi) 603 if (!ucpi)
604 return 0; 604 return 0;
605 ucg = ubh_get_ucg (UCPI_UBH); 605 ucg = ubh_get_ucg (UCPI_UBH(ucpi));
606 if (!ufs_cg_chkmagic(sb, ucg)) 606 if (!ufs_cg_chkmagic(sb, ucg))
607 ufs_panic (sb, "ufs_alloc_fragments", 607 ufs_panic (sb, "ufs_alloc_fragments",
608 "internal error, bad magic number on cg %u", cgno); 608 "internal error, bad magic number on cg %u", cgno);
@@ -625,7 +625,7 @@ cg_found:
625 return 0; 625 return 0;
626 goal = ufs_dtogd (result); 626 goal = ufs_dtogd (result);
627 for (i = count; i < uspi->s_fpb; i++) 627 for (i = count; i < uspi->s_fpb; i++)
628 ubh_setbit (UCPI_UBH, ucpi->c_freeoff, goal + i); 628 ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i);
629 i = uspi->s_fpb - count; 629 i = uspi->s_fpb - count;
630 DQUOT_FREE_BLOCK(inode, i); 630 DQUOT_FREE_BLOCK(inode, i);
631 631
@@ -644,7 +644,7 @@ cg_found:
644 return 0; 644 return 0;
645 } 645 }
646 for (i = 0; i < count; i++) 646 for (i = 0; i < count; i++)
647 ubh_clrbit (UCPI_UBH, ucpi->c_freeoff, result + i); 647 ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, result + i);
648 648
649 fs32_sub(sb, &ucg->cg_cs.cs_nffree, count); 649 fs32_sub(sb, &ucg->cg_cs.cs_nffree, count);
650 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count); 650 fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count);
@@ -655,11 +655,11 @@ cg_found:
655 fs32_add(sb, &ucg->cg_frsum[allocsize - count], 1); 655 fs32_add(sb, &ucg->cg_frsum[allocsize - count], 1);
656 656
657succed: 657succed:
658 ubh_mark_buffer_dirty (USPI_UBH); 658 ubh_mark_buffer_dirty (USPI_UBH(uspi));
659 ubh_mark_buffer_dirty (UCPI_UBH); 659 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
660 if (sb->s_flags & MS_SYNCHRONOUS) { 660 if (sb->s_flags & MS_SYNCHRONOUS) {
661 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); 661 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
662 ubh_wait_on_buffer (UCPI_UBH); 662 ubh_wait_on_buffer (UCPI_UBH(ucpi));
663 } 663 }
664 sb->s_dirt = 1; 664 sb->s_dirt = 1;
665 665
@@ -682,7 +682,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
682 sb = inode->i_sb; 682 sb = inode->i_sb;
683 uspi = UFS_SB(sb)->s_uspi; 683 uspi = UFS_SB(sb)->s_uspi;
684 usb1 = ubh_get_usb_first(uspi); 684 usb1 = ubh_get_usb_first(uspi);
685 ucg = ubh_get_ucg(UCPI_UBH); 685 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
686 686
687 if (goal == 0) { 687 if (goal == 0) {
688 goal = ucpi->c_rotor; 688 goal = ucpi->c_rotor;
@@ -694,7 +694,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
694 /* 694 /*
695 * If the requested block is available, use it. 695 * If the requested block is available, use it.
696 */ 696 */
697 if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, ufs_fragstoblks(goal))) { 697 if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) {
698 result = goal; 698 result = goal;
699 goto gotit; 699 goto gotit;
700 } 700 }
@@ -706,7 +706,7 @@ norot:
706 ucpi->c_rotor = result; 706 ucpi->c_rotor = result;
707gotit: 707gotit:
708 blkno = ufs_fragstoblks(result); 708 blkno = ufs_fragstoblks(result);
709 ubh_clrblock (UCPI_UBH, ucpi->c_freeoff, blkno); 709 ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
710 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) 710 if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
711 ufs_clusteracct (sb, ucpi, blkno, -1); 711 ufs_clusteracct (sb, ucpi, blkno, -1);
712 if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) { 712 if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) {
@@ -739,7 +739,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
739 739
740 uspi = UFS_SB(sb)->s_uspi; 740 uspi = UFS_SB(sb)->s_uspi;
741 usb1 = ubh_get_usb_first (uspi); 741 usb1 = ubh_get_usb_first (uspi);
742 ucg = ubh_get_ucg(UCPI_UBH); 742 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
743 743
744 if (goal) 744 if (goal)
745 start = ufs_dtogd(goal) >> 3; 745 start = ufs_dtogd(goal) >> 3;
@@ -747,12 +747,12 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
747 start = ucpi->c_frotor >> 3; 747 start = ucpi->c_frotor >> 3;
748 748
749 length = ((uspi->s_fpg + 7) >> 3) - start; 749 length = ((uspi->s_fpg + 7) >> 3) - start;
750 location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff + start, length, 750 location = ubh_scanc(UCPI_UBH(ucpi), ucpi->c_freeoff + start, length,
751 (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other, 751 (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
752 1 << (count - 1 + (uspi->s_fpb & 7))); 752 1 << (count - 1 + (uspi->s_fpb & 7)));
753 if (location == 0) { 753 if (location == 0) {
754 length = start + 1; 754 length = start + 1;
755 location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff, length, 755 location = ubh_scanc(UCPI_UBH(ucpi), ucpi->c_freeoff, length,
756 (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other, 756 (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
757 1 << (count - 1 + (uspi->s_fpb & 7))); 757 1 << (count - 1 + (uspi->s_fpb & 7)));
758 if (location == 0) { 758 if (location == 0) {
@@ -769,7 +769,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
769 /* 769 /*
770 * found the byte in the map 770 * found the byte in the map
771 */ 771 */
772 blockmap = ubh_blkmap(UCPI_UBH, ucpi->c_freeoff, result); 772 blockmap = ubh_blkmap(UCPI_UBH(ucpi), ucpi->c_freeoff, result);
773 fragsize = 0; 773 fragsize = 0;
774 for (possition = 0, mask = 1; possition < 8; possition++, mask <<= 1) { 774 for (possition = 0, mask = 1; possition < 8; possition++, mask <<= 1) {
775 if (blockmap & mask) { 775 if (blockmap & mask) {
@@ -808,9 +808,9 @@ static void ufs_clusteracct(struct super_block * sb,
808 return; 808 return;
809 809
810 if (cnt > 0) 810 if (cnt > 0)
811 ubh_setbit(UCPI_UBH, ucpi->c_clusteroff, blkno); 811 ubh_setbit(UCPI_UBH(ucpi), ucpi->c_clusteroff, blkno);
812 else 812 else
813 ubh_clrbit(UCPI_UBH, ucpi->c_clusteroff, blkno); 813 ubh_clrbit(UCPI_UBH(ucpi), ucpi->c_clusteroff, blkno);
814 814
815 /* 815 /*
816 * Find the size of the cluster going forward. 816 * Find the size of the cluster going forward.
@@ -819,7 +819,7 @@ static void ufs_clusteracct(struct super_block * sb,
819 end = start + uspi->s_contigsumsize; 819 end = start + uspi->s_contigsumsize;
820 if ( end >= ucpi->c_nclusterblks) 820 if ( end >= ucpi->c_nclusterblks)
821 end = ucpi->c_nclusterblks; 821 end = ucpi->c_nclusterblks;
822 i = ubh_find_next_zero_bit (UCPI_UBH, ucpi->c_clusteroff, end, start); 822 i = ubh_find_next_zero_bit (UCPI_UBH(ucpi), ucpi->c_clusteroff, end, start);
823 if (i > end) 823 if (i > end)
824 i = end; 824 i = end;
825 forw = i - start; 825 forw = i - start;
@@ -831,7 +831,7 @@ static void ufs_clusteracct(struct super_block * sb,
831 end = start - uspi->s_contigsumsize; 831 end = start - uspi->s_contigsumsize;
832 if (end < 0 ) 832 if (end < 0 )
833 end = -1; 833 end = -1;
834 i = ubh_find_last_zero_bit (UCPI_UBH, ucpi->c_clusteroff, start, end); 834 i = ubh_find_last_zero_bit (UCPI_UBH(ucpi), ucpi->c_clusteroff, start, end);
835 if ( i < end) 835 if ( i < end)
836 i = end; 836 i = end;
837 back = start - i; 837 back = start - i;
@@ -843,11 +843,11 @@ static void ufs_clusteracct(struct super_block * sb,
843 i = back + forw + 1; 843 i = back + forw + 1;
844 if (i > uspi->s_contigsumsize) 844 if (i > uspi->s_contigsumsize)
845 i = uspi->s_contigsumsize; 845 i = uspi->s_contigsumsize;
846 fs32_add(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (i << 2)), cnt); 846 fs32_add(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (i << 2)), cnt);
847 if (back > 0) 847 if (back > 0)
848 fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (back << 2)), cnt); 848 fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (back << 2)), cnt);
849 if (forw > 0) 849 if (forw > 0)
850 fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (forw << 2)), cnt); 850 fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (forw << 2)), cnt);
851} 851}
852 852
853 853
diff --git a/fs/ufs/cylinder.c b/fs/ufs/cylinder.c
index 14abb8b835f7..65fe06810172 100644
--- a/fs/ufs/cylinder.c
+++ b/fs/ufs/cylinder.c
@@ -47,14 +47,14 @@ static void ufs_read_cylinder (struct super_block * sb,
47 ucpi = sbi->s_ucpi[bitmap_nr]; 47 ucpi = sbi->s_ucpi[bitmap_nr];
48 ucg = (struct ufs_cylinder_group *)sbi->s_ucg[cgno]->b_data; 48 ucg = (struct ufs_cylinder_group *)sbi->s_ucg[cgno]->b_data;
49 49
50 UCPI_UBH->fragment = ufs_cgcmin(cgno); 50 UCPI_UBH(ucpi)->fragment = ufs_cgcmin(cgno);
51 UCPI_UBH->count = uspi->s_cgsize >> sb->s_blocksize_bits; 51 UCPI_UBH(ucpi)->count = uspi->s_cgsize >> sb->s_blocksize_bits;
52 /* 52 /*
53 * We have already the first fragment of cylinder group block in buffer 53 * We have already the first fragment of cylinder group block in buffer
54 */ 54 */
55 UCPI_UBH->bh[0] = sbi->s_ucg[cgno]; 55 UCPI_UBH(ucpi)->bh[0] = sbi->s_ucg[cgno];
56 for (i = 1; i < UCPI_UBH->count; i++) 56 for (i = 1; i < UCPI_UBH(ucpi)->count; i++)
57 if (!(UCPI_UBH->bh[i] = sb_bread(sb, UCPI_UBH->fragment + i))) 57 if (!(UCPI_UBH(ucpi)->bh[i] = sb_bread(sb, UCPI_UBH(ucpi)->fragment + i)))
58 goto failed; 58 goto failed;
59 sbi->s_cgno[bitmap_nr] = cgno; 59 sbi->s_cgno[bitmap_nr] = cgno;
60 60
@@ -103,7 +103,7 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr)
103 return; 103 return;
104 } 104 }
105 ucpi = sbi->s_ucpi[bitmap_nr]; 105 ucpi = sbi->s_ucpi[bitmap_nr];
106 ucg = ubh_get_ucg(UCPI_UBH); 106 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
107 107
108 if (uspi->s_ncg > UFS_MAX_GROUP_LOADED && bitmap_nr >= sbi->s_cg_loaded) { 108 if (uspi->s_ncg > UFS_MAX_GROUP_LOADED && bitmap_nr >= sbi->s_cg_loaded) {
109 ufs_panic (sb, "ufs_put_cylinder", "internal error"); 109 ufs_panic (sb, "ufs_put_cylinder", "internal error");
@@ -116,9 +116,9 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr)
116 ucg->cg_rotor = cpu_to_fs32(sb, ucpi->c_rotor); 116 ucg->cg_rotor = cpu_to_fs32(sb, ucpi->c_rotor);
117 ucg->cg_frotor = cpu_to_fs32(sb, ucpi->c_frotor); 117 ucg->cg_frotor = cpu_to_fs32(sb, ucpi->c_frotor);
118 ucg->cg_irotor = cpu_to_fs32(sb, ucpi->c_irotor); 118 ucg->cg_irotor = cpu_to_fs32(sb, ucpi->c_irotor);
119 ubh_mark_buffer_dirty (UCPI_UBH); 119 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
120 for (i = 1; i < UCPI_UBH->count; i++) { 120 for (i = 1; i < UCPI_UBH(ucpi)->count; i++) {
121 brelse (UCPI_UBH->bh[i]); 121 brelse (UCPI_UBH(ucpi)->bh[i]);
122 } 122 }
123 123
124 sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY; 124 sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY;
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index c7a47ed4f430..2da0ffda82cc 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -91,7 +91,7 @@ void ufs_free_inode (struct inode * inode)
91 unlock_super (sb); 91 unlock_super (sb);
92 return; 92 return;
93 } 93 }
94 ucg = ubh_get_ucg(UCPI_UBH); 94 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
95 if (!ufs_cg_chkmagic(sb, ucg)) 95 if (!ufs_cg_chkmagic(sb, ucg))
96 ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number"); 96 ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number");
97 97
@@ -104,10 +104,10 @@ void ufs_free_inode (struct inode * inode)
104 104
105 clear_inode (inode); 105 clear_inode (inode);
106 106
107 if (ubh_isclr (UCPI_UBH, ucpi->c_iusedoff, bit)) 107 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))
108 ufs_error(sb, "ufs_free_inode", "bit already cleared for inode %u", ino); 108 ufs_error(sb, "ufs_free_inode", "bit already cleared for inode %u", ino);
109 else { 109 else {
110 ubh_clrbit (UCPI_UBH, ucpi->c_iusedoff, bit); 110 ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
111 if (ino < ucpi->c_irotor) 111 if (ino < ucpi->c_irotor)
112 ucpi->c_irotor = ino; 112 ucpi->c_irotor = ino;
113 fs32_add(sb, &ucg->cg_cs.cs_nifree, 1); 113 fs32_add(sb, &ucg->cg_cs.cs_nifree, 1);
@@ -121,11 +121,11 @@ void ufs_free_inode (struct inode * inode)
121 } 121 }
122 } 122 }
123 123
124 ubh_mark_buffer_dirty (USPI_UBH); 124 ubh_mark_buffer_dirty (USPI_UBH(uspi));
125 ubh_mark_buffer_dirty (UCPI_UBH); 125 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
126 if (sb->s_flags & MS_SYNCHRONOUS) { 126 if (sb->s_flags & MS_SYNCHRONOUS) {
127 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi); 127 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi);
128 ubh_wait_on_buffer (UCPI_UBH); 128 ubh_wait_on_buffer (UCPI_UBH(ucpi));
129 } 129 }
130 130
131 sb->s_dirt = 1; 131 sb->s_dirt = 1;
@@ -213,14 +213,14 @@ cg_found:
213 ucpi = ufs_load_cylinder (sb, cg); 213 ucpi = ufs_load_cylinder (sb, cg);
214 if (!ucpi) 214 if (!ucpi)
215 goto failed; 215 goto failed;
216 ucg = ubh_get_ucg(UCPI_UBH); 216 ucg = ubh_get_ucg(UCPI_UBH(ucpi));
217 if (!ufs_cg_chkmagic(sb, ucg)) 217 if (!ufs_cg_chkmagic(sb, ucg))
218 ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number"); 218 ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");
219 219
220 start = ucpi->c_irotor; 220 start = ucpi->c_irotor;
221 bit = ubh_find_next_zero_bit (UCPI_UBH, ucpi->c_iusedoff, uspi->s_ipg, start); 221 bit = ubh_find_next_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, uspi->s_ipg, start);
222 if (!(bit < uspi->s_ipg)) { 222 if (!(bit < uspi->s_ipg)) {
223 bit = ubh_find_first_zero_bit (UCPI_UBH, ucpi->c_iusedoff, start); 223 bit = ubh_find_first_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, start);
224 if (!(bit < start)) { 224 if (!(bit < start)) {
225 ufs_error (sb, "ufs_new_inode", 225 ufs_error (sb, "ufs_new_inode",
226 "cylinder group %u corrupted - error in inode bitmap\n", cg); 226 "cylinder group %u corrupted - error in inode bitmap\n", cg);
@@ -228,8 +228,8 @@ cg_found:
228 } 228 }
229 } 229 }
230 UFSD(("start = %u, bit = %u, ipg = %u\n", start, bit, uspi->s_ipg)) 230 UFSD(("start = %u, bit = %u, ipg = %u\n", start, bit, uspi->s_ipg))
231 if (ubh_isclr (UCPI_UBH, ucpi->c_iusedoff, bit)) 231 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))
232 ubh_setbit (UCPI_UBH, ucpi->c_iusedoff, bit); 232 ubh_setbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
233 else { 233 else {
234 ufs_panic (sb, "ufs_new_inode", "internal error"); 234 ufs_panic (sb, "ufs_new_inode", "internal error");
235 goto failed; 235 goto failed;
@@ -245,11 +245,11 @@ cg_found:
245 fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1); 245 fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1);
246 } 246 }
247 247
248 ubh_mark_buffer_dirty (USPI_UBH); 248 ubh_mark_buffer_dirty (USPI_UBH(uspi));
249 ubh_mark_buffer_dirty (UCPI_UBH); 249 ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
250 if (sb->s_flags & MS_SYNCHRONOUS) { 250 if (sb->s_flags & MS_SYNCHRONOUS) {
251 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi); 251 ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi);
252 ubh_wait_on_buffer (UCPI_UBH); 252 ubh_wait_on_buffer (UCPI_UBH(ucpi));
253 } 253 }
254 sb->s_dirt = 1; 254 sb->s_dirt = 1;
255 255
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index fe5ab2aa2899..c00d1e741529 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -225,7 +225,7 @@ void ufs_error (struct super_block * sb, const char * function,
225 225
226 if (!(sb->s_flags & MS_RDONLY)) { 226 if (!(sb->s_flags & MS_RDONLY)) {
227 usb1->fs_clean = UFS_FSBAD; 227 usb1->fs_clean = UFS_FSBAD;
228 ubh_mark_buffer_dirty(USPI_UBH); 228 ubh_mark_buffer_dirty(USPI_UBH(uspi));
229 sb->s_dirt = 1; 229 sb->s_dirt = 1;
230 sb->s_flags |= MS_RDONLY; 230 sb->s_flags |= MS_RDONLY;
231 } 231 }
@@ -257,7 +257,7 @@ void ufs_panic (struct super_block * sb, const char * function,
257 257
258 if (!(sb->s_flags & MS_RDONLY)) { 258 if (!(sb->s_flags & MS_RDONLY)) {
259 usb1->fs_clean = UFS_FSBAD; 259 usb1->fs_clean = UFS_FSBAD;
260 ubh_mark_buffer_dirty(USPI_UBH); 260 ubh_mark_buffer_dirty(USPI_UBH(uspi));
261 sb->s_dirt = 1; 261 sb->s_dirt = 1;
262 } 262 }
263 va_start (args, fmt); 263 va_start (args, fmt);
@@ -1014,7 +1014,7 @@ static void ufs_write_super (struct super_block *sb) {
1014 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) 1014 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
1015 ufs_set_fs_state(sb, usb1, usb3, 1015 ufs_set_fs_state(sb, usb1, usb3,
1016 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); 1016 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
1017 ubh_mark_buffer_dirty (USPI_UBH); 1017 ubh_mark_buffer_dirty (USPI_UBH(uspi));
1018 } 1018 }
1019 sb->s_dirt = 0; 1019 sb->s_dirt = 0;
1020 UFSD(("EXIT\n")) 1020 UFSD(("EXIT\n"))
@@ -1083,7 +1083,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1083 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) 1083 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
1084 ufs_set_fs_state(sb, usb1, usb3, 1084 ufs_set_fs_state(sb, usb1, usb3,
1085 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); 1085 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
1086 ubh_mark_buffer_dirty (USPI_UBH); 1086 ubh_mark_buffer_dirty (USPI_UBH(uspi));
1087 sb->s_dirt = 0; 1087 sb->s_dirt = 0;
1088 sb->s_flags |= MS_RDONLY; 1088 sb->s_flags |= MS_RDONLY;
1089 } 1089 }
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index 72f91cc84bfe..f9556bc484ef 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -63,17 +63,17 @@ struct ufs_buffer_head * ubh_bread_uspi (struct ufs_sb_private_info * uspi,
63 count = size >> uspi->s_fshift; 63 count = size >> uspi->s_fshift;
64 if (count <= 0 || count > UFS_MAXFRAG) 64 if (count <= 0 || count > UFS_MAXFRAG)
65 return NULL; 65 return NULL;
66 USPI_UBH->fragment = fragment; 66 USPI_UBH(uspi)->fragment = fragment;
67 USPI_UBH->count = count; 67 USPI_UBH(uspi)->count = count;
68 for (i = 0; i < count; i++) 68 for (i = 0; i < count; i++)
69 if (!(USPI_UBH->bh[i] = sb_bread(sb, fragment + i))) 69 if (!(USPI_UBH(uspi)->bh[i] = sb_bread(sb, fragment + i)))
70 goto failed; 70 goto failed;
71 for (; i < UFS_MAXFRAG; i++) 71 for (; i < UFS_MAXFRAG; i++)
72 USPI_UBH->bh[i] = NULL; 72 USPI_UBH(uspi)->bh[i] = NULL;
73 return USPI_UBH; 73 return USPI_UBH(uspi);
74failed: 74failed:
75 for (j = 0; j < i; j++) 75 for (j = 0; j < i; j++)
76 brelse (USPI_UBH->bh[j]); 76 brelse (USPI_UBH(uspi)->bh[j]);
77 return NULL; 77 return NULL;
78} 78}
79 79
@@ -90,11 +90,11 @@ void ubh_brelse (struct ufs_buffer_head * ubh)
90void ubh_brelse_uspi (struct ufs_sb_private_info * uspi) 90void ubh_brelse_uspi (struct ufs_sb_private_info * uspi)
91{ 91{
92 unsigned i; 92 unsigned i;
93 if (!USPI_UBH) 93 if (!USPI_UBH(uspi))
94 return; 94 return;
95 for ( i = 0; i < USPI_UBH->count; i++ ) { 95 for ( i = 0; i < USPI_UBH(uspi)->count; i++ ) {
96 brelse (USPI_UBH->bh[i]); 96 brelse (USPI_UBH(uspi)->bh[i]);
97 USPI_UBH->bh[i] = NULL; 97 USPI_UBH(uspi)->bh[i] = NULL;
98 } 98 }
99} 99}
100 100
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index e10362d8f456..6a0b48cf9cef 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -17,10 +17,16 @@
17#define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len)) 17#define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len))
18 18
19/* 19/*
20 * macros used for retyping 20 * functions used for retyping
21 */ 21 */
22#define UCPI_UBH ((struct ufs_buffer_head *)ucpi) 22static inline struct ufs_buffer_head *UCPI_UBH(struct ufs_cg_private_info *cpi)
23#define USPI_UBH ((struct ufs_buffer_head *)uspi) 23{
24 return &cpi->c_ubh;
25}
26static inline struct ufs_buffer_head *USPI_UBH(struct ufs_sb_private_info *spi)
27{
28 return &spi->s_ubh;
29}
24 30
25 31
26 32
@@ -326,10 +332,10 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
326 * Macros to access cylinder group array structures 332 * Macros to access cylinder group array structures
327 */ 333 */
328#define ubh_cg_blktot(ucpi,cylno) \ 334#define ubh_cg_blktot(ucpi,cylno) \
329 (*((__fs32*)ubh_get_addr(UCPI_UBH, (ucpi)->c_btotoff + ((cylno) << 2)))) 335 (*((__fs32*)ubh_get_addr(UCPI_UBH(ucpi), (ucpi)->c_btotoff + ((cylno) << 2))))
330 336
331#define ubh_cg_blks(ucpi,cylno,rpos) \ 337#define ubh_cg_blks(ucpi,cylno,rpos) \
332 (*((__fs16*)ubh_get_addr(UCPI_UBH, \ 338 (*((__fs16*)ubh_get_addr(UCPI_UBH(ucpi), \
333 (ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 )))) 339 (ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 ))))
334 340
335/* 341/*