The long_name variable is not initialized. When the append_oname
function is called, it will strlen(long_name) and get a result
that depends on the stack content. The long_name is truncated to a
zero length string to prevent this unexpected behavior.
There is no sure way to trigger the problem by writing a unit
test. Unit tests are added for all public methods of the FlatIndex
class. Most of the time the tests fail if the long_name variable is
not properly initialized.
* uint32_t collection_version()
* coll_t coll() const
* void set_ref(std::tr1::shared_ptr<CollectionIndex> ref)
* int cleanup()
* int init()
* int created(const hobject_t &hoid, const char *path)
* int unlink(const hobject_t &hoid)
* int lookup(const hobject_t &hoid, IndexedPath *path, int *exist)
* int collection_list(vector<hobject_t> *ls)
* int collection_list_partial(const hobject_t &start, int min_count, int max_count, snapid_t seq, vector<hobject_t> *ls, hobject_t *next)
There are a number of border cases that cannot be tested, such as the
logic of the lfn_get static function. Since FlatIndex code is designed
to transition from older namespace conventions, it is difficult to
figure out.
The tests rely on xattr(2) and their availability is checked before
running them.
http://tracker.ceph.com/issues/4542 refs #4542
Signed-off-by: Loic Dachary <loic@dachary.org>
After changing the partition table, allow the udev event to be
processed before calling partprobe. This helps prevent partprobe
from getting a resource busy error on some platforms.
Signed-off-by: Gary Lowell <gary.lowell@inktank.com>
Always increment the iterator when adding old pools
to the backtrace. This fixes a bug on files where
the layout had been set to a different pool and then
back to the same pool, causing continuous looping in
the build_backtrace() function.
Fixes#4537.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Split up the conditionals handling unsafe reply
and signaling the caller to improve readability.
The overall behavior of the code remains the same.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
If the mds sends a duplicate safe reply, the mds_requests
map won't contain a matching request id (tid). Instead of
assert failing, we log a message that we saw a reply without
a matching request.
Also remove redundant mds_requests->erase(tid) line.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
The client MetaRequest should always be cleaned up
and removed from the mds_requests map once the client
gets a safe reply. This patch avoids a leak where the
mds does not send back an unsafe reply and the request
is never cleaned up.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Once a safe reply is received, we remove the
request from the mds_requests map, so checking that
it might be a duplicate won't succeed. This patch
removes the got_safe checks in the reply handling code
and the got_safe field on the MetaRequest to avoid confusion.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Passing the result of c_str() to a function that takes
std::string as argument is slow and redundant.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fixes: #4508
Backport: bobtail
On certain bucket index operations we didn't check whether
the bucket was a system bucket, which caused the operations
to fail. This triggered an error message on bucket removal
operations.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Adds a few JNI utilities from the Android project (license: Apache) to
help with IP address conversions. These functions are also updated to
work in our environment (use Ceph exception utilities, edit header
paths).
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
On rename, only set the other inode if the
lookup for the destination succeeds, otherwise we hit
a segv in set_other_inode().
Fixes#4517.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Tested-by: Noah Watkins <jayhawk@cs.ucsc.edu>
Introduced by fc80c1dc6e,
the client should _not_ fail if the lookup for the
destination path on rename returns ENOENT.
The previous code also did not check that the lookup
returned ENOENT or success. We add the check and fail
if we get any other errors.
Fixes#4517.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Note if the cluster is degraded. If so, indicate specifically which MDSs
are degraded and what state they are in.
Signed-off-by: Sage Weil <sage@inktank.com>
We should clobber configuration and log data, but *not* user data. Leave
/var/lib/ceph alone.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Gary Lowell <gary.lowell@inktank.com>
Make an 'unlink' mode of remove that will remove a link to a bucket but
not remove the bucket itself. This refactors remove_item[_under] and moves
some of the checks into common helpers where they are not duplicated. Fix
callers to pass the extra arg.
Signed-off-by: Sage Weil <sage@inktank.com>
Remove the bucket if there are no references left.
Remove the name from the map even if it is a bucket (not sure why that
condition was there in the first place!).
Signed-off-by: Sage Weil <sage@inktank.com>
This is (I think) the last missing piece to let you construct an entire
map via the CLI. The add/set commands will construct intervening ancestor
nodes provide there is an existing ancestor to stick them under, but this
is needed to create the initial root node.
Signed-off-by: Sage Weil <sage@inktank.com>
The find_roots() was looking for nodes referenced by 'take', but those
aren't necessarily roots, which is what the callers actually want.
Rename to find_takes() and add a real find_roots(). Not very efficient,
but we don't care.
Signed-off-by: Sage Weil <sage@inktank.com>
Allow a second reference to an existing bucket to be added. This lets
you create a DAG instead of a tree using the CLI.
Signed-off-by: Sage Weil <sage@inktank.com>