aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-09-13 13:10:25 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-09-13 13:10:25 -0400
commitae4d537211ff250a8c23c4f1227c4276cd2508ab (patch)
tree58aeb4ba30d0ae5b3bff93933200001349547721 /fs/ext4
parentdf22291ff0fde0d350cf15dac3e5cc33ac528875 (diff)
ext4: truncate block allocated on a failed ext4_write_begin
For blocksize < pagesize we need to remove blocks that got allocated in block_write_begin() if we fail with ENOSPC for later blocks. block_write_begin() internally does this if it allocated pages locally. This makes sure we don't have blocks outside inode.i_size during ENOSPC. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f97b3478eb89..634f0bc75700 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1391,6 +1391,13 @@ retry:
1391 unlock_page(page); 1391 unlock_page(page);
1392 ext4_journal_stop(handle); 1392 ext4_journal_stop(handle);
1393 page_cache_release(page); 1393 page_cache_release(page);
1394 /*
1395 * block_write_begin may have instantiated a few blocks
1396 * outside i_size. Trim these off again. Don't need
1397 * i_size_read because we hold i_mutex.
1398 */
1399 if (pos + len > inode->i_size)
1400 vmtruncate(inode, inode->i_size);
1394 } 1401 }
1395 1402
1396 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 1403 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
@@ -2560,6 +2567,13 @@ retry:
2560 unlock_page(page); 2567 unlock_page(page);
2561 ext4_journal_stop(handle); 2568 ext4_journal_stop(handle);
2562 page_cache_release(page); 2569 page_cache_release(page);
2570 /*
2571 * block_write_begin may have instantiated a few blocks
2572 * outside i_size. Trim these off again. Don't need
2573 * i_size_read because we hold i_mutex.
2574 */
2575 if (pos + len > inode->i_size)
2576 vmtruncate(inode, inode->i_size);
2563 } 2577 }
2564 2578
2565 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 2579 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))