aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-13 19:00:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-13 19:00:49 -0400
commit0e5b88cd9975dca6c191cc9bd11f233fac4ca882 (patch)
tree6302317acfb24d6b5ad7924aceaa0dd1c4a7a371 /fs/btrfs/extent_io.c
parenteebea5d13d391981061d6ef069a841002eba4a7a (diff)
parent36e39c40b3facc9b489a13f1d301fc53ff6960a3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: Btrfs: break out of shrink_delalloc earlier btrfs: fix not enough reserved space btrfs: fix dip leak Btrfs: make sure not to return overlapping extents to fiemap Btrfs: deal with short returns from copy_from_user Btrfs: fix regressions in copy_from_user handling
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fd3f172e94e6..714adc4ac4c2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3046,17 +3046,38 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3046 } 3046 }
3047 3047
3048 while (!end) { 3048 while (!end) {
3049 off = extent_map_end(em); 3049 u64 offset_in_extent;
3050 if (off >= max) 3050
3051 end = 1; 3051 /* break if the extent we found is outside the range */
3052 if (em->start >= max || extent_map_end(em) < off)
3053 break;
3054
3055 /*
3056 * get_extent may return an extent that starts before our
3057 * requested range. We have to make sure the ranges
3058 * we return to fiemap always move forward and don't
3059 * overlap, so adjust the offsets here
3060 */
3061 em_start = max(em->start, off);
3052 3062
3053 em_start = em->start; 3063 /*
3054 em_len = em->len; 3064 * record the offset from the start of the extent
3065 * for adjusting the disk offset below
3066 */
3067 offset_in_extent = em_start - em->start;
3055 em_end = extent_map_end(em); 3068 em_end = extent_map_end(em);
3069 em_len = em_end - em_start;
3056 emflags = em->flags; 3070 emflags = em->flags;
3057 disko = 0; 3071 disko = 0;
3058 flags = 0; 3072 flags = 0;
3059 3073
3074 /*
3075 * bump off for our next call to get_extent
3076 */
3077 off = extent_map_end(em);
3078 if (off >= max)
3079 end = 1;
3080
3060 if (em->block_start == EXTENT_MAP_LAST_BYTE) { 3081 if (em->block_start == EXTENT_MAP_LAST_BYTE) {
3061 end = 1; 3082 end = 1;
3062 flags |= FIEMAP_EXTENT_LAST; 3083 flags |= FIEMAP_EXTENT_LAST;
@@ -3067,7 +3088,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3067 flags |= (FIEMAP_EXTENT_DELALLOC | 3088 flags |= (FIEMAP_EXTENT_DELALLOC |
3068 FIEMAP_EXTENT_UNKNOWN); 3089 FIEMAP_EXTENT_UNKNOWN);
3069 } else { 3090 } else {
3070 disko = em->block_start; 3091 disko = em->block_start + offset_in_extent;
3071 } 3092 }
3072 if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) 3093 if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
3073 flags |= FIEMAP_EXTENT_ENCODED; 3094 flags |= FIEMAP_EXTENT_ENCODED;