From 9b63845ad15ce88fe7d47a764f37523e65f08480 Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Wed, 19 Jun 2019 15:53:08 +0800 Subject: [PATCH] msg/async/rdma: remove redundant code 1. Below three bits are meaningless in pollfd::events field: POLLERR, POLLHUP, or POLLNVAL. 2. QueuePair::pd is initialized in the initialize list. There's no need to assign same value to it. 3. Remove the never used function Chunk::set_bound 4. Remove the never used function Chunk::set_offset 5. Remove the never used function QueuePair::is_error 6. Remove SimplePolicyMessenger used vars 7. remove socket_fd() interface since it's never used. All data write/read is based on ConnectedSocketImpl::fd. So, there's no need to expose socket_fd since it's never used. 8. Remove RDMAServerSocketImpl::get_fd which is not used. BTW, RDMAServerSocketImpl::fd has the same function as get_fd. Signed-off-by: Changcheng Liu --- src/msg/SimplePolicyMessenger.h | 3 +-- src/msg/async/AsyncMessenger.cc | 2 +- src/msg/async/PosixStack.cc | 3 --- src/msg/async/Stack.h | 4 ---- src/msg/async/dpdk/DPDKStack.h | 4 ---- src/msg/async/rdma/Infiniband.cc | 28 ---------------------------- src/msg/async/rdma/Infiniband.h | 6 ------ src/msg/async/rdma/RDMAStack.cc | 4 ++-- src/msg/async/rdma/RDMAStack.h | 2 -- 9 files changed, 4 insertions(+), 52 deletions(-) diff --git a/src/msg/SimplePolicyMessenger.h b/src/msg/SimplePolicyMessenger.h index dc2b3c79222d2..3b25983a62b79 100644 --- a/src/msg/SimplePolicyMessenger.h +++ b/src/msg/SimplePolicyMessenger.h @@ -30,8 +30,7 @@ private: public: - SimplePolicyMessenger(CephContext *cct, entity_name_t name, - string mname, uint64_t _nonce) + SimplePolicyMessenger(CephContext *cct, entity_name_t name) : Messenger(cct, name) { } diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 6d2a4251cb1ee..47405cf18d871 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -276,7 +276,7 @@ class C_handle_reap : public EventCallback { AsyncMessenger::AsyncMessenger(CephContext *cct, entity_name_t name, const std::string &type, string mname, uint64_t _nonce) - : SimplePolicyMessenger(cct, name,mname, _nonce), + : SimplePolicyMessenger(cct, name), dispatch_queue(cct, this, mname), nonce(_nonce) { diff --git a/src/msg/async/PosixStack.cc b/src/msg/async/PosixStack.cc index 5a364b8fbe092..eb7b343a3677f 100644 --- a/src/msg/async/PosixStack.cc +++ b/src/msg/async/PosixStack.cc @@ -161,9 +161,6 @@ class PosixConnectedSocketImpl final : public ConnectedSocketImpl { int fd() const override { return _fd; } - int socket_fd() const override { - return _fd; - } friend class PosixServerSocketImpl; friend class PosixNetworkStack; }; diff --git a/src/msg/async/Stack.h b/src/msg/async/Stack.h index d05f934fd093a..a7430da873531 100644 --- a/src/msg/async/Stack.h +++ b/src/msg/async/Stack.h @@ -33,7 +33,6 @@ class ConnectedSocketImpl { virtual void shutdown() = 0; virtual void close() = 0; virtual int fd() const = 0; - virtual int socket_fd() const = 0; }; class ConnectedSocket; @@ -130,9 +129,6 @@ class ConnectedSocket { int fd() const { return _csi->fd(); } - int socket_fd() const { - return _csi->socket_fd(); - } explicit operator bool() const { return _csi.get(); diff --git a/src/msg/async/dpdk/DPDKStack.h b/src/msg/async/dpdk/DPDKStack.h index 622ff8a3c6945..e41a87545220e 100644 --- a/src/msg/async/dpdk/DPDKStack.h +++ b/src/msg/async/dpdk/DPDKStack.h @@ -176,10 +176,6 @@ class NativeConnectedSocketImpl : public ConnectedSocketImpl { virtual int fd() const override { return _conn.fd(); } - virtual int socket_fd() const override { - return _conn.fd(); - } - }; template diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index 9e27fe72abbde..360f39dd0a9ce 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -180,7 +180,6 @@ Infiniband::QueuePair::QueuePair( lderr(cct) << __func__ << " invalid queue pair type" << cpp_strerror(errno) << dendl; ceph_abort(); } - pd = infiniband.pd->pd; } int Infiniband::QueuePair::init() @@ -354,23 +353,6 @@ int Infiniband::QueuePair::get_state() const return qpa.qp_state; } -/** - * Return true if the queue pair is in an error state, false otherwise. - */ -bool Infiniband::QueuePair::is_error() const -{ - ibv_qp_attr qpa; - - int r = get_state(); - if (r) { - lderr(cct) << __func__ << " failed to get state: " - << cpp_strerror(errno) << dendl; - return true; - } - return qpa.qp_state == IBV_QPS_ERR; -} - - Infiniband::CompletionChannel::CompletionChannel(CephContext *c, Infiniband &ib) : cct(c), infiniband(ib), channel(NULL), cq(NULL), cq_events_that_need_ack(0) { @@ -509,21 +491,11 @@ Infiniband::MemoryManager::Chunk::~Chunk() { } -void Infiniband::MemoryManager::Chunk::set_offset(uint32_t o) -{ - offset = o; -} - uint32_t Infiniband::MemoryManager::Chunk::get_offset() { return offset; } -void Infiniband::MemoryManager::Chunk::set_bound(uint32_t b) -{ - bound = b; -} - uint32_t Infiniband::MemoryManager::Chunk::get_size() const { return bound - offset; diff --git a/src/msg/async/rdma/Infiniband.h b/src/msg/async/rdma/Infiniband.h index 09c58241a556e..d47f914e1c241 100644 --- a/src/msg/async/rdma/Infiniband.h +++ b/src/msg/async/rdma/Infiniband.h @@ -206,9 +206,7 @@ class Infiniband { Chunk(ibv_mr* m, uint32_t bytes, char* buffer, uint32_t offset = 0, uint32_t bound = 0, uint32_t lkey = 0); ~Chunk(); - void set_offset(uint32_t o); uint32_t get_offset(); - void set_bound(uint32_t b); uint32_t get_size() const; void prepare_read(uint32_t b); uint32_t get_bound(); @@ -476,10 +474,6 @@ class Infiniband { * Get the state of a QueuePair. */ int get_state() const; - /** - * Return true if the queue pair is in an error state, false otherwise. - */ - bool is_error() const; void add_tx_wr(uint32_t amt) { tx_wr_inflight += amt; } void dec_tx_wr(uint32_t amt) { tx_wr_inflight -= amt; } uint32_t get_tx_wr() const { return tx_wr_inflight; } diff --git a/src/msg/async/rdma/RDMAStack.cc b/src/msg/async/rdma/RDMAStack.cc index 82533c83a2981..254f45f2a6c99 100644 --- a/src/msg/async/rdma/RDMAStack.cc +++ b/src/msg/async/rdma/RDMAStack.cc @@ -315,10 +315,10 @@ void RDMADispatcher::polling() struct pollfd channel_poll[2]; channel_poll[0].fd = tx_cc->get_fd(); - channel_poll[0].events = POLLIN | POLLERR | POLLNVAL | POLLHUP; + channel_poll[0].events = POLLIN; channel_poll[0].revents = 0; channel_poll[1].fd = rx_cc->get_fd(); - channel_poll[1].events = POLLIN | POLLERR | POLLNVAL | POLLHUP; + channel_poll[1].events = POLLIN; channel_poll[1].revents = 0; r = 0; perf_logger->set(l_msgr_rdma_polling, 0); diff --git a/src/msg/async/rdma/RDMAStack.h b/src/msg/async/rdma/RDMAStack.h index 7a83260a54099..1642d17ad4d29 100644 --- a/src/msg/async/rdma/RDMAStack.h +++ b/src/msg/async/rdma/RDMAStack.h @@ -228,7 +228,6 @@ class RDMAConnectedSocketImpl : public ConnectedSocketImpl { virtual void shutdown() override; virtual void close() override; virtual int fd() const override { return notify_fd; } - virtual int socket_fd() const override { return tcp_fd; } void fault(); const char* get_qp_state() { return Infiniband::qp_state_string(qp->get_state()); } ssize_t submit(bool more); @@ -325,7 +324,6 @@ class RDMAServerSocketImpl : public ServerSocketImpl { virtual int accept(ConnectedSocket *s, const SocketOptions &opts, entity_addr_t *out, Worker *w) override; virtual void abort_accept() override; virtual int fd() const override { return server_setup_socket; } - int get_fd() { return server_setup_socket; } }; class RDMAIWARPServerSocketImpl : public RDMAServerSocketImpl { -- 2.39.5