Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2dc52b5 authored by Theodore Ts'o's avatar Theodore Ts'o
Browse files

ext4: Add BUG_ON debugging checks to noalloc_get_block_write()



Enforce that noalloc_get_block_write() is only called to map one block
at a time, and that it always is successful in finding a mapping for
given an inode's logical block block number if it is called with
create == 1.

Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent b920c755
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -2433,11 +2433,14 @@ static int noalloc_get_block_write(struct inode *inode, sector_t iblock,
	int ret = 0;
	int ret = 0;
	unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
	unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;


	BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);

	/*
	/*
	 * we don't want to do block allocation in writepage
	 * we don't want to do block allocation in writepage
	 * so call get_block_wrap with create = 0
	 * so call get_block_wrap with create = 0
	 */
	 */
	ret = ext4_get_blocks(NULL, inode, iblock, max_blocks, bh_result, 0);
	ret = ext4_get_blocks(NULL, inode, iblock, max_blocks, bh_result, 0);
	BUG_ON(create && ret == 0);
	if (ret > 0) {
	if (ret > 0) {
		bh_result->b_size = (ret << inode->i_blkbits);
		bh_result->b_size = (ret << inode->i_blkbits);
		ret = 0;
		ret = 0;