All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <keith.busch@wdc.com>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] nvme: honour O_NONBLOCK during resetting
Date: Thu, 11 Nov 2021 11:59:53 +0100	[thread overview]
Message-ID: <20211111105953.63072-1-hare@suse.de> (raw)

When opening a controller device node we should honour the O_NONBLOCK
flag to allow the device to be openend even if it's in state 'resetting'
or 'connecting'. This allows user-space applications to use a call to 'open'
to figure out if the controller is present, even if it's currently
undergoing a reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/nvme/host/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 74980a1cf89e..67cde3eaf5b0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3136,6 +3136,11 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
 	switch (ctrl->state) {
 	case NVME_CTRL_LIVE:
 		break;
+	case NVME_CTRL_RESETTING:
+	case NVME_CTRL_CONNECTING:
+		if (file->f_flags & O_NONBLOCK)
+			break;
+		fallthrough;
 	default:
 		return -EWOULDBLOCK;
 	}
-- 
2.29.2



             reply	other threads:[~2021-11-11 11:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 10:59 Hannes Reinecke [this message]
2021-11-16  1:40 ` [PATCH] nvme: honour O_NONBLOCK during resetting Chaitanya Kulkarni
2021-11-16  2:18   ` Keith Busch
2021-11-16  6:54     ` Hannes Reinecke
2021-11-16  6:52   ` 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=20211111105953.63072-1-hare@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=keith.busch@wdc.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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.