[PATCH] NVMe: Fix possible scheduling while atomic error

Keith Busch keith.busch at intel.com
Wed Jun 8 07:43:54 PDT 2016


On Wed, Jun 08, 2016 at 02:17:03PM +0300, Sagi Grimberg wrote:
> I really don't like this patch (sorry), having queue_rq being aware
> of what requeue_work *might* do looks backwards to me...
> now I'm thinking what I need to do in fabrics rdma and loop. This is
> why I didn't like the NVME_NS_DEAD check in queue_rq as well.

I agree, but I didn't find another card we can play to get the right
sequence.
 
> I'd really prefer to not propagate this backwards logic into
> other transports...
> 
> But, if this is mandatory for now, does this patch makes sense for
> rdma?

Looks right to me.


> -- 
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 938e7d55c4a8..60aaa1b4d021 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -1450,6 +1450,12 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx
> *hctx,
>                 goto err;
>         }
> 
> +       /* XXX: This is really not the correct layer to check this */
> +       if (ns && !test_bit(NVME_NS_DEAD, &ns->flags)) {
> +               ret = -EAGAIN;
> +               goto err;
> +       }
> +
>         ib_dma_sync_single_for_device(dev, sqe->dma,
>                         sizeof(struct nvme_command), DMA_TO_DEVICE);
> 
> @@ -1464,8 +1470,14 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx
> *hctx,
> 
>         return BLK_MQ_RQ_QUEUE_OK;
>  err:
> -       return (ret == -ENOMEM || ret == -EAGAIN) ?
> -               BLK_MQ_RQ_QUEUE_BUSY : BLK_MQ_RQ_QUEUE_ERROR;
> +       if (ret == -ENOMEM || ret == -EAGAIN) {
> +               spin_lock_irq(ns->queue->queue_lock);
> +               if (blk_queue_stopped(rq->q))
> +                       blk_mq_stop_hw_queues(ns->queue);
> +               spin_unlock_irq(ns->queue->queue_lock);
> +               return BLK_MQ_RQ_QUEUE_BUSY;
> +       }
> +       return BLK_MQ_RQ_QUEUE_ERROR;
>  }
> 
>  static int nvme_rdma_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag)
> -- 



More information about the Linux-nvme mailing list