Repository: mesos
Updated Branches:
  refs/heads/master 3dc041d55 -> 6241f7722


Fixed the device number proto 'major' and 'minor' to avoid MACROs.

Review: https://reviews.apache.org/r/61531


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6241f772
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6241f772
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6241f772

Branch: refs/heads/master
Commit: 6241f7722b85783d6ab7c3db77d6bb92c8dbc21a
Parents: 3dc041d
Author: Gilbert Song <songzihao1...@gmail.com>
Authored: Wed Aug 9 10:35:46 2017 -0700
Committer: Gilbert Song <songzihao1...@gmail.com>
Committed: Fri Aug 11 13:40:10 2017 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto                       |  4 ++--
 include/mesos/v1/mesos.proto                    |  4 ++--
 src/linux/cgroups.cpp                           | 20 ++++++++++++++++++++
 src/linux/cgroups.hpp                           |  4 ++--
 .../isolators/cgroups/subsystems/blkio.cpp      | 20 ++++++++++++++------
 5 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6241f772/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 5ac242c..50a5caf 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -3153,8 +3153,8 @@ message FileInfo {
  */
 message Device {
   message Number {
-    required uint64 major = 1;
-    required uint64 minor = 2;
+    required uint64 major_number = 1;
+    required uint64 minor_number = 2;
   }
 
   optional string path = 1;

http://git-wip-us.apache.org/repos/asf/mesos/blob/6241f772/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index ff02813..9d47a8a 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -3136,8 +3136,8 @@ message FileInfo {
  */
 message Device {
   message Number {
-    required uint64 major = 1;
-    required uint64 minor = 2;
+    required uint64 major_number = 1;
+    required uint64 minor_number = 2;
   }
 
   optional string path = 1;

http://git-wip-us.apache.org/repos/asf/mesos/blob/6241f772/src/linux/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp
index 21f9983..95c81d9 100644
--- a/src/linux/cgroups.cpp
+++ b/src/linux/cgroups.cpp
@@ -24,6 +24,14 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 
+// This header include must be enclosed in an `extern "C"` block to
+// workaround a bug in glibc <= 2.12 (see MESOS-7378).
+//
+// TODO(gilbert): Remove this when we no longer support glibc <= 2.12.
+extern "C" {
+#include <sys/sysmacros.h>
+}
+
 #include <glog/logging.h>
 
 #include <fstream>
@@ -1933,6 +1941,18 @@ Result<string> cgroup(pid_t pid)
 }
 
 
+unsigned int Device::getMajor() const
+{
+  return major(value);
+}
+
+
+unsigned int Device::getMinor() const
+{
+  return minor(value);
+}
+
+
 Try<Device> Device::parse(const string& s)
 {
   vector<string> device = strings::tokenize(s, ":");

http://git-wip-us.apache.org/repos/asf/mesos/blob/6241f772/src/linux/cgroups.hpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.hpp b/src/linux/cgroups.hpp
index e708747..154e5b6 100644
--- a/src/linux/cgroups.hpp
+++ b/src/linux/cgroups.hpp
@@ -415,8 +415,8 @@ class Device
 {
 public:
   constexpr Device(dev_t device) : value(device) {}
-  inline unsigned int getMajor() const { return major(value); }
-  inline unsigned int getMinor() const { return minor(value); }
+  unsigned int getMajor() const;
+  unsigned int getMinor() const;
 
   inline bool operator==(const Device& that) const
   {

http://git-wip-us.apache.org/repos/asf/mesos/blob/6241f772/src/slave/containerizer/mesos/isolators/cgroups/subsystems/blkio.cpp
----------------------------------------------------------------------
diff --git 
a/src/slave/containerizer/mesos/isolators/cgroups/subsystems/blkio.cpp 
b/src/slave/containerizer/mesos/isolators/cgroups/subsystems/blkio.cpp
index 96014b5..bbbe766 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups/subsystems/blkio.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups/subsystems/blkio.cpp
@@ -14,6 +14,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// This header include must be enclosed in an `extern "C"` block to
+// workaround a bug in glibc <= 2.12 (see MESOS-7378).
+//
+// TODO(gilbert): Remove this when we no longer support glibc <= 2.12.
+extern "C" {
+#include <sys/sysmacros.h>
+}
+
 #include <process/id.hpp>
 
 #include <stout/foreach.hpp>
@@ -351,20 +359,20 @@ Future<ResourceStatistics> BlkioSubsystem::usage(
   CgroupInfo::Blkio::Statistics* stat = result.mutable_blkio_statistics();
 
   foreachkey (dev_t dev, cfq) {
-    cfq[dev].mutable_device()->set_major(major(dev));
-    cfq[dev].mutable_device()->set_minor(minor(dev));
+    cfq[dev].mutable_device()->set_major_number(major(dev));
+    cfq[dev].mutable_device()->set_minor_number(minor(dev));
     stat->add_cfq()->CopyFrom(cfq[dev]);
   }
 
   foreachkey (dev_t dev, cfqRecursive) {
-    cfqRecursive[dev].mutable_device()->set_major(major(dev));
-    cfqRecursive[dev].mutable_device()->set_minor(minor(dev));
+    cfqRecursive[dev].mutable_device()->set_major_number(major(dev));
+    cfqRecursive[dev].mutable_device()->set_minor_number(minor(dev));
     stat->add_cfq_recursive()->CopyFrom(cfqRecursive[dev]);
   }
 
   foreachkey (dev_t dev, throttling) {
-    throttling[dev].mutable_device()->set_major(major(dev));
-    throttling[dev].mutable_device()->set_minor(minor(dev));
+    throttling[dev].mutable_device()->set_major_number(major(dev));
+    throttling[dev].mutable_device()->set_minor_number(minor(dev));
     stat->add_throttling()->CopyFrom(throttling[dev]);
   }
 

Reply via email to