diff options
Diffstat (limited to 'fs/ext3/inode.c')
| -rw-r--r-- | fs/ext3/inode.c | 32 | 
1 files changed, 13 insertions, 19 deletions
| diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 5f51fed5c750..b49908a167ae 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
| @@ -788,7 +788,7 @@ err_out: | |||
| 788 | int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, | 788 | int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, | 
| 789 | sector_t iblock, unsigned long maxblocks, | 789 | sector_t iblock, unsigned long maxblocks, | 
| 790 | struct buffer_head *bh_result, | 790 | struct buffer_head *bh_result, | 
| 791 | int create, int extend_disksize) | 791 | int create) | 
| 792 | { | 792 | { | 
| 793 | int err = -EIO; | 793 | int err = -EIO; | 
| 794 | int offsets[4]; | 794 | int offsets[4]; | 
| @@ -911,13 +911,6 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, | |||
| 911 | if (!err) | 911 | if (!err) | 
| 912 | err = ext3_splice_branch(handle, inode, iblock, | 912 | err = ext3_splice_branch(handle, inode, iblock, | 
| 913 | partial, indirect_blks, count); | 913 | partial, indirect_blks, count); | 
| 914 | /* | ||
| 915 | * i_disksize growing is protected by truncate_mutex. Don't forget to | ||
| 916 | * protect it if you're about to implement concurrent | ||
| 917 | * ext3_get_block() -bzzz | ||
| 918 | */ | ||
| 919 | if (!err && extend_disksize && inode->i_size > ei->i_disksize) | ||
| 920 | ei->i_disksize = inode->i_size; | ||
| 921 | mutex_unlock(&ei->truncate_mutex); | 914 | mutex_unlock(&ei->truncate_mutex); | 
| 922 | if (err) | 915 | if (err) | 
| 923 | goto cleanup; | 916 | goto cleanup; | 
| @@ -972,7 +965,7 @@ static int ext3_get_block(struct inode *inode, sector_t iblock, | |||
| 972 | } | 965 | } | 
| 973 | 966 | ||
| 974 | ret = ext3_get_blocks_handle(handle, inode, iblock, | 967 | ret = ext3_get_blocks_handle(handle, inode, iblock, | 
| 975 | max_blocks, bh_result, create, 0); | 968 | max_blocks, bh_result, create); | 
| 976 | if (ret > 0) { | 969 | if (ret > 0) { | 
| 977 | bh_result->b_size = (ret << inode->i_blkbits); | 970 | bh_result->b_size = (ret << inode->i_blkbits); | 
| 978 | ret = 0; | 971 | ret = 0; | 
| @@ -1005,7 +998,7 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode, | |||
| 1005 | dummy.b_blocknr = -1000; | 998 | dummy.b_blocknr = -1000; | 
| 1006 | buffer_trace_init(&dummy.b_history); | 999 | buffer_trace_init(&dummy.b_history); | 
| 1007 | err = ext3_get_blocks_handle(handle, inode, block, 1, | 1000 | err = ext3_get_blocks_handle(handle, inode, block, 1, | 
| 1008 | &dummy, create, 1); | 1001 | &dummy, create); | 
| 1009 | /* | 1002 | /* | 
| 1010 | * ext3_get_blocks_handle() returns number of blocks | 1003 | * ext3_get_blocks_handle() returns number of blocks | 
| 1011 | * mapped. 0 in case of a HOLE. | 1004 | * mapped. 0 in case of a HOLE. | 
| @@ -1193,15 +1186,16 @@ write_begin_failed: | |||
| 1193 | * i_size_read because we hold i_mutex. | 1186 | * i_size_read because we hold i_mutex. | 
| 1194 | * | 1187 | * | 
| 1195 | * Add inode to orphan list in case we crash before truncate | 1188 | * Add inode to orphan list in case we crash before truncate | 
| 1196 | * finishes. | 1189 | * finishes. Do this only if ext3_can_truncate() agrees so | 
| 1190 | * that orphan processing code is happy. | ||
| 1197 | */ | 1191 | */ | 
| 1198 | if (pos + len > inode->i_size) | 1192 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) | 
| 1199 | ext3_orphan_add(handle, inode); | 1193 | ext3_orphan_add(handle, inode); | 
| 1200 | ext3_journal_stop(handle); | 1194 | ext3_journal_stop(handle); | 
| 1201 | unlock_page(page); | 1195 | unlock_page(page); | 
| 1202 | page_cache_release(page); | 1196 | page_cache_release(page); | 
| 1203 | if (pos + len > inode->i_size) | 1197 | if (pos + len > inode->i_size) | 
| 1204 | vmtruncate(inode, inode->i_size); | 1198 | ext3_truncate(inode); | 
| 1205 | } | 1199 | } | 
| 1206 | if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) | 1200 | if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) | 
| 1207 | goto retry; | 1201 | goto retry; | 
| @@ -1287,7 +1281,7 @@ static int ext3_ordered_write_end(struct file *file, | |||
| 1287 | * There may be allocated blocks outside of i_size because | 1281 | * There may be allocated blocks outside of i_size because | 
| 1288 | * we failed to copy some data. Prepare for truncate. | 1282 | * we failed to copy some data. Prepare for truncate. | 
| 1289 | */ | 1283 | */ | 
| 1290 | if (pos + len > inode->i_size) | 1284 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) | 
| 1291 | ext3_orphan_add(handle, inode); | 1285 | ext3_orphan_add(handle, inode); | 
| 1292 | ret2 = ext3_journal_stop(handle); | 1286 | ret2 = ext3_journal_stop(handle); | 
| 1293 | if (!ret) | 1287 | if (!ret) | 
| @@ -1296,7 +1290,7 @@ static int ext3_ordered_write_end(struct file *file, | |||
| 1296 | page_cache_release(page); | 1290 | page_cache_release(page); | 
| 1297 | 1291 | ||
| 1298 | if (pos + len > inode->i_size) | 1292 | if (pos + len > inode->i_size) | 
| 1299 | vmtruncate(inode, inode->i_size); | 1293 | ext3_truncate(inode); | 
| 1300 | return ret ? ret : copied; | 1294 | return ret ? ret : copied; | 
| 1301 | } | 1295 | } | 
| 1302 | 1296 | ||
| @@ -1315,14 +1309,14 @@ static int ext3_writeback_write_end(struct file *file, | |||
| 1315 | * There may be allocated blocks outside of i_size because | 1309 | * There may be allocated blocks outside of i_size because | 
| 1316 | * we failed to copy some data. Prepare for truncate. | 1310 | * we failed to copy some data. Prepare for truncate. | 
| 1317 | */ | 1311 | */ | 
| 1318 | if (pos + len > inode->i_size) | 1312 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) | 
| 1319 | ext3_orphan_add(handle, inode); | 1313 | ext3_orphan_add(handle, inode); | 
| 1320 | ret = ext3_journal_stop(handle); | 1314 | ret = ext3_journal_stop(handle); | 
| 1321 | unlock_page(page); | 1315 | unlock_page(page); | 
| 1322 | page_cache_release(page); | 1316 | page_cache_release(page); | 
| 1323 | 1317 | ||
| 1324 | if (pos + len > inode->i_size) | 1318 | if (pos + len > inode->i_size) | 
| 1325 | vmtruncate(inode, inode->i_size); | 1319 | ext3_truncate(inode); | 
| 1326 | return ret ? ret : copied; | 1320 | return ret ? ret : copied; | 
| 1327 | } | 1321 | } | 
| 1328 | 1322 | ||
| @@ -1358,7 +1352,7 @@ static int ext3_journalled_write_end(struct file *file, | |||
| 1358 | * There may be allocated blocks outside of i_size because | 1352 | * There may be allocated blocks outside of i_size because | 
| 1359 | * we failed to copy some data. Prepare for truncate. | 1353 | * we failed to copy some data. Prepare for truncate. | 
| 1360 | */ | 1354 | */ | 
| 1361 | if (pos + len > inode->i_size) | 1355 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) | 
| 1362 | ext3_orphan_add(handle, inode); | 1356 | ext3_orphan_add(handle, inode); | 
| 1363 | EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; | 1357 | EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; | 
| 1364 | if (inode->i_size > EXT3_I(inode)->i_disksize) { | 1358 | if (inode->i_size > EXT3_I(inode)->i_disksize) { | 
| @@ -1375,7 +1369,7 @@ static int ext3_journalled_write_end(struct file *file, | |||
| 1375 | page_cache_release(page); | 1369 | page_cache_release(page); | 
| 1376 | 1370 | ||
| 1377 | if (pos + len > inode->i_size) | 1371 | if (pos + len > inode->i_size) | 
| 1378 | vmtruncate(inode, inode->i_size); | 1372 | ext3_truncate(inode); | 
| 1379 | return ret ? ret : copied; | 1373 | return ret ? ret : copied; | 
| 1380 | } | 1374 | } | 
| 1381 | 1375 | ||
