diff options
author | Filipe Manana <fdmanana@suse.com> | 2016-05-27 22:21:27 +0100 |
---|---|---|
committer | Filipe Manana <fdmanana@suse.com> | 2016-05-31 01:00:03 +0100 |
commit | b5de8d0df80fa87f1f97fbcc4bbc8cad0a018802 (patch) | |
tree | de3fd8d94140b60fb49bdcfc675c80ee069aec26 /fs/btrfs/export.c | |
parent | 2999241daa8d77947f108dfbde35c268cd7bd709 (diff) | |
download | linux-b5de8d0df80fa87f1f97fbcc4bbc8cad0a018802.tar.gz linux-b5de8d0df80fa87f1f97fbcc4bbc8cad0a018802.tar.bz2 linux-b5de8d0df80fa87f1f97fbcc4bbc8cad0a018802.zip |
Btrfs: fix race between device replace and read repair
While we are finishing a device replace operation we can have a concurrent
task trying to do a read repair operation, in which case it will call
btrfs_map_block() to get a struct btrfs_bio which can have a stripe that
points to the source device of the device replace operation. This allows
for the read repair task to dereference the stripe's device pointer after
the device replace operation has freed the source device, resulting in
an invalid memory access. This is similar to the problem solved by my
previous patch in the same series and named "Btrfs: fix race between
device replace and discard".
So fix this by surrounding the call to btrfs_map_block() and the code
that uses the returned struct btrfs_bio with calls to
btrfs_bio_counter_inc_blocked() and btrfs_bio_counter_dec(), giving the
proper serialization with the finishing phase of the device replace
operation.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/export.c')
0 files changed, 0 insertions, 0 deletions