Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / msg / xio / XioMsg.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7  * Portions Copyright (C) 2013 CohortFS, LLC
8  *
9  * This is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software
12  * Foundation.  See file COPYING.
13  *
14  */
15
16 #include "XioMessenger.h"
17 #include "XioConnection.h"
18 #include "XioMsg.h"
19
20
21 int XioDispatchHook::release_msgs()
22 {
23   XioCompletion *xcmp;
24   int r = msg_seq.size();
25   cl_flag = true;
26
27   /* queue for release */
28   xcmp = static_cast<XioCompletion *>(rsp_pool.alloc(sizeof(XioCompletion)));
29   new (xcmp) XioCompletion(xcon, this);
30   xcmp->trace = m->trace;
31
32   /* merge with portal traffic */
33   xcon->portal->enqueue(xcon, xcmp);
34
35   assert(r);
36   return r;
37 }
38
39 /*static*/ size_t XioMsgHdr::get_max_encoded_length() {
40   ceph_msg_header _ceph_msg_header;
41   ceph_msg_footer _ceph_msg_footer;
42   XioMsgHdr hdr (_ceph_msg_header, _ceph_msg_footer, 0 /* features */);
43   const std::list<buffer::ptr>& hdr_buffers = hdr.get_bl().buffers();
44   assert(hdr_buffers.size() == 1); /* accelio header is small without scatter gather */
45   return hdr_buffers.begin()->length();
46 }
47
48 void XioMsg::print_debug(CephContext *cct, const char *tag) const {
49   print_xio_msg_hdr(cct, tag, hdr, get_xio_msg());
50   print_ceph_msg(cct, tag, m);
51 }