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: support rbd on FreeBSD (without KRBD) #12798

Merged
merged 8 commits into from Jan 16, 2017

Conversation

wjwithagen
Copy link
Contributor

Cmake changes to exclude KRBD and keyutils from building because FreeBSD does not support that.
Code changes to:

  • Stub krbd kernel calls
  • small incompatabilities, missing includes.
  • Fix Clang casts errors

Signed-off-by: Willem Jan Withagen wjw@digiware.nl

@wjwithagen
Copy link
Contributor Author

@tchaikov @liewegas

Hi I'm getting this casting error in Clang that doesn't want to go away, with any of the casting version, other than static_cast.
Depressing is that GNU really doesn't like that, so either we fix the code, or I if-else-endif it.

I hope you have some suggestions.

/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_fixture.h:28:27: error: reinterpret_cast from 'nullptr_t' to 'ContextWQ *' is not allowed
  ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h:523:27: note: in instantiation of function template specialization 'CompleteContextActionP2<int, nullptr_t>::gmock_Impl<void (Context *)>::gmock_PerformImpl<Context *, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg>' requested here
    return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
                          ^

@tchaikov tchaikov self-assigned this Jan 5, 2017
@tchaikov
Copy link
Contributor

tchaikov commented Jan 5, 2017

@wjwithagen i will take a look at it tomorrow.

@wjwithagen
Copy link
Contributor Author

@tchaikov

Probably it is due to NULL usuage on:
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_Journal.cc:268:29

But as usual I'm not able to fix it. nullptr/NULL is not quite my thing.

rbd_types
rbd_replay_types)
if(WITH_KRBD)
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 squash this commit into 6022d01 ?

${CMAKE_DL_LIBS}
${EXTRALIBS})
if(HAVE_UDEV)
Copy link
Contributor

Choose a reason for hiding this comment

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

might want to remove udev from the linked libraries of librbd. as krbd links against it already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
To start it should use the define for that:
./cmake/modules/Findudev.cmake:23:# UDEV_LIBRARIES - List of libraries when using udev.
But I feel uncomfortable removing it, since it was already there, and I try to change as little functionality as possible when adding FreeBSD/Clang specifics.
Old behaviour should be kept as much as possible for all others.

That said, you are right: librbd add udev.
I'll make a separate PR for that, and rebase this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I try to change as little functionality as possible when adding FreeBSD/Clang specifics.

i agree, but behaviorwise, removing libudev here does not change anything.

I'll make a separate PR for that, and rebase this one.

thanks.

endif()
if(HAVE_UDEV)
target_link_libraries(ceph_test_cls_rbd
udev)
Copy link
Contributor

Choose a reason for hiding this comment

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

could just remove blkid and udev from ceph_test_cls_rbd's linked libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
Yup, like above

@@ -233,6 +233,9 @@ option(WITH_KVS "Key value store is here" ON)
# remote block storage
option(WITH_RBD "Remote block storage is here" ON)

# KERNEL remote block storage
option(WITH_KRBD "Kernel Remote block storage is here" ON)
Copy link
Contributor

Choose a reason for hiding this comment

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

should send out a FATAL_ERROR message if WITH_KRBD=ON and WITH_RBD=OFF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
I'll add some diganostics

Copy link
Contributor

@tchaikov tchaikov Jan 6, 2017

Choose a reason for hiding this comment

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

this is not addressed.

@@ -38,6 +38,9 @@
#undef ENODATA
#define ENODATA ENOATTR
#endif
#ifndef EREMOTEIO
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 consolidate this #define with the ones at line:79. so there is only one place that we define EREMOTEIO and HOST_NAME_MAX. also instead of HOST_NAME_MAX , FreeBSD has MAXHOSTNAMELEN. maybe we can define HOST_NAME_MAX like

#ifndef HOST_NAME_MAX
# ifdef MAXHOSTNAMELEN)
#  define HOST_NAME_MAX MAXHOSTNAMELEN
# else
#  define HOST_NAME_MAX 64
# endif
#endif

BTW, 64 is a very conservative number. probably we can make it 255.

@@ -163,6 +163,7 @@ static int parse_unmap_options(char *options)

