-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rbd: add data pool support to trash purge #21247
Conversation
retest this please |
1 similar comment
retest this please |
retest this please |
retest this please |
src/test/cli/rbd/help.t
Outdated
@@ -1624,6 +1624,7 @@ | |||
usage: rbd trash purge [--pool <pool>] [--no-progress] | |||
[--expired-before <expired-before>] | |||
[--threshold <threshold>] | |||
[--data-pool <data-pool>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/rbd/help.t: failed
--- /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/rbd/help.t
+++ /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/rbd/help.t.err
@@ -1626,8 +1626,7 @@
rbd help trash purge
usage: rbd trash purge [--pool <pool>] [--no-progress]
[--expired-before <expired-before>]
- [--threshold <threshold>]
- [--data-pool <data-pool>]
+ [--threshold <threshold>] [--data-pool <data-pool>]
<pool-name>
Remove all expired images from trash.
you might need to move "[--data-pool <data-pool>
" up to the previous line.
2b93a77
to
9c48700
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think it should just be implicit. It could loop through all the trashed images whose deferment end time is in the past and compute a set of (data) pools in-use by the images. For each pool in the set, delete trashed images in that (data) pool until that pool's threshold is met.
@dillaman ack. I wasn't alerted with Ceph tracker comment. |
@dillaman rbd trash purge seems to accept only one pool. And will only have access to trashed images (whose metadata is stored) in that particular pool. For example: rbd ls rbdpool datapool1 has {image1, otherimage1} rbd trash mv rbdpool/image1 On excuting: rbd trash purge rbdpool --threshold '0.02' do you mean purge trashed images in rbdpool until datapool1 & datapool2 both have used % of 2? In the above example datapool1 & datapool2 have images from a pool other than rbdpool. Not sure I understand when you say remove images from data pool. |
Yup -- the pool where the image headers are stored.
Yes
Remove images associated w/ datapool1 / datapool2 as necessary from "rbdpool" until you hit the threshold. |
1b3da49
to
6be4f7f
Compare
@dillaman review please |
src/tools/rbd/action/Trash.cc
Outdated
data_pool = "<missing data pool " + stringify(data_pool_id) + ">"; | ||
} else { | ||
data_pool = data_io_ctx.get_pool_name(); | ||
datapools[data_pool]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: unnecessary
src/tools/rbd/action/Trash.cc
Outdated
(pool_percent_used - threshold)); | ||
|
||
librbd::Image curr_img; | ||
std::string data_pool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: move to tightest scope
src/tools/rbd/action/Trash.cc
Outdated
librados::IoCtx data_io_ctx; | ||
r = rados.ioctx_create2(data_pool_id, data_io_ctx); | ||
if (r < 0) { | ||
data_pool = "<missing data pool " + stringify(data_pool_id) + ">"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: unnecessary
src/tools/rbd/action/Trash.cc
Outdated
} | ||
} | ||
} | ||
datapools[pool_name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: awkward -- might be clearer if you use datapools[pool_name] = {}
or datapools.insert({pool_name}, {}})
src/tools/rbd/action/Trash.cc
Outdated
} | ||
} | ||
datapools[pool_name]; | ||
uint64_t bytes_to_free; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: initialize your variable
src/tools/rbd/action/Trash.cc
Outdated
for(uint8_t i = 0; i < arr.size(); ++i) { | ||
json_spirit::mObject obj = arr[i].get_obj(); | ||
std::string name = obj.find("name")->second.get_str(); | ||
std::map<std::string, std::vector<std::string>>::iterator img = datapools.find(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: auto img = ...
src/tools/rbd/action/Trash.cc
Outdated
|
||
if(arr[i].get_obj()["name"] == pool_name){ | ||
librbd::Image curr_img; | ||
for (const auto& entry : trash_entries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be duplicating the code below. If you added the trash image ids for the base pool to datapools[pool_name]
above, you could then just iterate through the image ids in the datapools[arr[i].get_obj()["name"]]
to compute which images to remove.
@dillaman Thanks, updated. |
src/tools/rbd/action/Trash.cc
Outdated
data_pool = data_io_ctx.get_pool_name(); | ||
datapools[data_pool].push_back(entry.id.c_str()); | ||
} | ||
datapools[pool_name].push_back(entry.id.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought -- I guess my suggestion would double-count an image's space in both its data pool and base pool. Therefore, the disk usage check for determining which images to delete should only be made in the data pool. Therefore, perhaps this should just be the else
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. With your prev suggestion I reasoned that technically all images belong to the base pool anyway and should be fine if we delete (datapool) images from basepool (where datapool's threshold is what is required and basepool is higher). But not double-counting makes it easier to differentiate and the (trash purge) behavior more predictable. Will modify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (data_pool_id != io_ctx.get_id()) { | ||
librados::Rados rados(io_ctx); | ||
librados::IoCtx data_io_ctx; | ||
r = rados.ioctx_create2(data_pool_id, data_io_ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: log error message to std::cerr
and skip image if ```r < 0````
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/tools/rbd/action/Trash.cc
Outdated
data_pool = data_io_ctx.get_pool_name(); | ||
datapools[data_pool].push_back(entry.id.c_str()); | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: } else {
on same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/tools/rbd/action/Trash.cc
Outdated
datapools[data_pool].push_back(entry.id.c_str()); | ||
} | ||
else { | ||
datapools[pool_name].push_back(entry.id.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
checks implicitly for datapool utilization of all images and removes respective pool's trashed images until threshold value is hit. Fixes: http://tracker.ceph.com/issues/22872 Signed-off-by: Mahati Chamarthy <mahati.chamarthy@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MahatiC Can you add "Fixes: http://tracker.ceph.com/issues/22872" to your commit message?
Checks implicitly for datapool utilization of all images and removes
respective pool's trashed images until threshold value is hit.
Fixes: http://tracker.ceph.com/issues/22872
Signed-off-by: Mahati Chamarthy mahati.chamarthy@intel.com