aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
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
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')
-rw-r--r--fs/ext4/balloc.c2
-rw-r--r--fs/ext4/inode.c36
2 files changed, 16 insertions, 22 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index ae26c37e398e..cca7fd53ad7b 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -2063,7 +2063,7 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
2063 /* 2063 /*
2064 * Account for the allocated meta blocks 2064 * Account for the allocated meta blocks
2065 */ 2065 */
2066 if (!(*errp)) { 2066 if (!(*errp) && EXT4_I(inode)->i_delalloc_reserved_flag) {
2067 spin_lock(&EXT4_I(inode)->i_block_reservation_lock); 2067 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
2068 EXT4_I(inode)->i_allocated_meta_blocks += *count; 2068 EXT4_I(inode)->i_allocated_meta_blocks += *count;
2069 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 2069 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
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,