Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Change the xattr entry hash to use an unsighed char by default
[tools/e2fsprogs.git]
/
lib
/
ext2fs
/
alloc_stats.c
diff --git
a/lib/ext2fs/alloc_stats.c
b/lib/ext2fs/alloc_stats.c
index
5bb86ef
..
6f98bcc
100644
(file)
--- a/
lib/ext2fs/alloc_stats.c
+++ b/
lib/ext2fs/alloc_stats.c
@@
-20,13
+20,13
@@
void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
{
int group = ext2fs_group_of_ino(fs, ino);
-#ifndef OMIT_COM_ERR
if (ino > fs->super->s_inodes_count) {
+#ifndef OMIT_COM_ERR
com_err("ext2fs_inode_alloc_stats2", 0,
"Illegal inode number: %lu", (unsigned long) ino);
+#endif
return;
}
-#endif
if (inuse > 0)
ext2fs_mark_inode_bitmap2(fs->inode_map, ino);
else
@@
-62,13
+62,14
@@
void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
{
int group = ext2fs_group_of_blk2(fs, blk);
+ if (blk < fs->super->s_first_data_block ||
+ blk >= ext2fs_blocks_count(fs->super)) {
#ifndef OMIT_COM_ERR
- if (blk >= ext2fs_blocks_count(fs->super)) {
com_err("ext2fs_block_alloc_stats", 0,
"Illegal block number: %lu", (unsigned long) blk);
+#endif
return;
}
-#endif
if (inuse > 0)
ext2fs_mark_block_bitmap2(fs->block_map, blk);
else
@@
-78,7
+79,7
@@
void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
ext2fs_group_desc_csum_set(fs, group);
ext2fs_free_blocks_count_add(fs->super,
-
-inuse *
EXT2FS_CLUSTER_RATIO(fs));
+
-inuse * (blk64_t)
EXT2FS_CLUSTER_RATIO(fs));
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
if (fs->block_alloc_stats)
@@
-129,7
+130,7
@@
void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
while (num) {
int group = ext2fs_group_of_blk2(fs, blk);
blk64_t last_blk = ext2fs_group_last_block2(fs, group);
- blk_t n = num;
+ blk
64
_t n = num;
if (blk + num > last_blk)
n = last_blk - blk + 1;
@@
-139,10
+140,26
@@
void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
inuse*n/EXT2FS_CLUSTER_RATIO(fs));
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
ext2fs_group_desc_csum_set(fs, group);
- ext2fs_free_blocks_count_add(fs->super, -inuse * n);
+ ext2fs_free_blocks_count_add(fs->super, -inuse *
(blk64_t)
n);
blk += n;
num -= n;
}
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
+ if (fs->block_alloc_stats_range)
+ (fs->block_alloc_stats_range)(fs, blk, num, inuse);
+}
+
+void ext2fs_set_block_alloc_stats_range_callback(ext2_filsys fs,
+ void (*func)(ext2_filsys fs, blk64_t blk,
+ blk_t num, int inuse),
+ void (**old)(ext2_filsys fs, blk64_t blk,
+ blk_t num, int inuse))
+{
+ if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS)
+ return;
+ if (old)
+ *old = fs->block_alloc_stats_range;
+
+ fs->block_alloc_stats_range = func;
}