Tang, Thanks for the patch. On 10/09/2017 08:07 PM, tang.junhui@xxxxxxxxxx wrote:
From: Tang Junhui <tang.junhui@xxxxxxxxxx> cached_dev_put() is called before setting and writing bdev to BDEV_STATE_CLEAN state, but after calling cached_dev_put(), detach work queue works, and bdev is also set to BDEV_STATE_NONE state in cached_dev_detach_finish(), it may cause race condition, and the state of bdev is uncertain. Signed-off-by: Tang Junhui <tang.junhui@xxxxxxxxxx>
How did you find this? Did the race trigger at detach or was it through code inspection?
I need to analyze this more. It looks correct on its own, but there are a lot of atomic variables and the way they are used is complicated.
I'm inclined to think that detach should traverse the writeback lock for safety. It would be a lot less complicated to analyze what would happen. What do you think?
Thanks, Mike -- To unsubscribe from this list: send the line "unsubscribe linux-bcache" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html