Skip to content

Commit f603917

Browse files
YuKuai-huaweikawasaki
authored andcommitted
block, bfq: convert to use ioc_lookup_icq_rcu()
ioc_lookup_icq() are all called from IO issue path with queue_lock held, convert to use ioc_lookup_icq_rcu() to get rid of the disk level spin lock. Signed-off-by: Yu Kuai <[email protected]>
1 parent 2334533 commit f603917

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

block/bfq-iosched.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -454,17 +454,13 @@ static struct bfq_io_cq *icq_to_bic(struct io_cq *icq)
454454
*/
455455
static struct bfq_io_cq *bfq_bic_lookup(struct request_queue *q)
456456
{
457-
struct bfq_io_cq *icq;
458-
unsigned long flags;
459-
460-
if (!current->io_context)
461-
return NULL;
457+
struct io_cq *icq;
462458

463-
spin_lock_irqsave(&q->queue_lock, flags);
464-
icq = icq_to_bic(ioc_lookup_icq(q));
465-
spin_unlock_irqrestore(&q->queue_lock, flags);
459+
rcu_read_lock();
460+
icq = ioc_lookup_icq_rcu(q);
461+
rcu_read_unlock();
466462

467-
return icq;
463+
return icq_to_bic(icq);
468464
}
469465

470466
/*
@@ -2457,15 +2453,8 @@ static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
24572453
unsigned int nr_segs)
24582454
{
24592455
struct bfq_data *bfqd = q->elevator->elevator_data;
2460-
struct request *free = NULL;
2461-
/*
2462-
* bfq_bic_lookup grabs the queue_lock: invoke it now and
2463-
* store its return value for later use, to avoid nesting
2464-
* queue_lock inside the bfqd->lock. We assume that the bic
2465-
* returned by bfq_bic_lookup does not go away before
2466-
* bfqd->lock is taken.
2467-
*/
24682456
struct bfq_io_cq *bic = bfq_bic_lookup(q);
2457+
struct request *free = NULL;
24692458
bool ret;
24702459

24712460
spin_lock_irq(&bfqd->lock);

0 commit comments

Comments
 (0)