In dm_thin_find_block() the ->fail_io flag was checked outside the
metadata device's root_lock, causing dm_thin_find_block() to race with
the setting of this flag.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
        dm_block_t keys[2] = { td->id, block };
        struct dm_btree_info *info;
 
-       if (pmd->fail_io)
-               return -EINVAL;
-
        down_read(&pmd->root_lock);
+       if (pmd->fail_io) {
+               up_read(&pmd->root_lock);
+               return -EINVAL;
+       }
 
        if (can_issue_io) {
                info = &pmd->info;