From: DaiZhiwei Date: Sat, 30 Nov 2019 02:59:04 +0000 (+0800) Subject: osd/osd: Refactor get_iface_numa_node X-Git-Tag: v15.1.0~581^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=926248e9924ddff3b33756889d79ccdf70635c20;p=ceph-ci.git osd/osd: Refactor get_iface_numa_node Signed-off-by: Dai zhiwei Signed-off-by: luo rixin --- diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc index e6da4248b50..7c38de659c8 100644 --- a/src/common/pick_address.cc +++ b/src/common/pick_address.cc @@ -511,7 +511,7 @@ int get_iface_numa_node( const std::string& iface, int *node) { - int ifatype = IFACE_DEFAULT; + enum { IFACE_PHY_PORT = 1, IFACE_BOND_PORT = 2} ifatype = IFACE_PHY_PORT; string ifa = iface; int pos = ifa.find(":"); if (pos != string::npos) { @@ -526,14 +526,11 @@ int get_iface_numa_node( return -errno; } ifatype = IFACE_BOND_PORT; - } else { - ifatype = IFACE_PHY_PORT; } int r = 0; char buf[1024]; char *endptr = 0; - int bond_node = -1; r = safe_read(fd, &buf, sizeof(buf)); if (r < 0) { goto out; @@ -553,12 +550,10 @@ int get_iface_numa_node( r = 0; break; case IFACE_BOND_PORT: + int bond_node = -1; std::vector sv; - char *q, *p = strtok_r(buf, " ", &q); - while (p != NULL) { - sv.push_back(p); - p = strtok_r(NULL, " ", &q); - } + std::string ifacestr = buf; + get_str_vec(ifacestr, " ", sv); for (auto& iter : sv) { int bn = -1; r = get_iface_numa_node(iter, &bn); diff --git a/src/common/pick_address.h b/src/common/pick_address.h index ba9473a9649..aa87e7c51eb 100644 --- a/src/common/pick_address.h +++ b/src/common/pick_address.h @@ -20,12 +20,6 @@ class entity_addrvec_t; #define CEPH_PICK_ADDRESS_PREFER_IPV4 0x40 #define CEPH_PICK_ADDRESS_DEFAULT_MON_PORTS 0x80 -enum IfaceType { - IFACE_DEFAULT = 0, - IFACE_PHY_PORT = 1, - IFACE_BOND_PORT = 2 -}; - #ifndef WITH_SEASTAR /* Pick addresses based on subnets if needed.