Commit 9695ef16 authored by Evgeniy Dushistov's avatar Evgeniy Dushistov Committed by Linus Torvalds

[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: default avatarEvgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b71034e5
...@@ -69,7 +69,7 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count) ...@@ -69,7 +69,7 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
ucpi = ufs_load_cylinder (sb, cgno); ucpi = ufs_load_cylinder (sb, cgno);
if (!ucpi) if (!ucpi)
goto failed; goto failed;
ucg = ubh_get_ucg (UCPI_UBH); ucg = ubh_get_ucg (UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) { if (!ufs_cg_chkmagic(sb, ucg)) {
ufs_panic (sb, "ufs_free_fragments", "internal error, bad magic number on cg %u", cgno); ufs_panic (sb, "ufs_free_fragments", "internal error, bad magic number on cg %u", cgno);
goto failed; goto failed;
...@@ -77,11 +77,11 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count) ...@@ -77,11 +77,11 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
end_bit = bit + count; end_bit = bit + count;
bbase = ufs_blknum (bit); bbase = ufs_blknum (bit);
blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase); blkmap = ubh_blkmap (UCPI_UBH(ucpi), ucpi->c_freeoff, bbase);
ufs_fragacct (sb, blkmap, ucg->cg_frsum, -1); ufs_fragacct (sb, blkmap, ucg->cg_frsum, -1);
for (i = bit; i < end_bit; i++) { for (i = bit; i < end_bit; i++) {
if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, i)) if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, i))
ubh_setbit (UCPI_UBH, ucpi->c_freeoff, i); ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, i);
else else
ufs_error (sb, "ufs_free_fragments", ufs_error (sb, "ufs_free_fragments",
"bit already cleared for fragment %u", i); "bit already cleared for fragment %u", i);
...@@ -93,14 +93,14 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count) ...@@ -93,14 +93,14 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
fs32_add(sb, &ucg->cg_cs.cs_nffree, count); fs32_add(sb, &ucg->cg_cs.cs_nffree, count);
fs32_add(sb, &usb1->fs_cstotal.cs_nffree, count); fs32_add(sb, &usb1->fs_cstotal.cs_nffree, count);
fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count);
blkmap = ubh_blkmap (UCPI_UBH, ucpi->c_freeoff, bbase); blkmap = ubh_blkmap (UCPI_UBH(ucpi), ucpi->c_freeoff, bbase);
ufs_fragacct(sb, blkmap, ucg->cg_frsum, 1); ufs_fragacct(sb, blkmap, ucg->cg_frsum, 1);
/* /*
* Trying to reassemble free fragments into block * Trying to reassemble free fragments into block
*/ */
blkno = ufs_fragstoblks (bbase); blkno = ufs_fragstoblks (bbase);
if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) { if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) {
fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb);
fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, uspi->s_fpb); fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, uspi->s_fpb);
fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); 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,11 +114,11 @@ void ufs_free_fragments(struct inode *inode, unsigned fragment, unsigned count)
fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1);
} }
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -176,7 +176,7 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count) ...@@ -176,7 +176,7 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count)
ucpi = ufs_load_cylinder (sb, cgno); ucpi = ufs_load_cylinder (sb, cgno);
if (!ucpi) if (!ucpi)
goto failed; goto failed;
ucg = ubh_get_ucg (UCPI_UBH); ucg = ubh_get_ucg (UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) { if (!ufs_cg_chkmagic(sb, ucg)) {
ufs_panic (sb, "ufs_free_blocks", "internal error, bad magic number on cg %u", cgno); ufs_panic (sb, "ufs_free_blocks", "internal error, bad magic number on cg %u", cgno);
goto failed; goto failed;
...@@ -184,10 +184,10 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count) ...@@ -184,10 +184,10 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count)
for (i = bit; i < end_bit; i += uspi->s_fpb) { for (i = bit; i < end_bit; i += uspi->s_fpb) {
blkno = ufs_fragstoblks(i); blkno = ufs_fragstoblks(i);
if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, blkno)) { if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) {
ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); ufs_error(sb, "ufs_free_blocks", "freeing free fragment");
} }
ubh_setblock(UCPI_UBH, ucpi->c_freeoff, blkno); ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
ufs_clusteracct (sb, ucpi, blkno, 1); ufs_clusteracct (sb, ucpi, blkno, 1);
DQUOT_FREE_BLOCK(inode, uspi->s_fpb); DQUOT_FREE_BLOCK(inode, uspi->s_fpb);
...@@ -200,11 +200,11 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count) ...@@ -200,11 +200,11 @@ void ufs_free_blocks(struct inode *inode, unsigned fragment, unsigned count)
fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1);
} }
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
if (overflow) { if (overflow) {
...@@ -493,7 +493,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, ...@@ -493,7 +493,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
ucpi = ufs_load_cylinder (sb, cgno); ucpi = ufs_load_cylinder (sb, cgno);
if (!ucpi) if (!ucpi)
return 0; return 0;
ucg = ubh_get_ucg (UCPI_UBH); ucg = ubh_get_ucg (UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) { if (!ufs_cg_chkmagic(sb, ucg)) {
ufs_panic (sb, "ufs_add_fragments", ufs_panic (sb, "ufs_add_fragments",
"internal error, bad magic number on cg %u", cgno); "internal error, bad magic number on cg %u", cgno);
...@@ -503,14 +503,14 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, ...@@ -503,14 +503,14 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
fragno = ufs_dtogd (fragment); fragno = ufs_dtogd (fragment);
fragoff = ufs_fragnum (fragno); fragoff = ufs_fragnum (fragno);
for (i = oldcount; i < newcount; i++) for (i = oldcount; i < newcount; i++)
if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, fragno + i)) if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
return 0; return 0;
/* /*
* Block can be extended * Block can be extended
*/ */
ucg->cg_time = cpu_to_fs32(sb, get_seconds()); ucg->cg_time = cpu_to_fs32(sb, get_seconds());
for (i = newcount; i < (uspi->s_fpb - fragoff); i++) for (i = newcount; i < (uspi->s_fpb - fragoff); i++)
if (ubh_isclr (UCPI_UBH, ucpi->c_freeoff, fragno + i)) if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
break; break;
fragsize = i - oldcount; fragsize = i - oldcount;
if (!fs32_to_cpu(sb, ucg->cg_frsum[fragsize])) if (!fs32_to_cpu(sb, ucg->cg_frsum[fragsize]))
...@@ -520,7 +520,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, ...@@ -520,7 +520,7 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
if (fragsize != count) if (fragsize != count)
fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1);
for (i = oldcount; i < newcount; i++) for (i = oldcount; i < newcount; i++)
ubh_clrbit (UCPI_UBH, ucpi->c_freeoff, fragno + i); ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i);
if(DQUOT_ALLOC_BLOCK(inode, count)) { if(DQUOT_ALLOC_BLOCK(inode, count)) {
*err = -EDQUOT; *err = -EDQUOT;
return 0; return 0;
...@@ -530,11 +530,11 @@ ufs_add_fragments (struct inode * inode, unsigned fragment, ...@@ -530,11 +530,11 @@ ufs_add_fragments (struct inode * inode, unsigned fragment,
fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count);
fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count); fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count);
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -602,7 +602,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, ...@@ -602,7 +602,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno,
ucpi = ufs_load_cylinder (sb, cgno); ucpi = ufs_load_cylinder (sb, cgno);
if (!ucpi) if (!ucpi)
return 0; return 0;
ucg = ubh_get_ucg (UCPI_UBH); ucg = ubh_get_ucg (UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) if (!ufs_cg_chkmagic(sb, ucg))
ufs_panic (sb, "ufs_alloc_fragments", ufs_panic (sb, "ufs_alloc_fragments",
"internal error, bad magic number on cg %u", cgno); "internal error, bad magic number on cg %u", cgno);
...@@ -625,7 +625,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, ...@@ -625,7 +625,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno,
return 0; return 0;
goal = ufs_dtogd (result); goal = ufs_dtogd (result);
for (i = count; i < uspi->s_fpb; i++) for (i = count; i < uspi->s_fpb; i++)
ubh_setbit (UCPI_UBH, ucpi->c_freeoff, goal + i); ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i);
i = uspi->s_fpb - count; i = uspi->s_fpb - count;
DQUOT_FREE_BLOCK(inode, i); DQUOT_FREE_BLOCK(inode, i);
...@@ -644,7 +644,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, ...@@ -644,7 +644,7 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno,
return 0; return 0;
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
ubh_clrbit (UCPI_UBH, ucpi->c_freeoff, result + i); ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, result + i);
fs32_sub(sb, &ucg->cg_cs.cs_nffree, count); fs32_sub(sb, &ucg->cg_cs.cs_nffree, count);
fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count); fs32_sub(sb, &usb1->fs_cstotal.cs_nffree, count);
...@@ -655,11 +655,11 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno, ...@@ -655,11 +655,11 @@ static unsigned ufs_alloc_fragments (struct inode * inode, unsigned cgno,
fs32_add(sb, &ucg->cg_frsum[allocsize - count], 1); fs32_add(sb, &ucg->cg_frsum[allocsize - count], 1);
succed: succed:
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **)&ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -682,7 +682,7 @@ static unsigned ufs_alloccg_block (struct inode * inode, ...@@ -682,7 +682,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
sb = inode->i_sb; sb = inode->i_sb;
uspi = UFS_SB(sb)->s_uspi; uspi = UFS_SB(sb)->s_uspi;
usb1 = ubh_get_usb_first(uspi); usb1 = ubh_get_usb_first(uspi);
ucg = ubh_get_ucg(UCPI_UBH); ucg = ubh_get_ucg(UCPI_UBH(ucpi));
if (goal == 0) { if (goal == 0) {
goal = ucpi->c_rotor; goal = ucpi->c_rotor;
...@@ -694,7 +694,7 @@ static unsigned ufs_alloccg_block (struct inode * inode, ...@@ -694,7 +694,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
/* /*
* If the requested block is available, use it. * If the requested block is available, use it.
*/ */
if (ubh_isblockset(UCPI_UBH, ucpi->c_freeoff, ufs_fragstoblks(goal))) { if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) {
result = goal; result = goal;
goto gotit; goto gotit;
} }
...@@ -706,7 +706,7 @@ static unsigned ufs_alloccg_block (struct inode * inode, ...@@ -706,7 +706,7 @@ static unsigned ufs_alloccg_block (struct inode * inode,
ucpi->c_rotor = result; ucpi->c_rotor = result;
gotit: gotit:
blkno = ufs_fragstoblks(result); blkno = ufs_fragstoblks(result);
ubh_clrblock (UCPI_UBH, ucpi->c_freeoff, blkno); ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
ufs_clusteracct (sb, ucpi, blkno, -1); ufs_clusteracct (sb, ucpi, blkno, -1);
if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) { if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) {
...@@ -739,7 +739,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb, ...@@ -739,7 +739,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
uspi = UFS_SB(sb)->s_uspi; uspi = UFS_SB(sb)->s_uspi;
usb1 = ubh_get_usb_first (uspi); usb1 = ubh_get_usb_first (uspi);
ucg = ubh_get_ucg(UCPI_UBH); ucg = ubh_get_ucg(UCPI_UBH(ucpi));
if (goal) if (goal)
start = ufs_dtogd(goal) >> 3; start = ufs_dtogd(goal) >> 3;
...@@ -747,12 +747,12 @@ static unsigned ufs_bitmap_search (struct super_block * sb, ...@@ -747,12 +747,12 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
start = ucpi->c_frotor >> 3; start = ucpi->c_frotor >> 3;
length = ((uspi->s_fpg + 7) >> 3) - start; length = ((uspi->s_fpg + 7) >> 3) - start;
location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff + start, length, location = ubh_scanc(UCPI_UBH(ucpi), ucpi->c_freeoff + start, length,
(uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other, (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
1 << (count - 1 + (uspi->s_fpb & 7))); 1 << (count - 1 + (uspi->s_fpb & 7)));
if (location == 0) { if (location == 0) {
length = start + 1; length = start + 1;
location = ubh_scanc(UCPI_UBH, ucpi->c_freeoff, length, location = ubh_scanc(UCPI_UBH(ucpi), ucpi->c_freeoff, length,
(uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other, (uspi->s_fpb == 8) ? ufs_fragtable_8fpb : ufs_fragtable_other,
1 << (count - 1 + (uspi->s_fpb & 7))); 1 << (count - 1 + (uspi->s_fpb & 7)));
if (location == 0) { if (location == 0) {
...@@ -769,7 +769,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb, ...@@ -769,7 +769,7 @@ static unsigned ufs_bitmap_search (struct super_block * sb,
/* /*
* found the byte in the map * found the byte in the map
*/ */
blockmap = ubh_blkmap(UCPI_UBH, ucpi->c_freeoff, result); blockmap = ubh_blkmap(UCPI_UBH(ucpi), ucpi->c_freeoff, result);
fragsize = 0; fragsize = 0;
for (possition = 0, mask = 1; possition < 8; possition++, mask <<= 1) { for (possition = 0, mask = 1; possition < 8; possition++, mask <<= 1) {
if (blockmap & mask) { if (blockmap & mask) {
...@@ -808,9 +808,9 @@ static void ufs_clusteracct(struct super_block * sb, ...@@ -808,9 +808,9 @@ static void ufs_clusteracct(struct super_block * sb,
return; return;
if (cnt > 0) if (cnt > 0)
ubh_setbit(UCPI_UBH, ucpi->c_clusteroff, blkno); ubh_setbit(UCPI_UBH(ucpi), ucpi->c_clusteroff, blkno);
else else
ubh_clrbit(UCPI_UBH, ucpi->c_clusteroff, blkno); ubh_clrbit(UCPI_UBH(ucpi), ucpi->c_clusteroff, blkno);
/* /*
* Find the size of the cluster going forward. * Find the size of the cluster going forward.
...@@ -819,7 +819,7 @@ static void ufs_clusteracct(struct super_block * sb, ...@@ -819,7 +819,7 @@ static void ufs_clusteracct(struct super_block * sb,
end = start + uspi->s_contigsumsize; end = start + uspi->s_contigsumsize;
if ( end >= ucpi->c_nclusterblks) if ( end >= ucpi->c_nclusterblks)
end = ucpi->c_nclusterblks; end = ucpi->c_nclusterblks;
i = ubh_find_next_zero_bit (UCPI_UBH, ucpi->c_clusteroff, end, start); i = ubh_find_next_zero_bit (UCPI_UBH(ucpi), ucpi->c_clusteroff, end, start);
if (i > end) if (i > end)
i = end; i = end;
forw = i - start; forw = i - start;
...@@ -831,7 +831,7 @@ static void ufs_clusteracct(struct super_block * sb, ...@@ -831,7 +831,7 @@ static void ufs_clusteracct(struct super_block * sb,
end = start - uspi->s_contigsumsize; end = start - uspi->s_contigsumsize;
if (end < 0 ) if (end < 0 )
end = -1; end = -1;
i = ubh_find_last_zero_bit (UCPI_UBH, ucpi->c_clusteroff, start, end); i = ubh_find_last_zero_bit (UCPI_UBH(ucpi), ucpi->c_clusteroff, start, end);
if ( i < end) if ( i < end)
i = end; i = end;
back = start - i; back = start - i;
...@@ -843,11 +843,11 @@ static void ufs_clusteracct(struct super_block * sb, ...@@ -843,11 +843,11 @@ static void ufs_clusteracct(struct super_block * sb,
i = back + forw + 1; i = back + forw + 1;
if (i > uspi->s_contigsumsize) if (i > uspi->s_contigsumsize)
i = uspi->s_contigsumsize; i = uspi->s_contigsumsize;
fs32_add(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (i << 2)), cnt); fs32_add(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (i << 2)), cnt);
if (back > 0) if (back > 0)
fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (back << 2)), cnt); fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (back << 2)), cnt);
if (forw > 0) if (forw > 0)
fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (forw << 2)), cnt); fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH(ucpi), ucpi->c_clustersumoff + (forw << 2)), cnt);
} }
......
...@@ -47,14 +47,14 @@ static void ufs_read_cylinder (struct super_block * sb, ...@@ -47,14 +47,14 @@ static void ufs_read_cylinder (struct super_block * sb,
ucpi = sbi->s_ucpi[bitmap_nr]; ucpi = sbi->s_ucpi[bitmap_nr];
ucg = (struct ufs_cylinder_group *)sbi->s_ucg[cgno]->b_data; ucg = (struct ufs_cylinder_group *)sbi->s_ucg[cgno]->b_data;
UCPI_UBH->fragment = ufs_cgcmin(cgno); UCPI_UBH(ucpi)->fragment = ufs_cgcmin(cgno);
UCPI_UBH->count = uspi->s_cgsize >> sb->s_blocksize_bits; UCPI_UBH(ucpi)->count = uspi->s_cgsize >> sb->s_blocksize_bits;
/* /*
* We have already the first fragment of cylinder group block in buffer * We have already the first fragment of cylinder group block in buffer
*/ */
UCPI_UBH->bh[0] = sbi->s_ucg[cgno]; UCPI_UBH(ucpi)->bh[0] = sbi->s_ucg[cgno];
for (i = 1; i < UCPI_UBH->count; i++) for (i = 1; i < UCPI_UBH(ucpi)->count; i++)
if (!(UCPI_UBH->bh[i] = sb_bread(sb, UCPI_UBH->fragment + i))) if (!(UCPI_UBH(ucpi)->bh[i] = sb_bread(sb, UCPI_UBH(ucpi)->fragment + i)))
goto failed; goto failed;
sbi->s_cgno[bitmap_nr] = cgno; sbi->s_cgno[bitmap_nr] = cgno;
...@@ -103,7 +103,7 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr) ...@@ -103,7 +103,7 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr)
return; return;
} }
ucpi = sbi->s_ucpi[bitmap_nr]; ucpi = sbi->s_ucpi[bitmap_nr];
ucg = ubh_get_ucg(UCPI_UBH); ucg = ubh_get_ucg(UCPI_UBH(ucpi));
if (uspi->s_ncg > UFS_MAX_GROUP_LOADED && bitmap_nr >= sbi->s_cg_loaded) { if (uspi->s_ncg > UFS_MAX_GROUP_LOADED && bitmap_nr >= sbi->s_cg_loaded) {
ufs_panic (sb, "ufs_put_cylinder", "internal error"); ufs_panic (sb, "ufs_put_cylinder", "internal error");
...@@ -116,9 +116,9 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr) ...@@ -116,9 +116,9 @@ void ufs_put_cylinder (struct super_block * sb, unsigned bitmap_nr)
ucg->cg_rotor = cpu_to_fs32(sb, ucpi->c_rotor); ucg->cg_rotor = cpu_to_fs32(sb, ucpi->c_rotor);
ucg->cg_frotor = cpu_to_fs32(sb, ucpi->c_frotor); ucg->cg_frotor = cpu_to_fs32(sb, ucpi->c_frotor);
ucg->cg_irotor = cpu_to_fs32(sb, ucpi->c_irotor); ucg->cg_irotor = cpu_to_fs32(sb, ucpi->c_irotor);
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
for (i = 1; i < UCPI_UBH->count; i++) { for (i = 1; i < UCPI_UBH(ucpi)->count; i++) {
brelse (UCPI_UBH->bh[i]); brelse (UCPI_UBH(ucpi)->bh[i]);
} }
sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY; sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY;
......
...@@ -91,7 +91,7 @@ void ufs_free_inode (struct inode * inode) ...@@ -91,7 +91,7 @@ void ufs_free_inode (struct inode * inode)
unlock_super (sb); unlock_super (sb);
return; return;
} }
ucg = ubh_get_ucg(UCPI_UBH); ucg = ubh_get_ucg(UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) if (!ufs_cg_chkmagic(sb, ucg))
ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number"); ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number");
...@@ -104,10 +104,10 @@ void ufs_free_inode (struct inode * inode) ...@@ -104,10 +104,10 @@ void ufs_free_inode (struct inode * inode)
clear_inode (inode); clear_inode (inode);
if (ubh_isclr (UCPI_UBH, ucpi->c_iusedoff, bit)) if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))
ufs_error(sb, "ufs_free_inode", "bit already cleared for inode %u", ino); ufs_error(sb, "ufs_free_inode", "bit already cleared for inode %u", ino);
else { else {
ubh_clrbit (UCPI_UBH, ucpi->c_iusedoff, bit); ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
if (ino < ucpi->c_irotor) if (ino < ucpi->c_irotor)
ucpi->c_irotor = ino; ucpi->c_irotor = ino;
fs32_add(sb, &ucg->cg_cs.cs_nifree, 1); fs32_add(sb, &ucg->cg_cs.cs_nifree, 1);
...@@ -121,11 +121,11 @@ void ufs_free_inode (struct inode * inode) ...@@ -121,11 +121,11 @@ void ufs_free_inode (struct inode * inode)
} }
} }
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -213,14 +213,14 @@ struct inode * ufs_new_inode(struct inode * dir, int mode) ...@@ -213,14 +213,14 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
ucpi = ufs_load_cylinder (sb, cg); ucpi = ufs_load_cylinder (sb, cg);
if (!ucpi) if (!ucpi)
goto failed; goto failed;
ucg = ubh_get_ucg(UCPI_UBH); ucg = ubh_get_ucg(UCPI_UBH(ucpi));
if (!ufs_cg_chkmagic(sb, ucg)) if (!ufs_cg_chkmagic(sb, ucg))
ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number"); ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");
start = ucpi->c_irotor; start = ucpi->c_irotor;
bit = ubh_find_next_zero_bit (UCPI_UBH, ucpi->c_iusedoff, uspi->s_ipg, start); bit = ubh_find_next_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, uspi->s_ipg, start);
if (!(bit < uspi->s_ipg)) { if (!(bit < uspi->s_ipg)) {
bit = ubh_find_first_zero_bit (UCPI_UBH, ucpi->c_iusedoff, start); bit = ubh_find_first_zero_bit (UCPI_UBH(ucpi), ucpi->c_iusedoff, start);
if (!(bit < start)) { if (!(bit < start)) {
ufs_error (sb, "ufs_new_inode", ufs_error (sb, "ufs_new_inode",
"cylinder group %u corrupted - error in inode bitmap\n", cg); "cylinder group %u corrupted - error in inode bitmap\n", cg);
...@@ -228,8 +228,8 @@ struct inode * ufs_new_inode(struct inode * dir, int mode) ...@@ -228,8 +228,8 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
} }
} }
UFSD(("start = %u, bit = %u, ipg = %u\n", start, bit, uspi->s_ipg)) UFSD(("start = %u, bit = %u, ipg = %u\n", start, bit, uspi->s_ipg))
if (ubh_isclr (UCPI_UBH, ucpi->c_iusedoff, bit)) if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit))
ubh_setbit (UCPI_UBH, ucpi->c_iusedoff, bit); ubh_setbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
else { else {
ufs_panic (sb, "ufs_new_inode", "internal error"); ufs_panic (sb, "ufs_new_inode", "internal error");
goto failed; goto failed;
...@@ -245,11 +245,11 @@ struct inode * ufs_new_inode(struct inode * dir, int mode) ...@@ -245,11 +245,11 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1); fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1);
} }
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
ubh_mark_buffer_dirty (UCPI_UBH); ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi); ubh_ll_rw_block (SWRITE, 1, (struct ufs_buffer_head **) &ucpi);
ubh_wait_on_buffer (UCPI_UBH); ubh_wait_on_buffer (UCPI_UBH(ucpi));
} }
sb->s_dirt = 1; sb->s_dirt = 1;
......
...@@ -225,7 +225,7 @@ void ufs_error (struct super_block * sb, const char * function, ...@@ -225,7 +225,7 @@ void ufs_error (struct super_block * sb, const char * function,
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
usb1->fs_clean = UFS_FSBAD; usb1->fs_clean = UFS_FSBAD;
ubh_mark_buffer_dirty(USPI_UBH); ubh_mark_buffer_dirty(USPI_UBH(uspi));
sb->s_dirt = 1; sb->s_dirt = 1;
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
} }
...@@ -257,7 +257,7 @@ void ufs_panic (struct super_block * sb, const char * function, ...@@ -257,7 +257,7 @@ void ufs_panic (struct super_block * sb, const char * function,
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
usb1->fs_clean = UFS_FSBAD; usb1->fs_clean = UFS_FSBAD;
ubh_mark_buffer_dirty(USPI_UBH); ubh_mark_buffer_dirty(USPI_UBH(uspi));
sb->s_dirt = 1; sb->s_dirt = 1;
} }
va_start (args, fmt); va_start (args, fmt);
...@@ -1014,7 +1014,7 @@ static void ufs_write_super (struct super_block *sb) { ...@@ -1014,7 +1014,7 @@ static void ufs_write_super (struct super_block *sb) {
|| (flags & UFS_ST_MASK) == UFS_ST_SUNx86) || (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
ufs_set_fs_state(sb, usb1, usb3, ufs_set_fs_state(sb, usb1, usb3,
UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
} }
sb->s_dirt = 0; sb->s_dirt = 0;
UFSD(("EXIT\n")) UFSD(("EXIT\n"))
...@@ -1083,7 +1083,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) ...@@ -1083,7 +1083,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
|| (flags & UFS_ST_MASK) == UFS_ST_SUNx86) || (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
ufs_set_fs_state(sb, usb1, usb3, ufs_set_fs_state(sb, usb1, usb3,
UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
ubh_mark_buffer_dirty (USPI_UBH); ubh_mark_buffer_dirty (USPI_UBH(uspi));
sb->s_dirt = 0; sb->s_dirt = 0;
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
} }
......
...@@ -63,17 +63,17 @@ struct ufs_buffer_head * ubh_bread_uspi (struct ufs_sb_private_info * uspi, ...@@ -63,17 +63,17 @@ struct ufs_buffer_head * ubh_bread_uspi (struct ufs_sb_private_info * uspi,
count = size >> uspi->s_fshift; count = size >> uspi->s_fshift;
if (count <= 0 || count > UFS_MAXFRAG) if (count <= 0 || count > UFS_MAXFRAG)
return NULL; return NULL;
USPI_UBH->fragment = fragment; USPI_UBH(uspi)->fragment = fragment;
USPI_UBH->count = count; USPI_UBH(uspi)->count = count;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (!(USPI_UBH->bh[i] = sb_bread(sb, fragment + i))) if (!(USPI_UBH(uspi)->bh[i] = sb_bread(sb, fragment + i)))
goto failed; goto failed;
for (; i < UFS_MAXFRAG; i++) for (; i < UFS_MAXFRAG; i++)
USPI_UBH->bh[i] = NULL; USPI_UBH(uspi)->bh[i] = NULL;
return USPI_UBH; return USPI_UBH(uspi);
failed: failed:
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
brelse (USPI_UBH->bh[j]); brelse (USPI_UBH(uspi)->bh[j]);
return NULL; return NULL;
} }
...@@ -90,11 +90,11 @@ void ubh_brelse (struct ufs_buffer_head * ubh) ...@@ -90,11 +90,11 @@ void ubh_brelse (struct ufs_buffer_head * ubh)
void ubh_brelse_uspi (struct ufs_sb_private_info * uspi) void ubh_brelse_uspi (struct ufs_sb_private_info * uspi)
{ {
unsigned i; unsigned i;
if (!USPI_UBH) if (!USPI_UBH(uspi))
return; return;
for ( i = 0; i < USPI_UBH->count; i++ ) { for ( i = 0; i < USPI_UBH(uspi)->count; i++ ) {
brelse (USPI_UBH->bh[i]); brelse (USPI_UBH(uspi)->bh[i]);
USPI_UBH->bh[i] = NULL; USPI_UBH(uspi)->bh[i] = NULL;
} }
} }
......
...@@ -17,10 +17,16 @@ ...@@ -17,10 +17,16 @@
#define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len)) #define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len))
/* /*
* macros used for retyping * functions used for retyping
*/ */
#define UCPI_UBH ((struct ufs_buffer_head *)ucpi) static inline struct ufs_buffer_head *UCPI_UBH(struct ufs_cg_private_info *cpi)
#define USPI_UBH ((struct ufs_buffer_head *)uspi) {
return &cpi->c_ubh;
}
static inline struct ufs_buffer_head *USPI_UBH(struct ufs_sb_private_info *spi)
{
return &spi->s_ubh;
}
...@@ -326,10 +332,10 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, ...@@ -326,10 +332,10 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
* Macros to access cylinder group array structures * Macros to access cylinder group array structures
*/ */
#define ubh_cg_blktot(ucpi,cylno) \ #define ubh_cg_blktot(ucpi,cylno) \
(*((__fs32*)ubh_get_addr(UCPI_UBH, (ucpi)->c_btotoff + ((cylno) << 2)))) (*((__fs32*)ubh_get_addr(UCPI_UBH(ucpi), (ucpi)->c_btotoff + ((cylno) << 2))))
#define ubh_cg_blks(ucpi,cylno,rpos) \ #define ubh_cg_blks(ucpi,cylno,rpos) \
(*((__fs16*)ubh_get_addr(UCPI_UBH, \ (*((__fs16*)ubh_get_addr(UCPI_UBH(ucpi), \
(ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 )))) (ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 ))))
/* /*
......
...@@ -666,7 +666,7 @@ struct ufs_buffer_head { ...@@ -666,7 +666,7 @@ struct ufs_buffer_head {
}; };
struct ufs_cg_private_info { struct ufs_cg_private_info {
struct ufs_cylinder_group ucg; struct ufs_buffer_head c_ubh;
__u32 c_cgx; /* number of cylidner group */ __u32 c_cgx; /* number of cylidner group */
__u16 c_ncyl; /* number of cyl's this cg */ __u16 c_ncyl; /* number of cyl's this cg */
__u16 c_niblk; /* number of inode blocks this cg */ __u16 c_niblk; /* number of inode blocks this cg */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment