Thread (4 messages) 4 messages, 2 authors, 2016-05-31

Re: [PATCH 2/2] Btrfs: fix race between device replace and read repair

From: Josef Bacik <hidden>
Date: 2016-05-31 13:30:37

On 05/30/2016 11:19 AM, fdmanana@kernel.org wrote:
From: Filipe Manana <redacted>

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 <redacted>
---
Reviewed-by: Josef Bacik <redacted>

Thanks,

Josef
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help