Re: [PATCH 2/5] blk-mq: rename hctx_lock & hctx_unlock

Sagi Grimberg
2021-11-22T07:53:57Z

> -static inline void hctx_unlock(struct blk_mq_hw_ctx *hctx, int srcu_idx)
> - __releases(hctx->srcu)
> +static inline void queue_unlock(struct request_queue *q, bool blocking,
> + int srcu_idx)
> + __releases(q->srcu)
> {
> - if (!(hctx->flags & BLK_MQ_F_BLOCKING))
> + if (!blocking)
> rcu_read_unlock();
> else
> - srcu_read_unlock(hctx->queue->srcu, srcu_idx);
> + srcu_read_unlock(q->srcu, srcu_idx);

Maybe instead of passing blocking bool just look at srcu_idx?

if (srcu_idx < 0)
rcu_read_unlock();
else
srcu_read_unlock(q->srcu, srcu_idx);

Or look if the queue has srcu allocated?

if (!q->srcu)
rcu_read_unlock();
else
srcu_read_unlock(q->srcu, srcu_idx);

> }
>
> -static inline void hctx_lock(struct blk_mq_hw_ctx *hctx, int *srcu_idx)
> +static inline void queue_lock(struct request_queue *q, bool blocking,
> + int *srcu_idx)
> __acquires(hctx->srcu)
> {
> - if (!(hctx->flags & BLK_MQ_F_BLOCKING)) {
> + if (!blocking) {
> /* shut up gcc false positive */
> *srcu_idx = 0;
> rcu_read_lock();
> } else
> - *srcu_idx = srcu_read_lock(hctx->queue->srcu);
> + *srcu_idx = srcu_read_lock(q->srcu);

Same here:

if (!q->srcu)
rcu_read_lock();
else
srcu_idx = srcu_read_lock(q->srcu);