Commit 84bfed40 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-4.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
 "Two regression fixes and an incorrect error value propagation fix from
  'rename exchange'"

* tag 'for-4.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  Btrfs: fix return value on rename exchange failure
  btrfs: fix invalid-free in btrfs_extent_same
  Btrfs: fix physical offset reported by fiemap for inline extents
parents 6f0d349d c5b4a50b
...@@ -4542,8 +4542,11 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4542,8 +4542,11 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
offset_in_extent = em_start - em->start; offset_in_extent = em_start - em->start;
em_end = extent_map_end(em); em_end = extent_map_end(em);
em_len = em_end - em_start; em_len = em_end - em_start;
disko = em->block_start + offset_in_extent;
flags = 0; flags = 0;
if (em->block_start < EXTENT_MAP_LAST_BYTE)
disko = em->block_start + offset_in_extent;
else
disko = 0;
/* /*
* bump off for our next call to get_extent * bump off for our next call to get_extent
......
...@@ -9443,6 +9443,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9443,6 +9443,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
u64 new_idx = 0; u64 new_idx = 0;
u64 root_objectid; u64 root_objectid;
int ret; int ret;
int ret2;
bool root_log_pinned = false; bool root_log_pinned = false;
bool dest_log_pinned = false; bool dest_log_pinned = false;
...@@ -9639,7 +9640,8 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9639,7 +9640,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
dest_log_pinned = false; dest_log_pinned = false;
} }
} }
ret = btrfs_end_transaction(trans); ret2 = btrfs_end_transaction(trans);
ret = ret ? ret : ret2;
out_notrans: out_notrans:
if (new_ino == BTRFS_FIRST_FREE_OBJECTID) if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&fs_info->subvol_sem); up_read(&fs_info->subvol_sem);
......
...@@ -3577,7 +3577,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, ...@@ -3577,7 +3577,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN, ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
dst, dst_loff, &cmp); dst, dst_loff, &cmp);
if (ret) if (ret)
goto out_unlock; goto out_free;
loff += BTRFS_MAX_DEDUPE_LEN; loff += BTRFS_MAX_DEDUPE_LEN;
dst_loff += BTRFS_MAX_DEDUPE_LEN; dst_loff += BTRFS_MAX_DEDUPE_LEN;
...@@ -3587,16 +3587,16 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, ...@@ -3587,16 +3587,16 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
ret = btrfs_extent_same_range(src, loff, tail_len, dst, ret = btrfs_extent_same_range(src, loff, tail_len, dst,
dst_loff, &cmp); dst_loff, &cmp);
out_free:
kvfree(cmp.src_pages);
kvfree(cmp.dst_pages);
out_unlock: out_unlock:
if (same_inode) if (same_inode)
inode_unlock(src); inode_unlock(src);
else else
btrfs_double_inode_unlock(src, dst); btrfs_double_inode_unlock(src, dst);
out_free:
kvfree(cmp.src_pages);
kvfree(cmp.dst_pages);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment