aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r--fs/ext4/extents.c218
1 files changed, 64 insertions, 154 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 85287742f2ae..19d8059b58aa 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -144,7 +144,7 @@ static int ext4_ext_dirty(handle_t *handle, struct inode *inode,
144 144
145static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, 145static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
146 struct ext4_ext_path *path, 146 struct ext4_ext_path *path,
147 ext4_fsblk_t block) 147 ext4_lblk_t block)
148{ 148{
149 struct ext4_inode_info *ei = EXT4_I(inode); 149 struct ext4_inode_info *ei = EXT4_I(inode);
150 ext4_fsblk_t bg_start; 150 ext4_fsblk_t bg_start;
@@ -367,13 +367,14 @@ static void ext4_ext_drop_refs(struct ext4_ext_path *path)
367 * the header must be checked before calling this 367 * the header must be checked before calling this
368 */ 368 */
369static void 369static void
370ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int block) 370ext4_ext_binsearch_idx(struct inode *inode,
371 struct ext4_ext_path *path, ext4_lblk_t block)
371{ 372{
372 struct ext4_extent_header *eh = path->p_hdr; 373 struct ext4_extent_header *eh = path->p_hdr;
373 struct ext4_extent_idx *r, *l, *m; 374 struct ext4_extent_idx *r, *l, *m;
374 375
375 376
376 ext_debug("binsearch for %d(idx): ", block); 377 ext_debug("binsearch for %lu(idx): ", (unsigned long)block);
377 378
378 l = EXT_FIRST_INDEX(eh) + 1; 379 l = EXT_FIRST_INDEX(eh) + 1;
379 r = EXT_LAST_INDEX(eh); 380 r = EXT_LAST_INDEX(eh);
@@ -425,7 +426,8 @@ ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int bloc
425 * the header must be checked before calling this 426 * the header must be checked before calling this
426 */ 427 */
427static void 428static void
428ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block) 429ext4_ext_binsearch(struct inode *inode,
430 struct ext4_ext_path *path, ext4_lblk_t block)
429{ 431{
430 struct ext4_extent_header *eh = path->p_hdr; 432 struct ext4_extent_header *eh = path->p_hdr;
431 struct ext4_extent *r, *l, *m; 433 struct ext4_extent *r, *l, *m;
@@ -438,7 +440,7 @@ ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block)
438 return; 440 return;
439 } 441 }
440 442
441 ext_debug("binsearch for %d: ", block); 443 ext_debug("binsearch for %lu: ", (unsigned long)block);
442 444
443 l = EXT_FIRST_EXTENT(eh) + 1; 445 l = EXT_FIRST_EXTENT(eh) + 1;
444 r = EXT_LAST_EXTENT(eh); 446 r = EXT_LAST_EXTENT(eh);
@@ -494,7 +496,8 @@ int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
494} 496}
495 497
496struct ext4_ext_path * 498struct ext4_ext_path *
497ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path) 499ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
500 struct ext4_ext_path *path)
498{ 501{
499 struct ext4_extent_header *eh; 502 struct ext4_extent_header *eh;
500 struct buffer_head *bh; 503 struct buffer_head *bh;
@@ -979,8 +982,8 @@ repeat:
979 /* refill path */ 982 /* refill path */
980 ext4_ext_drop_refs(path); 983 ext4_ext_drop_refs(path);
981 path = ext4_ext_find_extent(inode, 984 path = ext4_ext_find_extent(inode,
982 le32_to_cpu(newext->ee_block), 985 (ext4_lblk_t)le32_to_cpu(newext->ee_block),
983 path); 986 path);
984 if (IS_ERR(path)) 987 if (IS_ERR(path))
985 err = PTR_ERR(path); 988 err = PTR_ERR(path);
986 } else { 989 } else {
@@ -992,8 +995,8 @@ repeat:
992 /* refill path */ 995 /* refill path */
993 ext4_ext_drop_refs(path); 996 ext4_ext_drop_refs(path);
994 path = ext4_ext_find_extent(inode, 997 path = ext4_ext_find_extent(inode,
995 le32_to_cpu(newext->ee_block), 998 (ext4_lblk_t)le32_to_cpu(newext->ee_block),
996 path); 999 path);
997 if (IS_ERR(path)) { 1000 if (IS_ERR(path)) {
998 err = PTR_ERR(path); 1001 err = PTR_ERR(path);
999 goto out; 1002 goto out;
@@ -1021,7 +1024,7 @@ out:
1021 * allocated block. Thus, index entries have to be consistent 1024 * allocated block. Thus, index entries have to be consistent
1022 * with leaves. 1025 * with leaves.
1023 */ 1026 */
1024static unsigned long 1027static ext4_lblk_t
1025ext4_ext_next_allocated_block(struct ext4_ext_path *path) 1028ext4_ext_next_allocated_block(struct ext4_ext_path *path)
1026{ 1029{
1027 int depth; 1030 int depth;
@@ -1054,7 +1057,7 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
1054 * ext4_ext_next_leaf_block: 1057 * ext4_ext_next_leaf_block:
1055 * returns first allocated block from next leaf or EXT_MAX_BLOCK 1058 * returns first allocated block from next leaf or EXT_MAX_BLOCK
1056 */ 1059 */
1057static unsigned ext4_ext_next_leaf_block(struct inode *inode, 1060static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
1058 struct ext4_ext_path *path) 1061 struct ext4_ext_path *path)
1059{ 1062{
1060 int depth; 1063 int depth;
@@ -1072,7 +1075,8 @@ static unsigned ext4_ext_next_leaf_block(struct inode *inode,
1072 while (depth >= 0) { 1075 while (depth >= 0) {
1073 if (path[depth].p_idx != 1076 if (path[depth].p_idx !=
1074 EXT_LAST_INDEX(path[depth].p_hdr)) 1077 EXT_LAST_INDEX(path[depth].p_hdr))
1075 return le32_to_cpu(path[depth].p_idx[1].ei_block); 1078 return (ext4_lblk_t)
1079 le32_to_cpu(path[depth].p_idx[1].ei_block);
1076 depth--; 1080 depth--;
1077 } 1081 }
1078 1082
@@ -1239,7 +1243,7 @@ unsigned int ext4_ext_check_overlap(struct inode *inode,
1239 struct ext4_extent *newext, 1243 struct ext4_extent *newext,
1240 struct ext4_ext_path *path) 1244 struct ext4_ext_path *path)
1241{ 1245{
1242 unsigned long b1, b2; 1246 ext4_lblk_t b1, b2;
1243 unsigned int depth, len1; 1247 unsigned int depth, len1;
1244 unsigned int ret = 0; 1248 unsigned int ret = 0;
1245 1249
@@ -1260,7 +1264,7 @@ unsigned int ext4_ext_check_overlap(struct inode *inode,
1260 goto out; 1264 goto out;
1261 } 1265 }
1262 1266
1263 /* check for wrap through zero */ 1267 /* check for wrap through zero on extent logical start block*/
1264 if (b1 + len1 < b1) { 1268 if (b1 + len1 < b1) {
1265 len1 = EXT_MAX_BLOCK - b1; 1269 len1 = EXT_MAX_BLOCK - b1;
1266 newext->ee_len = cpu_to_le16(len1); 1270 newext->ee_len = cpu_to_le16(len1);
@@ -1290,7 +1294,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
1290 struct ext4_extent *ex, *fex; 1294 struct ext4_extent *ex, *fex;
1291 struct ext4_extent *nearex; /* nearest extent */ 1295 struct ext4_extent *nearex; /* nearest extent */
1292 struct ext4_ext_path *npath = NULL; 1296 struct ext4_ext_path *npath = NULL;
1293 int depth, len, err, next; 1297 int depth, len, err;
1298 ext4_lblk_t next;
1294 unsigned uninitialized = 0; 1299 unsigned uninitialized = 0;
1295 1300
1296 BUG_ON(ext4_ext_get_actual_len(newext) == 0); 1301 BUG_ON(ext4_ext_get_actual_len(newext) == 0);
@@ -1435,114 +1440,8 @@ cleanup:
1435 return err; 1440 return err;
1436} 1441}
1437 1442
1438int ext4_ext_walk_space(struct inode *inode, unsigned long block,
1439 unsigned long num, ext_prepare_callback func,
1440 void *cbdata)
1441{
1442 struct ext4_ext_path *path = NULL;
1443 struct ext4_ext_cache cbex;
1444 struct ext4_extent *ex;
1445 unsigned long next, start = 0, end = 0;
1446 unsigned long last = block + num;
1447 int depth, exists, err = 0;
1448
1449 BUG_ON(func == NULL);
1450 BUG_ON(inode == NULL);
1451
1452 while (block < last && block != EXT_MAX_BLOCK) {
1453 num = last - block;
1454 /* find extent for this block */
1455 path = ext4_ext_find_extent(inode, block, path);
1456 if (IS_ERR(path)) {
1457 err = PTR_ERR(path);
1458 path = NULL;
1459 break;
1460 }
1461
1462 depth = ext_depth(inode);
1463 BUG_ON(path[depth].p_hdr == NULL);
1464 ex = path[depth].p_ext;
1465 next = ext4_ext_next_allocated_block(path);
1466
1467 exists = 0;
1468 if (!ex) {
1469 /* there is no extent yet, so try to allocate
1470 * all requested space */
1471 start = block;
1472 end = block + num;
1473 } else if (le32_to_cpu(ex->ee_block) > block) {
1474 /* need to allocate space before found extent */
1475 start = block;
1476 end = le32_to_cpu(ex->ee_block);
1477 if (block + num < end)
1478 end = block + num;
1479 } else if (block >= le32_to_cpu(ex->ee_block)
1480 + ext4_ext_get_actual_len(ex)) {
1481 /* need to allocate space after found extent */
1482 start = block;
1483 end = block + num;
1484 if (end >= next)
1485 end = next;
1486 } else if (block >= le32_to_cpu(ex->ee_block)) {
1487 /*
1488 * some part of requested space is covered
1489 * by found extent
1490 */
1491 start = block;
1492 end = le32_to_cpu(ex->ee_block)
1493 + ext4_ext_get_actual_len(ex);
1494 if (block + num < end)
1495 end = block + num;
1496 exists = 1;
1497 } else {
1498 BUG();
1499 }
1500 BUG_ON(end <= start);
1501
1502 if (!exists) {
1503 cbex.ec_block = start;
1504 cbex.ec_len = end - start;
1505 cbex.ec_start = 0;
1506 cbex.ec_type = EXT4_EXT_CACHE_GAP;
1507 } else {
1508 cbex.ec_block = le32_to_cpu(ex->ee_block);
1509 cbex.ec_len = ext4_ext_get_actual_len(ex);
1510 cbex.ec_start = ext_pblock(ex);
1511 cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
1512 }
1513
1514 BUG_ON(cbex.ec_len == 0);
1515 err = func(inode, path, &cbex, cbdata);
1516 ext4_ext_drop_refs(path);
1517
1518 if (err < 0)
1519 break;
1520 if (err == EXT_REPEAT)
1521 continue;
1522 else if (err == EXT_BREAK) {
1523 err = 0;
1524 break;
1525 }
1526
1527 if (ext_depth(inode) != depth) {
1528 /* depth was changed. we have to realloc path */
1529 kfree(path);
1530 path = NULL;
1531 }
1532
1533 block = cbex.ec_block + cbex.ec_len;
1534 }
1535
1536 if (path) {
1537 ext4_ext_drop_refs(path);
1538 kfree(path);
1539 }
1540
1541 return err;
1542}
1543
1544static void 1443static void
1545ext4_ext_put_in_cache(struct inode *inode, __u32 block, 1444ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
1546 __u32 len, ext4_fsblk_t start, int type) 1445 __u32 len, ext4_fsblk_t start, int type)
1547{ 1446{
1548 struct ext4_ext_cache *cex; 1447 struct ext4_ext_cache *cex;
@@ -1561,10 +1460,11 @@ ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1561 */ 1460 */
1562static void 1461static void
1563ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, 1462ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1564 unsigned long block) 1463 ext4_lblk_t block)
1565{ 1464{
1566 int depth = ext_depth(inode); 1465 int depth = ext_depth(inode);
1567 unsigned long lblock, len; 1466 unsigned long len;
1467 ext4_lblk_t lblock;
1568 struct ext4_extent *ex; 1468 struct ext4_extent *ex;
1569 1469
1570 ex = path[depth].p_ext; 1470 ex = path[depth].p_ext;
@@ -1582,15 +1482,17 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1582 (unsigned long) ext4_ext_get_actual_len(ex)); 1482 (unsigned long) ext4_ext_get_actual_len(ex));
1583 } else if (block >= le32_to_cpu(ex->ee_block) 1483 } else if (block >= le32_to_cpu(ex->ee_block)
1584 + ext4_ext_get_actual_len(ex)) { 1484 + ext4_ext_get_actual_len(ex)) {
1485 ext4_lblk_t next;
1585 lblock = le32_to_cpu(ex->ee_block) 1486 lblock = le32_to_cpu(ex->ee_block)
1586 + ext4_ext_get_actual_len(ex); 1487 + ext4_ext_get_actual_len(ex);
1587 len = ext4_ext_next_allocated_block(path); 1488
1489 next = ext4_ext_next_allocated_block(path);
1588 ext_debug("cache gap(after): [%lu:%lu] %lu", 1490 ext_debug("cache gap(after): [%lu:%lu] %lu",
1589 (unsigned long) le32_to_cpu(ex->ee_block), 1491 (unsigned long) le32_to_cpu(ex->ee_block),
1590 (unsigned long) ext4_ext_get_actual_len(ex), 1492 (unsigned long) ext4_ext_get_actual_len(ex),
1591 (unsigned long) block); 1493 (unsigned long) block);
1592 BUG_ON(len == lblock); 1494 BUG_ON(next == lblock);
1593 len = len - lblock; 1495 len = next - lblock;
1594 } else { 1496 } else {
1595 lblock = len = 0; 1497 lblock = len = 0;
1596 BUG(); 1498 BUG();
@@ -1601,7 +1503,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1601} 1503}
1602 1504
1603static int 1505static int
1604ext4_ext_in_cache(struct inode *inode, unsigned long block, 1506ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
1605 struct ext4_extent *ex) 1507 struct ext4_extent *ex)
1606{ 1508{
1607 struct ext4_ext_cache *cex; 1509 struct ext4_ext_cache *cex;
@@ -1714,7 +1616,7 @@ int ext4_ext_calc_credits_for_insert(struct inode *inode,
1714 1616
1715static int ext4_remove_blocks(handle_t *handle, struct inode *inode, 1617static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
1716 struct ext4_extent *ex, 1618 struct ext4_extent *ex,
1717 unsigned long from, unsigned long to) 1619 ext4_lblk_t from, ext4_lblk_t to)
1718{ 1620{
1719 struct buffer_head *bh; 1621 struct buffer_head *bh;
1720 unsigned short ee_len = ext4_ext_get_actual_len(ex); 1622 unsigned short ee_len = ext4_ext_get_actual_len(ex);
@@ -1738,11 +1640,12 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
1738 if (from >= le32_to_cpu(ex->ee_block) 1640 if (from >= le32_to_cpu(ex->ee_block)
1739 && to == le32_to_cpu(ex->ee_block) + ee_len - 1) { 1641 && to == le32_to_cpu(ex->ee_block) + ee_len - 1) {
1740 /* tail removal */ 1642 /* tail removal */
1741 unsigned long num; 1643 ext4_lblk_t num;
1742 ext4_fsblk_t start; 1644 ext4_fsblk_t start;
1645
1743 num = le32_to_cpu(ex->ee_block) + ee_len - from; 1646 num = le32_to_cpu(ex->ee_block) + ee_len - from;
1744 start = ext_pblock(ex) + ee_len - num; 1647 start = ext_pblock(ex) + ee_len - num;
1745 ext_debug("free last %lu blocks starting %llu\n", num, start); 1648 ext_debug("free last %u blocks starting %llu\n", num, start);
1746 for (i = 0; i < num; i++) { 1649 for (i = 0; i < num; i++) {
1747 bh = sb_find_get_block(inode->i_sb, start + i); 1650 bh = sb_find_get_block(inode->i_sb, start + i);
1748 ext4_forget(handle, 0, inode, bh, start + i); 1651 ext4_forget(handle, 0, inode, bh, start + i);
@@ -1750,30 +1653,32 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
1750 ext4_free_blocks(handle, inode, start, num); 1653 ext4_free_blocks(handle, inode, start, num);
1751 } else if (from == le32_to_cpu(ex->ee_block) 1654 } else if (from == le32_to_cpu(ex->ee_block)
1752 && to <= le32_to_cpu(ex->ee_block) + ee_len - 1) { 1655 && to <= le32_to_cpu(ex->ee_block) + ee_len - 1) {
1753 printk("strange request: removal %lu-%lu from %u:%u\n", 1656 printk(KERN_INFO "strange request: removal %u-%u from %u:%u\n",
1754 from, to, le32_to_cpu(ex->ee_block), ee_len); 1657 from, to, le32_to_cpu(ex->ee_block), ee_len);
1755 } else { 1658 } else {
1756 printk("strange request: removal(2) %lu-%lu from %u:%u\n", 1659 printk(KERN_INFO "strange request: removal(2) "
1757 from, to, le32_to_cpu(ex->ee_block), ee_len); 1660 "%u-%u from %u:%u\n",
1661 from, to, le32_to_cpu(ex->ee_block), ee_len);
1758 } 1662 }
1759 return 0; 1663 return 0;
1760} 1664}
1761 1665
1762static int 1666static int
1763ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, 1667ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
1764 struct ext4_ext_path *path, unsigned long start) 1668 struct ext4_ext_path *path, ext4_lblk_t start)
1765{ 1669{
1766 int err = 0, correct_index = 0; 1670 int err = 0, correct_index = 0;
1767 int depth = ext_depth(inode), credits; 1671 int depth = ext_depth(inode), credits;
1768 struct ext4_extent_header *eh; 1672 struct ext4_extent_header *eh;
1769 unsigned a, b, block, num; 1673 ext4_lblk_t a, b, block;
1770 unsigned long ex_ee_block; 1674 unsigned num;
1675 ext4_lblk_t ex_ee_block;
1771 unsigned short ex_ee_len; 1676 unsigned short ex_ee_len;
1772 unsigned uninitialized = 0; 1677 unsigned uninitialized = 0;
1773 struct ext4_extent *ex; 1678 struct ext4_extent *ex;
1774 1679
1775 /* the header must be checked already in ext4_ext_remove_space() */ 1680 /* the header must be checked already in ext4_ext_remove_space() */
1776 ext_debug("truncate since %lu in leaf\n", start); 1681 ext_debug("truncate since %u in leaf\n", start);
1777 if (!path[depth].p_hdr) 1682 if (!path[depth].p_hdr)
1778 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); 1683 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
1779 eh = path[depth].p_hdr; 1684 eh = path[depth].p_hdr;
@@ -1904,7 +1809,7 @@ ext4_ext_more_to_rm(struct ext4_ext_path *path)
1904 return 1; 1809 return 1;
1905} 1810}
1906 1811
1907int ext4_ext_remove_space(struct inode *inode, unsigned long start) 1812int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start)
1908{ 1813{
1909 struct super_block *sb = inode->i_sb; 1814 struct super_block *sb = inode->i_sb;
1910 int depth = ext_depth(inode); 1815 int depth = ext_depth(inode);
@@ -1912,7 +1817,7 @@ int ext4_ext_remove_space(struct inode *inode, unsigned long start)
1912 handle_t *handle; 1817 handle_t *handle;
1913 int i = 0, err = 0; 1818 int i = 0, err = 0;
1914 1819
1915 ext_debug("truncate since %lu\n", start); 1820 ext_debug("truncate since %u\n", start);
1916 1821
1917 /* probably first extent we're gonna free will be last in block */ 1822 /* probably first extent we're gonna free will be last in block */
1918 handle = ext4_journal_start(inode, depth + 1); 1823 handle = ext4_journal_start(inode, depth + 1);
@@ -2094,17 +1999,19 @@ void ext4_ext_release(struct super_block *sb)
2094 * b> Splits in two extents: Write is happening at either end of the extent 1999 * b> Splits in two extents: Write is happening at either end of the extent
2095 * c> Splits in three extents: Somone is writing in middle of the extent 2000 * c> Splits in three extents: Somone is writing in middle of the extent
2096 */ 2001 */
2097int ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode, 2002static int ext4_ext_convert_to_initialized(handle_t *handle,
2098 struct ext4_ext_path *path, 2003 struct inode *inode,
2099 ext4_fsblk_t iblock, 2004 struct ext4_ext_path *path,
2100 unsigned long max_blocks) 2005 ext4_lblk_t iblock,
2006 unsigned long max_blocks)
2101{ 2007{
2102 struct ext4_extent *ex, newex; 2008 struct ext4_extent *ex, newex;
2103 struct ext4_extent *ex1 = NULL; 2009 struct ext4_extent *ex1 = NULL;
2104 struct ext4_extent *ex2 = NULL; 2010 struct ext4_extent *ex2 = NULL;
2105 struct ext4_extent *ex3 = NULL; 2011 struct ext4_extent *ex3 = NULL;
2106 struct ext4_extent_header *eh; 2012 struct ext4_extent_header *eh;
2107 unsigned int allocated, ee_block, ee_len, depth; 2013 ext4_lblk_t ee_block;
2014 unsigned int allocated, ee_len, depth;
2108 ext4_fsblk_t newblock; 2015 ext4_fsblk_t newblock;
2109 int err = 0; 2016 int err = 0;
2110 int ret = 0; 2017 int ret = 0;
@@ -2226,7 +2133,7 @@ out:
2226} 2133}
2227 2134
2228int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, 2135int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2229 ext4_fsblk_t iblock, 2136 ext4_lblk_t iblock,
2230 unsigned long max_blocks, struct buffer_head *bh_result, 2137 unsigned long max_blocks, struct buffer_head *bh_result,
2231 int create, int extend_disksize) 2138 int create, int extend_disksize)
2232{ 2139{
@@ -2238,8 +2145,9 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2238 unsigned long allocated = 0; 2145 unsigned long allocated = 0;
2239 2146
2240 __clear_bit(BH_New, &bh_result->b_state); 2147 __clear_bit(BH_New, &bh_result->b_state);
2241 ext_debug("blocks %d/%lu requested for inode %u\n", (int) iblock, 2148 ext_debug("blocks %lu/%lu requested for inode %u\n",
2242 max_blocks, (unsigned) inode->i_ino); 2149 (unsigned long) iblock, max_blocks,
2150 (unsigned) inode->i_ino);
2243 mutex_lock(&EXT4_I(inode)->truncate_mutex); 2151 mutex_lock(&EXT4_I(inode)->truncate_mutex);
2244 2152
2245 /* check in cache */ 2153 /* check in cache */
@@ -2288,7 +2196,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2288 2196
2289 ex = path[depth].p_ext; 2197 ex = path[depth].p_ext;
2290 if (ex) { 2198 if (ex) {
2291 unsigned long ee_block = le32_to_cpu(ex->ee_block); 2199 ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block);
2292 ext4_fsblk_t ee_start = ext_pblock(ex); 2200 ext4_fsblk_t ee_start = ext_pblock(ex);
2293 unsigned short ee_len; 2201 unsigned short ee_len;
2294 2202
@@ -2423,7 +2331,7 @@ void ext4_ext_truncate(struct inode * inode, struct page *page)
2423{ 2331{
2424 struct address_space *mapping = inode->i_mapping; 2332 struct address_space *mapping = inode->i_mapping;
2425 struct super_block *sb = inode->i_sb; 2333 struct super_block *sb = inode->i_sb;
2426 unsigned long last_block; 2334 ext4_lblk_t last_block;
2427 handle_t *handle; 2335 handle_t *handle;
2428 int err = 0; 2336 int err = 0;
2429 2337
@@ -2516,7 +2424,8 @@ int ext4_ext_writepage_trans_blocks(struct inode *inode, int num)
2516long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) 2424long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
2517{ 2425{
2518 handle_t *handle; 2426 handle_t *handle;
2519 ext4_fsblk_t block, max_blocks; 2427 ext4_lblk_t block;
2428 unsigned long max_blocks;
2520 ext4_fsblk_t nblocks = 0; 2429 ext4_fsblk_t nblocks = 0;
2521 int ret = 0; 2430 int ret = 0;
2522 int ret2 = 0; 2431 int ret2 = 0;
@@ -2561,8 +2470,9 @@ retry:
2561 if (!ret) { 2470 if (!ret) {
2562 ext4_error(inode->i_sb, "ext4_fallocate", 2471 ext4_error(inode->i_sb, "ext4_fallocate",
2563 "ext4_ext_get_blocks returned 0! inode#%lu" 2472 "ext4_ext_get_blocks returned 0! inode#%lu"
2564 ", block=%llu, max_blocks=%llu", 2473 ", block=%lu, max_blocks=%lu",
2565 inode->i_ino, block, max_blocks); 2474 inode->i_ino, (unsigned long)block,
2475 (unsigned long)max_blocks);
2566 ret = -EIO; 2476 ret = -EIO;
2567 ext4_mark_inode_dirty(handle, inode); 2477 ext4_mark_inode_dirty(handle, inode);
2568 ret2 = ext4_journal_stop(handle); 2478 ret2 = ext4_journal_stop(handle);