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

Commit 16eb7295 authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Theodore Ts'o
Browse files

ext4: make sure ext4_has_free_blocks returns 0 for ENOSPC



Fix ext4_has_free_blocks() to return 0 when we don't have enough space.

Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: default avatarMingming Cao <cmm@us.ibm.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 525f4ed8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1626,6 +1626,9 @@ ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
		free_blocks =
			percpu_counter_sum_and_set(&sbi->s_freeblocks_counter);
#endif
	if (free_blocks <= root_blocks)
		/* we don't have free space */
		return 0;
	if (free_blocks - root_blocks < nblocks)
		return free_blocks - root_blocks;
	return nblocks;