{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/rkt/pulls/comments/47344428","id":47344428,"diff_hunk":"@@ -65,34 +67,86 @@ type mount struct {\n \tid         int\n \tparentId   int\n \tmountPoint string\n+\tmode       string\n }\n \n type mounts []*mount\n \n-// Less ensures that mounts are sorted in an order we can unmount; child before\n-// parent. This works by pushing all child mounts up to the front. Parent\n-// mounts are halted once they encounter a child. The actual sequential order\n-// of the mounts doesn't matter; only that children are in front of parents.\n-func (m mounts) Less(i, j int) bool { return m[i].id != m[j].parentId }\n-func (m mounts) Len() int           { return len(m) }\n-func (m mounts) Swap(i, j int)      { m[i], m[j] = m[j], m[i] }\n+// Less ensures that mounts are sorted in an order we can unmount; descendant before ancestor.\n+// The requirement of transitivity for Less has to be fulfilled otherwise the sort algorithm will fail.\n+// Transitivity is not necessary for our use-case though, so we have to declare extra conditions.\n+func (m mounts) getAncestors(i int) map[int]struct{} {\n+\tancestorMap := make(map[int]struct{}, 0)\n+\tcurrent := m[i]\n+\tfound := true","path":"stage0/gc.go","position":32,"original_position":32,"commit_id":"878e76161fffccd3d232e9e46a297a8545fb7844","original_commit_id":"878e76161fffccd3d232e9e46a297a8545fb7844","user":{"login":"krnowak","id":96081,"avatar_url":"https://avatars.githubusercontent.com/u/96081?v=3","gravatar_id":"","url":"https://api.github.com/users/krnowak","html_url":"https://github.com/krnowak","followers_url":"https://api.github.com/users/krnowak/followers","following_url":"https://api.github.com/users/krnowak/following{/other_user}","gists_url":"https://api.github.com/users/krnowak/gists{/gist_id}","starred_url":"https://api.github.com/users/krnowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krnowak/subscriptions","organizations_url":"https://api.github.com/users/krnowak/orgs","repos_url":"https://api.github.com/users/krnowak/repos","events_url":"https://api.github.com/users/krnowak/events{/privacy}","received_events_url":"https://api.github.com/users/krnowak/received_events","type":"User","site_admin":false},"body":"How about:\r\n```go\r\nfor {\r\n\tfound := false\r\n\tfor i, mnt := range m {\r\n\t\tif mnt.id == current.parentId {\r\n\t\t\tfound = true\r\n\t\t\tancestorMap[mnt.id] = struct{}{}\r\n\t\t\tcurrent = mnt\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n\tif !found {\r\n\t\tbreak\r\n\t}\r\n}\r\n```\r\n","created_at":"2015-12-11T11:08:11Z","updated_at":"2015-12-11T11:08:11Z","html_url":"https://github.com/coreos/rkt/pull/1856#discussion_r47344428","pull_request_url":"https://api.github.com/repos/coreos/rkt/pulls/1856","_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments/47344428"},"html":{"href":"https://github.com/coreos/rkt/pull/1856#discussion_r47344428"},"pull_request":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1856"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/rkt/pulls/1856","id":53122756,"html_url":"https://github.com/coreos/rkt/pull/1856","diff_url":"https://github.com/coreos/rkt/pull/1856.diff","patch_url":"https://github.com/coreos/rkt/pull/1856.patch","issue_url":"https://api.github.com/repos/coreos/rkt/issues/1856","number":1856,"state":"open","locked":false,"title":"GC: always detect and unmount leftovers","user":{"login":"steveeJ","id":1181362,"avatar_url":"https://avatars.githubusercontent.com/u/1181362?v=3","gravatar_id":"","url":"https://api.github.com/users/steveeJ","html_url":"https://github.com/steveeJ","followers_url":"https://api.github.com/users/steveeJ/followers","following_url":"https://api.github.com/users/steveeJ/following{/other_user}","gists_url":"https://api.github.com/users/steveeJ/gists{/gist_id}","starred_url":"https://api.github.com/users/steveeJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveeJ/subscriptions","organizations_url":"https://api.github.com/users/steveeJ/orgs","repos_url":"https://api.github.com/users/steveeJ/repos","events_url":"https://api.github.com/users/steveeJ/events{/privacy}","received_events_url":"https://api.github.com/users/steveeJ/received_events","type":"User","site_admin":false},"body":"This covers unmounting of recursive bind-mounts, as well as the overlay mounts.\r\nIt also has the advantage of not attempting to unmount something that is\r\nnot there, e.g. if a reboot happened and the mounts are gone anyway.","created_at":"2015-12-09T14:08:32Z","updated_at":"2015-12-11T11:08:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8979574dcd7fb5eec785921023a8909be8f24761","assignee":null,"milestone":{"url":"https://api.github.com/repos/coreos/rkt/milestones/25","html_url":"https://github.com/coreos/rkt/milestones/v0.14.0","labels_url":"https://api.github.com/repos/coreos/rkt/milestones/25/labels","id":1408793,"number":25,"title":"v0.14.0","description":"","creator":{"login":"alban","id":27575,"avatar_url":"https://avatars.githubusercontent.com/u/27575?v=3","gravatar_id":"","url":"https://api.github.com/users/alban","html_url":"https://github.com/alban","followers_url":"https://api.github.com/users/alban/followers","following_url":"https://api.github.com/users/alban/following{/other_user}","gists_url":"https://api.github.com/users/alban/gists{/gist_id}","starred_url":"https://api.github.com/users/alban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alban/subscriptions","organizations_url":"https://api.github.com/users/alban/orgs","repos_url":"https://api.github.com/users/alban/repos","events_url":"https://api.github.com/users/alban/events{/privacy}","received_events_url":"https://api.github.com/users/alban/received_events","type":"User","site_admin":false},"open_issues":42,"closed_issues":23,"state":"open","created_at":"2015-11-12T16:51:31Z","updated_at":"2015-12-11T09:28:18Z","due_on":"2015-12-16T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/coreos/rkt/pulls/1856/commits","review_comments_url":"https://api.github.com/repos/coreos/rkt/pulls/1856/comments","review_comment_url":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/rkt/issues/1856/comments","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/878e76161fffccd3d232e9e46a297a8545fb7844","head":{"label":"steveeJ:gc-rework","ref":"gc-rework","sha":"878e76161fffccd3d232e9e46a297a8545fb7844","user":{"login":"steveeJ","id":1181362,"avatar_url":"https://avatars.githubusercontent.com/u/1181362?v=3","gravatar_id":"","url":"https://api.github.com/users/steveeJ","html_url":"https://github.com/steveeJ","followers_url":"https://api.github.com/users/steveeJ/followers","following_url":"https://api.github.com/users/steveeJ/following{/other_user}","gists_url":"https://api.github.com/users/steveeJ/gists{/gist_id}","starred_url":"https://api.github.com/users/steveeJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveeJ/subscriptions","organizations_url":"https://api.github.com/users/steveeJ/orgs","repos_url":"https://api.github.com/users/steveeJ/repos","events_url":"https://api.github.com/users/steveeJ/events{/privacy}","received_events_url":"https://api.github.com/users/steveeJ/received_events","type":"User","site_admin":false},"repo":{"id":34967118,"name":"rkt","full_name":"steveeJ/rkt","owner":{"login":"steveeJ","id":1181362,"avatar_url":"https://avatars.githubusercontent.com/u/1181362?v=3","gravatar_id":"","url":"https://api.github.com/users/steveeJ","html_url":"https://github.com/steveeJ","followers_url":"https://api.github.com/users/steveeJ/followers","following_url":"https://api.github.com/users/steveeJ/following{/other_user}","gists_url":"https://api.github.com/users/steveeJ/gists{/gist_id}","starred_url":"https://api.github.com/users/steveeJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveeJ/subscriptions","organizations_url":"https://api.github.com/users/steveeJ/orgs","repos_url":"https://api.github.com/users/steveeJ/repos","events_url":"https://api.github.com/users/steveeJ/events{/privacy}","received_events_url":"https://api.github.com/users/steveeJ/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/steveeJ/rkt","description":"rkt is an App Container runtime for Linux","fork":true,"url":"https://api.github.com/repos/steveeJ/rkt","forks_url":"https://api.github.com/repos/steveeJ/rkt/forks","keys_url":"https://api.github.com/repos/steveeJ/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/steveeJ/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/steveeJ/rkt/teams","hooks_url":"https://api.github.com/repos/steveeJ/rkt/hooks","issue_events_url":"https://api.github.com/repos/steveeJ/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/steveeJ/rkt/events","assignees_url":"https://api.github.com/repos/steveeJ/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/steveeJ/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/steveeJ/rkt/tags","blobs_url":"https://api.github.com/repos/steveeJ/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/steveeJ/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/steveeJ/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/steveeJ/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/steveeJ/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/steveeJ/rkt/languages","stargazers_url":"https://api.github.com/repos/steveeJ/rkt/stargazers","contributors_url":"https://api.github.com/repos/steveeJ/rkt/contributors","subscribers_url":"https://api.github.com/repos/steveeJ/rkt/subscribers","subscription_url":"https://api.github.com/repos/steveeJ/rkt/subscription","commits_url":"https://api.github.com/repos/steveeJ/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/steveeJ/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/steveeJ/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/steveeJ/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/steveeJ/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/steveeJ/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/steveeJ/rkt/merges","archive_url":"https://api.github.com/repos/steveeJ/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/steveeJ/rkt/downloads","issues_url":"https://api.github.com/repos/steveeJ/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/steveeJ/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/steveeJ/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/steveeJ/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/steveeJ/rkt/labels{/name}","releases_url":"https://api.github.com/repos/steveeJ/rkt/releases{/id}","created_at":"2015-05-02T23:42:32Z","updated_at":"2015-05-02T23:42:50Z","pushed_at":"2015-12-11T10:45:33Z","git_url":"git://github.com/steveeJ/rkt.git","ssh_url":"git@github.com:steveeJ/rkt.git","clone_url":"https://github.com/steveeJ/rkt.git","svn_url":"https://github.com/steveeJ/rkt","homepage":"","size":17790,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"0d551c325197cf7b9656ef0378f03f1b42a9f60c","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":26509369,"name":"rkt","full_name":"coreos/rkt","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/rkt","description":"rkt is an App Container runtime for Linux","fork":false,"url":"https://api.github.com/repos/coreos/rkt","forks_url":"https://api.github.com/repos/coreos/rkt/forks","keys_url":"https://api.github.com/repos/coreos/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/rkt/teams","hooks_url":"https://api.github.com/repos/coreos/rkt/hooks","issue_events_url":"https://api.github.com/repos/coreos/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/rkt/events","assignees_url":"https://api.github.com/repos/coreos/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/rkt/tags","blobs_url":"https://api.github.com/repos/coreos/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/rkt/languages","stargazers_url":"https://api.github.com/repos/coreos/rkt/stargazers","contributors_url":"https://api.github.com/repos/coreos/rkt/contributors","subscribers_url":"https://api.github.com/repos/coreos/rkt/subscribers","subscription_url":"https://api.github.com/repos/coreos/rkt/subscription","commits_url":"https://api.github.com/repos/coreos/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/rkt/merges","archive_url":"https://api.github.com/repos/coreos/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/rkt/downloads","issues_url":"https://api.github.com/repos/coreos/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/rkt/labels{/name}","releases_url":"https://api.github.com/repos/coreos/rkt/releases{/id}","created_at":"2014-11-11T23:13:18Z","updated_at":"2015-12-11T03:11:33Z","pushed_at":"2015-12-11T10:45:34Z","git_url":"git://github.com/coreos/rkt.git","ssh_url":"git@github.com:coreos/rkt.git","clone_url":"https://github.com/coreos/rkt.git","svn_url":"https://github.com/coreos/rkt","homepage":"","size":21515,"stargazers_count":4925,"watchers_count":4925,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":419,"mirror_url":null,"open_issues_count":198,"forks":419,"open_issues":198,"watchers":4925,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1856"},"html":{"href":"https://github.com/coreos/rkt/pull/1856"},"issue":{"href":"https://api.github.com/repos/coreos/rkt/issues/1856"},"comments":{"href":"https://api.github.com/repos/coreos/rkt/issues/1856/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1856/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/rkt/pulls/1856/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/rkt/statuses/878e76161fffccd3d232e9e46a297a8545fb7844"}}}}