RDS: Stop supporting old cong map sending method
Andy Grover [Mon, 22 Mar 2010 22:22:04 +0000 (15:22 -0700)]
We now ask the transport to give us a rm for the congestion
map, and then we handle it normally. Previously, the
transport defined a function that we would call to send
a congestion map.

Convert TCP and loop transports to new cong map method.

Signed-off-by: Andy Grover <andy.grover@oracle.com>

net/rds/ib.c
net/rds/iw.c
net/rds/loop.c
net/rds/rds.h
net/rds/send.c
net/rds/tcp.c
net/rds/tcp.h
net/rds/tcp_send.c

index 932dacb..927c481 100644 (file)
@@ -265,7 +265,6 @@ struct rds_transport rds_ib_transport = {
        .laddr_check            = rds_ib_laddr_check,
        .xmit_complete          = rds_ib_xmit_complete,
        .xmit                   = rds_ib_xmit,
-       .xmit_cong_map          = NULL,
        .xmit_rdma              = rds_ib_xmit_rdma,
        .xmit_atomic            = rds_ib_xmit_atomic,
        .recv                   = rds_ib_recv,
index e766aec..467790d 100644 (file)
@@ -264,7 +264,6 @@ struct rds_transport rds_iw_transport = {
        .laddr_check            = rds_iw_laddr_check,
        .xmit_complete          = rds_iw_xmit_complete,
        .xmit                   = rds_iw_xmit,
-       .xmit_cong_map          = NULL,
        .xmit_rdma              = rds_iw_xmit_rdma,
        .recv                   = rds_iw_recv,
        .conn_alloc             = rds_iw_conn_alloc,
index 4a3dd49..c390156 100644 (file)
@@ -61,6 +61,12 @@ static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm,
                         unsigned int hdr_off, unsigned int sg,
                         unsigned int off)
 {
+       /* Do not send cong updates to loopback */
+       if (rm->m_inc.i_hdr.h_flags & RDS_FLAG_CONG_BITMAP) {
+               rds_cong_map_updated(conn->c_fcong, ~(u64) 0);
+               return sizeof(struct rds_header) + RDS_CONG_MAP_BYTES;
+       }
+
        BUG_ON(hdr_off || sg || off);
 
        rds_inc_init(&rm->m_inc, conn, conn->c_laddr);
@@ -88,18 +94,6 @@ static void rds_loop_inc_free(struct rds_incoming *inc)
         rds_message_put(rm);
 }
 
-static int rds_loop_xmit_cong_map(struct rds_connection *conn,
-                                 struct rds_cong_map *map,
-                                 unsigned long offset)
-{
-       BUG_ON(offset);
-       BUG_ON(map != conn->c_lcong);
-
-       rds_cong_map_updated(conn->c_fcong, ~(u64) 0);
-
-       return sizeof(struct rds_header) + RDS_CONG_MAP_BYTES;
-}
-
 /* we need to at least give the thread something to succeed */
 static int rds_loop_recv(struct rds_connection *conn)
 {
@@ -180,7 +174,6 @@ void rds_loop_exit(void)
  */
 struct rds_transport rds_loop_transport = {
        .xmit                   = rds_loop_xmit,
-       .xmit_cong_map          = rds_loop_xmit_cong_map,
        .recv                   = rds_loop_recv,
        .conn_alloc             = rds_loop_conn_alloc,
        .conn_free              = rds_loop_conn_free,
index 7291f00..e81d7e4 100644 (file)
@@ -393,10 +393,6 @@ struct rds_notifier {
  *                 transport is responsible for other serialization, including
  *                 rds_recv_incoming().  This is called in process context but
  *                 should try hard not to block.
- *
- * @xmit_cong_map: This asks the transport to send the local bitmap down the
- *                given connection.  XXX get a better story about the bitmap
- *                flag and header.
  */
 
 #define RDS_TRANS_IB   0
@@ -420,8 +416,6 @@ struct rds_transport {
        void (*xmit_complete)(struct rds_connection *conn);
        int (*xmit)(struct rds_connection *conn, struct rds_message *rm,
                    unsigned int hdr_off, unsigned int sg, unsigned int off);
-       int (*xmit_cong_map)(struct rds_connection *conn,
-                            struct rds_cong_map *map, unsigned long offset);
        int (*xmit_rdma)(struct rds_connection *conn, struct rm_rdma_op *op);
        int (*xmit_atomic)(struct rds_connection *conn, struct rm_atomic_op *op);
        int (*recv)(struct rds_connection *conn);
index d1f364e..8a0647a 100644 (file)
@@ -147,41 +147,16 @@ int rds_send_xmit(struct rds_connection *conn)
                /*
                 * If between sending messages, we can send a pending congestion
                 * map update.
-                *
-                * Transports either define a special xmit_cong_map function,
-                * or we allocate a cong_map message and treat it just like any
-                * other send.
                 */
                if (!rm && test_and_clear_bit(0, &conn->c_map_queued)) {
-                       if (conn->c_trans->xmit_cong_map) {
-                               unsigned long map_offset = 0;
-                               unsigned long map_bytes = sizeof(struct rds_header) +
-                                       RDS_CONG_MAP_BYTES;
-
-                               while (map_bytes) {
-                                       ret = conn->c_trans->xmit_cong_map(conn, conn->c_lcong,
-                                                                          map_offset);
-                                       if (ret <= 0) {
-                                               /* too far down the rabbithole! */
-                                               mutex_unlock(&conn->c_send_lock);
-                                               rds_conn_error(conn, "Cong map xmit failed\n");
-                                               goto out;
-                                       }
-
-                                       map_offset += ret;
-                                       map_bytes -= ret;
-                               }
-                       } else {
-                               /* send cong update like a normal rm */
-                               rm = rds_cong_update_alloc(conn);
-                               if (IS_ERR(rm)) {
-                                       ret = PTR_ERR(rm);
-                                       break;
-                               }
-                               rm->data.op_active = 1;
-
-                               conn->c_xmit_rm = rm;
+                       rm = rds_cong_update_alloc(conn);
+                       if (IS_ERR(rm)) {
+                               ret = PTR_ERR(rm);
+                               break;
                        }
+                       rm->data.op_active = 1;
+
+                       conn->c_xmit_rm = rm;
                }
 
                /*
index 8318816..3262992 100644 (file)
@@ -258,7 +258,6 @@ struct rds_transport rds_tcp_transport = {
        .laddr_check            = rds_tcp_laddr_check,
        .xmit_prepare           = rds_tcp_xmit_prepare,
        .xmit_complete          = rds_tcp_xmit_complete,
-       .xmit_cong_map          = rds_tcp_xmit_cong_map,
        .xmit                   = rds_tcp_xmit,
        .recv                   = rds_tcp_recv,
        .conn_alloc             = rds_tcp_conn_alloc,
index c639872..16b1663 100644 (file)
@@ -80,8 +80,6 @@ void rds_tcp_xmit_complete(struct rds_connection *conn);
 int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
                 unsigned int hdr_off, unsigned int sg, unsigned int off);
 void rds_tcp_write_space(struct sock *sk);
-int rds_tcp_xmit_cong_map(struct rds_connection *conn,
-                         struct rds_cong_map *map, unsigned long offset);
 
 /* tcp_stats.c */
 DECLARE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats);
index 53c1de5..2979fb4 100644 (file)
@@ -77,56 +77,6 @@ int rds_tcp_sendmsg(struct socket *sock, void *data, unsigned int len)
 }
 
 /* the core send_sem serializes this with other xmit and shutdown */
-int rds_tcp_xmit_cong_map(struct rds_connection *conn,
-                         struct rds_cong_map *map, unsigned long offset)
-{
-       static struct rds_header rds_tcp_map_header = {
-               .h_flags = RDS_FLAG_CONG_BITMAP,
-       };
-       struct rds_tcp_connection *tc = conn->c_transport_data;
-       unsigned long i;
-       int ret;
-       int copied = 0;
-
-       /* Some problem claims cpu_to_be32(constant) isn't a constant. */
-       rds_tcp_map_header.h_len = cpu_to_be32(RDS_CONG_MAP_BYTES);
-
-       if (offset < sizeof(struct rds_header)) {
-               ret = rds_tcp_sendmsg(tc->t_sock,
-                                     (void *)&rds_tcp_map_header + offset,
-                                     sizeof(struct rds_header) - offset);
-               if (ret <= 0)
-                       return ret;
-               offset += ret;
-               copied = ret;
-               if (offset < sizeof(struct rds_header))
-                       return ret;
-       }
-
-       offset -= sizeof(struct rds_header);
-       i = offset / PAGE_SIZE;
-       offset = offset % PAGE_SIZE;
-       BUG_ON(i >= RDS_CONG_MAP_PAGES);
-
-       do {
-               ret = tc->t_sock->ops->sendpage(tc->t_sock,
-                                       virt_to_page(map->m_page_addrs[i]),
-                                       offset, PAGE_SIZE - offset,
-                                       MSG_DONTWAIT);
-               if (ret <= 0)
-                       break;
-               copied += ret;
-               offset += ret;
-               if (offset == PAGE_SIZE) {
-                       offset = 0;
-                       i++;
-               }
-       } while (i < RDS_CONG_MAP_PAGES);
-
-        return copied ? copied : ret;
-}
-
-/* the core send_sem serializes this with other xmit and shutdown */
 int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
                 unsigned int hdr_off, unsigned int sg, unsigned int off)
 {