Skip to content
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

Merged
merged 1 commit into from
Jun 4, 2018

Conversation

MahatiC
Copy link
Contributor

@MahatiC MahatiC commented Apr 4, 2018

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

@batrick
Copy link
Member

batrick commented Apr 4, 2018

retest this please

1 similar comment
@MahatiC
Copy link
Contributor Author

MahatiC commented Apr 5, 2018

retest this please

@MahatiC
Copy link
Contributor Author

MahatiC commented Apr 6, 2018

retest this please
hmm, make check shows failure in run-cli-tests. But that test passes in my env though.

@tchaikov
Copy link
Contributor

tchaikov commented Apr 7, 2018

retest this please

@@ -1624,6 +1624,7 @@
usage: rbd trash purge [--pool <pool>] [--no-progress]
[--expired-before <expired-before>]
[--threshold <threshold>]
[--data-pool <data-pool>]
Copy link
Contributor

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.

@MahatiC MahatiC force-pushed the wip-rbd-datapool branch 2 times, most recently from 2b93a77 to 9c48700 Compare April 9, 2018 10:17
Copy link

@dillaman dillaman left a 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.

@MahatiC
Copy link
Contributor Author

MahatiC commented Apr 10, 2018

@dillaman ack. I wasn't alerted with Ceph tracker comment.

@MahatiC
Copy link
Contributor Author

MahatiC commented Apr 19, 2018

@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
image1, image2, image3

datapool1 has {image1, otherimage1}
datapool2 has {image2, otherimage2, otherimage3}

rbd trash mv rbdpool/image1
rbd trash mv rbdpool/image2

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.

@dillaman
Copy link

@MahatiC

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:

Yup -- the pool where the image headers are stored.

do you mean purge trashed images in rbdpool until datapool1 & datapool2 both have used % of 2?

Yes

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.

Remove images associated w/ datapool1 / datapool2 as necessary from "rbdpool" until you hit the threshold.

@MahatiC MahatiC force-pushed the wip-rbd-datapool branch 4 times, most recently from 1b3da49 to 6be4f7f Compare April 26, 2018 16:31
@MahatiC
Copy link
Contributor Author

MahatiC commented Apr 27, 2018

@dillaman review please

@dillaman dillaman changed the title rbd trash: add data pool support rbd: add data pool support to trash purge May 2, 2018
data_pool = "<missing data pool " + stringify(data_pool_id) + ">";
} else {
data_pool = data_io_ctx.get_pool_name();
datapools[data_pool];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary

(pool_percent_used - threshold));

librbd::Image curr_img;
std::string data_pool;
Copy link

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

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) + ">";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary

}
}
}
datapools[pool_name];
Copy link

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}, {}})

}
}
datapools[pool_name];
uint64_t bytes_to_free;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: initialize your variable

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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: auto img = ...


if(arr[i].get_obj()["name"] == pool_name){
librbd::Image curr_img;
for (const auto& entry : trash_entries) {
Copy link

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.

@MahatiC
Copy link
Contributor Author

MahatiC commented May 9, 2018

@dillaman Thanks, updated.

@tchaikov tchaikov dismissed their stale review May 9, 2018 10:23

since it compiles now

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());

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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);

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````

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

data_pool = data_io_ctx.get_pool_name();
datapools[data_pool].push_back(entry.id.c_str());
}
else {

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

datapools[data_pool].push_back(entry.id.c_str());
}
else {
datapools[pool_name].push_back(entry.id.c_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indentation

Copy link
Contributor Author

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>
Copy link

@dillaman dillaman left a 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?

@dillaman dillaman merged commit 1ae9dca into ceph:master Jun 4, 2018
@MahatiC MahatiC deleted the wip-rbd-datapool branch June 5, 2018 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants