diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-10-15 16:18:25 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:56 -0400 |
commit | 3326d1b07c0cb6a2ff5b835b7a2cffa54124d074 (patch) | |
tree | 16db275e3e8edb35e46fdd9f9a0f3a1c377ada5f /fs/btrfs/inode.c | |
parent | 4dc119046d0d8501afa4346472917fb05586ad9c (diff) |
Btrfs: Allow tails larger than one page
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d6b3a55ed8e0..84f496c838c9 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -87,7 +87,7 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end) | |||
87 | BUG_ON(!trans); | 87 | BUG_ON(!trans); |
88 | num_bytes = (end - start + blocksize) & ~(blocksize - 1); | 88 | num_bytes = (end - start + blocksize) & ~(blocksize - 1); |
89 | ret = btrfs_drop_extents(trans, root, inode, | 89 | ret = btrfs_drop_extents(trans, root, inode, |
90 | start, start + num_bytes, &alloc_hint); | 90 | start, start + num_bytes, start, &alloc_hint); |
91 | 91 | ||
92 | ret = btrfs_alloc_extent(trans, root, inode->i_ino, num_bytes, 0, | 92 | ret = btrfs_alloc_extent(trans, root, inode->i_ino, num_bytes, 0, |
93 | alloc_hint, (u64)-1, &ins, 1); | 93 | alloc_hint, (u64)-1, &ins, 1); |
@@ -776,7 +776,8 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
776 | trans = btrfs_start_transaction(root, 1); | 776 | trans = btrfs_start_transaction(root, 1); |
777 | btrfs_set_trans_block_group(trans, inode); | 777 | btrfs_set_trans_block_group(trans, inode); |
778 | err = btrfs_drop_extents(trans, root, inode, | 778 | err = btrfs_drop_extents(trans, root, inode, |
779 | pos, pos + hole_size, &alloc_hint); | 779 | pos, pos + hole_size, pos, |
780 | &alloc_hint); | ||
780 | 781 | ||
781 | err = btrfs_insert_file_extent(trans, root, inode->i_ino, | 782 | err = btrfs_insert_file_extent(trans, root, inode->i_ino, |
782 | pos, 0, 0, hole_size); | 783 | pos, 0, 0, hole_size); |
@@ -1581,7 +1582,9 @@ again: | |||
1581 | } else if (found_type == BTRFS_FILE_EXTENT_INLINE) { | 1582 | } else if (found_type == BTRFS_FILE_EXTENT_INLINE) { |
1582 | unsigned long ptr; | 1583 | unsigned long ptr; |
1583 | char *map; | 1584 | char *map; |
1584 | u32 size; | 1585 | size_t size; |
1586 | size_t extent_offset; | ||
1587 | size_t copy_size; | ||
1585 | 1588 | ||
1586 | size = btrfs_file_extent_inline_len(leaf, btrfs_item_nr(leaf, | 1589 | size = btrfs_file_extent_inline_len(leaf, btrfs_item_nr(leaf, |
1587 | path->slots[0])); | 1590 | path->slots[0])); |
@@ -1600,26 +1603,31 @@ again: | |||
1600 | goto not_found_em; | 1603 | goto not_found_em; |
1601 | } | 1604 | } |
1602 | 1605 | ||
1606 | extent_offset = (page->index << PAGE_CACHE_SHIFT) - | ||
1607 | extent_start; | ||
1608 | ptr = btrfs_file_extent_inline_start(item) + extent_offset; | ||
1609 | map = kmap(page); | ||
1610 | copy_size = min(PAGE_CACHE_SIZE - page_offset, | ||
1611 | size - extent_offset); | ||
1612 | |||
1603 | em->block_start = EXTENT_MAP_INLINE; | 1613 | em->block_start = EXTENT_MAP_INLINE; |
1604 | em->block_end = EXTENT_MAP_INLINE; | 1614 | em->block_end = EXTENT_MAP_INLINE; |
1605 | em->start = extent_start; | 1615 | em->start = extent_start + extent_offset; |
1606 | em->end = extent_end; | 1616 | em->end = (em->start + copy_size -1) | |
1617 | ((u64)root->sectorsize -1); | ||
1607 | 1618 | ||
1608 | if (!page) { | 1619 | if (!page) { |
1609 | goto insert; | 1620 | goto insert; |
1610 | } | 1621 | } |
1611 | 1622 | ||
1612 | ptr = btrfs_file_extent_inline_start(item); | 1623 | read_extent_buffer(leaf, map + page_offset, ptr, copy_size); |
1613 | map = kmap(page); | ||
1614 | read_extent_buffer(leaf, map + page_offset, ptr, size); | ||
1615 | /* | 1624 | /* |
1616 | memset(map + page_offset + size, 0, | 1625 | memset(map + page_offset + copy_size, 0, |
1617 | root->sectorsize - (page_offset + size)); | 1626 | PAGE_CACHE_SIZE - copy_size - page_offset); |
1618 | */ | 1627 | */ |
1619 | flush_dcache_page(page); | 1628 | flush_dcache_page(page); |
1620 | kunmap(page); | 1629 | kunmap(page); |
1621 | set_extent_uptodate(em_tree, extent_start, | 1630 | set_extent_uptodate(em_tree, em->start, em->end, GFP_NOFS); |
1622 | extent_end, GFP_NOFS); | ||
1623 | goto insert; | 1631 | goto insert; |
1624 | } else { | 1632 | } else { |
1625 | printk("unkknown found_type %d\n", found_type); | 1633 | printk("unkknown found_type %d\n", found_type); |