public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: truncate block allocated on a failed ext4_write_begin
@ 2008-08-28 17:27 Aneesh Kumar K.V
  2008-08-28 17:27 ` [PATCH] ext3: truncate block allocated on a failed ext3_write_begin Aneesh Kumar K.V
  0 siblings, 1 reply; 7+ messages in thread
From: Aneesh Kumar K.V @ 2008-08-28 17:27 UTC (permalink / raw)
  To: cmm, tytso, sandeen; +Cc: linux-ext4, Aneesh Kumar K.V

For blocksize < pagesize we need to remove blocks that
got allocte in block_wirte_begin if we fail with ENOSPC
for later blocks. block_write_begin internally does
this if it allocated page locally. This make sure
we don't have blocks outisde inode.i_size during
ENOSPC

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/inode.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 473d888..a8c6bc8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1394,6 +1394,13 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
  		unlock_page(page);
 		ext4_journal_stop(handle);
  		page_cache_release(page);
+		/*
+		 * block_write_begin may have instantiated a few blocks
+		 * outside i_size.  Trim these off again. Don't need
+		 * i_size_read because we hold i_mutex.
+		 */
+		if (pos + len > inode->i_size)
+			vmtruncate(inode, inode->i_size);
 	}
 
 	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
-- 
1.6.0.1.90.g27a6e


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-08-29 14:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-28 17:27 [PATCH] ext4: truncate block allocated on a failed ext4_write_begin Aneesh Kumar K.V
2008-08-28 17:27 ` [PATCH] ext3: truncate block allocated on a failed ext3_write_begin Aneesh Kumar K.V
2008-08-28 17:27   ` [PATCH] ext4: Properly update i_disksize Aneesh Kumar K.V
2008-08-28 17:56   ` [PATCH] ext3: truncate block allocated on a failed ext3_write_begin Eric Sandeen
2008-08-29 14:44     ` Aneesh Kumar K.V
2008-08-29  8:33   ` Dmitri Monakhov
2008-08-29  9:51     ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox