11 #include <linux/time.h>
20 #include <linux/slab.h>
29 static struct kmem_cache *ext4_system_zone_cachep;
34 if (ext4_system_zone_cachep ==
NULL)
57 static int add_system_zone(
struct ext4_sb_info *sbi,
68 if (start_blk < entry->start_blk)
70 else if (start_blk >= (entry->start_blk + entry->count))
73 if (start_blk + count > (entry->start_blk +
75 entry->count = (start_blk + count -
91 new_node = &new_entry->
node;
93 rb_link_node(new_node, parent, n);
101 if (can_merge(entry, new_entry)) {
103 new_entry->
count += entry->count;
113 if (can_merge(new_entry, entry)) {
114 new_entry->
count += entry->count;
122 static void debug_print_tree(
struct ext4_sb_info *sbi)
132 printk(
"%s%llu-%llu", first ?
"" :
", ",
143 struct ext4_sb_info *sbi =
EXT4_SB(sb);
146 int flex_size = ext4_flex_bg_size(sbi);
149 if (!
test_opt(sb, BLOCK_VALIDITY)) {
150 if (
EXT4_SB(sb)->system_blks.rb_node)
154 if (
EXT4_SB(sb)->system_blks.rb_node)
157 for (i=0; i < ngroups; i++) {
159 ((i < 5) || ((i % flex_size) == 0)))
160 add_system_zone(sbi, ext4_group_first_block_no(sb, i),
170 sbi->s_itb_per_group);
226 struct rb_node *n = sbi->system_blks.rb_node;
228 if ((start_blk <=
le32_to_cpu(sbi->s_es->s_first_data_block)) ||
229 (start_blk + count < start_blk) ||
230 (start_blk + count > ext4_blocks_count(sbi->s_es))) {
231 sbi->s_es->s_last_error_block =
cpu_to_le64(start_blk);
236 if (start_blk + count - 1 < entry->
start_blk)
241 sbi->s_es->s_last_error_block =
cpu_to_le64(start_blk);
255 while (bref < p+max) {