aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2014-05-08 22:01:02 -0400
committerChris Mason <clm@fb.com>2014-05-20 13:17:48 -0400
commitd3ecfcdf9108c833e4e501bfa02ecf673a0ace59 (patch)
tree83733f1f456047ba4f435f2fa06182707e4fe320 /fs/btrfs/ioctl.c
parentcfd4a535b68faf651b238586011f5bae128391c4 (diff)
Btrfs: fix EIO on reading file after ioctl clone works on it
For inline data extent, we need to make its length aligned, otherwise, we can get a phantom extent map which confuses readpages() to return -EIO. This can be detected by xfstests/btrfs/035. Reported-by: David Disseldorp <ddiss@suse.de> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7b001abc73c7..e1b47ef380d6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3142,6 +3142,8 @@ process_slot:
3142 } else if (type == BTRFS_FILE_EXTENT_INLINE) { 3142 } else if (type == BTRFS_FILE_EXTENT_INLINE) {
3143 u64 skip = 0; 3143 u64 skip = 0;
3144 u64 trim = 0; 3144 u64 trim = 0;
3145 u64 aligned_end = 0;
3146
3145 if (off > key.offset) { 3147 if (off > key.offset) {
3146 skip = off - key.offset; 3148 skip = off - key.offset;
3147 new_key.offset += skip; 3149 new_key.offset += skip;
@@ -3158,9 +3160,11 @@ process_slot:
3158 size -= skip + trim; 3160 size -= skip + trim;
3159 datal -= skip + trim; 3161 datal -= skip + trim;
3160 3162
3163 aligned_end = ALIGN(new_key.offset + datal,
3164 root->sectorsize);
3161 ret = btrfs_drop_extents(trans, root, inode, 3165 ret = btrfs_drop_extents(trans, root, inode,
3162 new_key.offset, 3166 new_key.offset,
3163 new_key.offset + datal, 3167 aligned_end,
3164 1); 3168 1);
3165 if (ret) { 3169 if (ret) {
3166 if (ret != -EOPNOTSUPP) 3170 if (ret != -EOPNOTSUPP)