Skip to content

Commit

Permalink
tree: Add getter for subsystem iopolicy
Browse files Browse the repository at this point in the history
Allow to retrieve the iopolicy settings for the subsystem.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Jul 26, 2023
1 parent 1b042eb commit f004349
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libnvme.map
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LIBNVME_1_6 {
nvme_host_release_fds;
nvme_ns_release_fd;
nvme_root_release_fds;
nvme_subsystem_get_iopolicy;
nvme_subsystem_release_fds;
};

Expand Down
1 change: 1 addition & 0 deletions src/nvme/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct nvme_subsystem {
char *firmware;
char *subsystype;
char *application;
char *iopolicy;
};

struct nvme_host {
Expand Down
8 changes: 8 additions & 0 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ void nvme_subsystem_set_application(nvme_subsystem_t s, const char *a)
s->application = strdup(a);
}

const char *nvme_subsystem_get_iopolicy(nvme_subsystem_t s)
{
return s->iopolicy;
}

nvme_ctrl_t nvme_subsystem_first_ctrl(nvme_subsystem_t s)
{
return list_top(&s->ctrls, struct nvme_ctrl, entry);
Expand Down Expand Up @@ -459,6 +464,8 @@ static void __nvme_free_subsystem(struct nvme_subsystem *s)
free(s->subsystype);
if (s->application)
free(s->application);
if (s->iopolicy)
free(s->iopolicy);
free(s);
}

Expand Down Expand Up @@ -638,6 +645,7 @@ static int nvme_init_subsystem(nvme_subsystem_t s, const char *name)
s->sysfs_dir = (char *)path;
if (s->h->r->application)
s->application = strdup(s->h->r->application);
s->iopolicy = nvme_get_attr(path, "iopolicy");

return 0;
}
Expand Down
8 changes: 8 additions & 0 deletions src/nvme/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,14 @@ const char *nvme_subsystem_get_application(nvme_subsystem_t s);
*/
void nvme_subsystem_set_application(nvme_subsystem_t s, const char *a);

/**
* nvme_subsystem_get_iopolicy() - Return the IO policy of subsytem
* @s: nvme_subsystem_t object
*
* Return: IO policy used by current subsystem
*/
const char *nvme_subsystem_get_iopolicy(nvme_subsystem_t s);

/**
* nvme_scan_topology() - Scan NVMe topology and apply filter
* @r: nvme_root_t object
Expand Down

0 comments on commit f004349

Please sign in to comment.