Synchronisation with libcrush

The crush/libcrush directory tracks master from http://github.com/ceph/ceph and should be updated to get the latest changes with:

git clone http://github.com/ceph/ceph /tmp/ceph
git revert 8f07936 # commit with change to make crush standalone
cd crush/libcrush
for file in {common,crush,include}/*.[ch] {common,crush}/*.cc ; do
   cp /tmp/ceph/src/$file $file
git commit -m 'libcrush: sync with Ceph'
git cherry-pick 8f07936
# update the hash above with the new hash
git commit -m 'doc: reference to the last sync with Ceph'

The commit message should then be updated with the hash of the ceph repository from which the files were copied.

Part of the sources it contains are compiled in the crush.libcrush module, as instructed in the [extension-crush.libcrush] section of the setup.cfg file:

The acconfig.h file is created by cmake via the build hooks mentionned in the [build_ext] section of the setup.cfg file:

# populate crush/libcrush with files from libcrush/crush
# as required by sources & libcrush_headers above
pre-hook.build_post_hook = setup._setup_hooks.build_pre_hook
post-hook.build_post_hook = setup._setup_hooks.build_post_hook

max-line-length = 100

The definition of the functions are in the setup/_setup_hooks.py file:

import os

def build_pre_hook(cmdobj):

    os.system(""" set -ex
    rm -fr build/tmp
    mkdir -p build/tmp
    ( cd build/tmp ; cmake ../../crush/libcrush )
    cp build/tmp/acconfig.h crush/libcrush
    rm -fr build/tmp

def build_post_hook(cmdobj):


The libcrush CPython module can be debugged by running tests from test/test_libcrush.py in verbose mode with commands such as:

tox -e py27 -- -vv -s -k test_parse_invalid_type tests/test_libcrush.py

For some reason py3 does not flush stdout and should be avoided. It is quite useful to see the output up to the point where a core dump happens.

Increasing libcrush verbosity

The cursh/libcrush module files must be recompiled to display a verbose output when they show lines like:

#define dprintk(args...) /* printf(args) */

Testing installation on RPM OS

The instructions are duplicated in:

  • docs/index.rst
  • README.rst
  • boostrap

Start by updating the bootstrap instructions and try it manually with:

cd ~/software/libcrush/libcrush
sudo docker run -ti -v $(pwd):$(pwd) -w $(pwd) opensuse:42.2 bash
zypper install -y which
source bootstrap

Debugging readthedocs