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

libradosstriper: conditional compile #18197

Closed

Conversation

chardan
Copy link
Contributor

@chardan chardan commented Oct 9, 2017

This PR affects the "rados" tool:

  1. enables support for libradosstriper features by default (unchanged from current feature);
  2. adds a new do_cmake.sh and cmake switch called "WITH_LIBRADOSSTRIPER", set to ON by default;
  3. if [2] is enabled, libradosstriper features are enabled in the "rados" tool. If disabled, libradosstriper features are disabled in the "rados" tool.
  4. modifies the RPM spec file to set WITH_LIBRADOSSTRIPER as needed

Please note that this PR is not meant to affect whether libradosstriper itself is built or linked, it is limited to governing the exposed features in the tool.

Fixes: https://tracker.ceph.com/issues/22750

@tchaikov
Copy link
Contributor

@chardan could you offer more context in the commit message, w.r.t. why we shall disable libradosstriper by default?

CMakeLists.txt Outdated
@@ -614,3 +614,6 @@ add_tags(ctags
EXCLUDE_OPTS ${CTAG_EXCLUDES}
EXCLUDES "*.js" "*.css")
add_custom_target(tags DEPENDS ctags)

option(WITH_LIBRADOSSTRIPER "Build with libradosstriper support." OFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this change the current upstream behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes-- looks like I thought the opposite of what we actually want-- fixed.

@@ -104,3 +111,5 @@ if(WITH_RBD)
add_subdirectory(rbd_ggate)
endif()
endif(WITH_RBD)


Copy link
Contributor

Choose a reason for hiding this comment

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

Adding gratuitous whitespace at end of file?

@@ -3661,8 +3925,10 @@ int main(int argc, const char **argv)
opts["target_locator"] = val;
} else if (ceph_argparse_witharg(args, i, &val, "--target-nspace" , (char *)NULL)) {
opts["target_nspace"] = val;
#ifdef USE_LIBRADSSTRIPER
Copy link
Contributor

Choose a reason for hiding this comment

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

typo? Should it be #ifdef WITH_LIBRADOSSTRIPER here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thank you!

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch from 866f42c to 91b70da Compare October 10, 2017 17:47
@chardan
Copy link
Contributor Author

chardan commented Oct 10, 2017

@smithfarm Thanks for your comments! Updated.
@tchaikov Notes updated (and reflect the correct behavior now). Thanks!

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch 2 times, most recently from 323c860 to cb83566 Compare October 10, 2017 17:52
@chardan
Copy link
Contributor Author

chardan commented Oct 10, 2017

I'll point out a little implementation oddity, which is that there are some nested conditionals. This is technically redundant, but I'm ok leaving them there unless there are objections. (This is an ugly thing to do, I'm ok with it having an ugly, attention-getting implementation. Another, neater way to go about this is with the detail idiom, but I'd rather give all of the code TLC if we go that route.)

@@ -2405,11 +2653,17 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
string oid(nargs[1]);
map<std::string, bufferlist> attrset;
bufferlist bl;

Copy link
Contributor

Choose a reason for hiding this comment

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

@chardan i'd suggest use following pattern to avoid repeating.

#ifdef WITH_LIBRADOSSTRIPER
if (use_striper) {
  ret = striper.getxattrs(oid, attrset);
} else 
#endif
{
  ret = io_ctx.getxattrs(oid, attrset);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered that, but it risks introducing subtly different behavior in that the current implementation has both the presence of a striper object /and/ a runtime flag. That said, the flag will always be set to true if creating the striper succeeds. I'd rather see all the plumbing in here get reworked...

@@ -373,6 +428,69 @@ static int do_copy_pool(Rados& rados, const char *src_pool, const char *target_p
return 0;
}

#ifndef USE_LIBIRADOSSTRIPER
Copy link
Contributor

Choose a reason for hiding this comment

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

where is USE_LIBIRADOSSTRIPER defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not, that's at typo. Good catch, thank you!

@@ -9,6 +9,11 @@ add_executable(rados ${rados_srcs})
target_link_libraries(rados librados global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} radosstriper)
install(TARGETS rados DESTINATION bin)

if(WITH_LIBRADOSSTRIPER)
Copy link
Contributor

@tchaikov tchaikov Oct 10, 2017

Choose a reason for hiding this comment

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

could you avoid adding options to the command line, but instead define this in src/include/config-h.in.cmake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not completely clear on how cmakedefine works. If I opt for that, are all of those variables still things that can be changed from the command-line/do_cmake?

Copy link
Contributor Author

@chardan chardan Oct 10, 2017

Choose a reason for hiding this comment

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

(I will RTFM in the meantime.) It /looks/ like this isn't quite what we want. That lets you change the behavior by editing that file, but we want to be able to do it from the command-line via do_cmake.
@smithfarm Is that right? Would it be equally satisfactory to make this something we change in config-h.in.cmake?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tchaikov The idea was that we could control striper on/off from a %bcond switch in the spec file.

Copy link
Contributor

@tchaikov tchaikov Oct 11, 2017

Choose a reason for hiding this comment

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

@chardan git grep -w WITH_BLKIN for an example.

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch 4 times, most recently from 4b30d24 to 121ec3c Compare October 16, 2017 20:29
@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch 2 times, most recently from 880788a to 9aa4e32 Compare October 17, 2017 23:00
@chardan
Copy link
Contributor Author

chardan commented Oct 19, 2017

@smithfarm / @tchaikov Okay, I think this should work! Please have a look.

@liewegas liewegas changed the title jfw-wip-libradosstriper_conditional_compile libradosstriper: conditional compile Nov 16, 2017
@smithfarm
Copy link
Contributor

@chardan Please rebase?

@smithfarm
Copy link
Contributor

@chardan Also, please change the title of the 3rd commit to something other than ("compile fix"). There are some basic guidelines at https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#title-of-pull-requests-and-title-of-commits

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch from 9aa4e32 to 32e56d7 Compare January 10, 2018 19:54
@chardan
Copy link
Contributor Author

chardan commented Jan 22, 2018

Jenkins retest this please.

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch from 32e56d7 to 5c00321 Compare January 22, 2018 09:32
@@ -389,6 +389,13 @@ if(WITH_DPDK)
endif()
endif()

option(WITH_LIBRADOSSTRIPER "Build with libradosstriper support." ON)
if(WITH_LIBRADOSSTRIPER)
message(STATUS "Enabling libradosstriper in \"rados\" tool.")
Copy link
Contributor

Choose a reason for hiding this comment

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

@chardan Could you add "support" after "libradosstriper" in this 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.

I sure can!

Copy link
Member

Choose a reason for hiding this comment

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

This doesn’t appear to have happened.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, now I see :-) @chardan Please add the word "support" as requested above

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the threading display on my review is a bit weird.

