]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: fix deadlock with extent-same and readpage
authorMark Fasheh <mfasheh@suse.de>
Tue, 30 Jun 2015 21:42:05 +0000 (14:42 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 22 Aug 2017 15:42:58 +0000 (08:42 -0700)
commitc703bf59889319e16c47c06c59464b80ff76cfa3
treee33d266a32359d1232d743d9133087028090a61e
parente08fe6d0fac9ea5729a75ac396600c7582434c2d
btrfs: fix deadlock with extent-same and readpage

->readpage() does page_lock() before extent_lock(), we do the opposite in
extent-same. We want to reverse the order in btrfs_extent_same() but it's
not quite straightforward since the page locks are taken inside btrfs_cmp_data().

So I split btrfs_cmp_data() into 3 parts with a small context structure that
is passed between them. The first, btrfs_cmp_data_prepare() gathers up the
pages needed (taking page lock as required) and puts them on our context
structure. At this point, we are safe to lock the extent range. Afterwards,
we use btrfs_cmp_data() to do the data compare as usual and btrfs_cmp_data_free()
to clean up our context.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
(Cherry picked from commit f441460202cb787c49963bcc1f54cb48c52f7512)

Orabug: 26251039

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Acked-by: John Haxby <john.haxby@oracle.com>
fs/btrfs/ioctl.c