diff options
Diffstat (limited to 'fs/ext4/indirect.c')
-rw-r--r-- | fs/ext4/indirect.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c index b8d5d351e24f..87b30cd357e7 100644 --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c | |||
@@ -624,7 +624,7 @@ cleanup: | |||
624 | partial--; | 624 | partial--; |
625 | } | 625 | } |
626 | out: | 626 | out: |
627 | trace_ext4_ind_map_blocks_exit(inode, map, err); | 627 | trace_ext4_ind_map_blocks_exit(inode, flags, map, err); |
628 | return err; | 628 | return err; |
629 | } | 629 | } |
630 | 630 | ||
@@ -675,11 +675,6 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, | |||
675 | 675 | ||
676 | retry: | 676 | retry: |
677 | if (rw == READ && ext4_should_dioread_nolock(inode)) { | 677 | if (rw == READ && ext4_should_dioread_nolock(inode)) { |
678 | if (unlikely(atomic_read(&EXT4_I(inode)->i_unwritten))) { | ||
679 | mutex_lock(&inode->i_mutex); | ||
680 | ext4_flush_unwritten_io(inode); | ||
681 | mutex_unlock(&inode->i_mutex); | ||
682 | } | ||
683 | /* | 678 | /* |
684 | * Nolock dioread optimization may be dynamically disabled | 679 | * Nolock dioread optimization may be dynamically disabled |
685 | * via ext4_inode_block_unlocked_dio(). Check inode's state | 680 | * via ext4_inode_block_unlocked_dio(). Check inode's state |
@@ -779,27 +774,18 @@ int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock) | |||
779 | return (blk_bits / EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb)) + 1; | 774 | return (blk_bits / EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb)) + 1; |
780 | } | 775 | } |
781 | 776 | ||
782 | int ext4_ind_trans_blocks(struct inode *inode, int nrblocks, int chunk) | 777 | /* |
778 | * Calculate number of indirect blocks touched by mapping @nrblocks logically | ||
779 | * contiguous blocks | ||
780 | */ | ||
781 | int ext4_ind_trans_blocks(struct inode *inode, int nrblocks) | ||
783 | { | 782 | { |
784 | int indirects; | ||
785 | |||
786 | /* if nrblocks are contiguous */ | ||
787 | if (chunk) { | ||
788 | /* | ||
789 | * With N contiguous data blocks, we need at most | ||
790 | * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks, | ||
791 | * 2 dindirect blocks, and 1 tindirect block | ||
792 | */ | ||
793 | return DIV_ROUND_UP(nrblocks, | ||
794 | EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4; | ||
795 | } | ||
796 | /* | 783 | /* |
797 | * if nrblocks are not contiguous, worse case, each block touch | 784 | * With N contiguous data blocks, we need at most |
798 | * a indirect block, and each indirect block touch a double indirect | 785 | * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks, |
799 | * block, plus a triple indirect block | 786 | * 2 dindirect blocks, and 1 tindirect block |
800 | */ | 787 | */ |
801 | indirects = nrblocks * 2 + 1; | 788 | return DIV_ROUND_UP(nrblocks, EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4; |
802 | return indirects; | ||
803 | } | 789 | } |
804 | 790 | ||
805 | /* | 791 | /* |
@@ -940,11 +926,13 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode, | |||
940 | __le32 *last) | 926 | __le32 *last) |
941 | { | 927 | { |
942 | __le32 *p; | 928 | __le32 *p; |
943 | int flags = EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_VALIDATED; | 929 | int flags = EXT4_FREE_BLOCKS_VALIDATED; |
944 | int err; | 930 | int err; |
945 | 931 | ||
946 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) | 932 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) |
947 | flags |= EXT4_FREE_BLOCKS_METADATA; | 933 | flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA; |
934 | else if (ext4_should_journal_data(inode)) | ||
935 | flags |= EXT4_FREE_BLOCKS_FORGET; | ||
948 | 936 | ||
949 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free, | 937 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free, |
950 | count)) { | 938 | count)) { |