diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3356ab5395f4..5653fa42930b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -416,11 +416,6 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, | |||
416 | } | 416 | } |
417 | if (!(flags & EXT4_GET_BLOCKS_NO_LOCK)) | 417 | if (!(flags & EXT4_GET_BLOCKS_NO_LOCK)) |
418 | up_read((&EXT4_I(inode)->i_data_sem)); | 418 | up_read((&EXT4_I(inode)->i_data_sem)); |
419 | /* | ||
420 | * Clear EXT4_MAP_FROM_CLUSTER and EXT4_MAP_BOUNDARY flag | ||
421 | * because it shouldn't be marked in es_map->m_flags. | ||
422 | */ | ||
423 | map->m_flags &= ~(EXT4_MAP_FROM_CLUSTER | EXT4_MAP_BOUNDARY); | ||
424 | 419 | ||
425 | /* | 420 | /* |
426 | * We don't check m_len because extent will be collpased in status | 421 | * We don't check m_len because extent will be collpased in status |
@@ -491,7 +486,6 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
491 | 486 | ||
492 | /* Lookup extent status tree firstly */ | 487 | /* Lookup extent status tree firstly */ |
493 | if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { | 488 | if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { |
494 | ext4_es_lru_add(inode); | ||
495 | if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { | 489 | if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { |
496 | map->m_pblk = ext4_es_pblock(&es) + | 490 | map->m_pblk = ext4_es_pblock(&es) + |
497 | map->m_lblk - es.es_lblk; | 491 | map->m_lblk - es.es_lblk; |
@@ -1393,7 +1387,6 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, | |||
1393 | 1387 | ||
1394 | /* Lookup extent status tree firstly */ | 1388 | /* Lookup extent status tree firstly */ |
1395 | if (ext4_es_lookup_extent(inode, iblock, &es)) { | 1389 | if (ext4_es_lookup_extent(inode, iblock, &es)) { |
1396 | ext4_es_lru_add(inode); | ||
1397 | if (ext4_es_is_hole(&es)) { | 1390 | if (ext4_es_is_hole(&es)) { |
1398 | retval = 0; | 1391 | retval = 0; |
1399 | down_read(&EXT4_I(inode)->i_data_sem); | 1392 | down_read(&EXT4_I(inode)->i_data_sem); |
@@ -1434,24 +1427,12 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, | |||
1434 | * file system block. | 1427 | * file system block. |
1435 | */ | 1428 | */ |
1436 | down_read(&EXT4_I(inode)->i_data_sem); | 1429 | down_read(&EXT4_I(inode)->i_data_sem); |
1437 | if (ext4_has_inline_data(inode)) { | 1430 | if (ext4_has_inline_data(inode)) |
1438 | /* | ||
1439 | * We will soon create blocks for this page, and let | ||
1440 | * us pretend as if the blocks aren't allocated yet. | ||
1441 | * In case of clusters, we have to handle the work | ||
1442 | * of mapping from cluster so that the reserved space | ||
1443 | * is calculated properly. | ||
1444 | */ | ||
1445 | if ((EXT4_SB(inode->i_sb)->s_cluster_ratio > 1) && | ||
1446 | ext4_find_delalloc_cluster(inode, map->m_lblk)) | ||
1447 | map->m_flags |= EXT4_MAP_FROM_CLUSTER; | ||
1448 | retval = 0; | 1431 | retval = 0; |
1449 | } else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) | 1432 | else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) |
1450 | retval = ext4_ext_map_blocks(NULL, inode, map, | 1433 | retval = ext4_ext_map_blocks(NULL, inode, map, 0); |
1451 | EXT4_GET_BLOCKS_NO_PUT_HOLE); | ||
1452 | else | 1434 | else |
1453 | retval = ext4_ind_map_blocks(NULL, inode, map, | 1435 | retval = ext4_ind_map_blocks(NULL, inode, map, 0); |
1454 | EXT4_GET_BLOCKS_NO_PUT_HOLE); | ||
1455 | 1436 | ||
1456 | add_delayed: | 1437 | add_delayed: |
1457 | if (retval == 0) { | 1438 | if (retval == 0) { |
@@ -1465,7 +1446,8 @@ add_delayed: | |||
1465 | * then we don't need to reserve it again. However we still need | 1446 | * then we don't need to reserve it again. However we still need |
1466 | * to reserve metadata for every block we're going to write. | 1447 | * to reserve metadata for every block we're going to write. |
1467 | */ | 1448 | */ |
1468 | if (!(map->m_flags & EXT4_MAP_FROM_CLUSTER)) { | 1449 | if (EXT4_SB(inode->i_sb)->s_cluster_ratio <= 1 || |
1450 | !ext4_find_delalloc_cluster(inode, map->m_lblk)) { | ||
1469 | ret = ext4_da_reserve_space(inode, iblock); | 1451 | ret = ext4_da_reserve_space(inode, iblock); |
1470 | if (ret) { | 1452 | if (ret) { |
1471 | /* not enough space to reserve */ | 1453 | /* not enough space to reserve */ |
@@ -1481,11 +1463,6 @@ add_delayed: | |||
1481 | goto out_unlock; | 1463 | goto out_unlock; |
1482 | } | 1464 | } |
1483 | 1465 | ||
1484 | /* Clear EXT4_MAP_FROM_CLUSTER flag since its purpose is served | ||
1485 | * and it should not appear on the bh->b_state. | ||
1486 | */ | ||
1487 | map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; | ||
1488 | |||
1489 | map_bh(bh, inode->i_sb, invalid_block); | 1466 | map_bh(bh, inode->i_sb, invalid_block); |
1490 | set_buffer_new(bh); | 1467 | set_buffer_new(bh); |
1491 | set_buffer_delay(bh); | 1468 | set_buffer_delay(bh); |
@@ -3643,7 +3620,7 @@ out_stop: | |||
3643 | * If this was a simple ftruncate() and the file will remain alive, | 3620 | * If this was a simple ftruncate() and the file will remain alive, |
3644 | * then we need to clear up the orphan record which we created above. | 3621 | * then we need to clear up the orphan record which we created above. |
3645 | * However, if this was a real unlink then we were called by | 3622 | * However, if this was a real unlink then we were called by |
3646 | * ext4_delete_inode(), and we allow that function to clean up the | 3623 | * ext4_evict_inode(), and we allow that function to clean up the |
3647 | * orphan info for us. | 3624 | * orphan info for us. |
3648 | */ | 3625 | */ |
3649 | if (inode->i_nlink) | 3626 | if (inode->i_nlink) |