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 {
#error "PAGE_SIZE too small"
#endif
#define DRBD_SOCKET_BUFFER_SIZE 4096
union p_polymorph {
struct p_header header;
struct p_handshake handshake;
......@@ -803,7 +805,7 @@ struct drbd_socket {
/* this way we get our
* send/receive buffers off the stack */
union p_polymorph sbuf;
union p_polymorph rbuf;
void *rbuf;
};
struct drbd_md {
......
......@@ -2272,6 +2272,19 @@ struct drbd_tconn *conn_by_name(const char *name)
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 *tconn;
......@@ -2284,6 +2297,11 @@ struct drbd_tconn *drbd_new_tconn(const char *name)
if (!tconn->name)
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))
goto fail;
......@@ -2322,6 +2340,8 @@ struct drbd_tconn *drbd_new_tconn(const char *name)
fail:
tl_cleanup(tconn);
free_cpumask_var(tconn->cpu_mask);
drbd_free_socket(&tconn->meta);
drbd_free_socket(&tconn->data);
kfree(tconn->name);
kfree(tconn);
......@@ -2334,6 +2354,8 @@ void drbd_free_tconn(struct drbd_tconn *tconn)
idr_destroy(&tconn->volumes);
free_cpumask_var(tconn->cpu_mask);
drbd_free_socket(&tconn->meta);
drbd_free_socket(&tconn->data);
kfree(tconn->name);
kfree(tconn->int_dig_out);
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