| Theodore Ts'o | 8bd0c95 | 2002-01-03 03:29:19 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * alloc_stats.c --- Update allocation statistics for ext2fs |
| 3 | * |
| 4 | * Copyright (C) 2001 Theodore Ts'o. |
| 5 | * |
| 6 | * %Begin-Header% |
| 7 | * This file may be redistributed under the terms of the GNU Public |
| 8 | * License. |
| 9 | * %End-Header% |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | |
| 15 | #include "ext2_fs.h" |
| 16 | #include "ext2fs.h" |
| 17 | |
| 18 | void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse) |
| 19 | { |
| 20 | int group = ext2fs_group_of_ino(fs, ino); |
| 21 | |
| 22 | if (inuse > 0) |
| 23 | ext2fs_mark_inode_bitmap(fs->inode_map, ino); |
| 24 | else |
| 25 | ext2fs_unmark_inode_bitmap(fs->inode_map, ino); |
| 26 | fs->group_desc[group].bg_free_inodes_count -= inuse; |
| 27 | fs->super->s_free_inodes_count -= inuse; |
| 28 | ext2fs_mark_super_dirty(fs); |
| 29 | ext2fs_mark_ib_dirty(fs); |
| 30 | } |
| 31 | |
| 32 | void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse) |
| 33 | { |
| 34 | int group = ext2fs_group_of_blk(fs, blk); |
| 35 | |
| 36 | if (inuse > 0) |
| 37 | ext2fs_mark_block_bitmap(fs->block_map, blk); |
| 38 | else |
| 39 | ext2fs_unmark_block_bitmap(fs->block_map, blk); |
| 40 | fs->group_desc[group].bg_free_blocks_count -= inuse; |
| 41 | fs->super->s_free_blocks_count -= inuse; |
| 42 | ext2fs_mark_super_dirty(fs); |
| 43 | ext2fs_mark_bb_dirty(fs); |
| 44 | } |