Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ struct request_queue *blk_alloc_queue(struct queue_limits *lim, int node_id)
refcount_set(&q->refs, 1);
mutex_init(&q->debugfs_mutex);
mutex_init(&q->elevator_lock);
mutex_init(&q->elevator_queue_lock);
mutex_init(&q->sysfs_lock);
mutex_init(&q->limits_lock);
mutex_init(&q->rq_qos_mutex);
Expand Down
9 changes: 9 additions & 0 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ static int elevator_change(struct request_queue *q, struct elv_change_ctx *ctx)
return ret;
}

/*
* Acquire elevator_queue_lock to serialize the debugfs (un)register
* steps for the same queue. The elevator switch core part is protected
* by queue freezing and ->elevator_lock.
*/
mutex_lock(&q->elevator_queue_lock);

memflags = blk_mq_freeze_queue(q);
/*
* May be called before adding disk, when there isn't any FS I/O,
Expand All @@ -690,6 +697,8 @@ static int elevator_change(struct request_queue *q, struct elv_change_ctx *ctx)
if (!ctx->new)
blk_mq_free_sched_res(&ctx->res, ctx->type, set);

mutex_unlock(&q->elevator_queue_lock);

return ret;
}

Expand Down
7 changes: 7 additions & 0 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ struct request_queue {
*/
struct mutex elevator_lock;

/*
* Serializes the whole elevator change operation for the same queue,
* including the debugfs (un)register steps. Must be acquired before
* freezing the queue and acquiring elevator_lock.
*/
struct mutex elevator_queue_lock;

struct mutex sysfs_lock;
/*
* Protects queue limits and also sysfs attribute read_ahead_kb.
Expand Down
Loading