Lihong Kou 3df49967f6 block: flush the integrity workqueue in blk_integrity_unregister
When the integrity profile is unregistered there can still be integrity
reads queued up which could see a NULL verify_fn as shown by the race
window below:

CPU0                                    CPU1
  process_one_work                      nvme_validate_ns
    bio_integrity_verify_fn                nvme_update_ns_info
	                                     nvme_update_disk_info
	                                       blk_integrity_unregister
                                               ---set queue->integrity as 0
	bio_integrity_process
	--access bi->profile->verify_fn(bi is a pointer of queue->integity)

Before calling blk_integrity_unregister in nvme_update_disk_info, we must
make sure that there is no work item in the kintegrityd_wq. Just call
blk_flush_integrity to flush the work queue so the bug can be resolved.

Signed-off-by: Lihong Kou <koulihong@huawei.com>
[hch: split up and shortened the changelog]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Link: https://lore.kernel.org/r/20210914070657.87677-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-09-14 20:03:30 -06:00
..
2021-08-30 18:52:11 -07:00
2021-08-18 07:21:12 -06:00
2021-08-30 18:52:11 -07:00
2021-08-30 19:30:30 -07:00
2021-08-17 20:17:34 -06:00
2021-08-30 18:52:11 -07:00
2021-08-30 18:52:11 -07:00
2021-06-17 15:51:20 +02:00
2021-08-30 19:30:30 -07:00
2020-03-17 20:55:21 +01:00
2021-09-11 10:19:51 -07:00
2021-09-02 15:09:46 -07:00
2021-09-11 10:19:51 -07:00