extents.c (3c6fe77017bc6ce489f231c35fed3220b6691836) extents.c (32de67569059d22b02dd9323a40220d953642b7e)
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 *

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

1677 if (unlikely(path[depth].p_hdr == NULL)) {
1678 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
1679 return -EIO;
1680 }
1681
1682 /* try to insert block into found extent and return */
1683 if (ex && !(flag & EXT4_GET_BLOCKS_PRE_IO)
1684 && ext4_can_extents_be_merged(inode, ex, newext)) {
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 *

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

1677 if (unlikely(path[depth].p_hdr == NULL)) {
1678 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
1679 return -EIO;
1680 }
1681
1682 /* try to insert block into found extent and return */
1683 if (ex && !(flag & EXT4_GET_BLOCKS_PRE_IO)
1684 && ext4_can_extents_be_merged(inode, ex, newext)) {
1685 ext_debug("append [%d]%d block to %d:[%d]%d (from %llu)\n",
1685 ext_debug("append [%d]%d block to %u:[%d]%d (from %llu)\n",
1686 ext4_ext_is_uninitialized(newext),
1687 ext4_ext_get_actual_len(newext),
1688 le32_to_cpu(ex->ee_block),
1689 ext4_ext_is_uninitialized(ex),
1690 ext4_ext_get_actual_len(ex),
1691 ext4_ext_pblock(ex));
1692 err = ext4_ext_get_access(handle, inode, path + depth);
1693 if (err)

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

1715 goto has_space;
1716
1717 /* probably next leaf has space for us? */
1718 fex = EXT_LAST_EXTENT(eh);
1719 next = EXT_MAX_BLOCKS;
1720 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block))
1721 next = ext4_ext_next_leaf_block(path);
1722 if (next != EXT_MAX_BLOCKS) {
1686 ext4_ext_is_uninitialized(newext),
1687 ext4_ext_get_actual_len(newext),
1688 le32_to_cpu(ex->ee_block),
1689 ext4_ext_is_uninitialized(ex),
1690 ext4_ext_get_actual_len(ex),
1691 ext4_ext_pblock(ex));
1692 err = ext4_ext_get_access(handle, inode, path + depth);
1693 if (err)

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

1715 goto has_space;
1716
1717 /* probably next leaf has space for us? */
1718 fex = EXT_LAST_EXTENT(eh);
1719 next = EXT_MAX_BLOCKS;
1720 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block))
1721 next = ext4_ext_next_leaf_block(path);
1722 if (next != EXT_MAX_BLOCKS) {
1723 ext_debug("next leaf block - %d\n", next);
1723 ext_debug("next leaf block - %u\n", next);
1724 BUG_ON(npath != NULL);
1725 npath = ext4_ext_find_extent(inode, next, NULL);
1726 if (IS_ERR(npath))
1727 return PTR_ERR(npath);
1728 BUG_ON(npath->p_depth != path->p_depth);
1729 eh = npath[depth].p_hdr;
1730 if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max)) {
1731 ext_debug("next leaf isn't full(%d)\n",

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

1753 nearex = path[depth].p_ext;
1754
1755 err = ext4_ext_get_access(handle, inode, path + depth);
1756 if (err)
1757 goto cleanup;
1758
1759 if (!nearex) {
1760 /* there is no extent in this leaf, create first one */
1724 BUG_ON(npath != NULL);
1725 npath = ext4_ext_find_extent(inode, next, NULL);
1726 if (IS_ERR(npath))
1727 return PTR_ERR(npath);
1728 BUG_ON(npath->p_depth != path->p_depth);
1729 eh = npath[depth].p_hdr;
1730 if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max)) {
1731 ext_debug("next leaf isn't full(%d)\n",

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

1753 nearex = path[depth].p_ext;
1754
1755 err = ext4_ext_get_access(handle, inode, path + depth);
1756 if (err)
1757 goto cleanup;
1758
1759 if (!nearex) {
1760 /* there is no extent in this leaf, create first one */
1761 ext_debug("first extent in the leaf: %d:%llu:[%d]%d\n",
1761 ext_debug("first extent in the leaf: %u:%llu:[%d]%d\n",
1762 le32_to_cpu(newext->ee_block),
1763 ext4_ext_pblock(newext),
1764 ext4_ext_is_uninitialized(newext),
1765 ext4_ext_get_actual_len(newext));
1766 nearex = EXT_FIRST_EXTENT(eh);
1767 } else {
1768 if (le32_to_cpu(newext->ee_block)
1769 > le32_to_cpu(nearex->ee_block)) {
1770 /* Insert after */
1762 le32_to_cpu(newext->ee_block),
1763 ext4_ext_pblock(newext),
1764 ext4_ext_is_uninitialized(newext),
1765 ext4_ext_get_actual_len(newext));
1766 nearex = EXT_FIRST_EXTENT(eh);
1767 } else {
1768 if (le32_to_cpu(newext->ee_block)
1769 > le32_to_cpu(nearex->ee_block)) {
1770 /* Insert after */
1771 ext_debug("insert %d:%llu:[%d]%d %s before: "
1772 "nearest 0x%p\n"
1771 ext_debug("insert %u:%llu:[%d]%d before: "
1772 "nearest %p\n",
1773 le32_to_cpu(newext->ee_block),
1774 ext4_ext_pblock(newext),
1775 ext4_ext_is_uninitialized(newext),
1776 ext4_ext_get_actual_len(newext),
1777 nearex);
1778 nearex++;
1779 } else {
1780 /* Insert before */
1781 BUG_ON(newext->ee_block == nearex->ee_block);
1773 le32_to_cpu(newext->ee_block),
1774 ext4_ext_pblock(newext),
1775 ext4_ext_is_uninitialized(newext),
1776 ext4_ext_get_actual_len(newext),
1777 nearex);
1778 nearex++;
1779 } else {
1780 /* Insert before */
1781 BUG_ON(newext->ee_block == nearex->ee_block);
1782 ext_debug("insert %d:%llu:[%d]%d %s after: "
1783 "nearest 0x%p\n"
1782 ext_debug("insert %u:%llu:[%d]%d after: "
1783 "nearest %p\n",
1784 le32_to_cpu(newext->ee_block),
1785 ext4_ext_pblock(newext),
1786 ext4_ext_is_uninitialized(newext),
1787 ext4_ext_get_actual_len(newext),
1788 nearex);
1789 }
1790 len = EXT_LAST_EXTENT(eh) - nearex + 1;
1791 if (len > 0) {
1784 le32_to_cpu(newext->ee_block),
1785 ext4_ext_pblock(newext),
1786 ext4_ext_is_uninitialized(newext),
1787 ext4_ext_get_actual_len(newext),
1788 nearex);
1789 }
1790 len = EXT_LAST_EXTENT(eh) - nearex + 1;
1791 if (len > 0) {
1792 ext_debug("insert %d:%llu:[%d]%d: "
1792 ext_debug("insert %u:%llu:[%d]%d: "
1793 "move %d extents from 0x%p to 0x%p\n",
1794 le32_to_cpu(newext->ee_block),
1795 ext4_ext_pblock(newext),
1796 ext4_ext_is_uninitialized(newext),
1797 ext4_ext_get_actual_len(newext),
1798 len, nearex, nearex + 1);
1799 memmove(nearex + 1, nearex,
1800 len * sizeof(struct ext4_extent));

--- 3148 unchanged lines hidden ---
1793 "move %d extents from 0x%p to 0x%p\n",
1794 le32_to_cpu(newext->ee_block),
1795 ext4_ext_pblock(newext),
1796 ext4_ext_is_uninitialized(newext),
1797 ext4_ext_get_actual_len(newext),
1798 len, nearex, nearex + 1);
1799 memmove(nearex + 1, nearex,
1800 len * sizeof(struct ext4_extent));

--- 3148 unchanged lines hidden ---