summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2019-01-03 21:30:59 +0100
committerSage Weil <sage@redhat.com>2019-01-04 20:08:03 +0100
commit8cddab4520b71c030311f33a3f1927d2a98e1c3f (patch)
treef5ab34e20245b2586a5616f16af0ac1725ffb882 /src
parentcommon/numa: cpu_set helpers and numa helpers (diff)
downloadceph-8cddab4520b71c030311f33a3f1927d2a98e1c3f.tar.xz
ceph-8cddab4520b71c030311f33a3f1927d2a98e1c3f.zip
common/blkdev: query numa info
Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/common/blkdev.cc12
-rw-r--r--src/common/blkdev.h5
2 files changed, 16 insertions, 1 deletions
diff --git a/src/common/blkdev.cc b/src/common/blkdev.cc
index 8f6a3a3f010..c32c7ba5d21 100644
--- a/src/common/blkdev.cc
+++ b/src/common/blkdev.cc
@@ -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);
diff --git a/src/common/blkdev.h b/src/common/blkdev.h
index 7a29a1e39cd..4df433f76af 100644
--- a/src/common/blkdev.h
+++ b/src/common/blkdev.h
@@ -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;