static int do_kernel_showmapped(Formatter *f)
{
#if defined(__linux__)
Copy link
Contributor

Choose a reason for hiding this comment

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

probably you can just ignore Kernel.cc and Nbd.cc in rbd_srcs in src/tools/rbd/CMakeLists.txt if !WITH_KRBD .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
I'm leaving this in for the moment, because I would like to not change the run-cli tests.
And that expects showmapped map unmap in the help output.
So for met that would make this the most transparent fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense. it's non-trivial to conditionalize the run-cli tests, i guess.

Copy link

Choose a reason for hiding this comment

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

Should it be based on WITH_KRBD?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wjwithagen could you add WITH_KRBD to config-h.in.cmake and conditionalize on it instead?

@@ -25,7 +25,11 @@ ACTION_P(CopyInBufferlist, str) {
}

ACTION_P2(CompleteContext, r, wq) {
#if defined(__clang__)
ContextWQ *context_wq = static_cast<ContextWQ *>(wq);
Copy link
Contributor

Choose a reason for hiding this comment

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

although this is a little bit awkward, but this is the best we can have with minimal change, otherwise we need to change some of the callers of CompleteContext to cast the NULL parameter to the ContextWQ *.

@dillaman what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov @dillaman
I'm not a real fan of this sollution either,
But it is the least invasive, and still very obvious as to why this is done.

Copy link

@dillaman dillaman Jan 6, 2017

Choose a reason for hiding this comment

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

Hmm --- it's pretty ugly so I might vote for just using a C-style cast if Clang doesn't like it.

Copy link

@dillaman dillaman Jan 6, 2017

Choose a reason for hiding this comment

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

... do you have any details on the compile failure? The only way I can see this failing is if somehow wq auto-resolved to nullptr_t, but nothing that I can find is passing in nullptr (unless Clang is somehow substituting nullptr for NULL -- which is wrong since they are not the same)

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 @tchaikov
This is the full output of the build error when I use the original cast:

 Building CXX object src/test/librbd/CMakeFiles/unittest_librbd.dir/test_mock_Journal.cc.o
cd /usr/srcs/Ceph/work/ceph/build/src/test/librbd && ccache /usr/bin/CC   -DCEPH_LIBDIR=\"/usr/local/lib\" -DCEPH_PKGLIBDIR=\"/usr/local/lib/ceph\" -DTEST_LIBRBD_INTERNALS -I/usr/srcs/Ceph/work/ceph/build/src/include -I/usr/srcs/Ceph/work/ceph/src -isystem /usr/local/include -isystem /usr/srcs/Ceph/work/ceph/build/include -I/usr/srcs/Ceph/work/ceph/src/xxHash -I/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include -I/usr/srcs/Ceph/work/ceph/src/googletest/googletest/include  -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char -Wno-unused-function -Wno-unused-local-typedef -Wno-varargs -Wno-gnu-designator -Wno-missing-braces -Wno-parentheses -Wno-deprecated-register  -ftemplate-depth-1024 -Wno-invalid-offsetof -Wnon-virtual-dtor -Wno-inconsistent-missing-override -Wno-mismatched-tags -Wno-unused-private-field -fdiagnostics-color=auto -I/usr/local/include/nss/nss -I/usr/local/include/nspr -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -Wno-null-dereference -O0 -g -fPIE   -DHAVE_CONFIG_H -D__CEPH__ -D_REENTRANT -D_THREAD_SAFE -D__STDC_FORMAT_MACROS -I/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include -I/usr/srcs/Ceph/work/ceph/build/src/googletest/googlemock/include -I/usr/srcs/Ceph/work/ceph/src/googletest/googletest/include -I/usr/srcs/Ceph/work/ceph/build/src/googletest/googletest/include -fno-strict-aliasing -std=c++11 -o CMakeFiles/unittest_librbd.dir/test_mock_Journal.cc.o -c /usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_Journal.cc
In file included from /usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_Journal.cc:4:
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_fixture.h:31:27: error: reinterpret_cast from 'nullptr_t' to 'ContextWQ *' is not allowed
  ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h:523:27: note: in instantiation of function template specialization 'CompleteContextActionP2<int, nullptr_t>::gmock_Impl<void (Context *)>::gmock_PerformImpl<Context *, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg, testing::internal::ExcessiveArg>' requested here
    return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
                          ^
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_fixture.h:27:1: note: in instantiation of function template specialization 'testing::internal::ActionHelper<void, CompleteContextActionP2<int, nullptr_t>::gmock_Impl<void (Context *)> >::Perform<Context *>' requested here
ACTION_P2(CompleteContext, r, wq) {
^
/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h:1420:13: note: expanded from macro 'ACTION_P2'
            Perform(this, args);\
            ^
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_fixture.h:27:1: note: in instantiation of member function 'CompleteContextActionP2<int, nullptr_t>::gmock_Impl<void (Context *)>::Perform' requested here
/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h:1416:7: note: expanded from macro 'ACTION_P2'
      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
      ^
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_fixture.h:27:1: note: in instantiation of member function 'CompleteContextActionP2<int, nullptr_t>::gmock_Impl<void (Context *)>::gmock_Impl' requested here
/usr/srcs/Ceph/work/ceph/src/googletest/googlemock/include/gmock/gmock-generated-actions.h:1436:39: note: expanded from macro 'ACTION_P2'
      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
                                      ^
/usr/srcs/Ceph/work/ceph/src/test/librbd/test_mock_Journal.cc:268:29: note: in instantiation of function template specialization 'CompleteContextActionP2<int, nullptr_t>::operator Action<void (Context *)>' requested here
                  .WillOnce(CompleteContext(0, NULL));
                            ^
1 error generated.

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
Not quite.....
A nicer sollution might be to actually fix the typecaset for NULL:
CompleteContext(r, static_cast<ContextWQ *>(NULL))

That works for both FreeBSD/Clang and linux/GCC.
Need to fix that in about 8 locations.
Could do that in a separate PR and drop this commit from this PR?

Choose a reason for hiding this comment

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

That's fine as well -- long term would still need a Clang compiler in the Jenkins build set to ensure future PRs don't break things

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
And it needs to be running with a environment where NULL is defined to be nullptr !!
Will submit a PR tomorrow. It is past midnight here.

Copy link
Contributor

@tchaikov tchaikov Jan 11, 2017

Choose a reason for hiding this comment

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

yeah, that's also what i suggested in the beginning. as NULL could also be defined as 0 where static_cast<>() does not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov @dillaman
Gentleman,
If you could checkout #12880.
Once that is accepted, I'll rebase this PR to macht it.

@wjwithagen
Copy link
Contributor Author

@tchaikov
Thanx for the review... I'll go over them and fix.

#define HOST_NAME_MAX 255
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

see #12798 (comment), could use MAXHOSTNAMELEN instead hardwire HOST_NAME_MAX to 255.

Copy link
Contributor

Choose a reason for hiding this comment

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

and could move the #endif /* __APPLE__ */ before #ifndef EREMOTEIO and change it to #endif.

@wjwithagen wjwithagen force-pushed the wip-wjw-krbd-optional branch 2 times, most recently from 7861936 to d917dfb Compare January 6, 2017 10:47
@tchaikov
Copy link
Contributor

tchaikov commented Jan 6, 2017

@wjwithagen needs rebase.

@wjwithagen
Copy link
Contributor Author

@tchaikov
Yup, due to the UDEV commit. rebased.
I'm in and out of the datacenter with screwdriver and more, So this needs to go inbetween real work. :)

option(WITH_KRBD "Kernel Remote block storage is here" ON)

if(WITH_KRBD AND !WITH_RBD)
message(FATAL_ERROR "Cannot have WITH_KRBD with 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.

s/with/without/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
Every day something new to learn.... ;-)

@@ -163,6 +163,7 @@ static int parse_unmap_options(char *options)

static int do_kernel_showmapped(Formatter *f)
{
#if defined(__linux__)
Copy link
Contributor

Choose a reason for hiding this comment

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

@wjwithagen could you add WITH_KRBD to config-h.in.cmake and conditionalize on it instead?

@wjwithagen
Copy link
Contributor Author

@tchaikov
I think I addressed your suggestions...

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
 - and combined some FreeBSD defines with Apple's

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
…c_cast is sufficient

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
@wjwithagen
Copy link
Contributor Author

@tchaikov @dillaman
Rebased for the NULL-cast if-def PR.
So this PR is now more or less how it should be as well.

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

@tchaikov tchaikov self-assigned this Jan 12, 2017
@dillaman dillaman changed the title RBD: enable rbd on FreeBSD (without KRBD) rbd: support rbd on FreeBSD (without KRBD) Jan 16, 2017
@dillaman dillaman merged commit 7c55be9 into ceph:master Jan 16, 2017
@wjwithagen wjwithagen deleted the wip-wjw-krbd-optional branch April 28, 2017 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants