erasure-code: refactor jerasure Liberation parameters checks

Create a virtual function to check for each parameter for Liberation
and its derivations Liber8tion and BlaumRoth. The code is moved around
but is unmodified.

A function reseting the parameters to sane defaults when an error
occurs is introduced. It is slightly different from the code that was
duplicated in Liberation and BlaumRoth. In both cases it now resets w.
It is a noop for Liber8tion because the user cannot modify this
parameter which is always set to the default.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
erasure-code: fix BlaumRoth sanity check on w

For the BlaumRoth technique, w+1 must be a prime. This sanity check is
present in the sample code from the jerasure library but was not
implemented in the jerasure plugin.

The default value for w is also changed to match this constraint. The
unit tests is changed to always use the default w instead of forcing it
to w.

http://tracker.ceph.com/issues/6754 Fixes: #6754

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Change CrushWrapper::crush to private

Currently in CrushWrapper, the member "struct crush_map *crush"  is a public member,
so people can break the encapsulation and manipulate directly to the crush structure.

This is not a good practice for encapsulation and will lead to inconsistent if code
mix use the CrushWrapper API and crush C API.A simple example could be:
1.some code use crush_add_rule(C-API) to add a rule, which will not set the have_rmap flag to false in CrushWrapper
2.another code using CrushWrapper trying to look up the newly added rule by name will get a -ENOENT.

This patch move CrushWrapper::crush to private, together with three reverse map(type_rmap, name_rmap, rule_name_rmap)
and also change codes accessing the CrushWrapper::crush to make it compile.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
erasure-code: mon, osd etc. depend on the plugins

Since the erasure code plugin version check has been introduced,
whenever a library/binary that can load plugin needs to be recompiled,
the erasure code plugins must also be considered. If the reason for
recompiling the library/binary is a new commit, the plugins will fail to
load.

The dependency is not based on source compilation and a shared library
dependency on liberasure-code.la is added instead. This library is
uniformly used whenever a plugin is to be loaded and therefore covers
all library/binaries that need it.

http://tracker.ceph.com/issues/9413 Fixes: #9413

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
erasure-code: fix erasure_code_benchmark goop

Using a stringstream that is only displayed on error when calling the
erasure code factory, instead of cerr. The user expects the output to be
clean when there is no error.

http://tracker.ceph.com/issues/9429 Fixes: #9429

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Merge pull request #2450 from dachary/wip-9413-erasure-code-version-check

erasure-code: mon, osd etc. depend on the plugins
Merge pull request #2416 from xiaoxichen/make_crush_private

Change CrushWrapper::crush to private

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #2464 from dachary/wip-9429-bench

erasure-code: fix erasure_code_benchmark goop

Reviewed-by: Janne Grunau <j@jannau.net>
daemons: write pid file even when told not to daemonize

systemd wants to run daemons in foreground, but daemons wouldn't write
out the pid file with -f.  Fixed.

Signed-off-by: Alexandre Oliva <oliva@gnu.org>
Merge pull request #2468 from dachary/wip-always-create-pidfile

daemons: write pid file even when told not to daemonize

Reviewed-by: Loic Dachary <loic-201408@dachary.org>
Reviewed-by: Sage Weil <sage@redhat.com>
buffer: In rebuild_page_aligned for the last ptr is page aligned, no need call rebuild().

This only happen for the last ptr. Because rebuild() don't change the len
of ptr, so if last ptr isn't page-size aligned but is page aligned, the
rebuild() don't change anything.

Signed-off-by: Ma Jianpeng <jianpeng.ma@intel.com>
buffer: Add a test for bufferlist::rebuild_page_aligned

Make the last prt of bufferlist which is page-aligned don't change anything
after rebuild_page_aligned.

Signed-off-by: Ma Jianpeng <jianpeng.ma@intel.com>
mon: fix MDS health detail output

I fat fingered a couple of things here.

Signed-off-by: John Spray <john.spray@redhat.com>
erasure-code: fix erasure_code_benchmark goop (decode)

Using a stringstream that is only displayed on error when calling the
erasure code factory, instead of cerr. The user expects the output to be
clean when there is no error. That was done for the encode function but
not the decode function.

http://tracker.ceph.com/issues/9429 Fixes: #9429

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Merge pull request #2471 from ceph/wip-9446

mon: fix MDS health detail output

Reviewed-by: Sage Weil <sage@redhat.com>
mds: update segment references during journal rewrite

... to avoid leaving log events that reference log
segments by offsets which no longer exist.

Signed-off-by: John Spray <john.spray@redhat.com>
log: add Log::is_inside_log_lock()

Signed-off-by: Sage Weil <sage@redhat.com>
global/signal_handler: do not log if SEGV originated inside log code

Signed-off-by: Sage Weil <sage@redhat.com>
client: fix a message leak

Signed-off-by: John Spray <john.spray@redhat.com>
log: add simple test to verify an internal SEGV doesn't hang

Test that the segv injection works.

Test that a segv while logging something doesn't hang when the signal
handlers are installed.  Note that this fails/hangs without the previous
fix.

Signed-off-by: Sage Weil <sage@redhat.com>