From: Bart Van Assche <bvanassche@acm.org>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <jbottomley@parallels.com>,
linux-scsi@vger.kernel.org, Ewan Milne <emilne@redhat.com>,
Ren Mingxin <renmx@cn.fujitsu.com>, Joern Engel <joern@logfs.org>,
James Smart <james.smart@emulex.com>,
Roland Dreier <roland@purestorage.com>
Subject: Re: [PATCH 3/9] scsi: improved eh timeout handler
Date: Mon, 02 Sep 2013 18:38:30 +0200 [thread overview]
Message-ID: <5224BF06.3000208@acm.org> (raw)
In-Reply-To: <52248E6C.2060105@suse.de>
On 09/02/13 15:11, Hannes Reinecke wrote:
> On 09/02/2013 02:45 PM, Bart Van Assche wrote:
>> On 09/02/13 09:12, Hannes Reinecke wrote:
>>> @@ -353,6 +354,8 @@ void scsi_put_command(struct scsi_cmnd *cmd)
>>> list_del_init(&cmd->list);
>>> spin_unlock_irqrestore(&cmd->device->list_lock, flags);
>>>
>>> + cancel_delayed_work(&cmd->abort_work);
>>> +
>>> __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev);
>>> }
>>> EXPORT_SYMBOL(scsi_put_command);
>>
>> Is this approach safe ? Is it e.g. possible that the abort work
>> starts just before the cancel_delayed_work() call and continues to
>> run after scsi_put_command() has finished ? In
>> drivers/scsi/libfc/fc_exch.c a similar issue is solved by holding an
>> additional reference as long as delayed work (fc_exch.timeout_work)
>> is queued.
>>
> I have been thinking of this, and in fact my original approach had
> 'cancel_delayed_work_sync' here. However, this didn't work as
> scsi_put_command() might end up being called from an softirq context.
>
>>From my understanding the workqueue stuff guarantees that either
> a) the workqueue item is still queued
> -> cancel_delayed_work will be in fact synchronous, as it'll
> cancel queue item from the queue
> b) the workqueue item is running
> -> cancel_delayed_work is essentially a no-op, as the function
> is running and will be terminated anyway.
>
> IE from the API perspective the transition between 'queued' and
> 'running' is atomic, and no in-between states are visible.
>
> So case a) is obviously safe, and for case b) the abort function is
> already running. But then the abort function has been called from
> the block timeout handler, which did a blk_mark_rq_complete() prior
> to calling the handler. So any completion coming in after that will
> be ignored, and scsi_put_command() won't be called.
>
> Hence we should be safe here.
Hello Hannes,
I think that you have just explained why that cancel_delayed_work() call
in scsi_put_command() is not necessary at all ... In case of normal
command completion, scsi_put_command() will be reached with no
scmd_eh_abort_handler() call queued since there was no timeout. If the
command timed out scsi_put_command() will be called after the abort_work
has already been dequeued since work items are dequeued before being
executed.
Bart.
next prev parent reply other threads:[~2013-09-02 16:38 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-02 7:12 [PATCHv5 0/9] New EH command timeout handler Hannes Reinecke
2013-09-02 7:12 ` [PATCH 1/9] scsi: Fix erratic device offline during EH Hannes Reinecke
2013-09-02 7:12 ` [PATCH 2/9] blk-timeout: add BLK_EH_SCHEDULED return code Hannes Reinecke
2013-09-02 7:12 ` [PATCH 3/9] scsi: improved eh timeout handler Hannes Reinecke
2013-09-02 12:45 ` Bart Van Assche
2013-09-02 13:11 ` Hannes Reinecke
2013-09-02 16:38 ` Bart Van Assche [this message]
2013-09-03 9:13 ` Bart Van Assche
2013-09-04 7:02 ` Hannes Reinecke
2013-09-02 7:13 ` [PATCH 4/9] virtio_scsi: Enable new EH " Hannes Reinecke
2013-09-02 7:13 ` [PATCH 5/9] libsas: " Hannes Reinecke
2013-09-02 7:13 ` [PATCH 6/9] mptsas: " Hannes Reinecke
2013-09-02 7:13 ` [PATCH 7/9] mpt2sas: " Hannes Reinecke
2013-09-02 7:13 ` [PATCH 8/9] mpt3sas: " Hannes Reinecke
2013-09-02 7:13 ` [PATCH 9/9] scsi_transport_fc: " Hannes Reinecke
2013-09-02 8:27 ` [PATCHv5 0/9] New EH command " Christoph Hellwig
2013-09-02 8:54 ` Hannes Reinecke
2013-09-02 9:31 ` Christoph Hellwig
2013-09-02 9:59 ` Hannes Reinecke
2013-09-03 16:36 ` Jörn Engel
-- strict thread matches above, loose matches on Subject: below --
2013-08-29 13:32 [PATCHv4 " Hannes Reinecke
2013-08-29 13:32 ` [PATCH 3/9] scsi: improved eh " Hannes Reinecke
2013-07-01 14:24 [PATCHv3 0/9] New EH command " Hannes Reinecke
2013-07-01 14:24 ` [PATCH 3/9] scsi: improved eh " Hannes Reinecke
2013-08-22 8:51 ` Ren Mingxin
2013-08-23 12:27 ` Hannes Reinecke
2013-06-10 7:40 [PATCHv2 0/9] New SCSI command " Hannes Reinecke
2013-06-10 7:40 ` [PATCH 3/9] scsi: improved eh " Hannes Reinecke
2013-06-10 8:20 ` Christoph Hellwig
2013-06-10 9:00 ` Hannes Reinecke
2013-06-10 15:19 ` Jörn Engel
2013-06-10 23:24 ` Jörn Engel
2013-06-11 6:18 ` Hannes Reinecke
2013-06-11 16:35 ` Jörn Engel
2013-06-11 18:57 ` James Bottomley
2013-06-11 20:41 ` Ewan Milne
2013-06-11 20:54 ` James Bottomley
2013-06-12 5:54 ` Hannes Reinecke
2013-06-12 6:34 ` Bart Van Assche
2013-06-12 6:42 ` Hannes Reinecke
2013-06-10 15:47 ` Jörn Engel
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=5224BF06.3000208@acm.org \
--to=bvanassche@acm.org \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=james.smart@emulex.com \
--cc=jbottomley@parallels.com \
--cc=joern@logfs.org \
--cc=linux-scsi@vger.kernel.org \
--cc=renmx@cn.fujitsu.com \
--cc=roland@purestorage.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.