Skip to content

Commit 7b23205

Browse files
committed
tree: add nvme_ctrl_get_ana_state()
Add a function to return the ANA state of a namespace on a given controller. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 7aaed6e commit 7b23205

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LIBNVME_1_0 {
1212
nvme_ctrl_first_ns;
1313
nvme_ctrl_first_path;
1414
nvme_ctrl_get_address;
15+
nvme_ctrl_get_ana_state;
1516
nvme_ctrl_get_dhchap_key;
1617
nvme_ctrl_get_discovery_ctrl;
1718
nvme_ctrl_get_fd;

src/nvme/tree.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,19 @@ const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c)
768768
return c->cfg.host_iface;
769769
}
770770

771+
const char *nvme_ctrl_get_ana_state(nvme_ctrl_t c, __u32 nsid)
772+
{
773+
if (nsid != NVME_NSID_ALL) {
774+
nvme_path_t p;
775+
776+
nvme_ctrl_for_each_path(c, p) {
777+
if (p->n && p->n->nsid == nsid)
778+
return p->ana_state;
779+
}
780+
}
781+
return NULL;
782+
}
783+
771784
struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c)
772785
{
773786
return &c->cfg;

src/nvme/tree.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,15 @@ const char *nvme_ctrl_get_host_traddr(nvme_ctrl_t c);
836836
*/
837837
const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c);
838838

839+
/**
840+
* nvme_ctrl_get_ana_state() - ANA state of a controller path
841+
* @c: Constroller instance
842+
* @nsid: Namespace ID to evaluate
843+
*
844+
* Return: ANA state of the namespace @nsid on controller @c.
845+
*/
846+
const char *nvme_ctrl_get_ana_state(nvme_ctrl_t c, __u32 nsid);
847+
839848
/**
840849
* nvme_ctrl_get_dhchap_key() - Return controller key
841850
* @c: Controller for which the key should be set

0 commit comments

Comments
 (0)