]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Add getter for subsystem iopolicy
authorDaniel Wagner <dwagner@suse.de>
Wed, 26 Jul 2023 13:33:39 +0000 (15:33 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 26 Jul 2023 13:40:45 +0000 (15:40 +0200)
Allow to retrieve the iopolicy settings for the subsystem.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/libnvme.map
src/nvme/private.h
src/nvme/tree.c
src/nvme/tree.h

index 83dd25ac8e546bce5f399453235454b20fb39fb1..d3930998faa09a6d44c81b3e253ba2f30730c091 100644 (file)
@@ -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;
 };
 
index f4992a48a41e1d6c7a8238c107c4f23296248051..edb6c4e297e4f68f8f12d3ae6bbb0ea27ba9ed2e 100644 (file)
@@ -106,6 +106,7 @@ struct nvme_subsystem {
        char *firmware;
        char *subsystype;
        char *application;
+       char *iopolicy;
 };
 
 struct nvme_host {
index 60e861e0b3f00a83f31d95dca61a79abbd7c096d..a8d2cfcc1c15a52324c93c3f2bbcc43b9daa12f1 100644 (file)
@@ -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);
@@ -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);
 }
 
@@ -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;
 }
index a82019e042bf0867a7e811c9c97754d79b4659c2..ac3c30f804609b143646a2841cee10a73dd217c2 100644 (file)
@@ -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