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>

authored by Liu Bo and committed by Chris Mason d3ecfcdf cfd4a535

+5 -1
+5 -1
fs/btrfs/ioctl.c
··· 3142 3142 } else if (type == BTRFS_FILE_EXTENT_INLINE) { 3143 3143 u64 skip = 0; 3144 3144 u64 trim = 0; 3145 + u64 aligned_end = 0; 3146 + 3145 3147 if (off > key.offset) { 3146 3148 skip = off - key.offset; 3147 3149 new_key.offset += skip; ··· 3160 3158 size -= skip + trim; 3161 3159 datal -= skip + trim; 3162 3160 3161 + aligned_end = ALIGN(new_key.offset + datal, 3162 + root->sectorsize); 3163 3163 ret = btrfs_drop_extents(trans, root, inode, 3164 3164 new_key.offset, 3165 - new_key.offset + datal, 3165 + aligned_end, 3166 3166 1); 3167 3167 if (ret) { 3168 3168 if (ret != -EOPNOTSUPP)