Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drbd: improve resync request throttling due to sendbuf size

If we throttle resync because the socket sendbuffer is filling up,
tell TCP about it, so it may expand the sendbuffer for us.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>

authored by

Lars Ellenberg and committed by
Philipp Reisner
506afb62 659b2e3b

+14 -9
+14 -9
drivers/block/drbd/drbd_worker.c
··· 592 592 const sector_t capacity = drbd_get_capacity(device->this_bdev); 593 593 int max_bio_size; 594 594 int number, rollback_i, size; 595 - int align, queued, sndbuf; 595 + int align, requeue = 0; 596 596 int i = 0; 597 597 598 598 if (unlikely(cancel)) ··· 619 619 goto requeue; 620 620 621 621 for (i = 0; i < number; i++) { 622 - /* Stop generating RS requests, when half of the send buffer is filled */ 622 + /* Stop generating RS requests when half of the send buffer is filled, 623 + * but notify TCP that we'd like to have more space. */ 623 624 mutex_lock(&connection->data.mutex); 624 625 if (connection->data.socket) { 625 - queued = connection->data.socket->sk->sk_wmem_queued; 626 - sndbuf = connection->data.socket->sk->sk_sndbuf; 627 - } else { 628 - queued = 1; 629 - sndbuf = 0; 630 - } 626 + struct sock *sk = connection->data.socket->sk; 627 + int queued = sk->sk_wmem_queued; 628 + int sndbuf = sk->sk_sndbuf; 629 + if (queued > sndbuf / 2) { 630 + requeue = 1; 631 + if (sk->sk_socket) 632 + set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 633 + } 634 + } else 635 + requeue = 1; 631 636 mutex_unlock(&connection->data.mutex); 632 - if (queued > sndbuf / 2) 637 + if (requeue) 633 638 goto requeue; 634 639 635 640 next_sector: