{"action":"created","comment":{"url":"https://api.github.com/repos/ceph/ceph/pulls/comments/113030418","pull_request_review_id":34389265,"id":113030418,"diff_hunk":"@@ -0,0 +1,391 @@\n+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-\n+// vim: ts=8 sw=2 smarttab\n+\n+#include \"rgw_rados.h\"\n+#include \"rgw_reshard.h\"\n+#include \"cls/rgw/cls_rgw_client.h\"\n+#include \"cls/lock/cls_lock_client.h\"\n+#include \"common/errno.h\"\n+\n+#define dout_context g_ceph_context\n+#define dout_subsys ceph_subsys_rgw\n+\n+const string reshard_oid = \"reshard\";\n+const string reshard_lock_name = \"reshard_process\";\n+const string bucket_instance_lock_name = \"bucket_instance_lock\";\n+\n+RGWReshard::RGWReshard(CephContext *_cct, RGWRados* _store):cct(_cct), store(_store),\n+\t\t\t\t\t\t\t    instance_lock(bucket_instance_lock_name)\n+{\n+    max_jobs = cct->_conf->rgw_reshard_max_jobs;\n+}\n+\n+int RGWReshard::get_io_ctx(librados::IoCtx& io_ctx)\n+{\n+  string reshard_pool = store->get_zone_params().reshard_pool.name;\n+  librados::Rados *rad = store->get_rados_handle();\n+  int r = rad->ioctx_create(reshard_pool.c_str(), io_ctx);\n+  if (r == -ENOENT) {\n+    r = store->create_pool(store->get_zone_params().reshard_pool);\n+    if (r < 0)\n+      return r;\n+\n+    // retry\n+    r = rad->ioctx_create(reshard_pool.c_str(), io_ctx);\n+  }\n+  if (r < 0)\n+    return r;\n+\n+  return 0;\n+}\n+\n+int RGWReshard::add(cls_rgw_reshard_entry& entry)\n+{\n+  rados::cls::lock::Lock l(reshard_lock_name);\n+  librados::IoCtx io_ctx;\n+\n+  int ret = get_io_ctx(io_ctx);\n+  if (ret < 0)\n+    return ret;\n+\n+  ret = l.lock_exclusive(&io_ctx, reshard_oid);\n+  if (ret == -EBUSY) {\n+    dout(0) << \"RGWReshard::add failed to acquire lock on \" << reshard_oid << dendl;\n+    return 0;\n+  }\n+  if (ret < 0)\n+    return ret;\n+\n+  librados::ObjectWriteOperation op;\n+  cls_rgw_reshard_add(op, entry);\n+\n+  ret = io_ctx.operate(reshard_oid, &op);\n+\n+  l.unlock(&io_ctx, reshard_oid);\n+  return ret;\n+}\n+\n+\n+int RGWReshard::list(string& marker, uint32_t max, std::list<cls_rgw_reshard_entry>& entries, bool& is_truncated)\n+{\n+  rados::cls::lock::Lock l(reshard_lock_name);\n+  librados::IoCtx io_ctx;\n+\n+  int ret = get_io_ctx(io_ctx);\n+  if (ret < 0)\n+    return ret;\n+\n+  ret = l.lock_shared(&io_ctx, reshard_oid);","path":"src/rgw/rgw_reshard.cc","position":78,"original_position":78,"commit_id":"fbea5efc865311226d8fe1f9ac3dd6b288e43aa2","original_commit_id":"fbea5efc865311226d8fe1f9ac3dd6b288e43aa2","user":{"login":"yehudasa","id":1036377,"avatar_url":"https://avatars3.githubusercontent.com/u/1036377?v=3","gravatar_id":"","url":"https://api.github.com/users/yehudasa","html_url":"https://github.com/yehudasa","followers_url":"https://api.github.com/users/yehudasa/followers","following_url":"https://api.github.com/users/yehudasa/following{/other_user}","gists_url":"https://api.github.com/users/yehudasa/gists{/gist_id}","starred_url":"https://api.github.com/users/yehudasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yehudasa/subscriptions","organizations_url":"https://api.github.com/users/yehudasa/orgs","repos_url":"https://api.github.com/users/yehudasa/repos","events_url":"https://api.github.com/users/yehudasa/events{/privacy}","received_events_url":"https://api.github.com/users/yehudasa/received_events","type":"User","site_admin":false},"body":"@oritwas why lock shared here?","created_at":"2017-04-24T19:04:43Z","updated_at":"2017-04-24T19:04:43Z","html_url":"https://github.com/ceph/ceph/pull/14618#discussion_r113030418","pull_request_url":"https://api.github.com/repos/ceph/ceph/pulls/14618","_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments/113030418"},"html":{"href":"https://github.com/ceph/ceph/pull/14618#discussion_r113030418"},"pull_request":{"href":"https://api.github.com/repos/ceph/ceph/pulls/14618"}}},"pull_request":{"url":"https://api.github.com/repos/ceph/ceph/pulls/14618","id":116365053,"html_url":"https://github.com/ceph/ceph/pull/14618","diff_url":"https://github.com/ceph/ceph/pull/14618.diff","patch_url":"https://github.com/ceph/ceph/pull/14618.patch","issue_url":"https://api.github.com/repos/ceph/ceph/issues/14618","number":14618,"state":"open","locked":false,"title":"DNM: Wip rgw dynamic resharding","user":{"login":"oritwas","id":2041071,"avatar_url":"https://avatars3.githubusercontent.com/u/2041071?v=3","gravatar_id":"","url":"https://api.github.com/users/oritwas","html_url":"https://github.com/oritwas","followers_url":"https://api.github.com/users/oritwas/followers","following_url":"https://api.github.com/users/oritwas/following{/other_user}","gists_url":"https://api.github.com/users/oritwas/gists{/gist_id}","starred_url":"https://api.github.com/users/oritwas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oritwas/subscriptions","organizations_url":"https://api.github.com/users/oritwas/orgs","repos_url":"https://api.github.com/users/oritwas/repos","events_url":"https://api.github.com/users/oritwas/events{/privacy}","received_events_url":"https://api.github.com/users/oritwas/received_events","type":"User","site_admin":false},"body":"work in progress:\r\n- need to remove all get_object_instance unneeded stuff\r\n- thread that schedules resharding\r\n- lots testing","created_at":"2017-04-18T16:11:51Z","updated_at":"2017-04-24T19:04:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f1d8994792688b229d351af6a4a81626dfabbc7","assignee":{"login":"yehudasa","id":1036377,"avatar_url":"https://avatars3.githubusercontent.com/u/1036377?v=3","gravatar_id":"","url":"https://api.github.com/users/yehudasa","html_url":"https://github.com/yehudasa","followers_url":"https://api.github.com/users/yehudasa/followers","following_url":"https://api.github.com/users/yehudasa/following{/other_user}","gists_url":"https://api.github.com/users/yehudasa/gists{/gist_id}","starred_url":"https://api.github.com/users/yehudasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yehudasa/subscriptions","organizations_url":"https://api.github.com/users/yehudasa/orgs","repos_url":"https://api.github.com/users/yehudasa/repos","events_url":"https://api.github.com/users/yehudasa/events{/privacy}","received_events_url":"https://api.github.com/users/yehudasa/received_events","type":"User","site_admin":false},"assignees":[{"login":"yehudasa","id":1036377,"avatar_url":"https://avatars3.githubusercontent.com/u/1036377?v=3","gravatar_id":"","url":"https://api.github.com/users/yehudasa","html_url":"https://github.com/yehudasa","followers_url":"https://api.github.com/users/yehudasa/followers","following_url":"https://api.github.com/users/yehudasa/following{/other_user}","gists_url":"https://api.github.com/users/yehudasa/gists{/gist_id}","starred_url":"https://api.github.com/users/yehudasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yehudasa/subscriptions","organizations_url":"https://api.github.com/users/yehudasa/orgs","repos_url":"https://api.github.com/users/yehudasa/repos","events_url":"https://api.github.com/users/yehudasa/events{/privacy}","received_events_url":"https://api.github.com/users/yehudasa/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ceph/ceph/pulls/14618/commits","review_comments_url":"https://api.github.com/repos/ceph/ceph/pulls/14618/comments","review_comment_url":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ceph/ceph/issues/14618/comments","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/fbea5efc865311226d8fe1f9ac3dd6b288e43aa2","head":{"label":"oritwas:wip-rgw-dynamic-sharding","ref":"wip-rgw-dynamic-sharding","sha":"fbea5efc865311226d8fe1f9ac3dd6b288e43aa2","user":{"login":"oritwas","id":2041071,"avatar_url":"https://avatars3.githubusercontent.com/u/2041071?v=3","gravatar_id":"","url":"https://api.github.com/users/oritwas","html_url":"https://github.com/oritwas","followers_url":"https://api.github.com/users/oritwas/followers","following_url":"https://api.github.com/users/oritwas/following{/other_user}","gists_url":"https://api.github.com/users/oritwas/gists{/gist_id}","starred_url":"https://api.github.com/users/oritwas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oritwas/subscriptions","organizations_url":"https://api.github.com/users/oritwas/orgs","repos_url":"https://api.github.com/users/oritwas/repos","events_url":"https://api.github.com/users/oritwas/events{/privacy}","received_events_url":"https://api.github.com/users/oritwas/received_events","type":"User","site_admin":false},"repo":{"id":32010315,"name":"ceph","full_name":"oritwas/ceph","owner":{"login":"oritwas","id":2041071,"avatar_url":"https://avatars3.githubusercontent.com/u/2041071?v=3","gravatar_id":"","url":"https://api.github.com/users/oritwas","html_url":"https://github.com/oritwas","followers_url":"https://api.github.com/users/oritwas/followers","following_url":"https://api.github.com/users/oritwas/following{/other_user}","gists_url":"https://api.github.com/users/oritwas/gists{/gist_id}","starred_url":"https://api.github.com/users/oritwas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oritwas/subscriptions","organizations_url":"https://api.github.com/users/oritwas/orgs","repos_url":"https://api.github.com/users/oritwas/repos","events_url":"https://api.github.com/users/oritwas/events{/privacy}","received_events_url":"https://api.github.com/users/oritwas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oritwas/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":true,"url":"https://api.github.com/repos/oritwas/ceph","forks_url":"https://api.github.com/repos/oritwas/ceph/forks","keys_url":"https://api.github.com/repos/oritwas/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oritwas/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oritwas/ceph/teams","hooks_url":"https://api.github.com/repos/oritwas/ceph/hooks","issue_events_url":"https://api.github.com/repos/oritwas/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/oritwas/ceph/events","assignees_url":"https://api.github.com/repos/oritwas/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/oritwas/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/oritwas/ceph/tags","blobs_url":"https://api.github.com/repos/oritwas/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oritwas/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oritwas/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/oritwas/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oritwas/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/oritwas/ceph/languages","stargazers_url":"https://api.github.com/repos/oritwas/ceph/stargazers","contributors_url":"https://api.github.com/repos/oritwas/ceph/contributors","subscribers_url":"https://api.github.com/repos/oritwas/ceph/subscribers","subscription_url":"https://api.github.com/repos/oritwas/ceph/subscription","commits_url":"https://api.github.com/repos/oritwas/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/oritwas/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/oritwas/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/oritwas/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/oritwas/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/oritwas/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oritwas/ceph/merges","archive_url":"https://api.github.com/repos/oritwas/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oritwas/ceph/downloads","issues_url":"https://api.github.com/repos/oritwas/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/oritwas/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/oritwas/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/oritwas/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oritwas/ceph/labels{/name}","releases_url":"https://api.github.com/repos/oritwas/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/oritwas/ceph/deployments","created_at":"2015-03-11T09:56:27Z","updated_at":"2016-11-09T11:18:52Z","pushed_at":"2017-04-21T06:07:53Z","git_url":"git://github.com/oritwas/ceph.git","ssh_url":"git@github.com:oritwas/ceph.git","clone_url":"https://github.com/oritwas/ceph.git","svn_url":"https://github.com/oritwas/ceph","homepage":"http://ceph.com","size":212518,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"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":1,"default_branch":"master"}},"base":{"label":"ceph:master","ref":"master","sha":"9264e1c85d675615de68f422d223ae0993e5e61c","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars0.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":2310495,"name":"ceph","full_name":"ceph/ceph","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars0.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":false,"url":"https://api.github.com/repos/ceph/ceph","forks_url":"https://api.github.com/repos/ceph/ceph/forks","keys_url":"https://api.github.com/repos/ceph/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph/teams","hooks_url":"https://api.github.com/repos/ceph/ceph/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph/events","assignees_url":"https://api.github.com/repos/ceph/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph/tags","blobs_url":"https://api.github.com/repos/ceph/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph/subscription","commits_url":"https://api.github.com/repos/ceph/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph/merges","archive_url":"https://api.github.com/repos/ceph/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph/downloads","issues_url":"https://api.github.com/repos/ceph/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/ceph/ceph/deployments","created_at":"2011-09-01T21:41:26Z","updated_at":"2017-04-24T15:15:11Z","pushed_at":"2017-04-24T18:54:55Z","git_url":"git://github.com/ceph/ceph.git","ssh_url":"git@github.com:ceph/ceph.git","clone_url":"https://github.com/ceph/ceph.git","svn_url":"https://github.com/ceph/ceph","homepage":"http://ceph.com","size":205709,"stargazers_count":3135,"watchers_count":3135,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1835,"mirror_url":null,"open_issues_count":484,"forks":1835,"open_issues":484,"watchers":3135,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/14618"},"html":{"href":"https://github.com/ceph/ceph/pull/14618"},"issue":{"href":"https://api.github.com/repos/ceph/ceph/issues/14618"},"comments":{"href":"https://api.github.com/repos/ceph/ceph/issues/14618/comments"},"review_comments":{"href":"https://api.github.com/repos/ceph/ceph/pulls/14618/comments"},"review_comment":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ceph/ceph/pulls/14618/commits"},"statuses":{"href":"https://api.github.com/repos/ceph/ceph/statuses/fbea5efc865311226d8fe1f9ac3dd6b288e43aa2"}}}}
{"actor":{"display_login":"yehudasa"}}