Message ID | 1399600862-3141-1-git-send-email-bo.li.liu@oracle.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
(cc David) -liubo On Fri, May 09, 2014 at 10:01:02AM +0800, Liu Bo wrote: > 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> > --- > fs/btrfs/ioctl.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 2ad7de9..2f6d7b1 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -3120,6 +3120,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; > @@ -3136,9 +3138,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) > -- > 1.8.1.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 2ad7de9..2f6d7b1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3120,6 +3120,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; @@ -3136,9 +3138,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)
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> --- fs/btrfs/ioctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)