All of lore.kernel.org
 help / color / mirror / Atom feed
From: "jianchao.wang" <jianchao.w.wang@oracle.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Ming Lei <tom.leiming@gmail.com>, Jens Axboe <axboe@kernel.dk>,
	linux-block <linux-block@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Christoph Hellwig <hch@lst.de>,
	Bart Van Assche <bart.vanassche@wdc.com>,
	Hannes Reinecke <hare@suse.de>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Bottomley <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Linux SCSI List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH V3 11/17] SCSI: track pending admin commands
Date: Tue, 18 Sep 2018 16:25:33 +0800	[thread overview]
Message-ID: <8d9049f4-a133-d725-d144-769b2d285660@oracle.com> (raw)
In-Reply-To: <20180918075544.GD4805@ming.t460p>



On 09/18/2018 03:55 PM, Ming Lei wrote:
> On Tue, Sep 18, 2018 at 03:51:10PM +0800, jianchao.wang wrote:
>>
>>
>> On 09/18/2018 03:39 PM, Ming Lei wrote:
>>> On Tue, Sep 18, 2018 at 09:22:32AM +0800, jianchao.wang wrote:
>>>> Hi Ming
>>>>
>>>> On 09/17/2018 07:35 PM, Ming Lei wrote:
>>>>> On Mon, Sep 17, 2018 at 10:46:34AM +0800, jianchao.wang wrote:
>>>>>> Hi Ming
>>>>>>
>>>>>> On 09/14/2018 07:33 PM, Ming Lei wrote:
>>>>>>> On Fri, Sep 14, 2018 at 11:40 AM jianchao.wang
>>>>>>> <jianchao.w.wang@oracle.com> wrote:
>>>>>>>>
>>>>>>>> Hi Ming
>>>>>>>>
>>>>>>>> On 09/13/2018 08:15 PM, Ming Lei wrote:
>>>>>>>>>  EXPORT_SYMBOL(__scsi_execute);
>>>>>>>>> @@ -3246,6 +3251,7 @@ static int scsi_internal_device_block(struct scsi_device *sdev)
>>>>>>>>>               else
>>>>>>>>>                       scsi_wait_for_queuecommand(sdev);
>>>>>>>>>       }
>>>>>>>>> +     wait_event(sdev->admin_wq, !atomic_read(&sdev->nr_admin_pending));
>>>>>>>>>       mutex_unlock(&sdev->state_mutex);
>>>>>>>>>
>>>>>>>>>       return err;
>>>>>>>> ...
>>>>>>>>> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
>>>>>>>>> index 3aee9464a7bf..8bcb7ecc0c06 100644
>>>>>>>>> --- a/drivers/scsi/scsi_sysfs.c
>>>>>>>>> +++ b/drivers/scsi/scsi_sysfs.c
>>>>>>>>> @@ -1393,6 +1393,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
>>>>>>>>>
>>>>>>>>>       blk_cleanup_queue(sdev->request_queue);
>>>>>>>>>       cancel_work_sync(&sdev->requeue_work);
>>>>>>>>> +     wait_event(sdev->admin_wq, !atomic_read(&sdev->nr_admin_pending))
>>>>>>>>
>>>>>>>> This nr_admin_pending could drain the ongoing scsi_request_fn/scsi_queue_rq,
>>>>>>>> but I'm afraid it cannot stop new ones coming in, such as the ones that have passed
>>>>>>>> the sdev state checking and have not crossed the atomic_inc(&sdev->nr_admin_pending).
>>>>>>>>
>>>>>>>
>>>>>>> The counter of .nr_admin_pending is introduced for draining queued
>>>>>>> admin requests to this scsi device.
>>>>>>>
>>>>>>> Actually new requests have been prevented from entering scsi_queue_rq(),
>>>>>>> please see the two callers of wait_event(sdev->admin_wq,
>>>>>>> !atomic_read(&sdev->nr_admin_pending)).
>>>>>>>
>>>>>> For example
>>>>>>
>>>>>> _scsi_execute
>>>>>> ...
>>>>>>                                           scsi_internal_device_block
>>>>>>                                             scsi_internal_device_block_nowait
>>>>>>                                             blk_mq_quiesce_queue
>>>>>>                                             wait_event(sdev->admin_wq, !atomic_read(&sdev->nr_admin_pending))
>>>>>>   &sdev->nr_admin_pending;
>>>>>>
>>>>>>   blk_execute_rq(...)
>>>>>>
>>>>>>   atomic_dec(&sdev->nr_admin_pending);
>>>>>>   wake_up_all(&sdev->admin_wq);
>>>>>>
>>>>>> Or do you mean the scsi_queue_rq -> scsi_prep_state_check could gate out of ?
>>>>>
>>>>> I got it, then this issue can be fixed simply by moving atomic_inc/dec(&sdev->nr_admin_pending)
>>>>> and related wake_up_all(&sdev->admin_wq) into scsi_admin_queue_rq().
>>>>>
>>>>
>>>> I don't think so. It is a similar scenario.
>>>>
>>>> I guess a state checking is needed after atomic_inc(&sdev->nr_admin_pending), like:
>>>>
>>>>  _scsi_execute
>>>>  ...
>>>>                                            scsi_internal_device_block
>>>>                                              scsi_internal_device_block_nowait
>>>>                                              blk_mq_quiesce_queue
>>>>                                              wait_event(sdev->admin_wq, !atomic_read(&sdev->nr_admin_pending))
>>>>    atomic_inc(&sdev->nr_admin_pending);
>>>>    if state checking fails
>>>>      goto done
>>>
>>> The check will be done in scsi_admin_queue_rq().
>>>
>>>>
>>>>    blk_execute_rq(...)
>>>>
>>>>    atomic_dec(&sdev->nr_admin_pending);
>>>>    wake_up_all(&sdev->admin_wq);
>>>
>>> I guess you may misunderstand the purpose of .nr_admin_pending, which is
>>> for draining requests to .queue_rq(). So it is enough to just move the
>>> inc/dec of .nr_admin_pending into scsi_admin_queue_rq(), right?
>> Yes.
> 
> Thanks for your confirmation.
> 
>>
>> But I just think of how to assign with queue quiesce.
>> The existence of per-host adminq seems to break it.
> 
> The per-host adminq won't be frozen or quiesced at all,

