~csurbhi/ubuntu/maverick/e2fsprogs/e2fsprogs.fix-505719

« back to all changes in this revision

Viewing changes to lib/ext2fs/alloc_stats.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2008-08-08 20:32:11 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808203211-w72lpsd9q7o3bw6x
Tags: 1.41.0-3ubuntu1
* Merge from Debian unstable (LP: #254152, #246461), remaining changes:
  - Do not build-depend on dietlibc-dev, which is in universe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        fs->group_desc[group].bg_free_inodes_count -= inuse;
28
28
        if (isdir)
29
29
                fs->group_desc[group].bg_used_dirs_count += inuse;
 
30
 
 
31
        /* We don't strictly need to be clearing the uninit flag if inuse < 0
 
32
         * (i.e. freeing inodes) but it also means something is bad. */
 
33
        fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
 
34
        if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
 
35
                                       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
 
36
                ext2_ino_t first_unused_inode = fs->super->s_inodes_per_group -
 
37
                        fs->group_desc[group].bg_itable_unused +
 
38
                        group * fs->super->s_inodes_per_group + 1;
 
39
 
 
40
                if (ino >= first_unused_inode)
 
41
                        fs->group_desc[group].bg_itable_unused =
 
42
                                group * fs->super->s_inodes_per_group +
 
43
                                fs->super->s_inodes_per_group - ino;
 
44
                ext2fs_group_desc_csum_set(fs, group);
 
45
        }
 
46
 
30
47
        fs->super->s_free_inodes_count -= inuse;
31
48
        ext2fs_mark_super_dirty(fs);
32
49
        ext2fs_mark_ib_dirty(fs);
46
63
        else
47
64
                ext2fs_unmark_block_bitmap(fs->block_map, blk);
48
65
        fs->group_desc[group].bg_free_blocks_count -= inuse;
 
66
        fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
 
67
        ext2fs_group_desc_csum_set(fs, group);
 
68
 
49
69
        fs->super->s_free_blocks_count -= inuse;
50
70
        ext2fs_mark_super_dirty(fs);
51
71
        ext2fs_mark_bb_dirty(fs);
 
72
        if (fs->block_alloc_stats)
 
73
                (fs->block_alloc_stats)(fs, (blk64_t) blk, inuse);
 
74
}
 
75
 
 
76
void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, 
 
77
                                           void (*func)(ext2_filsys fs,
 
78
                                                        blk64_t blk,
 
79
                                                        int inuse),
 
80
                                           void (**old)(ext2_filsys fs,
 
81
                                                        blk64_t blk,
 
82
                                                        int inuse))
 
83
{
 
84
        if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS)
 
85
                return;
 
86
        if (old)
 
87
                *old = fs->block_alloc_stats;
 
88
 
 
89
        fs->block_alloc_stats = func;
52
90
}