mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject [2/7] mesos git commit: Added special case when sorting hierarchically in MountInfoTable::read.
Date Thu, 13 Oct 2016 05:34:40 GMT
Added special case when sorting hierarchically in MountInfoTable::read.

It is legal to have entries in a `MountInfoTable` whose `entry.id` is
the same as `entry.parent`. This can happen (for example), if a system
boots from the network and then keeps the original `/` in RAM.
However, to avoid cycles when walking the mount hierarchy, we should
not treat these entries as children of their parent so we skip them.

This commit adds functionality to handle this case.

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


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

Branch: refs/heads/master
Commit: ccc746a7d12cc524120a76aa49a0d69e7303608a
Parents: 70b227f
Author: Kevin Klues <klueska@gmail.com>
Authored: Wed Oct 12 22:33:56 2016 -0700
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Wed Oct 12 22:33:56 2016 -0700

----------------------------------------------------------------------
 src/linux/fs.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ccc746a7/src/linux/fs.cpp
----------------------------------------------------------------------
diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp
index d49d1f5..aeec882 100644
--- a/src/linux/fs.cpp
+++ b/src/linux/fs.cpp
@@ -147,7 +147,16 @@ Try<MountInfoTable> MountInfoTable::read(
       foreach (const MountInfoTable::Entry& entry, parentToChildren[parentId]) {
         int newParentId = entry.id;
         sortedEntries.push_back(std::move(entry));
-        sortFrom(newParentId);
+
+        // It is legal to have a `MountInfoTable` entry whose
+        // `entry.id` is the same as its `entry.parent`. This can
+        // happen (for example), if a system boots from the network
+        // and then keeps the original `/` in RAM. To avoid cycles
+        // when walking the mount hierarchy, we only recurse into our
+        // children if this case is not satisfied.
+        if (parentId != newParentId) {
+          sortFrom(newParentId);
+        }
       }
     };
 


Mime
View raw message