Skip to content

Commit

Permalink
stop queue before del_gendisk()
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeiShtepa committed Oct 25, 2024
1 parent c30d72c commit 2cfb675
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 3 additions & 5 deletions module/snapimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static blk_status_t snapimage_queue_rq(struct blk_mq_hw_ctx *hctx,

blk_mq_start_request(rq);

if (unlikely(!snapimage->is_ready || diff_area_is_corrupted(snapimage->diff_area))) {
if (unlikely(diff_area_is_corrupted(snapimage->diff_area))) {
blk_mq_end_request(rq, BLK_STS_NOSPC);
return BLK_STS_NOSPC;
}
Expand Down Expand Up @@ -194,9 +194,8 @@ void snapimage_free(struct snapimage *snapimage)
pr_info("Snapshot image disk [%u:%u] delete\n",
MAJOR(snapimage->image_dev_id), MINOR(snapimage->image_dev_id));

blk_mq_freeze_queue(snapimage->disk->queue);
snapimage->is_ready = false;
blk_mq_unfreeze_queue(snapimage->disk->queue);
blk_mq_stop_hw_queues(snapimage->disk->queue);
blk_mq_quiesce_queue(snapimage->disk->queue);

snapimage_unprepare_worker(snapimage);

Expand Down Expand Up @@ -244,7 +243,6 @@ struct snapimage *snapimage_create(struct diff_area *diff_area,
goto fail_free_image;
}

snapimage->is_ready = true;
snapimage->capacity = cbt_map->device_capacity;
snapimage->image_dev_id = MKDEV(_major, minor);
pr_info("Create snapshot image device [%u:%u] for original device [%u:%u]\n",
Expand Down
4 changes: 0 additions & 4 deletions module/snapimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ struct cbt_map;
* @capacity:
* The size of the snapshot image in sectors must be equal to the size
* of the original device at the time of taking the snapshot.
* @is_ready:
* The flag means that the snapshot image is ready for processing
* I/O requests.
* @worker:
* The worker thread for processing I/O requests.
* @worker_task:
Expand All @@ -49,7 +46,6 @@ struct cbt_map;
struct snapimage {
dev_t image_dev_id;
sector_t capacity;
bool is_ready;

struct kthread_worker worker;
struct task_struct *worker_task;
Expand Down

0 comments on commit 2cfb675

Please sign in to comment.