crush: insert_item returns on error if bucket name is invalid

A bucket name may be created as a side effect of insert_item. All names
in the loc argument are checked for validity at the beginning of the
method and an error is returned immediately if one is found. This allows
to not check for errors when setting the name of an item later on.

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: remove redundant test in insert_item

A year after the last modification of test to check if an item was added
twice to the same bucket, the subtree_contains test was added a few
lines above it, making it redundant.

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: CrushWrapper unit tests

Covers all cases for the following methods. All but insert_item are trivial.

* insert_item
* set_item_name
* name_exists
* item_exists
* get_item_id
* get_item_name
* get_num_type_names
* get_type_id
* get_type_name
* is_valid_crush_name

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

CrushWrapper::insert_item unittest and minor fixes

Reviewed-by: Sage Weil <sage@inktank.com>
s/true/1 and s/false/0

Signed-off-by: tamil <tamil.muthamizhan@inktank.com>
Merge git://github.com/ceph/ceph