From: Omar Sandoval <osan...@fb.com>

This makes us consistent with both reflink and the XFS implementation of
dedupe.

Signed-off-by: Omar Sandoval <osan...@fb.com>
---
 fs/btrfs/ioctl.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e23f945..320fb35 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3121,21 +3121,25 @@ static int extent_same_check_offsets(struct inode 
*inode, u64 off, u64 *plen,
 static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
                             struct inode *dst, u64 dst_loff)
 {
-       int ret;
-       u64 len = olen;
+       int ret = 0;
+       u64 len;
        struct cmp_pages cmp;
        bool same_inode = (src == dst);
        u64 same_lock_start = 0;
        u64 same_lock_len = 0;
 
-       if (len == 0)
-               return 0;
-
        if (same_inode)
                inode_lock(src);
        else
                btrfs_double_inode_lock(src, dst);
 
+       if (olen == 0) {
+               olen = i_size_read(src) - loff;
+               if (olen == 0)
+                       goto out_unlock;
+       }
+       len = olen;
+
        ret = extent_same_check_offsets(src, loff, &len, olen);
        if (ret)
                goto out_unlock;
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to