From: "Jörn Engel" <joern@logfs.org>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <jbottomley@parallels.com>,
linux-scsi@vger.kernel.org, Ewan Milne <emilne@redhat.com>,
James Smart <james.smart@emulex.com>,
Ren Mingxin <renmx@cn.fujitsu.com>,
Roland Dreier <roland@purestorage.com>,
Bryn Reeves <bmr@redhat.com>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH 3/4] scsi: improved eh timeout handler
Date: Fri, 7 Jun 2013 12:21:08 -0400 [thread overview]
Message-ID: <20130607162108.GB25323@logfs.org> (raw)
In-Reply-To: <1370511835-50072-4-git-send-email-hare@suse.de>
On Thu, 6 June 2013 11:43:54 +0200, Hannes Reinecke wrote:
>
> + spin_lock_irqsave(&sdev->list_lock, flags);
> + list_for_each_entry_safe(scmd, tmp, &sdev->eh_abort_list, eh_entry) {
> + list_del_init(&scmd->eh_entry);
> + spin_unlock_irqrestore(&sdev->list_lock, flags);
I never liked the list_for_each_entry_safe() loop but until this
morning couldn't really say why. The problem is that it can finish
with commands left on the list. And since your kick_worker checks for
list_empty, there wouldn't be any more aborts.
Thread1 list state Thread2
head->1->2->head
spin_lock_irqsave();
scmd = 1; tmp = 2;
list_del_init(scmd);
spin_unlock_irqrestore();
head->2->head
spin_lock_irqsave();
kick_worker = 0;
list_add();
spin_unlock_irqrestore();
head->3->2->head
spin_lock_irqsave();
scmd = 2; tmp = head;
list_del_init(scmd);
spin_unlock_irqrestore();
head->3->head
And now that I think about nasty races, you could also do
schedule_work() when the list is empty, but the worker thread is still
running. I've had to debug similar cases and the approach is to waste
a day or five, despair and eventually get lucky half a year later when
you happen to notice the race. Rare random crashes in the kworker
code a not my favorite sight.
> +void
> +scsi_abort_command(struct scsi_cmnd *scmd)
> +{
> + unsigned long flags;
> + int kick_worker = 0;
> + struct scsi_device *sdev = scmd->device;
> +
> + spin_lock_irqsave(&sdev->list_lock, flags);
> + if (list_empty(&sdev->eh_abort_list))
> + kick_worker = 1;
> + list_add(&scmd->eh_entry, &sdev->eh_abort_list);
> + SCSI_LOG_ERROR_RECOVERY(3,
> + scmd_printk(KERN_INFO, scmd, "adding to eh_abort_list\n"));
> + spin_unlock_irqrestore(&sdev->list_lock, flags);
> + if (kick_worker)
> + schedule_work(&sdev->abort_work);
> +}
> +EXPORT_SYMBOL_GPL(scsi_abort_command);
Jörn
--
Time? What's that? Time is only worth what you do with it.
-- Theo de Raadt
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-06-07 17:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 9:43 [PATCH 0/4] New SCSI command timeout handler Hannes Reinecke
2013-06-06 9:43 ` [PATCH 1/4] scsi: move initialization of scmd->eh_entry Hannes Reinecke
2013-06-06 16:14 ` Jörn Engel
2013-06-06 9:43 ` [PATCH 2/4] blk-timeout: add BLK_EH_SCHEDULED return code Hannes Reinecke
2013-06-06 16:24 ` Jörn Engel
2013-06-06 9:43 ` [PATCH 3/4] scsi: improved eh timeout handler Hannes Reinecke
2013-06-06 16:23 ` Jörn Engel
2013-06-06 20:39 ` Hannes Reinecke
2013-06-06 20:28 ` Jörn Engel
2013-06-07 6:25 ` Ren Mingxin
2013-06-07 6:42 ` Hannes Reinecke
2013-06-07 16:21 ` Jörn Engel [this message]
2013-06-10 0:12 ` Baruch Even
2013-06-10 5:48 ` Hannes Reinecke
2013-06-06 9:43 ` [PATCH 4/4] virtio_scsi: use " Hannes Reinecke
2013-06-07 6:54 ` [PATCH 0/4] New SCSI command " Ren Mingxin
2013-06-07 7:31 ` Hannes Reinecke
2013-06-07 16:02 ` Jörn Engel
-- strict thread matches above, loose matches on Subject: below --
2013-10-30 8:37 [PATCHv7 0/4] New EH " Hannes Reinecke
2013-10-30 8:37 ` [PATCH 3/4] scsi: improved eh " Hannes Reinecke
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=20130607162108.GB25323@logfs.org \
--to=joern@logfs.org \
--cc=bmr@redhat.com \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=hch@infradead.org \
--cc=james.smart@emulex.com \
--cc=jbottomley@parallels.com \
--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.