Commit e6ef8a5c authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Preallocate one page per drbd_socket as a receive buffer

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent cb703454
...@@ -554,6 +554,8 @@ struct p_delay_probe93 { ...@@ -554,6 +554,8 @@ struct p_delay_probe93 {
#error "PAGE_SIZE too small" #error "PAGE_SIZE too small"
#endif #endif
#define DRBD_SOCKET_BUFFER_SIZE 4096
union p_polymorph { union p_polymorph {
struct p_header header; struct p_header header;
struct p_handshake handshake; struct p_handshake handshake;
...@@ -803,7 +805,7 @@ struct drbd_socket { ...@@ -803,7 +805,7 @@ struct drbd_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; union p_polymorph sbuf;
union p_polymorph rbuf; void *rbuf;
}; };
struct drbd_md { struct drbd_md {
......
...@@ -2272,6 +2272,19 @@ struct drbd_tconn *conn_by_name(const char *name) ...@@ -2272,6 +2272,19 @@ struct drbd_tconn *conn_by_name(const char *name)
return tconn; return tconn;
} }
static int drbd_alloc_socket(struct drbd_socket *socket)
{
socket->rbuf = (void *) __get_free_page(GFP_KERNEL);
if (!socket->rbuf)
return -ENOMEM;
return 0;
}
static void drbd_free_socket(struct drbd_socket *socket)
{
free_page((unsigned long) socket->rbuf);
}
struct drbd_tconn *drbd_new_tconn(const char *name) struct drbd_tconn *drbd_new_tconn(const char *name)
{ {
struct drbd_tconn *tconn; struct drbd_tconn *tconn;
...@@ -2284,6 +2297,11 @@ struct drbd_tconn *drbd_new_tconn(const char *name) ...@@ -2284,6 +2297,11 @@ struct drbd_tconn *drbd_new_tconn(const char *name)
if (!tconn->name) if (!tconn->name)
goto fail; goto fail;
if (drbd_alloc_socket(&tconn->data))
goto fail;
if (drbd_alloc_socket(&tconn->meta))
goto fail;
if (!zalloc_cpumask_var(&tconn->cpu_mask, GFP_KERNEL)) if (!zalloc_cpumask_var(&tconn->cpu_mask, GFP_KERNEL))
goto fail; goto fail;
...@@ -2322,6 +2340,8 @@ struct drbd_tconn *drbd_new_tconn(const char *name) ...@@ -2322,6 +2340,8 @@ struct drbd_tconn *drbd_new_tconn(const char *name)
fail: fail:
tl_cleanup(tconn); tl_cleanup(tconn);
free_cpumask_var(tconn->cpu_mask); free_cpumask_var(tconn->cpu_mask);
drbd_free_socket(&tconn->meta);
drbd_free_socket(&tconn->data);
kfree(tconn->name); kfree(tconn->name);
kfree(tconn); kfree(tconn);
...@@ -2334,6 +2354,8 @@ void drbd_free_tconn(struct drbd_tconn *tconn) ...@@ -2334,6 +2354,8 @@ void drbd_free_tconn(struct drbd_tconn *tconn)
idr_destroy(&tconn->volumes); idr_destroy(&tconn->volumes);
free_cpumask_var(tconn->cpu_mask); free_cpumask_var(tconn->cpu_mask);
drbd_free_socket(&tconn->meta);
drbd_free_socket(&tconn->data);
kfree(tconn->name); kfree(tconn->name);
kfree(tconn->int_dig_out); kfree(tconn->int_dig_out);
kfree(tconn->int_dig_in); kfree(tconn->int_dig_in);
......
This diff is collapsed.
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