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

Commit 815a1130 authored by Theodore Ts'o's avatar Theodore Ts'o
Browse files

ext4: remove ext4_new_blocks() and call ext4_mb_new_blocks() directly



There was only one caller of the compatibility function
ext4_new_blocks(), in balloc.c's ext4_alloc_blocks().  Change it to
call ext4_mb_new_blocks() directly, and remove ext4_new_blocks()
altogether.  This cleans up the code, by removing two extra functions
from the call chain, and hopefully saving some stack usage.

Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 8e1a4857
Loading
Loading
Loading
Loading
+0 −20
Original line number Original line Diff line number Diff line
@@ -741,26 +741,6 @@ ext4_fsblk_t ext4_new_meta_block(handle_t *handle, struct inode *inode,
	return ext4_new_meta_blocks(handle, inode, goal, &count, errp);
	return ext4_new_meta_blocks(handle, inode, goal, &count, errp);
}
}


/*
 * ext4_new_blocks() -- allocate data blocks
 *
 * @handle:             handle to this transaction
 * @inode:              file inode
 * @goal:               given target block(filesystem wide)
 * @count:		total number of blocks need
 * @errp:               error code
 *
 * Return 1st allocated block numberon success, *count stores total account
 * error stores in errp pointer
 */

ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
				ext4_lblk_t iblock, ext4_fsblk_t goal,
				unsigned long *count, int *errp)
{
	return do_blk_alloc(handle, inode, iblock, goal, count, errp, 0);
}

/**
/**
 * ext4_count_free_blocks() -- count filesystem free blocks
 * ext4_count_free_blocks() -- count filesystem free blocks
 * @sb:		superblock
 * @sb:		superblock
+0 −3
Original line number Original line Diff line number Diff line
@@ -1002,9 +1002,6 @@ extern ext4_fsblk_t ext4_new_meta_block(handle_t *handle, struct inode *inode,
			ext4_fsblk_t goal, int *errp);
			ext4_fsblk_t goal, int *errp);
extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
			ext4_fsblk_t goal, unsigned long *count, int *errp);
			ext4_fsblk_t goal, unsigned long *count, int *errp);
extern ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
					ext4_lblk_t iblock, ext4_fsblk_t goal,
					unsigned long *count, int *errp);
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
+13 −5
Original line number Original line Diff line number Diff line
@@ -547,6 +547,7 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
				int indirect_blks, int blks,
				int indirect_blks, int blks,
				ext4_fsblk_t new_blocks[4], int *err)
				ext4_fsblk_t new_blocks[4], int *err)
{
{
	struct ext4_allocation_request ar;
	int target, i;
	int target, i;
	unsigned long count = 0, blk_allocated = 0;
	unsigned long count = 0, blk_allocated = 0;
	int index = 0;
	int index = 0;
@@ -595,10 +596,17 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
	if (!target)
	if (!target)
		goto allocated;
		goto allocated;
	/* Now allocate data blocks */
	/* Now allocate data blocks */
	count = target;
	memset(&ar, 0, sizeof(ar));
	/* allocating blocks for data blocks */
	ar.inode = inode;
	current_block = ext4_new_blocks(handle, inode, iblock,
	ar.goal = goal;
						goal, &count, err);
	ar.len = target;
	ar.logical = iblock;
	if (S_ISREG(inode->i_mode))
		/* enable in-core preallocation only for regular files */
		ar.flags = EXT4_MB_HINT_DATA;

	current_block = ext4_mb_new_blocks(handle, &ar, err);

	if (*err && (target == blks)) {
	if (*err && (target == blks)) {
		/*
		/*
		 * if the allocation failed and we didn't allocate
		 * if the allocation failed and we didn't allocate
@@ -614,7 +622,7 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
		 */
		 */
			new_blocks[index] = current_block;
			new_blocks[index] = current_block;
		}
		}
		blk_allocated += count;
		blk_allocated += ar.len;
	}
	}
allocated:
allocated:
	/* total number of blocks allocated for direct blocks */
	/* total number of blocks allocated for direct blocks */