From 42bb91a258512c34ea402f34f130518069db3835 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Wed, 22 Nov 2017 17:12:43 +0530 Subject: [PATCH 1/2] mds: Fix error message when mds not active Fix error message for mds not active state. Also fixed the 'unrecognized command' logic by avoiding the new stringstream local object. Signed-off-by: Jos Collin (cherry picked from commit 10f93cf5828afbc8ff25ef81b2437ef5c0362396) --- src/mds/MDSDaemon.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 4c30b6747136b..6fe1e2488de02 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -823,18 +823,19 @@ int MDSDaemon::_handle_command( cpu_profiler_handle_command(argvec, ds); } else { // Give MDSRank a shot at the command - if (mds_rank) { + if (!mds_rank) { + ss << "MDS not active"; + r = -EINVAL; + } + else { bool handled = mds_rank->handle_command(cmdmap, m, &r, &ds, &ss, need_reply); - if (handled) { - goto out; + if (!handled) { + // MDSDaemon doesn't know this command + ss << "unrecognized command! " << prefix; + r = -EINVAL; } } - - // Neither MDSDaemon nor MDSRank know this command - std::ostringstream ss; - ss << "unrecognized command! " << prefix; - r = -EINVAL; } out: From ca980a63c3125a356cff79eba9df06fd2b37d731 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Wed, 22 Nov 2017 17:20:58 +0530 Subject: [PATCH 2/2] pybind: return error message when ceph_mds_command() returns error Returned the error message when ceph_mds_command() returns error. Signed-off-by: Jos Collin (cherry picked from commit 941b58c968f6b0e359f279c8bc9e7decf51e75d1) --- src/pybind/cephfs/cephfs.pyx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 806e0ab4c3756..3f106c4dfc6a9 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -962,10 +962,10 @@ cdef class LibCephFS(object): char *_inbuf = input_data size_t _inbuf_len = len(input_data) - char *_outbuf - size_t _outbuf_len - char *_outs - size_t _outs_len + char *_outbuf = NULL + size_t _outbuf_len = 0 + char *_outs = NULL + size_t _outs_len = 0 try: with nogil: @@ -974,15 +974,12 @@ cdef class LibCephFS(object): _inbuf, _inbuf_len, &_outbuf, &_outbuf_len, &_outs, &_outs_len) - if ret == 0: - my_outs = decode_cstr(_outs[:_outs_len]) - my_outbuf = _outbuf[:_outbuf_len] - if _outs_len: - ceph_buffer_free(_outs) - if _outbuf_len: - ceph_buffer_free(_outbuf) - return (ret, my_outbuf, my_outs) - else: - return (ret, b"", "") + my_outs = decode_cstr(_outs[:_outs_len]) + my_outbuf = _outbuf[:_outbuf_len] + if _outs_len: + ceph_buffer_free(_outs) + if _outbuf_len: + ceph_buffer_free(_outbuf) + return (ret, my_outbuf, my_outs) finally: free(_cmd)