aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-10-30 14:25:28 -0400
committerChris Mason <chris.mason@oracle.com>2008-10-30 14:25:28 -0400
commitd899e05215178fed903ad0e7fc1cb4d8e0cc0a88 (patch)
tree2969e3558f5c50ec0f9ac4201099c0d5d1d6e2c2 /fs/btrfs/extent_io.c
parent80ff385665b7fca29fefe358a60ab0d09f9b8e87 (diff)
Btrfs: Add fallocate support v2
This patch updates btrfs-progs for fallocate support. fallocate is a little different in Btrfs because we need to tell the COW system that a given preallocated extent doesn't need to be cow'd as long as there are no snapshots of it. This leverages the -o nodatacow checks. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 65a0583027e9..eb3c12e7beaf 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2015,6 +2015,8 @@ printk("2bad mapping end %Lu cur %Lu\n", end, cur);
2015 } 2015 }
2016 bdev = em->bdev; 2016 bdev = em->bdev;
2017 block_start = em->block_start; 2017 block_start = em->block_start;
2018 if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags))
2019 block_start = EXTENT_MAP_HOLE;
2018 free_extent_map(em); 2020 free_extent_map(em);
2019 em = NULL; 2021 em = NULL;
2020 2022
@@ -2769,14 +2771,18 @@ sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
2769 struct inode *inode = mapping->host; 2771 struct inode *inode = mapping->host;
2770 u64 start = iblock << inode->i_blkbits; 2772 u64 start = iblock << inode->i_blkbits;
2771 sector_t sector = 0; 2773 sector_t sector = 0;
2774 size_t blksize = (1 << inode->i_blkbits);
2772 struct extent_map *em; 2775 struct extent_map *em;
2773 2776
2774 em = get_extent(inode, NULL, 0, start, (1 << inode->i_blkbits), 0); 2777 lock_extent(&BTRFS_I(inode)->io_tree, start, start + blksize - 1,
2778 GFP_NOFS);
2779 em = get_extent(inode, NULL, 0, start, blksize, 0);
2780 unlock_extent(&BTRFS_I(inode)->io_tree, start, start + blksize - 1,
2781 GFP_NOFS);
2775 if (!em || IS_ERR(em)) 2782 if (!em || IS_ERR(em))
2776 return 0; 2783 return 0;
2777 2784
2778 if (em->block_start == EXTENT_MAP_INLINE || 2785 if (em->block_start > EXTENT_MAP_LAST_BYTE)
2779 em->block_start == EXTENT_MAP_HOLE)
2780 goto out; 2786 goto out;
2781 2787
2782 sector = (em->block_start + start - em->start) >> inode->i_blkbits; 2788 sector = (em->block_start + start - em->start) >> inode->i_blkbits;