Skip to content

Commit

Permalink
block: factor out a blk_debugfs_remove helper
Browse files Browse the repository at this point in the history
Split the debugfs removal from blk_unregister_queue into a helper so that
the it can be reused for blk_register_queue error handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20221114042637.1009333-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Nov 30, 2022
1 parent 450deb9 commit 6fc75f3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,19 @@ struct kobj_type blk_queue_ktype = {
.release = blk_release_queue,
};

static void blk_debugfs_remove(struct gendisk *disk)
{
struct request_queue *q = disk->queue;

mutex_lock(&q->debugfs_mutex);
blk_trace_shutdown(q);
debugfs_remove_recursive(q->debugfs_dir);
q->debugfs_dir = NULL;
q->sched_debugfs_dir = NULL;
q->rqos_debugfs_dir = NULL;
mutex_unlock(&q->debugfs_mutex);
}

/**
* blk_register_queue - register a block layer queue with sysfs
* @disk: Disk of which the request queue should be registered with sysfs.
Expand Down Expand Up @@ -925,11 +938,5 @@ void blk_unregister_queue(struct gendisk *disk)
kobject_del(&q->kobj);
mutex_unlock(&q->sysfs_dir_lock);

mutex_lock(&q->debugfs_mutex);
blk_trace_shutdown(q);
debugfs_remove_recursive(q->debugfs_dir);
q->debugfs_dir = NULL;
q->sched_debugfs_dir = NULL;
q->rqos_debugfs_dir = NULL;
mutex_unlock(&q->debugfs_mutex);
blk_debugfs_remove(disk);
}

0 comments on commit 6fc75f3

Please sign in to comment.