if (r < 0)
exit(1);
+ if (g_conf->osd_heartbeat_use_min_delay_socket) {
+ ms_hbclient->set_socket_priority(SOCKET_PRIORITY_MIN_DELAY);
+ ms_hb_back_server->set_socket_priority(SOCKET_PRIORITY_MIN_DELAY);
+ ms_hb_front_server->set_socket_priority(SOCKET_PRIORITY_MIN_DELAY);
+ }
+
// hb back should bind to same ip as cluster_addr (if specified)
entity_addr_t hb_back_addr = g_conf->osd_heartbeat_addr;
if (hb_back_addr.is_blank_ip()) {
OPTION(osd_heartbeat_interval, OPT_INT, 6) // (seconds) how often we ping peers
OPTION(osd_heartbeat_grace, OPT_INT, 20) // (seconds) how long before we decide a peer has failed
OPTION(osd_heartbeat_min_peers, OPT_INT, 10) // minimum number of peers
+OPTION(osd_heartbeat_use_min_delay_socket, OPT_BOOL, false) // set SO_PRIORITY of the sockets as 6(high) if true
// max number of parallel snap trims/pg
OPTION(osd_pg_max_concurrent_snap_trims, OPT_U64, 2)
#include <errno.h>
#include <sstream>
+#define SOCKET_PRIORITY_MIN_DELAY 6
+
class MDS;
class Timer;
int default_send_priority;
/// set to true once the Messenger has started, and set to false on shutdown
bool started;
+ int socket_priority;
public:
/**
Messenger(CephContext *cct_, entity_name_t w)
: my_inst(),
default_send_priority(CEPH_MSG_PRIO_DEFAULT), started(false),
+ socket_priority(-1),
cct(cct_)
{
my_inst.name = w;
assert(!started);
default_send_priority = p;
}
+ /**
+ * Set the priority(SO_PRIORITY) for all packets to be sent on this socket.
+ *
+ * Linux uses this value to order the networking queues: packets with a higher
+ * priority may be processed first depending on the selected device queueing
+ * discipline.
+ *
+ * @param prio The priority. Setting a priority outside the range 0 to 6
+ * requires the CAP_NET_ADMIN capability.
+ */
+ void set_socket_priority(int prio) {
+ socket_priority = prio;
+ }
+ /**
+ * Get the socket priority
+ *
+ * @return the socket priority
+ */
+ int get_socket_priority() {
+ return socket_priority;
+ }
/**
* Add a new Dispatcher to the front of the list. If you add
* a Dispatcher which is already included, it will get a duplicate
socklen_t slen = sizeof(addr.ss_addr());
int sd = ::accept(listen_sd, (sockaddr*)&addr.ss_addr(), &slen);
if (sd >= 0) {
+ int prio = msgr->get_socket_priority();
+ if (prio >= 0) {
+ int rc = ::setsockopt(sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
+ if (rc < 0) {
+ ldout(msgr->cct,0) << "WARNING: failed to set SO_PRIORITY for sd "
+ << sd << ": " << cpp_strerror(errno) << dendl;
+ }
+ }
+
errors = 0;
ldout(msgr->cct,10) << "accepted incoming on sd " << sd << dendl;
ldout(msgr->cct,0) << "couldn't set SO_NOSIGPIPE: " << cpp_strerror(r) << dendl;
}
#endif
+
+ int prio = msgr->get_socket_priority();
+ if (prio >= 0) {
+ int r = ::setsockopt(sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
+ if (r < 0) {
+ ldout(msgr->cct,0) << "couldn't set SO_PRIORITY to " << prio
+ << ": " << cpp_strerror(errno) << dendl;
+ }
+ }
}
int Pipe::connect()