drbd: Preallocate one page per drbd_socket as a send buffer
authorAndreas Gruenbacher <agruen@linbit.com>
Thu, 24 Mar 2011 20:17:52 +0000 (21:17 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 8 Nov 2012 15:44:54 +0000 (16:44 +0100)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_worker.c

index 932ba030435318c610a77f8fe98eddf1136e7966..9f1f0f56f71eb5f009a69397b756c64c0d98d726 100644 (file)
@@ -556,27 +556,6 @@ struct p_delay_probe93 {
 
 #define DRBD_SOCKET_BUFFER_SIZE 4096
 
-union p_polymorph {
-        struct p_header           header;
-        struct p_handshake       handshake;
-        struct p_data            data;
-        struct p_block_ack       block_ack;
-        struct p_barrier         barrier;
-        struct p_barrier_ack     barrier_ack;
-        struct p_rs_param_89     rs_param_89;
-        struct p_rs_param_95     rs_param_95;
-        struct p_protocol        protocol;
-        struct p_sizes           sizes;
-        struct p_uuids           uuids;
-        struct p_state           state;
-        struct p_req_state       req_state;
-        struct p_req_state_reply req_state_reply;
-        struct p_block_req       block_req;
-       struct p_delay_probe93   delay_probe93;
-       struct p_rs_uuid         rs_uuid;
-       struct p_block_desc      block_desc;
-} __packed;
-
 /**********************************************************************/
 enum drbd_thread_state {
        NONE,
@@ -804,7 +783,7 @@ struct drbd_socket {
        struct socket    *socket;
        /* this way we get our
         * send/receive buffers off the stack */
-       union p_polymorph sbuf;
+       void *sbuf;
        void *rbuf;
 };
 
index 004a8ce7f1d3d1553d85606bdef392be9399aedb..16ec6c3bd7d6326dff51dbe3b44fb281dfef29c9 100644 (file)
@@ -800,7 +800,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev)
                enum drbd_packet cmd =
                        apv >= 89 ? P_SYNC_PARAM89 : P_SYNC_PARAM;
 
-               p = &mdev->tconn->data.sbuf.rs_param_95;
+               p = mdev->tconn->data.sbuf;
 
                /* initialize verify_alg and csums_alg */
                memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
@@ -2277,11 +2277,15 @@ static int drbd_alloc_socket(struct drbd_socket *socket)
        socket->rbuf = (void *) __get_free_page(GFP_KERNEL);
        if (!socket->rbuf)
                return -ENOMEM;
+       socket->sbuf = (void *) __get_free_page(GFP_KERNEL);
+       if (!socket->sbuf)
+               return -ENOMEM;
        return 0;
 }
 
 static void drbd_free_socket(struct drbd_socket *socket)
 {
+       free_page((unsigned long) socket->sbuf);
        free_page((unsigned long) socket->rbuf);
 }
 
index 59e5a50332d64b4fcc30b5afee0cad716fc6e24a..e75eb270263d6fb9410747145df136c16fffa66e 100644 (file)
@@ -736,7 +736,7 @@ out:
 
 static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd_packet cmd)
 {
-       struct p_header *h = &tconn->data.sbuf.header;
+       struct p_header *h = tconn->data.sbuf;
 
        return !_conn_send_cmd(tconn, 0, sock, cmd, h, sizeof(*h), 0);
 }
@@ -4138,7 +4138,7 @@ static int drbd_disconnected(int vnr, void *p, void *data)
 static int drbd_send_handshake(struct drbd_tconn *tconn)
 {
        /* ASSERT current == mdev->tconn->receiver ... */
-       struct p_handshake *p = &tconn->data.sbuf.handshake;
+       struct p_handshake *p = tconn->data.sbuf;
        int err;
 
        if (mutex_lock_interruptible(&tconn->data.mutex)) {
index 185cd25b18dd87d0678fc2e9ee9ab1c57f0a59c3..cbbc5c7cbef4fca3035e02ad6d78d7f3f36cd079 100644 (file)
@@ -1193,7 +1193,7 @@ int w_send_barrier(struct drbd_work *w, int cancel)
 {
        struct drbd_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w);
        struct drbd_conf *mdev = w->mdev;
-       struct p_barrier *p = &mdev->tconn->data.sbuf.barrier;
+       struct p_barrier *p = mdev->tconn->data.sbuf;
        int err = 0;
 
        /* really avoid racing with tl_clear.  w.cb may have been referenced