ext3: Truncate allocated blocks if direct IO write fails to update i_size
authorJan Kara <jack@suse.cz>
Mon, 1 Mar 2010 13:02:37 +0000 (14:02 +0100)
committerJan Kara <jack@suse.cz>
Thu, 4 Mar 2010 23:20:27 +0000 (00:20 +0100)
We have to truncate blocks allocated to file during direct IO when we
fail to update i_size properly.

Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext3/inode.c

index 44b53386ab8b2e0f756e8fefc7d4db861bb191f5..c0ff9d6ffde63ae5e76b4d30c561e1b451671590 100644 (file)
@@ -1785,8 +1785,9 @@ retry:
                handle = ext3_journal_start(inode, 2);
                if (IS_ERR(handle)) {
                        /* This is really bad luck. We've written the data
-                        * but cannot extend i_size. Bail out and pretend
-                        * the write failed... */
+                        * but cannot extend i_size. Truncate allocated blocks
+                        * and pretend the write failed... */
+                       ext3_truncate(inode);
                        ret = PTR_ERR(handle);
                        goto out;
                }