From: gpiccoli@linux.vnet.ibm.com (Guilherme G. Piccoli)
Subject: [PATCH] Avoid reset work on watchdog timer function during error recovery
Date: Thu, 7 Apr 2016 10:17:28 -0300 [thread overview]
Message-ID: <57065DE8.7040109@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160407131131.GA2063@infradead.org>
On 04/07/2016 10:11 AM, Christoph Hellwig wrote:
> On Wed, Apr 06, 2016@05:30:35PM -0300, Guilherme G. Piccoli wrote:
>> /*
>> * Skip controllers currently under reset.
>> + * Also, skip controllers going through PCI error recovery.
>> */
>> if (!work_pending(&dev->reset_work) && !work_busy(&dev->reset_work) &&
>> ((csts & NVME_CSTS_CFS) ||
>> - (dev->subsystem && (csts & NVME_CSTS_NSSRO)))) {
>> + (dev->subsystem && (csts & NVME_CSTS_NSSRO))) &&
>> + !pci_channel_offline(to_pci_dev(dev->dev))) {
>> if (queue_work(nvme_workq, &dev->reset_work)) {
>> dev_warn(dev->dev,
>> "Failed status: 0x%x, reset controller.\n",
>
> This looks correct to me, but the condition is getting basically
> unreadable. Can you factor it out into a little helper returns a
> boolean value if we should reset or not, and document each condition,
> e.g. something like the function below, just with proper comments:
>
> static bool nvme_should_reset(struct nvme_dev *dev)
> {
> u32 csts = readl(dev->bar + NVME_REG_CSTS);
>
> if (!(csts & NVME_CSTS_CFS) &&
> !((dev->subsystem && (csts & NVME_CSTS_NSSRO))))
> return false;
>
> if (work_pending(&dev->reset_work))
> return false;
> if (work_busy(&dev->reset_work))
> return false;
> if (pci_channel_offline(to_pci_dev(dev->dev))
> return false;
>
> return true;
> }
>
Heheh agreed, very good suggestion indeed. I found myself struggling to
understand this huge condition line. I'll improve it following your
suggestion, thanks.
Cheers,
Guilherme
next prev parent reply other threads:[~2016-04-07 13:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 20:30 [PATCH] Avoid reset work on watchdog timer function during error recovery Guilherme G. Piccoli
2016-04-06 20:50 ` Keith Busch
2016-04-07 8:05 ` Johannes Thumshirn
2016-04-07 13:11 ` Christoph Hellwig
2016-04-07 13:17 ` Guilherme G. Piccoli [this message]
2016-04-07 13:18 ` Sagi Grimberg
2016-04-07 13:26 ` Christoph Hellwig
2016-04-07 14:24 ` Keith Busch
2016-04-07 15:42 ` Guilherme G. Piccoli
2016-04-07 15:46 ` Keith Busch
2016-04-07 16:03 ` Guilherme G. Piccoli
2016-04-12 19:01 ` Christoph Hellwig
2016-04-12 23:33 ` Guilherme G. Piccoli
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=57065DE8.7040109@linux.vnet.ibm.com \
--to=gpiccoli@linux.vnet.ibm.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.