]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/blkdev: query numa info
authorSage Weil <sage@redhat.com>
Thu, 3 Jan 2019 20:30:59 +0000 (14:30 -0600)
committerSage Weil <sage@redhat.com>
Fri, 4 Jan 2019 19:08:03 +0000 (13:08 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/blkdev.cc
src/common/blkdev.h

index 8f6a3a3f0109e0153cfcfa5be5196397931b9238..c32c7ba5d21fcf2743222d07f8658e0e7a6f044d 100644 (file)
@@ -31,6 +31,7 @@
 #include "include/uuid.h"
 #include "include/stringify.h"
 #include "blkdev.h"
+#include "numa.h"
 
 #include "json_spirit/json_spirit_reader.h"
 
@@ -108,6 +109,8 @@ static const char *blkdev_props2strings[] = {
   [BLKDEV_PROP_ROTATIONAL]          = "queue/rotational",
   [BLKDEV_PROP_SERIAL]              = "device/serial",
   [BLKDEV_PROP_VENDOR]              = "device/device/vendor",
+  [BLKDEV_PROP_NUMA_NODE]           = "device/device/numa_node",
+  [BLKDEV_PROP_NUMA_CPUS]           = "device/device/local_cpulist",
 };
 
 const char *BlkDev::sysfsdir() const {
@@ -228,6 +231,15 @@ bool BlkDev::is_rotational() const
   return get_int_property(BLKDEV_PROP_ROTATIONAL) > 0;
 }
 
+int BlkDev::get_numa_node(int *node) const
+{
+  int numa = get_int_property(BLKDEV_PROP_NUMA_NODE);
+  if (numa < 0)
+    return -1;
+  *node = numa;
+  return 0;
+}
+
 int BlkDev::dev(char *dev, size_t max) const
 {
   return get_string_property(BLKDEV_PROP_DEV, dev, max);
index 7a29a1e39cd8b6295d402ce3099560669b9351eb..4df433f76affecf750fab20fd8efb3ed83919ac5 100644 (file)
@@ -15,7 +15,9 @@ enum blkdev_prop_t {
   BLKDEV_PROP_ROTATIONAL,
   BLKDEV_PROP_SERIAL,
   BLKDEV_PROP_VENDOR,
-  BLKDEV_PROP_NUMPROPS
+  BLKDEV_PROP_NUMA_NODE,
+  BLKDEV_PROP_NUMA_CPUS,
+  BLKDEV_PROP_NUMPROPS,
 };
 
 extern int get_device_by_path(const char *path, char* partition, char* device, size_t max);
@@ -54,6 +56,7 @@ public:
   bool support_discard() const;
   bool is_nvme() const;
   bool is_rotational() const;
+  int get_numa_node(int *node) const;
   int dev(char *dev, size_t max) const;
   int vendor(char *vendor, size_t max) const;
   int model(char *model, size_t max) const;