Add ext4-printk-throttling patch
[ext4-patch-queue.git] / ext4_truncate_block_allocated_on_a_failed_ext4_write_begin.patch
blob61624cdf572ab1c79b4d0bc275a77e5657bebcb4
1 ext4: truncate block allocated on a failed ext4_write_begin
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 For blocksize < pagesize we need to remove blocks that got allocated in
6 block_write_begin() if we fail with ENOSPC for later blocks.
7 block_write_begin() internally does this if it allocated page
8 locally. This makes sure we don't have blocks outside inode.i_size
9 during ENOSPC.
11 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
14 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
15 index 5a595af..6cfe142 100644
16 --- a/fs/ext4/inode.c
17 +++ b/fs/ext4/inode.c
18 @@ -1391,6 +1391,13 @@ retry:
19 unlock_page(page);
20 ext4_journal_stop(handle);
21 page_cache_release(page);
22 + /*
23 + * block_write_begin may have instantiated a few blocks
24 + * outside i_size. Trim these off again. Don't need
25 + * i_size_read because we hold i_mutex.
26 + */
27 + if (pos + len > inode->i_size)
28 + vmtruncate(inode, inode->i_size);
31 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))