]> git.baikalelectronics.ru Git - kernel.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)
committerChris Mason <clm@fb.com>
Thu, 2 Jul 2015 00:17:14 +0000 (17:17 -0700)
commit5ccec6e2a43a0ea24f73a4f72ff54cffe7dae3ef
treeb66f909b1cf80dc1e2736f5716fb5566ec368a06
parentb08b341a7ca8010161b471658722b0a41a76f53e
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>
fs/btrfs/ioctl.c