Bug 12829 - kernel complains on ENOSPC
Summary: kernel complains on ENOSPC
Status: CLOSED OBSOLETE
Alias: None
Product: File System
Classification: Unclassified
Component: ext4 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_ext4@kernel-bugs.osdl.org
URL:
Keywords:
: 13604 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-06 14:33 UTC by Eric Sandeen
Modified: 2012-05-30 14:33 UTC (History)
5 users (show)

See Also:
Kernel Version: 2.6.29-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Eric Sandeen 2009-03-06 14:33:05 UTC
while copying a few very large files to ext4:

mpage_da_map_blocks block allocation failed for inode 12289 at logical offset 443072 with max blocks 1036 with error -28
This should not happen.!! Data will be lost
Total free blocks count 0
Free/Dirty block details
free_blocks=0
dirty_blocks=1179
Block reservation details
i_reserved_data_blocks=1174
i_reserved_meta_blocks=5
mpage_da_map_blocks block allocation failed for inode 12289 at logical offset 444108 with max blocks 138 with error -28
This should not happen.!! Data will be lost
Total free blocks count 0
Free/Dirty block details
free_blocks=0
dirty_blocks=1179
Block reservation details
i_reserved_data_blocks=1174
i_reserved_meta_blocks=5

haven't dug into it, but this is just ENOSPC; ext4 should be more graceful.

-Eric
Comment 1 Theodore Tso 2009-03-06 15:02:21 UTC
What are the precise reproduction details?   We're supposed to keep track of how many delayed allocation blocks are outstanding, so that we return ENOSPC *before* we get to this stage.

I'm not sure we do the right thing if we mmap into an unallocated region of file; when do we actually track delayed allocation blocks?   The right answer would be at mmap() time, but OTOH that means if we mmap a 2GB region, do we immediately take a 2GB charge because the process might write into this region?  And does free space returned by 'df' immediately drop by 2GB?

Do you know if there was any allocation by mmap going on in your reproduction case?   That seems the most likely cause to me, if I had to guess....
Comment 2 Eric Sandeen 2009-03-06 15:28:45 UTC
It's a series of big files, just doing cp avi foo/* /mnt/ext4fs/bar

It's a user e2image, so won't share the exact fs but will come up w/ a reproducer.
Comment 3 Aneesh Kumar K.V 2009-03-08 22:17:01 UTC
On Fri, Mar 06, 2009 at 03:02:21PM -0800, bugme-daemon@bugzilla.kernel.org wrote:
> 
> 
> ------- Comment #1 from tytso@mit.edu  2009-03-06 15:02 -------
> What are the precise reproduction details?   We're supposed to keep track of
> how many delayed allocation blocks are outstanding, so that we return ENOSPC
> *before* we get to this stage.

Yes. We should not get the ENOSPC during writeback. That would imply the
block reservation is going wrong.

> 
> I'm not sure we do the right thing if we mmap into an unallocated region of
> file; when do we actually track delayed allocation blocks?   The right answer
> would be at mmap() time, but OTOH that means if we mmap a 2GB region, do we
> immediately take a 2GB charge because the process might write into this
> region?
>  And does free space returned by 'df' immediately drop by 2GB?


For mmap block reservation is doing during page_mkwrite.

> 
> Do you know if there was any allocation by mmap going on in your reproduction
> case?   That seems the most likely cause to me, if I had to guess....
> 

-aneesh
Comment 4 Aneesh Kumar K.V 2009-03-10 09:38:24 UTC
This patch will not fix the problem. But i guess we need this change

-aneesh

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 4415bee..671f215 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4652,11 +4652,11 @@ out1:
 	if (ar->len < inquota)
 		DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len);
 out3:
-	if (!ar->len) {
+	if (ar->len < reserv_blks) {
 		if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag)
 			/* release all the reserved blocks if non delalloc */
 			percpu_counter_sub(&sbi->s_dirtyblocks_counter,
-						reserv_blks);
+						reserv_blks - ar->len);
 	}
 
 	trace_mark(ext4_allocate_blocks,
Comment 5 Theodore Tso 2009-05-19 19:24:03 UTC
Eric --- as a reminder, when you have a chance can you dig into this?   This can cause data loss, so we really should return ENOSPC instead of syslogging the error.
Comment 6 Eric Sandeen 2010-03-15 20:23:26 UTC
*** Bug 13604 has been marked as a duplicate of this bug. ***
Comment 7 Alan 2012-05-30 14:33:32 UTC
Closing as obsolete, if this is incorrect please re-open

Note You need to log in before you can comment on or make changes to this bug.