{"action":"created","comment":{"url":"https://api.github.com/repos/openzfs/openzfs/pulls/comments/154513245","pull_request_review_id":80691285,"id":154513245,"diff_hunk":"@@ -0,0 +1,594 @@\n+/*\n+ * CDDL HEADER START\n+ *\n+ * This file and its contents are supplied under the terms of the\n+ * Common Development and Distribution License (\"CDDL\"), version 1.0.\n+ * You may only use this file in accordance with the terms of version\n+ * 1.0 of the CDDL.\n+ *\n+ * A full copy of the text of the CDDL should have accompanied this\n+ * source.  A copy of the CDDL is also available via the Internet at\n+ * http://www.illumos.org/license/CDDL.\n+ *\n+ * CDDL HEADER END\n+ */\n+\n+/*\n+ * Copyright (c) 2015 by Delphix. All rights reserved.\n+ */\n+\n+#include <sys/dmu_tx.h>\n+#include <sys/dsl_pool.h>\n+#include <sys/spa.h>\n+#include <sys/vdev_impl.h>\n+#include <sys/vdev_indirect_mapping.h>\n+#include <sys/zfeature.h>\n+#include <sys/dmu_objset.h>\n+\n+static boolean_t\n+vdev_indirect_mapping_verify(vdev_indirect_mapping_t *vim)\n+{\n+\tASSERT(vim != NULL);\n+\n+\tASSERT(vim->vim_object != 0);\n+\tASSERT(vim->vim_objset != NULL);\n+\tASSERT(vim->vim_phys != NULL);\n+\tASSERT(vim->vim_dbuf != NULL);\n+\n+\tEQUIV(vim->vim_phys->vimp_num_entries > 0,\n+\t    vim->vim_entries != NULL);\n+\tif (vim->vim_phys->vimp_num_entries > 0) {\n+\t\tvdev_indirect_mapping_entry_phys_t *last_entry =\n+\t\t    &vim->vim_entries[vim->vim_phys->vimp_num_entries - 1];\n+\t\tuint64_t offset = DVA_MAPPING_GET_SRC_OFFSET(last_entry);\n+\t\tuint64_t size = DVA_GET_ASIZE(&last_entry->vimep_dst);\n+\n+\t\tASSERT3U(vim->vim_phys->vimp_max_offset, >=, offset + size);\n+\t}\n+\tif (vim->vim_havecounts) {\n+\t\tASSERT(vim->vim_phys->vimp_counts_object != 0);\n+\t}\n+\n+\treturn (B_TRUE);\n+}\n+\n+uint64_t\n+vdev_indirect_mapping_num_entries(vdev_indirect_mapping_t *vim)\n+{\n+\tASSERT(vdev_indirect_mapping_verify(vim));\n+\n+\treturn (vim->vim_phys->vimp_num_entries);\n+}\n+\n+uint64_t\n+vdev_indirect_mapping_max_offset(vdev_indirect_mapping_t *vim)\n+{\n+\tASSERT(vdev_indirect_mapping_verify(vim));\n+\n+\treturn (vim->vim_phys->vimp_max_offset);\n+}\n+\n+uint64_t\n+vdev_indirect_mapping_object(vdev_indirect_mapping_t *vim)\n+{\n+\tASSERT(vdev_indirect_mapping_verify(vim));\n+\n+\treturn (vim->vim_object);\n+}\n+\n+uint64_t\n+vdev_indirect_mapping_bytes_mapped(vdev_indirect_mapping_t *vim)\n+{\n+\tASSERT(vdev_indirect_mapping_verify(vim));\n+\n+\treturn (vim->vim_phys->vimp_bytes_mapped);\n+}\n+\n+/*\n+ * The length (in bytes) of the mapping object array in memory and\n+ * (logically) on disk.\n+ *\n+ * Note that unlike most of our accessor functions,\n+ * we don't assert that the struct is consistent; therefore it can be\n+ * called while there may be concurrent changes, if we don't care about\n+ * the value being immediately stale (e.g. from spa_removal_get_stats()).\n+ */\n+uint64_t\n+vdev_indirect_mapping_size(vdev_indirect_mapping_t *vim)\n+{\n+\treturn (vim->vim_phys->vimp_num_entries * sizeof (*vim->vim_entries));\n+}\n+\n+/*\n+ * Compare an offset with an indirect mapping entry; there are three\n+ * possible scenarios:\n+ *\n+ *     1. The offset is \"less than\" the mapping entry; meaning the\n+ *        offset is less than the source offset of the mapping entry. In\n+ *        this case, there is no overlap between the offset and the\n+ *        mapping entry and -1 will be returned.\n+ *\n+ *     2. The offset is \"greater than\" the mapping entry; meaning the\n+ *        offset is greater than the mapping entry's source offset plus\n+ *        the entry's size. In this case, there is no overlap between\n+ *        the offset and the mapping entry and 1 will be returned.\n+ *\n+ *        NOTE: If the offset is actually equal to the entry's offset\n+ *        plus size, this is considered to be \"greater\" than the entry,\n+ *        and this case applies (i.e. 1 will be returned). Thus, the\n+ *        entry's \"range\" can be considered to be inclusive at its\n+ *        start, but exclusive at its end: e.g. [src, src + size).\n+ *\n+ *     3. The last case to consider is if the offset actually falls\n+ *        within the mapping entry's range. If this is the case, the\n+ *        offset is considered to be \"equal to\" the mapping entry and\n+ *        0 will be returned.\n+ *\n+ *        NOTE: If the offset is equal to the entry's source offset,\n+ *        this case applies and 0 will be returned. If the offset is\n+ *        equal to the entry's source plus its size, this case does\n+ *        *not* apply (see \"NOTE\" above for scenario 2), and 1 will be\n+ *        returned.\n+ */\n+static int\n+dva_mapping_overlap_compare(const void *v_key, const void *v_array_elem)\n+{\n+\tconst uint64_t const *key = v_key;\n+\tconst vdev_indirect_mapping_entry_phys_t const *array_elem =\n+\t    v_array_elem;","path":"usr/src/uts/common/fs/zfs/vdev_indirect_mapping.c","position":138,"original_position":138,"commit_id":"ab76136f115730cc18702f8e7655ed23d1f8231b","original_commit_id":"ab76136f115730cc18702f8e7655ed23d1f8231b","user":{"login":"dweeezil","id":1432005,"avatar_url":"https://avatars1.githubusercontent.com/u/1432005?v=4","gravatar_id":"","url":"https://api.github.com/users/dweeezil","html_url":"https://github.com/dweeezil","followers_url":"https://api.github.com/users/dweeezil/followers","following_url":"https://api.github.com/users/dweeezil/following{/other_user}","gists_url":"https://api.github.com/users/dweeezil/gists{/gist_id}","starred_url":"https://api.github.com/users/dweeezil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dweeezil/subscriptions","organizations_url":"https://api.github.com/users/dweeezil/orgs","repos_url":"https://api.github.com/users/dweeezil/repos","events_url":"https://api.github.com/users/dweeezil/events{/privacy}","received_events_url":"https://api.github.com/users/dweeezil/received_events","type":"User","site_admin":false},"body":"I moved the second ```const``` after the \"*\".","created_at":"2017-12-03T03:41:34Z","updated_at":"2017-12-03T03:41:34Z","html_url":"https://github.com/openzfs/openzfs/pull/482#discussion_r154513245","pull_request_url":"https://api.github.com/repos/openzfs/openzfs/pulls/482","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/comments/154513245"},"html":{"href":"https://github.com/openzfs/openzfs/pull/482#discussion_r154513245"},"pull_request":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/482"}},"in_reply_to_id":153272417},"pull_request":{"url":"https://api.github.com/repos/openzfs/openzfs/pulls/482","id":148278452,"html_url":"https://github.com/openzfs/openzfs/pull/482","diff_url":"https://github.com/openzfs/openzfs/pull/482.diff","patch_url":"https://github.com/openzfs/openzfs/pull/482.patch","issue_url":"https://api.github.com/repos/openzfs/openzfs/issues/482","number":482,"state":"open","locked":false,"title":"7614 zfs device evacuation/removal","user":{"login":"prashks","id":1361362,"avatar_url":"https://avatars0.githubusercontent.com/u/1361362?v=4","gravatar_id":"","url":"https://api.github.com/users/prashks","html_url":"https://github.com/prashks","followers_url":"https://api.github.com/users/prashks/followers","following_url":"https://api.github.com/users/prashks/following{/other_user}","gists_url":"https://api.github.com/users/prashks/gists{/gist_id}","starred_url":"https://api.github.com/users/prashks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prashks/subscriptions","organizations_url":"https://api.github.com/users/prashks/orgs","repos_url":"https://api.github.com/users/prashks/repos","events_url":"https://api.github.com/users/prashks/events{/privacy}","received_events_url":"https://api.github.com/users/prashks/received_events","type":"User","site_admin":false},"body":"Reviewed by: Alex Reece <alex@delphix.com>\r\nReviewed by: George Wilson <george.wilson@delphix.com>\r\nReviewed by: John Kennedy <john.kennedy@delphix.com>\r\nReviewed by: Prakash Surya <prakash.surya@delphix.com>\r\n\r\nThis project allows top-level vdevs to be removed from the storage pool\r\nwith \"zpool remove\", reducing the total amount of storage in the pool.\r\nThis operation copies all allocated regions of the device to be removed\r\nonto other devices, recording the mapping from old to new location.\r\nAfter the removal is complete, read and free operations to the removed\r\n(now \"indirect\") vdev must be remapped and performed at the new location\r\non disk.  The indirect mapping table is kept in memory whenever the pool\r\nis loaded, so there is minimal performance overhead when doing\r\noperations on the indirect vdev.\r\n\r\nThe size of the in-memory mapping table will be reduced when its entries\r\nbecome \"obsolete\" because they are no longer used by any block pointers\r\nin the pool.  An entry becomes obsolete when all the blocks that use it\r\nare freed.  An entry can also become obsolete when all the snapshots\r\nthat reference it are deleted, and the block pointers that reference it\r\nhave been \"remapped\" in all filesystems/zvols (and clones).  Whenever an\r\nindirect block is written, all the block pointers in it will be\r\n\"remapped\" to their new (concrete) locations if possible.  This process\r\ncan be accelerated by using the \"zfs remap\" command to proactively\r\nrewrite all indirect blocks that reference indirect (removed) vdevs.\r\n\r\nNote that when a device is removed, we do not verify the checksum of the\r\ndata that is copied.  This makes the process much faster, but if it were\r\nused on raidz vdevs, it would be possible to copy the wrong data, \r\nwhen we have the correct data on e.g. the other side of the raidz.\r\nTherefore, raidz devices can not be removed.","created_at":"2017-10-24T01:38:45Z","updated_at":"2017-12-03T03:41:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c10b1f570544bfb99e0abf911fbd999f91eb7b11","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/openzfs/openzfs/pulls/482/commits","review_comments_url":"https://api.github.com/repos/openzfs/openzfs/pulls/482/comments","review_comment_url":"https://api.github.com/repos/openzfs/openzfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openzfs/openzfs/issues/482/comments","statuses_url":"https://api.github.com/repos/openzfs/openzfs/statuses/ab76136f115730cc18702f8e7655ed23d1f8231b","head":{"label":"prashks:7614","ref":"7614","sha":"ab76136f115730cc18702f8e7655ed23d1f8231b","user":{"login":"prashks","id":1361362,"avatar_url":"https://avatars0.githubusercontent.com/u/1361362?v=4","gravatar_id":"","url":"https://api.github.com/users/prashks","html_url":"https://github.com/prashks","followers_url":"https://api.github.com/users/prashks/followers","following_url":"https://api.github.com/users/prashks/following{/other_user}","gists_url":"https://api.github.com/users/prashks/gists{/gist_id}","starred_url":"https://api.github.com/users/prashks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prashks/subscriptions","organizations_url":"https://api.github.com/users/prashks/orgs","repos_url":"https://api.github.com/users/prashks/repos","events_url":"https://api.github.com/users/prashks/events{/privacy}","received_events_url":"https://api.github.com/users/prashks/received_events","type":"User","site_admin":false},"repo":{"id":3523598,"name":"illumos-gate","full_name":"prashks/illumos-gate","owner":{"login":"prashks","id":1361362,"avatar_url":"https://avatars0.githubusercontent.com/u/1361362?v=4","gravatar_id":"","url":"https://api.github.com/users/prashks","html_url":"https://github.com/prashks","followers_url":"https://api.github.com/users/prashks/followers","following_url":"https://api.github.com/users/prashks/following{/other_user}","gists_url":"https://api.github.com/users/prashks/gists{/gist_id}","starred_url":"https://api.github.com/users/prashks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prashks/subscriptions","organizations_url":"https://api.github.com/users/prashks/orgs","repos_url":"https://api.github.com/users/prashks/repos","events_url":"https://api.github.com/users/prashks/events{/privacy}","received_events_url":"https://api.github.com/users/prashks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prashks/illumos-gate","description":"Community developed and maintained version of the OS/Net consolidation","fork":true,"url":"https://api.github.com/repos/prashks/illumos-gate","forks_url":"https://api.github.com/repos/prashks/illumos-gate/forks","keys_url":"https://api.github.com/repos/prashks/illumos-gate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prashks/illumos-gate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prashks/illumos-gate/teams","hooks_url":"https://api.github.com/repos/prashks/illumos-gate/hooks","issue_events_url":"https://api.github.com/repos/prashks/illumos-gate/issues/events{/number}","events_url":"https://api.github.com/repos/prashks/illumos-gate/events","assignees_url":"https://api.github.com/repos/prashks/illumos-gate/assignees{/user}","branches_url":"https://api.github.com/repos/prashks/illumos-gate/branches{/branch}","tags_url":"https://api.github.com/repos/prashks/illumos-gate/tags","blobs_url":"https://api.github.com/repos/prashks/illumos-gate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prashks/illumos-gate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prashks/illumos-gate/git/refs{/sha}","trees_url":"https://api.github.com/repos/prashks/illumos-gate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prashks/illumos-gate/statuses/{sha}","languages_url":"https://api.github.com/repos/prashks/illumos-gate/languages","stargazers_url":"https://api.github.com/repos/prashks/illumos-gate/stargazers","contributors_url":"https://api.github.com/repos/prashks/illumos-gate/contributors","subscribers_url":"https://api.github.com/repos/prashks/illumos-gate/subscribers","subscription_url":"https://api.github.com/repos/prashks/illumos-gate/subscription","commits_url":"https://api.github.com/repos/prashks/illumos-gate/commits{/sha}","git_commits_url":"https://api.github.com/repos/prashks/illumos-gate/git/commits{/sha}","comments_url":"https://api.github.com/repos/prashks/illumos-gate/comments{/number}","issue_comment_url":"https://api.github.com/repos/prashks/illumos-gate/issues/comments{/number}","contents_url":"https://api.github.com/repos/prashks/illumos-gate/contents/{+path}","compare_url":"https://api.github.com/repos/prashks/illumos-gate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prashks/illumos-gate/merges","archive_url":"https://api.github.com/repos/prashks/illumos-gate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prashks/illumos-gate/downloads","issues_url":"https://api.github.com/repos/prashks/illumos-gate/issues{/number}","pulls_url":"https://api.github.com/repos/prashks/illumos-gate/pulls{/number}","milestones_url":"https://api.github.com/repos/prashks/illumos-gate/milestones{/number}","notifications_url":"https://api.github.com/repos/prashks/illumos-gate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prashks/illumos-gate/labels{/name}","releases_url":"https://api.github.com/repos/prashks/illumos-gate/releases{/id}","deployments_url":"https://api.github.com/repos/prashks/illumos-gate/deployments","created_at":"2012-02-23T08:34:11Z","updated_at":"2013-01-07T23:32:36Z","pushed_at":"2017-10-28T16:23:23Z","git_url":"git://github.com/prashks/illumos-gate.git","ssh_url":"git@github.com:prashks/illumos-gate.git","clone_url":"https://github.com/prashks/illumos-gate.git","svn_url":"https://github.com/prashks/illumos-gate","homepage":"http://www.illumos.org/projects/illumos-gate","size":302150,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"openzfs:master","ref":"master","sha":"c0b7cacf07c80be55092999ec9981a998d83d2f9","user":{"login":"openzfs","id":4510897,"avatar_url":"https://avatars1.githubusercontent.com/u/4510897?v=4","gravatar_id":"","url":"https://api.github.com/users/openzfs","html_url":"https://github.com/openzfs","followers_url":"https://api.github.com/users/openzfs/followers","following_url":"https://api.github.com/users/openzfs/following{/other_user}","gists_url":"https://api.github.com/users/openzfs/gists{/gist_id}","starred_url":"https://api.github.com/users/openzfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openzfs/subscriptions","organizations_url":"https://api.github.com/users/openzfs/orgs","repos_url":"https://api.github.com/users/openzfs/repos","events_url":"https://api.github.com/users/openzfs/events{/privacy}","received_events_url":"https://api.github.com/users/openzfs/received_events","type":"Organization","site_admin":false},"repo":{"id":44220580,"name":"openzfs","full_name":"openzfs/openzfs","owner":{"login":"openzfs","id":4510897,"avatar_url":"https://avatars1.githubusercontent.com/u/4510897?v=4","gravatar_id":"","url":"https://api.github.com/users/openzfs","html_url":"https://github.com/openzfs","followers_url":"https://api.github.com/users/openzfs/followers","following_url":"https://api.github.com/users/openzfs/following{/other_user}","gists_url":"https://api.github.com/users/openzfs/gists{/gist_id}","starred_url":"https://api.github.com/users/openzfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openzfs/subscriptions","organizations_url":"https://api.github.com/users/openzfs/orgs","repos_url":"https://api.github.com/users/openzfs/repos","events_url":"https://api.github.com/users/openzfs/events{/privacy}","received_events_url":"https://api.github.com/users/openzfs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openzfs/openzfs","description":"OpenZFS is a storage platform that encompasses the functionality of traditional filesystems and volume managers, delivering enterprise reliability, modern functionality, and consistent performance in an easy to administer package on several operating system platforms.","fork":true,"url":"https://api.github.com/repos/openzfs/openzfs","forks_url":"https://api.github.com/repos/openzfs/openzfs/forks","keys_url":"https://api.github.com/repos/openzfs/openzfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openzfs/openzfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openzfs/openzfs/teams","hooks_url":"https://api.github.com/repos/openzfs/openzfs/hooks","issue_events_url":"https://api.github.com/repos/openzfs/openzfs/issues/events{/number}","events_url":"https://api.github.com/repos/openzfs/openzfs/events","assignees_url":"https://api.github.com/repos/openzfs/openzfs/assignees{/user}","branches_url":"https://api.github.com/repos/openzfs/openzfs/branches{/branch}","tags_url":"https://api.github.com/repos/openzfs/openzfs/tags","blobs_url":"https://api.github.com/repos/openzfs/openzfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openzfs/openzfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openzfs/openzfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/openzfs/openzfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openzfs/openzfs/statuses/{sha}","languages_url":"https://api.github.com/repos/openzfs/openzfs/languages","stargazers_url":"https://api.github.com/repos/openzfs/openzfs/stargazers","contributors_url":"https://api.github.com/repos/openzfs/openzfs/contributors","subscribers_url":"https://api.github.com/repos/openzfs/openzfs/subscribers","subscription_url":"https://api.github.com/repos/openzfs/openzfs/subscription","commits_url":"https://api.github.com/repos/openzfs/openzfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/openzfs/openzfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/openzfs/openzfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/openzfs/openzfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/openzfs/openzfs/contents/{+path}","compare_url":"https://api.github.com/repos/openzfs/openzfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openzfs/openzfs/merges","archive_url":"https://api.github.com/repos/openzfs/openzfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openzfs/openzfs/downloads","issues_url":"https://api.github.com/repos/openzfs/openzfs/issues{/number}","pulls_url":"https://api.github.com/repos/openzfs/openzfs/pulls{/number}","milestones_url":"https://api.github.com/repos/openzfs/openzfs/milestones{/number}","notifications_url":"https://api.github.com/repos/openzfs/openzfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openzfs/openzfs/labels{/name}","releases_url":"https://api.github.com/repos/openzfs/openzfs/releases{/id}","deployments_url":"https://api.github.com/repos/openzfs/openzfs/deployments","created_at":"2015-10-14T03:03:50Z","updated_at":"2017-12-01T22:58:59Z","pushed_at":"2017-12-03T01:00:21Z","git_url":"git://github.com/openzfs/openzfs.git","ssh_url":"git@github.com:openzfs/openzfs.git","clone_url":"https://github.com/openzfs/openzfs.git","svn_url":"https://github.com/openzfs/openzfs","homepage":"http://open-zfs.org","size":284592,"stargazers_count":172,"watchers_count":172,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":63,"mirror_url":null,"archived":false,"open_issues_count":39,"license":null,"forks":63,"open_issues":39,"watchers":172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/482"},"html":{"href":"https://github.com/openzfs/openzfs/pull/482"},"issue":{"href":"https://api.github.com/repos/openzfs/openzfs/issues/482"},"comments":{"href":"https://api.github.com/repos/openzfs/openzfs/issues/482/comments"},"review_comments":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/482/comments"},"review_comment":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openzfs/openzfs/pulls/482/commits"},"statuses":{"href":"https://api.github.com/repos/openzfs/openzfs/statuses/ab76136f115730cc18702f8e7655ed23d1f8231b"}},"author_association":"NONE"}}
{"actor":{"display_login":"dweeezil"}}