mon: check cluster features before rule create-erasure

Encapsulate the logic used when creating an erasure coded pool into the
check_cluster_features helper.

check_cluster_features(CEPH_FEATURE_CRUSH_V2) is required for crush rule
create-erasure because it is expected that the erasure code plugin will
use indep instead of firstn and expect the V2 behavior and not the
legacy behavior.

The CEPH_FEATURE_CRUSH_V2 is added to CEPH_FEATURE_OSD_ERASURE_CODES
when an erasure coded pool is created. It is necessary because pool
won't function properly if given an indep ruleset that does not
implement the V2 behavior.

Signed-off-by: Loic Dachary <loic@dachary.org>
Merge pull request #1180 from dachary/wip-7313

mon: check cluster features before rule create-erasure

Reviewed-by: Sage Weil <sage@inktank.com>
erasure-code: benchmark moves to a dedicated directory

Signed-off-by: Loic Dachary <loic@dachary.org>
mds: avoid sending duplicated discovers during recovery

If MDS just entered the rejoin state, it should not kick discovers
because the discovers were just sent. Similarly, if MDS just entered
the clientreplay state, it should not call MDS::handle_mds_recovery()
because MDS::recovery_done() has already recovered the table server.

Also make MDCache::handle_mds_recovery() not wake the discover waiters
up. Because the MDCache::kick_discovers re-sends the discovers, their
replies will wake the discover waiter up.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
erasure-code: add ceph_erasure_code debug command

It loads a designated erasure-code plugin and calls its
methods. It is convenient to figure out and tune the number of data
chunks, the size of an aligned chunk etc. For instance:

ceph_erasure_code \
      --parameter erasure-code-plugin=jerasure \
      --parameter erasure-code-directory=.libs \
      --parameter erasure-code-technique=reed_sol_van \
      --parameter erasure-code-k=2 \
      --parameter erasure-code-m=2 \
      --all

displays the chunk size when encoding an object of 1024 bytes.

get_chunk_size(1024)	512
get_data_chunk_count	2
get_chunk_count	4

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: OSDMonitor: Refuse to delete CephFS pools

To avoid confusing CephFS, don't permit deletion
of pools which are in use as the metadata pool
or any of the data pools.

Signed-off-by: John Spray <john.spray@inktank.com>
mon: MDSMonitor: Forbid removal of first data pool

Because inodes from other pools now store their backtrace
on the first/default data pool, it is special and may not
be removed.

Fixes: 7109

Signed-off-by: John Spray <john.spray@inktank.com>
Merge pull request #1177 from dachary/wip-erasure-code-command

erasure code command

Reviewed-By: Christophe Courtaut <christophe.courtaut@gmail.com>
Merge pull request #1182 from ceph/wip-mds-cluster

mds: avoid sending duplicated discovers during recovery

Reviewed-by: Sage Weil <sage@inktank.com>
common: simpler erasure code technique

Change the default technique from Cauchy to ReedSolomon. Although it is
less efficient the alignment constraints are more intuitive.

Signed-off-by: Loic Dachary <loic@dachary.org>
os/kvstore: trivial portability fixes

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
os/kvstore: remove used var

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
osd: fix type mismatch warning

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Merge pull request #1187 from ceph/port/fixes

portability fixes

Reviewed-by: Sage Weil <sage@inktank.com>
mon: add erasure-code pg_pool_t::stripe_width

Contains the actual stripe size used by erasure coded pools. It is
initialized to zero by default and has to be explicitly set by erasure
coded pools. get/set methods are added inline.

Signed-off-by: Loic Dachary <loic@dachary.org>
unittests: update osdmaptools with stripe_width

stripe_width 0 now shows on every osd dump.

Signed-off-by: Loic Dachary <loic@dachary.org>
common: add osd_pool_erasure_code_stripe_width

and document it.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: osd pool create sets pg_pool_t::stripe_width

It does nothing if the pool is replicated. Otherwise it uses
osd_pool_erasure_code_stripe_width as the desired stripe width and run
it by get_chunk_size() on the erasure code plugin to get the actual
stripe_width. It will always be >= 0 to the desired stripe_width, padded
to match the alignment constraints imposed by the erasure code plugin.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: test osd pool create pg_pool_t::stripe_width behavior

* Check that the default from the configuration options is found in the
  output of osd dump
* Check that specifying an undersized osd_pool_erasure_code_stripe_width
  value is taken into account and padded.

Signed-off-by: Loic Dachary <loic@dachary.org>
rgw: initialize variable before call

Need to initialize the truncated variable, as we sometimes ignore error
response (e.g., with ENOENT), and in such cases we can't expect it to be
set.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>