Commit 5a87d920 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Preallocate one page per drbd_socket as a send buffer

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent fc56815c
...@@ -556,27 +556,6 @@ struct p_delay_probe93 { ...@@ -556,27 +556,6 @@ struct p_delay_probe93 {
#define DRBD_SOCKET_BUFFER_SIZE 4096 #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 { enum drbd_thread_state {
NONE, NONE,
...@@ -804,7 +783,7 @@ struct drbd_socket { ...@@ -804,7 +783,7 @@ struct drbd_socket {
struct socket *socket; struct socket *socket;
/* this way we get our /* this way we get our
* send/receive buffers off the stack */ * send/receive buffers off the stack */
union p_polymorph sbuf; void *sbuf;
void *rbuf; void *rbuf;
}; };
......
...@@ -800,7 +800,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev) ...@@ -800,7 +800,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev)
enum drbd_packet cmd = enum drbd_packet cmd =
apv >= 89 ? P_SYNC_PARAM89 : P_SYNC_PARAM; 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 */ /* initialize verify_alg and csums_alg */
memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
...@@ -2277,11 +2277,15 @@ static int drbd_alloc_socket(struct drbd_socket *socket) ...@@ -2277,11 +2277,15 @@ static int drbd_alloc_socket(struct drbd_socket *socket)
socket->rbuf = (void *) __get_free_page(GFP_KERNEL); socket->rbuf = (void *) __get_free_page(GFP_KERNEL);
if (!socket->rbuf) if (!socket->rbuf)
return -ENOMEM; return -ENOMEM;
socket->sbuf = (void *) __get_free_page(GFP_KERNEL);
if (!socket->sbuf)
return -ENOMEM;
return 0; return 0;
} }
static void drbd_free_socket(struct drbd_socket *socket) static void drbd_free_socket(struct drbd_socket *socket)
{ {
free_page((unsigned long) socket->sbuf);
free_page((unsigned long) socket->rbuf); free_page((unsigned long) socket->rbuf);
} }
......
...@@ -736,7 +736,7 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn) ...@@ -736,7 +736,7 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn)
static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd_packet cmd) 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); 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) ...@@ -4138,7 +4138,7 @@ static int drbd_disconnected(int vnr, void *p, void *data)
static int drbd_send_handshake(struct drbd_tconn *tconn) static int drbd_send_handshake(struct drbd_tconn *tconn)
{ {
/* ASSERT current == mdev->tconn->receiver ... */ /* ASSERT current == mdev->tconn->receiver ... */
struct p_handshake *p = &tconn->data.sbuf.handshake; struct p_handshake *p = tconn->data.sbuf;
int err; int err;
if (mutex_lock_interruptible(&tconn->data.mutex)) { if (mutex_lock_interruptible(&tconn->data.mutex)) {
......
...@@ -1193,7 +1193,7 @@ int w_send_barrier(struct drbd_work *w, int cancel) ...@@ -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_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w);
struct drbd_conf *mdev = w->mdev; 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; int err = 0;
/* really avoid racing with tl_clear. w.cb may have been referenced /* really avoid racing with tl_clear. w.cb may have been referenced
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment