Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext4_fs_put_block_group_ref missing in early returns. #57

Open
wzx-ipads opened this issue Dec 16, 2021 · 0 comments
Open

ext4_fs_put_block_group_ref missing in early returns. #57

wzx-ipads opened this issue Dec 16, 2021 · 0 comments

Comments

@wzx-ipads
Copy link
Contributor

In int ext4_balloc_alloc_block(), ext4_fs_put_block_group_ref() should be called in early returns in line#440 and line#455.

        /* Try to find free block near to goal */
	uint32_t tmp_idx;
	for (tmp_idx = idx_in_bg + 1; tmp_idx < end_idx; ++tmp_idx) {
		if (ext4_bmap_is_bit_clr(b.data, tmp_idx)) {
			ext4_bmap_bit_set(b.data, tmp_idx);

			ext4_balloc_set_bitmap_csum(sb, bg, b.data);
			ext4_trans_set_block_dirty(b.buf);
			r = ext4_block_set(inode_ref->fs->bdev, &b);
			if (r != EOK)
				return r;

			alloc = ext4_fs_bg_idx_to_addr(sb, tmp_idx, bg_id);
			goto success;
		}
	}

        /* Find free bit in bitmap */
	r = ext4_bmap_bit_find_clr(b.data, idx_in_bg, blk_in_bg, &rel_blk_idx);
	if (r == EOK) {
		ext4_bmap_bit_set(b.data, rel_blk_idx);
		ext4_balloc_set_bitmap_csum(sb, bg_ref.block_group, b.data);
		ext4_trans_set_block_dirty(b.buf);
		r = ext4_block_set(inode_ref->fs->bdev, &b);
		if (r != EOK)
			return r;

		alloc = ext4_fs_bg_idx_to_addr(sb, rel_blk_idx, bg_id);
		goto success;
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant