]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: fix check_shared for fiemap ioctl
authorLu Fengqi <lufq.fnst@cn.fujitsu.com>
Mon, 13 Jun 2016 01:36:46 +0000 (09:36 +0800)
committerBrian Maly <brian.maly@oracle.com>
Wed, 19 Sep 2018 00:30:29 +0000 (20:30 -0400)
commit8673e8940f701f866385d5138d0648d60a6fcddc
tree271ea46bd94e38c8e044c6f4686e4e486f438b6b
parent6af1c37c19ea6ddb78d1999e67d5fb55764aeb42
btrfs: fix check_shared for fiemap ioctl

Only in the case of different root_id or different object_id, check_shared
identified extent as the shared. However, If a extent was referred by
different offset of same file, it should also be identified as shared.
In addition, check_shared's loop scale is at least n^3, so if a extent
has too many references, even causes soft hang up.

First, add all delayed_ref to the ref_tree and calculate the unqiue_refs,
if the unique_refs is greater than one, return BACKREF_FOUND_SHARED.
Then individually add the on-disk reference(inline/keyed) to the ref_tree
and calculate the unique_refs of the ref_tree to check if the unique_refs
is greater than one.Because once there are two references to return
SHARED, so the time complexity is close to the constant.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit afce772e87c36c7f07f230a76d525025aaf09e41)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
fs/btrfs/backref.c - Modified comment so that patch applies.

Signed-off-by: Divya Indi <divya.indi@oracle.com>
Orabug: 24716710
Signed-off-by: Brian Maly <brian.maly@oracle.com>
fs/btrfs/backref.c
fs/btrfs/extent_io.c