Skip to content

librbd: fix don't send get_stripe_unit_count if striping is not enabled#17660

Merged
dillaman merged 1 commit intoceph:masterfrom
gmayyyha:striping-feature-21360
Oct 3, 2017
Merged

librbd: fix don't send get_stripe_unit_count if striping is not enabled#17660
dillaman merged 1 commit intoceph:masterfrom
gmayyyha:striping-feature-21360

Conversation

@gmayyyha
Copy link
Contributor

@liewegas liewegas added the rbd label Sep 12, 2017
send_close_image(*result);
} else {
send_v2_get_stripe_unit_count();
if ((m_image_ctx->features & RBD_FEATURE_STRIPINGV2) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: what about if (m_image_ctx->features & RBD_FEATURE_STRIPINGV2) like https://github.com/ceph/ceph/blob/master/src/tools/rbd/action/Info.cc#L261.

Otherwise, looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yangdongsheng :) done.

send_close_image(*result);
} else {
send_v2_get_stripe_unit_count();
if (m_image_ctx->features & RBD_FEATURE_STRIPINGV2)
Copy link
Contributor

Choose a reason for hiding this comment

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

@gmayyyha Wait, did you test this patch? Because the features would be applied in refresh step. so the features is not already set at this place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trociny @yangdongsheng fixed. I think calling get_stripe_unit_count should be before init_layout rather than after refresh

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the reason why we can't get striping information after refresh?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okey, after a look at init_layout() it's true.

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from e905029 to b360948 Compare September 14, 2017 02:32
@trociny
Copy link
Contributor

trociny commented Sep 14, 2017

@gmayyyha Agree, get_stripe_unit_count should be called before m_image_ctx->init_layout() (I missed this in my PR). Though I don't like you modified get_immutable_metadata to retrieve features. Note, features is not "immutable" metadata.

send_close_image(*result);
} else {
send_v2_get_stripe_unit_count();
if (m_image_ctx->features & RBD_FEATURE_STRIPINGV2)
Copy link
Contributor

Choose a reason for hiding this comment

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

@gmayyyha I think using test_features() is a bit cleaner.

@yangdongsheng
Copy link
Contributor

yangdongsheng commented Sep 14, 2017

@gmayyyha you can get the features by get_features(), example:
https://github.com/ceph/ceph/blob/master/src/librbd/api/Mirror.cc#L582

But you have to refactor it into get_features_start() and get_features_finish(). I think.

@trociny
Copy link
Contributor

trociny commented Sep 14, 2017

@gmayyyha Also note, you can't just modify an existing cls function to retrieve features, because it will fail when a new client is used with older OSDs.

So, I think you either need to add get_features call before get_stripe_unit_count, or try to move m_image_ctx->init_layout() to be called after refresh (and get_stripe_unit_count) -- at first glance it looks like it should work.

@dillaman what do you think?

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from b360948 to e702a0e Compare September 14, 2017 11:35
@gmayyyha
Copy link
Contributor Author

@yangdongsheng @trociny Thanks for your suggestions. I add get_features call before 'get_stripe_unit_count'. and don't need to refactor get_features(https://github.com/ceph/ceph/blob/master/src/cls/rbd/cls_rbd_client.cc#L176) .

@gmayyyha
Copy link
Contributor Author

retest this please.

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.

It might be nicer to add the get_features cls call to the existing cls_client::get_immutable_metadata call to avoid the second round-trip call to the OSDs. In RefreshRequest, the reason why we have to many steps is only due to backwards compatibility -- which wouldn't be an issue here.

send_close_image(*result);
} else {
send_v2_get_stripe_unit_count();
send_v2_get_features();

Choose a reason for hiding this comment

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

Nit: spacing

lderr(cct) << "failed to retreive features: "
<< cpp_strerror(*result) << dendl;
send_close_image(*result);
} else {

Choose a reason for hiding this comment

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

Nit: just return nullptr if you need to close the image and then eliminate the nested if block

@trociny
Copy link
Contributor

trociny commented Sep 14, 2017

@dillaman Previously I wrote I didn't like the idea to return features in cls_client::get_immutable_metadata because features is "mutable". But if you like it I don't mind and @gmayyyha then sorry, and just make sure you do this in cls client, not server, as it was in your first version.

@dillaman
Copy link

@trociny We can always rename the method in cls_client to something like get_initial_metadata

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from e702a0e to f93e5f1 Compare September 14, 2017 13:48
@gmayyyha
Copy link
Contributor Author

@trociny @dillaman revert to my first version?

@dillaman
Copy link

@gmayyyha I didn't see the first version, so I cannot comment. I would add it to cls_client::get_immutable_metadata and rename the function since it's doing more than retrieving immutable things now.

@trociny
Copy link
Contributor

trociny commented Sep 14, 2017

+1

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from f93e5f1 to 859f699 Compare September 14, 2017 14:27
@gmayyyha
Copy link
Contributor Author

@dillaman when I try to enable RBD_FEATURE_STRIPINGV2. the output is immutable features. need to rename the function ?

[root@ceph14 build]# rbd feature enable disk01 striping
2017-09-14 22:19:14.377140 7f5ec3b1ed40 -1 WARNING: all dangerous and experimental features are enabled.
2017-09-14 22:19:14.378398 7f5ec3b1ed40 -1 WARNING: all dangerous and experimental features are enabled.
2017-09-14 22:19:14.426221 7f5ec3b1ed40 -1 WARNING: all dangerous and experimental features are enabled.
rbd: failed to update image features: 2017-09-14 22:19:14.534979 7f5ec3b1ed40 -1 librbd::Operations: cannot update immutable features
(22) Invalid argument

@dillaman
Copy link

@gmayyyha The RBD_FEATURE_STRIPINGV2 feature is immutable but other features are not. Therefore, the value returned from get_features can change / is not immutable.

@trociny
Copy link
Contributor

trociny commented Sep 15, 2017

@gmayyyha Jason suggested to rename it to get_initial_metadata. Also, when changing send_v2_get_immutable_metadata method name, don't forget to update ascii art state diagram in OpenRequest.h.

@trociny
Copy link
Contributor

trociny commented Sep 15, 2017

Also, if you want this in 2 commits, it is more logical to have in the first commit get_immutable_metadata rename + change to retrieve features, and in the second commit the actual fix (test for feature and skip get_stripe_unit_count if no striping).

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from 0aa2a00 to 3c1ad3d Compare September 15, 2017 07:39
@gmayyyha
Copy link
Contributor Author

@trociny all done.

Copy link
Contributor

@trociny trociny left a comment

Choose a reason for hiding this comment

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

LGTM

// get_object_prefix
::decode(*object_prefix, *it);
// get_features
::decode(*features, *it);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note, get_features returns also incompatible_features. It is not necessary to decode this field here, because it is the last item. On the other hand, if someone later adds yet another get_xyz after get_features he might forget (not know) to decode incompatible_features, so probably it makes sense to decode it (or left a comment). I don't have a strong opinion here though.

Choose a reason for hiding this comment

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

I'd vote for decoding it into a throwaway local variable for clarity

Choose a reason for hiding this comment

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

Still looks like this comment is open

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dillaman decode features for test_features.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gmayyyha We meant that you need to add something like this:

uint64_t incompatible_features;
::decode(incompatible_features, *it);

See "get_size" case above where we decode size in a throwaway local variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trociny Ah... Sorry, I misunderstand. fixed.

int get_immutable_metadata_finish(bufferlist::iterator *it,
void get_initial_metadata_start(librados::ObjectReadOperation *op);
int get_initial_metadata_finish(bufferlist::iterator *it,
std::string *object_prefix,

Choose a reason for hiding this comment

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

Nit: adjust spacing to match alignment

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from 3c1ad3d to 10dd165 Compare September 16, 2017 04:52
@gmayyyha
Copy link
Contributor Author

gmayyyha commented Sep 18, 2017

retest this please

@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from 10dd165 to 2ca15b9 Compare September 18, 2017 02:18
@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from 2ca15b9 to 0d0d01f Compare September 25, 2017 07:07
@gmayyyha gmayyyha force-pushed the striping-feature-21360 branch from 0d0d01f to 3995fe2 Compare September 25, 2017 08:24
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.

lgtm

trociny pushed a commit to trociny/ceph that referenced this pull request Sep 28, 2017
…ot enabled by gmayyyha · Pull Request ceph#17660 · ceph/ceph · GitHub

* striping-feature-21360:
  librbd: fix don't send get_stripe_unit_count if striping is not enabled
@dillaman dillaman merged commit 24acc55 into ceph:master Oct 3, 2017
@gmayyyha gmayyyha deleted the striping-feature-21360 branch October 9, 2017 02:01
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.

5 participants