aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2013-01-28 13:06:48 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-01-28 13:06:48 -0500
commitb6a8e62f8b0aec7607c947ba0d37d30fef65440f (patch)
tree8227ba01c4f38e032aeb1b8c3c4a45d9e171643a /fs/ext4/inode.c
parentf8bec37037aceb126d695c021cf4dc93b7238d47 (diff)
ext4: simplify mpage_add_bh_to_extent()
The argument b_size of mpage_add_bh_to_extent() was bogus since it was always == blocksize (which we can easily derive from inode->i_blkbits). Also second branch of condition: if (nrblocks >= EXT4_MAX_TRANS_DATA) { } else if ((nrblocks + (b_size >> mpd->inode->i_blkbits)) > EXT4_MAX_TRANS_DATA) { } was never taken because (b_size >> mpd->inode->i_blkbits) == 1. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8a89cbbf0f1a..6824cb1bd1bb 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1647,16 +1647,16 @@ submit_io:
1647 * 1647 *
1648 * @mpd->lbh - extent of blocks 1648 * @mpd->lbh - extent of blocks
1649 * @logical - logical number of the block in the file 1649 * @logical - logical number of the block in the file
1650 * @bh - bh of the block (used to access block's state) 1650 * @b_state - b_state of the buffer head added
1651 * 1651 *
1652 * the function is used to collect contig. blocks in same state 1652 * the function is used to collect contig. blocks in same state
1653 */ 1653 */
1654static void mpage_add_bh_to_extent(struct mpage_da_data *mpd, 1654static void mpage_add_bh_to_extent(struct mpage_da_data *mpd, sector_t logical,
1655 sector_t logical, size_t b_size,
1656 unsigned long b_state) 1655 unsigned long b_state)
1657{ 1656{
1658 sector_t next; 1657 sector_t next;
1659 int nrblocks = mpd->b_size >> mpd->inode->i_blkbits; 1658 int blkbits = mpd->inode->i_blkbits;
1659 int nrblocks = mpd->b_size >> blkbits;
1660 1660
1661 /* 1661 /*
1662 * XXX Don't go larger than mballoc is willing to allocate 1662 * XXX Don't go larger than mballoc is willing to allocate
@@ -1664,11 +1664,11 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
1664 * mpage_da_submit_io() into this function and then call 1664 * mpage_da_submit_io() into this function and then call
1665 * ext4_map_blocks() multiple times in a loop 1665 * ext4_map_blocks() multiple times in a loop
1666 */ 1666 */
1667 if (nrblocks >= 8*1024*1024/mpd->inode->i_sb->s_blocksize) 1667 if (nrblocks >= (8*1024*1024 >> blkbits))
1668 goto flush_it; 1668 goto flush_it;
1669 1669
1670 /* check if thereserved journal credits might overflow */ 1670 /* check if the reserved journal credits might overflow */
1671 if (!(ext4_test_inode_flag(mpd->inode, EXT4_INODE_EXTENTS))) { 1671 if (!ext4_test_inode_flag(mpd->inode, EXT4_INODE_EXTENTS)) {
1672 if (nrblocks >= EXT4_MAX_TRANS_DATA) { 1672 if (nrblocks >= EXT4_MAX_TRANS_DATA) {
1673 /* 1673 /*
1674 * With non-extent format we are limited by the journal 1674 * With non-extent format we are limited by the journal
@@ -1677,16 +1677,6 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
1677 * nrblocks. So limit nrblocks. 1677 * nrblocks. So limit nrblocks.
1678 */ 1678 */
1679 goto flush_it; 1679 goto flush_it;
1680 } else if ((nrblocks + (b_size >> mpd->inode->i_blkbits)) >
1681 EXT4_MAX_TRANS_DATA) {
1682 /*
1683 * Adding the new buffer_head would make it cross the
1684 * allowed limit for which we have journal credit
1685 * reserved. So limit the new bh->b_size
1686 */
1687 b_size = (EXT4_MAX_TRANS_DATA - nrblocks) <<
1688 mpd->inode->i_blkbits;
1689 /* we will do mpage_da_submit_io in the next loop */
1690 } 1680 }
1691 } 1681 }
1692 /* 1682 /*
@@ -1694,7 +1684,7 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
1694 */ 1684 */
1695 if (mpd->b_size == 0) { 1685 if (mpd->b_size == 0) {
1696 mpd->b_blocknr = logical; 1686 mpd->b_blocknr = logical;
1697 mpd->b_size = b_size; 1687 mpd->b_size = 1 << blkbits;
1698 mpd->b_state = b_state & BH_FLAGS; 1688 mpd->b_state = b_state & BH_FLAGS;
1699 return; 1689 return;
1700 } 1690 }
@@ -1704,7 +1694,7 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
1704 * Can we merge the block to our big extent? 1694 * Can we merge the block to our big extent?
1705 */ 1695 */
1706 if (logical == next && (b_state & BH_FLAGS) == mpd->b_state) { 1696 if (logical == next && (b_state & BH_FLAGS) == mpd->b_state) {
1707 mpd->b_size += b_size; 1697 mpd->b_size += 1 << blkbits;
1708 return; 1698 return;
1709 } 1699 }
1710 1700
@@ -2156,7 +2146,6 @@ static int write_cache_pages_da(handle_t *handle,
2156 */ 2146 */
2157 if (ext4_bh_delay_or_unwritten(NULL, bh)) { 2147 if (ext4_bh_delay_or_unwritten(NULL, bh)) {
2158 mpage_add_bh_to_extent(mpd, logical, 2148 mpage_add_bh_to_extent(mpd, logical,
2159 bh->b_size,
2160 bh->b_state); 2149 bh->b_state);
2161 if (mpd->io_done) 2150 if (mpd->io_done)
2162 goto ret_extent_tail; 2151 goto ret_extent_tail;