aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-09-08 23:08:40 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-09-08 23:08:40 -0400
commit166348dd37a4baacfb6fe495954b56f56b116f0c (patch)
treeafb36ca25ec3bdbd4397a5b952bc78be1e5feff9 /fs/ext4/inode.c
parent68629f29c6764c37ebdceec2f6bbef6637eaf420 (diff)
ext4: Don't add the inode to journal handle until after the block is allocated
Make sure we don't add the inode to the journal handle until after the block allocation, so that a journal commit will not include the inode in case of block allocation failure. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b1a6a7373f07..b567e71f5be9 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2170,18 +2170,24 @@ static int ext4_da_get_block_write(struct inode *inode, sector_t iblock,
2170 handle_t *handle = NULL; 2170 handle_t *handle = NULL;
2171 2171
2172 handle = ext4_journal_current_handle(); 2172 handle = ext4_journal_current_handle();
2173 if (!handle) { 2173 BUG_ON(!handle);
2174 ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks, 2174 ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
2175 bh_result, 0, 0, 0); 2175 bh_result, create, 0, EXT4_DELALLOC_RSVED);
2176 BUG_ON(!ret);
2177 } else {
2178 ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
2179 bh_result, create, 0, EXT4_DELALLOC_RSVED);
2180 }
2181
2182 if (ret > 0) { 2176 if (ret > 0) {
2177
2183 bh_result->b_size = (ret << inode->i_blkbits); 2178 bh_result->b_size = (ret << inode->i_blkbits);
2184 2179
2180 if (ext4_should_order_data(inode)) {
2181 int retval;
2182 retval = ext4_jbd2_file_inode(handle, inode);
2183 if (retval)
2184 /*
2185 * Failed to add inode for ordered
2186 * mode. Don't update file size
2187 */
2188 return retval;
2189 }
2190
2185 /* 2191 /*
2186 * Update on-disk size along with block allocation 2192 * Update on-disk size along with block allocation
2187 * we don't use 'extend_disksize' as size may change 2193 * we don't use 'extend_disksize' as size may change
@@ -2407,18 +2413,6 @@ restart_loop:
2407 dump_stack(); 2413 dump_stack();
2408 goto out_writepages; 2414 goto out_writepages;
2409 } 2415 }
2410 if (ext4_should_order_data(inode)) {
2411 /*
2412 * With ordered mode we need to add
2413 * the inode to the journal handl
2414 * when we do block allocation.
2415 */
2416 ret = ext4_jbd2_file_inode(handle, inode);
2417 if (ret) {
2418 ext4_journal_stop(handle);
2419 goto out_writepages;
2420 }
2421 }
2422 2416
2423 to_write -= wbc->nr_to_write; 2417 to_write -= wbc->nr_to_write;
2424 ret = mpage_da_writepages(mapping, wbc, 2418 ret = mpage_da_writepages(mapping, wbc,