lkml.org 
[lkml]   [2019]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] nvme: add API for getting nsid by bdev
Date
Add kernel API function for getting nvme namespace id.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
---
drivers/nvme/host/core.c | 14 ++++++++++++++
include/linux/nvme.h | 2 ++
2 files changed, 16 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 06f917f391c4..35d121cd2378 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -812,6 +812,20 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
}
EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd);

+int nvme_get_nsid_by_bdev(struct block_device *bdev, unsigned int *nsid)
+{
+ struct nvme_ns *ns;
+
+ if (!bdev && !nsid)
+ return -EINVAL;
+
+ ns = bdev->bd_disk->private_data;
+ *nsid = ns->head->ns_id;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(nvme_nsid_by_bdev);
+
int nvme_submit_admin_cmd_by_bdev(struct block_device *bdev,
struct nvme_command *c, void *buffer, unsigned int bufflen)
{
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 6f26c5654514..c54e210ad271 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1392,6 +1392,8 @@ struct nvme_completion {
#define NVME_MINOR(ver) (((ver) >> 8) & 0xff)
#define NVME_TERTIARY(ver) ((ver) & 0xff)

+int nvme_get_nsid_by_bdev(struct block_device *bdev, unsigned int *nsid);
+
int nvme_submit_admin_cmd_by_bdev(struct block_device *bdev,
struct nvme_command *c, void *buffer, unsigned int bufflen);

--
2.17.1
--------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

\
 
 \ /
  Last update: 2019-09-13 13:17    [W:0.127 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site