Skip to content

Commit c5df105

Browse files
author
Al Viro
committed
ufs_clusteracct(): switch to passing fragment number
Currently all callers pass it a block number. All of them have it derived from a fragment number (both fragment and block numbers are within a cylinder group, and thus 32bit). Pass it the fragment number instead; none of the callers has other uses for the block number, so that ends up with cleaner code. Signed-off-by: Al Viro <[email protected]>
1 parent dce3e8d commit c5df105

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

fs/ufs/balloc.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
4343
struct ufs_cg_private_info * ucpi;
4444
struct ufs_cylinder_group * ucg;
4545
unsigned cgno, bit, end_bit, bbase, blkmap, i;
46-
u64 blkno;
4746

4847
sb = inode->i_sb;
4948
uspi = UFS_SB(sb)->s_uspi;
@@ -94,13 +93,12 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
9493
/*
9594
* Trying to reassemble free fragments into block
9695
*/
97-
blkno = ufs_fragstoblks (bbase);
9896
if (ubh_isblockset(uspi, ucpi, bbase)) {
9997
fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb);
10098
uspi->cs_total.cs_nffree -= uspi->s_fpb;
10199
fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb);
102100
if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
103-
ufs_clusteracct (sb, ucpi, blkno, 1);
101+
ufs_clusteracct(sb, ucpi, bbase, 1);
104102
fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1);
105103
uspi->cs_total.cs_nbfree++;
106104
fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nbfree, 1);
@@ -139,7 +137,6 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)
139137
struct ufs_cg_private_info * ucpi;
140138
struct ufs_cylinder_group * ucg;
141139
unsigned overflow, cgno, bit, end_bit, i;
142-
u64 blkno;
143140

144141
sb = inode->i_sb;
145142
uspi = UFS_SB(sb)->s_uspi;
@@ -181,14 +178,13 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)
181178
}
182179

183180
for (i = bit; i < end_bit; i += uspi->s_fpb) {
184-
blkno = ufs_fragstoblks(i);
185181
if (ubh_isblockset(uspi, ucpi, i)) {
186182
ufs_error(sb, "ufs_free_blocks", "freeing free fragment");
187183
}
188184
ubh_setblock(uspi, ucpi, i);
189185
inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift);
190186
if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
191-
ufs_clusteracct (sb, ucpi, blkno, 1);
187+
ufs_clusteracct(sb, ucpi, i, 1);
192188

193189
fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1);
194190
uspi->cs_total.cs_nbfree++;
@@ -698,7 +694,7 @@ static u64 ufs_alloccg_block(struct inode *inode,
698694
struct super_block * sb;
699695
struct ufs_sb_private_info * uspi;
700696
struct ufs_cylinder_group * ucg;
701-
u64 result, blkno;
697+
u64 result;
702698

703699
UFSD("ENTER, goal %llu\n", (unsigned long long)goal);
704700

@@ -729,10 +725,9 @@ static u64 ufs_alloccg_block(struct inode *inode,
729725
gotit:
730726
if (!try_add_frags(inode, uspi->s_fpb))
731727
return 0;
732-
blkno = ufs_fragstoblks(result);
733728
ubh_clrblock(uspi, ucpi, result);
734729
if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
735-
ufs_clusteracct (sb, ucpi, blkno, -1);
730+
ufs_clusteracct(sb, ucpi, result, -1);
736731

737732
fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1);
738733
uspi->cs_total.cs_nbfree--;
@@ -863,12 +858,12 @@ static u64 ufs_bitmap_search(struct super_block *sb,
863858
}
864859

865860
static void ufs_clusteracct(struct super_block * sb,
866-
struct ufs_cg_private_info * ucpi, unsigned blkno, int cnt)
861+
struct ufs_cg_private_info * ucpi, unsigned frag, int cnt)
867862
{
868-
struct ufs_sb_private_info * uspi;
863+
struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi;
869864
int i, start, end, forw, back;
865+
unsigned blkno = ufs_fragstoblks(frag);
870866

871-
uspi = UFS_SB(sb)->s_uspi;
872867
if (uspi->s_contigsumsize <= 0)
873868
return;
874869

0 commit comments

Comments
 (0)