extents.c (56055d3ae4cc7fa6d2b10885f20269de8a989ed7) extents.c (749269facaf87f6e516c3af12763e03181b9c139)
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * Architecture independence:
6 * Copyright (c) 2005, Bull S.A.
7 * Written by Pierre Peiffer <pierre.peiffer@bull.net>
8 *

--- 1093 unchanged lines hidden (view full) ---

1102
1103 return err;
1104}
1105
1106static int
1107ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
1108 struct ext4_extent *ex2)
1109{
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * Architecture independence:
6 * Copyright (c) 2005, Bull S.A.
7 * Written by Pierre Peiffer <pierre.peiffer@bull.net>
8 *

--- 1093 unchanged lines hidden (view full) ---

1102
1103 return err;
1104}
1105
1106static int
1107ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
1108 struct ext4_extent *ex2)
1109{
1110 unsigned short ext1_ee_len, ext2_ee_len;
1110 unsigned short ext1_ee_len, ext2_ee_len, max_len;
1111
1112 /*
1113 * Make sure that either both extents are uninitialized, or
1114 * both are _not_.
1115 */
1116 if (ext4_ext_is_uninitialized(ex1) ^ ext4_ext_is_uninitialized(ex2))
1117 return 0;
1118
1111
1112 /*
1113 * Make sure that either both extents are uninitialized, or
1114 * both are _not_.
1115 */
1116 if (ext4_ext_is_uninitialized(ex1) ^ ext4_ext_is_uninitialized(ex2))
1117 return 0;
1118
1119 if (ext4_ext_is_uninitialized(ex1))
1120 max_len = EXT_UNINIT_MAX_LEN;
1121 else
1122 max_len = EXT_INIT_MAX_LEN;
1123
1119 ext1_ee_len = ext4_ext_get_actual_len(ex1);
1120 ext2_ee_len = ext4_ext_get_actual_len(ex2);
1121
1122 if (le32_to_cpu(ex1->ee_block) + ext1_ee_len !=
1123 le32_to_cpu(ex2->ee_block))
1124 return 0;
1125
1126 /*
1127 * To allow future support for preallocated extents to be added
1128 * as an RO_COMPAT feature, refuse to merge to extents if
1129 * this can result in the top bit of ee_len being set.
1130 */
1124 ext1_ee_len = ext4_ext_get_actual_len(ex1);
1125 ext2_ee_len = ext4_ext_get_actual_len(ex2);
1126
1127 if (le32_to_cpu(ex1->ee_block) + ext1_ee_len !=
1128 le32_to_cpu(ex2->ee_block))
1129 return 0;
1130
1131 /*
1132 * To allow future support for preallocated extents to be added
1133 * as an RO_COMPAT feature, refuse to merge to extents if
1134 * this can result in the top bit of ee_len being set.
1135 */
1131 if (ext1_ee_len + ext2_ee_len > EXT_MAX_LEN)
1136 if (ext1_ee_len + ext2_ee_len > max_len)
1132 return 0;
1133#ifdef AGGRESSIVE_TEST
1134 if (le16_to_cpu(ex1->ee_len) >= 4)
1135 return 0;
1136#endif
1137
1138 if (ext_pblock(ex1) + ext1_ee_len == ext_pblock(ex2))
1139 return 1;

--- 670 unchanged lines hidden (view full) ---

1810 if (num == 0) {
1811 /* this extent is removed; mark slot entirely unused */
1812 ext4_ext_store_pblock(ex, 0);
1813 eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
1814 }
1815
1816 ex->ee_block = cpu_to_le32(block);
1817 ex->ee_len = cpu_to_le16(num);
1137 return 0;
1138#ifdef AGGRESSIVE_TEST
1139 if (le16_to_cpu(ex1->ee_len) >= 4)
1140 return 0;
1141#endif
1142
1143 if (ext_pblock(ex1) + ext1_ee_len == ext_pblock(ex2))
1144 return 1;

--- 670 unchanged lines hidden (view full) ---

1815 if (num == 0) {
1816 /* this extent is removed; mark slot entirely unused */
1817 ext4_ext_store_pblock(ex, 0);
1818 eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
1819 }
1820
1821 ex->ee_block = cpu_to_le32(block);
1822 ex->ee_len = cpu_to_le16(num);
1818 if (uninitialized)
1823 /*
1824 * Do not mark uninitialized if all the blocks in the
1825 * extent have been removed.
1826 */
1827 if (uninitialized && num)
1819 ext4_ext_mark_uninitialized(ex);
1820
1821 err = ext4_ext_dirty(handle, inode, path + depth);
1822 if (err)
1823 goto out;
1824
1825 ext_debug("new extent: %u:%u:%llu\n", block, num,
1826 ext_pblock(ex));

--- 476 unchanged lines hidden (view full) ---

2303 * allocation info here if necessary.
2304 */
2305 if (S_ISREG(inode->i_mode) && (!EXT4_I(inode)->i_block_alloc_info))
2306 ext4_init_block_alloc_info(inode);
2307
2308 /* allocate new block */
2309 goal = ext4_ext_find_goal(inode, path, iblock);
2310
1828 ext4_ext_mark_uninitialized(ex);
1829
1830 err = ext4_ext_dirty(handle, inode, path + depth);
1831 if (err)
1832 goto out;
1833
1834 ext_debug("new extent: %u:%u:%llu\n", block, num,
1835 ext_pblock(ex));

--- 476 unchanged lines hidden (view full) ---

2312 * allocation info here if necessary.
2313 */
2314 if (S_ISREG(inode->i_mode) && (!EXT4_I(inode)->i_block_alloc_info))
2315 ext4_init_block_alloc_info(inode);
2316
2317 /* allocate new block */
2318 goal = ext4_ext_find_goal(inode, path, iblock);
2319
2320 /*
2321 * See if request is beyond maximum number of blocks we can have in
2322 * a single extent. For an initialized extent this limit is
2323 * EXT_INIT_MAX_LEN and for an uninitialized extent this limit is
2324 * EXT_UNINIT_MAX_LEN.
2325 */
2326 if (max_blocks > EXT_INIT_MAX_LEN &&
2327 create != EXT4_CREATE_UNINITIALIZED_EXT)
2328 max_blocks = EXT_INIT_MAX_LEN;
2329 else if (max_blocks > EXT_UNINIT_MAX_LEN &&
2330 create == EXT4_CREATE_UNINITIALIZED_EXT)
2331 max_blocks = EXT_UNINIT_MAX_LEN;
2332
2311 /* Check if we can really insert (iblock)::(iblock+max_blocks) extent */
2312 newex.ee_block = cpu_to_le32(iblock);
2313 newex.ee_len = cpu_to_le16(max_blocks);
2314 err = ext4_ext_check_overlap(inode, &newex, path);
2315 if (err)
2316 allocated = le16_to_cpu(newex.ee_len);
2317 else
2318 allocated = max_blocks;

--- 258 unchanged lines hidden ---
2333 /* Check if we can really insert (iblock)::(iblock+max_blocks) extent */
2334 newex.ee_block = cpu_to_le32(iblock);
2335 newex.ee_len = cpu_to_le16(max_blocks);
2336 err = ext4_ext_check_overlap(inode, &newex, path);
2337 if (err)
2338 allocated = le16_to_cpu(newex.ee_len);
2339 else
2340 allocated = max_blocks;

--- 258 unchanged lines hidden ---