This is the place which makes me confused.

Before this patchset, when scsi_internal_device_block quiesces the request_queue,
Both normal IO or admin requests cannot be processed any more.

Given the per-adminq, we could say every scsi device has two request_queues, or
there could be two request_queues sending requests to the a scsi_device:
 - normal IO request_queue
 - shared per-host adminq

We could quiesce the normal IO request_queue, but what's about the per-host adminq ?

> could you explain
> your concern in a bit detail about 'assign with queue quiesce'? 
>

The scsi_queue_rq->scsi_prep_state_check could stop requests entering further, but
the scsi_queue_rq is still invoked.


Thanks
Jianchao

  reply	other threads:[~2018-09-18  8:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 12:15 [PATCH V3 00/17] SCSI: introduce per-host admin queue & enable runtime PM Ming Lei
2018-09-13 12:15 ` [PATCH V3 01/17] blk-mq: allow to pass default queue flags for creating & initializing queue Ming Lei
2018-09-13 12:15 ` [PATCH V3 02/17] blk-mq: convert BLK_MQ_F_NO_SCHED into per-queue flag Ming Lei
2018-09-13 12:15 ` [PATCH V3 03/17] block: rename QUEUE_FLAG_NO_SCHED as QUEUE_FLAG_ADMIN Ming Lei
2018-09-13 12:15 ` [PATCH V3 04/17] blk-mq: don't reserve tags for admin queue Ming Lei
2018-09-13 12:15 ` [PATCH V3 05/17] SCSI: try to retrieve request_queue via 'scsi_cmnd' if possible Ming Lei
2018-09-13 12:15 ` [PATCH V3 06/17] SCSI: pass 'scsi_device' instance from 'scsi_request' Ming Lei
2018-09-13 12:15 ` [PATCH V3 07/17] SCSI: prepare for introducing admin queue for legacy path Ming Lei
2018-09-13 12:15 ` [PATCH V3 08/17] SCSI: pass scsi_device to scsi_mq_prep_fn Ming Lei
2018-09-13 12:15 ` [PATCH V3 09/17] SCSI: don't set .queuedata in scsi_mq_alloc_queue() Ming Lei
2018-09-13 12:15 ` [PATCH V3 10/17] SCSI: deal with admin queue busy Ming Lei
2018-09-13 12:15 ` [PATCH V3 11/17] SCSI: track pending admin commands Ming Lei
2018-09-14  3:33   ` jianchao.wang
2018-09-14 11:33     ` Ming Lei
2018-09-17  2:46       ` jianchao.wang
2018-09-17 11:35         ` Ming Lei
2018-09-18  1:22           ` jianchao.wang
2018-09-18  7:39             ` Ming Lei
2018-09-18  7:51               ` jianchao.wang
2018-09-18  7:55                 ` Ming Lei
2018-09-18  8:25                   ` jianchao.wang [this message]
2018-09-18 12:15                     ` Ming Lei
2018-09-19  3:52                       ` jianchao.wang
2018-09-19  8:07                         ` Ming Lei
2018-09-13 12:15 ` [PATCH V3 12/17] SCSI: create admin queue for each host Ming Lei
2018-09-13 12:15 ` [PATCH V3 13/17] SCSI: use the dedicated admin queue to send admin commands Ming Lei
2018-09-13 12:15 ` [PATCH V3 14/17] SCSI: transport_spi: resume a quiesced device Ming Lei
2018-09-13 12:15 ` [PATCH V3 15/17] SCSI: use admin queue to implement queue QUIESCE Ming Lei
2018-09-13 12:15 ` [PATCH V3 16/17] block: simplify runtime PM support Ming Lei
2018-09-13 12:15 ` [PATCH V3 17/17] block: enable runtime PM for blk-mq Ming Lei
2018-09-14 10:33   ` kbuild test robot
2018-09-15  1:13   ` kbuild test robot
2018-09-14  7:27 ` [PATCH V3 00/17] SCSI: introduce per-host admin queue & enable runtime PM jianchao.wang
2018-09-16 13:09   ` Ming Lei
2018-09-17  2:25     ` jianchao.wang
2018-09-17 12:07       ` Ming Lei
2018-09-18  1:17         ` jianchao.wang
2018-09-18  7:42           ` Ming Lei
2018-09-18  7:53             ` jianchao.wang
2018-09-17  6:34 ` Hannes Reinecke
2018-09-17 11:55   ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d9049f4-a133-d725-d144-769b2d285660@oracle.com \
    --to=jianchao.w.wang@oracle.com \
    --cc=adrian.hunter@intel.com \
    --cc=axboe@kernel.dk \
    --cc=bart.vanassche@wdc.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tom.leiming@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.