1 ext4: make sure ext4_has_free_blocks returns 0 for ENOSPC
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 Fix ext4_has_free_blocks() to return 0 when we don't have enough space.
7 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
9 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 fs/ext4/balloc.c | 3 +++
13 1 file changed, 3 insertions(+)
15 Index: linux-2.6.27-rc3/fs/ext4/balloc.c
16 ===================================================================
17 --- linux-2.6.27-rc3.orig/fs/ext4/balloc.c 2008-08-18 11:38:07.000000000 -0700
18 +++ linux-2.6.27-rc3/fs/ext4/balloc.c 2008-08-18 11:40:12.000000000 -0700
19 @@ -1626,6 +1626,9 @@ ext4_fsblk_t ext4_has_free_blocks(struct
21 percpu_counter_sum_and_set(&sbi->s_freeblocks_counter);
23 + if (free_blocks <= root_blocks)
24 + /* we don't have free space */
26 if (free_blocks - root_blocks < nblocks)
27 return free_blocks - root_blocks;