xprtrdma: Initialize the xprt address string array earlier
authorChuck Lever <chuck.lever@oracle.com>
Fri, 15 Dec 2017 01:56:50 +0000 (20:56 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 16 Jan 2018 16:19:45 +0000 (11:19 -0500)
This makes the address strings available for debugging messages in
earlier stages of transport set up.

The first benefit is to get rid of the single-use rep_remote_addr
field, saving 128+ bytes in struct rpcrdma_ep.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index dc9000d087a9e717ad040bedd40711b1f0cc27fa..f6d171e15d7db18a33f8c8e8066ee00c828026d8 100644 (file)
@@ -373,6 +373,7 @@ xprt_setup_rdma(struct xprt_create *args)
 
        if (rpc_get_port(sap))
                xprt_set_bound(xprt);
+       xprt_rdma_format_addresses(xprt, sap);
 
        cdata.max_requests = xprt->max_reqs;
 
@@ -405,7 +406,6 @@ xprt_setup_rdma(struct xprt_create *args)
         */
        new_xprt->rx_data = cdata;
        new_ep = &new_xprt->rx_ep;
-       new_ep->rep_remote_addr = cdata.addr;
 
        rc = rpcrdma_ep_create(&new_xprt->rx_ep,
                                &new_xprt->rx_ia, &new_xprt->rx_data);
@@ -419,7 +419,6 @@ xprt_setup_rdma(struct xprt_create *args)
        INIT_DELAYED_WORK(&new_xprt->rx_connect_worker,
                          xprt_rdma_connect_worker);
 
-       xprt_rdma_format_addresses(xprt, sap);
        xprt->max_payload = new_xprt->rx_ia.ri_ops->ro_maxpages(new_xprt);
        if (xprt->max_payload == 0)
                goto out4;
@@ -437,13 +436,13 @@ xprt_setup_rdma(struct xprt_create *args)
 
 out4:
        rpcrdma_buffer_destroy(&new_xprt->rx_buf);
-       xprt_rdma_free_addresses(xprt);
        rc = -ENODEV;
 out3:
        rpcrdma_ep_destroy(new_ep, &new_xprt->rx_ia);
 out2:
        rpcrdma_ia_close(&new_xprt->rx_ia);
 out1:
+       xprt_rdma_free_addresses(xprt);
        xprt_free(xprt);
        return ERR_PTR(rc);
 }
index 4a9b6f811859e8b1d3db4878fbdd58e80d8924da..0b4d6a3f6d023c7ac71486b2adbaebb8dd0ff11d 100644 (file)
@@ -219,9 +219,6 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
        struct rpcrdma_xprt *xprt = id->context;
        struct rpcrdma_ia *ia = &xprt->rx_ia;
        struct rpcrdma_ep *ep = &xprt->rx_ep;
-#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
-       struct sockaddr *sap = (struct sockaddr *)&ep->rep_remote_addr;
-#endif
        int connstate = 0;
 
        switch (event->event) {
@@ -244,9 +241,9 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
                break;
        case RDMA_CM_EVENT_DEVICE_REMOVAL:
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
-               pr_info("rpcrdma: removing device %s for %pIS:%u\n",
+               pr_info("rpcrdma: removing device %s for %s:%s\n",
                        ia->ri_device->name,
-                       sap, rpc_get_port(sap));
+                       rpcrdma_addrstr(xprt), rpcrdma_portstr(xprt));
 #endif
                set_bit(RPCRDMA_IAF_REMOVING, &ia->ri_flags);
                ep->rep_connected = -ENODEV;
@@ -269,8 +266,8 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
                connstate = -ENETDOWN;
                goto connected;
        case RDMA_CM_EVENT_REJECTED:
-               dprintk("rpcrdma: connection to %pIS:%u rejected: %s\n",
-                       sap, rpc_get_port(sap),
+               dprintk("rpcrdma: connection to %s:%s rejected: %s\n",
+                       rpcrdma_addrstr(xprt), rpcrdma_portstr(xprt),
                        rdma_reject_msg(id, event->status));
                connstate = -ECONNREFUSED;
                if (event->status == IB_CM_REJ_STALE_CONN)
@@ -285,8 +282,9 @@ connected:
                wake_up_all(&ep->rep_connect_wait);
                /*FALLTHROUGH*/
        default:
-               dprintk("RPC:       %s: %pIS:%u on %s/%s (ep 0x%p): %s\n",
-                       __func__, sap, rpc_get_port(sap),
+               dprintk("RPC:       %s: %s:%s on %s/%s (ep 0x%p): %s\n",
+                       __func__,
+                       rpcrdma_addrstr(xprt), rpcrdma_portstr(xprt),
                        ia->ri_device->name, ia->ri_ops->ro_displayname,
                        ep, rdma_event_msg(event->event));
                break;
index 375df3d3ff598289bc2d59fcf720507568a23975..0b28026e150236718fa8b2342ca75e0ea3bfafee 100644 (file)
@@ -100,7 +100,6 @@ struct rpcrdma_ep {
        wait_queue_head_t       rep_connect_wait;
        struct rpcrdma_connect_private  rep_cm_private;
        struct rdma_conn_param  rep_remote_cma;
-       struct sockaddr_storage rep_remote_addr;
        struct delayed_work     rep_connect_worker;
 };
 
@@ -519,6 +518,18 @@ struct rpcrdma_xprt {
 #define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, rx_xprt)
 #define rpcx_to_rdmad(x) (rpcx_to_rdmax(x)->rx_data)
 
+static inline const char *
+rpcrdma_addrstr(const struct rpcrdma_xprt *r_xprt)
+{
+       return r_xprt->rx_xprt.address_strings[RPC_DISPLAY_ADDR];
+}
+
+static inline const char *
+rpcrdma_portstr(const struct rpcrdma_xprt *r_xprt)
+{
+       return r_xprt->rx_xprt.address_strings[RPC_DISPLAY_PORT];
+}
+
 /* Setting this to 0 ensures interoperability with early servers.
  * Setting this to 1 enhances certain unaligned read/write performance.
  * Default is 0, see sysctl entry and rpc_rdma.c rpcrdma_convert_iovs() */