{
struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
- complete(&dc->wait);
dc->error = bio->bi_error;
dc->state = D_DONE;
+ complete(&dc->wait);
bio_put(bio);
}
list_for_each_entry_safe(dc, tmp, wait_list, list) {
if (dc->lstart <= blkaddr && blkaddr < dc->lstart + dc->len) {
- if (dc->state == D_SUBMIT)
- wait_for_completion_io(&dc->wait);
+ wait_for_completion_io(&dc->wait);
__punch_discard_cmd(sbi, dc, blkaddr);
}
}
}
list_for_each_entry_safe(dc, tmp, wait_list, list) {
- if (dc->state == D_DONE)
+ if (dc->state == D_DONE) {
+ wait_for_completion_io(&dc->wait);
__remove_discard_cmd(sbi, dc);
+ }
}
mutex_unlock(&dcc->cmd_lock);