10 #include <linux/slab.h>
20 pr_debug(
"AFFS: count_free_blocks()\n");
27 bm = AFFS_SB(sb)->s_bitmap;
29 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
42 struct buffer_head *bh;
46 pr_debug(
"AFFS: free_block(%u)\n", block);
61 bh = affs_bread(sb, bm->
bm_key);
68 mask = 1 << (bit & 31);
69 data = (
__be32 *)bh->b_data + bit / 32 + 1;
89 affs_warning(sb,
"affs_free_block",
"Trying to free block %u which is already free", block);
101 affs_error(sb,
"affs_free_block",
"Block %u outside partition", block);
120 struct buffer_head *bh;
128 pr_debug(
"AFFS: balloc(inode=%lu,goal=%u): ", inode->
i_ino, goal);
130 if (AFFS_I(inode)->i_pa_cnt) {
131 pr_debug(
"%d\n", AFFS_I(inode)->i_lastalloc+1);
132 AFFS_I(inode)->i_pa_cnt--;
133 return ++AFFS_I(inode)->i_lastalloc;
138 affs_warning(sb,
"affs_balloc",
"invalid goal %d", goal);
174 bh = affs_bread(sb, bm->
bm_key);
183 data = (
__be32 *)bh->b_data + bit / 32 + 1;
185 mask = ~0
UL << (bit & 31);
195 if (++data >= enddata)
206 bit =
ffs(tmp & mask) - 1;
208 mask2 = mask = 1 << (bit & 31);
209 AFFS_I(inode)->i_lastalloc =
blk;
212 while ((mask2 <<= 1)) {
215 AFFS_I(inode)->i_pa_cnt++;
218 bm->
bm_free -= AFFS_I(inode)->i_pa_cnt + 1;
247 struct buffer_head *bmap_bh =
NULL, *bh =
NULL;
283 bh = affs_bread(sb, bm->
bm_key);
301 if (++blk < end || i == 1)
304 affs_brelse(bmap_bh);
305 bmap_bh = affs_bread(sb,
be32_to_cpu(bmap_blk[blk]));
311 bmap_blk = (
__be32 *)bmap_bh->b_data;
317 mask = ~(0xFFFFFFFFU << (offset & 31));
318 pr_debug(
"last word: %d %d %d\n", offset, offset / 32 + 1, mask);
319 offset = offset / 32 + 1;
340 ((
__be32 *)bh->b_data)[0] = 0;
350 affs_brelse(bmap_bh);