I’m indifferent to the wording but noticed it was discussed and not done. :)

@@ -336,4 +335,7 @@
/* Defined if boost::context is available */
#cmakedefine HAVE_BOOST_CONTEXT

/* Define if libradosstriper is enabled: */
Copy link
Contributor

Choose a reason for hiding this comment

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

@chardan change "Define" to "Defined" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The style in the file isn't entirely consistent-- but I'll go with "defined".

Copy link
Member

Choose a reason for hiding this comment

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

This doesn’t appear to have happened.

@@ -302,11 +350,17 @@ static int do_get(IoCtx& io_ctx, RadosStriper& striper,
int ret;
while (true) {
bufferlist outdata;

#ifndef WITH_LIBRADOSSTRIPER
ret = io_ctx.read(oid, outdata, op_size, offset);
Copy link
Contributor

Choose a reason for hiding this comment

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

@chardan since this is inside the #else // WITH_LIBRADOSSTRIPER, the #ifndef WITH_LIBRADOSSTRIPER will never be true and the preprocessor will always remove it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, please refer to my note:
#18197 (comment)

I can remove them if you feel strongly about it (I agree it is gnarly and potentially confusing).

Copy link
Member

Choose a reason for hiding this comment

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

I don’t understand this even after reading that note. This is a separate striper-aware compilation path; why would we add an implementation that doesn’t contain the striper?

@smithfarm
Copy link
Contributor

removed my testing label because this cannot be tested at the same time as #19122

@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch 3 times, most recently from f512cb9 to 9281cfb Compare January 30, 2018 13:31
smithfarm
smithfarm previously approved these changes Feb 2, 2018
@chardan
Copy link
Contributor Author

chardan commented Feb 5, 2018

@tchaikov How is this looking to you?

Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@chardan chardan force-pushed the jfw-wip-libradosstriper-conditional-compile branch 3 times, most recently from 016252c to 6b2aaef Compare February 5, 2018 12:01
Jesse Williamson and others added 3 commits February 5, 2018 04:01
… features

Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
Enable downstreams (such as SLE) to not ship libradosstriper.

Fixes: https://tracker.ceph.com/issues/22750
Signed-off-by: Nathan Cutler <ncutler@suse.com>
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@chardan
Copy link
Contributor Author

chardan commented Feb 6, 2018

Jenkins retest this please.

@smithfarm
Copy link
Contributor

@gregsfortytwo This has passed a rados suite (with one failure - see the previous comment). Can you review?

Copy link
Member

@gregsfortytwo gregsfortytwo left a comment

Choose a reason for hiding this comment

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

So, I guess this works. But I note two problems:

  1. it appears that users who attempt to invoke the striper when it has been disabled do not get an error message (because it still parses the flag), but merely a silent different behavior.
  2. we’ve duplicated all our IO function implementations. We’re going to get bugs as they diverge.

To avoid that, I’d suggest doing something like what we do with tcmalloc functionality. Add in a stub striper interface implementation that errors out whenever invoked, and if the striper is compiled out we construct one of those stub failure objects instead. Then in rados.cc we can (depending on implementation choices) either rely on that stub to inform the user they’ve messed up, or else bail out when they specify the striper and actually throw an assertion failure in the stub,

@@ -302,11 +350,17 @@ static int do_get(IoCtx& io_ctx, RadosStriper& striper,
int ret;
while (true) {
bufferlist outdata;

#ifndef WITH_LIBRADOSSTRIPER
ret = io_ctx.read(oid, outdata, op_size, offset);
Copy link
Member

Choose a reason for hiding this comment

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

I don’t understand this even after reading that note. This is a separate striper-aware compilation path; why would we add an implementation that doesn’t contain the striper?

@@ -389,6 +389,13 @@ if(WITH_DPDK)
endif()
endif()

option(WITH_LIBRADOSSTRIPER "Build with libradosstriper support." ON)
if(WITH_LIBRADOSSTRIPER)
message(STATUS "Enabling libradosstriper in \"rados\" tool.")
Copy link
Member

Choose a reason for hiding this comment

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

This doesn’t appear to have happened.

@@ -336,4 +335,7 @@
/* Defined if boost::context is available */
#cmakedefine HAVE_BOOST_CONTEXT

/* Define if libradosstriper is enabled: */
Copy link
Member

Choose a reason for hiding this comment

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

This doesn’t appear to have happened.

@smithfarm
Copy link
Contributor

smithfarm commented Mar 3, 2018

@gregsfortytwo Regarding the status message in CMakeLists.txt, what do you mean by "This doesn't appear to have happened"? I see the status message in the build log:

-- Enabling libradosstriper in "rados" tool.

@smithfarm smithfarm dismissed their stale review March 3, 2018 06:32

in light of Greg's review

@chardan
Copy link
Contributor Author

chardan commented Mar 3, 2018

Hi Greg, thanks for the useful feedback! I entirely agree that a stub implementation would be much tidier-- that's what I was suggesting in my note with "detail" implementations. I'm happy to do that, and while I'm at it have a look at some of the surrounding code. In any case, there's now officially enough confusion from the direction taken that it seems best to change it-- I'll look into this further next week. Thanks!

@chardan
Copy link
Contributor Author

chardan commented May 14, 2018

Let's try this again.
#21983

@chardan chardan closed this May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants