Re: [PATCH V9 6/7] SCSI: allow to pass null rq to scsi_prep_state_check()

From: Ming Lei
Date: Sat Oct 14 2017 - 04:06:26 EST


On Fri, Oct 13, 2017 at 11:16:12PM +0000, Bart Van Assche wrote:
> On Sat, 2017-10-14 at 02:05 +0800, Ming Lei wrote:
> > In the following patch, we will implement scsi_get_budget()
> > which need to call scsi_prep_state_check() when rq isn't
> > dequeued yet.
>
> My understanding is that this change is only needed because scsi_mq_get_budget()
> calls scsi_prep_state_check() with the req argument set to NULL. Since
> scsi_prep_state_check() tests for sdev states other than SDEV_RUNNING and since
> the purpose of this series is to optimize performance for the case SDEV_RUNNING
> I'm not sure it's a good idea to make scsi_mq_get_budget() call
> scsi_prep_state_check(). And if scsi_mq_get_budget() wouldn't call
> scsi_prep_state_check() then this patch is not necessary.

The purpose is that I don't want to change the current SCSI logic of
queuing request.

For example, if sdev state becomes OFFLINE or DEL, the current
logic is to fail the request immediately. If the state isn't checked
in scsi_mq_get_budget(), we have to try to obtain budget first,
if it isn't available in the state of OFFLINE of DEL, there might be
risk of I/O hang.

So I suggest to check the state in scsi_mq_get_budget(), just like
what the current scsi_queue_rq() does.

--
Ming