diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2014-05-09 04:01:02 +0200 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-05-20 19:17:48 +0200 |
commit | d3ecfcdf9108c833e4e501bfa02ecf673a0ace59 (patch) | |
tree | 83733f1f456047ba4f435f2fa06182707e4fe320 /fs/btrfs/ioctl.c | |
parent | Btrfs: limit the path size in send to PATH_MAX (diff) | |
download | linux-d3ecfcdf9108c833e4e501bfa02ecf673a0ace59.tar.xz linux-d3ecfcdf9108c833e4e501bfa02ecf673a0ace59.zip |
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 '')
-rw-r--r-- | fs/btrfs/ioctl.c | 6 |
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: } else if (type == BTRFS_FILE_EXTENT_INLINE) { u64 skip = 0; u64 trim = 0; + u64 aligned_end = 0; + if (off > key.offset) { skip = off - key.offset; new_key.offset += skip; @@ -3158,9 +3160,11 @@ process_slot: size -= skip + trim; datal -= skip + trim; + aligned_end = ALIGN(new_key.offset + datal, + root->sectorsize); ret = btrfs_drop_extents(trans, root, inode, new_key.offset, - new_key.offset + datal, + aligned_end, 1); if (ret) { if (ret != -EOPNOTSUPP) |