Lines Matching refs:sb
32 void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, in ext4_get_group_no_and_offset() argument
35 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_get_group_no_and_offset()
39 offset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb)); in ext4_get_group_no_and_offset()
47 static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block, in ext4_block_in_group() argument
51 ext4_get_group_no_and_offset(sb, block, &actual_group, NULL); in ext4_block_in_group()
57 static int ext4_group_used_meta_blocks(struct super_block *sb, in ext4_group_used_meta_blocks() argument
61 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_group_used_meta_blocks()
65 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) { in ext4_group_used_meta_blocks()
69 gdp = ext4_get_group_desc(sb, block_group, &bh); in ext4_group_used_meta_blocks()
70 if (!ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp), in ext4_group_used_meta_blocks()
74 if (!ext4_block_in_group(sb, ext4_inode_bitmap(sb, gdp), in ext4_group_used_meta_blocks()
78 tmp = ext4_inode_table(sb, gdp); in ext4_group_used_meta_blocks()
79 for (; tmp < ext4_inode_table(sb, gdp) + in ext4_group_used_meta_blocks()
81 if (!ext4_block_in_group(sb, tmp, block_group)) in ext4_group_used_meta_blocks()
90 unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, in ext4_init_block_bitmap() argument
95 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_init_block_bitmap()
103 ext4_error(sb, __func__, in ext4_init_block_bitmap()
105 ext4_free_blks_set(sb, gdp, 0); in ext4_init_block_bitmap()
106 ext4_free_inodes_set(sb, gdp, 0); in ext4_init_block_bitmap()
107 ext4_itable_unused_set(sb, gdp, 0); in ext4_init_block_bitmap()
108 memset(bh->b_data, 0xff, sb->s_blocksize); in ext4_init_block_bitmap()
111 memset(bh->b_data, 0, sb->s_blocksize); in ext4_init_block_bitmap()
115 bit_max = ext4_bg_has_super(sb, block_group); in ext4_init_block_bitmap()
117 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) || in ext4_init_block_bitmap()
121 bit_max += ext4_bg_num_gdb(sb, block_group); in ext4_init_block_bitmap()
126 bit_max += ext4_bg_num_gdb(sb, block_group); in ext4_init_block_bitmap()
137 (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)); in ext4_init_block_bitmap()
139 group_blocks = EXT4_BLOCKS_PER_GROUP(sb); in ext4_init_block_bitmap()
151 start = ext4_group_first_block_no(sb, block_group); in ext4_init_block_bitmap()
153 if (EXT4_HAS_INCOMPAT_FEATURE(sb, in ext4_init_block_bitmap()
158 tmp = ext4_block_bitmap(sb, gdp); in ext4_init_block_bitmap()
159 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group)) in ext4_init_block_bitmap()
162 tmp = ext4_inode_bitmap(sb, gdp); in ext4_init_block_bitmap()
163 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group)) in ext4_init_block_bitmap()
166 tmp = ext4_inode_table(sb, gdp); in ext4_init_block_bitmap()
167 for (; tmp < ext4_inode_table(sb, gdp) + in ext4_init_block_bitmap()
170 ext4_block_in_group(sb, tmp, block_group)) in ext4_init_block_bitmap()
178 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data); in ext4_init_block_bitmap()
180 return free_blocks - ext4_group_used_meta_blocks(sb, block_group); in ext4_init_block_bitmap()
205 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, in ext4_get_group_desc() argument
212 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_get_group_desc()
215 ext4_error(sb, "ext4_get_group_desc", in ext4_get_group_desc()
224 group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb); in ext4_get_group_desc()
225 offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1); in ext4_get_group_desc()
227 ext4_error(sb, "ext4_get_group_desc", in ext4_get_group_desc()
236 offset * EXT4_DESC_SIZE(sb)); in ext4_get_group_desc()
242 static int ext4_valid_block_bitmap(struct super_block *sb, in ext4_valid_block_bitmap() argument
252 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) { in ext4_valid_block_bitmap()
261 group_first_block = ext4_group_first_block_no(sb, block_group); in ext4_valid_block_bitmap()
264 bitmap_blk = ext4_block_bitmap(sb, desc); in ext4_valid_block_bitmap()
271 bitmap_blk = ext4_inode_bitmap(sb, desc); in ext4_valid_block_bitmap()
278 bitmap_blk = ext4_inode_table(sb, desc); in ext4_valid_block_bitmap()
281 offset + EXT4_SB(sb)->s_itb_per_group, in ext4_valid_block_bitmap()
283 if (next_zero_bit >= offset + EXT4_SB(sb)->s_itb_per_group) in ext4_valid_block_bitmap()
288 ext4_error(sb, __func__, in ext4_valid_block_bitmap()
305 ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group) in ext4_read_block_bitmap() argument
311 desc = ext4_get_group_desc(sb, block_group, NULL); in ext4_read_block_bitmap()
314 bitmap_blk = ext4_block_bitmap(sb, desc); in ext4_read_block_bitmap()
315 bh = sb_getblk(sb, bitmap_blk); in ext4_read_block_bitmap()
317 ext4_error(sb, __func__, in ext4_read_block_bitmap()
332 spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group)); in ext4_read_block_bitmap()
334 ext4_init_block_bitmap(sb, bh, block_group, desc); in ext4_read_block_bitmap()
337 spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); in ext4_read_block_bitmap()
341 spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); in ext4_read_block_bitmap()
360 ext4_error(sb, __func__, in ext4_read_block_bitmap()
366 ext4_valid_block_bitmap(sb, desc, block_group, bh); in ext4_read_block_bitmap()
385 void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, in ext4_add_groupblocks() argument
400 sbi = EXT4_SB(sb); in ext4_add_groupblocks()
404 ext4_get_group_no_and_offset(sb, block, &block_group, &bit); in ext4_add_groupblocks()
405 grp = ext4_get_group_info(sb, block_group); in ext4_add_groupblocks()
410 if (bit + count > EXT4_BLOCKS_PER_GROUP(sb)) { in ext4_add_groupblocks()
413 bitmap_bh = ext4_read_block_bitmap(sb, block_group); in ext4_add_groupblocks()
416 desc = ext4_get_group_desc(sb, block_group, &gd_bh); in ext4_add_groupblocks()
420 if (in_range(ext4_block_bitmap(sb, desc), block, count) || in ext4_add_groupblocks()
421 in_range(ext4_inode_bitmap(sb, desc), block, count) || in ext4_add_groupblocks()
422 in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) || in ext4_add_groupblocks()
423 in_range(block + count - 1, ext4_inode_table(sb, desc), in ext4_add_groupblocks()
425 ext4_error(sb, __func__, in ext4_add_groupblocks()
459 ext4_error(sb, __func__, in ext4_add_groupblocks()
468 blk_free_count = blocks_freed + ext4_free_blks_count(sb, desc); in ext4_add_groupblocks()
469 ext4_free_blks_set(sb, desc, blk_free_count); in ext4_add_groupblocks()
497 sb->s_dirt = 1; in ext4_add_groupblocks()
501 ext4_std_error(sb, err); in ext4_add_groupblocks()
517 struct super_block *sb; in ext4_free_blocks() local
534 sb = inode->i_sb; in ext4_free_blocks()
610 int ext4_should_retry_alloc(struct super_block *sb, int *retries) in ext4_should_retry_alloc() argument
612 if (!ext4_has_free_blocks(EXT4_SB(sb), 1) || in ext4_should_retry_alloc()
614 !EXT4_SB(sb)->s_journal) in ext4_should_retry_alloc()
617 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); in ext4_should_retry_alloc()
619 return jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); in ext4_should_retry_alloc()
667 ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb) in ext4_count_free_blocks() argument
672 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; in ext4_count_free_blocks()
679 es = EXT4_SB(sb)->s_es; in ext4_count_free_blocks()
686 gdp = ext4_get_group_desc(sb, i, NULL); in ext4_count_free_blocks()
689 desc_count += ext4_free_blks_count(sb, gdp); in ext4_count_free_blocks()
691 bitmap_bh = ext4_read_block_bitmap(sb, i); in ext4_count_free_blocks()
695 x = ext4_count_free(bitmap_bh, sb->s_blocksize); in ext4_count_free_blocks()
697 i, ext4_free_blks_count(sb, gdp), x); in ext4_count_free_blocks()
709 gdp = ext4_get_group_desc(sb, i, NULL); in ext4_count_free_blocks()
712 desc_count += ext4_free_blks_count(sb, gdp); in ext4_count_free_blocks()
746 int ext4_bg_has_super(struct super_block *sb, ext4_group_t group) in ext4_bg_has_super() argument
748 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, in ext4_bg_has_super()
755 static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, in ext4_bg_num_gdb_meta() argument
758 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb); in ext4_bg_num_gdb_meta()
759 ext4_group_t first = metagroup * EXT4_DESC_PER_BLOCK(sb); in ext4_bg_num_gdb_meta()
760 ext4_group_t last = first + EXT4_DESC_PER_BLOCK(sb) - 1; in ext4_bg_num_gdb_meta()
767 static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, in ext4_bg_num_gdb_nometa() argument
770 return ext4_bg_has_super(sb, group) ? EXT4_SB(sb)->s_gdb_count : 0; in ext4_bg_num_gdb_nometa()
782 unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group) in ext4_bg_num_gdb() argument
785 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg); in ext4_bg_num_gdb()
786 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb); in ext4_bg_num_gdb()
788 if (!EXT4_HAS_INCOMPAT_FEATURE(sb,EXT4_FEATURE_INCOMPAT_META_BG) || in ext4_bg_num_gdb()
790 return ext4_bg_num_gdb_nometa(sb, group); in ext4_bg_num_gdb()
792 return ext4_bg_num_gdb_meta(sb,group); in ext4_bg_num_gdb()