diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2010-05-25 10:18:01 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-06-01 05:12:27 -0400 |
commit | 5dbf1673383f2f1554f0634fdfc390d59dc2c7d6 (patch) | |
tree | a63a9ed3528b35f943100072b88add3fca72dbaf /drivers/block | |
parent | 344fa462e3246bd102059ccc3c59deef416676dd (diff) |
drbd: need to set socket bufsize early to take effect
quoting tcp(7):
On individual connections, the socket buffer size must be set prior to the
listen(2) or connect(2) calls in order to have it take effect.
This adds a wrapper to do so, and uses it appropriately.
Improves performance in certain situations.
Note that because we cannot easily determine which socket will be
"meta" and wich "data" (bulk) socket, we adjust both sockets.
Previously, DRBD only adjusted the bufsizes of the "data" socket.
Thanks again to Eduard.Guzovsky@stratus.com.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index a56340dd5710..f9a3e199e715 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -571,6 +571,25 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size) | |||
571 | return rv; | 571 | return rv; |
572 | } | 572 | } |
573 | 573 | ||
574 | /* quoting tcp(7): | ||
575 | * On individual connections, the socket buffer size must be set prior to the | ||
576 | * listen(2) or connect(2) calls in order to have it take effect. | ||
577 | * This is our wrapper to do so. | ||
578 | */ | ||
579 | static void drbd_setbufsize(struct socket *sock, unsigned int snd, | ||
580 | unsigned int rcv) | ||
581 | { | ||
582 | /* open coded SO_SNDBUF, SO_RCVBUF */ | ||
583 | if (snd) { | ||
584 | sock->sk->sk_sndbuf = snd; | ||
585 | sock->sk->sk_userlocks |= SOCK_SNDBUF_LOCK; | ||
586 | } | ||
587 | if (rcv) { | ||
588 | sock->sk->sk_rcvbuf = rcv; | ||
589 | sock->sk->sk_userlocks |= SOCK_RCVBUF_LOCK; | ||
590 | } | ||
591 | } | ||
592 | |||
574 | static struct socket *drbd_try_connect(struct drbd_conf *mdev) | 593 | static struct socket *drbd_try_connect(struct drbd_conf *mdev) |
575 | { | 594 | { |
576 | const char *what; | 595 | const char *what; |
@@ -592,6 +611,8 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) | |||
592 | 611 | ||
593 | sock->sk->sk_rcvtimeo = | 612 | sock->sk->sk_rcvtimeo = |
594 | sock->sk->sk_sndtimeo = mdev->net_conf->try_connect_int*HZ; | 613 | sock->sk->sk_sndtimeo = mdev->net_conf->try_connect_int*HZ; |
614 | drbd_setbufsize(sock, mdev->net_conf->sndbuf_size, | ||
615 | mdev->net_conf->rcvbuf_size); | ||
595 | 616 | ||
596 | /* explicitly bind to the configured IP as source IP | 617 | /* explicitly bind to the configured IP as source IP |
597 | * for the outgoing connections. | 618 | * for the outgoing connections. |
@@ -670,6 +691,8 @@ static struct socket *drbd_wait_for_connect(struct drbd_conf *mdev) | |||
670 | s_listen->sk->sk_reuse = 1; /* SO_REUSEADDR */ | 691 | s_listen->sk->sk_reuse = 1; /* SO_REUSEADDR */ |
671 | s_listen->sk->sk_rcvtimeo = timeo; | 692 | s_listen->sk->sk_rcvtimeo = timeo; |
672 | s_listen->sk->sk_sndtimeo = timeo; | 693 | s_listen->sk->sk_sndtimeo = timeo; |
694 | drbd_setbufsize(s_listen, mdev->net_conf->sndbuf_size, | ||
695 | mdev->net_conf->rcvbuf_size); | ||
673 | 696 | ||
674 | what = "bind before listen"; | 697 | what = "bind before listen"; |
675 | err = s_listen->ops->bind(s_listen, | 698 | err = s_listen->ops->bind(s_listen, |
@@ -856,16 +879,6 @@ retry: | |||
856 | sock->sk->sk_priority = TC_PRIO_INTERACTIVE_BULK; | 879 | sock->sk->sk_priority = TC_PRIO_INTERACTIVE_BULK; |
857 | msock->sk->sk_priority = TC_PRIO_INTERACTIVE; | 880 | msock->sk->sk_priority = TC_PRIO_INTERACTIVE; |
858 | 881 | ||
859 | if (mdev->net_conf->sndbuf_size) { | ||
860 | sock->sk->sk_sndbuf = mdev->net_conf->sndbuf_size; | ||
861 | sock->sk->sk_userlocks |= SOCK_SNDBUF_LOCK; | ||
862 | } | ||
863 | |||
864 | if (mdev->net_conf->rcvbuf_size) { | ||
865 | sock->sk->sk_rcvbuf = mdev->net_conf->rcvbuf_size; | ||
866 | sock->sk->sk_userlocks |= SOCK_RCVBUF_LOCK; | ||
867 | } | ||
868 | |||
869 | /* NOT YET ... | 882 | /* NOT YET ... |
870 | * sock->sk->sk_sndtimeo = mdev->net_conf->timeout*HZ/10; | 883 | * sock->sk->sk_sndtimeo = mdev->net_conf->timeout*HZ/10; |
871 | * sock->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT; | 884 | * sock->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT; |