]> git.hungrycats.org Git - linux/commitdiff
Btrfs: read lock extent buffer while walking backrefs
authorFilipe Manana <fdmanana@suse.com>
Wed, 2 Jul 2014 19:07:54 +0000 (20:07 +0100)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Wed, 20 Aug 2014 05:27:22 +0000 (01:27 -0400)
Before processing the extent buffer, acquire a read lock on it, so
that we're safe against concurrent updates on the extent buffer.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 6f7ff6d7832c6be13e8c95598884dbc40ad69fb7)

fs/btrfs/backref.c

index 14d29d02097da3d253c966b6867c940d2585582f..96d44197e38a27f2bbe3279104355a0c08dbb1c9 100644 (file)
@@ -985,8 +985,11 @@ again:
                                        ret = -EIO;
                                        goto out;
                                }
+                               btrfs_tree_read_lock(eb);
+                               btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
                                ret = find_extent_in_eb(eb, bytenr,
                                                        *extent_item_pos, &eie);
+                               btrfs_tree_read_unlock_blocking(eb);
                                free_extent_buffer(eb);
                                if (ret < 0)
                                        goto out;